39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
sqlite3*userdb;
xrm_db*resourcedb;
const char*basefilename;
xrm_quark optionquery[16];
char main_options[128];
Uint8 message_trace[0x4100/8];
#ifdef __GNUC__
char stack_protect_mode=0;
void*stack_protect_mark;
void*stack_protect_low;
void*stack_protect_high;
#endif
|
>
>
>
>
| 39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
sqlite3*userdb;
xrm_db*resourcedb;
const char*basefilename;
xrm_quark optionquery[16];
char main_options[128];
Uint8 message_trace[0x4100/8];
Uint16 level_id,level_ord,level_version,level_code;
unsigned char*level_title;
Uint16*level_index;
int level_nindex;
#ifdef __GNUC__
char stack_protect_mode=0;
void*stack_protect_mark;
void*stack_protect_low;
void*stack_protect_high;
#endif
|
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
| unsigned char*p=buf;
unsigned char*end=buf+sz;
int i,n,x,y,z;
Uint32 o;
Uint32 mru[2];
if(lvl<0) return "Invalid level ID";
if(!buf) return "Cannot find level";
annihilate();
generation_number=TY_MAXTYPE+1;
p+=4; // skip level version and level code for now
pfwidth=(*p++&63)+1;
pfheight=(*p++&63)+1;
while(*p && p<end) p++; // skip text for now
p++; // skip null terminator
if(p==end) goto bad1;
x=0;
y=1;
n=0;
mru[0]=mru[1]=VOIDLINK;
for(;;) {
if(n) {
o=objalloc(objects[*mru]->class);
|
>
>
>
>
|
|
>
>
| 189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
| unsigned char*p=buf;
unsigned char*end=buf+sz;
int i,n,x,y,z;
Uint32 o;
Uint32 mru[2];
if(lvl<0) return "Invalid level ID";
if(!buf) return "Cannot find level";
free(level_title);
level_title=0;
annihilate();
generation_number=TY_MAXTYPE+1;
level_version=p[0]|(p[1]<<8);
level_code=p[2]|(p[3]<<8);
p+=4;
pfwidth=(*p++&63)+1;
pfheight=(*p++&63)+1;
while(*p && p<end) p++; // skip text for now
p++; // skip null terminator
if(p>=end) goto bad1;
level_title=strdup(buf+6);
if(!level_title) fatal("Allocation failed\n");
x=0;
y=1;
n=0;
mru[0]=mru[1]=VOIDLINK;
for(;;) {
if(n) {
o=objalloc(objects[*mru]->class);
|
283
284
285
286
287
288
289
290
291
292
293
294
295
296
| n=0;
}
}
}
// skip level strings for now
if(p>end) goto bad1;
free(buf);
return 0;
bad1:
free(buf);
return "Corrupted level data";
bad2:
free(buf);
return "Object out of bounds";
|
>
| 293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
| n=0;
}
}
}
// skip level strings for now
if(p>end) goto bad1;
free(buf);
level_id=lvl;
return 0;
bad1:
free(buf);
return "Corrupted level data";
bad2:
free(buf);
return "Object out of bounds";
|