-
Notifications
You must be signed in to change notification settings - Fork 1
/
litfile.c
61 lines (44 loc) · 1.08 KB
/
litfile.c
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
#include "light.h"
byte *dlitdata = NULL;
byte *AllocLitEntry (int offset)
{
// generate the proper data the first time we go in here
if (!dlitdata)
dlitdata = malloc (MAX_MAP_LIGHTING * 3);
// just return a position within the array
return &dlitdata[offset];
}
#define LIT_IDENT 0x54494c51
#define LIT_VERSION 1
void GenerateLITFile (char *source)
{
int i;
FILE *f;
char litfilename[256];
printf ("Generating LIT file... ");
sprintf (litfilename, "%s", source);
for (i = 0; ; i++)
{
// note : these will always happen
if (litfilename[i] == '.' &&
litfilename[i + 1] == 'b' &&
litfilename[i + 2] == 's' &&
litfilename[i + 3] == 'p')
{
litfilename[i + 1] = 'l';
litfilename[i + 2] = 'i';
litfilename[i + 3] = 't';
break;
}
}
f = fopen (litfilename, "wb");
// write the header
i = LIT_IDENT;
fwrite (&i, sizeof (int), 1, f);
i = LIT_VERSION;
fwrite (&i, sizeof (int), 1, f);
// write the entries
fwrite (dlitdata, lightdatasize * 3, 1, f);
fclose (f);
printf ("Done\n");
}