44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
static MessageVars msgvars;
static char lastimage_processing,changed,all_flushed;
static Value vstack[VSTACKSIZE];
static int vstackptr;
static const char*traceprefix;
static Uint8 current_key;
static Value quiz_obj;
#define Throw(x) (my_error=(x),longjmp(my_env,1))
#define StackReq(x,y) do{ if(vstackptr<(x)) Throw("Stack underflow"); if(vstackptr-(x)+(y)>=VSTACKSIZE) Throw("Stack overflow"); }while(0)
#define Push(x) (vstack[vstackptr++]=(x))
#define Pop() (vstack[--vstackptr])
// For arrival/departure masks
|
>
|
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
static MessageVars msgvars;
static char lastimage_processing,changed,all_flushed;
static Value vstack[VSTACKSIZE];
static int vstackptr;
static const char*traceprefix;
static Uint8 current_key;
static Value quiz_obj;
static Value traced_obj;
#define Throw(x) (my_error=(x),longjmp(my_env,1))
#define StackReq(x,y) do{ if(vstackptr<(x)) Throw("Stack underflow"); if(vstackptr-(x)+(y)>=VSTACKSIZE) Throw("Stack overflow"); }while(0)
#define Push(x) (vstack[vstackptr++]=(x))
#define Pop() (vstack[--vstackptr])
// For arrival/departure masks
|
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
}
#define animfree free
void objtrash(Uint32 n) {
Object*o=objects[n];
if(!o) return;
animfree(o->anim);
if(o->down==VOIDLINK) playfield[o->x+o->y*64-65]=o->up;
else objects[o->down]->up=o->up;
if(o->up!=VOIDLINK) objects[o->up]->down=o->down;
if(!(o->oflags&OF_DESTROYED)) {
if(firstobj==n) firstobj=o->next;
if(lastobj==n) lastobj=o->prev;
|
>
>
>
>
|
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
}
#define animfree free
void objtrash(Uint32 n) {
Object*o=objects[n];
if(!o) return;
if(n==traced_obj.u && o->generation==traced_obj.t && main_options['t'] && !main_options['e']) {
printf("# Object traced at (%d,%d)\n",o->x,o->y);
Throw("Object traced");
}
animfree(o->anim);
if(o->down==VOIDLINK) playfield[o->x+o->y*64-65]=o->up;
else objects[o->down]->up=o->up;
if(o->up!=VOIDLINK) objects[o->up]->down=o->down;
if(!(o->oflags&OF_DESTROYED)) {
if(firstobj==n) firstobj=o->next;
if(lastobj==n) lastobj=o->prev;
|
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
|
static Uint32 v_object(Value v) {
if(v.t==TY_NUMBER) {
if(v.u) Throw("Cannot convert non-zero number to object");
return VOIDLINK;
} else if(v.t>TY_MAXTYPE) {
if(v.u>=nobjects || !objects[v.u] || objects[v.u]->generation!=v.t) {
if(main_options['t']) printf("Object %lu in generation %lu does not exist\n",(long)v.u,(long)v.t);
Throw("Attempt to use a nonexistent object");
}
return v.u;
} else {
Throw("Cannot convert non-object to object");
}
}
|
|
|
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
|
static Uint32 v_object(Value v) {
if(v.t==TY_NUMBER) {
if(v.u) Throw("Cannot convert non-zero number to object");
return VOIDLINK;
} else if(v.t>TY_MAXTYPE) {
if(v.u>=nobjects || !objects[v.u] || objects[v.u]->generation!=v.t) {
if(main_options['t']) printf("[Object %lu in generation %lu does not exist]\n",(long)v.u,(long)v.t);
Throw("Attempt to use a nonexistent object");
}
return v.u;
} else {
Throw("Cannot convert non-object to object");
}
}
|
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
|
if(generation_number<=TY_MAXTYPE) return "Too many generations of objects";
// Finished
return 0;
}
const char*init_level(void) {
if(setjmp(my_env)) return my_error;
if(main_options['t']) printf("[Level %d restarted]\n",level_id);
memcpy(globals,initglobals,sizeof(globals));
quiz_obj=NVALUE(0);
gameover=0;
changed=0;
key_ignored=0;
all_flushed=0;
lastimage_processing=0;
|
>
|
>
>
>
>
>
>
>
>
>
>
>
>
|
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
|
if(generation_number<=TY_MAXTYPE) return "Too many generations of objects";
// Finished
return 0;
}
const char*init_level(void) {
if(setjmp(my_env)) return my_error;
if(main_options['t']) {
printf("[Level %d restarted]\n",level_id);
if(!traced_obj.t) {
const char*s;
optionquery[1]=Q_traceObject;
if(s=xrm_get_resource(resourcedb,optionquery,optionquery,2)) {
traced_obj.u=strtol(s,(char**)&s,10);
if(*s==':') traced_obj.t=strtol(s+1,0,10);
printf("Tracing object <%ld:%ld>\n",(long)traced_obj.u,(long)traced_obj.t);
} else {
traced_obj.t=TY_FOR;
}
}
}
memcpy(globals,initglobals,sizeof(globals));
quiz_obj=NVALUE(0);
gameover=0;
changed=0;
key_ignored=0;
all_flushed=0;
lastimage_processing=0;
|