-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreateWDT.cpp
More file actions
76 lines (64 loc) · 1.64 KB
/
CreateWDT.cpp
File metadata and controls
76 lines (64 loc) · 1.64 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
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define DESCRIPTION "Makes a WDT file telling that the specified ADT tiles are present."
#define ARGUMENTS "<MapName> <LowerX> <LowerY> <UpperX> <UpperY>"
#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; \
}
int main(int argc, char **argv)
{
USAGE( 5, argc, argv );
int x,y;
int LowerX,LowerY,UpperX,UpperY,OffsetX,OffsetY;
char temp[512];
FILE *fid;
unsigned int Writing;
LowerX=atoi(argv[2]);
LowerY=atoi(argv[3]);
UpperX=atoi(argv[4]);
UpperY=atoi(argv[5]);
// printf("Range (%d,%d) to (%d,%d)\n",LowerX,LowerY,UpperX,UpperY);
sprintf(temp,"%s.wdt",argv[1]);
fid=fopen(temp,"wb");
Writing=0x4d564552;//MVER
fwrite(&Writing,4,1,fid);
Writing=0x04;
fwrite(&Writing,4,1,fid);
Writing=0x12;
fwrite(&Writing,4,1,fid);
Writing=0x4d504844;//MPHD
fwrite(&Writing,4,1,fid);
Writing=0x20;
fwrite(&Writing,4,1,fid);
Writing=0x0;
for(int i=0;i<8;i++)
fwrite(&Writing,4,1,fid);
Writing=0x4d41494e;//MAIN
fwrite(&Writing,4,1,fid);
Writing=0x8000;
fwrite(&Writing,4,1,fid);
Writing=0;
for(int i=0;i<4096;i++)
{
x=(i%64);
y=i/64;
if ((x>=LowerX) && (x<=UpperX) && (y>=LowerY) && (y<=UpperY))
{
// printf("(%d,%d)\n",x,y);
Writing=1;
}
fwrite(&Writing,4,1,fid);
Writing=0;
fwrite(&Writing,4,1,fid);
}
Writing=0x4d574d4f; //MWMO
fclose(fid);
return 0;
}