Index: class.c ================================================================== --- class.c +++ class.c @@ -2110,10 +2110,11 @@ static void parse_order_block(void) { // OP_MISC1, OP_MISC1_C, etc = properties (_C=reverse) // 0x1000...0x10FF = Have flag // OP_RET = end of block Uint16 beg,ptr; + ParseError("(Not implemented yet)\n"); //TODO: remove this when it is implemented in exec.c too orders=malloc(0x4000*sizeof(Uint16)); if(!orders) fatal("Allocation failed\n"); nxttok(); if(tokent==TF_INT) { if(tokenv<1 || tokenv>254) ParseError("Order number out of range\n"); @@ -2125,12 +2126,12 @@ while(tokent!=TF_CLOSE) { if(tokent!=TF_OPEN) ParseError("Open or close parenthesis expected\n"); if(ptr>=0x3FFD) ParseError("Out of order memory\n"); nxttok(); if(Tokenf(TF_MACRO|TF_COMMA|TF_EQUAL) || !Tokenf(TF_NAME)) ParseError("Unexpected token in (Order) block\n"); + orders[++norders]=ptr; if(norders==beg) ParseError("Too many orders\n"); - orders[norders++]=ptr; switch(tokenv) { case OP_INPUT: case OP_PLAYER: orders[ptr++]=tokenv; break; case OP_USERFLAG: @@ -2167,11 +2168,27 @@ if(!norders) ParseError("Empty (Order) block\n"); orders=realloc(orders,ptr*sizeof(Uint16))?:orders; } static void set_class_orders(void) { - //TODO + int i,j,k; + for(i=1;icflags&(CF_GROUP|CF_NOCLASS2))) { + for(j=1;jmisc4&(1UL<<(k&0x1F))) goto found; break; + case 0x1020 ... 0x103F: if(classes[i]->misc5&(1UL<<(k&0x1F))) goto found; break; + case 0x1040 ... 0x105F: if(classes[i]->misc6&(1UL<<(k&0x1F))) goto found; break; + case 0x1060 ... 0x107F: if(classes[i]->misc7&(1UL<<(k&0x1F))) goto found; break; + case 0x1080 ... 0x1087: if(classes[i]->collisionLayers&(1L<<(k&0x07))) goto found; break; + case OP_PLAYER: if(classes[i]->cflags&CF_PLAYER) goto found; break; + case OP_INPUT: if(classes[i]->cflags&CF_INPUT) goto found; break; + } + continue; + found: classes[i]->order=j; break; + } + } } void load_classes(void) { int i; int gloptr=0; @@ -2305,11 +2322,11 @@ break; case OP_MISC4: define_user_flags(0x1000,0x101F); break; case OP_MISC5: define_user_flags(0x1020,0x103F); break; case OP_MISC6: define_user_flags(0x1040,0x105F); break; case OP_MISC7: define_user_flags(0x1060,0x107F); break; - case OP_COLLISIONLAYERS: define_user_flags(0x1C80,0x1C87); break; + case OP_COLLISIONLAYERS: define_user_flags(0x1080,0x1087); break; case OP_CODEPAGE: nxttok(); if(tokent!=TF_INT || tokenv<1 || tokenv>65535) ParseError("Number from 1 to 65535 expected\n"); set_code_page(tokenv); nxttok(); Index: class.doc ================================================================== --- class.doc +++ class.doc @@ -286,10 +286,13 @@ (Misc7 ) Define user flags as Misc7 bits; the first defined flag is bit0. Up to 32 flags can be defined in this way. +(Order ) + (Not fully implemented yet.) + (Synchronize ) Define an animation slot for synchronized animation. The slot number can be 0 to 7, the length is the number of images in the sequence, and the speed is the number of centiseconds between frames. @@ -2464,10 +2467,39 @@ Ends a block started with begin or if. Trace Used for debugging. + +=== Order of execution === + +(The below describes a feature that is not implemented yet; currently +only the syntax is implemented. When it is completed, this note will be +removed and further descriptions will be added below.) + +You can specify the order of execution of objects by class by a global +(Order) block. Inside of this block is a list of sub-lists; each sub-list +is delimited by parentheses. + +Each sub-list starts with a flag name, which may be a user flag, or Input, +or Player. This matches only classes that have that flag (changing that +flag at run time has no effect on order of execution). The remaining +elements are optional; if they are present, they are used to break ties. +First, the second item breaks ties if there is one, and then if there is +still a tie then the third item breaks ties, etc. These extra elements +can be one of the following, with or without a comma: Misc1, Misc2, Misc3, +Misc4, Misc5, Misc6, Misc7, Temperature, Density, Xloc, Yloc, Image. If +there is no comma, they are lowest to highest, but a comma reverses the +order to be highest to lowest instead. These values are treated as signed, +and the values after INIT or CREATE message returns is used. If any of +the values is not a number, then it is an error. + +The order of execution is then first all objects not listed in the (Order) +block, and then for each sub-list in the (Order) block, the objects that +meet that criteria, in that order. (If it meets multiple criteria, only +the first one that meets that criteria is used.) + === Compatibility === Compatible objects have the following differences from the default: