︙ | | | ︙ | |
664
665
666
667
668
669
670
671
672
673
674
675
676
677
|
destroy(n,e[i],3);
}
}
if(obj_layer_at(b,x,y)!=VOIDLINK) r|=0x01;
}
return r;
}
static Uint32 create(Uint32 from,Uint16 c,Uint32 x,Uint32 y,Uint32 im,Uint32 d) {
Uint32 m,n;
int i,xx,yy;
Object*o;
Object*p;
Value v;
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
|
destroy(n,e[i],3);
}
}
if(obj_layer_at(b,x,y)!=VOIDLINK) r|=0x01;
}
return r;
}
static void set_order(Uint32 obj) {
// To avoid confusing order of execution at the wrong time,
// calling this function is limited to only certain times.
Object*o=objects[obj];
Uint8 ord=classes[objects[obj]->class]->order;
Uint8 u;
Sint32 v0,v1;
Uint16 p=orders[ord]+1;
Uint32 n=firstobj;
for(;;) {
if(n==obj || n==VOIDLINK) goto notfound;
u=classes[objects[n]->class]->order;
if(u<ord) goto found;
if(u==ord) {
criteria: switch(orders[p]) {
case OP_RET: goto found;
case OP_DENSITY: v0=o->density; v1=objects[n]->density; goto compare;
case OP_DENSITY_C: v1=o->density; v0=objects[n]->density; goto compare;
case OP_IMAGE: v0=o->image; v1=objects[n]->image; goto compare;
case OP_IMAGE_C: v1=o->image; v0=objects[n]->image; goto compare;
case OP_MISC1:
if(o->misc1.t || objects[n]->misc1.t) Throw("Type mismatch in order criteria");
v0=o->misc1.s; v1=objects[n]->misc1.s; goto compare;
case OP_MISC1_C:
if(o->misc1.t || objects[n]->misc1.t) Throw("Type mismatch in order criteria");
v1=o->misc1.s; v0=objects[n]->misc1.s; goto compare;
case OP_MISC2:
if(o->misc2.t || objects[n]->misc2.t) Throw("Type mismatch in order criteria");
v0=o->misc2.s; v1=objects[n]->misc2.s; goto compare;
case OP_MISC2_C:
if(o->misc2.t || objects[n]->misc2.t) Throw("Type mismatch in order criteria");
v1=o->misc2.s; v0=objects[n]->misc2.s; goto compare;
case OP_MISC3:
if(o->misc3.t || objects[n]->misc3.t) Throw("Type mismatch in order criteria");
v0=o->misc3.s; v1=objects[n]->misc3.s; goto compare;
case OP_MISC3_C:
if(o->misc3.t || objects[n]->misc3.t) Throw("Type mismatch in order criteria");
v1=o->misc3.s; v0=objects[n]->misc3.s; goto compare;
case OP_MISC4:
if(o->misc4.t || objects[n]->misc4.t) Throw("Type mismatch in order criteria");
v0=o->misc4.s; v1=objects[n]->misc4.s; goto compare;
case OP_MISC4_C:
if(o->misc4.t || objects[n]->misc4.t) Throw("Type mismatch in order criteria");
v1=o->misc4.s; v0=objects[n]->misc4.s; goto compare;
case OP_MISC5:
if(o->misc5.t || objects[n]->misc5.t) Throw("Type mismatch in order criteria");
v0=o->misc5.s; v1=objects[n]->misc5.s; goto compare;
case OP_MISC5_C:
if(o->misc5.t || objects[n]->misc5.t) Throw("Type mismatch in order criteria");
v1=o->misc5.s; v0=objects[n]->misc5.s; goto compare;
case OP_MISC6:
if(o->misc6.t || objects[n]->misc6.t) Throw("Type mismatch in order criteria");
v0=o->misc6.s; v1=objects[n]->misc6.s; goto compare;
case OP_MISC6_C:
if(o->misc6.t || objects[n]->misc6.t) Throw("Type mismatch in order criteria");
v1=o->misc6.s; v0=objects[n]->misc6.s; goto compare;
case OP_MISC7:
if(o->misc7.t || objects[n]->misc7.t) Throw("Type mismatch in order criteria");
v0=o->misc7.s; v1=objects[n]->misc7.s; goto compare;
case OP_MISC7_C:
if(o->misc7.t || objects[n]->misc7.t) Throw("Type mismatch in order criteria");
v1=o->misc7.s; v0=objects[n]->misc7.s; goto compare;
case OP_TEMPERATURE: v0=o->temperature; v1=objects[n]->temperature; goto compare;
case OP_TEMPERATURE_C: v1=o->temperature; v0=objects[n]->temperature; goto compare;
case OP_XLOC: v0=o->x; v1=objects[n]->x; goto compare;
case OP_XLOC_C: v1=o->x; v0=objects[n]->x; goto compare;
case OP_YLOC: v0=o->y; v1=objects[n]->y; goto compare;
case OP_YLOC_C: v1=o->y; v0=objects[n]->y; goto compare;
compare:
if(v0==v1) {
p++;
goto criteria;
}
if(v0>v1) goto found;
break;
default: fatal("Internal confusion: Invalid order criteria (%d)\n",orders[p]);
}
}
n=objects[n]->next;
}
found:
// Now it has been found; insert this object previous to the found object, removing from its existing slot.
// (Objects are executed in reverse order, so previous in the linked list means executed next)
if(firstobj==obj) firstobj=o->next;
if(lastobj==obj) lastobj=o->prev;
if(o->prev!=VOIDLINK) objects[o->prev]->next=o->next;
if(o->next!=VOIDLINK) objects[o->next]->prev=o->prev;
o->prev=objects[n]->prev;
o->next=n;
objects[n]->prev=obj;
if(o->prev==VOIDLINK) firstobj=obj;
if(objects[n]->next==VOIDLINK) lastobj=n;
notfound:
objects[obj]->oflags|=OF_ORDERED;
}
static Uint32 create(Uint32 from,Uint16 c,Uint32 x,Uint32 y,Uint32 im,Uint32 d) {
Uint32 m,n;
int i,xx,yy;
Object*o;
Object*p;
Value v;
|
︙ | | | ︙ | |
699
700
701
702
703
704
705
706
707
708
709
710
711
712
|
while(m!=VOIDLINK) {
p=objects[m];
if(p->arrivals&(1<<i)) if(m!=n) send_message(n,m,MSG_CREATED,NVALUE(o->x),NVALUE(o->y),v);
m=p->up;
}
}
if(o->oflags&OF_DESTROYED) return VOIDLINK;
m=objects[n]->up;
if(m!=VOIDLINK) {
v=send_message(VOIDLINK,n,MSG_SUNK,NVALUE(0),NVALUE(0),v);
while(m!=VOIDLINK) {
send_message(n,m,MSG_FLOATED,NVALUE(0),NVALUE(0),v);
m=objects[m]->up;
}
|
>
|
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
|
while(m!=VOIDLINK) {
p=objects[m];
if(p->arrivals&(1<<i)) if(m!=n) send_message(n,m,MSG_CREATED,NVALUE(o->x),NVALUE(o->y),v);
m=p->up;
}
}
if(o->oflags&OF_DESTROYED) return VOIDLINK;
if(classes[objects[n]->class]->order) set_order(n);
m=objects[n]->up;
if(m!=VOIDLINK) {
v=send_message(VOIDLINK,n,MSG_SUNK,NVALUE(0),NVALUE(0),v);
while(m!=VOIDLINK) {
send_message(n,m,MSG_FLOATED,NVALUE(0),NVALUE(0),v);
m=objects[m]->up;
}
|
︙ | | | ︙ | |
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
|
if(generation_number<=TY_MAXTYPE) return "Too many generations of objects";
if(firstobj==VOIDLINK) return "Game cannot continue with no objects";
// Finished
return 0;
}
const char*init_level(void) {
if(setjmp(my_env)) return my_error;
clear_inventory();
if(main_options['t']) {
printf("[Level %d restarted]\n",level_id);
if(!traced_obj.t) {
const char*s;
optionquery[1]=Q_traceObject;
|
>
|
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
|
if(generation_number<=TY_MAXTYPE) return "Too many generations of objects";
if(firstobj==VOIDLINK) return "Game cannot continue with no objects";
// Finished
return 0;
}
const char*init_level(void) {
Uint32 n;
if(setjmp(my_env)) return my_error;
clear_inventory();
if(main_options['t']) {
printf("[Level %d restarted]\n",level_id);
if(!traced_obj.t) {
const char*s;
optionquery[1]=Q_traceObject;
|
︙ | | | ︙ | |
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
|
changed=0;
key_ignored=0;
all_flushed=0;
lastimage_processing=0;
vstackptr=0;
move_number=0;
current_key=0;
broadcast(VOIDLINK,0,MSG_INIT,NVALUE(0),NVALUE(0),NVALUE(0),0);
broadcast(VOIDLINK,0,MSG_POSTINIT,NVALUE(0),NVALUE(0),NVALUE(0),0);
if(gameover) return 0;
return execute_turn(0);
}
|
>
>
|
>
>
>
|
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
|
changed=0;
key_ignored=0;
all_flushed=0;
lastimage_processing=0;
vstackptr=0;
move_number=0;
current_key=0;
n=lastobj;
while(n!=VOIDLINK && !(objects[n]->oflags&OF_ORDERED)) {
send_message(VOIDLINK,n,MSG_INIT,NVALUE(0),NVALUE(0),NVALUE(0));
if(classes[objects[n]->class]->order && !(objects[n]->oflags&OF_DESTROYED)) set_order(n);
n=objects[n]->prev;
}
broadcast(VOIDLINK,0,MSG_POSTINIT,NVALUE(0),NVALUE(0),NVALUE(0),0);
if(gameover) return 0;
return execute_turn(0);
}
|