mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-24 10:40:46 +00:00
Patch from hunter_rus to use hash tables for CON compiling
This was sent to me broken, but after some investigation it looks like the only problem was in CON_STATE. This should speed up CON compilation speed about 500%or so. git-svn-id: https://svn.eduke32.com/eduke32@1024 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
07b71b1139
commit
25adc68899
6 changed files with 574 additions and 414 deletions
|
@ -333,65 +333,65 @@ struct savehead {
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int UseJoystick;
|
int UseJoystick;
|
||||||
int UseMouse;
|
int UseMouse;
|
||||||
int RunMode;
|
int RunMode;
|
||||||
int AutoAim;
|
int AutoAim;
|
||||||
int ShowOpponentWeapons;
|
int ShowOpponentWeapons;
|
||||||
int MouseFilter,MouseBias;
|
int MouseFilter,MouseBias;
|
||||||
int SmoothInput;
|
int SmoothInput;
|
||||||
|
|
||||||
// JBF 20031211: Store the input settings because
|
// JBF 20031211: Store the input settings because
|
||||||
// (currently) jmact can't regurgitate them
|
// (currently) jmact can't regurgitate them
|
||||||
int MouseFunctions[MAXMOUSEBUTTONS][2];
|
int MouseFunctions[MAXMOUSEBUTTONS][2];
|
||||||
int MouseDigitalFunctions[MAXMOUSEAXES][2];
|
int MouseDigitalFunctions[MAXMOUSEAXES][2];
|
||||||
int MouseAnalogueAxes[MAXMOUSEAXES];
|
int MouseAnalogueAxes[MAXMOUSEAXES];
|
||||||
int MouseAnalogueScale[MAXMOUSEAXES];
|
int MouseAnalogueScale[MAXMOUSEAXES];
|
||||||
int JoystickFunctions[MAXJOYBUTTONS][2];
|
int JoystickFunctions[MAXJOYBUTTONS][2];
|
||||||
int JoystickDigitalFunctions[MAXJOYAXES][2];
|
int JoystickDigitalFunctions[MAXJOYAXES][2];
|
||||||
int JoystickAnalogueAxes[MAXJOYAXES];
|
int JoystickAnalogueAxes[MAXJOYAXES];
|
||||||
int JoystickAnalogueScale[MAXJOYAXES];
|
int JoystickAnalogueScale[MAXJOYAXES];
|
||||||
int JoystickAnalogueDead[MAXJOYAXES];
|
int JoystickAnalogueDead[MAXJOYAXES];
|
||||||
int JoystickAnalogueSaturate[MAXJOYAXES];
|
int JoystickAnalogueSaturate[MAXJOYAXES];
|
||||||
byte KeyboardKeys[NUMGAMEFUNCTIONS][2];
|
byte KeyboardKeys[NUMGAMEFUNCTIONS][2];
|
||||||
|
|
||||||
//
|
//
|
||||||
// Sound variables
|
// Sound variables
|
||||||
//
|
//
|
||||||
int FXDevice;
|
int FXDevice;
|
||||||
int MusicDevice;
|
int MusicDevice;
|
||||||
int FXVolume;
|
int FXVolume;
|
||||||
int MusicVolume;
|
int MusicVolume;
|
||||||
int SoundToggle;
|
int SoundToggle;
|
||||||
int MusicToggle;
|
int MusicToggle;
|
||||||
int VoiceToggle;
|
int VoiceToggle;
|
||||||
int AmbienceToggle;
|
int AmbienceToggle;
|
||||||
|
|
||||||
int NumVoices;
|
int NumVoices;
|
||||||
int NumChannels;
|
int NumChannels;
|
||||||
int NumBits;
|
int NumBits;
|
||||||
int MixRate;
|
int MixRate;
|
||||||
|
|
||||||
int ReverseStereo;
|
int ReverseStereo;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Screen variables
|
// Screen variables
|
||||||
//
|
//
|
||||||
|
|
||||||
int ScreenMode;
|
int ScreenMode;
|
||||||
|
|
||||||
int ScreenWidth;
|
int ScreenWidth;
|
||||||
int ScreenHeight;
|
int ScreenHeight;
|
||||||
int ScreenBPP;
|
int ScreenBPP;
|
||||||
|
|
||||||
int ForceSetup;
|
int ForceSetup;
|
||||||
|
|
||||||
int scripthandle;
|
int scripthandle;
|
||||||
int setupread;
|
int setupread;
|
||||||
|
|
||||||
int CheckForUpdates;
|
int CheckForUpdates;
|
||||||
int LastUpdateCheck;
|
int LastUpdateCheck;
|
||||||
int useprecache;
|
int useprecache;
|
||||||
} config_t;
|
} config_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -402,7 +402,7 @@ typedef struct {
|
||||||
int runkey_mode,statusbarscale,mouseaiming,weaponswitch,drawweapon; // JBF 20031125
|
int runkey_mode,statusbarscale,mouseaiming,weaponswitch,drawweapon; // JBF 20031125
|
||||||
int democams,color,msgdisptime,statusbarmode;
|
int democams,color,msgdisptime,statusbarmode;
|
||||||
int m_noexits,noexits,autovote,automsg,idplayers;
|
int m_noexits,noexits,autovote,automsg,idplayers;
|
||||||
int team, viewbob, weaponsway, althud;
|
int team, viewbob, weaponsway, althud;
|
||||||
|
|
||||||
int entered_name,screen_tilting,shadows,fta_on,executions,auto_run;
|
int entered_name,screen_tilting,shadows,fta_on,executions,auto_run;
|
||||||
int coords,tickrate,levelstats,m_coop,coop,screen_size,lockout,crosshair;
|
int coords,tickrate,levelstats,m_coop,coop,screen_size,lockout,crosshair;
|
||||||
|
@ -429,7 +429,7 @@ typedef struct {
|
||||||
char pwlockout[128],rtsname[128];
|
char pwlockout[128],rtsname[128];
|
||||||
char display_bonus_screen;
|
char display_bonus_screen;
|
||||||
|
|
||||||
config_t config;
|
config_t config;
|
||||||
} user_defs;
|
} user_defs;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -627,8 +627,8 @@ enum gametypeflags {
|
||||||
GAMETYPE_FLAG_FIXEDRESPAWN = 8192,
|
GAMETYPE_FLAG_FIXEDRESPAWN = 8192,
|
||||||
GAMETYPE_FLAG_ACCESSATSTART = 16384,
|
GAMETYPE_FLAG_ACCESSATSTART = 16384,
|
||||||
GAMETYPE_FLAG_PRESERVEINVENTORYDEATH = 32768,
|
GAMETYPE_FLAG_PRESERVEINVENTORYDEATH = 32768,
|
||||||
GAMETYPE_FLAG_TDM = 65536,
|
GAMETYPE_FLAG_TDM = 65536,
|
||||||
GAMETYPE_FLAG_TDMSPAWN = 131072
|
GAMETYPE_FLAG_TDMSPAWN = 131072
|
||||||
};
|
};
|
||||||
|
|
||||||
#define GTFLAGS(x) (gametype_flags[ud.coop] & x)
|
#define GTFLAGS(x) (gametype_flags[ud.coop] & x)
|
||||||
|
@ -784,19 +784,19 @@ enum events {
|
||||||
EVENT_FAKEDOMOVETHINGS,
|
EVENT_FAKEDOMOVETHINGS,
|
||||||
EVENT_DISPLAYROOMS,
|
EVENT_DISPLAYROOMS,
|
||||||
EVENT_KILLIT,
|
EVENT_KILLIT,
|
||||||
EVENT_LOADACTOR,
|
EVENT_LOADACTOR,
|
||||||
EVENT_DISPLAYBONUSSCREEN,
|
EVENT_DISPLAYBONUSSCREEN,
|
||||||
EVENT_DISPLAYMENU,
|
EVENT_DISPLAYMENU,
|
||||||
EVENT_DISPLAYMENUREST,
|
EVENT_DISPLAYMENUREST,
|
||||||
EVENT_DISPLAYLOADINGSCREEN,
|
EVENT_DISPLAYLOADINGSCREEN,
|
||||||
EVENT_ANIMATESPRITES,
|
EVENT_ANIMATESPRITES,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum sysstrs {
|
enum sysstrs {
|
||||||
STR_MAPNAME,
|
STR_MAPNAME,
|
||||||
STR_MAPFILENAME,
|
STR_MAPFILENAME,
|
||||||
STR_PLAYERNAME,
|
STR_PLAYERNAME,
|
||||||
STR_VERSION,
|
STR_VERSION,
|
||||||
STR_GAMETYPE
|
STR_GAMETYPE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -825,7 +825,7 @@ enum gamevarflags {
|
||||||
|
|
||||||
enum gamearrayflags {
|
enum gamearrayflags {
|
||||||
MAXGAMEARRAYS = (MAXGAMEVARS>>2), // must be lower than MAXGAMEVARS
|
MAXGAMEARRAYS = (MAXGAMEVARS>>2), // must be lower than MAXGAMEVARS
|
||||||
MAXARRAYLABEL = MAXVARLABEL,
|
MAXARRAYLABEL = MAXVARLABEL,
|
||||||
GAMEARRAY_FLAG_NORMAL = 0,
|
GAMEARRAY_FLAG_NORMAL = 0,
|
||||||
GAMEARRAY_FLAG_NORESET = 1,
|
GAMEARRAY_FLAG_NORESET = 1,
|
||||||
};
|
};
|
||||||
|
@ -842,7 +842,7 @@ typedef struct {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *szLabel;
|
char *szLabel;
|
||||||
int *plValues; // array of values
|
int *plValues; // array of values
|
||||||
int size;
|
int size;
|
||||||
char bReset;
|
char bReset;
|
||||||
} gamearray_t;
|
} gamearray_t;
|
||||||
|
|
||||||
|
@ -966,8 +966,8 @@ enum logoflags {
|
||||||
LOGO_FLAG_DUKENUKEM = 32,
|
LOGO_FLAG_DUKENUKEM = 32,
|
||||||
LOGO_FLAG_THREEDEE = 64,
|
LOGO_FLAG_THREEDEE = 64,
|
||||||
LOGO_FLAG_PLUTOPAKSPRITE = 128,
|
LOGO_FLAG_PLUTOPAKSPRITE = 128,
|
||||||
LOGO_FLAG_SHAREWARESCREENS = 256,
|
LOGO_FLAG_SHAREWARESCREENS = 256,
|
||||||
LOGO_FLAG_TENSCREEN = 512
|
LOGO_FLAG_TENSCREEN = 512
|
||||||
};
|
};
|
||||||
|
|
||||||
extern int g_NumPalettes;
|
extern int g_NumPalettes;
|
||||||
|
@ -1025,22 +1025,22 @@ typedef struct {
|
||||||
} mapstate_t;
|
} mapstate_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int partime, designertime;
|
int partime, designertime;
|
||||||
char *name, *filename, *musicfn, *musicfn1;
|
char *name, *filename, *musicfn, *musicfn1;
|
||||||
mapstate_t *savedstate;
|
mapstate_t *savedstate;
|
||||||
} map_t;
|
} map_t;
|
||||||
|
|
||||||
extern map_t map[(MAXVOLUMES+1)*MAXLEVELS]; // +1 volume for "intro", "briefing" music
|
extern map_t map[(MAXVOLUMES+1)*MAXLEVELS]; // +1 volume for "intro", "briefing" music
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
player_struct *ps;
|
player_struct *ps;
|
||||||
input_t *sync;
|
input_t *sync;
|
||||||
|
|
||||||
int movefifoend, syncvalhead, myminlag;
|
int movefifoend, syncvalhead, myminlag;
|
||||||
int pcolor, pteam, frags[MAXPLAYERS], wchoice[MAX_WEAPONS];
|
int pcolor, pteam, frags[MAXPLAYERS], wchoice[MAX_WEAPONS];
|
||||||
|
|
||||||
char vote, gotvote, playerreadyflag, playerquitflag;
|
char vote, gotvote, playerreadyflag, playerquitflag;
|
||||||
char user_name[32], syncval[MOVEFIFOSIZ];
|
char user_name[32], syncval[MOVEFIFOSIZ];
|
||||||
} playerdata_t;
|
} playerdata_t;
|
||||||
|
|
||||||
extern input_t inputfifo[MOVEFIFOSIZ][MAXPLAYERS];
|
extern input_t inputfifo[MOVEFIFOSIZ][MAXPLAYERS];
|
||||||
|
@ -1060,6 +1060,30 @@ extern char *mousenames[];
|
||||||
extern char *duke3dgrp, *duke3dgrpstring;
|
extern char *duke3dgrp, *duke3dgrpstring;
|
||||||
extern char mod_dir[BMAX_PATH];
|
extern char mod_dir[BMAX_PATH];
|
||||||
|
|
||||||
|
// Hash functions
|
||||||
|
struct HASH_item // size is 12/24 bits.
|
||||||
|
{
|
||||||
|
const char *string;
|
||||||
|
int key;
|
||||||
|
struct HASH_item *next;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct HASH_table
|
||||||
|
{
|
||||||
|
int size;
|
||||||
|
struct HASH_item **items;
|
||||||
|
};
|
||||||
|
void HASH_init(struct HASH_table *t);
|
||||||
|
void HASH_free(struct HASH_table *t);
|
||||||
|
int HASH_findcase(struct HASH_table *t, const char *s);
|
||||||
|
int HASH_find(struct HASH_table *t, const char *s);
|
||||||
|
void HASH_replace(struct HASH_table *t, const char *s, int key);
|
||||||
|
void HASH_add(struct HASH_table *t, const char *s, int key);
|
||||||
|
|
||||||
|
struct HASH_table gamevarH;
|
||||||
|
struct HASH_table arrayH;
|
||||||
|
struct HASH_table keywH;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -9941,6 +9941,7 @@ static void loadtmb(void)
|
||||||
kclose(fil);
|
kclose(fil);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void freehash();
|
||||||
static void freeconmem(void)
|
static void freeconmem(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -10008,6 +10009,8 @@ static void freeconmem(void)
|
||||||
Bfree(script);
|
Bfree(script);
|
||||||
if (bitptr != NULL)
|
if (bitptr != NULL)
|
||||||
Bfree(bitptr);
|
Bfree(bitptr);
|
||||||
|
|
||||||
|
freehash();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -923,6 +923,248 @@ char *bitptr;
|
||||||
#define BITPTR_DONTFUCKWITHIT 0
|
#define BITPTR_DONTFUCKWITHIT 0
|
||||||
#define BITPTR_POINTER 1
|
#define BITPTR_POINTER 1
|
||||||
|
|
||||||
|
/*struct HASH_item // size is 12/24 bits.
|
||||||
|
{
|
||||||
|
const char *string;
|
||||||
|
int key;
|
||||||
|
struct HASH_item *next;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct HASH_table
|
||||||
|
{
|
||||||
|
int size;
|
||||||
|
struct HASH_item **items;
|
||||||
|
};
|
||||||
|
void HASH_init(struct HASH_table *t,int size);
|
||||||
|
void HASH_free(struct HASH_table *t);
|
||||||
|
int HASH_findcase(struct HASH_table *t, const char *s);
|
||||||
|
int HASH_find(struct HASH_table *t, const char *s);
|
||||||
|
void HASH_replace(struct HASH_table *t, const char *s, int key);
|
||||||
|
void HASH_add(struct HASH_table *t, const char *s, int key);
|
||||||
|
*/
|
||||||
|
void HASH_init(struct HASH_table *t)
|
||||||
|
{
|
||||||
|
HASH_free(t);
|
||||||
|
t->items=Bcalloc(1,t->size * sizeof(struct HASH_item));
|
||||||
|
Bmemset(t->items,0,t->size * sizeof(struct HASH_item));
|
||||||
|
}
|
||||||
|
|
||||||
|
void HASH_free(struct HASH_table *t)
|
||||||
|
{
|
||||||
|
struct HASH_item *cur, *tmp;
|
||||||
|
int i;
|
||||||
|
int num;
|
||||||
|
|
||||||
|
if (t->items==NULL)return;
|
||||||
|
initprintf("*free\n");
|
||||||
|
i=t->size-1;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
cur=t->items[i];
|
||||||
|
num=0;
|
||||||
|
while (cur)
|
||||||
|
{
|
||||||
|
tmp=cur;
|
||||||
|
cur=cur->next;
|
||||||
|
// initprintf("Free %4d '%s'\n",tmp->key,(tmp->string)?tmp->string:".");
|
||||||
|
Bfree(tmp);
|
||||||
|
num++;
|
||||||
|
}
|
||||||
|
// initprintf("Bucket #%4d: %3d\n",i,num);
|
||||||
|
}
|
||||||
|
while (--i>=0);
|
||||||
|
Bfree(t->items);
|
||||||
|
t->items=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int HASH_getcode(const char *s)
|
||||||
|
{
|
||||||
|
int i=0, fact=1;
|
||||||
|
while (*s)
|
||||||
|
{
|
||||||
|
i+=*s;
|
||||||
|
i+=1<<fact;
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HASH_add(struct HASH_table *t, const char *s, int key)
|
||||||
|
{
|
||||||
|
struct HASH_item *cur, *prev=NULL;
|
||||||
|
int code;
|
||||||
|
|
||||||
|
if (!s)return;
|
||||||
|
if (t->items==NULL) {initprintf("HASH_add: not initalized\n");return;}
|
||||||
|
code=HASH_getcode(s)%t->size;
|
||||||
|
cur=t->items[code];
|
||||||
|
|
||||||
|
if (!cur)
|
||||||
|
{
|
||||||
|
cur=Bcalloc(1,sizeof(struct HASH_item));
|
||||||
|
cur->string=s;
|
||||||
|
cur->key=key;
|
||||||
|
cur->next=NULL;
|
||||||
|
t->items[code]=cur;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (Bstrcmp(s,cur->string)==0)return;
|
||||||
|
prev=cur;
|
||||||
|
cur=cur->next;
|
||||||
|
}
|
||||||
|
while (cur);
|
||||||
|
|
||||||
|
cur=Bcalloc(1,sizeof(struct HASH_item));
|
||||||
|
cur->string=s;
|
||||||
|
cur->key=key;
|
||||||
|
cur->next=NULL;
|
||||||
|
prev->next=cur;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HASH_replace(struct HASH_table *t, const char *s, int key)
|
||||||
|
{
|
||||||
|
struct HASH_item *cur, *prev=NULL;
|
||||||
|
int code;
|
||||||
|
|
||||||
|
if (t->items==NULL) {initprintf("HASH_add: not initalized\n");return;}
|
||||||
|
code=HASH_getcode(s)%t->size;
|
||||||
|
cur=t->items[code];
|
||||||
|
|
||||||
|
if (!cur)
|
||||||
|
{
|
||||||
|
cur=Bcalloc(1,sizeof(struct HASH_item));
|
||||||
|
cur->string=s;
|
||||||
|
cur->key=key;
|
||||||
|
cur->next=NULL;
|
||||||
|
t->items[code]=cur;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (Bstrcmp(s,cur->string)==0)
|
||||||
|
{
|
||||||
|
cur->key=key;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
prev=cur;
|
||||||
|
cur=cur->next;
|
||||||
|
}
|
||||||
|
while (cur);
|
||||||
|
|
||||||
|
cur=Bcalloc(1,sizeof(struct HASH_item));
|
||||||
|
cur->string=s;
|
||||||
|
cur->key=key;
|
||||||
|
cur->next=NULL;
|
||||||
|
prev->next=cur;
|
||||||
|
}
|
||||||
|
|
||||||
|
int HASH_find(struct HASH_table *t, const char *s)
|
||||||
|
{
|
||||||
|
struct HASH_item *cur;
|
||||||
|
|
||||||
|
// initprintf("{");
|
||||||
|
if (t->items==NULL) {initprintf("HASH_findyy: not initalized\n");return -1;}
|
||||||
|
cur=t->items[HASH_getcode(s)%t->size];
|
||||||
|
while (cur)
|
||||||
|
{
|
||||||
|
if (Bstrcmp(s,cur->string)==0)return cur->key;
|
||||||
|
cur=cur->next;
|
||||||
|
}
|
||||||
|
// initprintf("}");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int HASH_findcase(struct HASH_table *t, const char *s)
|
||||||
|
{
|
||||||
|
struct HASH_item *cur;
|
||||||
|
|
||||||
|
// initprintf("{");
|
||||||
|
if (t->items==NULL) {initprintf("HASH_findcase: not initalized\n");return -1;}
|
||||||
|
cur=t->items[HASH_getcode(s)%t->size];
|
||||||
|
while (cur)
|
||||||
|
{
|
||||||
|
if (Bstrcasecmp(s,cur->string)==0)return cur->key;
|
||||||
|
cur=cur->next;
|
||||||
|
}
|
||||||
|
// initprintf("}");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct HASH_table gamevarH ={8096,NULL};
|
||||||
|
struct HASH_table arrayH ={2096,NULL};
|
||||||
|
struct HASH_table labelH ={8096,NULL};
|
||||||
|
struct HASH_table keywH ={ 800,NULL};
|
||||||
|
|
||||||
|
struct HASH_table sectorH ={ 200,NULL};
|
||||||
|
struct HASH_table wallH ={ 200,NULL};
|
||||||
|
struct HASH_table userdefH ={ 200,NULL};
|
||||||
|
|
||||||
|
struct HASH_table projectileH ={ 500,NULL};
|
||||||
|
struct HASH_table playerH ={ 500,NULL};
|
||||||
|
struct HASH_table inputH ={ 100,NULL};
|
||||||
|
struct HASH_table actorH ={ 500,NULL};
|
||||||
|
struct HASH_table tspriteH ={ 400,NULL};
|
||||||
|
|
||||||
|
void inithash()
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
HASH_init(&gamevarH);
|
||||||
|
HASH_init(&arrayH);
|
||||||
|
HASH_init(&labelH);
|
||||||
|
|
||||||
|
HASH_init(&keywH);
|
||||||
|
for (i=NUMKEYWORDS-1;i>=0;i--)
|
||||||
|
HASH_add(&keywH,keyw[i],i);
|
||||||
|
|
||||||
|
HASH_init(§orH);
|
||||||
|
for (i=0;sectorlabels[i].lId >=0 ; i++)
|
||||||
|
HASH_add(§orH,sectorlabels[i].name,i);
|
||||||
|
HASH_init(&wallH);
|
||||||
|
for (i=0;walllabels[i].lId >=0 ; i++)
|
||||||
|
HASH_add(&wallH,walllabels[i].name,i);
|
||||||
|
HASH_init(&userdefH);
|
||||||
|
for (i=0;userdefslabels[i].lId >=0 ; i++)
|
||||||
|
HASH_add(&userdefH,userdefslabels[i].name,i);
|
||||||
|
|
||||||
|
HASH_init(&projectileH);
|
||||||
|
for (i=0;projectilelabels[i].lId >=0 ; i++)
|
||||||
|
HASH_add(&projectileH,projectilelabels[i].name,i);
|
||||||
|
HASH_init(&playerH);
|
||||||
|
for (i=0;playerlabels[i].lId >=0 ; i++)
|
||||||
|
HASH_add(&playerH,playerlabels[i].name,i);
|
||||||
|
HASH_init(&inputH);
|
||||||
|
for (i=0;inputlabels[i].lId >=0 ; i++)
|
||||||
|
HASH_add(&inputH,inputlabels[i].name,i);
|
||||||
|
HASH_init(&actorH);
|
||||||
|
for (i=0;actorlabels[i].lId >=0 ; i++)
|
||||||
|
HASH_add(&actorH,actorlabels[i].name,i);
|
||||||
|
HASH_init(&tspriteH);
|
||||||
|
for (i=0;tsprlabels[i].lId >=0 ; i++)
|
||||||
|
HASH_add(&tspriteH,tsprlabels[i].name,i);
|
||||||
|
}
|
||||||
|
void freehash()
|
||||||
|
{
|
||||||
|
HASH_free(&gamevarH);
|
||||||
|
HASH_free(&arrayH);
|
||||||
|
HASH_free(&labelH);
|
||||||
|
HASH_free(&keywH);
|
||||||
|
|
||||||
|
HASH_free(§orH);
|
||||||
|
HASH_free(&wallH);
|
||||||
|
HASH_free(&userdefH);
|
||||||
|
|
||||||
|
HASH_free(&projectileH);
|
||||||
|
HASH_free(&playerH);
|
||||||
|
HASH_free(&inputH);
|
||||||
|
HASH_free(&actorH);
|
||||||
|
HASH_free(&tspriteH);
|
||||||
|
}
|
||||||
|
|
||||||
static int increasescriptsize(int size)
|
static int increasescriptsize(int size)
|
||||||
{
|
{
|
||||||
intptr_t oscriptptr = (unsigned)(scriptptr-script);
|
intptr_t oscriptptr = (unsigned)(scriptptr-script);
|
||||||
|
@ -1281,37 +1523,13 @@ void AddLog(const char *psz, ...)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int GetDefID(const char *szGameLabel)
|
inline static int GetDefID(const char *szGameLabel)
|
||||||
{
|
{
|
||||||
int i;
|
return HASH_find(&gamevarH,szGameLabel);
|
||||||
for (i=0;i<iGameVarCount;i++)
|
|
||||||
{
|
|
||||||
if (aGameVars[i].szLabel != NULL)
|
|
||||||
{
|
|
||||||
if (Bstrcmp(szGameLabel, aGameVars[i].szLabel) == 0)
|
|
||||||
{
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
static int GetADefID(const char *szGameLabel)
|
inline static int GetADefID(const char *szGameLabel)
|
||||||
{
|
{
|
||||||
int i;
|
return HASH_find(&arrayH,szGameLabel);
|
||||||
// initprintf("iGameArrayCount is %i\n",iGameArrayCount);
|
|
||||||
for (i=0;i<iGameArrayCount;i++)
|
|
||||||
{
|
|
||||||
if (aGameArrays[i].szLabel != NULL)
|
|
||||||
{
|
|
||||||
if (Bstrcmp(szGameLabel, aGameArrays[i].szLabel) == 0)
|
|
||||||
{
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// initprintf("game array %s not found\n",szGameLabel);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
static int ispecial(char c)
|
static int ispecial(char c)
|
||||||
{
|
{
|
||||||
|
@ -1332,40 +1550,25 @@ static inline int isaltok(char c)
|
||||||
return (isalnum(c) || c == '{' || c == '}' || c == '/' || c == '*' || c == '-' || c == '_' || c == '.');
|
return (isalnum(c) || c == '{' || c == '}' || c == '/' || c == '*' || c == '-' || c == '_' || c == '.');
|
||||||
}
|
}
|
||||||
|
|
||||||
static int getlabelid(const memberlabel_t *pLabel, const char *psz)
|
inline static int getlabelid(const memberlabel_t *pLabel, struct HASH_table *tH, const char *psz)
|
||||||
{
|
{
|
||||||
// find the label psz in the table pLabel.
|
// find the label psz in the table pLabel.
|
||||||
// returns the ID for the label, or -1
|
// returns the ID for the label, or -1
|
||||||
|
|
||||||
int l=-1;
|
int l=-1;
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i=0;pLabel[i].lId >=0 ; i++)
|
l = HASH_findcase(tH,psz);
|
||||||
{
|
if (l>=0) l= pLabel[l].lId;
|
||||||
if (!Bstrcasecmp(pLabel[i].name,psz))
|
|
||||||
{
|
|
||||||
l= pLabel[i].lId;
|
|
||||||
break; // stop for loop
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int getlabeloffset(const memberlabel_t *pLabel, const char *psz)
|
inline static int getlabeloffset(struct HASH_table *tH, const char *psz)
|
||||||
{
|
{
|
||||||
// find the label psz in the table pLabel.
|
// find the label psz in the table pLabel.
|
||||||
// returns the offset in the array for the label, or -1
|
// returns the offset in the array for the label, or -1
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i=0;pLabel[i].lId >=0 ; i++)
|
return HASH_findcase(tH,psz);
|
||||||
{
|
|
||||||
if (!Bstrcasecmp(pLabel[i].name,psz))
|
|
||||||
{
|
|
||||||
// printf("Label has flags of %02X\n",pLabel[i].flags);
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void getlabel(void)
|
static void getlabel(void)
|
||||||
|
@ -1414,11 +1617,7 @@ static int keyword(void)
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
tempbuf[i] = 0;
|
tempbuf[i] = 0;
|
||||||
for (i=NUMKEYWORDS-1;i>=0;i--)
|
return HASH_find(&keywH,tempbuf);
|
||||||
if (Bstrcmp(tempbuf,keyw[i]) == 0)
|
|
||||||
return i;
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int transword(void) //Returns its code #
|
static int transword(void) //Returns its code #
|
||||||
|
@ -1448,18 +1647,16 @@ static int transword(void) //Returns its code #
|
||||||
}
|
}
|
||||||
tempbuf[l] = 0;
|
tempbuf[l] = 0;
|
||||||
|
|
||||||
for (i=0;i<NUMKEYWORDS;i++)
|
i = HASH_find(&keywH,tempbuf);
|
||||||
|
if (i>=0)
|
||||||
{
|
{
|
||||||
if (Bstrcmp(tempbuf,keyw[i]) == 0)
|
*scriptptr = i + (line_number<<12);
|
||||||
{
|
bitptr[(scriptptr-script)] = BITPTR_DONTFUCKWITHIT;
|
||||||
*scriptptr = i + (line_number<<12);
|
textptr += l;
|
||||||
bitptr[(scriptptr-script)] = BITPTR_DONTFUCKWITHIT;
|
scriptptr++;
|
||||||
textptr += l;
|
if (!(error || warning) && g_ScriptDebug)
|
||||||
scriptptr++;
|
initprintf("%s:%d: debug: translating keyword `%s'.\n",compilefile,line_number,keyw[i]);
|
||||||
if (!(error || warning) && g_ScriptDebug)
|
return i;
|
||||||
initprintf("%s:%d: debug: translating keyword `%s'.\n",compilefile,line_number,keyw[i]);
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
textptr += l;
|
textptr += l;
|
||||||
|
@ -1517,14 +1714,12 @@ static void transvartype(int type)
|
||||||
}
|
}
|
||||||
getlabel();
|
getlabel();
|
||||||
|
|
||||||
if (!nokeywordcheck)
|
if (!nokeywordcheck && HASH_find(&keywH,label+(labelcnt<<6))>=0)
|
||||||
for (i=NUMKEYWORDS-1;i>=0;i--)
|
{
|
||||||
if (Bstrcmp(label+(labelcnt<<6),keyw[i]) == 0)
|
error++;
|
||||||
{
|
ReportError(ERROR_ISAKEYWORD);
|
||||||
error++;
|
return;
|
||||||
ReportError(ERROR_ISAKEYWORD);
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
skipcomments(); //skip comments and whitespace
|
skipcomments(); //skip comments and whitespace
|
||||||
if ((*textptr == '[')) //read of array as a gamevar
|
if ((*textptr == '[')) //read of array as a gamevar
|
||||||
|
@ -1568,9 +1763,10 @@ static void transvartype(int type)
|
||||||
{
|
{
|
||||||
//try looking for a define instead
|
//try looking for a define instead
|
||||||
Bstrcpy(tempbuf,label+(labelcnt<<6));
|
Bstrcpy(tempbuf,label+(labelcnt<<6));
|
||||||
for (i=labelcnt-1;i>=0;i--)
|
i = HASH_find(&labelH,tempbuf);
|
||||||
|
if (i>=0)
|
||||||
{
|
{
|
||||||
if (Bstrcmp(tempbuf,label+(i<<6)) == 0 && (labeltype[i] & LABEL_DEFINE))
|
if (labeltype[i] & LABEL_DEFINE)
|
||||||
{
|
{
|
||||||
if (!(error || warning) && g_ScriptDebug)
|
if (!(error || warning) && g_ScriptDebug)
|
||||||
initprintf("%s:%d: debug: accepted defined label `%s' instead of gamevar.\n",compilefile,line_number,label+(i<<6));
|
initprintf("%s:%d: debug: accepted defined label `%s' instead of gamevar.\n",compilefile,line_number,label+(i<<6));
|
||||||
|
@ -1654,47 +1850,43 @@ static int transnum(int type)
|
||||||
}
|
}
|
||||||
tempbuf[l] = 0;
|
tempbuf[l] = 0;
|
||||||
|
|
||||||
if (!nokeywordcheck)
|
if (!nokeywordcheck && HASH_find(&keywH,label+(labelcnt<<6))>=0)
|
||||||
for (i=NUMKEYWORDS-1;i>=0;i--)
|
|
||||||
if (Bstrcmp(label+(labelcnt<<6),keyw[i]) == 0)
|
|
||||||
{
|
|
||||||
error++;
|
|
||||||
ReportError(ERROR_ISAKEYWORD);
|
|
||||||
textptr+=l;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i=labelcnt-1;i>=0;i--)
|
|
||||||
{
|
{
|
||||||
if (!Bstrcmp(tempbuf,label+(i<<6)))
|
error++;
|
||||||
{
|
ReportError(ERROR_ISAKEYWORD);
|
||||||
char *el,*gl;
|
textptr+=l;
|
||||||
|
}
|
||||||
|
|
||||||
if (labeltype[i] & type)
|
i = HASH_find(&labelH,tempbuf);
|
||||||
|
if (i>=0)
|
||||||
|
{
|
||||||
|
char *el,*gl;
|
||||||
|
|
||||||
|
if (labeltype[i] & type)
|
||||||
|
{
|
||||||
|
if (!(error || warning) && g_ScriptDebug > 1)
|
||||||
{
|
{
|
||||||
if (!(error || warning) && g_ScriptDebug > 1)
|
gl = (char *)translatelabeltype(labeltype[i]);
|
||||||
{
|
initprintf("%s:%d: debug: accepted %s label `%s'.\n",compilefile,line_number,gl,label+(i<<6));
|
||||||
gl = (char *)translatelabeltype(labeltype[i]);
|
Bfree(gl);
|
||||||
initprintf("%s:%d: debug: accepted %s label `%s'.\n",compilefile,line_number,gl,label+(i<<6));
|
|
||||||
Bfree(gl);
|
|
||||||
}
|
|
||||||
if (labeltype[i] != LABEL_DEFINE && labelcode[i] >= (intptr_t)&script[0] && labelcode[i] < (intptr_t)&script[g_ScriptSize])
|
|
||||||
bitptr[(scriptptr-script)] = BITPTR_POINTER;
|
|
||||||
else bitptr[(scriptptr-script)] = BITPTR_DONTFUCKWITHIT;
|
|
||||||
*(scriptptr++) = labelcode[i];
|
|
||||||
textptr += l;
|
|
||||||
return labeltype[i];
|
|
||||||
}
|
}
|
||||||
bitptr[(scriptptr-script)] = BITPTR_DONTFUCKWITHIT;
|
if (labeltype[i] != LABEL_DEFINE && labelcode[i] >= (intptr_t)&script[0] && labelcode[i] < (intptr_t)&script[g_ScriptSize])
|
||||||
*(scriptptr++) = 0;
|
bitptr[(scriptptr-script)] = BITPTR_POINTER;
|
||||||
|
else bitptr[(scriptptr-script)] = BITPTR_DONTFUCKWITHIT;
|
||||||
|
*(scriptptr++) = labelcode[i];
|
||||||
textptr += l;
|
textptr += l;
|
||||||
el = (char *)translatelabeltype(type);
|
return labeltype[i];
|
||||||
gl = (char *)translatelabeltype(labeltype[i]);
|
|
||||||
ReportError(-1);
|
|
||||||
initprintf("%s:%d: warning: expected a %s, found a %s.\n",compilefile,line_number,el,gl);
|
|
||||||
Bfree(el);
|
|
||||||
Bfree(gl);
|
|
||||||
return -1; // valid label name, but wrong type
|
|
||||||
}
|
}
|
||||||
|
bitptr[(scriptptr-script)] = BITPTR_DONTFUCKWITHIT;
|
||||||
|
*(scriptptr++) = 0;
|
||||||
|
textptr += l;
|
||||||
|
el = (char *)translatelabeltype(type);
|
||||||
|
gl = (char *)translatelabeltype(labeltype[i]);
|
||||||
|
ReportError(-1);
|
||||||
|
initprintf("%s:%d: warning: expected a %s, found a %s.\n",compilefile,line_number,el,gl);
|
||||||
|
Bfree(el);
|
||||||
|
Bfree(gl);
|
||||||
|
return -1; // valid label name, but wrong type
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isdigit(*textptr) == 0 && *textptr != '-')
|
if (isdigit(*textptr) == 0 && *textptr != '-')
|
||||||
|
@ -1804,58 +1996,53 @@ static int parsecommand(void)
|
||||||
|
|
||||||
parsing_state = 1;
|
parsing_state = 1;
|
||||||
Bsprintf(parsing_item_name,"%s",label+(labelcnt<<6));
|
Bsprintf(parsing_item_name,"%s",label+(labelcnt<<6));
|
||||||
|
HASH_add(&labelH,label+(labelcnt<<6),labelcnt);
|
||||||
labelcnt++;
|
labelcnt++;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
getlabel();
|
getlabel();
|
||||||
|
|
||||||
for (i=NUMKEYWORDS-1;i>=0;i--)
|
if (HASH_find(&keywH,label+(labelcnt<<6))>=0)
|
||||||
if (Bstrcmp(label+(labelcnt<<6),keyw[i]) == 0)
|
{
|
||||||
|
error++;
|
||||||
|
ReportError(ERROR_ISAKEYWORD);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
i = HASH_find(&gamevarH,label+(labelcnt<<6));
|
||||||
|
if (i>=0)
|
||||||
|
{
|
||||||
|
// warning++;
|
||||||
|
ReportError(WARNING_NAMEMATCHESVAR);
|
||||||
|
}
|
||||||
|
|
||||||
|
j = HASH_find(&labelH,label+(labelcnt<<6));
|
||||||
|
if (j>=0)
|
||||||
|
{
|
||||||
|
if (labeltype[j] & LABEL_STATE)
|
||||||
{
|
{
|
||||||
error++;
|
if (!(error || warning) && g_ScriptDebug > 1)
|
||||||
ReportError(ERROR_ISAKEYWORD);
|
initprintf("%s:%d: debug: accepted state label `%s'.\n",compilefile,line_number,label+(j<<6));
|
||||||
|
*scriptptr = labelcode[j];
|
||||||
|
if (labelcode[j] >= (intptr_t)&script[0] && labelcode[j] < (intptr_t)&script[g_ScriptSize])
|
||||||
|
bitptr[(scriptptr-script)] = BITPTR_POINTER;
|
||||||
|
else bitptr[(scriptptr-script)] = BITPTR_DONTFUCKWITHIT;
|
||||||
|
scriptptr++;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
for (i=iGameVarCount-1;i>=0;i--)
|
|
||||||
{
|
|
||||||
if (aGameVars[i].szLabel)
|
|
||||||
if (Bstrcmp(label+(labelcnt<<6),aGameVars[i].szLabel) == 0)
|
|
||||||
{
|
|
||||||
// warning++;
|
|
||||||
ReportError(WARNING_NAMEMATCHESVAR);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (j=0;j<labelcnt;j++)
|
|
||||||
{
|
|
||||||
if (Bstrcmp(label+(j<<6),label+(labelcnt<<6)) == 0)
|
|
||||||
{
|
{
|
||||||
if (labeltype[j] & LABEL_STATE)
|
char *gl = (char *)translatelabeltype(labeltype[j]);
|
||||||
{
|
ReportError(-1);
|
||||||
if (!(error || warning) && g_ScriptDebug > 1)
|
initprintf("%s:%d: warning: expected a state, found a %s.\n",compilefile,line_number,gl);
|
||||||
initprintf("%s:%d: debug: accepted state label `%s'.\n",compilefile,line_number,label+(j<<6));
|
Bfree(gl);
|
||||||
*scriptptr = labelcode[j];
|
*(scriptptr-1) = CON_NULLOP; // get rid of the state, leaving a nullop to satisfy if conditions
|
||||||
if (labelcode[j] >= (intptr_t)&script[0] && labelcode[j] < (intptr_t)&script[g_ScriptSize])
|
bitptr[(scriptptr-script-1)] = BITPTR_DONTFUCKWITHIT;
|
||||||
bitptr[(scriptptr-script)] = BITPTR_POINTER;
|
return 0; // valid label name, but wrong type
|
||||||
else bitptr[(scriptptr-script)] = BITPTR_DONTFUCKWITHIT;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
char *gl = (char *)translatelabeltype(labeltype[j]);
|
|
||||||
ReportError(-1);
|
|
||||||
initprintf("%s:%d: warning: expected a state, found a %s.\n",compilefile,line_number,gl);
|
|
||||||
Bfree(gl);
|
|
||||||
*(scriptptr-1) = CON_NULLOP; // get rid of the state, leaving a nullop to satisfy if conditions
|
|
||||||
bitptr[(scriptptr-script-1)] = BITPTR_DONTFUCKWITHIT;
|
|
||||||
return 0; // valid label name, but wrong type
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (j==labelcnt)
|
else
|
||||||
{
|
{
|
||||||
ReportError(-1);
|
ReportError(-1);
|
||||||
initprintf("%s:%d: error: state `%s' not found.\n",compilefile,line_number,label+(labelcnt<<6));
|
initprintf("%s:%d: error: state `%s' not found.\n",compilefile,line_number,label+(labelcnt<<6));
|
||||||
|
@ -1942,7 +2129,7 @@ static int parsecommand(void)
|
||||||
getlabel();
|
getlabel();
|
||||||
//printf("found xxx label of '%s'\n", label+(labelcnt<<6));
|
//printf("found xxx label of '%s'\n", label+(labelcnt<<6));
|
||||||
|
|
||||||
lLabelID=getlabeloffset(projectilelabels,label+(labelcnt<<6));
|
lLabelID=getlabeloffset(&projectileH,label+(labelcnt<<6));
|
||||||
//printf("LabelID is %d\n",lLabelID);
|
//printf("LabelID is %d\n",lLabelID);
|
||||||
if (lLabelID == -1)
|
if (lLabelID == -1)
|
||||||
{
|
{
|
||||||
|
@ -1994,13 +2181,12 @@ static int parsecommand(void)
|
||||||
//printf("Got Label '%.20s'\n",textptr);
|
//printf("Got Label '%.20s'\n",textptr);
|
||||||
// Check to see it's already defined
|
// Check to see it's already defined
|
||||||
|
|
||||||
for (i=NUMKEYWORDS-1;i>=0;i--)
|
if (HASH_find(&keywH,label+(labelcnt<<6))>=0)
|
||||||
if (Bstrcmp(label+(labelcnt<<6),keyw[i]) == 0)
|
{
|
||||||
{
|
error++;
|
||||||
error++;
|
ReportError(ERROR_ISAKEYWORD);
|
||||||
ReportError(ERROR_ISAKEYWORD);
|
return 0;
|
||||||
return 0;
|
}
|
||||||
}
|
|
||||||
#if 0
|
#if 0
|
||||||
for (i=0;i<iGameVarCount;i++)
|
for (i=0;i<iGameVarCount;i++)
|
||||||
{
|
{
|
||||||
|
@ -2054,23 +2240,18 @@ static int parsecommand(void)
|
||||||
//printf("Got Label '%.20s'\n",textptr);
|
//printf("Got Label '%.20s'\n",textptr);
|
||||||
// Check to see it's already defined
|
// Check to see it's already defined
|
||||||
|
|
||||||
for (i=NUMKEYWORDS-1;i>=0;i--)
|
if (HASH_find(&keywH,label+(labelcnt<<6))>=0)
|
||||||
if (Bstrcmp(label+(labelcnt<<6),keyw[i]) == 0)
|
|
||||||
{
|
|
||||||
error++;
|
|
||||||
ReportError(ERROR_ISAKEYWORD);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i=iGameVarCount-1;i>=0;i--)
|
|
||||||
{
|
{
|
||||||
if (aGameVars[i].szLabel)
|
error++;
|
||||||
if (Bstrcmp(label+(labelcnt<<6),aGameVars[i].szLabel) == 0)
|
ReportError(ERROR_ISAKEYWORD);
|
||||||
{
|
return 0;
|
||||||
// warning++;
|
}
|
||||||
ReportError(WARNING_NAMEMATCHESVAR);
|
|
||||||
break;
|
i = HASH_find(&gamevarH,label+(labelcnt<<6));
|
||||||
}
|
if (i>=0)
|
||||||
|
{
|
||||||
|
// warning++;
|
||||||
|
ReportError(WARNING_NAMEMATCHESVAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
transnum(LABEL_DEFINE);
|
transnum(LABEL_DEFINE);
|
||||||
|
@ -2087,35 +2268,27 @@ static int parsecommand(void)
|
||||||
//printf("Got label. '%.20s'\n",textptr);
|
//printf("Got label. '%.20s'\n",textptr);
|
||||||
// Check to see it's already defined
|
// Check to see it's already defined
|
||||||
|
|
||||||
for (i=NUMKEYWORDS-1;i>=0;i--)
|
if (HASH_find(&keywH,label+(labelcnt<<6))>=0)
|
||||||
if (Bstrcmp(label+(labelcnt<<6),keyw[i]) == 0)
|
|
||||||
{
|
|
||||||
error++;
|
|
||||||
ReportError(ERROR_ISAKEYWORD);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i=iGameVarCount-1;i>=0;i--)
|
|
||||||
{
|
{
|
||||||
if (aGameVars[i].szLabel)
|
error++;
|
||||||
if (Bstrcmp(label+(labelcnt<<6),aGameVars[i].szLabel) == 0)
|
ReportError(ERROR_ISAKEYWORD);
|
||||||
{
|
return 0;
|
||||||
// warning++;
|
|
||||||
ReportError(WARNING_NAMEMATCHESVAR);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=labelcnt-1;i>=0;i--)
|
i = HASH_find(&gamevarH,label+(labelcnt<<6));
|
||||||
|
if (i>=0)
|
||||||
{
|
{
|
||||||
if (Bstrcmp(label+(labelcnt<<6),label+(i<<6)) == 0 /* && (labeltype[i] & LABEL_DEFINE) */)
|
// warning++;
|
||||||
|
ReportError(WARNING_NAMEMATCHESVAR);
|
||||||
|
}
|
||||||
|
|
||||||
|
i = HASH_find(&labelH,label+(labelcnt<<6));
|
||||||
|
if (i>=0)
|
||||||
|
{
|
||||||
|
if (i >= defaultlabelcnt)
|
||||||
{
|
{
|
||||||
if (i >= defaultlabelcnt)
|
warning++;
|
||||||
{
|
ReportError(WARNING_DUPLICATEDEFINITION);
|
||||||
warning++;
|
|
||||||
ReportError(WARNING_DUPLICATEDEFINITION);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2125,6 +2298,7 @@ static int parsecommand(void)
|
||||||
if (i == -1)
|
if (i == -1)
|
||||||
{
|
{
|
||||||
// printf("Defining Definition '%s' to be '%d'\n",label+(labelcnt<<6),*(scriptptr-1));
|
// printf("Defining Definition '%s' to be '%d'\n",label+(labelcnt<<6),*(scriptptr-1));
|
||||||
|
HASH_add(&labelH,label+(labelcnt<<6),labelcnt);
|
||||||
labeltype[labelcnt] = LABEL_DEFINE;
|
labeltype[labelcnt] = LABEL_DEFINE;
|
||||||
labelcode[labelcnt++] = *(scriptptr-1);
|
labelcode[labelcnt++] = *(scriptptr-1);
|
||||||
if (*(scriptptr-1) >= 0 && *(scriptptr-1) < MAXTILES && dynamicremap)
|
if (*(scriptptr-1) >= 0 && *(scriptptr-1) < MAXTILES && dynamicremap)
|
||||||
|
@ -2183,34 +2357,29 @@ static int parsecommand(void)
|
||||||
getlabel();
|
getlabel();
|
||||||
// Check to see it's already defined
|
// Check to see it's already defined
|
||||||
|
|
||||||
for (i=NUMKEYWORDS-1;i>=0;i--)
|
if (HASH_find(&keywH,label+(labelcnt<<6))>=0)
|
||||||
if (Bstrcmp(label+(labelcnt<<6),keyw[i]) == 0)
|
|
||||||
{
|
|
||||||
error++;
|
|
||||||
ReportError(ERROR_ISAKEYWORD);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i=iGameVarCount-1;i>=0;i--)
|
|
||||||
{
|
{
|
||||||
if (aGameVars[i].szLabel)
|
error++;
|
||||||
if (Bstrcmp(label+(labelcnt<<6),aGameVars[i].szLabel) == 0)
|
ReportError(ERROR_ISAKEYWORD);
|
||||||
{
|
return 0;
|
||||||
// warning++;
|
|
||||||
ReportError(WARNING_NAMEMATCHESVAR);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=labelcnt-1;i>=0;i--)
|
i = HASH_find(&gamevarH,label+(labelcnt<<6));
|
||||||
if (Bstrcmp(label+(labelcnt<<6),label+(i<<6)) == 0 /* && (labeltype[i] & LABEL_MOVE) */)
|
if (i>=0)
|
||||||
{
|
{
|
||||||
warning++;
|
// warning++;
|
||||||
initprintf("%s:%d: warning: duplicate move `%s' ignored.\n",compilefile,line_number,label+(labelcnt<<6));
|
ReportError(WARNING_NAMEMATCHESVAR);
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
|
i = HASH_find(&labelH,label+(labelcnt<<6));
|
||||||
|
if (i>=0)
|
||||||
|
{
|
||||||
|
warning++;
|
||||||
|
initprintf("%s:%d: warning: duplicate move `%s' ignored.\n",compilefile,line_number,label+(labelcnt<<6));
|
||||||
|
}
|
||||||
if (i == -1)
|
if (i == -1)
|
||||||
{
|
{
|
||||||
|
HASH_add(&labelH,label+(labelcnt<<6),labelcnt);
|
||||||
labeltype[labelcnt] = LABEL_MOVE;
|
labeltype[labelcnt] = LABEL_MOVE;
|
||||||
labelcode[labelcnt++] = (intptr_t) scriptptr;
|
labelcode[labelcnt++] = (intptr_t) scriptptr;
|
||||||
}
|
}
|
||||||
|
@ -2387,36 +2556,31 @@ static int parsecommand(void)
|
||||||
scriptptr--;
|
scriptptr--;
|
||||||
getlabel();
|
getlabel();
|
||||||
|
|
||||||
for (i=NUMKEYWORDS-1;i>=0;i--)
|
if (HASH_find(&keywH,label+(labelcnt<<6))>=0)
|
||||||
if (Bstrcmp(label+(labelcnt<<6),keyw[i]) == 0)
|
|
||||||
{
|
|
||||||
error++;
|
|
||||||
ReportError(ERROR_ISAKEYWORD);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i=iGameVarCount-1;i>=0;i--)
|
|
||||||
{
|
{
|
||||||
if (aGameVars[i].szLabel)
|
error++;
|
||||||
if (Bstrcmp(label+(labelcnt<<6),aGameVars[i].szLabel) == 0)
|
ReportError(ERROR_ISAKEYWORD);
|
||||||
{
|
return 0;
|
||||||
// warning++;
|
|
||||||
ReportError(WARNING_NAMEMATCHESVAR);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=labelcnt-1;i>=0;i--)
|
i = HASH_find(&gamevarH,label+(labelcnt<<6));
|
||||||
if (Bstrcmp(label+(labelcnt<<6),label+(i<<6)) == 0 /* && (labeltype[i] & LABEL_AI) */)
|
if (i>=0)
|
||||||
{
|
{
|
||||||
warning++;
|
// warning++;
|
||||||
initprintf("%s:%d: warning: duplicate ai `%s' ignored.\n",compilefile,line_number,label+(labelcnt<<6));
|
ReportError(WARNING_NAMEMATCHESVAR);
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
|
i = HASH_find(&labelH,label+(labelcnt<<6));
|
||||||
|
if (i>=0)
|
||||||
|
{
|
||||||
|
warning++;
|
||||||
|
initprintf("%s:%d: warning: duplicate ai `%s' ignored.\n",compilefile,line_number,label+(labelcnt<<6));
|
||||||
|
}
|
||||||
|
|
||||||
if (i == -1)
|
if (i == -1)
|
||||||
{
|
{
|
||||||
labeltype[labelcnt] = LABEL_AI;
|
labeltype[labelcnt] = LABEL_AI;
|
||||||
|
HASH_add(&labelH,label+(labelcnt<<6),labelcnt);
|
||||||
labelcode[labelcnt++] = (intptr_t) scriptptr;
|
labelcode[labelcnt++] = (intptr_t) scriptptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2469,37 +2633,32 @@ static int parsecommand(void)
|
||||||
getlabel();
|
getlabel();
|
||||||
// Check to see it's already defined
|
// Check to see it's already defined
|
||||||
|
|
||||||
for (i=NUMKEYWORDS-1;i>=0;i--)
|
if (HASH_find(&keywH,label+(labelcnt<<6))>=0)
|
||||||
if (Bstrcmp(label+(labelcnt<<6),keyw[i]) == 0)
|
|
||||||
{
|
|
||||||
error++;
|
|
||||||
ReportError(ERROR_ISAKEYWORD);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i=iGameVarCount-1;i>=0;i--)
|
|
||||||
{
|
{
|
||||||
if (aGameVars[i].szLabel)
|
error++;
|
||||||
if (Bstrcmp(label+(labelcnt<<6),aGameVars[i].szLabel) == 0)
|
ReportError(ERROR_ISAKEYWORD);
|
||||||
{
|
return 0;
|
||||||
// warning++;
|
|
||||||
ReportError(WARNING_NAMEMATCHESVAR);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=labelcnt-1;i>=0;i--)
|
i = HASH_find(&gamevarH,label+(labelcnt<<6));
|
||||||
if (Bstrcmp(label+(labelcnt<<6),label+(i<<6)) == 0 /* && (labeltype[i] & LABEL_ACTION) */)
|
if (i>=0)
|
||||||
{
|
{
|
||||||
warning++;
|
// warning++;
|
||||||
initprintf("%s:%d: warning: duplicate action `%s' ignored.\n",compilefile,line_number,label+(labelcnt<<6));
|
ReportError(WARNING_NAMEMATCHESVAR);
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
|
i = HASH_find(&labelH,label+(labelcnt<<6));
|
||||||
|
if (i>=0)
|
||||||
|
{
|
||||||
|
warning++;
|
||||||
|
initprintf("%s:%d: warning: duplicate action `%s' ignored.\n",compilefile,line_number,label+(labelcnt<<6));
|
||||||
|
}
|
||||||
|
|
||||||
if (i == -1)
|
if (i == -1)
|
||||||
{
|
{
|
||||||
labeltype[labelcnt] = LABEL_ACTION;
|
labeltype[labelcnt] = LABEL_ACTION;
|
||||||
labelcode[labelcnt] = (intptr_t) scriptptr;
|
labelcode[labelcnt] = (intptr_t) scriptptr;
|
||||||
|
HASH_add(&labelH,label+(labelcnt<<6),labelcnt);
|
||||||
labelcnt++;
|
labelcnt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2929,7 +3088,7 @@ static int parsecommand(void)
|
||||||
getlabel();
|
getlabel();
|
||||||
//printf("found xxx label of '%s'\n", label+(labelcnt<<6));
|
//printf("found xxx label of '%s'\n", label+(labelcnt<<6));
|
||||||
|
|
||||||
lLabelID=getlabelid(sectorlabels,label+(labelcnt<<6));
|
lLabelID=getlabelid(sectorlabels,§orH,label+(labelcnt<<6));
|
||||||
|
|
||||||
if (lLabelID == -1)
|
if (lLabelID == -1)
|
||||||
{
|
{
|
||||||
|
@ -3061,7 +3220,7 @@ static int parsecommand(void)
|
||||||
getlabel();
|
getlabel();
|
||||||
//printf("found xxx label of '%s'\n", label+(labelcnt<<6));
|
//printf("found xxx label of '%s'\n", label+(labelcnt<<6));
|
||||||
|
|
||||||
lLabelID=getlabelid(walllabels,label+(labelcnt<<6));
|
lLabelID=getlabelid(walllabels,&wallH,label+(labelcnt<<6));
|
||||||
|
|
||||||
if (lLabelID == -1)
|
if (lLabelID == -1)
|
||||||
{
|
{
|
||||||
|
@ -3125,7 +3284,7 @@ static int parsecommand(void)
|
||||||
getlabel();
|
getlabel();
|
||||||
//printf("found xxx label of '%s'\n", label+(labelcnt<<6));
|
//printf("found xxx label of '%s'\n", label+(labelcnt<<6));
|
||||||
|
|
||||||
lLabelID=getlabeloffset(playerlabels,label+(labelcnt<<6));
|
lLabelID=getlabeloffset(&playerH,label+(labelcnt<<6));
|
||||||
//printf("LabelID is %d\n",lLabelID);
|
//printf("LabelID is %d\n",lLabelID);
|
||||||
if (lLabelID == -1)
|
if (lLabelID == -1)
|
||||||
{
|
{
|
||||||
|
@ -3203,7 +3362,7 @@ static int parsecommand(void)
|
||||||
getlabel();
|
getlabel();
|
||||||
//printf("found xxx label of '%s'\n", label+(labelcnt<<6));
|
//printf("found xxx label of '%s'\n", label+(labelcnt<<6));
|
||||||
|
|
||||||
lLabelID=getlabeloffset(inputlabels,label+(labelcnt<<6));
|
lLabelID=getlabeloffset(&inputH,label+(labelcnt<<6));
|
||||||
//printf("LabelID is %d\n",lLabelID);
|
//printf("LabelID is %d\n",lLabelID);
|
||||||
if (lLabelID == -1)
|
if (lLabelID == -1)
|
||||||
{
|
{
|
||||||
|
@ -3254,7 +3413,7 @@ static int parsecommand(void)
|
||||||
getlabel();
|
getlabel();
|
||||||
//printf("found xxx label of '%s'\n", label+(labelcnt<<6));
|
//printf("found xxx label of '%s'\n", label+(labelcnt<<6));
|
||||||
|
|
||||||
lLabelID=getlabelid(userdefslabels,label+(labelcnt<<6));
|
lLabelID=getlabelid(userdefslabels,&userdefH,label+(labelcnt<<6));
|
||||||
|
|
||||||
if (lLabelID == -1)
|
if (lLabelID == -1)
|
||||||
{
|
{
|
||||||
|
@ -3342,13 +3501,12 @@ static int parsecommand(void)
|
||||||
//printf("found label of '%s'\n", label+(labelcnt<<6));
|
//printf("found label of '%s'\n", label+(labelcnt<<6));
|
||||||
|
|
||||||
// Check to see if it's a keyword
|
// Check to see if it's a keyword
|
||||||
for (i=NUMKEYWORDS-1;i>=0;i--)
|
if (HASH_find(&keywH,label+(labelcnt<<6))>=0)
|
||||||
if (Bstrcmp(label+(labelcnt<<6),keyw[i]) == 0)
|
{
|
||||||
{
|
error++;
|
||||||
error++;
|
ReportError(ERROR_ISAKEYWORD);
|
||||||
ReportError(ERROR_ISAKEYWORD);
|
return 0;
|
||||||
return 0;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
i=GetDefID(label+(labelcnt<<6));
|
i=GetDefID(label+(labelcnt<<6));
|
||||||
//printf("Label '%s' ID is %d\n",label+(labelcnt<<6), i);
|
//printf("Label '%s' ID is %d\n",label+(labelcnt<<6), i);
|
||||||
|
@ -3454,7 +3612,7 @@ static int parsecommand(void)
|
||||||
getlabel();
|
getlabel();
|
||||||
//printf("found xxx label of '%s'\n", label+(labelcnt<<6));
|
//printf("found xxx label of '%s'\n", label+(labelcnt<<6));
|
||||||
|
|
||||||
lLabelID=getlabeloffset(actorlabels,label+(labelcnt<<6));
|
lLabelID=getlabeloffset(&actorH,label+(labelcnt<<6));
|
||||||
//printf("LabelID is %d\n",lLabelID);
|
//printf("LabelID is %d\n",lLabelID);
|
||||||
if (lLabelID == -1)
|
if (lLabelID == -1)
|
||||||
{
|
{
|
||||||
|
@ -3536,7 +3694,7 @@ static int parsecommand(void)
|
||||||
getlabel();
|
getlabel();
|
||||||
//printf("found xxx label of '%s'\n", label+(labelcnt<<6));
|
//printf("found xxx label of '%s'\n", label+(labelcnt<<6));
|
||||||
|
|
||||||
lLabelID=getlabeloffset(tsprlabels,label+(labelcnt<<6));
|
lLabelID=getlabeloffset(&tspriteH,label+(labelcnt<<6));
|
||||||
//printf("LabelID is %d\n",lLabelID);
|
//printf("LabelID is %d\n",lLabelID);
|
||||||
if (lLabelID == -1)
|
if (lLabelID == -1)
|
||||||
{
|
{
|
||||||
|
@ -5295,6 +5453,7 @@ static void AddDefinition(const char *lLabel,int lValue,int lType)
|
||||||
{
|
{
|
||||||
Bstrcpy(label+(labelcnt<<6),lLabel);
|
Bstrcpy(label+(labelcnt<<6),lLabel);
|
||||||
labeltype[labelcnt] = lType;
|
labeltype[labelcnt] = lType;
|
||||||
|
HASH_add(&labelH,label+(labelcnt<<6),labelcnt);
|
||||||
labelcode[labelcnt++] = lValue;
|
labelcode[labelcnt++] = lValue;
|
||||||
defaultlabelcnt++;
|
defaultlabelcnt++;
|
||||||
}
|
}
|
||||||
|
@ -5468,6 +5627,7 @@ void loadefs(const char *filenam)
|
||||||
|
|
||||||
clearbuf(apScriptGameEvent,MAXGAMEEVENTS,0L);
|
clearbuf(apScriptGameEvent,MAXGAMEEVENTS,0L);
|
||||||
|
|
||||||
|
inithash();
|
||||||
InitGameVars();
|
InitGameVars();
|
||||||
InitProjectiles();
|
InitProjectiles();
|
||||||
|
|
||||||
|
|
|
@ -5444,11 +5444,11 @@ static int parse(void)
|
||||||
int i = GetGameVarID(*insptr++, g_i, g_p),
|
int i = GetGameVarID(*insptr++, g_i, g_p),
|
||||||
f=GetGameVarID(*insptr++, g_i, g_p);
|
f=GetGameVarID(*insptr++, g_i, g_p);
|
||||||
j=GetGameVarID(*insptr++, g_i, g_p);
|
j=GetGameVarID(*insptr++, g_i, g_p);
|
||||||
if ((i<0 || i>=MAXQUOTES) && checkCON)
|
if ((i<0 || i>=MAXQUOTES) && checkCON)
|
||||||
OSD_Printf(CON_ERROR "invalid quote ID %d\n",line_num,keyw[g_tw],i);
|
OSD_Printf(CON_ERROR "invalid quote ID %d\n",line_num,keyw[g_tw],i);
|
||||||
else if ((fta_quotes[i] == NULL) && checkCON)
|
else if ((fta_quotes[i] == NULL) && checkCON)
|
||||||
OSD_Printf(CON_ERROR "null quote %d\n",line_num,keyw[g_tw],i);
|
OSD_Printf(CON_ERROR "null quote %d\n",line_num,keyw[g_tw],i);
|
||||||
else if ((f<0 || f>=NUMGAMEFUNCTIONS) && checkCON)
|
else if ((f<0 || f>=NUMGAMEFUNCTIONS) && checkCON)
|
||||||
OSD_Printf(CON_ERROR "invalid function %d\n",line_num,keyw[g_tw],f);
|
OSD_Printf(CON_ERROR "invalid function %d\n",line_num,keyw[g_tw],f);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -50,6 +50,8 @@ static void FreeGameVars(void) /* called from ReadGameVars() and ResetGameVars()
|
||||||
aGameArrays[i].bReset=1;
|
aGameArrays[i].bReset=1;
|
||||||
}
|
}
|
||||||
iGameVarCount=iGameArrayCount=0;
|
iGameVarCount=iGameArrayCount=0;
|
||||||
|
HASH_init(&gamevarH);
|
||||||
|
HASH_init(&arrayH);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,6 +86,8 @@ static void ClearGameVars(void)
|
||||||
aGameArrays[i].bReset=1;
|
aGameArrays[i].bReset=1;
|
||||||
}
|
}
|
||||||
iGameVarCount=iGameArrayCount=0;
|
iGameVarCount=iGameArrayCount=0;
|
||||||
|
HASH_init(&gamevarH);
|
||||||
|
HASH_init(&arrayH);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,6 +111,7 @@ int ReadGameVars(int fil)
|
||||||
if (kdfread(&(aGameVars[i]),sizeof(gamevar_t),1,fil) != 1) goto corrupt;
|
if (kdfread(&(aGameVars[i]),sizeof(gamevar_t),1,fil) != 1) goto corrupt;
|
||||||
aGameVars[i].szLabel=Bcalloc(MAXVARLABEL,sizeof(char));
|
aGameVars[i].szLabel=Bcalloc(MAXVARLABEL,sizeof(char));
|
||||||
if (kdfread(aGameVars[i].szLabel,sizeof(char) * MAXVARLABEL, 1, fil) != 1) goto corrupt;
|
if (kdfread(aGameVars[i].szLabel,sizeof(char) * MAXVARLABEL, 1, fil) != 1) goto corrupt;
|
||||||
|
HASH_add(&gamevarH,aGameVars[i].szLabel,i);
|
||||||
}
|
}
|
||||||
// Bsprintf(g_szBuf,"CP:%s %d",__FILE__,__LINE__);
|
// Bsprintf(g_szBuf,"CP:%s %d",__FILE__,__LINE__);
|
||||||
// AddLog(g_szBuf);
|
// AddLog(g_szBuf);
|
||||||
|
@ -152,6 +157,7 @@ int ReadGameVars(int fil)
|
||||||
if (kdfread(&(aGameArrays[i]),sizeof(gamearray_t),1,fil) != 1) goto corrupt;
|
if (kdfread(&(aGameArrays[i]),sizeof(gamearray_t),1,fil) != 1) goto corrupt;
|
||||||
aGameArrays[i].szLabel=Bcalloc(MAXARRAYLABEL,sizeof(char));
|
aGameArrays[i].szLabel=Bcalloc(MAXARRAYLABEL,sizeof(char));
|
||||||
if (kdfread(aGameArrays[i].szLabel,sizeof(char) * MAXARRAYLABEL, 1, fil) != 1) goto corrupt;
|
if (kdfread(aGameArrays[i].szLabel,sizeof(char) * MAXARRAYLABEL, 1, fil) != 1) goto corrupt;
|
||||||
|
HASH_add(&arrayH,aGameArrays[i].szLabel,i);
|
||||||
}
|
}
|
||||||
// Bsprintf(g_szBuf,"CP:%s %d",__FILE__,__LINE__);
|
// Bsprintf(g_szBuf,"CP:%s %d",__FILE__,__LINE__);
|
||||||
// AddLog(g_szBuf);
|
// AddLog(g_szBuf);
|
||||||
|
@ -417,20 +423,14 @@ int AddGameArray(const char *pszLabel, int asize)
|
||||||
initprintf("%s:%d: error: array name `%s' exceeds limit of %d characters.\n",compilefile,line_number,pszLabel, MAXARRAYLABEL);
|
initprintf("%s:%d: error: array name `%s' exceeds limit of %d characters.\n",compilefile,line_number,pszLabel, MAXARRAYLABEL);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
for (i=0;i<iGameArrayCount;i++)
|
if (HASH_find(&arrayH,pszLabel)>=0 && !aGameArrays[i].bReset)
|
||||||
{
|
{
|
||||||
if (aGameVars[i].szLabel != NULL && !aGameArrays[i].bReset)
|
// found it it's a duplicate in error
|
||||||
{
|
warning++;
|
||||||
if (Bstrcmp(pszLabel,aGameArrays[i].szLabel) == 0)
|
ReportError(WARNING_DUPLICATEDEFINITION);
|
||||||
{
|
return 0;
|
||||||
// found it it's a duplicate in error
|
|
||||||
warning++;
|
|
||||||
ReportError(WARNING_DUPLICATEDEFINITION);
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
i = iGameArrayCount;
|
||||||
if (i < MAXGAMEARRAYS)
|
if (i < MAXGAMEARRAYS)
|
||||||
{
|
{
|
||||||
if (aGameArrays[i].szLabel == NULL)
|
if (aGameArrays[i].szLabel == NULL)
|
||||||
|
@ -441,6 +441,7 @@ int AddGameArray(const char *pszLabel, int asize)
|
||||||
aGameArrays[i].size=asize;
|
aGameArrays[i].size=asize;
|
||||||
aGameVars[i].bReset=0;
|
aGameVars[i].bReset=0;
|
||||||
iGameArrayCount++;
|
iGameArrayCount++;
|
||||||
|
HASH_add(&arrayH,aGameArrays[i].szLabel,i);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -523,6 +524,7 @@ int AddGameVar(const char *pszLabel, int lValue, unsigned int dwFlags)
|
||||||
if (i==iGameVarCount)
|
if (i==iGameVarCount)
|
||||||
{
|
{
|
||||||
// we're adding a new one.
|
// we're adding a new one.
|
||||||
|
HASH_replace(&gamevarH,aGameVars[i].szLabel,i);
|
||||||
iGameVarCount++;
|
iGameVarCount++;
|
||||||
}
|
}
|
||||||
if (aGameVars[i].plValues && !(aGameVars[i].dwFlags & GAMEVAR_FLAG_SYSTEM))
|
if (aGameVars[i].plValues && !(aGameVars[i].dwFlags & GAMEVAR_FLAG_SYSTEM))
|
||||||
|
@ -566,21 +568,9 @@ void ResetActorGameVars(int iActor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int GetGameID(const char *szGameLabel)
|
inline static int GetGameID(const char *szGameLabel)
|
||||||
{
|
{
|
||||||
int i;
|
return HASH_find(&gamevarH,szGameLabel);
|
||||||
|
|
||||||
for (i=0;i<iGameVarCount;i++)
|
|
||||||
{
|
|
||||||
if (aGameVars[i].szLabel != NULL)
|
|
||||||
{
|
|
||||||
if (Bstrcmp(szGameLabel, aGameVars[i].szLabel) == 0)
|
|
||||||
{
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetGameVarID(int id, int iActor, int iPlayer)
|
int GetGameVarID(int id, int iActor, int iPlayer)
|
||||||
|
@ -732,44 +722,27 @@ void SetGameVarID(int id, int lValue, int iActor, int iPlayer)
|
||||||
int GetGameVar(const char *szGameLabel, int lDefault, int iActor, int iPlayer)
|
int GetGameVar(const char *szGameLabel, int lDefault, int iActor, int iPlayer)
|
||||||
{
|
{
|
||||||
int i=0;
|
int i=0;
|
||||||
for (;i<iGameVarCount;i++)
|
i = HASH_find(&gamevarH,szGameLabel);
|
||||||
{
|
if (i<0)return lDefault;
|
||||||
if (aGameVars[i].szLabel != NULL)
|
return GetGameVarID(i, iActor, iPlayer);
|
||||||
{
|
|
||||||
if (Bstrcmp(szGameLabel, aGameVars[i].szLabel) == 0)
|
|
||||||
{
|
|
||||||
return GetGameVarID(i, iActor, iPlayer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return lDefault;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static intptr_t *GetGameValuePtr(const char *szGameLabel)
|
static intptr_t *GetGameValuePtr(const char *szGameLabel)
|
||||||
{
|
{
|
||||||
int i=0;
|
int i=0;
|
||||||
|
|
||||||
for (;i<iGameVarCount;i++)
|
i = HASH_find(&gamevarH,szGameLabel);
|
||||||
|
if (i<0)return NULL;
|
||||||
|
|
||||||
|
if (aGameVars[i].dwFlags & (GAMEVAR_FLAG_PERACTOR | GAMEVAR_FLAG_PERPLAYER))
|
||||||
{
|
{
|
||||||
if (aGameVars[i].szLabel != NULL)
|
if (!aGameVars[i].plValues)
|
||||||
{
|
{
|
||||||
if (Bstrcmp(szGameLabel, aGameVars[i].szLabel) == 0)
|
OSD_Printf(OSD_ERROR "GetGameValuePtr(): INTERNAL ERROR: NULL array !!!\n");
|
||||||
{
|
|
||||||
if (aGameVars[i].dwFlags & (GAMEVAR_FLAG_PERACTOR | GAMEVAR_FLAG_PERPLAYER))
|
|
||||||
{
|
|
||||||
if (!aGameVars[i].plValues)
|
|
||||||
{
|
|
||||||
OSD_Printf(OSD_ERROR "GetGameValuePtr(): INTERNAL ERROR: NULL array !!!\n");
|
|
||||||
}
|
|
||||||
return aGameVars[i].plValues;
|
|
||||||
}
|
|
||||||
return &(aGameVars[i].lValue);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return aGameVars[i].plValues;
|
||||||
}
|
}
|
||||||
//Bsprintf(g_szBuf,"Could not find value '%s'\n",szGameLabel);
|
return &(aGameVars[i].lValue);
|
||||||
//AddLog(g_szBuf);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResetSystemDefaults(void)
|
void ResetSystemDefaults(void)
|
||||||
|
|
|
@ -289,7 +289,7 @@ static int getsound(unsigned int num)
|
||||||
if (fp == -1)fp = kopen4loadfrommod(g_sounds[num].filename,loadfromgrouponly);
|
if (fp == -1)fp = kopen4loadfrommod(g_sounds[num].filename,loadfromgrouponly);
|
||||||
if (fp == -1)
|
if (fp == -1)
|
||||||
{
|
{
|
||||||
// initprintf("Sound '%s' not found\n",g_sounds[num].filename);
|
initprintf("Sound '%s' not found\n",g_sounds[num].filename);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue