-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSetChunkFlags.cpp
More file actions
72 lines (55 loc) · 1.43 KB
/
SetChunkFlags.cpp
File metadata and controls
72 lines (55 loc) · 1.43 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
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define DESCRIPTION "Sets the MCNK flags for all chunks in an ADT."
#define ARGUMENTS "<map filename> [<flag = 8>]\n magma = 16, ocean = 8, river = 4"
#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; \
}
struct MCIN{
unsigned int Offset;
unsigned int Size;
unsigned int Temp1;
unsigned int Temp2;
};
MCIN *Positions;
FILE *Input;
char *File;
unsigned int FileSize;
int main(int argc, char **argv)
{
USAGE( 1, argc, argv );
int flag = 8;
if( argc > 2 )
flag = atoi(argv[2]);
Input = fopen( argv[1], "rb+" );
fseek( Input, 0, SEEK_END );
FileSize = ftell( Input );
File = new char[ FileSize ];
fseek( Input, 0, SEEK_SET );
fread( File, 1, FileSize, Input );
fclose( Input );
Positions = (MCIN *)( File+92 );
unsigned int *TInt;
for( int i = 0; i < 256; i++ )
{
TInt = (unsigned int *)( File + Positions[i].Offset + 8 );
// magma = 16
// ocean = 8
// river = 4
// mask = 00011 = 3
*TInt=*TInt & 3;
*TInt=*TInt | flag;
*TInt=*TInt | 1;
}
Input = fopen( argv[1], "wb" );
fwrite( File, 1, FileSize, Input );
fclose( Input );
delete File;
}