-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRemoveTheWalls.cpp
More file actions
113 lines (86 loc) · 1.94 KB
/
RemoveTheWalls.cpp
File metadata and controls
113 lines (86 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define DESCRIPTION "Removes unpassable chunks of an ADT."
#define ARGUMENTS "<map filename>"
#define USAGE( minimumArguments, argc, argv ) \
if( argc < minimumArguments + 1 ) \
{ \
printf( " %s\n", argv[0] ); \
printf( " " DESCRIPTION "\n\n" ); \
printf( " Usage: \"%s " ARGUMENTS "\"\n", argv[0] ); \
printf( " Built at: " __DATE__ "\n" ); \
return -1; \
}
FILE *Input;
int XOffset,YOffset;
float WaterLevel;
/*
MCNK
0x14 MCVT Offset
0x18 MCNR Offset
0x1C MCLY Offset
0x20 MCRF Offset
0x24 MCAL Offset
0x2C MCSH Offset
0x58 MCSE Offset
0x60 MCLQ Offset
0x68 Z' Base Coordinate
0x6C X' Base Coordinate
0x70 Y Base Coordinate
*/
struct MCIN{
unsigned int Offset;
unsigned int Size;
unsigned int Temp1;
unsigned int Temp2;
};
unsigned int MDDF_Offset;
unsigned int MODF_Offset;
MCIN *Positions;
unsigned int MCLQ_Positions[256];
unsigned int MCSE_Positions[256];
char *File;
unsigned int FileSize;
char *NewFile;
unsigned int NewFileSize;
unsigned int Change;
void FindMCNKs()
{
Positions=(MCIN *)(File+92);
}
void FixFlags()
{
unsigned int *TFloat;
unsigned int *TInt;
for (int i=0;i<256;i++)
{
TInt=(unsigned int *)(File+Positions[i].Offset+8);
if(*TInt&0x02)
{
printf("Found Invisible Wall Chunk %d (Flag %x)\n",i,*TInt);
*TInt=*TInt^0x02;
fseek(Input,Positions[i].Offset+8,SEEK_SET);
fwrite(TInt,sizeof(unsigned int),1,Input);
}
}
}
int main(int argc, char **argv)
{
USAGE( 1, argc, argv );
char *replace;
int i,len;
printf("Removing Walls from File %s\n",argv[1]);
Input=fopen(argv[1],"rb+");
fseek(Input,0,SEEK_END);
FileSize=ftell(Input);
NewFileSize=FileSize;
File=new char[FileSize];
fseek(Input,0,SEEK_SET);
fread(File,1,FileSize,Input);
Change=0;
FindMCNKs();
FixFlags();
fclose(Input);
delete File;
}