Index: class.c ================================================================== --- class.c +++ class.c @@ -22,11 +22,10 @@ #define TF_COMPAT 0x0008 #define TF_DIR 0x0010 #define TF_DROP 0x0020 #define TF_NAME 0x0080 #define TF_KEY 0x0100 -#define TF_STRING 0x0200 #define TF_OPEN 0x0400 #define TF_CLOSE 0x0800 #define TF_INT 0x1000 #define TF_MACRO 0x4000 #define TF_EOF 0x8000 @@ -33,10 +32,11 @@ typedef struct { const char*txt; Uint32 num; } Op_Names; #include "instruc.h" +#define Tokenf(x) (tokent&(x)) Class*classes[0x4000]; const char*messages[0x4000]; int max_animation=32; Sint32 max_volume=10000; @@ -109,10 +109,63 @@ static int name_compar(const void*a,const void*b) { const Op_Names*x=a; const Op_Names*y=b; return strcmp(x->txt,y->txt); } + +static Class*initialize_class(int n,int f,const char*name) { + Class*cl; + if(classes[n]) fatal("Duplicate class number %d\n",n); + cl=classes[n]=malloc(sizeof(Class)); + if(!cl) fatal("Allocation failed\n"); + cl->name=strdup(name); + if(!cl->name) fatal("Allocation failed\n"); + cl->edithelp=cl->gamehelp=0; + cl->codes=cl->messages=cl->images=0; + cl->height=cl->weight=cl->climb=cl->density=cl->volume=cl->strength=cl->arrivals=cl->departures=0; + cl->temperature=cl->misc4=cl->misc5=cl->misc6=cl->misc7=0; + cl->uservars=cl->hard[0]=cl->hard[1]=cl->hard[2]=cl->hard[3]=0; + cl->oflags=cl->sharp[0]=cl->sharp[1]=cl->sharp[2]=cl->sharp[3]=0; + cl->shape=cl->shovable=cl->collisionLayers=cl->nimages=0; + cl->cflags=f; + if(undef_class<=n) undef_class=n+1; +} + +static int look_class_name(void) { + int i; + int u=undef_class; + for(i=1;iname,tokenstr)) { + if(classes[i]->cflags&CF_NOCLASS2) classes[i]->cflags|=CF_NOCLASS1; + return i; + } + } else { + u=i; + } + } + if(u==0x4000) ParseError("Too many class names; cannot add $%s\n",tokenstr); + initialize_class(u,CF_NOCLASS1,tokenstr); + return u; +} + +static int look_message_name(void) { + int i; + int u=undef_message; + for(i=0;inum&0xFFFF; tokent=op->num>>16; if(fl&~tokent) ParseError("Invalid use of , and = in token: %s\n",tokenstr); - + if(fl&TF_COMMA) tokenv+=0x0800; + if(fl&TF_EQUAL) tokenv+=0x1000; + tokent&=fl|~(TF_COMMA|TF_EQUAL); } break; case '$': - + if(fl) ParseError("Invalid use of , and = in token\n"); + tokent=TF_NAME; + tokenv=look_class_name()+0x4000; break; case '!': // Just ignore sounds for now - if(fl) ParseError("Invalid use of , and = in user sound token\n"); + if(fl) ParseError("Invalid use of , and = in token\n"); tokent=TF_NAME; tokenv=0x0400; break; case '%': - + if(fl&TF_COMMA) ParseError("Invalid use of , in token\n"); + tokent=TF_NAME|fl; + tokenv=OP_LOCAL; break; case '@': + if(fl&TF_COMMA) ParseError("Invalid use of , in token\n"); + tokent=TF_NAME|fl; break; case '#': - + if(fl) ParseError("Invalid use of , and = in token\n"); + tokent=TF_NAME; + tokenv=look_message_name()+0xC000; break; case ':': - + tokent=TF_NAME|TF_ABNORMAL|fl; + tokenv=OP_LABEL; break; case '&': break; case '\'': - + if(fl) ParseError("Invalid use of , and = in token\n"); + tokent=TF_NAME|TF_KEY; + for(i=8;i<256;i++) { + if(heromesh_key_names[i] && !strcmp(heromesh_key_names[i],tokenstr)) { + tokenv=i; + return; + } + } + ParseError("Invalid Hero Mesh key name: %s\n",tokenstr); break; } } void load_classes(void) { + int i; + for(i=1;icflags&CF_NOCLASS1)) fatal("Class $%s mentioned but not defined",classes[i]->name); } Index: heromesh.h ================================================================== --- heromesh.h +++ heromesh.h @@ -76,14 +76,14 @@ Sint32 height,weight,climb,density,volume,strength,arrivals,departures; Sint32 temperature,misc4,misc5,misc6,misc7; Uint16 uservars,oflags; Uint16 sharp[4]; Uint16 hard[4]; - Uint8 cflags,shape,shovable,collisionLayers; + Uint8 cflags,shape,shovable,collisionLayers,nimages; } Class; -extern Class*classes[0x4000]; // 0 isn't used +extern Class*classes[0x4000]; // 0 isn't a real class extern const char*messages[0x4000]; // index is 256 less than message number extern int max_animation; // max steps in animation queue (default 32) extern Sint32 max_volume; // max total volume to allow moving diagonally (default 10000) void load_classes(void); Index: instruc ================================================================== --- instruc +++ instruc @@ -179,15 +179,15 @@ -EditorHelp -SUBS ; Main operations Animate -,Assassinate +,Assassinate ; destroy without sending any messages .Broadcast -*BroadcastClass -.BroadcastEx -BroadcastSum +*BroadcastClass ; for (Broadcast [class]) +.BroadcastEx ; broadcast with three arguments +BroadcastSum ; Broadcast, but result is sum of return values BroadcastSumEx .Create DelInventory Delta .,Destroy @@ -194,29 +194,30 @@ FlushClass FlushObj GetInventory HeightAt IgnoreKey -.,IntMove +.,IntMove ; move without initializing Inertia ,JumpTo -,Loc +,Loc ; same as: Xloc Yloc LocateMe LoseLevel -MaxInventory +MaxInventory ; error if more than that many slots in inventory .,Move -.,MovePlus "Move+" -.,MoveTo +.,MovePlus "Move+" ; obj.Inertia+=Strength instead of obj.Inertia=Strength +.,MoveTo ; the internal MoveTo() function NewX NewY ,ObjAbove ObjClassAt ,ObjBelow ,ObjDir PopUp -*PopUpArgs +*PopUpArgs ; for (PopUp [number]) +QueueTurn ; queue another turn that automatically occurs after this one .,Send -.,SendEx +.,SendEx ; send with three arguments SetInventory Sound Trace VolumeAt WinLevel Index: instruc.h ================================================================== --- instruc.h +++ instruc.h @@ -308,31 +308,32 @@ #define OP_OBJBELOW_C 34958 #define OP_OBJDIR 32911 #define OP_OBJDIR_C 34959 #define OP_POPUP 32912 #define OP_POPUPARGS 32913 -#define OP_SEND 32914 -#define OP_SEND_C 34962 -#define OP_SEND_D 41106 -#define OP_SEND_CD 43154 -#define OP_SENDEX 32915 -#define OP_SENDEX_C 34963 -#define OP_SENDEX_D 41107 -#define OP_SENDEX_CD 43155 -#define OP_SETINVENTORY 32916 -#define OP_SOUND 32917 -#define OP_TRACE 32918 -#define OP_VOLUMEAT 32919 -#define OP_WINLEVEL 32920 -#define OP_XDIR 32921 -#define OP_XDIR_C 34969 -#define OP_YDIR 32922 -#define OP_YDIR_C 34970 -#define OP_FUNCTION 32923 -#define OP_LOCAL 32924 -#define OP_LABEL 32925 -#define OP_STRING 32926 +#define OP_QUEUETURN 32914 +#define OP_SEND 32915 +#define OP_SEND_C 34963 +#define OP_SEND_D 41107 +#define OP_SEND_CD 43155 +#define OP_SENDEX 32916 +#define OP_SENDEX_C 34964 +#define OP_SENDEX_D 41108 +#define OP_SENDEX_CD 43156 +#define OP_SETINVENTORY 32917 +#define OP_SOUND 32918 +#define OP_TRACE 32919 +#define OP_VOLUMEAT 32920 +#define OP_WINLEVEL 32921 +#define OP_XDIR 32922 +#define OP_XDIR_C 34970 +#define OP_YDIR 32923 +#define OP_YDIR_C 34971 +#define OP_FUNCTION 32924 +#define OP_LOCAL 32925 +#define OP_LABEL 32926 +#define OP_STRING 32927 #ifdef HEROMESH_CLASS static const Op_Names op_names[]={ {"*",8486933}, {"+",8421395}, {"-",8421396}, @@ -473,10 +474,11 @@ {"PLAYERMOVING",8389133}, {"POSTINIT",8389138}, {"POUR",8389377}, {"POWER",8389386}, {"PopUp",8421520}, +{"QueueTurn",8421522}, {"Quiz",8683627}, {"R",9437198}, {"RATCHET1",8389418}, {"RATCHET2",8389412}, {"RATTLE",8389403}, @@ -490,42 +492,42 @@ {"STOP",8388608}, {"SUBS",8683632}, {"SUNK",8389131}, {"SW",9437189}, {"Self",8421474}, -{"Send",10584210}, -{"SendEx",10584211}, -{"SetInventory",8421524}, +{"Send",10584211}, +{"SendEx",10584212}, +{"SetInventory",8421525}, {"Shape",8618030}, {"ShapeDir",8618053}, {"Sharp",8618052}, {"Shovable",8618054}, -{"Sound",8421525}, +{"Sound",8421526}, {"Stealthy",8618078}, {"Strength",9142337}, {"TAHTASHH",8389409}, {"THMP_thmp",8389405}, {"THWIT",8389384}, {"TICK",8389391}, {"Temperature",9142316}, -{"Trace",8421526}, +{"Trace",8421527}, {"UH_OH",8389382}, {"UNCORK",8389414}, {"UNHH",8389381}, {"UserSignal",8618076}, {"VACUUM",8389411}, {"VisualOnly",8618077}, {"Volume",9142329}, -{"VolumeAt",8421527}, +{"VolumeAt",8421528}, {"W",9437188}, {"WAHOO",8389400}, {"WHACK",8389423}, {"Weight",9142331}, -{"WinLevel",8421528}, -{"XDir",8487065}, +{"WinLevel",8421529}, +{"XDir",8487066}, {"Xloc",8486959}, -{"YDir",8487066}, +{"YDir",8487067}, {"YEEHAW",8389401}, {"Yloc",8486960}, {"again",8683530}, {"band",8421403}, {"begin",8683529}, @@ -593,7 +595,7 @@ {"then",8683527}, {"tuck",8421380}, {"until",8683531}, {"while",8683532}, }; -#define N_OP_NAMES 261 +#define N_OP_NAMES 262 #endif Index: quarks ================================================================== --- quarks +++ quarks @@ -206,6 +206,7 @@ sqlCoveringIndexScan sqlPowerSafe ! Miscellaneous level +tracePrefix