From 4910928877593ff980b0503b2e0245131e9b17ba Mon Sep 17 00:00:00 2001 From: terminx Date: Thu, 20 Nov 2008 14:06:36 +0000 Subject: [PATCH] source code rape git-svn-id: https://svn.eduke32.com/eduke32@1143 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/Makefile | 4 +- polymer/eduke32/build/Makefile.shared | 4 +- polymer/eduke32/build/src/engine.c | 3 +- polymer/eduke32/build/src/mmulti_unstable.c | 32 +- polymer/eduke32/eduke32.vcproj | 8 + polymer/eduke32/source/_functio.h | 11 +- polymer/eduke32/source/actors.c | 2361 ++++++------ polymer/eduke32/source/anim.c | 80 +- polymer/eduke32/source/astub.c | 26 +- polymer/eduke32/source/config.c | 497 +-- polymer/eduke32/source/duke3d.h | 496 +-- polymer/eduke32/source/funct.h | 316 +- polymer/eduke32/source/function.h | 9 +- polymer/eduke32/source/game.c | 3204 ++++++++--------- polymer/eduke32/source/gamedef.c | 3124 ++++++++-------- polymer/eduke32/source/gamedef.h | 62 +- polymer/eduke32/source/gameexec.c | 1788 +++++---- polymer/eduke32/source/gamestructures.c | 1096 +++--- polymer/eduke32/source/gamevars.c | 1175 +++--- polymer/eduke32/source/global.c | 100 +- .../source/jaudiolib/audiolib_musicstub.c | 2 +- polymer/eduke32/source/jaudiolib/multivoc.c | 2 +- polymer/eduke32/source/jaudiolib/music.c | 6 +- polymer/eduke32/source/jaudiolib/sdlmusic.c | 2 +- polymer/eduke32/source/jmact/scriplib.c | 2 +- polymer/eduke32/source/menus.c | 894 +++-- polymer/eduke32/source/namesdyn.c | 64 +- polymer/eduke32/source/namesdyn.h | 2 +- polymer/eduke32/source/osdcmds.c | 174 +- polymer/eduke32/source/osdcmds.h | 2 +- polymer/eduke32/source/osdfuncs.c | 2 +- polymer/eduke32/source/player.c | 1690 ++++----- polymer/eduke32/source/premap.c | 648 ++-- polymer/eduke32/source/savegame.c | 264 +- polymer/eduke32/source/sector.c | 1081 +++--- polymer/eduke32/source/sounds.c | 101 +- polymer/eduke32/source/sounds.h | 8 +- polymer/eduke32/source/startgtk.game.c | 8 +- polymer/eduke32/source/startwin.game.c | 8 +- polymer/eduke32/source/sync.c | 220 +- polymer/eduke32/source/winbits.c | 4 +- 41 files changed, 9860 insertions(+), 9720 deletions(-) diff --git a/polymer/eduke32/Makefile b/polymer/eduke32/Makefile index 7b639c8ca..3dc222123 100644 --- a/polymer/eduke32/Makefile +++ b/polymer/eduke32/Makefile @@ -291,14 +291,14 @@ endif enginelib editorlib: -mkdir -p $(EOBJ) ifeq ($(PRETTY_OUTPUT),1) - printf "\033[K\033[0;35mChanging dir to \033[1;35m$(CURDIR)/$(EROOT)\033[0;35m.\033[0m\n" + printf "\033[K\033[0;35mChanging dir to \033[1;35m$(CURDIR)/$(EROOT)\033[0;35m \033[0m\n" endif $(MAKE) -C $(EROOT)/ "OBJ=../$(EOBJ)" \ SUPERBUILD=$(SUPERBUILD) POLYMOST=$(POLYMOST) \ USE_OPENGL=$(USE_OPENGL) BUILD32_ON_64=$(BUILD32_ON_64) \ NOASM=$(NOASM) RELEASE=$(RELEASE) OPTLEVEL=$(OPTLEVEL) RANCID_NETWORKING=$(RANCID_NETWORKING) $@ ifeq ($(PRETTY_OUTPUT),1) - printf "\033[K\033[0;35mChanging dir to \033[1;35m$(CURDIR)\033[0;35m.\033[0m\n" + printf "\033[K\033[0;35mChanging dir to \033[1;35m$(CURDIR)\033[0;35m \033[0m\n" endif $(EOBJ)/$(ENGINELIB): enginelib diff --git a/polymer/eduke32/build/Makefile.shared b/polymer/eduke32/build/Makefile.shared index bea331960..fb0bd36a5 100644 --- a/polymer/eduke32/build/Makefile.shared +++ b/polymer/eduke32/build/Makefile.shared @@ -194,10 +194,10 @@ ifeq ($(PRETTY_OUTPUT),1) BUILD_STARTED = printf "\033[K\033[1;36mBuild started using \"$(CC) $(OURCFLAGS)\"\033[0m\n" BUILD_FINISHED = printf "\033[K\033[1;36mBuild successful:\033[0m\n" COMPILE_STATUS = printf "\033[K\033[0mBuilding object \033[1m$@\033[0m...\033[0m\r" -COMPILE_OK = printf "\033[K\033[0;32mBuilt object \033[1;32m$@\033[0;32m.\033[0m\n" +COMPILE_OK = printf "\033[K\033[0;32mBuilt object \033[1;32m$@\033[0;32m \033[0m\n" COMPILE_FAILED = printf "\033[K\033[0;31mFailed building \033[1;31m$@\033[0;31m from\033[0m \033[1;31m$<\033[0;31m!\033[0m\n"; exit 1 LINK_STATUS = printf "\033[K\033[0;0mLinking executable \033[1m$@\033[0;0m...\033[0m\r" -LINK_OK = printf "\033[K\033[0;32mLinked executable \033[1;32m$@\033[0;32m.\033[0m\n" +LINK_OK = printf "\033[K\033[0;32mLinked executable \033[1;32m$@\033[0;32m \033[0m\n" LINK_FAILED = printf "\033[K\033[0;31mFailed linking executable \033[1;31m$@\033[0;31m!\033[0m\n"; exit 1 else BUILD_STARTED = diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index a6b48d61b..188b1137c 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -9611,7 +9611,8 @@ void getmousevalues(int *mousx, int *mousy, int *bstatus) // int krand(void) { - randomseed = (randomseed*27584621)+1; +// randomseed = (randomseed*27584621)+1; + randomseed = (randomseed * 1664525ul) + 221297ul; return(((unsigned int)randomseed)>>16); } diff --git a/polymer/eduke32/build/src/mmulti_unstable.c b/polymer/eduke32/build/src/mmulti_unstable.c index 557376af1..9e17e74bc 100644 --- a/polymer/eduke32/build/src/mmulti_unstable.c +++ b/polymer/eduke32/build/src/mmulti_unstable.c @@ -11,7 +11,6 @@ #include #include #include -#include //HACK, for id generation #include "mmulti_unstable.h" // #include @@ -73,6 +72,8 @@ int connecthead, connectpoint2[MAXPLAYERS]; char syncstate = 0; #define MAXPACKETSIZE 2048 +#define PACKET_START_GAME 0x1337 + typedef struct { // short intnum; /* communication between Game and the driver */ @@ -127,6 +128,11 @@ enum ECommitCMDs COMMIT_CMD_SCORE = 5, }; +static struct +{ + int host; + unsigned short port; +} allowed_addresses[MAXPLAYERS]; /* only respond to these IPs. */ // Queue of out going packets. //PacketQueue outgoingPacketQueue; @@ -180,6 +186,8 @@ void initmultiplayers(int argc, char **argv) outcntplc[i] = 0L; outcntend[i] = 0L; bakpacketlen[i][255] = -1; + allowed_addresses[i].host = 0; + allowed_addresses[i].port = 0; } // clear out the packet ordering @@ -544,7 +552,7 @@ int getpacket(int *other, char *bufptr) void flushpackets() { -#if 0 +#if 1 int i; if (numplayers < 2) return; @@ -629,12 +637,6 @@ void genericmultifunction(int other, char *bufptr, int messleng, int command) static sockettype udpsocket = -1; static unsigned short udpport = BUILD_DEFAULT_UDP_PORT; -static struct -{ - int host; - unsigned short port; -} allowed_addresses[MAXPLAYERS]; /* only respond to these IPs. */ - #if PLATFORM_WIN32 /* * Figure out what the last failing Win32 API call was, and @@ -1121,7 +1123,7 @@ static int wait_for_other_players(gcomtype *gcom, int myip) // greeting with 0x1337 id starts the game for clients send_peer_greeting(allowed_addresses[j].host, allowed_addresses[j].port, - 0x1337); + PACKET_START_GAME); } /* ok, now everyone is talking to you. Sort them into player numbers... */ @@ -1217,9 +1219,10 @@ static int connect_to_server(gcomtype *gcom, int myip) while (my_id == 0) /* player number is based on id, low to high. */ { - struct timeval tv; +/* struct timeval tv; gettimeofday(&tv, NULL); - my_id = (unsigned short)tv.tv_usec; //HACK + my_id = (unsigned short)tv.tv_usec; //HACK */ + my_id = (unsigned short) rand(); } initprintf("mmulti_unstable: Using 0x%X as client ID\n", my_id); @@ -1285,7 +1288,7 @@ static int connect_to_server(gcomtype *gcom, int myip) if (!heard_from[i] || heard_from[i] == B_SWAP16(packet.id)) break; // only increase once // greeting with 0x1337 id starts the game - if (B_SWAP16(packet.id) == 0x1337) + if (B_SWAP16(packet.id) == PACKET_START_GAME) { remaining = 0; continue; @@ -1427,9 +1430,10 @@ static int connect_to_everyone(gcomtype *gcom, int myip, int bcast) while (my_id == 0) /* player number is based on id, low to high. */ { - struct timeval tv; +/* struct timeval tv; gettimeofday(&tv, NULL); - my_id = (unsigned short)tv.tv_usec; //HACK + my_id = (unsigned short)tv.tv_usec; //HACK */ + my_id = (unsigned short) rand(); } diff --git a/polymer/eduke32/eduke32.vcproj b/polymer/eduke32/eduke32.vcproj index a45aa9a5a..8a465becd 100644 --- a/polymer/eduke32/eduke32.vcproj +++ b/polymer/eduke32/eduke32.vcproj @@ -456,6 +456,10 @@ RelativePath=".\source\startwin.game.c" > + + @@ -552,6 +556,10 @@ RelativePath=".\source\startwin.game.h" > + + =0;i--) oldipos[i] = *curipos[i]; } -void setinterpolation(int *posptr) +void G_SetInterpolation(int *posptr) { - int i=numinterpolations-1; + int i=g_numInterpolations-1; - if (numinterpolations >= MAXINTERPOLATIONS) return; + if (g_numInterpolations >= MAXINTERPOLATIONS) return; for (;i>=0;i--) if (curipos[i] == posptr) return; - curipos[numinterpolations] = posptr; - oldipos[numinterpolations] = *posptr; - numinterpolations++; + curipos[g_numInterpolations] = posptr; + oldipos[g_numInterpolations] = *posptr; + g_numInterpolations++; } -void stopinterpolation(int *posptr) +void G_StopInterpolation(int *posptr) { - int i=numinterpolations-1; + int i=g_numInterpolations-1; for (;i>=startofdynamicinterpolations;i--) if (curipos[i] == posptr) { - numinterpolations--; - oldipos[i] = oldipos[numinterpolations]; - bakipos[i] = bakipos[numinterpolations]; - curipos[i] = curipos[numinterpolations]; + g_numInterpolations--; + oldipos[i] = oldipos[g_numInterpolations]; + bakipos[i] = bakipos[g_numInterpolations]; + curipos[i] = curipos[g_numInterpolations]; } } -void dointerpolations(int smoothratio) //Stick at beginning of drawscreen +void G_DoInterpolations(int smoothratio) //Stick at beginning of drawscreen { - int i=numinterpolations-1, j = 0, odelta, ndelta = 0; + int i=g_numInterpolations-1, j = 0, odelta, ndelta = 0; for (;i>=0;i--) { @@ -74,23 +76,23 @@ void dointerpolations(int smoothratio) //Stick at beginning of drawscreen } } -inline void restoreinterpolations(void) //Stick at end of drawscreen +inline void G_RestoreInterpolations(void) //Stick at end of drawscreen { - int i=numinterpolations-1; + int i=g_numInterpolations-1; for (;i>=0;i--) *curipos[i] = bakipos[i]; } -inline int ceilingspace(int sectnum) +inline int G_CheckForSpaceCeiling(int sectnum) { return ((sector[sectnum].ceilingstat&1) && sector[sectnum].ceilingpal == 0 && (sector[sectnum].ceilingpicnum==MOONSKY1 || sector[sectnum].ceilingpicnum==BIGORBIT1)?1:0); } -inline int floorspace(int sectnum) +inline int G_CheckForSpaceFloor(int sectnum) { return ((sector[sectnum].floorstat&1) && sector[sectnum].ceilingpal == 0 && ((sector[sectnum].floorpicnum==MOONSKY1)||(sector[sectnum].floorpicnum==BIGORBIT1))?1:0); } -void addammo(int weapon,player_struct *p,int amount) +void P_AddAmmo(int weapon,DukePlayer_t *p,int amount) { p->ammo_amount[weapon] += amount; @@ -98,7 +100,7 @@ void addammo(int weapon,player_struct *p,int amount) p->ammo_amount[weapon] = p->max_ammo_amount[weapon]; } -void addweaponnoswitch(player_struct *p, int weapon) +void P_AddWeaponNoSwitch(DukePlayer_t *p, int weapon) { if (p->gotweapon[weapon] == 0) { @@ -106,6 +108,13 @@ void addweaponnoswitch(player_struct *p, int weapon) if (weapon == SHRINKER_WEAPON) p->gotweapon[GROW_WEAPON] = 1; } + +#if 1 + if (aplWeaponSelectSound[p->curr_weapon][sprite[p->i].yvel]) + A_StopSound(aplWeaponSelectSound[p->curr_weapon][sprite[p->i].yvel],p->i); + if (aplWeaponSelectSound[weapon][sprite[p->i].yvel]) + A_PlaySound(aplWeaponSelectSound[weapon][sprite[p->i].yvel],p->i); +#else switch (p->curr_weapon) { case KNEE_WEAPON: @@ -114,13 +123,13 @@ void addweaponnoswitch(player_struct *p, int weapon) case HANDBOMB_WEAPON: break; case SHOTGUN_WEAPON: - stopspritesound(SHOTGUN_COCK,p->i); + A_StopSound(SHOTGUN_COCK,p->i); break; case PISTOL_WEAPON: - stopspritesound(INSERT_CLIP,p->i); + A_StopSound(INSERT_CLIP,p->i); break; default: - stopspritesound(SELECT_WEAPON,p->i); + A_StopSound(SELECT_WEAPON,p->i); break; } switch (weapon) @@ -131,22 +140,23 @@ void addweaponnoswitch(player_struct *p, int weapon) case HANDBOMB_WEAPON: break; case SHOTGUN_WEAPON: - spritesound(SHOTGUN_COCK,p->i); + A_PlaySound(SHOTGUN_COCK,p->i); break; case PISTOL_WEAPON: - spritesound(INSERT_CLIP,p->i); + A_PlaySound(INSERT_CLIP,p->i); break; default: - spritesound(SELECT_WEAPON,p->i); + A_PlaySound(SELECT_WEAPON,p->i); break; } +#endif } -void addweapon(player_struct *p,int weapon) +void P_AddWeapon(DukePlayer_t *p,int weapon) { int snum = sprite[p->i].yvel; - addweaponnoswitch(p,weapon); + P_AddWeaponNoSwitch(p,weapon); if (p->reloading) return; @@ -169,22 +179,22 @@ void addweapon(player_struct *p,int weapon) p->kickback_pic = 0; if (p->curr_weapon != weapon) - OnEvent(EVENT_CHANGEWEAPON,p->i, snum, -1); + X_OnEvent(EVENT_CHANGEWEAPON,p->i, snum, -1); p->curr_weapon = weapon; - SetGameVarID(g_iWeaponVarID,p->curr_weapon, p->i, snum); + Gv_SetVar(g_iWeaponVarID,p->curr_weapon, p->i, snum); if (p->curr_weapon>=0) { - SetGameVarID(g_iWorksLikeVarID,aplWeaponWorksLike[p->curr_weapon][snum], p->i, snum); + Gv_SetVar(g_iWorksLikeVarID,aplWeaponWorksLike[p->curr_weapon][snum], p->i, snum); } else { - SetGameVarID(g_iWorksLikeVarID,-1, p->i, snum); + Gv_SetVar(g_iWorksLikeVarID,-1, p->i, snum); } } -void checkavailinven(player_struct *p) +void P_SelectNextInventoryItem(DukePlayer_t *p) { if (p->firstaid_amount > 0) p->inven_icon = 1; @@ -203,7 +213,7 @@ void checkavailinven(player_struct *p) else p->inven_icon = 0; } -void checkavailweapon(player_struct *p) +void P_CheckWeapon(DukePlayer_t *p) { short i,snum; int32 weap; @@ -218,7 +228,7 @@ void checkavailweapon(player_struct *p) if (weap == p->curr_weapon) return; else if (p->gotweapon[weap] && p->ammo_amount[weap] > 0) { - addweapon(p,weap); + P_AddWeapon(p,weap); return; } } @@ -250,16 +260,16 @@ void checkavailweapon(player_struct *p) p->last_weapon = p->curr_weapon; p->random_club_frame = 0; p->curr_weapon = weap; - SetGameVarID(g_iWeaponVarID,p->curr_weapon, p->i, snum); + Gv_SetVar(g_iWeaponVarID,p->curr_weapon, p->i, snum); if (p->curr_weapon>=0) { - SetGameVarID(g_iWorksLikeVarID,aplWeaponWorksLike[p->curr_weapon][snum], p->i, snum); + Gv_SetVar(g_iWorksLikeVarID,aplWeaponWorksLike[p->curr_weapon][snum], p->i, snum); } else { - SetGameVarID(g_iWorksLikeVarID,-1, p->i, snum); + Gv_SetVar(g_iWorksLikeVarID,-1, p->i, snum); } - OnEvent(EVENT_CHANGEWEAPON,p->i, snum, -1); + X_OnEvent(EVENT_CHANGEWEAPON,p->i, snum, -1); p->kickback_pic = 0; if (p->holster_weapon == 1) { @@ -269,7 +279,7 @@ void checkavailweapon(player_struct *p) else p->weapon_pos = -1; } -void hitradius(int i, int r, int hp1, int hp2, int hp3, int hp4) +void A_RadiusDamage(int i, int r, int hp1, int hp2, int hp3, int hp4) { spritetype *s=&sprite[i],*sj; walltype *wal; @@ -277,7 +287,9 @@ void hitradius(int i, int r, int hp1, int hp2, int hp3, int hp4) int sectcnt, sectend, dasect, startwall, endwall, nextsect; int j,k,p,x,nextj; short sect=-1; - char statlist[] = {0,1,6,10,12,2,5}; + char statlist[] = {STAT_DEFAULT,STAT_ACTOR,STAT_STANDABLE, + STAT_PLAYER,STAT_FALLER,STAT_ZOMBIEACTOR,STAT_MISC + }; short *tempshort = (short *)tempbuf; if (s->picnum == RPG && s->xrepeat < 11) goto SKIPWALLCHECK; @@ -296,12 +308,12 @@ void hitradius(int i, int r, int hp1, int hp2, int hp3, int hp4) { d = klabs(wall[sector[dasect].wallptr].x-s->x)+klabs(wall[sector[dasect].wallptr].y-s->y); if (d < r) - checkhitceiling(dasect); + Sect_DamageCeiling(dasect); else { d = klabs(wall[wall[wall[sector[dasect].wallptr].point2].point2].x-s->x)+klabs(wall[wall[wall[sector[dasect].wallptr].point2].point2].y-s->y); if (d < r) - checkhitceiling(dasect); + Sect_DamageCeiling(dasect); } } @@ -321,7 +333,7 @@ void hitradius(int i, int r, int hp1, int hp2, int hp3, int hp4) y1 = (((wal->y+wall[wal->point2].y)>>1)+s->y)>>1; updatesector(x1,y1,§); if (sect >= 0 && cansee(x1,y1,s->z,sect,s->x,s->y,s->z,s->sectnum)) - checkhitwall(i,x,wal->x,wal->y,s->z,s->picnum); + A_DamageWall(i,x,wal->x,wal->y,s->z,s->picnum); } } while (sectcnt < sectend); @@ -329,7 +341,7 @@ void hitradius(int i, int r, int hp1, int hp2, int hp3, int hp4) SKIPWALLCHECK: - q = -(16<<8)+(TRAND&((32<<8)-1)); + q = -(16<<8)+(krand()&((32<<8)-1)); for (x = 0;x<7;x++) { @@ -344,12 +356,12 @@ SKIPWALLCHECK: if (s->picnum != SHRINKSPARK || (sj->cstat&257)) if (dist(s, sj) < r) { - if (badguy(sj) && !cansee(sj->x, sj->y,sj->z+q, sj->sectnum, s->x, s->y, s->z+q, s->sectnum)) + if (A_CheckEnemySprite(sj) && !cansee(sj->x, sj->y,sj->z+q, sj->sectnum, s->x, s->y, s->z+q, s->sectnum)) goto BOLT; - checkhitsprite(j, i); + A_DamageObject(j, i); } } - else if (sj->extra >= 0 && sj != s && (sj->picnum == TRIPBOMB || badguy(sj) || sj->picnum == QUEBALL || sj->picnum == STRIPEBALL || (sj->cstat&257) || sj->picnum == DUKELYINGDEAD)) + else if (sj->extra >= 0 && sj != s && (sj->picnum == TRIPBOMB || A_CheckEnemySprite(sj) || sj->picnum == QUEBALL || sj->picnum == STRIPEBALL || (sj->cstat&257) || sj->picnum == DUKELYINGDEAD)) { if (s->picnum == SHRINKSPARK && sj->picnum != SHARK && (j == s->owner || sj->xrepeat < 24)) { @@ -368,17 +380,17 @@ SKIPWALLCHECK: if (d < r && cansee(sj->x, sj->y, sj->z-(8<<8), sj->sectnum, s->x, s->y, s->z-(12<<8), s->sectnum)) { - hittype[j].ang = getangle(sj->x-s->x,sj->y-s->y); + ActorExtra[j].ang = getangle(sj->x-s->x,sj->y-s->y); if (s->picnum == RPG && sj->extra > 0) - hittype[j].picnum = RPG; - else if (checkspriteflags(i,SPRITE_FLAG_PROJECTILE) && hittype[i].projectile.workslike & PROJECTILE_FLAG_RADIUS_PICNUM && sj->extra > 0) - hittype[j].picnum = s->picnum; + ActorExtra[j].picnum = RPG; + else if (A_CheckSpriteFlags(i,SPRITE_PROJECTILE) && ActorExtra[i].projectile.workslike & PROJECTILE_RADIUS_PICNUM && sj->extra > 0) + ActorExtra[j].picnum = s->picnum; else { if (s->picnum == SHRINKSPARK) - hittype[j].picnum = SHRINKSPARK; - else hittype[j].picnum = RADIUSEXPLOSION; + ActorExtra[j].picnum = SHRINKSPARK; + else ActorExtra[j].picnum = RADIUSEXPLOSION; } if (s->picnum != SHRINKSPARK) @@ -387,17 +399,17 @@ SKIPWALLCHECK: if (d < k) { if (hp4 == hp3) hp4++; - hittype[j].extra = hp3 + (TRAND%(hp4-hp3)); + ActorExtra[j].extra = hp3 + (krand()%(hp4-hp3)); } - else if (d < (k<<1)) + else if (d < (k*2)) { if (hp3 == hp2) hp3++; - hittype[j].extra = hp2 + (TRAND%(hp3-hp2)); + ActorExtra[j].extra = hp2 + (krand()%(hp3-hp2)); } else if (d < r) { if (hp2 == hp1) hp2++; - hittype[j].extra = hp1 + (TRAND%(hp2-hp1)); + ActorExtra[j].extra = hp1 + (krand()%(hp2-hp1)); } if (sprite[j].picnum != TANK && sprite[j].picnum != ROTATEGUN && sprite[j].picnum != RECON && sprite[j].picnum != BOSS1 && sprite[j].picnum != BOSS2 && sprite[j].picnum != BOSS3 && sprite[j].picnum != BOSS4) @@ -413,9 +425,9 @@ SKIPWALLCHECK: sj->picnum == FEM8 || sj->picnum == FEM9 || sj->picnum == FEM10 || sj->picnum == STATUE || sj->picnum == STATUEFLASH || sj->picnum == SPACEMARINE || sj->picnum == QUEBALL || sj->picnum == STRIPEBALL) - checkhitsprite(j, i); + A_DamageObject(j, i); } - else if (s->extra == 0) hittype[j].extra = 0; + else if (s->extra == 0) ActorExtra[j].extra = 0; if (sj->picnum != RADIUSEXPLOSION && s->owner >= 0 && sprite[s->owner].statnum < MAXSTATUS) @@ -431,9 +443,9 @@ SKIPWALLCHECK: g_player[p].ps->posz = g_player[p].ps->oposz; g_player[p].ps->ang = g_player[p].ps->oang; updatesector(g_player[p].ps->posx,g_player[p].ps->posy,&g_player[p].ps->cursectnum); - setpal(g_player[p].ps); + P_UpdateScreenPal(g_player[p].ps); - k = headspritestat[1]; + k = headspritestat[STAT_ACTOR]; while (k >= 0) { if (sprite[k].picnum==CAMERA1) @@ -442,7 +454,7 @@ SKIPWALLCHECK: } } } - hittype[j].owner = s->owner; + ActorExtra[j].owner = s->owner; } } } @@ -452,12 +464,12 @@ BOLT: } } -int movesprite(int spritenum, int xchange, int ychange, int zchange, unsigned int cliptype) +int A_MoveSprite(int spritenum, int xchange, int ychange, int zchange, unsigned int cliptype) { int daz, oldx, oldy; int retval; short dasectnum, cd; - int bg = badguy(&sprite[spritenum]); + int bg = A_CheckEnemySprite(&sprite[spritenum]); if (sprite[spritenum].statnum == 5 || (bg && sprite[spritenum].xrepeat < 4)) { @@ -484,7 +496,7 @@ int movesprite(int spritenum, int xchange, int ychange, int zchange, unsigned in { if (sprite[spritenum].picnum == LIZMAN) cd = 292L; - else if ((actortype[sprite[spritenum].picnum]&3)) + else if ((ActorType[sprite[spritenum].picnum]&3)) cd = sprite[spritenum].clipdist<<2; else cd = 192L; @@ -493,7 +505,7 @@ int movesprite(int spritenum, int xchange, int ychange, int zchange, unsigned in } if (dasectnum < 0 || (dasectnum >= 0 && - ((hittype[spritenum].actorstayput >= 0 && hittype[spritenum].actorstayput != dasectnum) || + ((ActorExtra[spritenum].actorstayput >= 0 && ActorExtra[spritenum].actorstayput != dasectnum) || ((sprite[spritenum].picnum == BOSS2) && sprite[spritenum].pal == 0 && sector[dasectnum].lotag != 3) || ((sprite[spritenum].picnum == BOSS1 || sprite[spritenum].picnum == BOSS2) && sector[dasectnum].lotag == 1) /*|| (sector[dasectnum].lotag == 1 && (sprite[spritenum].picnum == LIZMAN || (sprite[spritenum].picnum == LIZTROOP && sprite[spritenum].zvel == 0)))*/ @@ -503,14 +515,14 @@ int movesprite(int spritenum, int xchange, int ychange, int zchange, unsigned in sprite[spritenum].x = oldx; sprite[spritenum].y = oldy; /* if (dasectnum >= 0 && sector[dasectnum].lotag == 1 && sprite[spritenum].picnum == LIZMAN) - sprite[spritenum].ang = (TRAND&2047); - else if ((hittype[spritenum].temp_data[0]&3) == 1 && sprite[spritenum].picnum != COMMANDER) - sprite[spritenum].ang = (TRAND&2047); */ + sprite[spritenum].ang = (krand()&2047); + else if ((ActorExtra[spritenum].temp_data[0]&3) == 1 && sprite[spritenum].picnum != COMMANDER) + sprite[spritenum].ang = (krand()&2047); */ setsprite(spritenum,oldx,oldy,sprite[spritenum].z); if (dasectnum < 0) dasectnum = 0; return (16384+dasectnum); } - if ((retval&49152) >= 32768 && (hittype[spritenum].cgg==0)) sprite[spritenum].ang += 768; + if ((retval&49152) >= 32768 && (ActorExtra[spritenum].cgg==0)) sprite[spritenum].ang += 768; } else { @@ -526,7 +538,7 @@ int movesprite(int spritenum, int xchange, int ychange, int zchange, unsigned in if ((dasectnum != sprite[spritenum].sectnum)) changespritesect(spritenum,dasectnum); daz = sprite[spritenum].z + ((zchange*TICSPERFRAME)>>3); - if ((daz > hittype[spritenum].ceilingz) && (daz <= hittype[spritenum].floorz)) + if ((daz > ActorExtra[spritenum].ceilingz) && (daz <= ActorExtra[spritenum].floorz)) sprite[spritenum].z = daz; else if (retval == 0) return(16384+dasectnum); @@ -534,71 +546,72 @@ int movesprite(int spritenum, int xchange, int ychange, int zchange, unsigned in return(retval); } -inline int ssp(int i,unsigned int cliptype) //The set sprite function +inline int A_SetSprite(int i,unsigned int cliptype) //The set sprite function { - return (movesprite(i,(sprite[i].xvel*(sintable[(sprite[i].ang+512)&2047]))>>14, - (sprite[i].xvel*(sintable[sprite[i].ang&2047]))>>14,sprite[i].zvel, - cliptype)==0); + return (A_MoveSprite(i,(sprite[i].xvel*(sintable[(sprite[i].ang+512)&2047]))>>14, + (sprite[i].xvel*(sintable[sprite[i].ang&2047]))>>14,sprite[i].zvel, + cliptype)==0); } #undef deletesprite int block_deletesprite = 0; -void deletesprite_(int s) +void A_DeleteSprite(int s) { if (block_deletesprite) { - OSD_Printf(OSD_ERROR "deletesprite_(): tried to remove sprite %d in EVENT_EGS\n",s); + OSD_Printf(OSD_ERROR "A_DeleteSprite(): tried to remove sprite %d in EVENT_EGS\n",s); return; } if (apScriptGameEvent[EVENT_KILLIT]) { static int p, pl; - pl=findplayer(&sprite[s],&p); - SetGameVarID(g_iReturnVarID,0, -1, -1); - OnEvent(EVENT_KILLIT, s, pl, p); - if (GetGameVarID(g_iReturnVarID, -1, -1)) + pl=A_FindPlayer(&sprite[s],&p); + Gv_SetVar(g_iReturnVarID,0, -1, -1); + X_OnEvent(EVENT_KILLIT, s, pl, p); + if (Gv_GetVar(g_iReturnVarID, -1, -1)) return; } deletesprite(s); } -#define deletesprite deletesprite_ +#define deletesprite A_DeleteSprite -void insertspriteq(int i) +void A_AddToDeleteQueue(int i) { - if (spriteqamount == 0) + if (g_spriteDeleteQueueSize == 0) { deletesprite(i); return; } - if (spriteq[spriteqloc] >= 0) - sprite[spriteq[spriteqloc]].xrepeat = 0; - spriteq[spriteqloc] = i; - spriteqloc = (spriteqloc+1)%spriteqamount; + if (SpriteDeletionQueue[g_spriteDeleteQueuePos] >= 0) + sprite[SpriteDeletionQueue[g_spriteDeleteQueuePos]].xrepeat = 0; + SpriteDeletionQueue[g_spriteDeleteQueuePos] = i; + g_spriteDeleteQueuePos = (g_spriteDeleteQueuePos+1)%g_spriteDeleteQueueSize; } -void lotsofmoneymailpaper(int sp, int n, int pic) +void A_SpawnMultiple(int sp, int pic, int n) { - int i=n ,j; + int j; spritetype *s = &sprite[sp]; - for (;i>0;i--) + for (;n>0;n--) { - j = EGS(s->sectnum,s->x,s->y,s->z-(TRAND%(47<<8)),pic,-32,8,8,TRAND&2047,0,0,sp,5); - sprite[j].cstat = TRAND&12; + j = A_InsertSprite(s->sectnum,s->x,s->y,s->z-(krand()%(47<<8)),pic,-32,8,8,krand()&2047,0,0,sp,5); + A_Spawn(-1, j); + sprite[j].cstat = krand()&12; } } -void guts(int sp, int gtype, int n) +void A_DoGuts(int sp, int gtype, int n) { int gutz,floorz; int i,a,j,sx = 32,sy = 32; // int pal; spritetype *s = &sprite[sp]; - if (badguy(s) && s->xrepeat < 16) + if (A_CheckEnemySprite(s) && s->xrepeat < 16) sx = sy = 8; gutz = s->z-(8<<8); @@ -610,14 +623,14 @@ void guts(int sp, int gtype, int n) if (s->picnum == COMMANDER) gutz -= (24<<8); -// if (badguy(s) && s->pal == 6) +// if (A_CheckEnemySprite(s) && s->pal == 6) // pal = 6; // else pal = 0; for (j=n;j>0;j--) { - a = TRAND&2047; - i = EGS(s->sectnum,s->x+(TRAND&255)-128,s->y+(TRAND&255)-128,gutz-(TRAND&8191),gtype,-32,sx,sy,a,48+(TRAND&31),-512-(TRAND&2047),sp,5); + a = krand()&2047; + i = A_InsertSprite(s->sectnum,s->x+(krand()&255)-128,s->y+(krand()&255)-128,gutz-(krand()&8191),gtype,-32,sx,sy,a,48+(krand()&31),-512-(krand()&2047),sp,5); if (PN == JIBS2) { sprite[i].xrepeat >>= 2; @@ -629,13 +642,13 @@ void guts(int sp, int gtype, int n) } } -void gutsdir(int sp, int gtype, int n) +void A_DoGutsDir(int sp, int gtype, int n) { int gutz,floorz; int i,a,j,sx = 32,sy = 32; spritetype *s = &sprite[sp]; - if (badguy(s) && s->xrepeat < 16) + if (A_CheckEnemySprite(s) && s->xrepeat < 16) sx = sy = 8; gutz = s->z-(8<<8); @@ -649,44 +662,44 @@ void gutsdir(int sp, int gtype, int n) for (j=n;j>0;j--) { - a = TRAND&2047; - i = EGS(s->sectnum,s->x,s->y,gutz,gtype,-32,sx,sy,a,256+(TRAND&127),-512-(TRAND&2047),sp,5); + a = krand()&2047; + i = A_InsertSprite(s->sectnum,s->x,s->y,gutz,gtype,-32,sx,sy,a,256+(krand()&127),-512-(krand()&2047),sp,5); sprite[i].pal = s->pal; } } -void setsectinterpolate(int i) +void Sect_SetInterpolation(int i) { int k, j = sector[SECT].wallptr,endwall = j+sector[SECT].wallnum; for (;j= 0) { - setinterpolation(&wall[k].x); - setinterpolation(&wall[k].y); + G_SetInterpolation(&wall[k].x); + G_SetInterpolation(&wall[k].y); k = wall[k].point2; - setinterpolation(&wall[k].x); - setinterpolation(&wall[k].y); + G_SetInterpolation(&wall[k].x); + G_SetInterpolation(&wall[k].y); } } } -void clearsectinterpolate(int i) +void Sect_ClearInterpolation(int i) { int j = sector[SECT].wallptr,endwall = j+sector[SECT].wallnum; for (;j= 0) { - stopinterpolation(&wall[wall[j].nextwall].x); - stopinterpolation(&wall[wall[j].nextwall].y); + G_StopInterpolation(&wall[wall[j].nextwall].x); + G_StopInterpolation(&wall[wall[j].nextwall].y); } } } @@ -715,10 +728,11 @@ static void ms(int i) } } -static void movefta(void) +// sleeping monsters, etc +static void G_MoveZombieActors(void) { int x, px, py, sx, sy; - int i = headspritestat[2], j, p, nexti; + int i = headspritestat[STAT_ZOMBIEACTOR], j, p, nexti; short psect, ssect; spritetype *s; @@ -727,7 +741,7 @@ static void movefta(void) nexti = nextspritestat[i]; s = &sprite[i]; - p = findplayer(s,&x); + p = A_FindPlayer(s,&x); ssect = psect = s->sectnum; @@ -735,35 +749,35 @@ static void movefta(void) { if (x < 30000) { - hittype[i].timetosleep++; - if (hittype[i].timetosleep >= (x>>8)) + ActorExtra[i].timetosleep++; + if (ActorExtra[i].timetosleep >= (x>>8)) { - if (badguy(s)) + if (A_CheckEnemySprite(s)) { - px = g_player[p].ps->oposx+64-(TRAND&127); - py = g_player[p].ps->oposy+64-(TRAND&127); + px = g_player[p].ps->oposx+64-(krand()&127); + py = g_player[p].ps->oposy+64-(krand()&127); updatesector(px,py,&psect); if (psect == -1) { i = nexti; continue; } - sx = s->x+64-(TRAND&127); - sy = s->y+64-(TRAND&127); + sx = s->x+64-(krand()&127); + sy = s->y+64-(krand()&127); updatesector(px,py,&ssect); if (ssect == -1) { i = nexti; continue; } - j = cansee(sx,sy,s->z-(TRAND%(52<<8)),s->sectnum,px,py,g_player[p].ps->oposz-(TRAND%(32<<8)),g_player[p].ps->cursectnum); + j = cansee(sx,sy,s->z-(krand()%(52<<8)),s->sectnum,px,py,g_player[p].ps->oposz-(krand()%(32<<8)),g_player[p].ps->cursectnum); } else - j = cansee(s->x,s->y,s->z-((TRAND&31)<<8),s->sectnum,g_player[p].ps->oposx,g_player[p].ps->oposy,g_player[p].ps->oposz-((TRAND&31)<<8),g_player[p].ps->cursectnum); + j = cansee(s->x,s->y,s->z-((krand()&31)<<8),s->sectnum,g_player[p].ps->oposx,g_player[p].ps->oposy,g_player[p].ps->oposz-((krand()&31)<<8),g_player[p].ps->cursectnum); // j = 1; - if (j) switch (dynamictostatic[s->picnum]) + if (j) switch (DynamicTileMap[s->picnum]) { case RUBBERCAN__STATIC: case EXPLODINGBARREL__STATIC: @@ -779,23 +793,23 @@ static void movefta(void) case NUKEBARRELDENTED__STATIC: case NUKEBARRELLEAKED__STATIC: case TRIPBOMB__STATIC: - if (sector[s->sectnum].ceilingstat&1 && checkspriteflags(j,SPRITE_FLAG_NOSHADE) == 0) + if (sector[s->sectnum].ceilingstat&1 && A_CheckSpriteFlags(j,SPRITE_NOSHADE) == 0) s->shade = sector[s->sectnum].ceilingshade; else s->shade = sector[s->sectnum].floorshade; - hittype[i].timetosleep = 0; + ActorExtra[i].timetosleep = 0; changespritestat(i,6); break; default: - hittype[i].timetosleep = 0; - check_fta_sounds(i); + ActorExtra[i].timetosleep = 0; + A_PlayAlertSound(i); changespritestat(i,1); break; } - else hittype[i].timetosleep = 0; + else ActorExtra[i].timetosleep = 0; } } - if (badguy(s) && checkspriteflags(i,SPRITE_FLAG_NOSHADE) == 0) + if (A_CheckEnemySprite(s) && A_CheckSpriteFlags(i,SPRITE_NOSHADE) == 0) { if (sector[s->sectnum].ceilingstat&1) s->shade = sector[s->sectnum].ceilingshade; @@ -808,7 +822,7 @@ static void movefta(void) static inline int ifhitsectors(int sectnum) { - int i = headspritestat[5]; + int i = headspritestat[STAT_MISC]; while (i >= 0) { if (PN == EXPLOSION2 && sectnum == SECT) @@ -820,12 +834,12 @@ static inline int ifhitsectors(int sectnum) #define IFHITSECT j=ifhitsectors(s->sectnum);if(j >= 0) -int ifhitbyweapon(int sn) +int A_IncurDamage(int sn) { int j,p; spritetype *npc; - if (hittype[sn].extra >= 0) + if (ActorExtra[sn].extra >= 0) { if (sprite[sn].extra >= 0) { @@ -833,57 +847,57 @@ int ifhitbyweapon(int sn) if (npc->picnum == APLAYER) { - if (ud.god && hittype[sn].picnum != SHRINKSPARK) return -1; + if (ud.god && ActorExtra[sn].picnum != SHRINKSPARK) return -1; p = npc->yvel; - j = hittype[sn].owner; + j = ActorExtra[sn].owner; if (j >= 0 && sprite[j].picnum == APLAYER && - (gametype_flags[ud.coop] & GAMETYPE_FLAG_PLAYERSFRIENDLY) && + (GametypeFlags[ud.coop] & GAMETYPE_PLAYERSFRIENDLY) && ud.ffire == 0) return -1; if (j >= 0 && sprite[j].picnum == APLAYER && - (gametype_flags[ud.coop] & GAMETYPE_FLAG_TDM) && + (GametypeFlags[ud.coop] & GAMETYPE_TDM) && g_player[p].ps->team == g_player[sprite[j].yvel].ps->team && ud.ffire == 0) return -1; - npc->extra -= hittype[sn].extra; + npc->extra -= ActorExtra[sn].extra; if (j >= 0) { - if (npc->extra <= 0 && hittype[sn].picnum != FREEZEBLAST) + if (npc->extra <= 0 && ActorExtra[sn].picnum != FREEZEBLAST) { npc->extra = 0; g_player[p].ps->wackedbyactor = j; - if (sprite[hittype[sn].owner].picnum == APLAYER && p != sprite[hittype[sn].owner].yvel) + if (sprite[ActorExtra[sn].owner].picnum == APLAYER && p != sprite[ActorExtra[sn].owner].yvel) g_player[p].ps->frag_ps = sprite[j].yvel; - hittype[sn].owner = g_player[p].ps->i; + ActorExtra[sn].owner = g_player[p].ps->i; } } - if (checkspriteflagsp(hittype[sn].picnum,SPRITE_FLAG_PROJECTILE) && (hittype[sn].projectile.workslike & PROJECTILE_FLAG_RPG)) + if (A_CheckSpriteTileFlags(ActorExtra[sn].picnum,SPRITE_PROJECTILE) && (ActorExtra[sn].projectile.workslike & PROJECTILE_RPG)) { g_player[p].ps->posxv += - hittype[sn].extra*(sintable[(hittype[sn].ang+512)&2047])<<2; + ActorExtra[sn].extra*(sintable[(ActorExtra[sn].ang+512)&2047])<<2; g_player[p].ps->posyv += - hittype[sn].extra*(sintable[hittype[sn].ang&2047])<<2; + ActorExtra[sn].extra*(sintable[ActorExtra[sn].ang&2047])<<2; } - else if (checkspriteflagsp(hittype[sn].picnum,SPRITE_FLAG_PROJECTILE)) + else if (A_CheckSpriteTileFlags(ActorExtra[sn].picnum,SPRITE_PROJECTILE)) { g_player[p].ps->posxv += - hittype[sn].extra*(sintable[(hittype[sn].ang+512)&2047])<<1; + ActorExtra[sn].extra*(sintable[(ActorExtra[sn].ang+512)&2047])<<1; g_player[p].ps->posyv += - hittype[sn].extra*(sintable[hittype[sn].ang&2047])<<1; + ActorExtra[sn].extra*(sintable[ActorExtra[sn].ang&2047])<<1; } - switch (dynamictostatic[hittype[sn].picnum]) + switch (DynamicTileMap[ActorExtra[sn].picnum]) { case RADIUSEXPLOSION__STATIC: case RPG__STATIC: @@ -893,45 +907,45 @@ int ifhitbyweapon(int sn) case OOZFILTER__STATIC: case EXPLODINGBARREL__STATIC: g_player[p].ps->posxv += - hittype[sn].extra*(sintable[(hittype[sn].ang+512)&2047])<<2; + ActorExtra[sn].extra*(sintable[(ActorExtra[sn].ang+512)&2047])<<2; g_player[p].ps->posyv += - hittype[sn].extra*(sintable[hittype[sn].ang&2047])<<2; + ActorExtra[sn].extra*(sintable[ActorExtra[sn].ang&2047])<<2; break; default: g_player[p].ps->posxv += - hittype[sn].extra*(sintable[(hittype[sn].ang+512)&2047])<<1; + ActorExtra[sn].extra*(sintable[(ActorExtra[sn].ang+512)&2047])<<1; g_player[p].ps->posyv += - hittype[sn].extra*(sintable[hittype[sn].ang&2047])<<1; + ActorExtra[sn].extra*(sintable[ActorExtra[sn].ang&2047])<<1; break; } } else { - if (hittype[sn].extra == 0) - if (hittype[sn].picnum == SHRINKSPARK && npc->xrepeat < 24) + if (ActorExtra[sn].extra == 0) + if (ActorExtra[sn].picnum == SHRINKSPARK && npc->xrepeat < 24) return -1; - npc->extra -= hittype[sn].extra; + npc->extra -= ActorExtra[sn].extra; if (npc->picnum != RECON && npc->owner >= 0 && sprite[npc->owner].statnum < MAXSTATUS) - npc->owner = hittype[sn].owner; + npc->owner = ActorExtra[sn].owner; } - hittype[sn].extra = -1; - return hittype[sn].picnum; + ActorExtra[sn].extra = -1; + return ActorExtra[sn].picnum; } } - hittype[sn].extra = -1; + ActorExtra[sn].extra = -1; return -1; } -void movecyclers(void) +void A_MoveCyclers(void) { int q, j, x, t, s, cshade; short *c; walltype *wal; - for (q=numcyclers-1;q>=0;q--) + for (q=g_numCyclers-1;q>=0;q--) { c = &cyclers[q][0]; @@ -962,9 +976,9 @@ void movecyclers(void) } } -void movedummyplayers(void) +void A_MoveDummyPlayers(void) { - int i = headspritestat[13], p, nexti; + int i = headspritestat[STAT_DUMMYPLAYER], p, nexti; while (i >= 0) { @@ -1007,12 +1021,12 @@ BOLT: int otherp; -static void moveplayers(void) //Players +static void G_MovePlayers(void) //Players { - int i = headspritestat[10], nexti; + int i = headspritestat[STAT_PLAYER], nexti; int otherx; spritetype *s; - player_struct *p; + DukePlayer_t *p; while (i >= 0) { @@ -1026,14 +1040,14 @@ static void moveplayers(void) //Players { s->x = p->oposx; s->y = p->oposy; - hittype[i].bposz = s->z = p->oposz+PHEIGHT; + ActorExtra[i].bposz = s->z = p->oposz+PHEIGHT; s->ang = p->oang; setsprite(i,s->x,s->y,s->z); } else { if (ud.multimode > 1) - otherp = findotherplayer(s->yvel,&otherx); + otherp = P_FindOtherPlayer(s->yvel,&otherx); else { otherp = s->yvel; @@ -1041,7 +1055,7 @@ static void moveplayers(void) //Players } if (actorscrptr[sprite[i].picnum]) - execute(i,s->yvel,otherx); + A_Execute(i,s->yvel,otherx); if (ud.multimode > 1) if (sprite[g_player[otherp].ps->i].extra > 0) @@ -1066,11 +1080,11 @@ static void moveplayers(void) //Players if (s->extra > 0) { - hittype[i].owner = i; + ActorExtra[i].owner = i; if (ud.god == 0) - if (ceilingspace(s->sectnum) || floorspace(s->sectnum)) - quickkill(p); + if (G_CheckForSpaceCeiling(s->sectnum) || G_CheckForSpaceFloor(s->sectnum)) + P_QuickKill(p); } else { @@ -1083,7 +1097,7 @@ static void moveplayers(void) //Players if (p->wackedbyactor >= 0 && sprite[p->wackedbyactor].statnum < MAXSTATUS) { - p->ang += getincangle(p->ang,getangle(sprite[p->wackedbyactor].x-p->posx,sprite[p->wackedbyactor].y-p->posy))>>1; + p->ang += G_GetAngleDelta(p->ang,getangle(sprite[p->wackedbyactor].x-p->posx,sprite[p->wackedbyactor].y-p->posy))>>1; p->ang &= 2047; } @@ -1096,9 +1110,9 @@ static void moveplayers(void) //Players if (p->holoduke_on == -1) KILLIT(i); - hittype[i].bposx = s->x; - hittype[i].bposy = s->y; - hittype[i].bposz = s->z; + ActorExtra[i].bposx = s->x; + ActorExtra[i].bposy = s->y; + ActorExtra[i].bposz = s->z; s->cstat = 0; @@ -1114,7 +1128,7 @@ static void moveplayers(void) //Players { s->yrepeat = 36; if (sector[s->sectnum].lotag != 2) - makeitfall(i); + A_Fall(i); if (s->zvel == 0 && sector[s->sectnum].lotag == 1) s->z += (32<<8); } @@ -1124,7 +1138,7 @@ static void moveplayers(void) //Players s->xvel = 128; s->ang = p->ang; s->extra++; - ssp(i,CLIPMASK0); + A_SetSprite(i,CLIPMASK0); } else { @@ -1143,9 +1157,9 @@ BOLT: } } -static void movefx(void) +static void G_MoveFX(void) { - int i = headspritestat[11], j, nexti, p; + int i = headspritestat[STAT_FX], j, nexti, p; int x, ht; spritetype *s; @@ -1155,12 +1169,12 @@ static void movefx(void) nexti = nextspritestat[i]; - switch (dynamictostatic[s->picnum]) + switch (DynamicTileMap[s->picnum]) { case RESPAWN__STATIC: if (sprite[i].extra == 66) { - j = spawn(i,SHT); + j = A_Spawn(i,SHT); // sprite[j].pal = sprite[i].pal; KILLIT(i); } @@ -1200,39 +1214,40 @@ static void movefx(void) x = dist(&sprite[g_player[screenpeek].ps->i],s); if (x < ht && T1 == 0 && FX_VoiceAvailable(g_sounds[s->lotag].pr-1)) { - if (numenvsnds == ud.config.NumVoices) + if (g_numEnvSoundsPlaying == ud.config.NumVoices) { - j = headspritestat[11]; + j = headspritestat[STAT_FX]; while (j >= 0) { - if (PN == MUSICANDSFX && j != i && sprite[j].lotag < 999 && hittype[j].temp_data[0] == 1 && dist(&sprite[j],&sprite[g_player[screenpeek].ps->i]) > x) + if (PN == MUSICANDSFX && j != i && sprite[j].lotag < 999 && ActorExtra[j].temp_data[0] == 1 && dist(&sprite[j],&sprite[g_player[screenpeek].ps->i]) > x) { - stopenvsound(sprite[j].lotag,j); + S_StopEnvSound(sprite[j].lotag,j); break; } j = nextspritestat[j]; } if (j == -1) goto BOLT; } - spritesound(s->lotag,i); + A_PlaySound(s->lotag,i); T1 = 1; } if (x >= ht && T1 == 1) { T1 = 0; - stopenvsound(s->lotag,i); + S_StopEnvSound(s->lotag,i); } } if ((g_sounds[s->lotag].m&16)) { if (T5 > 0) T5--; - else for (p=connecthead;p>=0;p=connectpoint2[p]) - if (p == myconnectindex && g_player[p].ps->cursectnum == s->sectnum) - { - j = s->lotag+((unsigned)global_random%(s->hitag+1)); - sound(j); - T5 = 26*40 + (global_random%(26*40)); - } + else + TRAVERSE_CONNECT(p) + if (p == myconnectindex && g_player[p].ps->cursectnum == s->sectnum) + { + j = s->lotag+((unsigned)g_globalRandom%(s->hitag+1)); + S_PlaySound(j); + T5 = 26*40 + (g_globalRandom%(26*40)); + } } } break; @@ -1242,9 +1257,9 @@ BOLT: } } -static void movefallers(void) +static void G_MoveFallers(void) { - int i = headspritestat[12], nexti, sect, j; + int i = headspritestat[STAT_FALLER], nexti, sect, j; spritetype *s; int x; @@ -1267,12 +1282,12 @@ static void movefallers(void) if (s->extra <= 0) { T1 = 1; - j = headspritestat[12]; + j = headspritestat[STAT_FALLER]; while (j >= 0) { if (sprite[j].hitag == SHT) { - hittype[j].temp_data[0] = 1; + ActorExtra[j].temp_data[0] = 1; sprite[j].cstat &= (65535-64); if (sprite[j].picnum == CEILINGSTEAM || sprite[j].picnum == STEAM) sprite[j].cstat |= 32768; @@ -1283,7 +1298,7 @@ static void movefallers(void) } else { - hittype[i].extra = 0; + ActorExtra[i].extra = 0; s->extra = x; } } @@ -1297,8 +1312,8 @@ static void movefallers(void) s->lotag-=3; if (s->lotag <= 0) { - s->xvel = (32+(TRAND&63)); - s->zvel = -(1024+(TRAND&1023)); + s->xvel = (32+(krand()&63)); + s->zvel = -(1024+(krand()&1023)); } } else @@ -1306,16 +1321,16 @@ static void movefallers(void) if (s->xvel > 0) { s->xvel -= 8; - ssp(i,CLIPMASK0); + A_SetSprite(i,CLIPMASK0); } - if (floorspace(s->sectnum)) x = 0; + if (G_CheckForSpaceFloor(s->sectnum)) x = 0; else { - if (ceilingspace(s->sectnum)) - x = gc/6; + if (G_CheckForSpaceCeiling(s->sectnum)) + x = SpriteGravity/6; else - x = gc; + x = SpriteGravity; } if (s->z < (sector[sect].floorz-FOURSLEIGHT)) @@ -1327,7 +1342,7 @@ static void movefallers(void) } if ((sector[sect].floorz-s->z) < (16<<8)) { - j = 1+(TRAND&7); + j = 1+(krand()&7); for (x=0;xsectnum; if (sect < 0) KILLIT(i); - hittype[i].bposx = s->x; - hittype[i].bposy = s->y; - hittype[i].bposz = s->z; + ActorExtra[i].bposx = s->x; + ActorExtra[i].bposy = s->y; + ActorExtra[i].bposz = s->z; IFWITHIN(CRANE,CRANE+3) { //t[0] = state //t[1] = checking sector number - if (s->xvel) getglobalz(i); + if (s->xvel) A_GetZLimits(i); if (t[0] == 0) //Waiting to check the sector { @@ -1396,7 +1411,7 @@ static void movestandables(void) s->picnum = CRANE+1; s->xvel += 8; } - ssp(i,CLIPMASK0); + A_SetSprite(i,CLIPMASK0); if (sect == t[1]) t[0]++; } @@ -1421,8 +1436,8 @@ static void movestandables(void) { if (s->owner==-2) { - p = findplayer(s,&x); - spritesound(DUKE_GRUNT,g_player[p].ps->i); + p = A_FindPlayer(s,&x); + A_PlaySound(DUKE_GRUNT,g_player[p].ps->i); if (g_player[p].ps->on_crane == i) g_player[p].ps->on_crane = -1; } @@ -1437,12 +1452,12 @@ static void movestandables(void) s->picnum++; if (s->picnum == (CRANE+2)) { - p = checkcursectnums(t[1]); + p = CheckPlayerInSector(t[1]); if (p >= 0 && g_player[p].ps->on_ground) { s->owner = -2; g_player[p].ps->on_crane = i; - spritesound(DUKE_GRUNT,g_player[p].ps->i); + A_PlaySound(DUKE_GRUNT,g_player[p].ps->i); g_player[p].ps->ang = s->ang+1024; } else @@ -1491,7 +1506,7 @@ static void movestandables(void) if (s->xvel < 192) s->xvel += 8; s->ang = getangle(msx[t[4]]-s->x,msy[t[4]]-s->y); - ssp(i,CLIPMASK0); + A_SetSprite(i,CLIPMASK0); if (((s->x-msx[t[4]])*(s->x-msx[t[4]])+(s->y-msy[t[4]])*(s->y-msy[t[4]])) < (128*128)) t[0]++; } @@ -1503,7 +1518,7 @@ static void movestandables(void) if (s->owner != -1) { - p = findplayer(s,&x); + p = A_FindPlayer(s,&x); IFHIT { @@ -1519,9 +1534,9 @@ static void movestandables(void) { setsprite(s->owner,s->x,s->y,s->z); - hittype[s->owner].bposx = s->x; - hittype[s->owner].bposy = s->y; - hittype[s->owner].bposz = s->z; + ActorExtra[s->owner].bposx = s->x; + ActorExtra[s->owner].bposy = s->y; + ActorExtra[s->owner].bposz = s->z; s->zvel = 0; } @@ -1553,7 +1568,7 @@ static void movestandables(void) } else { - p = findplayer(s,&x); + p = A_FindPlayer(s,&x); if (x > 512) { @@ -1576,7 +1591,7 @@ static void movestandables(void) if (s->picnum == TIRE && T2 == 32) { s->cstat = 0; - j = spawn(i,BLOODPOOL); + j = A_Spawn(i,BLOODPOOL); sprite[j].shade = 127; } else @@ -1585,7 +1600,7 @@ static void movestandables(void) else KILLIT(i); } - j = s->xrepeat-(TRAND&7); + j = s->xrepeat-(krand()&7); if (j < 10) { KILLIT(i); @@ -1593,7 +1608,7 @@ static void movestandables(void) s->xrepeat = j; - j = s->yrepeat-(TRAND&7); + j = s->yrepeat-(krand()&7); if (j < 4) { KILLIT(i); @@ -1602,49 +1617,49 @@ static void movestandables(void) } if (s->picnum == BOX) { - makeitfall(i); - hittype[i].ceilingz = sector[s->sectnum].ceilingz; + A_Fall(i); + ActorExtra[i].ceilingz = sector[s->sectnum].ceilingz; } goto BOLT; } if (s->picnum == TRIPBOMB) { - // int lTripBombControl=GetGameVar("TRIPBOMB_CONTROL", TRIPBOMB_TRIPWIRE, -1, -1); + // int lTripBombControl=Gv_GetVarByLabel("TRIPBOMB_CONTROL", TRIPBOMB_TRIPWIRE, -1, -1); // if(lTripBombControl & TRIPBOMB_TIMER) - if (hittype[i].temp_data[6] == 1) + if (ActorExtra[i].temp_data[6] == 1) { - if (hittype[i].temp_data[7] >= 1) + if (ActorExtra[i].temp_data[7] >= 1) { - hittype[i].temp_data[7]--; + ActorExtra[i].temp_data[7]--; } - if (hittype[i].temp_data[7] <= 0) + if (ActorExtra[i].temp_data[7] <= 0) { // s->extra = *actorscrptr[s->picnum]; T3=16; - hittype[i].temp_data[6]=3; - spritesound(LASERTRIP_ARMING,i); + ActorExtra[i].temp_data[6]=3; + A_PlaySound(LASERTRIP_ARMING,i); } // we're on a timer.... } - if (T3 > 0 && hittype[i].temp_data[6] == 3) + if (T3 > 0 && ActorExtra[i].temp_data[6] == 3) { T3--; if (T3 == 8) { - spritesound(LASERTRIP_EXPLODE,i); + A_PlaySound(LASERTRIP_EXPLODE,i); for (j=0;j<5;j++) RANDOMSCRAP; x = s->extra; - hitradius(i, tripbombblastradius, x>>2,x>>1,x-(x>>2),x); + A_RadiusDamage(i, g_tripbombBlastRadius, x>>2,x>>1,x-(x>>2),x); - j = spawn(i,EXPLOSION2); + j = A_Spawn(i,EXPLOSION2); sprite[j].ang = s->ang; sprite[j].xvel = 348; - ssp(j,CLIPMASK0); + A_SetSprite(j,CLIPMASK0); - j = headspritestat[5]; + j = headspritestat[STAT_MISC]; while (j >= 0) { if (sprite[j].picnum == LASERLINE && s->hitag == sprite[j].hitag) @@ -1660,7 +1675,7 @@ static void movestandables(void) x = s->extra; s->extra = 1; l = s->ang; - IFHIT { hittype[i].temp_data[6] = 3; + IFHIT { ActorExtra[i].temp_data[6] = 3; T3 = 16; } s->extra = x; @@ -1669,7 +1684,7 @@ static void movestandables(void) if (T1 < 32) { - p = findplayer(s,&x); + p = A_FindPlayer(s,&x); if (x > 768) T1++; else if (T1 > 16) T1++; } @@ -1685,25 +1700,25 @@ static void movestandables(void) s->z -= (3<<8); setsprite(i,s->x,s->y,s->z); - x = hitasprite(i,&m); + x = A_CheckHitSprite(i,&m); - hittype[i].lastvx = x; + ActorExtra[i].lastvx = x; s->ang = l; k = 0; // if(lTripBombControl & TRIPBOMB_TRIPWIRE) - if (hittype[i].temp_data[6] != 1) + if (ActorExtra[i].temp_data[6] != 1) { // we're on a trip wire while (x > 0) { - j = spawn(i,LASERLINE); + j = A_Spawn(i,LASERLINE); setsprite(j,sprite[j].x,sprite[j].y,sprite[j].z); sprite[j].hitag = s->hitag; - hittype[j].temp_data[1] = sprite[j].z; + ActorExtra[j].temp_data[1] = sprite[j].z; s->x += sintable[(T6+512)&2047]>>4; s->y += sintable[(T6)&2047]>>4; @@ -1723,11 +1738,11 @@ static void movestandables(void) setsprite(i,s->x,s->y,s->z); T4 = 0; // if( m >= 0 && lTripBombControl & TRIPBOMB_TRIPWIRE) - if (m >= 0 && hittype[i].temp_data[6] != 1) + if (m >= 0 && ActorExtra[i].temp_data[6] != 1) { - hittype[i].temp_data[6] = 3; + ActorExtra[i].temp_data[6] = 3; T3 = 13; - spritesound(LASERTRIP_ARMING,i); + A_PlaySound(LASERTRIP_ARMING,i); } else T3 = 0; } @@ -1743,19 +1758,19 @@ static void movestandables(void) s->z -= (3<<8); setsprite(i,s->x,s->y,s->z); - x = hitasprite(i,&m); + x = A_CheckHitSprite(i,&m); s->x = T4; s->y = T5; s->z += (3<<8); setsprite(i,s->x,s->y,s->z); - // if( hittype[i].lastvx != x && lTripBombControl & TRIPBOMB_TRIPWIRE) - if (hittype[i].lastvx != x && hittype[i].temp_data[6] != 1) + // if( ActorExtra[i].lastvx != x && lTripBombControl & TRIPBOMB_TRIPWIRE) + if (ActorExtra[i].lastvx != x && ActorExtra[i].temp_data[6] != 1) { - hittype[i].temp_data[6] = 3; + ActorExtra[i].temp_data[6] = 3; T3 = 13; - spritesound(LASERTRIP_ARMING,i); + A_PlaySound(LASERTRIP_ARMING,i); } } goto BOLT; @@ -1768,10 +1783,10 @@ static void movestandables(void) { t[0] = s->cstat; t[1] = s->ang; - j = ifhitbyweapon(i); + j = A_IncurDamage(i); if (j == FIREEXT || j == RPG || j == RADIUSEXPLOSION || j == SEENINE || j == OOZFILTER) { - j = headspritestat[6]; + j = headspritestat[STAT_STANDABLE]; while (j >= 0) { if (s->hitag == sprite[j].hitag && (sprite[j].picnum == OOZFILTER || sprite[j].picnum == SEENINE)) @@ -1794,22 +1809,22 @@ static void movestandables(void) if (s->picnum == FIREEXT) { - j = ifhitbyweapon(i); + j = A_IncurDamage(i); if (j == -1) goto BOLT; for (k=0;k<16;k++) { - j = EGS(SECT,SX,SY,SZ-(TRAND%(48<<8)),SCRAP3+(TRAND&3),-8,48,48,TRAND&2047,(TRAND&63)+64,-(TRAND&4095)-(sprite[i].zvel>>2),i,5); + j = A_InsertSprite(SECT,SX,SY,SZ-(krand()%(48<<8)),SCRAP3+(krand()&3),-8,48,48,krand()&2047,(krand()&63)+64,-(krand()&4095)-(sprite[i].zvel>>2),i,5); sprite[j].pal = 2; } - spawn(i,EXPLOSION2); - spritesound(PIPEBOMB_EXPLODE,i); - spritesound(GLASS_HEAVYBREAK,i); + A_Spawn(i,EXPLOSION2); + A_PlaySound(PIPEBOMB_EXPLODE,i); + A_PlaySound(GLASS_HEAVYBREAK,i); if (s->hitag > 0) { - j = headspritestat[6]; + j = headspritestat[STAT_STANDABLE]; while (j >= 0) { if (s->hitag == sprite[j].hitag && (sprite[j].picnum == OOZFILTER || sprite[j].picnum == SEENINE)) @@ -1819,15 +1834,15 @@ static void movestandables(void) } x = s->extra; - spawn(i,EXPLOSION2); - hitradius(i, pipebombblastradius,x>>2, x-(x>>1),x-(x>>2), x); - spritesound(PIPEBOMB_EXPLODE,i); + A_Spawn(i,EXPLOSION2); + A_RadiusDamage(i, g_pipebombBlastRadius,x>>2, x-(x>>1),x-(x>>2), x); + A_PlaySound(PIPEBOMB_EXPLODE,i); goto DETONATE; } else { - hitradius(i,seenineblastradius,10,15,20,25); + A_RadiusDamage(i,g_seenineBlastRadius,10,15,20,25); KILLIT(i); } goto BOLT; @@ -1838,7 +1853,7 @@ static void movestandables(void) if (s->shade != -32 && s->shade != -33) { if (s->xrepeat) - j = (ifhitbyweapon(i) >= 0); + j = (A_IncurDamage(i) >= 0); else j = 0; @@ -1848,7 +1863,7 @@ static void movestandables(void) t[3] = 1; - j = headspritestat[6]; + j = headspritestat[STAT_STANDABLE]; while (j >= 0) { if (s->hitag == sprite[j].hitag && (sprite[j].picnum == SEENINE || sprite[j].picnum == OOZFILTER)) @@ -1896,27 +1911,27 @@ static void movestandables(void) DETONATE: - earthquaketime = 16; + g_earthquakeTime = 16; - j = headspritestat[3]; + j = headspritestat[STAT_EFFECTOR]; while (j >= 0) { if (s->hitag == sprite[j].hitag) { if (sprite[j].lotag == 13) { - if (hittype[j].temp_data[2] == 0) - hittype[j].temp_data[2] = 1; + if (ActorExtra[j].temp_data[2] == 0) + ActorExtra[j].temp_data[2] = 1; } else if (sprite[j].lotag == 8) - hittype[j].temp_data[4] = 1; + ActorExtra[j].temp_data[4] = 1; else if (sprite[j].lotag == 18) { - if (hittype[j].temp_data[0] == 0) - hittype[j].temp_data[0] = 1; + if (ActorExtra[j].temp_data[0] == 0) + ActorExtra[j].temp_data[0] = 1; } else if (sprite[j].lotag == 21) - hittype[j].temp_data[0] = 1; + ActorExtra[j].temp_data[0] = 1; } j = nextspritestat[j]; } @@ -1926,9 +1941,9 @@ DETONATE: if ((t[3] == 1 && s->xrepeat) || s->lotag == -99) { x = s->extra; - spawn(i,EXPLOSION2); - hitradius(i,seenineblastradius,x>>2, x-(x>>1),x-(x>>2), x); - spritesound(PIPEBOMB_EXPLODE,i); + A_Spawn(i,EXPLOSION2); + A_RadiusDamage(i,g_seenineBlastRadius,x>>2, x-(x>>1),x-(x>>2), x); + A_PlaySound(PIPEBOMB_EXPLODE,i); } if (s->xrepeat) @@ -1947,7 +1962,7 @@ DETONATE: s->hitag--; if (s->hitag <= 0) { - operatesectors(sect,i); + G_OperateSectors(sect,i); j = headspritesect[sect]; while (j >= 0) @@ -1961,16 +1976,16 @@ DETONATE: case 31: case 32: case 36: - hittype[j].temp_data[0] = 1; + ActorExtra[j].temp_data[0] = 1; break; case 3: - hittype[j].temp_data[4] = 1; + ActorExtra[j].temp_data[4] = 1; break; } } else if (sprite[j].statnum == 6) { - switch (dynamictostatic[sprite[j].picnum]) + switch (DynamicTileMap[sprite[j].picnum]) { case SEENINE__STATIC: case OOZFILTER__STATIC: @@ -1995,14 +2010,14 @@ DETONATE: switchpicnum = BOLT1; } - switch (dynamictostatic[switchpicnum]) + switch (DynamicTileMap[switchpicnum]) { case VIEWSCREEN__STATIC: case VIEWSCREEN2__STATIC: if (s->xrepeat == 0) KILLIT(i); - p = findplayer(s, &x); + p = A_FindPlayer(s, &x); if (x < 2048) { @@ -2025,10 +2040,10 @@ DETONATE: if (s->xvel == 0) s->xvel = 1; IFMOVING { - makeitfall(i); - if (TRAND&1) s->zvel -= 256; + A_Fall(i); + if (krand()&1) s->zvel -= 256; if (klabs(s->xvel) < 48) - s->xvel += (TRAND&3); + s->xvel += (krand()&3); } else KILLIT(i); break; @@ -2037,7 +2052,7 @@ DETONATE: // case SIDEBOLT1+1: // case SIDEBOLT1+2: // case SIDEBOLT1+3: - p = findplayer(s, &x); + p = A_FindPlayer(s, &x); if (x > 20480) goto BOLT; CLEAR_THE_BOLT2: @@ -2051,11 +2066,11 @@ CLEAR_THE_BOLT2: s->xrepeat=t[0]; s->yrepeat=t[1]; } - if ((TRAND&8) == 0) + if ((krand()&8) == 0) { t[0]=s->xrepeat; t[1]=s->yrepeat; - t[2] = global_random&4; + t[2] = g_globalRandom&4; s->xrepeat=s->yrepeat=0; goto CLEAR_THE_BOLT2; } @@ -2063,8 +2078,8 @@ CLEAR_THE_BOLT2: if (l&1) s->cstat ^= 2; - if ((TRAND&1) && sector[sect].floorpicnum == HURTRAIL) - spritesound(SHORT_CIRCUIT,i); + if ((krand()&1) && sector[sect].floorpicnum == HURTRAIL) + A_PlaySound(SHORT_CIRCUIT,i); if (s->picnum == SIDEBOLT1+4) s->picnum = SIDEBOLT1; @@ -2074,7 +2089,7 @@ CLEAR_THE_BOLT2: // case BOLT1+1: // case BOLT1+2: // case BOLT1+3: - p = findplayer(s, &x); + p = A_FindPlayer(s, &x); if (x > 20480) goto BOLT; if (t[3] == 0) @@ -2093,23 +2108,23 @@ CLEAR_THE_BOLT: s->xrepeat=t[0]; s->yrepeat=t[1]; } - else if ((TRAND&8) == 0) + else if ((krand()&8) == 0) { t[0]=s->xrepeat; t[1]=s->yrepeat; - t[2] = global_random&4; + t[2] = g_globalRandom&4; s->xrepeat=s->yrepeat=0; goto CLEAR_THE_BOLT; } s->picnum++; - l = global_random&7; + l = g_globalRandom&7; s->xrepeat=l+8; if (l&1) s->cstat ^= 2; - if (s->picnum == (BOLT1+1) && (TRAND&7) == 0 && sector[sect].floorpicnum == HURTRAIL) - spritesound(SHORT_CIRCUIT,i); + if (s->picnum == (BOLT1+1) && (krand()&7) == 0 && sector[sect].floorpicnum == HURTRAIL) + A_PlaySound(SHORT_CIRCUIT,i); if (s->picnum==BOLT1+4) s->picnum=BOLT1; @@ -2135,8 +2150,8 @@ CLEAR_THE_BOLT: } else { - makeitfall(i); - ssp(i,CLIPMASK0); + A_Fall(i); + A_SetSprite(i,CLIPMASK0); if (s->xvel > 0) s->xvel -= 2; if (s->zvel == 0) @@ -2144,7 +2159,7 @@ CLEAR_THE_BOLT: s->cstat |= 32768; if (s->pal != 2 && s->hitag == 0) - spritesound(SOMETHING_DRIPPING,i); + A_PlaySound(SOMETHING_DRIPPING,i); if (sprite[s->owner].picnum != WATERDRIP) { @@ -2152,8 +2167,8 @@ CLEAR_THE_BOLT: } else { - hittype[i].bposz = s->z = t[0]; - t[1] = 48+(TRAND&31); + ActorExtra[i].bposz = s->z = t[0]; + t[1] = 48+(krand()&31); } } } @@ -2183,7 +2198,7 @@ CLEAR_THE_BOLT: else { sector[sect].floorz += sector[sect].extra; - p = checkcursectnums(sect); + p = CheckPlayerInSector(sect); if (p >= 0) g_player[p].ps->posz += sector[sect].extra; } } @@ -2197,7 +2212,7 @@ CLEAR_THE_BOLT: else { sector[sect].floorz -= sector[sect].extra; - p = checkcursectnums(sect); + p = CheckPlayerInSector(sect); if (p >= 0) g_player[p].ps->posz -= sector[sect].extra; } @@ -2207,7 +2222,7 @@ CLEAR_THE_BOLT: if (t[5] == 1) goto BOLT; - p = checkcursectnums(sect); + p = CheckPlayerInSector(sect); if (p >= 0 && (g_player[p].ps->on_ground || s->ang == 512)) { if (t[0] == 0 && !check_activator_motion(s->lotag)) @@ -2215,8 +2230,8 @@ CLEAR_THE_BOLT: t[0] = 1; t[1] = 1; t[3] = !t[3]; - operatemasterswitches(s->lotag); - operateactivators(s->lotag,p); + G_OperateMasterSwitches(s->lotag); + G_OperateActivators(s->lotag,p); if (s->hitag > 0) { s->hitag--; @@ -2228,13 +2243,13 @@ CLEAR_THE_BOLT: if (t[1] == 1) { - j = headspritestat[6]; + j = headspritestat[STAT_STANDABLE]; while (j >= 0) { if (j != i && sprite[j].picnum == TOUCHPLATE && sprite[j].lotag == s->lotag) { - hittype[j].temp_data[1] = 1; - hittype[j].temp_data[3] = t[3]; + ActorExtra[j].temp_data[1] = 1; + ActorExtra[j].temp_data[3] = t[3]; } j = nextspritestat[j]; } @@ -2245,14 +2260,14 @@ CLEAR_THE_BOLT: case CANWITHSOMETHING2__STATIC: case CANWITHSOMETHING3__STATIC: case CANWITHSOMETHING4__STATIC: - makeitfall(i); + A_Fall(i); IFHIT { - spritesound(VENT_BUST,i); + A_PlaySound(VENT_BUST,i); for (j=0;j<10;j++) RANDOMSCRAP; - if (s->lotag) spawn(i,s->lotag); + if (s->lotag) A_Spawn(i,s->lotag); KILLIT(i); } @@ -2273,14 +2288,14 @@ CLEAR_THE_BOLT: case CEILINGSTEAM__STATIC: if (!actorscrptr[sprite[i].picnum]) goto BOLT; - p = findplayer(s, &x); - execute(i,p,x); + p = A_FindPlayer(s, &x); + A_Execute(i,p,x); goto BOLT; case WATERBUBBLEMAKER__STATIC: if (!actorscrptr[sprite[i].picnum]) goto BOLT; - p = findplayer(s, &x); - execute(i,p,x); + p = A_FindPlayer(s, &x); + A_Execute(i,p,x); goto BOLT; } @@ -2289,7 +2304,7 @@ BOLT: } } -static void bounce(int i) +static void A_DoProjectileBounce(int i) { int dax, day, daz = 4096; spritetype *s = &sprite[i]; @@ -2303,7 +2318,7 @@ static void bounce(int i) int daang = getangle(wall[l].x-wall[k].x,wall[l].y-wall[k].y); - if (s->z < (hittype[i].floorz+hittype[i].ceilingz)>>1) + if (s->z < (ActorExtra[i].floorz+ActorExtra[i].ceilingz)>>1) k = sector[hitsect].ceilingheinum; else k = sector[hitsect].floorheinum; @@ -2326,9 +2341,9 @@ static void bounce(int i) s->ang = getangle(xvect,yvect); } -static void moveweapons(void) +static void G_MoveWeapons(void) { - int i = headspritestat[4], j=0, k, f, nexti, p, q; + int i = headspritestat[STAT_PROJECTILE], j=0, k, f, nexti, p, q; int dax,day,daz, x, ll; unsigned int qq; spritetype *s; @@ -2340,41 +2355,41 @@ static void moveweapons(void) if (s->sectnum < 0) KILLIT(i); - hittype[i].bposx = s->x; - hittype[i].bposy = s->y; - hittype[i].bposz = s->z; + ActorExtra[i].bposx = s->x; + ActorExtra[i].bposy = s->y; + ActorExtra[i].bposz = s->z; // here - if (checkspriteflags(i,SPRITE_FLAG_PROJECTILE)) + if (A_CheckSpriteFlags(i,SPRITE_PROJECTILE)) { /* Custom projectiles. This is a big hack. */ - if (hittype[i].projectile.pal >= 0) - s->pal=hittype[i].projectile.pal; + if (ActorExtra[i].projectile.pal >= 0) + s->pal=ActorExtra[i].projectile.pal; - if (hittype[i].projectile.workslike & PROJECTILE_FLAG_KNEE) + if (ActorExtra[i].projectile.workslike & PROJECTILE_KNEE) KILLIT(i); - if (hittype[i].projectile.workslike & PROJECTILE_FLAG_RPG) + if (ActorExtra[i].projectile.workslike & PROJECTILE_RPG) { - // if (hittype[i].projectile.workslike & COOLEXPLOSION1) + // if (ActorExtra[i].projectile.workslike & COOLEXPLOSION1) // if( g_sounds[WIERDSHOT_FLY].num == 0 ) - // spritesound(WIERDSHOT_FLY,i); + // A_PlaySound(WIERDSHOT_FLY,i); p = -1; - if (hittype[i].projectile.workslike & PROJECTILE_FLAG_COOLEXPLOSION1) + if (ActorExtra[i].projectile.workslike & PROJECTILE_COOLEXPLOSION1) { s->shade++; if (s->shade >= 40) KILLIT(i); } - if (hittype[i].projectile.drop) - s->zvel -= hittype[i].projectile.drop; + if (ActorExtra[i].projectile.drop) + s->zvel -= ActorExtra[i].projectile.drop; - if (hittype[i].projectile.workslike & PROJECTILE_FLAG_SPIT) + if (ActorExtra[i].projectile.workslike & PROJECTILE_SPIT) if (s->zvel < 6144) - s->zvel += gc-112; + s->zvel += SpriteGravity-112; k = s->xvel; ll = s->zvel; @@ -2389,114 +2404,114 @@ static void moveweapons(void) day = s->y; daz = s->z; - getglobalz(i); + A_GetZLimits(i); qq = CLIPMASK1; - if (hittype[i].projectile.trail >= 0) + if (ActorExtra[i].projectile.trail >= 0) { - for (f=0;f<=hittype[i].projectile.tnum;f++) + for (f=0;f<=ActorExtra[i].projectile.tnum;f++) { - j = spawn(i,hittype[i].projectile.trail); - if (hittype[i].projectile.toffset != 0) - sprite[j].z += (hittype[i].projectile.toffset<<8); - if (hittype[i].projectile.txrepeat >= 0) - sprite[j].xrepeat=hittype[i].projectile.txrepeat; - if (hittype[i].projectile.tyrepeat >= 0) - sprite[j].yrepeat=hittype[i].projectile.tyrepeat; + j = A_Spawn(i,ActorExtra[i].projectile.trail); + if (ActorExtra[i].projectile.toffset != 0) + sprite[j].z += (ActorExtra[i].projectile.toffset<<8); + if (ActorExtra[i].projectile.txrepeat >= 0) + sprite[j].xrepeat=ActorExtra[i].projectile.txrepeat; + if (ActorExtra[i].projectile.tyrepeat >= 0) + sprite[j].yrepeat=ActorExtra[i].projectile.tyrepeat; } } - for (f=1;f<=hittype[i].projectile.velmult;f++) + for (f=1;f<=ActorExtra[i].projectile.velmult;f++) { dax = s->x; day = s->y; daz = s->z; - j = movesprite(i, - (k*(sintable[(s->ang+512)&2047]))>>14, - (k*(sintable[s->ang&2047]))>>14,ll,qq); + j = A_MoveSprite(i, + (k*(sintable[(s->ang+512)&2047]))>>14, + (k*(sintable[s->ang&2047]))>>14,ll,qq); if (j) break; } - if (!(hittype[i].projectile.workslike & PROJECTILE_FLAG_BOUNCESOFFWALLS) && + if (!(ActorExtra[i].projectile.workslike & PROJECTILE_BOUNCESOFFWALLS) && s->yvel >= 0 && sprite[s->yvel].sectnum < MAXSECTORS) if (FindDistance2D(s->x-sprite[s->yvel].x,s->y-sprite[s->yvel].y) < 256) j = 49152|s->yvel; - hittype[i].movflag = j; + ActorExtra[i].movflag = j; if (s->sectnum < 0) { KILLIT(i); } - if (hittype[i].projectile.workslike & PROJECTILE_FLAG_TIMED && hittype[i].projectile.range > 0) + if (ActorExtra[i].projectile.workslike & PROJECTILE_TIMED && ActorExtra[i].projectile.range > 0) { - if (!(hittype[i].temp_data[8])) - hittype[i].temp_data[8] = 1; + if (!(ActorExtra[i].temp_data[8])) + ActorExtra[i].temp_data[8] = 1; else - hittype[i].temp_data[8]++; + ActorExtra[i].temp_data[8]++; - if (hittype[i].temp_data[8] > hittype[i].projectile.range) + if (ActorExtra[i].temp_data[8] > ActorExtra[i].projectile.range) { - if (hittype[i].projectile.workslike & PROJECTILE_FLAG_EXPLODEONTIMER) + if (ActorExtra[i].projectile.workslike & PROJECTILE_EXPLODEONTIMER) { - if (hittype[i].projectile.spawns >= 0) + if (ActorExtra[i].projectile.spawns >= 0) { - k = spawn(i,hittype[i].projectile.spawns); + k = A_Spawn(i,ActorExtra[i].projectile.spawns); sprite[k].x = dax; sprite[k].y = day; sprite[k].z = daz; - if (hittype[i].projectile.sxrepeat > 4) - sprite[k].xrepeat=hittype[i].projectile.sxrepeat; - if (hittype[i].projectile.syrepeat > 4) - sprite[k].yrepeat=hittype[i].projectile.syrepeat; + if (ActorExtra[i].projectile.sxrepeat > 4) + sprite[k].xrepeat=ActorExtra[i].projectile.sxrepeat; + if (ActorExtra[i].projectile.syrepeat > 4) + sprite[k].yrepeat=ActorExtra[i].projectile.syrepeat; } - if (hittype[i].projectile.isound >= 0) - spritesound(hittype[i].projectile.isound,i); + if (ActorExtra[i].projectile.isound >= 0) + A_PlaySound(ActorExtra[i].projectile.isound,i); - s->extra=hittype[i].projectile.extra; + s->extra=ActorExtra[i].projectile.extra; - if (hittype[i].projectile.extra_rand > 0) - s->extra += (TRAND&hittype[i].projectile.extra_rand); + if (ActorExtra[i].projectile.extra_rand > 0) + s->extra += (krand()&ActorExtra[i].projectile.extra_rand); x = s->extra; - hitradius(i,hittype[i].projectile.hitradius, x>>2,x>>1,x-(x>>2),x); + A_RadiusDamage(i,ActorExtra[i].projectile.hitradius, x>>2,x>>1,x-(x>>2),x); } KILLIT(i); } } - if (hittype[i].projectile.workslike & PROJECTILE_FLAG_BOUNCESOFFWALLS) + if (ActorExtra[i].projectile.workslike & PROJECTILE_BOUNCESOFFWALLS) { /* if(s->yvel < 1 || s->extra < 2 || (s->xvel|s->zvel) == 0) Did this cause the bug with prematurely exploding projectiles? */ if (s->yvel < 1) { - if (hittype[i].projectile.spawns >= 0) + if (ActorExtra[i].projectile.spawns >= 0) { - k = spawn(i,hittype[i].projectile.spawns); + k = A_Spawn(i,ActorExtra[i].projectile.spawns); sprite[k].x = dax; sprite[k].y = day; sprite[k].z = daz; - if (hittype[i].projectile.sxrepeat > 4) - sprite[k].xrepeat=hittype[i].projectile.sxrepeat; - if (hittype[i].projectile.syrepeat > 4) - sprite[k].yrepeat=hittype[i].projectile.syrepeat; + if (ActorExtra[i].projectile.sxrepeat > 4) + sprite[k].xrepeat=ActorExtra[i].projectile.sxrepeat; + if (ActorExtra[i].projectile.syrepeat > 4) + sprite[k].yrepeat=ActorExtra[i].projectile.syrepeat; } - if (hittype[i].projectile.isound >= 0) - spritesound(hittype[i].projectile.isound,i); + if (ActorExtra[i].projectile.isound >= 0) + A_PlaySound(ActorExtra[i].projectile.isound,i); - s->extra=hittype[i].projectile.extra; + s->extra=ActorExtra[i].projectile.extra; - if (hittype[i].projectile.extra_rand > 0) - s->extra += (TRAND&hittype[i].projectile.extra_rand); + if (ActorExtra[i].projectile.extra_rand > 0) + s->extra += (krand()&ActorExtra[i].projectile.extra_rand); x = s->extra; - hitradius(i,hittype[i].projectile.hitradius, x>>2,x>>1,x-(x>>2),x); + A_RadiusDamage(i,ActorExtra[i].projectile.hitradius, x>>2,x>>1,x-(x>>2),x); KILLIT(i); } @@ -2504,16 +2519,16 @@ static void moveweapons(void) } if ((j&49152) != 49152) - if (!(hittype[i].projectile.workslike & PROJECTILE_FLAG_BOUNCESOFFWALLS)) + if (!(ActorExtra[i].projectile.workslike & PROJECTILE_BOUNCESOFFWALLS)) { - if (s->z < hittype[i].ceilingz) + if (s->z < ActorExtra[i].ceilingz) { j = 16384|(s->sectnum); s->zvel = -1; } else - if ((s->z > hittype[i].floorz && sector[s->sectnum].lotag != 1) || - (s->z > hittype[i].floorz+(16<<8) && sector[s->sectnum].lotag == 1)) + if ((s->z > ActorExtra[i].floorz && sector[s->sectnum].lotag != 1) || + (s->z > ActorExtra[i].floorz+(16<<8) && sector[s->sectnum].lotag == 1)) { j = 16384|(s->sectnum); if (sector[s->sectnum].lotag != 1) @@ -2521,13 +2536,13 @@ static void moveweapons(void) } } - if (hittype[i].projectile.workslike & PROJECTILE_FLAG_WATERBUBBLES && + if (ActorExtra[i].projectile.workslike & PROJECTILE_WATERBUBBLES && sector[s->sectnum].lotag == 2 && rnd(140)) - spawn(i,WATERBUBBLE); + A_Spawn(i,WATERBUBBLE); if (j != 0) { - if (hittype[i].projectile.workslike & PROJECTILE_FLAG_COOLEXPLOSION1) + if (ActorExtra[i].projectile.workslike & PROJECTILE_COOLEXPLOSION1) { s->xvel = 0; s->zvel = 0; @@ -2537,87 +2552,87 @@ static void moveweapons(void) { j &= (MAXSPRITES-1); - if (hittype[i].projectile.workslike & PROJECTILE_FLAG_BOUNCESOFFSPRITES) + if (ActorExtra[i].projectile.workslike & PROJECTILE_BOUNCESOFFSPRITES) { s->yvel--; k = getangle(sprite[j].x-s->x,sprite[j].y-s->y)+(sprite[j].cstat&16?0:512); s->ang = ((k<<1) - s->ang)&2047; - if (hittype[i].projectile.bsound >= 0) - spritesound(hittype[i].projectile.bsound,i); + if (ActorExtra[i].projectile.bsound >= 0) + A_PlaySound(ActorExtra[i].projectile.bsound,i); - if (hittype[i].projectile.workslike & PROJECTILE_FLAG_LOSESVELOCITY) + if (ActorExtra[i].projectile.workslike & PROJECTILE_LOSESVELOCITY) { s->xvel=s->xvel>>1; s->zvel=s->zvel>>1; } - if (!(hittype[i].projectile.workslike & PROJECTILE_FLAG_FORCEIMPACT))goto BOLT; + if (!(ActorExtra[i].projectile.workslike & PROJECTILE_FORCEIMPACT))goto BOLT; } - checkhitsprite(j,i); + A_DamageObject(j,i); if (sprite[j].picnum == APLAYER) { p = sprite[j].yvel; - spritesound(PISTOL_BODYHIT,j); + A_PlaySound(PISTOL_BODYHIT,j); - if (hittype[i].projectile.workslike & PROJECTILE_FLAG_SPIT) + if (ActorExtra[i].projectile.workslike & PROJECTILE_SPIT) { g_player[p].ps->horiz += 32; g_player[p].ps->return_to_center = 8; if (g_player[p].ps->loogcnt == 0) { - if (!isspritemakingsound(g_player[p].ps->i, DUKE_LONGTERM_PAIN)) - spritesound(DUKE_LONGTERM_PAIN,g_player[p].ps->i); + if (!A_CheckSoundPlaying(g_player[p].ps->i, DUKE_LONGTERM_PAIN)) + A_PlaySound(DUKE_LONGTERM_PAIN,g_player[p].ps->i); - j = 3+(TRAND&3); + j = 3+(krand()&3); g_player[p].ps->numloogs = j; g_player[p].ps->loogcnt = 24*4; for (x=0;x < j;x++) { - g_player[p].ps->loogiex[x] = TRAND%xdim; - g_player[p].ps->loogiey[x] = TRAND%ydim; + g_player[p].ps->loogiex[x] = krand()%xdim; + g_player[p].ps->loogiey[x] = krand()%ydim; } } } } - if (hittype[i].projectile.workslike & PROJECTILE_FLAG_RPG_IMPACT) + if (ActorExtra[i].projectile.workslike & PROJECTILE_RPG_IMPACT) { - hittype[j].owner = s->owner; - hittype[j].picnum = s->picnum; - hittype[j].extra += hittype[i].projectile.extra; + ActorExtra[j].owner = s->owner; + ActorExtra[j].picnum = s->picnum; + ActorExtra[j].extra += ActorExtra[i].projectile.extra; - if (hittype[i].projectile.spawns >= 0) + if (ActorExtra[i].projectile.spawns >= 0) { - k = spawn(i,hittype[i].projectile.spawns); + k = A_Spawn(i,ActorExtra[i].projectile.spawns); sprite[k].x = dax; sprite[k].y = day; sprite[k].z = daz; - if (hittype[i].projectile.sxrepeat > 4) - sprite[k].xrepeat=hittype[i].projectile.sxrepeat; - if (hittype[i].projectile.syrepeat > 4) - sprite[k].yrepeat=hittype[i].projectile.syrepeat; + if (ActorExtra[i].projectile.sxrepeat > 4) + sprite[k].xrepeat=ActorExtra[i].projectile.sxrepeat; + if (ActorExtra[i].projectile.syrepeat > 4) + sprite[k].yrepeat=ActorExtra[i].projectile.syrepeat; } - if (hittype[i].projectile.isound >= 0) - spritesound(hittype[i].projectile.isound,i); + if (ActorExtra[i].projectile.isound >= 0) + A_PlaySound(ActorExtra[i].projectile.isound,i); - if (!(hittype[i].projectile.workslike & PROJECTILE_FLAG_FORCEIMPACT))KILLIT(i); + if (!(ActorExtra[i].projectile.workslike & PROJECTILE_FORCEIMPACT))KILLIT(i); } - if (hittype[i].projectile.workslike & PROJECTILE_FLAG_FORCEIMPACT)goto BOLT; + if (ActorExtra[i].projectile.workslike & PROJECTILE_FORCEIMPACT)goto BOLT; } else if ((j&49152) == 32768) { j &= (MAXWALLS-1); - if (hittype[i].projectile.workslike & PROJECTILE_FLAG_BOUNCESOFFMIRRORS && + if (ActorExtra[i].projectile.workslike & PROJECTILE_BOUNCESOFFMIRRORS && (wall[j].overpicnum == MIRROR || wall[j].picnum == MIRROR)) { k = getangle( @@ -2625,15 +2640,15 @@ static void moveweapons(void) wall[wall[j].point2].y-wall[j].y); s->ang = ((k<<1) - s->ang)&2047; s->owner = i; - spawn(i,TRANSPORTERSTAR); + A_Spawn(i,TRANSPORTERSTAR); goto BOLT; } else { setsprite(i,dax,day,daz); - checkhitwall(i,j,s->x,s->y,s->z,s->picnum); + A_DamageWall(i,j,s->x,s->y,s->z,s->picnum); - if (hittype[i].projectile.workslike & PROJECTILE_FLAG_BOUNCESOFFWALLS) + if (ActorExtra[i].projectile.workslike & PROJECTILE_BOUNCESOFFWALLS) { if (wall[j].overpicnum != MIRROR && wall[j].picnum != MIRROR) s->yvel--; @@ -2643,10 +2658,10 @@ static void moveweapons(void) wall[wall[j].point2].y-wall[j].y); s->ang = ((k<<1) - s->ang)&2047; - if (hittype[i].projectile.bsound >= 0) - spritesound(hittype[i].projectile.bsound,i); + if (ActorExtra[i].projectile.bsound >= 0) + A_PlaySound(ActorExtra[i].projectile.bsound,i); - if (hittype[i].projectile.workslike & PROJECTILE_FLAG_LOSESVELOCITY) + if (ActorExtra[i].projectile.workslike & PROJECTILE_LOSESVELOCITY) { s->xvel=s->xvel>>1; s->zvel=s->zvel>>1; @@ -2664,20 +2679,20 @@ static void moveweapons(void) if (sector[s->sectnum].ceilingstat&1 && sector[s->sectnum].ceilingpal == 0) KILLIT(i); - checkhitceiling(s->sectnum); + Sect_DamageCeiling(s->sectnum); } - if (hittype[i].projectile.workslike & PROJECTILE_FLAG_BOUNCESOFFWALLS) + if (ActorExtra[i].projectile.workslike & PROJECTILE_BOUNCESOFFWALLS) { - bounce(i); - ssp(i,qq); + A_DoProjectileBounce(i); + A_SetSprite(i,qq); s->yvel--; - if (hittype[i].projectile.bsound >= 0) - spritesound(hittype[i].projectile.bsound,i); + if (ActorExtra[i].projectile.bsound >= 0) + A_PlaySound(ActorExtra[i].projectile.bsound,i); - if (hittype[i].projectile.workslike & PROJECTILE_FLAG_LOSESVELOCITY) + if (ActorExtra[i].projectile.workslike & PROJECTILE_LOSESVELOCITY) { s->xvel=s->xvel>>1; s->zvel=s->zvel>>1; @@ -2687,40 +2702,40 @@ static void moveweapons(void) } } - if (hittype[i].projectile.workslike & PROJECTILE_FLAG_RPG && hittype[i].projectile.spawns > 0) + if (ActorExtra[i].projectile.workslike & PROJECTILE_RPG && ActorExtra[i].projectile.spawns > 0) { - k = spawn(i,hittype[i].projectile.spawns); + k = A_Spawn(i,ActorExtra[i].projectile.spawns); sprite[k].x = dax; sprite[k].y = day; sprite[k].z = daz; - if (hittype[i].projectile.sxrepeat > 4) - sprite[k].xrepeat=hittype[i].projectile.sxrepeat; - if (hittype[i].projectile.syrepeat > 4) - sprite[k].yrepeat=hittype[i].projectile.syrepeat; + if (ActorExtra[i].projectile.sxrepeat > 4) + sprite[k].xrepeat=ActorExtra[i].projectile.sxrepeat; + if (ActorExtra[i].projectile.syrepeat > 4) + sprite[k].yrepeat=ActorExtra[i].projectile.syrepeat; } - if (hittype[i].projectile.workslike & PROJECTILE_FLAG_HITSCAN) + if (ActorExtra[i].projectile.workslike & PROJECTILE_HITSCAN) { if (!actorscrptr[sprite[i].picnum]) goto BOLT; - p = findplayer(s,&x); - execute(i,p,x); + p = A_FindPlayer(s,&x); + A_Execute(i,p,x); goto BOLT; } - if (hittype[i].projectile.workslike & PROJECTILE_FLAG_RPG) + if (ActorExtra[i].projectile.workslike & PROJECTILE_RPG) { - if (hittype[i].projectile.isound >= 0) - spritesound(hittype[i].projectile.isound,i); + if (ActorExtra[i].projectile.isound >= 0) + A_PlaySound(ActorExtra[i].projectile.isound,i); - s->extra=hittype[i].projectile.extra; - if (hittype[i].projectile.extra_rand > 0) - s->extra += (TRAND&hittype[i].projectile.extra_rand); + s->extra=ActorExtra[i].projectile.extra; + if (ActorExtra[i].projectile.extra_rand > 0) + s->extra += (krand()&ActorExtra[i].projectile.extra_rand); - hitradius(i,hittype[i].projectile.hitradius, - s->extra>>2,s->extra>>1,s->extra-(s->extra>>2),s->extra); + A_RadiusDamage(i,ActorExtra[i].projectile.hitradius, + s->extra>>2,s->extra>>1,s->extra-(s->extra>>2),s->extra); KILLIT(i); } } @@ -2731,7 +2746,7 @@ static void moveweapons(void) { // here - switch (dynamictostatic[s->picnum]) + switch (DynamicTileMap[s->picnum]) { case RADIUSEXPLOSION__STATIC: case KNEE__STATIC: @@ -2742,7 +2757,7 @@ static void moveweapons(void) if (T2 > 2047) KILLIT(i); if (sprite[s->owner].statnum == MAXSTATUS) - if (badguy(&sprite[s->owner]) == 0) + if (A_CheckEnemySprite(&sprite[s->owner]) == 0) KILLIT(i); s->ang = sprite[s->owner].ang; @@ -2752,19 +2767,19 @@ static void moveweapons(void) s->z = sprite[s->owner].z-(34<<8); for (k=0;ksectnum, - s->x+((k*sintable[(s->ang+512)&2047])>>9), - s->y+((k*sintable[s->ang&2047])>>9), - s->z+((k*ksgn(s->zvel))*klabs(s->zvel/12)),TONGUE,-40+(k<<1), - 8,8,0,0,0,i,5); + q = A_InsertSprite(s->sectnum, + s->x+((k*sintable[(s->ang+512)&2047])>>9), + s->y+((k*sintable[s->ang&2047])>>9), + s->z+((k*ksgn(s->zvel))*klabs(s->zvel/12)),TONGUE,-40+(k<<1), + 8,8,0,0,0,i,5); sprite[q].cstat = 128; sprite[q].pal = 8; } - q = EGS(s->sectnum, - s->x+((k*sintable[(s->ang+512)&2047])>>9), - s->y+((k*sintable[s->ang&2047])>>9), - s->z+((k*ksgn(s->zvel))*klabs(s->zvel/12)),INNERJAW,-40, - 32,32,0,0,0,i,5); + q = A_InsertSprite(s->sectnum, + s->x+((k*sintable[(s->ang+512)&2047])>>9), + s->y+((k*sintable[s->ang&2047])>>9), + s->z+((k*ksgn(s->zvel))*klabs(s->zvel/12)),INNERJAW,-40, + 32,32,0,0,0,i,5); sprite[q].cstat = 128; if (T2 > 512 && T2 < (1024)) sprite[q].picnum = INNERJAW+1; @@ -2774,7 +2789,7 @@ static void moveweapons(void) case FREEZEBLAST__STATIC: if (s->yvel < 1 || s->extra < 2 || (s->xvel|s->zvel) == 0) { - j = spawn(i,TRANSPORTERSTAR); + j = A_Spawn(i,TRANSPORTERSTAR); sprite[j].pal = 1; sprite[j].xrepeat = 32; sprite[j].yrepeat = 32; @@ -2787,8 +2802,8 @@ static void moveweapons(void) case COOLEXPLOSION1__STATIC: if (s->picnum == COOLEXPLOSION1) - if (!issoundplaying(i,WIERDSHOT_FLY)) - spritesound(WIERDSHOT_FLY,i); + if (!S_CheckSoundPlaying(i,WIERDSHOT_FLY)) + A_PlaySound(WIERDSHOT_FLY,i); p = -1; @@ -2805,27 +2820,27 @@ static void moveweapons(void) day = s->y; daz = s->z; - getglobalz(i); + A_GetZLimits(i); qq = CLIPMASK1; - switch (dynamictostatic[s->picnum]) + switch (DynamicTileMap[s->picnum]) { case RPG__STATIC: - if (hittype[i].picnum != BOSS2 && s->xrepeat >= 10 && sector[s->sectnum].lotag != 2) + if (ActorExtra[i].picnum != BOSS2 && s->xrepeat >= 10 && sector[s->sectnum].lotag != 2) { - j = spawn(i,SMALLSMOKE); + j = A_Spawn(i,SMALLSMOKE); sprite[j].z += (1<<8); } break; } - j = movesprite(i,(k*(sintable[(s->ang+512)&2047]))>>14,(k*(sintable[s->ang&2047]))>>14,ll,qq); + j = A_MoveSprite(i,(k*(sintable[(s->ang+512)&2047]))>>14,(k*(sintable[s->ang&2047]))>>14,ll,qq); if (s->picnum == RPG && s->yvel >= 0 && sprite[s->yvel].sectnum < MAXSECTORS) if (FindDistance2D(s->x-sprite[s->yvel].x,s->y-sprite[s->yvel].y) < 256) j = 49152|s->yvel; - hittype[i].movflag = j; + ActorExtra[i].movflag = j; if (s->sectnum < 0) KILLIT(i); @@ -2833,14 +2848,14 @@ static void moveweapons(void) if ((j&49152) != 49152) if (s->picnum != FREEZEBLAST) { - if (s->z < hittype[i].ceilingz) + if (s->z < ActorExtra[i].ceilingz) { j = 16384|(s->sectnum); s->zvel = -1; } else - if ((s->z > hittype[i].floorz && sector[s->sectnum].lotag != 1) || - (s->z > hittype[i].floorz+(16<<8) && sector[s->sectnum].lotag == 1)) + if ((s->z > ActorExtra[i].floorz && sector[s->sectnum].lotag != 1) || + (s->z > ActorExtra[i].floorz+(16<<8) && sector[s->sectnum].lotag == 1)) { j = 16384|(s->sectnum); if (sector[s->sectnum].lotag != 1) @@ -2852,18 +2867,18 @@ static void moveweapons(void) { for (k=-3;k<2;k++) { - x = EGS(s->sectnum, - s->x+((k*sintable[(s->ang+512)&2047])>>9), - s->y+((k*sintable[s->ang&2047])>>9), - s->z+((k*ksgn(s->zvel))*klabs(s->zvel/24)),FIRELASER,-40+(k<<2), - s->xrepeat,s->yrepeat,0,0,0,s->owner,5); + x = A_InsertSprite(s->sectnum, + s->x+((k*sintable[(s->ang+512)&2047])>>9), + s->y+((k*sintable[s->ang&2047])>>9), + s->z+((k*ksgn(s->zvel))*klabs(s->zvel/24)),FIRELASER,-40+(k<<2), + s->xrepeat,s->yrepeat,0,0,0,s->owner,5); sprite[x].cstat = 128; sprite[x].pal = s->pal; } } else if (s->picnum == SPIT) if (s->zvel < 6144) - s->zvel += gc-112; + s->zvel += SpriteGravity-112; if (j != 0) { @@ -2880,9 +2895,9 @@ static void moveweapons(void) j &= (MAXSPRITES-1); if (s->picnum == FREEZEBLAST && sprite[j].pal == 1) - if (badguy(&sprite[j]) || sprite[j].picnum == APLAYER) + if (A_CheckEnemySprite(&sprite[j]) || sprite[j].picnum == APLAYER) { - j = spawn(i,TRANSPORTERSTAR); + j = A_Spawn(i,TRANSPORTERSTAR); sprite[j].pal = 1; sprite[j].xrepeat = 32; sprite[j].yrepeat = 32; @@ -2890,12 +2905,12 @@ static void moveweapons(void) KILLIT(i); } - checkhitsprite(j,i); + A_DamageObject(j,i); if (sprite[j].picnum == APLAYER) { p = sprite[j].yvel; - spritesound(PISTOL_BODYHIT,j); + A_PlaySound(PISTOL_BODYHIT,j); if (s->picnum == SPIT) { @@ -2904,16 +2919,16 @@ static void moveweapons(void) if (g_player[p].ps->loogcnt == 0) { - if (!isspritemakingsound(g_player[p].ps->i, DUKE_LONGTERM_PAIN)) - spritesound(DUKE_LONGTERM_PAIN,g_player[p].ps->i); + if (!A_CheckSoundPlaying(g_player[p].ps->i, DUKE_LONGTERM_PAIN)) + A_PlaySound(DUKE_LONGTERM_PAIN,g_player[p].ps->i); - j = 3+(TRAND&3); + j = 3+(krand()&3); g_player[p].ps->numloogs = j; g_player[p].ps->loogcnt = 24*4; for (x=0;x < j;x++) { - g_player[p].ps->loogiex[x] = TRAND%xdim; - g_player[p].ps->loogiey[x] = TRAND%ydim; + g_player[p].ps->loogiex[x] = krand()%xdim; + g_player[p].ps->loogiey[x] = krand()%ydim; } } } @@ -2930,13 +2945,13 @@ static void moveweapons(void) wall[wall[j].point2].y-wall[j].y); s->ang = ((k<<1) - s->ang)&2047; s->owner = i; - spawn(i,TRANSPORTERSTAR); + A_Spawn(i,TRANSPORTERSTAR); goto BOLT; } else { setsprite(i,dax,day,daz); - checkhitwall(i,j,s->x,s->y,s->z,s->picnum); + A_DamageWall(i,j,s->x,s->y,s->z,s->picnum); if (s->picnum == FREEZEBLAST) { @@ -2964,13 +2979,13 @@ static void moveweapons(void) if (sector[s->sectnum].ceilingpal == 0) KILLIT(i); - checkhitceiling(s->sectnum); + Sect_DamageCeiling(s->sectnum); } if (s->picnum == FREEZEBLAST) { - bounce(i); - ssp(i,qq); + A_DoProjectileBounce(i); + A_SetSprite(i,qq); s->extra >>= 1; if (s->xrepeat > 8) s->xrepeat -= 2; @@ -2985,7 +3000,7 @@ static void moveweapons(void) { if (s->picnum == RPG) { - k = spawn(i,EXPLOSION2); + k = A_Spawn(i,EXPLOSION2); sprite[k].x = dax; sprite[k].y = day; sprite[k].z = daz; @@ -2998,7 +3013,7 @@ static void moveweapons(void) else if ((j&49152) == 16384) { if (s->zvel > 0) - spawn(i,EXPLOSION2BOT); + A_Spawn(i,EXPLOSION2BOT); else { sprite[k].cstat |= 8; @@ -3006,28 +3021,28 @@ static void moveweapons(void) } } - spritesound(RPG_EXPLODE,i); + A_PlaySound(RPG_EXPLODE,i); if (s->xrepeat >= 10) { x = s->extra; - hitradius(i,rpgblastradius, x>>2,x>>1,x-(x>>2),x); + A_RadiusDamage(i,g_rpgBlastRadius, x>>2,x>>1,x-(x>>2),x); } else { - x = s->extra+(global_random&3); - hitradius(i,(rpgblastradius>>1),x>>2,x>>1,x-(x>>2),x); + x = s->extra+(g_globalRandom&3); + A_RadiusDamage(i,(g_rpgBlastRadius>>1),x>>2,x>>1,x-(x>>2),x); } } else if (s->picnum == SHRINKSPARK) { - spawn(i,SHRINKEREXPLOSION); - spritesound(SHRINKER_HIT,i); - hitradius(i,shrinkerblastradius,0,0,0,0); + A_Spawn(i,SHRINKEREXPLOSION); + A_PlaySound(SHRINKER_HIT,i); + A_RadiusDamage(i,g_shrinkerBlastRadius,0,0,0,0); } else if (s->picnum != COOLEXPLOSION1 && s->picnum != FREEZEBLAST && s->picnum != FIRELASER) { - k = spawn(i,EXPLOSION2); + k = A_Spawn(i,EXPLOSION2); sprite[k].xrepeat = sprite[k].yrepeat = s->xrepeat>>1; if ((j&49152) == 16384) { @@ -3048,15 +3063,15 @@ static void moveweapons(void) if (s->shade >= 40) KILLIT(i); } else if (s->picnum == RPG && sector[s->sectnum].lotag == 2 && s->xrepeat >= 10 && rnd(140)) - spawn(i,WATERBUBBLE); + A_Spawn(i,WATERBUBBLE); goto BOLT; case SHOTSPARK1__STATIC: if (!actorscrptr[sprite[i].picnum]) goto BOLT; - p = findplayer(s,&x); - execute(i,p,x); + p = A_FindPlayer(s,&x); + A_Execute(i,p,x); goto BOLT; } } @@ -3065,10 +3080,10 @@ BOLT: } } -static void movetransports(void) +static void G_MoveTransports(void) { int warpspriteto; - int i = headspritestat[9], j, k, l, p, sect, sectlotag, nexti, nextj; + int i = headspritestat[STAT_TRANSPORT], j, k, l, p, sect, sectlotag, nexti, nextj; int ll,onfloorz,q; while (i >= 0) @@ -3109,23 +3124,23 @@ static void movetransports(void) { if (sprite[i].pal == 0) { - spawn(i,TRANSPORTERBEAM); - spritesound(TELEPORTER,i); + A_Spawn(i,TRANSPORTERBEAM); + A_PlaySound(TELEPORTER,i); } - for (k=connecthead;k>=0;k=connectpoint2[k]) - if (g_player[k].ps->cursectnum == sprite[OW].sectnum) - { - g_player[k].ps->frag_ps = p; - sprite[g_player[k].ps->i].extra = 0; - } + TRAVERSE_CONNECT(k) + if (g_player[k].ps->cursectnum == sprite[OW].sectnum) + { + g_player[k].ps->frag_ps = p; + sprite[g_player[k].ps->i].extra = 0; + } g_player[p].ps->ang = sprite[OW].ang; if (sprite[OW].owner != OW) { T1 = 13; - hittype[OW].temp_data[0] = 13; + ActorExtra[OW].temp_data[0] = 13; g_player[p].ps->transporter_hold = 13; } @@ -3138,8 +3153,8 @@ static void movetransports(void) if (sprite[i].pal == 0) { - k = spawn(OW,TRANSPORTERBEAM); - spritesound(TELEPORTER,k); + k = A_Spawn(OW,TRANSPORTERBEAM); + A_PlaySound(TELEPORTER,k); } break; @@ -3148,20 +3163,20 @@ static void movetransports(void) else if (!(sectlotag == 1 && g_player[p].ps->on_ground == 1)) break; if (onfloorz == 0 && klabs(SZ-g_player[p].ps->posz) < 6144) - if ((g_player[p].ps->jetpack_on == 0) || (g_player[p].ps->jetpack_on && (g_player[p].sync->bits&1)) || - (g_player[p].ps->jetpack_on && (g_player[p].sync->bits&2))) + if ((g_player[p].ps->jetpack_on == 0) || (g_player[p].ps->jetpack_on && TEST_SYNC_KEY(g_player[p].sync->bits, SK_JUMP)) || + (g_player[p].ps->jetpack_on && TEST_SYNC_KEY(g_player[p].sync->bits, SK_CROUCH))) { g_player[p].ps->oposx = g_player[p].ps->posx += sprite[OW].x-SX; g_player[p].ps->oposy = g_player[p].ps->posy += sprite[OW].y-SY; - if (g_player[p].ps->jetpack_on && ((g_player[p].sync->bits&1) || g_player[p].ps->jetpack_on < 11)) + if (g_player[p].ps->jetpack_on && (TEST_SYNC_KEY(g_player[p].sync->bits, SK_JUMP) || g_player[p].ps->jetpack_on < 11)) g_player[p].ps->posz = sprite[OW].z-6144; else g_player[p].ps->posz = sprite[OW].z+6144; g_player[p].ps->oposz = g_player[p].ps->posz; - hittype[g_player[p].ps->i].bposx = g_player[p].ps->posx; - hittype[g_player[p].ps->i].bposy = g_player[p].ps->posy; - hittype[g_player[p].ps->i].bposz = g_player[p].ps->posz; + ActorExtra[g_player[p].ps->i].bposx = g_player[p].ps->posx; + ActorExtra[g_player[p].ps->i].bposy = g_player[p].ps->posy; + ActorExtra[g_player[p].ps->i].bposz = g_player[p].ps->posz; changespritesect(j,sprite[OW].sectnum); g_player[p].ps->cursectnum = sprite[OW].sectnum; @@ -3171,22 +3186,24 @@ static void movetransports(void) k = 0; - if (onfloorz && sectlotag == 1 && g_player[p].ps->on_ground && g_player[p].ps->posz > (sector[sect].floorz-1080) && ((g_player[p].sync->bits&2) || g_player[p].ps->poszv > 2048)) + if (onfloorz && sectlotag == 1 && g_player[p].ps->on_ground && + g_player[p].ps->posz > (sector[sect].floorz-1080) && + (TEST_SYNC_KEY(g_player[p].sync->bits, SK_CROUCH) || g_player[p].ps->poszv > 2048)) // if( onfloorz && sectlotag == 1 && g_player[p].ps->posz > (sector[sect].floorz-(6<<8)) ) { k = 1; if (screenpeek == p) { FX_StopAllSounds(); - clearsoundlocks(); + S_ClearSoundLocks(); } if (sprite[g_player[p].ps->i].extra > 0) - spritesound(DUKE_UNDERWATER,j); + A_PlaySound(DUKE_UNDERWATER,j); g_player[p].ps->oposz = g_player[p].ps->posz = sector[sprite[OW].sectnum].ceilingz; - g_player[p].ps->posxv = 4096-(TRAND&8192); - g_player[p].ps->posyv = 4096-(TRAND&8192); + g_player[p].ps->posxv = 4096-(krand()&8192); + g_player[p].ps->posyv = 4096-(krand()&8192); // g_player[p].ps->poszv += 1080; } @@ -3197,9 +3214,9 @@ static void movetransports(void) if (screenpeek == p) { FX_StopAllSounds(); - clearsoundlocks(); + S_ClearSoundLocks(); } - spritesound(DUKE_GASP,j); + A_PlaySound(DUKE_GASP,j); g_player[p].ps->oposz = g_player[p].ps->posz = sector[sprite[OW].sectnum].floorz; @@ -3221,16 +3238,16 @@ static void movetransports(void) changespritesect(j,sprite[OW].sectnum); setsprite(g_player[p].ps->i,g_player[p].ps->posx,g_player[p].ps->posy,g_player[p].ps->posz+PHEIGHT); - setpal(g_player[p].ps); + P_UpdateScreenPal(g_player[p].ps); - if ((TRAND&255) < 32) - spawn(j,WATERSPLASH2); + if ((krand()&255) < 32) + A_Spawn(j,WATERSPLASH2); if (sectlotag == 1) for (l = 0;l < 9;l++) { - q = spawn(g_player[p].ps->i,WATERBUBBLE); - sprite[q].z += TRAND&16383; + q = A_Spawn(g_player[p].ps->i,WATERBUBBLE); + sprite[q].z += krand()&16383; } } } @@ -3268,9 +3285,9 @@ static void movetransports(void) warpspriteto = 1; } - if (warpspriteto && checkspriteflags(j,SPRITE_FLAG_DECAL)) goto JBOLT; + if (warpspriteto && A_CheckSpriteFlags(j,SPRITE_DECAL)) goto JBOLT; - if (warpspriteto) switch (dynamictostatic[sprite[j].picnum]) + if (warpspriteto) switch (DynamicTileMap[sprite[j].picnum]) { case TRANSPORTERSTAR__STATIC: case TRANSPORTERBEAM__STATIC: @@ -3300,12 +3317,12 @@ static void movetransports(void) if (sectlotag > 0) { - k = spawn(j,WATERSPLASH2); + k = A_Spawn(j,WATERSPLASH2); if (sectlotag == 1 && sprite[j].statnum == 4) { sprite[k].xvel = sprite[j].xvel>>1; sprite[k].ang = sprite[j].ang; - ssp(k,CLIPMASK0); + A_SetSprite(k,CLIPMASK0); } } @@ -3314,30 +3331,30 @@ static void movetransports(void) case 0: if (onfloorz) { - if (sprite[j].statnum == 4 || (checkcursectnums(sect) == -1 && checkcursectnums(sprite[OW].sectnum) == -1)) + if (sprite[j].statnum == 4 || (CheckPlayerInSector(sect) == -1 && CheckPlayerInSector(sprite[OW].sectnum) == -1)) { sprite[j].x += (sprite[OW].x-SX); sprite[j].y += (sprite[OW].y-SY); sprite[j].z -= SZ - sector[sprite[OW].sectnum].floorz; sprite[j].ang = sprite[OW].ang; - hittype[j].bposx = sprite[j].x; - hittype[j].bposy = sprite[j].y; - hittype[j].bposz = sprite[j].z; + ActorExtra[j].bposx = sprite[j].x; + ActorExtra[j].bposy = sprite[j].y; + ActorExtra[j].bposz = sprite[j].z; if (sprite[i].pal == 0) { - k = spawn(i,TRANSPORTERBEAM); - spritesound(TELEPORTER,k); + k = A_Spawn(i,TRANSPORTERBEAM); + A_PlaySound(TELEPORTER,k); - k = spawn(OW,TRANSPORTERBEAM); - spritesound(TELEPORTER,k); + k = A_Spawn(OW,TRANSPORTERBEAM); + A_PlaySound(TELEPORTER,k); } if (sprite[OW].owner != OW) { T1 = 13; - hittype[OW].temp_data[0] = 13; + ActorExtra[OW].temp_data[0] = 13; } changespritesect(j,sprite[OW].sectnum); @@ -3349,9 +3366,9 @@ static void movetransports(void) sprite[j].y += (sprite[OW].y-SY); sprite[j].z = sprite[OW].z+4096; - hittype[j].bposx = sprite[j].x; - hittype[j].bposy = sprite[j].y; - hittype[j].bposz = sprite[j].z; + ActorExtra[j].bposx = sprite[j].x; + ActorExtra[j].bposy = sprite[j].y; + ActorExtra[j].bposz = sprite[j].z; changespritesect(j,sprite[OW].sectnum); } @@ -3361,9 +3378,9 @@ static void movetransports(void) sprite[j].y += (sprite[OW].y-SY); sprite[j].z = sector[sprite[OW].sectnum].ceilingz+ll; - hittype[j].bposx = sprite[j].x; - hittype[j].bposy = sprite[j].y; - hittype[j].bposz = sprite[j].z; + ActorExtra[j].bposx = sprite[j].x; + ActorExtra[j].bposy = sprite[j].y; + ActorExtra[j].bposz = sprite[j].z; changespritesect(j,sprite[OW].sectnum); @@ -3373,9 +3390,9 @@ static void movetransports(void) sprite[j].y += (sprite[OW].y-SY); sprite[j].z = sector[sprite[OW].sectnum].floorz-ll; - hittype[j].bposx = sprite[j].x; - hittype[j].bposy = sprite[j].y; - hittype[j].bposz = sprite[j].z; + ActorExtra[j].bposx = sprite[j].x; + ActorExtra[j].bposy = sprite[j].y; + ActorExtra[j].bposz = sprite[j].z; changespritesect(j,sprite[OW].sectnum); @@ -3396,9 +3413,9 @@ BOLT: } } -static short LocateTheLocator(int n,int sn) +static short A_FindLocator(int n,int sn) { - int i = headspritestat[7]; + int i = headspritestat[STAT_LOCATOR]; while (i >= 0) { @@ -3409,13 +3426,13 @@ static short LocateTheLocator(int n,int sn) return -1; } -static void moveactors(void) +static void G_MoveActors(void) { int x, m, l; intptr_t *t; int a, j, nexti, nextj, sect, p, switchpicnum, k; spritetype *s; - int i = headspritestat[1]; + int i = headspritestat[STAT_ACTOR]; while (i >= 0) { @@ -3428,17 +3445,17 @@ static void moveactors(void) if (s->xrepeat == 0 || sect < 0 || sect >= MAXSECTORS) KILLIT(i); - t = &hittype[i].temp_data[0]; + t = &ActorExtra[i].temp_data[0]; - hittype[i].bposx = s->x; - hittype[i].bposy = s->y; - hittype[i].bposz = s->z; + ActorExtra[i].bposx = s->x; + ActorExtra[i].bposy = s->y; + ActorExtra[i].bposz = s->z; switchpicnum=s->picnum; if ((s->picnum > GREENSLIME)&&(s->picnum <= GREENSLIME+7)) { switchpicnum = GREENSLIME; } - switch (dynamictostatic[switchpicnum]) + switch (DynamicTileMap[switchpicnum]) { case DUCK__STATIC: case TARGET__STATIC: @@ -3454,13 +3471,13 @@ static void moveactors(void) } else { - j = ifhitbyweapon(i); + j = A_IncurDamage(i); if (j >= 0) { s->cstat = 32+128; k = 1; - j = headspritestat[1]; + j = headspritestat[STAT_ACTOR]; while (j >= 0) { if (sprite[j].lotag == s->lotag && @@ -3480,9 +3497,9 @@ static void moveactors(void) if (k == 1) { - operateactivators(s->lotag,-1); - operateforcefields(i,s->lotag); - operatemasterswitches(s->lotag); + G_OperateActivators(s->lotag,-1); + G_OperateForceFields(i,s->lotag); + G_OperateMasterSwitches(s->lotag); } } } @@ -3492,15 +3509,15 @@ static void moveactors(void) case RESPAWNMARKERYELLOW__STATIC: case RESPAWNMARKERGREEN__STATIC: T1++; - if (T1 > respawnitemtime) + if (T1 > g_itemRespawnTime) { KILLIT(i); } - if (T1 >= (respawnitemtime>>1) && T1 < ((respawnitemtime>>1)+(respawnitemtime>>2))) + if (T1 >= (g_itemRespawnTime>>1) && T1 < ((g_itemRespawnTime>>1)+(g_itemRespawnTime>>2))) PN = RESPAWNMARKERYELLOW; - else if (T1 > ((respawnitemtime>>1)+(respawnitemtime>>2))) + else if (T1 > ((g_itemRespawnTime>>1)+(g_itemRespawnTime>>2))) PN = RESPAWNMARKERGREEN; - makeitfall(i); + A_Fall(i); break; case HELECOPT__STATIC: @@ -3509,25 +3526,25 @@ static void moveactors(void) s->z += s->zvel; t[0]++; - if (t[0] == 4) spritesound(WAR_AMBIENCE2,i); + if (t[0] == 4) A_PlaySound(WAR_AMBIENCE2,i); if (t[0] > (26*8)) { - sound(RPG_EXPLODE); + S_PlaySound(RPG_EXPLODE); for (j=0;j<32;j++) RANDOMSCRAP; - earthquaketime = 16; + g_earthquakeTime = 16; KILLIT(i); } else if ((t[0]&3) == 0) - spawn(i,EXPLOSION2); - ssp(i,CLIPMASK0); + A_Spawn(i,EXPLOSION2); + A_SetSprite(i,CLIPMASK0); break; case RAT__STATIC: - makeitfall(i); + A_Fall(i); IFMOVING { - if ((TRAND&255) < 3) spritesound(RATTY,i); - s->ang += (TRAND&31)-15+(sintable[(t[0]<<8)&2047]>>11); + if ((krand()&255) < 3) A_PlaySound(RATTY,i); + s->ang += (krand()&31)-15+(sintable[(t[0]<<8)&2047]>>11); } else { @@ -3536,17 +3553,17 @@ static void moveactors(void) { KILLIT(i); } - else s->ang = (TRAND&2047); + else s->ang = (krand()&2047); } if (s->xvel < 128) s->xvel+=2; - s->ang += (TRAND&3)-6; + s->ang += (krand()&3)-6; break; case QUEBALL__STATIC: case STRIPEBALL__STATIC: if (s->xvel) { - j = headspritestat[0]; + j = headspritestat[STAT_DEFAULT]; while (j >= 0) { nextj = nextspritestat[j]; @@ -3572,7 +3589,7 @@ static void moveactors(void) else if ((j&49152) == 49152) { j &= (MAXSPRITES-1); - checkhitsprite(i,j); + A_DamageObject(i,j); } } s->xvel --; @@ -3586,26 +3603,26 @@ static void moveactors(void) } else { - p = findplayer(s,&x); + p = A_FindPlayer(s,&x); if (x < 1596) { // if(s->pal == 12) { - j = getincangle(g_player[p].ps->ang,getangle(s->x-g_player[p].ps->posx,s->y-g_player[p].ps->posy)); - if (j > -64 && j < 64 && (g_player[p].sync->bits&(1<<29))) + j = G_GetAngleDelta(g_player[p].ps->ang,getangle(s->x-g_player[p].ps->posx,s->y-g_player[p].ps->posy)); + if (j > -64 && j < 64 && TEST_SYNC_KEY(g_player[p].sync->bits, SK_OPEN)) if (g_player[p].ps->toggle_key_flag == 1) { - a = headspritestat[1]; + a = headspritestat[STAT_ACTOR]; while (a >= 0) { if (sprite[a].picnum == QUEBALL || sprite[a].picnum == STRIPEBALL) { - j = getincangle(g_player[p].ps->ang,getangle(sprite[a].x-g_player[p].ps->posx,sprite[a].y-g_player[p].ps->posy)); + j = G_GetAngleDelta(g_player[p].ps->ang,getangle(sprite[a].x-g_player[p].ps->posx,sprite[a].y-g_player[p].ps->posy)); if (j > -64 && j < 64) { - findplayer(&sprite[a],&l); + A_FindPlayer(&sprite[a],&l); if (x > l) break; } } @@ -3639,7 +3656,7 @@ static void moveactors(void) for (l=512;l<(2048-512);l+= 128) for (j=0;j<2048;j += 128) { - k = spawn(i,FORCESPHERE); + k = A_Spawn(i,FORCESPHERE); sprite[k].cstat = 257+128; sprite[k].clipdist = 64; sprite[k].ang = j; @@ -3662,11 +3679,11 @@ static void moveactors(void) } else if (t[2] > 10) { - j = headspritestat[5]; + j = headspritestat[STAT_MISC]; while (j >= 0) { if (sprite[j].owner == i && sprite[j].picnum == FORCESPHERE) - hittype[j].temp_data[1] = 1+(TRAND&63); + ActorExtra[j].temp_data[1] = 1+(krand()&63); j = nextspritestat[j]; } t[3] = 64; @@ -3676,7 +3693,7 @@ static void moveactors(void) case RECON__STATIC: - getglobalz(i); + A_GetZLimits(i); if (sector[s->sectnum].ceilingstat&1) s->shade += (sector[s->sectnum].ceilingshade-s->shade)>>1; @@ -3687,12 +3704,12 @@ static void moveactors(void) if (ud.multimode < 2) { - if (actor_tog == 1) + if (g_noEnemies == 1) { s->cstat = (short)32768; goto BOLT; } - else if (actor_tog == 2) s->cstat = 257; + else if (g_noEnemies == 2) s->cstat = 257; } IFHIT { @@ -3701,7 +3718,7 @@ static void moveactors(void) t[0] = -1; s->extra = 0; } - spritesound(RECO_PAIN,i); + A_PlaySound(RECO_PAIN,i); RANDOMSCRAP; } @@ -3709,17 +3726,17 @@ static void moveactors(void) { s->z += 1024; t[2]++; - if ((t[2]&3) == 0) spawn(i,EXPLOSION2); - getglobalz(i); + if ((t[2]&3) == 0) A_Spawn(i,EXPLOSION2); + A_GetZLimits(i); s->ang += 96; s->xvel = 128; - j = ssp(i,CLIPMASK0); - if (j != 1 || s->z > hittype[i].floorz) + j = A_SetSprite(i,CLIPMASK0); + if (j != 1 || s->z > ActorExtra[i].floorz) { for (l=0;l<16;l++) RANDOMSCRAP; - spritesound(LASERTRIP_EXPLODE,i); - spawn(i,PIGCOP); + A_PlaySound(LASERTRIP_EXPLODE,i); + A_Spawn(i,PIGCOP); g_player[myconnectindex].ps->actors_killed++; KILLIT(i); } @@ -3727,11 +3744,11 @@ static void moveactors(void) } else { - if (s->z > hittype[i].floorz-(48<<8)) - s->z = hittype[i].floorz-(48<<8); + if (s->z > ActorExtra[i].floorz-(48<<8)) + s->z = ActorExtra[i].floorz-(48<<8); } - p = findplayer(s,&x); + p = A_FindPlayer(s,&x); j = s->owner; // 3 = findplayerz, 4 = shoot @@ -3742,9 +3759,9 @@ static void moveactors(void) if ((t[2]&15) == 0) { a = s->ang; - s->ang = hittype[i].tempang; - spritesound(RECO_ATTACK,i); - shoot(i,FIRELASER); + s->ang = ActorExtra[i].tempang; + A_PlaySound(RECO_ATTACK,i); + A_Shoot(i,FIRELASER); s->ang = a; } if (t[2] > (26*3) || !cansee(s->x,s->y,s->z-(16<<8),s->sectnum, g_player[p].ps->posx,g_player[p].ps->posy,g_player[p].ps->posz,g_player[p].ps->cursectnum)) @@ -3752,8 +3769,8 @@ static void moveactors(void) t[0] = 0; t[2] = 0; } - else hittype[i].tempang += - getincangle(hittype[i].tempang,getangle(g_player[p].ps->posx-s->x,g_player[p].ps->posy-s->y))/3; + else ActorExtra[i].tempang += + G_GetAngleDelta(ActorExtra[i].tempang,getangle(g_player[p].ps->posx-s->x,g_player[p].ps->posy-s->y))/3; } else if (t[0] == 2 || t[0] == 3) { @@ -3777,11 +3794,11 @@ static void moveactors(void) } else if ((t[2]&15) == 0) { - spritesound(RECO_ATTACK,i); - shoot(i,FIRELASER); + A_PlaySound(RECO_ATTACK,i); + A_Shoot(i,FIRELASER); } } - s->ang += getincangle(s->ang,getangle(g_player[p].ps->posx-s->x,g_player[p].ps->posy-s->y))>>2; + s->ang += G_GetAngleDelta(s->ang,getangle(g_player[p].ps->posx-s->x,g_player[p].ps->posy-s->y))>>2; } if (t[0] != 2 && t[0] != 3) @@ -3821,9 +3838,9 @@ static void moveactors(void) if (x < 6144 && t[0] < 2 && t[2] > (26*4)) { - t[0] = 2+(TRAND&2); + t[0] = 2+(krand()&2); t[2] = 0; - hittype[i].tempang = s->ang; + ActorExtra[i].tempang = s->ang; } } @@ -3832,38 +3849,40 @@ static void moveactors(void) if (t[0] == 0) t[0] = 1; else t[0] = 4; - j = s->owner = LocateTheLocator(s->hitag,-1); + j = s->owner = A_FindLocator(s->hitag,-1); if (j == -1) { - s->hitag = j = hittype[i].temp_data[5]; - s->owner = LocateTheLocator(j,-1); + s->hitag = j = ActorExtra[i].temp_data[5]; + s->owner = A_FindLocator(j,-1); j = s->owner; if (j == -1) KILLIT(i); } else s->hitag++; } - t[3] = getincangle(s->ang,a); + t[3] = G_GetAngleDelta(s->ang,a); s->ang += t[3]>>3; - if (s->z < sprite[j].z) - s->z += 1024; - else s->z -= 1024; + if ((s->z - sprite[j].z) < -512) + s->z += 512; + else if ((s->z - sprite[j].z) > 512) + s->z -= 512; + else s->z = sprite[j].z; } - if (!isspritemakingsound(i,RECO_ROAM)) - spritesound(RECO_ROAM,i); + if (!A_CheckSoundPlaying(i,RECO_ROAM)) + A_PlaySound(RECO_ROAM,i); - ssp(i,CLIPMASK0); + A_SetSprite(i,CLIPMASK0); goto BOLT; case OOZ__STATIC: case OOZ2__STATIC: - getglobalz(i); + A_GetZLimits(i); - j = (hittype[i].floorz-hittype[i].ceilingz)>>9; + j = (ActorExtra[i].floorz-ActorExtra[i].ceilingz)>>9; if (j > 255) j = 255; x = 25-(j>>1); @@ -3872,7 +3891,7 @@ static void moveactors(void) s->yrepeat = j; s->xrepeat = x; - s->z = hittype[i].floorz; + s->z = ActorExtra[i].floorz; goto BOLT; @@ -3888,12 +3907,12 @@ static void moveactors(void) // #ifndef VOLUMEONE if (ud.multimode < 2) { - if (actor_tog == 1) + if (g_noEnemies == 1) { s->cstat = (short)32768; goto BOLT; } - else if (actor_tog == 2) s->cstat = 257; + else if (g_noEnemies == 2) s->cstat = 257; } // #endif @@ -3902,14 +3921,14 @@ static void moveactors(void) if (sector[sect].floorstat&1) KILLIT(i); - p = findplayer(s,&x); + p = A_FindPlayer(s,&x); if (x > 20480) { - hittype[i].timetosleep++; - if (hittype[i].timetosleep > SLEEPTIME) + ActorExtra[i].timetosleep++; + if (ActorExtra[i].timetosleep > SLEEPTIME) { - hittype[i].timetosleep = 0; + ActorExtra[i].timetosleep = 0; changespritestat(i,2); goto BOLT; } @@ -3924,7 +3943,7 @@ static void moveactors(void) t[0] = 0; goto BOLT; } - makeitfall(i); + A_Fall(i); s->cstat = 257; s->picnum = GREENSLIME+2; s->extra = 1; @@ -3934,15 +3953,15 @@ static void moveactors(void) if (j == FREEZEBLAST) goto BOLT; for (j=16; j >= 0 ;j--) { - k = EGS(SECT,SX,SY,SZ,GLASSPIECES+(j%3),-32,36,36,TRAND&2047,32+(TRAND&63),1024-(TRAND&1023),i,5); + k = A_InsertSprite(SECT,SX,SY,SZ,GLASSPIECES+(j%3),-32,36,36,krand()&2047,32+(krand()&63),1024-(krand()&1023),i,5); sprite[k].pal = 1; } - spritesound(GLASS_BREAKING,i); + A_PlaySound(GLASS_BREAKING,i); KILLIT(i); } else if (x < 1024 && g_player[p].ps->quick_kick == 0) { - j = getincangle(g_player[p].ps->ang,getangle(SX-g_player[p].ps->posx,SY-g_player[p].ps->posy)); + j = G_GetAngleDelta(g_player[p].ps->ang,getangle(SX-g_player[p].ps->posx,SY-g_player[p].ps->posy)); if (j > -128 && j < 128) g_player[p].ps->quick_kick = 14; } @@ -3966,20 +3985,20 @@ static void moveactors(void) s->ang = g_player[p].ps->ang; - if (((g_player[p].sync->bits&4) || (g_player[p].ps->quick_kick > 0)) && sprite[g_player[p].ps->i].extra > 0) + if ((TEST_SYNC_KEY(g_player[p].sync->bits, SK_FIRE) || (g_player[p].ps->quick_kick > 0)) && sprite[g_player[p].ps->i].extra > 0) if (g_player[p].ps->quick_kick > 0 || (g_player[p].ps->curr_weapon != HANDREMOTE_WEAPON && g_player[p].ps->curr_weapon != HANDBOMB_WEAPON && g_player[p].ps->curr_weapon != TRIPBOMB_WEAPON && g_player[p].ps->ammo_amount[g_player[p].ps->curr_weapon] >= 0)) { for (x=0;x<8;x++) { - j = EGS(sect,s->x,s->y,s->z-(8<<8),SCRAP3+(TRAND&3),-8,48,48,TRAND&2047,(TRAND&63)+64,-(TRAND&4095)-(s->zvel>>2),i,5); + j = A_InsertSprite(sect,s->x,s->y,s->z-(8<<8),SCRAP3+(krand()&3),-8,48,48,krand()&2047,(krand()&63)+64,-(krand()&4095)-(s->zvel>>2),i,5); sprite[j].pal = 6; } - spritesound(SLIM_DYING,i); - spritesound(SQUISHED,i); - if ((TRAND&255) < 32) + A_PlaySound(SLIM_DYING,i); + A_PlaySound(SQUISHED,i); + if ((krand()&255) < 32) { - j = spawn(i,BLOODPOOL); + j = A_Spawn(i,BLOODPOOL); sprite[j].pal = 0; } g_player[p].ps->actors_killed ++; @@ -4008,9 +4027,9 @@ static void moveactors(void) g_player[p].ps->ang = g_player[p].ps->oang; updatesector(g_player[p].ps->posx,g_player[p].ps->posy,&g_player[p].ps->cursectnum); - setpal(g_player[p].ps); + P_UpdateScreenPal(g_player[p].ps); - j = headspritestat[1]; + j = headspritestat[STAT_ACTOR]; while (j >= 0) { if (sprite[j].picnum==CAMERA1) sprite[j].yvel = 0; @@ -4026,8 +4045,8 @@ static void moveactors(void) if (t[3] == 5) { - sprite[g_player[p].ps->i].extra += -(5+(TRAND&3)); - spritesound(SLIM_ATTACK,i); + sprite[g_player[p].ps->i].extra += -(5+(krand()&3)); + A_PlaySound(SLIM_ATTACK,i); } if (t[3] < 7) t[3]++; @@ -4064,7 +4083,7 @@ static void moveactors(void) IFHIT { - spritesound(SLIM_DYING,i); + A_PlaySound(SLIM_DYING,i); g_player[p].ps->actors_killed ++; if (g_player[p].ps->somethingonplayer == i) @@ -4072,21 +4091,21 @@ static void moveactors(void) if (j == FREEZEBLAST) { - spritesound(SOMETHINGFROZE,i); + A_PlaySound(SOMETHINGFROZE,i); t[0] = -5 ; t[3] = 0 ; goto BOLT; } - if ((TRAND&255) < 32) + if ((krand()&255) < 32) { - j = spawn(i,BLOODPOOL); + j = A_Spawn(i,BLOODPOOL); sprite[j].pal = 0; } for (x=0;x<8;x++) { - j = EGS(sect,s->x,s->y,s->z-(8<<8),SCRAP3+(TRAND&3),-8,48,48,TRAND&2047,(TRAND&63)+64,-(TRAND&4095)-(s->zvel>>2),i,5); + j = A_InsertSprite(sect,s->x,s->y,s->z-(8<<8),SCRAP3+(krand()&3),-8,48,48,krand()&2047,(krand()&63)+64,-(krand()&4095)-(s->zvel>>2),i,5); sprite[j].pal = 6; } t[0] = -3; @@ -4095,16 +4114,16 @@ static void moveactors(void) // All weap if (t[0] == -1) //Shrinking down { - makeitfall(i); + A_Fall(i); s->cstat &= 65535-8; s->picnum = GREENSLIME+4; // if(s->yrepeat > 62) - // guts(s,JIBS6,5,myconnectindex); + // A_DoGuts(s,JIBS6,5,myconnectindex); - if (s->xrepeat > 32) s->xrepeat -= TRAND&7; - if (s->yrepeat > 16) s->yrepeat -= TRAND&7; + if (s->xrepeat > 32) s->xrepeat -= krand()&7; + if (s->yrepeat > 16) s->yrepeat -= krand()&7; else { s->xrepeat = 40; @@ -4115,11 +4134,11 @@ static void moveactors(void) goto BOLT; } - else if (t[0] != -2) getglobalz(i); + else if (t[0] != -2) A_GetZLimits(i); if (t[0] == -2) //On top of somebody { - makeitfall(i); + A_Fall(i); sprite[t[5]].xvel = 0; l = sprite[t[5]].ang; @@ -4128,7 +4147,7 @@ static void moveactors(void) s->x = sprite[t[5]].x+(sintable[(l+512)&2047]>>11); s->y = sprite[t[5]].y+(sintable[l&2047]>>11); - s->picnum = GREENSLIME+2+(global_random&1); + s->picnum = GREENSLIME+2+(g_globalRandom&1); if (s->yrepeat < 64) s->yrepeat+=2; else @@ -4158,7 +4177,7 @@ static void moveactors(void) j = headspritesect[sect]; while (j>=0) { - switch (dynamictostatic[sprite[j].picnum]) + switch (DynamicTileMap[sprite[j].picnum]) { case LIZTROOP__STATIC: case LIZMAN__STATIC: @@ -4183,15 +4202,15 @@ static void moveactors(void) { s->picnum = GREENSLIME; - if ((TRAND&511) == 0) - spritesound(SLIM_ROAM,i); + if ((krand()&511) == 0) + A_PlaySound(SLIM_ROAM,i); if (t[0]==2) { s->zvel = 0; s->cstat &= (65535-8); - if ((sector[sect].ceilingstat&1) || (hittype[i].ceilingz+6144) < s->z) + if ((sector[sect].ceilingstat&1) || (ActorExtra[i].ceilingz+6144) < s->z) { s->z += 2048; t[0] = 3; @@ -4201,10 +4220,10 @@ static void moveactors(void) else { s->cstat |= 8; - makeitfall(i); + A_Fall(i); } - if (everyothertime&1) ssp(i,CLIPMASK0); + if (everyothertime&1) A_SetSprite(i,CLIPMASK0); if (s->xvel > 96) { @@ -4216,8 +4235,8 @@ static void moveactors(void) if (s->xvel < 32) s->xvel += 4; s->xvel = 64 - (sintable[(t[1]+512)&2047]>>9); - s->ang += getincangle(s->ang, - getangle(g_player[p].ps->posx-s->x,g_player[p].ps->posy-s->y))>>3; + s->ang += G_GetAngleDelta(s->ang, + getangle(g_player[p].ps->posx-s->x,g_player[p].ps->posy-s->y))>>3; // TJR } @@ -4225,7 +4244,7 @@ static void moveactors(void) s->yrepeat = 16 + (sintable[t[1]&2047]>>13); if (rnd(4) && (sector[sect].ceilingstat&1) == 0 && - klabs(hittype[i].floorz-hittype[i].ceilingz) + klabs(ActorExtra[i].floorz-ActorExtra[i].ceilingz) < (192<<8)) { s->zvel = 0; @@ -4242,9 +4261,9 @@ static void moveactors(void) if (s->zvel > -(2048+1024)) s->zvel -= 348; s->z += s->zvel; - if (s->z < hittype[i].ceilingz+4096) + if (s->z < ActorExtra[i].ceilingz+4096) { - s->z = hittype[i].ceilingz+4096; + s->z = ActorExtra[i].ceilingz+4096; s->xvel = 0; t[0] = 2; } @@ -4254,9 +4273,9 @@ static void moveactors(void) { s->picnum = GREENSLIME+1; - makeitfall(i); + A_Fall(i); - if (s->z > hittype[i].floorz-(8<<8)) + if (s->z > ActorExtra[i].floorz-(8<<8)) { s->yrepeat-=4; s->xrepeat+=2; @@ -4267,9 +4286,9 @@ static void moveactors(void) if (s->xrepeat > 8) s->xrepeat-=4; } - if (s->z > hittype[i].floorz-2048) + if (s->z > ActorExtra[i].floorz-2048) { - s->z = hittype[i].floorz-2048; + s->z = ActorExtra[i].floorz-2048; t[0] = 0; s->xvel = 0; } @@ -4278,8 +4297,8 @@ static void moveactors(void) case BOUNCEMINE__STATIC: case MORTER__STATIC: - j = spawn(i,(PLUTOPAK?FRAMEEFFECT1:FRAMEEFFECT1_13)); - hittype[j].temp_data[0] = 3; + j = A_Spawn(i,(PLUTOPAK?FRAMEEFFECT1:FRAMEEFFECT1_13)); + ActorExtra[j].temp_data[0] = 3; case HEAVYHBOMB__STATIC: @@ -4288,21 +4307,21 @@ static void moveactors(void) t[2]--; if (t[2] <= 0) { - spritesound(TELEPORTER,i); - spawn(i,TRANSPORTERSTAR); + A_PlaySound(TELEPORTER,i); + A_Spawn(i,TRANSPORTERSTAR); s->cstat = 257; } goto BOLT; } - p = findplayer(s,&x); + p = A_FindPlayer(s,&x); if (x < 1220) s->cstat &= ~257; else s->cstat |= 257; if (t[3] == 0) { - j = ifhitbyweapon(i); + j = A_IncurDamage(i); if (j >= 0) { t[3] = 1; @@ -4315,38 +4334,38 @@ static void moveactors(void) if (s->picnum != BOUNCEMINE) { - makeitfall(i); + A_Fall(i); - if ((sector[sect].lotag != 1 || hittype[i].floorz != sector[sect].floorz) && s->z >= hittype[i].floorz-(FOURSLEIGHT) && s->yvel < 3) + if ((sector[sect].lotag != 1 || ActorExtra[i].floorz != sector[sect].floorz) && s->z >= ActorExtra[i].floorz-(FOURSLEIGHT) && s->yvel < 3) { - if (s->yvel > 0 || (s->yvel == 0 && hittype[i].floorz == sector[sect].floorz)) - spritesound(PIPEBOMB_BOUNCE,i); + if (s->yvel > 0 || (s->yvel == 0 && ActorExtra[i].floorz == sector[sect].floorz)) + A_PlaySound(PIPEBOMB_BOUNCE,i); s->zvel = -((4-s->yvel)<<8); if (sector[s->sectnum].lotag== 2) s->zvel >>= 2; s->yvel++; } - if (s->z < hittype[i].ceilingz) // && sector[sect].lotag != 2 ) + if (s->z < ActorExtra[i].ceilingz) // && sector[sect].lotag != 2 ) { - s->z = hittype[i].ceilingz+(3<<8); + s->z = ActorExtra[i].ceilingz+(3<<8); s->zvel = 0; } } - j = movesprite(i, - (s->xvel*(sintable[(s->ang+512)&2047]))>>14, - (s->xvel*(sintable[s->ang&2047]))>>14, - s->zvel,CLIPMASK0); + j = A_MoveSprite(i, + (s->xvel*(sintable[(s->ang+512)&2047]))>>14, + (s->xvel*(sintable[s->ang&2047]))>>14, + s->zvel,CLIPMASK0); - hittype[i].movflag = j; + ActorExtra[i].movflag = j; - if (sector[SECT].lotag == 1 && s->zvel == 0 && hittype[i].floorz == sector[sect].floorz) + if (sector[SECT].lotag == 1 && s->zvel == 0 && ActorExtra[i].floorz == sector[sect].floorz) { s->z += (32<<8); if (t[5] == 0) { t[5] = 1; - spawn(i,WATERSPLASH2); + A_Spawn(i,WATERSPLASH2); } } else t[5] = 0; @@ -4379,7 +4398,7 @@ static void moveactors(void) { j &= (MAXWALLS-1); - checkhitwall(i,j,s->x,s->y,s->z,s->picnum); + A_DamageWall(i,j,s->x,s->y,s->z,s->picnum); k = getangle( wall[wall[j].point2].x-wall[j].x, @@ -4389,7 +4408,7 @@ static void moveactors(void) s->xvel >>= 1; } - // int lPipeBombControl=GetGameVar("PIPEBOMB_CONTROL", PIPEBOMB_REMOTE, -1, -1); + // int lPipeBombControl=Gv_GetVarByLabel("PIPEBOMB_CONTROL", PIPEBOMB_REMOTE, -1, -1); DETONATEB: @@ -4426,24 +4445,24 @@ DETONATEB: { x = s->extra; m = 0; - switch (dynamictostatic[s->picnum]) + switch (DynamicTileMap[s->picnum]) { case HEAVYHBOMB__STATIC: - m = pipebombblastradius; + m = g_pipebombBlastRadius; break; case MORTER__STATIC: - m = morterblastradius; + m = g_morterBlastRadius; break; case BOUNCEMINE__STATIC: - m = bouncemineblastradius; + m = g_bouncemineBlastRadius; break; } - hitradius(i, m,x>>2,x>>1,x-(x>>2),x); - spawn(i,EXPLOSION2); + A_RadiusDamage(i, m,x>>2,x>>1,x-(x>>2),x); + A_Spawn(i,EXPLOSION2); if (s->zvel == 0) - spawn(i,EXPLOSION2BOT); - spritesound(PIPEBOMB_EXPLODE,i); + A_Spawn(i,EXPLOSION2BOT); + A_PlaySound(PIPEBOMB_EXPLODE,i); for (x=0;x<8;x++) RANDOMSCRAP; } @@ -4462,8 +4481,8 @@ DETONATEB: } else { - t[2] = respawnitemtime; - spawn(i,RESPAWNMARKERRED); + t[2] = g_itemRespawnTime; + A_Spawn(i,RESPAWNMARKERRED); s->cstat = (short) 32768; s->yrepeat = 9; goto BOLT; @@ -4474,7 +4493,7 @@ DETONATEB: if (cansee(s->x,s->y,s->z-(8<<8),s->sectnum,g_player[p].ps->posx,g_player[p].ps->posy,g_player[p].ps->posz,g_player[p].ps->cursectnum)) if (g_player[p].ps->ammo_amount[HANDBOMB_WEAPON] < g_player[p].ps->max_ammo_amount[HANDBOMB_WEAPON]) { - if ((gametype_flags[ud.coop] & GAMETYPE_FLAG_WEAPSTAY) && s->owner == i) + if ((GametypeFlags[ud.coop] & GAMETYPE_WEAPSTAY) && s->owner == i) { for (j=0;jweapreccnt;j++) if (g_player[p].ps->weaprecs[j] == s->picnum) @@ -4484,15 +4503,15 @@ DETONATEB: g_player[p].ps->weaprecs[g_player[p].ps->weapreccnt++] = s->picnum; } - addammo(HANDBOMB_WEAPON,g_player[p].ps,1); - spritesound(DUKE_GET,g_player[p].ps->i); + P_AddAmmo(HANDBOMB_WEAPON,g_player[p].ps,1); + A_PlaySound(DUKE_GET,g_player[p].ps->i); if (g_player[p].ps->gotweapon[HANDBOMB_WEAPON] == 0 || s->owner == g_player[p].ps->i) { - /* addweapon(g_player[p].ps,HANDBOMB_WEAPON); */ + /* P_AddWeapon(g_player[p].ps,HANDBOMB_WEAPON); */ if (!(g_player[p].ps->weaponswitch & 1) && *aplWeaponWorksLike[g_player[p].ps->curr_weapon] != HANDREMOTE_WEAPON) - addweaponnoswitch(g_player[p].ps,HANDBOMB_WEAPON); - else addweapon(g_player[p].ps,HANDBOMB_WEAPON); + P_AddWeaponNoSwitch(g_player[p].ps,HANDBOMB_WEAPON); + else P_AddWeapon(g_player[p].ps,HANDBOMB_WEAPON); } if (sprite[s->owner].picnum != APLAYER) @@ -4505,14 +4524,14 @@ DETONATEB: if (s->owner != i || ud.respawn_items == 0) { - if (s->owner == i && (gametype_flags[ud.coop] & GAMETYPE_FLAG_WEAPSTAY)) + if (s->owner == i && (GametypeFlags[ud.coop] & GAMETYPE_WEAPSTAY)) goto BOLT; KILLIT(i); } else { - t[2] = respawnitemtime; - spawn(i,RESPAWNMARKERRED); + t[2] = g_itemRespawnTime; + A_Spawn(i,RESPAWNMARKERRED); s->cstat = (short) 32768; } } @@ -4532,7 +4551,7 @@ DETONATEB: j = headspritesect[sect]; while (j >= 0) { - switch (dynamictostatic[sprite[j].picnum]) + switch (DynamicTileMap[sprite[j].picnum]) { case SECTOREFFECTOR__STATIC: if (sprite[j].lotag == 1) @@ -4563,19 +4582,19 @@ DETONATEB: goto BOLT; } - p = findplayer(s,&x); + p = A_FindPlayer(s,&x); t[2]++; if (t[2] == 4) t[2]=0; if (x < 4096) { - if ((TRAND&255) < 16) + if ((krand()&255) < 16) { - if (!isspritemakingsound(g_player[p].ps->i, DUKE_LONGTERM_PAIN)) - spritesound(DUKE_LONGTERM_PAIN,g_player[p].ps->i); + if (!A_CheckSoundPlaying(g_player[p].ps->i, DUKE_LONGTERM_PAIN)) + A_PlaySound(DUKE_LONGTERM_PAIN,g_player[p].ps->i); - spritesound(SHORT_CIRCUIT,i); + A_PlaySound(SHORT_CIRCUIT,i); sprite[g_player[p].ps->i].extra --; g_player[p].ps->pals_time = 32; @@ -4594,34 +4613,34 @@ DETONATEB: t[1]++; t[4] = s->z; - s->z = sector[sect].floorz-(TRAND%(sector[sect].floorz-sector[sect].ceilingz)); + s->z = sector[sect].floorz-(krand()%(sector[sect].floorz-sector[sect].ceilingz)); switch (t[1]) { case 3: //Turn on all of those flashing sectoreffector. - hitradius(i, 4096, - impact_damage<<2, - impact_damage<<2, - impact_damage<<2, - impact_damage<<2); + A_RadiusDamage(i, 4096, + g_impactDamage<<2, + g_impactDamage<<2, + g_impactDamage<<2, + g_impactDamage<<2); /* - j = headspritestat[3]; + j = headspritestat[STAT_EFFECTOR]; while(j>=0) { if( sprite[j].lotag == 3 ) - hittype[j].temp_data[4]=1; + ActorExtra[j].temp_data[4]=1; else if(sprite[j].lotag == 12) { - hittype[j].temp_data[4] = 1; + ActorExtra[j].temp_data[4] = 1; sprite[j].lotag = 3; sprite[j].owner = 0; - hittype[j].temp_data[0] = s->shade; + ActorExtra[j].temp_data[0] = s->shade; } j = nextspritestat[j]; } */ - j = headspritestat[6]; + j = headspritestat[STAT_STANDABLE]; while (j >= 0) { if (sprite[j].picnum == MASTERSWITCH) @@ -4674,7 +4693,7 @@ DETONATEB: if (t[0] == 0) { t[1]+=8; - if (camerashitable) + if (g_damageCameras) { IFHIT { @@ -4703,14 +4722,14 @@ DETONATEB: goto BOLT; } - if (ud.multimode < 2 && badguy(s)) + if (ud.multimode < 2 && A_CheckEnemySprite(s)) { - if (actor_tog == 1) + if (g_noEnemies == 1) { s->cstat = (short)32768; goto BOLT; } - else if (actor_tog == 2) + else if (g_noEnemies == 2) { s->cstat = 0; if (s->extra) @@ -4720,15 +4739,15 @@ DETONATEB: if (!actorscrptr[sprite[i].picnum]) goto BOLT; - p = findplayer(s,&x); - execute(i,p,x); + p = A_FindPlayer(s,&x); + A_Execute(i,p,x); BOLT: i = nexti; } } -static void moveexplosions(void) // STATNUM 5 +static void G_MoveMisc(void) // STATNUM 5 { short i, j, nexti, sect, p; int l, x; @@ -4736,20 +4755,20 @@ static void moveexplosions(void) // STATNUM 5 spritetype *s; int switchpicnum; - i = headspritestat[5]; + i = headspritestat[STAT_MISC]; while (i >= 0) { nexti = nextspritestat[i]; - t = &hittype[i].temp_data[0]; + t = &ActorExtra[i].temp_data[0]; s = &sprite[i]; sect = s->sectnum; if (sect < 0 || s->xrepeat == 0) KILLIT(i); - hittype[i].bposx = s->x; - hittype[i].bposy = s->y; - hittype[i].bposz = s->z; + ActorExtra[i].bposx = s->x; + ActorExtra[i].bposy = s->y; + ActorExtra[i].bposz = s->z; switchpicnum = s->picnum; if ((s->picnum > NUKEBUTTON)&&(s->picnum <= NUKEBUTTON+3)) { @@ -4764,8 +4783,8 @@ static void moveexplosions(void) // STATNUM 5 switchpicnum--; } if ((s->picnum == MONEY+1) || (s->picnum == MAIL+1) || (s->picnum == PAPER+1)) - hittype[i].floorz = s->z = getflorzofslope(s->sectnum,s->x,s->y); - else switch (dynamictostatic[switchpicnum]) + ActorExtra[i].floorz = s->z = getflorzofslope(s->sectnum,s->x,s->y); + else switch (DynamicTileMap[switchpicnum]) { case NEON1__STATIC: case NEON2__STATIC: @@ -4774,7 +4793,7 @@ static void moveexplosions(void) // STATNUM 5 case NEON5__STATIC: case NEON6__STATIC: - if ((global_random/(s->lotag+1)&31) > 4) s->shade = -127; + if ((g_globalRandom/(s->lotag+1)&31) > 4) s->shade = -127; else s->shade = 127; goto BOLT; @@ -4784,7 +4803,7 @@ static void moveexplosions(void) // STATNUM 5 case BLOODSPLAT4__STATIC: if (t[0] == 7*26) goto BOLT; - s->z += 16+(TRAND&15); + s->z += 16+(krand()&15); t[0]++; if ((t[0]%9) == 0) s->yrepeat++; goto BOLT; @@ -4819,7 +4838,7 @@ static void moveexplosions(void) // STATNUM 5 KILLIT(i); } } - if (hittype[s->owner].temp_data[1] == 0) + if (ActorExtra[s->owner].temp_data[1] == 0) { if (t[0] < 64) { @@ -4837,7 +4856,7 @@ static void moveexplosions(void) // STATNUM 5 s->x = sprite[s->owner].x; s->y = sprite[s->owner].y; s->z = sprite[s->owner].z; - s->ang += hittype[s->owner].temp_data[0]; + s->ang += ActorExtra[s->owner].temp_data[0]; if (l > 64) l = 64; else if (l < 1) l = 1; @@ -4847,7 +4866,7 @@ static void moveexplosions(void) // STATNUM 5 s->shade = (l>>1)-48; for (j=t[0];j > 0;j--) - ssp(i,CLIPMASK0); + A_SetSprite(i,CLIPMASK0); goto BOLT; case WATERSPLASH2__STATIC: @@ -4862,8 +4881,8 @@ static void moveexplosions(void) // STATNUM 5 if( l > (16<<8) ) KILLIT(i); } else */ - if (!issoundplaying(i,ITEM_SPLASH)) - spritesound(ITEM_SPLASH,i); + if (!S_CheckSoundPlaying(i,ITEM_SPLASH)) + A_PlaySound(ITEM_SPLASH,i); } if (t[0] == 3) { @@ -4896,7 +4915,7 @@ static void moveexplosions(void) // STATNUM 5 case INNERJAW__STATIC: // case INNERJAW+1: - p = findplayer(s,&x); + p = A_FindPlayer(s,&x); if (x < 512) { g_player[p].ps->pals_time = 32; @@ -4918,23 +4937,23 @@ static void moveexplosions(void) // STATNUM 5 case MAIL__STATIC: case PAPER__STATIC: - s->xvel = (TRAND&7)+(sintable[T1&2047]>>9); - T1 += (TRAND&63); + s->xvel = (krand()&7)+(sintable[T1&2047]>>9); + T1 += (krand()&63); if ((T1&2047) > 512 && (T1&2047) < 1596) { if (sector[sect].lotag == 2) { if (s->zvel < 64) - s->zvel += (gc>>5)+(TRAND&7); + s->zvel += (SpriteGravity>>5)+(krand()&7); } else if (s->zvel < 144) - s->zvel += (gc>>5)+(TRAND&7); + s->zvel += (SpriteGravity>>5)+(krand()&7); } - ssp(i,CLIPMASK0); + A_SetSprite(i,CLIPMASK0); - if ((TRAND&3) == 0) + if ((krand()&3) == 0) setsprite(i,s->x,s->y,s->z); if (s->sectnum == -1) KILLIT(i); @@ -4944,10 +4963,10 @@ static void moveexplosions(void) // STATNUM 5 { s->z = l; - insertspriteq(i); + A_AddToDeleteQueue(i); PN ++; - j = headspritestat[5]; + j = headspritestat[STAT_MISC]; while (j >= 0) { if (sprite[j].picnum == BLOODPOOL) @@ -5020,7 +5039,7 @@ static void moveexplosions(void) // STATNUM 5 s->zvel += 48; else s->zvel = 1024; } - else s->zvel += gc-50; + else s->zvel += SpriteGravity-50; } s->x += (s->xvel*sintable[(s->ang+512)&2047])>>14; @@ -5074,46 +5093,46 @@ static void moveexplosions(void) // STATNUM 5 { KILLIT(i); } - else insertspriteq(i); + else A_AddToDeleteQueue(i); } - makeitfall(i); + A_Fall(i); - p = findplayer(s,&x); + p = A_FindPlayer(s,&x); - s->z = hittype[i].floorz-(FOURSLEIGHT); + s->z = ActorExtra[i].floorz-(FOURSLEIGHT); if (t[2] < 32) { t[2]++; - if (hittype[i].picnum == TIRE) + if (ActorExtra[i].picnum == TIRE) { if (s->xrepeat < 64 && s->yrepeat < 64) { - s->xrepeat += TRAND&3; - s->yrepeat += TRAND&3; + s->xrepeat += krand()&3; + s->yrepeat += krand()&3; } } else { if (s->xrepeat < 32 && s->yrepeat < 32) { - s->xrepeat += TRAND&3; - s->yrepeat += TRAND&3; + s->xrepeat += krand()&3; + s->yrepeat += krand()&3; } } } if (x < 844 && s->xrepeat > 6 && s->yrepeat > 6) { - if (s->pal == 0 && (TRAND&255) < 16 && s->picnum != PUKE) + if (s->pal == 0 && (krand()&255) < 16 && s->picnum != PUKE) { if (g_player[p].ps->boot_amount > 0) g_player[p].ps->boot_amount--; else { - if (!isspritemakingsound(g_player[p].ps->i,DUKE_LONGTERM_PAIN)) - spritesound(DUKE_LONGTERM_PAIN,g_player[p].ps->i); + if (!A_CheckSoundPlaying(g_player[p].ps->i,DUKE_LONGTERM_PAIN)) + A_PlaySound(DUKE_LONGTERM_PAIN,g_player[p].ps->i); sprite[g_player[p].ps->i].extra --; g_player[p].ps->pals_time = 32; g_player[p].ps->pals[0] = 16; @@ -5125,7 +5144,7 @@ static void moveexplosions(void) // STATNUM 5 if (t[1] == 1) goto BOLT; t[1] = 1; - if (hittype[i].picnum == TIRE) + if (ActorExtra[i].picnum == TIRE) g_player[p].ps->footprintcount = 10; else g_player[p].ps->footprintcount = 3; @@ -5156,14 +5175,14 @@ static void moveexplosions(void) // STATNUM 5 case TRANSPORTERBEAM__STATIC: if (!actorscrptr[sprite[i].picnum]) goto BOLT; - p = findplayer(s,&x); - execute(i,p,x); + p = A_FindPlayer(s,&x); + A_Execute(i,p,x); goto BOLT; case SHELL__STATIC: case SHOTGUNSHELL__STATIC: - ssp(i,CLIPMASK0); + A_SetSprite(i,CLIPMASK0); if (sect < 0 || (sector[sect].floorz + 256) < s->z) KILLIT(i); @@ -5176,7 +5195,7 @@ static void moveexplosions(void) // STATNUM 5 t[0]++; t[0] &= 3; } - if (s->zvel < 128) s->zvel += (gc/13); // 8 + if (s->zvel < 128) s->zvel += (SpriteGravity/13); // 8 else s->zvel -= 64; if (s->xvel > 0) s->xvel -= 4; @@ -5191,7 +5210,7 @@ static void moveexplosions(void) // STATNUM 5 t[0]++; t[0] &= 3; } - if (s->zvel < 512) s->zvel += (gc/3); // 52; + if (s->zvel < 512) s->zvel += (SpriteGravity/3); // 52; if (s->xvel > 0) s->xvel --; // else KILLIT(i); @@ -5203,14 +5222,14 @@ static void moveexplosions(void) // STATNUM 5 // case GLASSPIECES+1: // case GLASSPIECES+2: - makeitfall(i); + A_Fall(i); if (s->zvel > 4096) s->zvel = 4096; if (sect < 0) KILLIT(i); - if (s->z == hittype[i].floorz-(FOURSLEIGHT) && t[0] < 3) + if (s->z == ActorExtra[i].floorz-(FOURSLEIGHT) && t[0] < 3) { - s->zvel = -((3-t[0])<<8)-(TRAND&511); + s->zvel = -((3-t[0])<<8)-(krand()&511); if (sector[sect].lotag == 2) s->zvel >>= 1; s->xrepeat >>= 1; @@ -5228,7 +5247,7 @@ static void moveexplosions(void) // STATNUM 5 } else s->xvel = 0; - ssp(i,CLIPMASK0); + A_SetSprite(i,CLIPMASK0); goto BOLT; } @@ -5265,7 +5284,7 @@ static void moveexplosions(void) // STATNUM 5 else t[0]++; } } - if (s->zvel < 4096) s->zvel += gc-50; + if (s->zvel < 4096) s->zvel += SpriteGravity-50; s->x += (s->xvel*sintable[(s->ang+512)&2047])>>14; s->y += (s->xvel*sintable[s->ang&2047])>>14; s->z += s->zvel; @@ -5274,9 +5293,9 @@ static void moveexplosions(void) // STATNUM 5 { if (s->picnum == SCRAP1 && s->yvel > 0) { - j = spawn(i,s->yvel); + j = A_Spawn(i,s->yvel); setsprite(j,s->x,s->y,s->z); - getglobalz(j); + A_GetZLimits(j); sprite[j].hitag = sprite[j].lotag = 0; } KILLIT(i); @@ -5289,11 +5308,11 @@ BOLT: } } -static void moveeffectors(void) //STATNUM 3 +static void G_MoveEffectors(void) //STATNUM 3 { int q=0, m, x, st, j; intptr_t *t,l; - int i = headspritestat[3], nexti, nextk, p, sh, nextj; + int i = headspritestat[STAT_EFFECTOR], nexti, nextk, p, sh, nextj; short k; spritetype *s; sectortype *sc; @@ -5310,7 +5329,7 @@ static void moveeffectors(void) //STATNUM 3 st = s->lotag; sh = s->hitag; - t = &hittype[i].temp_data[0]; + t = &ActorExtra[i].temp_data[0]; switch (st) { @@ -5334,15 +5353,15 @@ static void moveeffectors(void) //STATNUM 3 if (sprite[i].extra == 1) { - if (hittype[i].tempang < 256) + if (ActorExtra[i].tempang < 256) { - hittype[i].tempang += 4; - if (hittype[i].tempang >= 256) - callsound(s->sectnum,i); + ActorExtra[i].tempang += 4; + if (ActorExtra[i].tempang >= 256) + A_CallSound(s->sectnum,i); if (s->clipdist) l = 1; else l = -1; } - else hittype[i].tempang = 256; + else ActorExtra[i].tempang = 256; if (sc->floorz > s->z) //z's are touching { @@ -5362,15 +5381,15 @@ static void moveeffectors(void) //STATNUM 3 } else if (sprite[i].extra == 3) { - if (hittype[i].tempang > 0) + if (ActorExtra[i].tempang > 0) { - hittype[i].tempang -= 4; - if (hittype[i].tempang <= 0) - callsound(s->sectnum,i); + ActorExtra[i].tempang -= 4; + if (ActorExtra[i].tempang <= 0) + A_CallSound(s->sectnum,i); if (s->clipdist) l = -1; else l = 1; } - else hittype[i].tempang = 0; + else ActorExtra[i].tempang = 0; if (sc->floorz > T4) //z's are touching { @@ -5394,8 +5413,8 @@ static void moveeffectors(void) //STATNUM 3 } else { - if (hittype[j].temp_data[0] == 0) break; - if (hittype[j].temp_data[0] == 2) KILLIT(i); + if (ActorExtra[j].temp_data[0] == 0) break; + if (ActorExtra[j].temp_data[0] == 2) KILLIT(i); if (sprite[j].ang > 1024) l = -1; @@ -5411,7 +5430,7 @@ static void moveeffectors(void) //STATNUM 3 if (l && (sc->floorstat&64)) { - for (p=connecthead;p>=0;p=connectpoint2[p]) + TRAVERSE_CONNECT(p) { if (g_player[p].ps->cursectnum == s->sectnum && g_player[p].ps->on_ground == 1) { @@ -5470,7 +5489,7 @@ static void moveeffectors(void) //STATNUM 3 { s->owner = i; - j = headspritestat[3]; + j = headspritestat[STAT_EFFECTOR]; while (j >= 0) { if (sprite[j].lotag == 19 && sprite[j].hitag == sh) @@ -5503,22 +5522,22 @@ static void moveeffectors(void) //STATNUM 3 } else s->xvel = k; - j = headspritestat[3]; + j = headspritestat[STAT_EFFECTOR]; while (j >= 0) { - if ((sprite[j].lotag == 14) && (sh == sprite[j].hitag) && (hittype[j].temp_data[0] == t[0])) + if ((sprite[j].lotag == 14) && (sh == sprite[j].hitag) && (ActorExtra[j].temp_data[0] == t[0])) { sprite[j].xvel = s->xvel; // if( t[4] == 1 ) { - if (hittype[j].temp_data[5] == 0) - hittype[j].temp_data[5] = dist(&sprite[j],s); - x = ksgn(dist(&sprite[j],s)-hittype[j].temp_data[5]); + if (ActorExtra[j].temp_data[5] == 0) + ActorExtra[j].temp_data[5] = dist(&sprite[j],s); + x = ksgn(dist(&sprite[j],s)-ActorExtra[j].temp_data[5]); if (sprite[j].extra) x = -x; s->xvel += x; } - hittype[j].temp_data[4] = t[4]; + ActorExtra[j].temp_data[4] = t[4]; } j = nextspritestat[j]; } @@ -5527,12 +5546,12 @@ static void moveeffectors(void) //STATNUM 3 case 14: if (s->owner==-1) - s->owner = LocateTheLocator((short)t[3],(short)t[0]); + s->owner = A_FindLocator((short)t[3],(short)t[0]); if (s->owner == -1) { Bsprintf(tempbuf,"Could not find any locators for SE# 6 and 14 with a hitag of %" PRIdPTR ".\n",t[3]); - gameexit(tempbuf); + G_GameExit(tempbuf); } j = ldist(&sprite[s->owner],s); @@ -5543,18 +5562,18 @@ static void moveeffectors(void) //STATNUM 3 if (sprite[s->owner].hitag&1) t[4]=sc->extra; //Slow it down t[3]++; - s->owner = LocateTheLocator(t[3],t[0]); + s->owner = A_FindLocator(t[3],t[0]); if (s->owner==-1) { t[3]=0; - s->owner = LocateTheLocator(0,t[0]); + s->owner = A_FindLocator(0,t[0]); } } if (s->xvel) { x = getangle(sprite[s->owner].x-s->x,sprite[s->owner].y-s->y); - q = getincangle(s->ang,x)>>3; + q = G_GetAngleDelta(s->ang,x)>>3; t[2] += q; s->ang += q; @@ -5563,43 +5582,43 @@ static void moveeffectors(void) //STATNUM 3 { if ((sc->floorstat&1) == 0 && (sc->ceilingstat&1) == 0) { - if (!issoundplaying(i,hittype[i].lastvx)) - spritesound(hittype[i].lastvx,i); + if (!S_CheckSoundPlaying(i,ActorExtra[i].lastvx)) + A_PlaySound(ActorExtra[i].lastvx,i); } else if (ud.monsters_off == 0 && sc->floorpal == 0 && (sc->floorstat&1) && rnd(8)) { - p = findplayer(s,&x); + p = A_FindPlayer(s,&x); if (x < 20480) { j = s->ang; s->ang = getangle(s->x-g_player[p].ps->posx,s->y-g_player[p].ps->posy); - shoot(i,RPG); + A_Shoot(i,RPG); s->ang = j; } } } if (s->xvel <= 64 && (sc->floorstat&1) == 0 && (sc->ceilingstat&1) == 0) - stopspritesound(hittype[i].lastvx,i); + A_StopSound(ActorExtra[i].lastvx,i); if ((sc->floorz-sc->ceilingz) < (108<<8)) { if (ud.clipping == 0 && s->xvel >= 192) - for (p=connecthead;p>=0;p=connectpoint2[p]) - if (sprite[g_player[p].ps->i].extra > 0) + TRAVERSE_CONNECT(p) + if (sprite[g_player[p].ps->i].extra > 0) + { + k = g_player[p].ps->cursectnum; + updatesector(g_player[p].ps->posx,g_player[p].ps->posy,&k); + if ((k == -1 && ud.clipping == 0) || (k == s->sectnum && g_player[p].ps->cursectnum != s->sectnum)) { - k = g_player[p].ps->cursectnum; - updatesector(g_player[p].ps->posx,g_player[p].ps->posy,&k); - if ((k == -1 && ud.clipping == 0) || (k == s->sectnum && g_player[p].ps->cursectnum != s->sectnum)) - { - g_player[p].ps->posx = s->x; - g_player[p].ps->posy = s->y; - g_player[p].ps->cursectnum = s->sectnum; + g_player[p].ps->posx = s->x; + g_player[p].ps->posy = s->y; + g_player[p].ps->cursectnum = s->sectnum; - setsprite(g_player[p].ps->i,s->x,s->y,s->z); - quickkill(g_player[p].ps); - } + setsprite(g_player[p].ps->i,s->x,s->y,s->z); + P_QuickKill(g_player[p].ps); } + } } m = (s->xvel*sintable[(s->ang+512)&2047])>>14; @@ -5608,10 +5627,10 @@ static void moveeffectors(void) //STATNUM 3 for (p = connecthead;p >= 0;p=connectpoint2[p]) if (sector[g_player[p].ps->cursectnum].lotag != 2) { - if (g_PlayerSpawnPoints[p].os == s->sectnum) + if (g_playerSpawnPoints[p].os == s->sectnum) { - g_PlayerSpawnPoints[p].ox += m; - g_PlayerSpawnPoints[p].oy += x; + g_playerSpawnPoints[p].ox += m; + g_playerSpawnPoints[p].oy += x; } if (s->sectnum == sprite[g_player[p].ps->i].sectnum) @@ -5652,8 +5671,8 @@ static void moveeffectors(void) //STATNUM 3 if (numplayers > 1) { - hittype[j].bposx = sprite[j].x; - hittype[j].bposy = sprite[j].y; + ActorExtra[j].bposx = sprite[j].x; + ActorExtra[j].bposy = sprite[j].y; } } j = nextspritesect[j]; @@ -5665,34 +5684,34 @@ static void moveeffectors(void) //STATNUM 3 if ((sc->floorz-sc->ceilingz) < (108<<8)) { if (ud.clipping == 0 && s->xvel >= 192) - for (p=connecthead;p>=0;p=connectpoint2[p]) - if (sprite[g_player[p].ps->i].extra > 0) + TRAVERSE_CONNECT(p) + if (sprite[g_player[p].ps->i].extra > 0) + { + k = g_player[p].ps->cursectnum; + updatesector(g_player[p].ps->posx,g_player[p].ps->posy,&k); + if ((k == -1 && ud.clipping == 0) || (k == s->sectnum && g_player[p].ps->cursectnum != s->sectnum)) { - k = g_player[p].ps->cursectnum; - updatesector(g_player[p].ps->posx,g_player[p].ps->posy,&k); - if ((k == -1 && ud.clipping == 0) || (k == s->sectnum && g_player[p].ps->cursectnum != s->sectnum)) - { - g_player[p].ps->oposx = g_player[p].ps->posx = s->x; - g_player[p].ps->oposy = g_player[p].ps->posy = s->y; - g_player[p].ps->cursectnum = s->sectnum; + g_player[p].ps->oposx = g_player[p].ps->posx = s->x; + g_player[p].ps->oposy = g_player[p].ps->posy = s->y; + g_player[p].ps->cursectnum = s->sectnum; - setsprite(g_player[p].ps->i,s->x,s->y,s->z); - quickkill(g_player[p].ps); - } + setsprite(g_player[p].ps->i,s->x,s->y,s->z); + P_QuickKill(g_player[p].ps); } + } j = headspritesect[sprite[OW].sectnum]; while (j >= 0) { l = nextspritesect[j]; - if (sprite[j].statnum == 1 && badguy(&sprite[j]) && sprite[j].picnum != SECTOREFFECTOR && sprite[j].picnum != LOCATORS) + if (sprite[j].statnum == 1 && A_CheckEnemySprite(&sprite[j]) && sprite[j].picnum != SECTOREFFECTOR && sprite[j].picnum != LOCATORS) { k = sprite[j].sectnum; updatesector(sprite[j].x,sprite[j].y,&k); if (sprite[j].extra >= 0 && k == s->sectnum) { - gutsdir(j,JIBS6,72); - spritesound(SQUISHED,i); + A_DoGutsDir(j,JIBS6,72); + A_PlaySound(SQUISHED,i); deletesprite(j); } } @@ -5707,7 +5726,7 @@ static void moveeffectors(void) //STATNUM 3 if (s->owner == -1) { t[3] = !t[3]; - s->owner = LocateTheLocator(t[3],t[0]); + s->owner = A_FindLocator(t[3],t[0]); } else { @@ -5719,7 +5738,7 @@ static void moveeffectors(void) //STATNUM 3 else { if (s->xvel == 0) - operateactivators(s->hitag+(!t[3]),-1); + G_OperateActivators(s->hitag+(!t[3]),-1); if (s->xvel < 256) s->xvel += 16; } @@ -5736,19 +5755,19 @@ static void moveeffectors(void) //STATNUM 3 else { s->xvel = 0; - operateactivators(s->hitag+(short)t[3],-1); + G_OperateActivators(s->hitag+(short)t[3],-1); s->owner = -1; s->ang += 1024; t[4] = 0; - operateforcefields(i,s->hitag); + G_OperateForceFields(i,s->hitag); j = headspritesect[s->sectnum]; while (j >= 0) { if (sprite[j].picnum != SECTOREFFECTOR && sprite[j].picnum != LOCATORS) { - hittype[j].bposx = sprite[j].x; - hittype[j].bposy = sprite[j].y; + ActorExtra[j].bposx = sprite[j].x; + ActorExtra[j].bposy = sprite[j].y; } j = nextspritesect[j]; } @@ -5764,21 +5783,21 @@ static void moveeffectors(void) //STATNUM 3 if ((sc->floorz-sc->ceilingz) < (108<<8)) if (ud.clipping == 0) - for (p=connecthead;p>=0;p=connectpoint2[p]) - if (sprite[g_player[p].ps->i].extra > 0) + TRAVERSE_CONNECT(p) + if (sprite[g_player[p].ps->i].extra > 0) + { + k = g_player[p].ps->cursectnum; + updatesector(g_player[p].ps->posx,g_player[p].ps->posy,&k); + if ((k == -1 && ud.clipping == 0) || (k == s->sectnum && g_player[p].ps->cursectnum != s->sectnum)) { - k = g_player[p].ps->cursectnum; - updatesector(g_player[p].ps->posx,g_player[p].ps->posy,&k); - if ((k == -1 && ud.clipping == 0) || (k == s->sectnum && g_player[p].ps->cursectnum != s->sectnum)) - { - g_player[p].ps->posx = s->x; - g_player[p].ps->posy = s->y; - g_player[p].ps->cursectnum = s->sectnum; + g_player[p].ps->posx = s->x; + g_player[p].ps->posy = s->y; + g_player[p].ps->cursectnum = s->sectnum; - setsprite(g_player[p].ps->i,s->x,s->y,s->z); - quickkill(g_player[p].ps); - } + setsprite(g_player[p].ps->i,s->x,s->y,s->z); + P_QuickKill(g_player[p].ps); } + } for (p = connecthead;p >= 0;p = connectpoint2[p]) { @@ -5797,10 +5816,10 @@ static void moveeffectors(void) //STATNUM 3 g_player[p].ps->bobposy += x; } - if (g_PlayerSpawnPoints[p].os == s->sectnum) + if (g_playerSpawnPoints[p].os == s->sectnum) { - g_PlayerSpawnPoints[p].ox += l; - g_PlayerSpawnPoints[p].oy += x; + g_playerSpawnPoints[p].ox += l; + g_playerSpawnPoints[p].oy += x; } } @@ -5811,8 +5830,8 @@ static void moveeffectors(void) //STATNUM 3 { if (numplayers < 2) { - hittype[j].bposx = sprite[j].x; - hittype[j].bposy = sprite[j].y; + ActorExtra[j].bposx = sprite[j].x; + ActorExtra[j].bposy = sprite[j].y; } sprite[j].x += l; @@ -5820,8 +5839,8 @@ static void moveeffectors(void) //STATNUM 3 if (numplayers > 1) { - hittype[j].bposx = sprite[j].x; - hittype[j].bposy = sprite[j].y; + ActorExtra[j].bposx = sprite[j].x; + ActorExtra[j].bposy = sprite[j].y; } } j = nextspritesect[j]; @@ -5833,31 +5852,31 @@ static void moveeffectors(void) //STATNUM 3 if ((sc->floorz-sc->ceilingz) < (108<<8)) { if (ud.clipping == 0) - for (p=connecthead;p>=0;p=connectpoint2[p]) - if (sprite[g_player[p].ps->i].extra > 0) + TRAVERSE_CONNECT(p) + if (sprite[g_player[p].ps->i].extra > 0) + { + k = g_player[p].ps->cursectnum; + updatesector(g_player[p].ps->posx,g_player[p].ps->posy,&k); + if ((k == -1 && ud.clipping == 0) || (k == s->sectnum && g_player[p].ps->cursectnum != s->sectnum)) { - k = g_player[p].ps->cursectnum; - updatesector(g_player[p].ps->posx,g_player[p].ps->posy,&k); - if ((k == -1 && ud.clipping == 0) || (k == s->sectnum && g_player[p].ps->cursectnum != s->sectnum)) - { - g_player[p].ps->posx = s->x; - g_player[p].ps->posy = s->y; + g_player[p].ps->posx = s->x; + g_player[p].ps->posy = s->y; - g_player[p].ps->oposx = g_player[p].ps->posx; - g_player[p].ps->oposy = g_player[p].ps->posy; + g_player[p].ps->oposx = g_player[p].ps->posx; + g_player[p].ps->oposy = g_player[p].ps->posy; - g_player[p].ps->cursectnum = s->sectnum; + g_player[p].ps->cursectnum = s->sectnum; - setsprite(g_player[p].ps->i,s->x,s->y,s->z); - quickkill(g_player[p].ps); - } + setsprite(g_player[p].ps->i,s->x,s->y,s->z); + P_QuickKill(g_player[p].ps); } + } j = headspritesect[sprite[OW].sectnum]; while (j >= 0) { l = nextspritesect[j]; - if (sprite[j].statnum == 1 && badguy(&sprite[j]) && sprite[j].picnum != SECTOREFFECTOR && sprite[j].picnum != LOCATORS) + if (sprite[j].statnum == 1 && A_CheckEnemySprite(&sprite[j]) && sprite[j].picnum != SECTOREFFECTOR && sprite[j].picnum != LOCATORS) { // if(sprite[j].sectnum != s->sectnum) { @@ -5865,8 +5884,8 @@ static void moveeffectors(void) //STATNUM 3 updatesector(sprite[j].x,sprite[j].y,&k); if (sprite[j].extra >= 0 && k == s->sectnum) { - gutsdir(j,JIBS6,24); - spritesound(SQUISHED,j); + A_DoGutsDir(j,JIBS6,24); + A_PlaySound(SQUISHED,j); deletesprite(j); } } @@ -5904,8 +5923,8 @@ static void moveeffectors(void) //STATNUM 3 { if ((t[0]&31) == 8) { - earthquaketime = 48; - spritesound(EARTHQUAKE,g_player[screenpeek].ps->i); + g_earthquakeTime = 48; + A_PlaySound(EARTHQUAKE,g_player[screenpeek].ps->i); } if (klabs(sc->floorheinum-t[5]) < 8) @@ -5917,15 +5936,15 @@ static void moveeffectors(void) //STATNUM 3 x = (s->xvel*sintable[s->ang&2047])>>14; - for (p=connecthead;p>=0;p=connectpoint2[p]) - if (g_player[p].ps->cursectnum == s->sectnum && g_player[p].ps->on_ground) - { - g_player[p].ps->posx += m; - g_player[p].ps->posy += x; + TRAVERSE_CONNECT(p) + if (g_player[p].ps->cursectnum == s->sectnum && g_player[p].ps->on_ground) + { + g_player[p].ps->posx += m; + g_player[p].ps->posy += x; - g_player[p].ps->bobposx += m; - g_player[p].ps->bobposy += x; - } + g_player[p].ps->bobposx += m; + g_player[p].ps->bobposy += x; + } j = headspritesect[s->sectnum]; while (j >= 0) @@ -5950,20 +5969,20 @@ static void moveeffectors(void) //STATNUM 3 case 3: if (t[4] == 0) break; - p = findplayer(s,&x); + p = A_FindPlayer(s,&x); // if(t[5] > 0) { t[5]--; break; } - if ((global_random/(sh+1)&31) < 4 && !t[2]) + if ((g_globalRandom/(sh+1)&31) < 4 && !t[2]) { - // t[5] = 4+(global_random&7); + // t[5] = 4+(g_globalRandom&7); sc->ceilingpal = s->owner>>8; sc->floorpal = s->owner&0xff; - t[0] = s->shade + (global_random&15); + t[0] = s->shade + (g_globalRandom&15); } else { - // t[5] = 4+(global_random&3); + // t[5] = 4+(g_globalRandom&3); sc->ceilingpal = s->pal; sc->floorpal = s->pal; t[0] = t[3]; @@ -5990,10 +6009,10 @@ static void moveeffectors(void) //STATNUM 3 case 4: - if ((global_random/(sh+1)&31) < 4) + if ((g_globalRandom/(sh+1)&31) < 4) { - t[1] = s->shade + (global_random&15);//Got really bright - t[0] = s->shade + (global_random&15); + t[1] = s->shade + (g_globalRandom&15);//Got really bright + t[0] = s->shade + (g_globalRandom&15); sc->ceilingpal = s->owner>>8; sc->floorpal = s->owner&0xff; j = 1; @@ -6030,7 +6049,7 @@ static void moveeffectors(void) //STATNUM 3 j = headspritesect[SECT]; while (j >= 0) { - if (sprite[j].cstat&16 && checkspriteflags(j,SPRITE_FLAG_NOSHADE) == 0) + if (sprite[j].cstat&16 && A_CheckSpriteFlags(j,SPRITE_NOSHADE) == 0) { if (sc->ceilingstat&1) sprite[j].shade = sc->ceilingshade; @@ -6046,12 +6065,12 @@ static void moveeffectors(void) //STATNUM 3 //BOSS case 5: - p = findplayer(s,&x); + p = A_FindPlayer(s,&x); if (x < 8192) { j = s->ang; s->ang = getangle(s->x-g_player[p].ps->posx,s->y-g_player[p].ps->posy); - shoot(i,FIRELASER); + A_Shoot(i,FIRELASER); s->ang = j; } @@ -6061,7 +6080,7 @@ static void moveeffectors(void) //STATNUM 3 l = 0x7fffffff; while (1) //Find the shortest dist { - s->owner = LocateTheLocator((short)t[4],-1); //t[0] hold sectnum + s->owner = A_FindLocator((short)t[4],-1); //t[0] hold sectnum if (s->owner==-1) break; @@ -6093,7 +6112,7 @@ static void moveeffectors(void) //STATNUM 3 else s->xvel=256; x = getangle(sprite[s->owner].x-s->x,sprite[s->owner].y-s->y); - q = getincangle(s->ang,x)>>3; + q = G_GetAngleDelta(s->ang,x)>>3; s->ang += q; if (rnd(32)) @@ -6104,7 +6123,7 @@ static void moveeffectors(void) //STATNUM 3 else { t[2] += - getincangle(t[2]+512,getangle(g_player[p].ps->posx-s->x,g_player[p].ps->posy-s->y))>>2; + G_GetAngleDelta(t[2]+512,getangle(g_player[p].ps->posx-s->x,g_player[p].ps->posy-s->y))>>2; sc->ceilingshade = 0; } IFHIT @@ -6113,7 +6132,7 @@ static void moveeffectors(void) //STATNUM 3 if (t[3] == 5) { s->zvel += 1024; - FTA(7,g_player[myconnectindex].ps); + P_DoQuote(7,g_player[myconnectindex].ps); } } @@ -6132,26 +6151,26 @@ static void moveeffectors(void) //STATNUM 3 j = -1; - if (hittype[i].temp_data[4]) + if (ActorExtra[i].temp_data[4]) { - hittype[i].temp_data[4]++; - if (hittype[i].temp_data[4] > 8) KILLIT(i); + ActorExtra[i].temp_data[4]++; + if (ActorExtra[i].temp_data[4] > 8) KILLIT(i); j = 1; } - else j = getanimationgoal(&sc->ceilingz); + else j = GetAnimationGoal(&sc->ceilingz); if (j >= 0) { short sn; - if ((sc->lotag&0x8000) || hittype[i].temp_data[4]) + if ((sc->lotag&0x8000) || ActorExtra[i].temp_data[4]) x = -t[3]; else x = t[3]; if (st == 9) x = -x; - j = headspritestat[3]; + j = headspritestat[STAT_EFFECTOR]; while (j >= 0) { if (((sprite[j].lotag) == st) && (sprite[j].hitag) == sh) @@ -6169,8 +6188,8 @@ static void moveeffectors(void) //STATNUM 3 if (wal->shade < m) wal->shade = m; - else if (wal->shade > hittype[j].temp_data[2]) - wal->shade = hittype[j].temp_data[2]; + else if (wal->shade > ActorExtra[j].temp_data[2]) + wal->shade = ActorExtra[j].temp_data[2]; if (wal->nextwall >= 0) if (wall[wal->nextwall].hitag != 1) @@ -6183,13 +6202,13 @@ static void moveeffectors(void) //STATNUM 3 if (sector[sn].floorshade < m) sector[sn].floorshade = m; - else if (sector[sn].floorshade > hittype[j].temp_data[0]) - sector[sn].floorshade = hittype[j].temp_data[0]; + else if (sector[sn].floorshade > ActorExtra[j].temp_data[0]) + sector[sn].floorshade = ActorExtra[j].temp_data[0]; if (sector[sn].ceilingshade < m) sector[sn].ceilingshade = m; - else if (sector[sn].ceilingshade > hittype[j].temp_data[1]) - sector[sn].ceilingshade = hittype[j].temp_data[1]; + else if (sector[sn].ceilingshade > ActorExtra[j].temp_data[1]) + sector[sn].ceilingshade = ActorExtra[j].temp_data[1]; } j = nextspritestat[j]; @@ -6203,10 +6222,10 @@ static void moveeffectors(void) //STATNUM 3 j = 1; if ((sc->lotag&0xff) != 27) - for (p=connecthead;p>=0;p=connectpoint2[p]) - if (sc->lotag != 30 && sc->lotag != 31 && sc->lotag != 0) - if (s->sectnum == sprite[g_player[p].ps->i].sectnum) - j = 0; + TRAVERSE_CONNECT(p) + if (sc->lotag != 30 && sc->lotag != 31 && sc->lotag != 0) + if (s->sectnum == sprite[g_player[p].ps->i].sectnum) + j = 0; if (j == 1) { @@ -6217,7 +6236,7 @@ static void moveeffectors(void) //STATNUM 3 case 21: case 22: case 26: - if (getanimationgoal(§or[s->sectnum].ceilingz) >= 0) + if (GetAnimationGoal(§or[s->sectnum].ceilingz) >= 0) break; default: activatebysector(s->sectnum,i); @@ -6243,15 +6262,15 @@ static void moveeffectors(void) //STATNUM 3 for (j=sc->wallptr;j= 0) { - if (sprite[k].extra > 0 && badguy(&sprite[k]) && clipinsidebox(sprite[k].x,sprite[k].y,j,256L) == 1) + if (sprite[k].extra > 0 && A_CheckEnemySprite(&sprite[k]) && clipinsidebox(sprite[k].x,sprite[k].y,j,256L) == 1) goto BOLT; k = nextspritestat[k]; } - k = headspritestat[10]; + k = headspritestat[STAT_PLAYER]; while (k >= 0) { if (sprite[k].owner >= 0 && clipinsidebox(sprite[k].x,sprite[k].y,j,144L) == 1) @@ -6305,7 +6324,7 @@ static void moveeffectors(void) //STATNUM 3 j = headspritesect[SECT]; while (j >= 0) { - if (sprite[j].cstat&16 && checkspriteflags(j,SPRITE_FLAG_NOSHADE) == 0) + if (sprite[j].cstat&16 && A_CheckSpriteFlags(j,SPRITE_NOSHADE) == 0) { if (sc->ceilingstat&1) sprite[j].shade = sc->ceilingshade; @@ -6342,7 +6361,7 @@ static void moveeffectors(void) //STATNUM 3 { if (sprite[j].cstat&16) { - if (sc->ceilingstat&1 && checkspriteflags(j,SPRITE_FLAG_NOSHADE) == 0) + if (sc->ceilingstat&1 && A_CheckSpriteFlags(j,SPRITE_NOSHADE) == 0) sprite[j].shade = sc->ceilingshade; else sprite[j].shade = sc->floorshade; } @@ -6428,7 +6447,7 @@ static void moveeffectors(void) //STATNUM 3 if (t[3] >= (SP>>3)) { t[4] = 0; //Turn off the sliders - callsound(s->sectnum,i); + A_CallSound(s->sectnum,i); break; } t[3]++; @@ -6438,7 +6457,7 @@ static void moveeffectors(void) //STATNUM 3 if (t[3]<1) { t[4] = 0; - callsound(s->sectnum,i); + A_CallSound(s->sectnum,i); break; } t[3]--; @@ -6507,12 +6526,12 @@ static void moveeffectors(void) //STATNUM 3 } if (sprite[j].statnum != 3) { - hittype[j].bposz = sprite[j].z; + ActorExtra[j].bposz = sprite[j].z; sprite[j].z += q; } - hittype[j].floorz = sc->floorz; - hittype[j].ceilingz = sc->ceilingz; + ActorExtra[j].floorz = sc->floorz; + ActorExtra[j].ceilingz = sc->ceilingz; j = nextspritesect[j]; } @@ -6521,7 +6540,7 @@ static void moveeffectors(void) //STATNUM 3 { if (klabs(sc->floorz-t[2]) <= SP) { - activatewarpelevators(i,0); + G_ActivateWarpElevators(i,0); break; } @@ -6535,7 +6554,7 @@ static void moveeffectors(void) //STATNUM 3 if (t[1] == 0) break; t[1] = 0; - j = headspritestat[3]; + j = headspritestat[STAT_EFFECTOR]; while (j >= 0) { if (i != j && (sprite[j].lotag) == 17) @@ -6561,15 +6580,15 @@ static void moveeffectors(void) //STATNUM 3 g_player[p].ps->posy += sprite[j].y-s->y; g_player[p].ps->posz = sector[sprite[j].sectnum].floorz-(sc->floorz-g_player[p].ps->posz); - hittype[k].floorz = sector[sprite[j].sectnum].floorz; - hittype[k].ceilingz = sector[sprite[j].sectnum].ceilingz; + ActorExtra[k].floorz = sector[sprite[j].sectnum].floorz; + ActorExtra[k].ceilingz = sector[sprite[j].sectnum].ceilingz; g_player[p].ps->bobposx = g_player[p].ps->oposx = g_player[p].ps->posx; g_player[p].ps->bobposy = g_player[p].ps->oposy = g_player[p].ps->posy; g_player[p].ps->oposz = g_player[p].ps->posz; - g_player[p].ps->truefz = hittype[k].floorz; - g_player[p].ps->truecz = hittype[k].ceilingz; + g_player[p].ps->truefz = ActorExtra[k].floorz; + g_player[p].ps->truecz = ActorExtra[k].ceilingz; g_player[p].ps->bobcounter = 0; changespritesect(k,sprite[j].sectnum); @@ -6584,15 +6603,15 @@ static void moveeffectors(void) //STATNUM 3 sprite[k].z = sector[sprite[j].sectnum].floorz- (sc->floorz-sprite[k].z); - hittype[k].bposx = sprite[k].x; - hittype[k].bposy = sprite[k].y; - hittype[k].bposz = sprite[k].z; + ActorExtra[k].bposx = sprite[k].x; + ActorExtra[k].bposy = sprite[k].y; + ActorExtra[k].bposz = sprite[k].z; changespritesect(k,sprite[j].sectnum); setsprite(k,sprite[k].x,sprite[k].y,sprite[k].z); - hittype[k].floorz = sector[sprite[j].sectnum].floorz; - hittype[k].ceilingz = sector[sprite[j].sectnum].ceilingz; + ActorExtra[k].floorz = sector[sprite[j].sectnum].floorz; + ActorExtra[k].ceilingz = sector[sprite[j].sectnum].ceilingz; } k = nextk; @@ -6625,8 +6644,8 @@ static void moveeffectors(void) //STATNUM 3 g_player[sprite[j].yvel].ps->posz += sc->extra; if (sprite[j].zvel == 0 && sprite[j].statnum != 3 && sprite[j].statnum != 4) { - hittype[j].bposz = sprite[j].z += sc->extra; - hittype[j].floorz = sc->floorz; + ActorExtra[j].bposz = sprite[j].z += sc->extra; + ActorExtra[j].floorz = sc->floorz; } j = nextspritesect[j]; } @@ -6659,8 +6678,8 @@ static void moveeffectors(void) //STATNUM 3 g_player[sprite[j].yvel].ps->posz -= sc->extra; if (sprite[j].zvel == 0 && sprite[j].statnum != 3 && sprite[j].statnum != 4) { - hittype[j].bposz = sprite[j].z -= sc->extra; - hittype[j].floorz = sc->floorz; + ActorExtra[j].bposz = sprite[j].z -= sc->extra; + ActorExtra[j].floorz = sc->floorz; } j = nextspritesect[j]; } @@ -6709,7 +6728,7 @@ static void moveeffectors(void) //STATNUM 3 { sc->ceilingz = sc->floorz; - j = headspritestat[3]; + j = headspritestat[STAT_EFFECTOR]; while (j >= 0) { if (sprite[j].lotag == 0 && sprite[j].hitag==sh) @@ -6720,7 +6739,7 @@ static void moveeffectors(void) //STATNUM 3 sector[sprite[j].sectnum].floorshade = sector[sprite[j].sectnum].ceilingshade = sector[q].floorshade; - hittype[sprite[j].owner].temp_data[0] = 2; + ActorExtra[sprite[j].owner].temp_data[0] = 2; } j = nextspritestat[j]; } @@ -6731,9 +6750,9 @@ static void moveeffectors(void) //STATNUM 3 { IFHITSECT { - FTA(8,g_player[myconnectindex].ps); + P_DoQuote(8,g_player[myconnectindex].ps); - l = headspritestat[3]; + l = headspritestat[STAT_EFFECTOR]; while (l >= 0) { x = sprite[l].lotag&0x7fff; @@ -6758,9 +6777,9 @@ static void moveeffectors(void) //STATNUM 3 case 19: if (sh == sprite[l].hitag) - if (hittype[l].temp_data[0] == 0) + if (ActorExtra[l].temp_data[0] == 0) { - hittype[l].temp_data[0] = 1; //Shut them all on + ActorExtra[l].temp_data[0] = 1; //Shut them all on sprite[l].owner = i; } @@ -6794,7 +6813,7 @@ static void moveeffectors(void) //STATNUM 3 s->x -= x; s->y -= l; t[0] = 0; - callsound(s->sectnum,i); + A_CallSound(s->sectnum,i); break; } @@ -6810,7 +6829,7 @@ static void moveeffectors(void) //STATNUM 3 setsprite(j,sprite[j].x,sprite[j].y,sprite[j].z); if (sector[sprite[j].sectnum].floorstat&2) if (sprite[j].statnum == 2) - makeitfall(j); + A_Fall(j); } j = nextj; } @@ -6818,17 +6837,17 @@ static void moveeffectors(void) //STATNUM 3 dragpoint((short)t[1],wall[t[1]].x+x,wall[t[1]].y+l); dragpoint((short)t[2],wall[t[2]].x+x,wall[t[2]].y+l); - for (p=connecthead;p>=0;p=connectpoint2[p]) - if (g_player[p].ps->cursectnum == s->sectnum && g_player[p].ps->on_ground) - { - g_player[p].ps->posx += x; - g_player[p].ps->posy += l; + TRAVERSE_CONNECT(p) + if (g_player[p].ps->cursectnum == s->sectnum && g_player[p].ps->on_ground) + { + g_player[p].ps->posx += x; + g_player[p].ps->posy += l; - g_player[p].ps->oposx = g_player[p].ps->posx; - g_player[p].ps->oposy = g_player[p].ps->posy; + g_player[p].ps->oposx = g_player[p].ps->posx; + g_player[p].ps->oposy = g_player[p].ps->posy; - setsprite(g_player[p].ps->i,g_player[p].ps->posx,g_player[p].ps->posy,g_player[p].ps->posz+PHEIGHT); - } + setsprite(g_player[p].ps->i,g_player[p].ps->posx,g_player[p].ps->posy,g_player[p].ps->posz+PHEIGHT); + } sc->floorxpanning-=x>>3; sc->floorypanning-=l>>3; @@ -6871,7 +6890,7 @@ static void moveeffectors(void) //STATNUM 3 if (t[1]) { - if (getanimationgoal(§or[t[0]].ceilingz) >= 0) + if (GetAnimationGoal(§or[t[0]].ceilingz) >= 0) sc->ceilingz += sc->extra*9; else t[1] = 0; } @@ -6895,7 +6914,7 @@ static void moveeffectors(void) //STATNUM 3 switch (sprite[j].statnum) { case 5: - switch (dynamictostatic[sprite[j].picnum]) + switch (DynamicTileMap[sprite[j].picnum]) { case BLOODPOOL__STATIC: case PUKE__STATIC: @@ -6928,16 +6947,16 @@ static void moveeffectors(void) //STATNUM 3 sprite[j].picnum == SIDEBOLT1+1 || sprite[j].picnum == SIDEBOLT1+2 || sprite[j].picnum == SIDEBOLT1+3 || - wallswitchcheck(j) + A_CheckSwitchTile(j) ) break; if (!(sprite[j].picnum >= CRANE && sprite[j].picnum <= (CRANE+3))) { - if (sprite[j].z > (hittype[j].floorz-(16<<8))) + if (sprite[j].z > (ActorExtra[j].floorz-(16<<8))) { - hittype[j].bposx = sprite[j].x; - hittype[j].bposy = sprite[j].y; + ActorExtra[j].bposx = sprite[j].x; + ActorExtra[j].bposy = sprite[j].y; sprite[j].x += x>>2; sprite[j].y += l>>2; @@ -6946,7 +6965,7 @@ static void moveeffectors(void) //STATNUM 3 if (sector[sprite[j].sectnum].floorstat&2) if (sprite[j].statnum == 2) - makeitfall(j); + A_Fall(j); } } break; @@ -6970,13 +6989,13 @@ static void moveeffectors(void) //STATNUM 3 if (sc->ceilingz > s->z) for (j = 0;j < 8;j++) { - s->ang += TRAND&511; - k = spawn(i,SMALLSMOKE); - sprite[k].xvel = 96+(TRAND&127); - ssp(k,CLIPMASK0); + s->ang += krand()&511; + k = A_Spawn(i,SMALLSMOKE); + sprite[k].xvel = 96+(krand()&127); + A_SetSprite(k,CLIPMASK0); setsprite(k,sprite[k].x,sprite[k].y,sprite[k].z); if (rnd(16)) - spawn(i,EXPLOSION2); + A_Spawn(i,EXPLOSION2); } switch (t[0]) @@ -7046,8 +7065,8 @@ static void moveeffectors(void) //STATNUM 3 nextj = nextspritesect[j]; if (sprite[j].statnum != 3 && sprite[j].statnum != 10) { - hittype[j].bposx = sprite[j].x; - hittype[j].bposy = sprite[j].y; + ActorExtra[j].bposx = sprite[j].x; + ActorExtra[j].bposy = sprite[j].y; sprite[j].x += l; sprite[j].y += x; @@ -7079,9 +7098,9 @@ static void moveeffectors(void) //STATNUM 3 if (ud.recstat == 0 || !ud.democams) break; - hittype[i].tempang = s->ang; + ActorExtra[i].tempang = s->ang; - p = findplayer(s,&x); + p = A_FindPlayer(s,&x); if (sprite[g_player[p].ps->i].extra > 0 && myconnectindex == screenpeek) { if (t[0] < 0) @@ -7097,7 +7116,7 @@ static void moveeffectors(void) //STATNUM 3 { ud.camerasprite = i; t[0] = 999; - s->ang += getincangle(s->ang,getangle(g_player[p].ps->posx-s->x,g_player[p].ps->posy-s->y))>>3; + s->ang += G_GetAngleDelta(s->ang,getangle(g_player[p].ps->posx-s->x,g_player[p].ps->posy-s->y))>>3; SP = 100+((s->z-g_player[p].ps->posz)/257); } @@ -7134,11 +7153,11 @@ static void moveeffectors(void) //STATNUM 3 if (T1 == 0) { - p = findplayer(s,&x); + p = A_FindPlayer(s,&x); if (x > 15500) break; T1 = 1; - T2 = 64 + (TRAND&511); + T2 = 64 + (krand()&511); T3 = 0; } else @@ -7151,12 +7170,12 @@ static void moveeffectors(void) //STATNUM 3 break; } else if (T3 == (T2>>1)) - spritesound(THUNDER,i); + A_PlaySound(THUNDER,i); else if (T3 == (T2>>3)) - spritesound(LIGHTNING_SLAP,i); + A_PlaySound(LIGHTNING_SLAP,i); else if (T3 == (T2>>2)) { - j = headspritestat[0]; + j = headspritestat[STAT_DEFAULT]; while (j >= 0) { if (sprite[j].picnum == NATURALLIGHTNING && sprite[j].hitag == s->hitag) @@ -7178,7 +7197,7 @@ static void moveeffectors(void) //STATNUM 3 else if (j) g_player[screenpeek].ps->visibility = ud.const_visibility; - j = headspritestat[0]; + j = headspritestat[STAT_DEFAULT]; while (j >= 0) { if (sprite[j].picnum == NATURALLIGHTNING && sprite[j].hitag == s->hitag) @@ -7186,16 +7205,16 @@ static void moveeffectors(void) //STATNUM 3 if (rnd(32) && (T3&1)) { sprite[j].cstat &= 32767; - spawn(j,SMALLSMOKE); + A_Spawn(j,SMALLSMOKE); - p = findplayer(s,&x); + p = A_FindPlayer(s,&x); x = ldist(&sprite[g_player[p].ps->i], &sprite[j]); if (x < 768) { - if (!isspritemakingsound(g_player[p].ps->i,DUKE_LONGTERM_PAIN)) - spritesound(DUKE_LONGTERM_PAIN,g_player[p].ps->i); - spritesound(SHORT_CIRCUIT,g_player[p].ps->i); - sprite[g_player[p].ps->i].extra -= 8+(TRAND&7); + if (!A_CheckSoundPlaying(g_player[p].ps->i,DUKE_LONGTERM_PAIN)) + A_PlaySound(DUKE_LONGTERM_PAIN,g_player[p].ps->i); + A_PlaySound(SHORT_CIRCUIT,g_player[p].ps->i); + sprite[g_player[p].ps->i].extra -= 8+(krand()&7); g_player[p].ps->pals_time = 32; g_player[p].ps->pals[0] = 16; g_player[p].ps->pals[1] = 0; @@ -7237,7 +7256,7 @@ static void moveeffectors(void) //STATNUM 3 t[2] = 0; t[0] = 0; t[3] = s->hitag; - callsound(s->sectnum,i); + A_CallSound(s->sectnum,i); } else { @@ -7252,8 +7271,8 @@ static void moveeffectors(void) //STATNUM 3 g_player[sprite[j].yvel].ps->posz += l; if (sprite[j].zvel == 0 && sprite[j].statnum != 3 && sprite[j].statnum != 4) { - hittype[j].bposz = sprite[j].z += l; - hittype[j].floorz = sc->floorz; + ActorExtra[j].bposz = sprite[j].z += l; + ActorExtra[j].floorz = sc->floorz; } j = nextspritesect[j]; } @@ -7264,7 +7283,7 @@ static void moveeffectors(void) //STATNUM 3 if (klabs(sc->floorz - t[1]) < SP) { sc->floorz = t[1]; - callsound(s->sectnum,i); + A_CallSound(s->sectnum,i); t[2] = 0; t[0] = 0; t[3] = s->hitag; @@ -7282,8 +7301,8 @@ static void moveeffectors(void) //STATNUM 3 g_player[sprite[j].yvel].ps->posz += l; if (sprite[j].zvel == 0 && sprite[j].statnum != 3 && sprite[j].statnum != 4) { - hittype[j].bposz = sprite[j].z += l; - hittype[j].floorz = sc->floorz; + ActorExtra[j].bposz = sprite[j].z += l; + ActorExtra[j].floorz = sc->floorz; } j = nextspritesect[j]; } @@ -7296,7 +7315,7 @@ static void moveeffectors(void) //STATNUM 3 { if (klabs(s->z-sc->floorz) < SP) { - callsound(s->sectnum,i); + A_CallSound(s->sectnum,i); t[0] = 0; t[2] = 1; t[3] = s->hitag; @@ -7314,8 +7333,8 @@ static void moveeffectors(void) //STATNUM 3 g_player[sprite[j].yvel].ps->posz += l; if (sprite[j].zvel == 0 && sprite[j].statnum != 3 && sprite[j].statnum != 4) { - hittype[j].bposz = sprite[j].z += l; - hittype[j].floorz = sc->floorz; + ActorExtra[j].bposz = sprite[j].z += l; + ActorExtra[j].floorz = sc->floorz; } j = nextspritesect[j]; } @@ -7326,7 +7345,7 @@ static void moveeffectors(void) //STATNUM 3 if (klabs(sc->floorz-t[1]) < SP) { t[0] = 0; - callsound(s->sectnum,i); + A_CallSound(s->sectnum,i); t[2] = 1; t[3] = s->hitag; } @@ -7343,8 +7362,8 @@ static void moveeffectors(void) //STATNUM 3 g_player[sprite[j].yvel].ps->posz -= l; if (sprite[j].zvel == 0 && sprite[j].statnum != 3 && sprite[j].statnum != 4) { - hittype[j].bposz = sprite[j].z -= l; - hittype[j].floorz = sc->floorz; + ActorExtra[j].bposz = sprite[j].z -= l; + ActorExtra[j].floorz = sc->floorz; } j = nextspritesect[j]; } @@ -7366,7 +7385,7 @@ static void moveeffectors(void) //STATNUM 3 (SP<<1)) { sc->ceilingz = s->z; - callsound(s->sectnum,i); + A_CallSound(s->sectnum,i); t[2] = 0; t[0] = 0; } @@ -7379,7 +7398,7 @@ static void moveeffectors(void) //STATNUM 3 (SP<<1)) { sc->ceilingz = t[1]; - callsound(s->sectnum,i); + A_CallSound(s->sectnum,i); t[2] = 0; t[0] = 0; } @@ -7396,7 +7415,7 @@ static void moveeffectors(void) //STATNUM 3 { t[0] = 0; t[2] = !t[2]; - callsound(s->sectnum,i); + A_CallSound(s->sectnum,i); sc->ceilingz = s->z; } else sc->ceilingz += @@ -7408,7 +7427,7 @@ static void moveeffectors(void) //STATNUM 3 { t[0] = 0; t[2] = !t[2]; - callsound(s->sectnum,i); + A_CallSound(s->sectnum,i); } else sc->ceilingz -= ksgn(s->z-t[1])*SP; } @@ -7416,7 +7435,7 @@ static void moveeffectors(void) //STATNUM 3 break; case 33: - if (earthquaketime > 0 && (TRAND&7) == 0) + if (g_earthquakeTime > 0 && (krand()&7) == 0) RANDOMSCRAP; break; case 36: @@ -7424,7 +7443,7 @@ static void moveeffectors(void) //STATNUM 3 if (t[0]) { if (t[0] == 1) - shoot(i,sc->extra); + A_Shoot(i,sc->extra); else if (t[0] == 26*5) t[0] = 0; t[0]++; @@ -7472,12 +7491,12 @@ static void moveeffectors(void) //STATNUM 3 if (rnd(64)) { - k = spawn(i,EXPLOSION2); - sprite[k].xrepeat = sprite[k].yrepeat = 2+(TRAND&7); - sprite[k].z = sc->floorz-(TRAND%x); - sprite[k].ang += 256-(TRAND%511); - sprite[k].xvel = TRAND&127; - ssp(k,CLIPMASK0); + k = A_Spawn(i,EXPLOSION2); + sprite[k].xrepeat = sprite[k].yrepeat = 2+(krand()&7); + sprite[k].z = sc->floorz-(krand()%x); + sprite[k].ang += 256-(krand()%511); + sprite[k].xvel = krand()&127; + A_SetSprite(k,CLIPMASK0); } break; case 131: @@ -7491,12 +7510,12 @@ static void moveeffectors(void) //STATNUM 3 if (rnd(32)) { - k = spawn(i,EXPLOSION2); - sprite[k].xrepeat = sprite[k].yrepeat = 2+(TRAND&3); - sprite[k].z = sc->floorz-(TRAND%x); - sprite[k].ang += 256-(TRAND%511); - sprite[k].xvel = TRAND&127; - ssp(k,CLIPMASK0); + k = A_Spawn(i,EXPLOSION2); + sprite[k].xrepeat = sprite[k].yrepeat = 2+(krand()&3); + sprite[k].z = sc->floorz-(krand()%x); + sprite[k].ang += 256-(krand()%511); + sprite[k].xvel = krand()&127; + A_SetSprite(k,CLIPMASK0); } break; } @@ -7505,7 +7524,7 @@ BOLT: } //Sloped sin-wave floors! - for (i=headspritestat[3];i>=0;i=nextspritestat[i]) + for (i=headspritestat[STAT_EFFECTOR];i>=0;i=nextspritestat[i]) { s = &sprite[i]; if (s->lotag != 29) continue; @@ -7516,20 +7535,216 @@ BOLT: } } -void moveobjects(void) +void A_PlayAlertSound(int i) { - movefta(); //ST 2 - moveweapons(); //ST 4 - movetransports(); //ST 9 + if (sprite[i].extra > 0) + switch (DynamicTileMap[PN]) + { + case LIZTROOPONTOILET__STATIC: + case LIZTROOPJUSTSIT__STATIC: + case LIZTROOPSHOOT__STATIC: + case LIZTROOPJETPACK__STATIC: + case LIZTROOPDUCKING__STATIC: + case LIZTROOPRUNNING__STATIC: + case LIZTROOP__STATIC: + A_PlaySound(PRED_RECOG,i); + break; + case LIZMAN__STATIC: + case LIZMANSPITTING__STATIC: + case LIZMANFEEDING__STATIC: + case LIZMANJUMP__STATIC: + A_PlaySound(CAPT_RECOG,i); + break; + case PIGCOP__STATIC: + case PIGCOPDIVE__STATIC: + A_PlaySound(PIG_RECOG,i); + break; + case RECON__STATIC: + A_PlaySound(RECO_RECOG,i); + break; + case DRONE__STATIC: + A_PlaySound(DRON_RECOG,i); + break; + case COMMANDER__STATIC: + case COMMANDERSTAYPUT__STATIC: + A_PlaySound(COMM_RECOG,i); + break; + case ORGANTIC__STATIC: + A_PlaySound(TURR_RECOG,i); + break; + case OCTABRAIN__STATIC: + case OCTABRAINSTAYPUT__STATIC: + A_PlaySound(OCTA_RECOG,i); + break; + case BOSS1__STATIC: + S_PlaySound(BOS1_RECOG); + break; + case BOSS2__STATIC: + if (sprite[i].pal == 1) + S_PlaySound(BOS2_RECOG); + else S_PlaySound(WHIPYOURASS); + break; + case BOSS3__STATIC: + if (sprite[i].pal == 1) + S_PlaySound(BOS3_RECOG); + else S_PlaySound(RIPHEADNECK); + break; + case BOSS4__STATIC: + case BOSS4STAYPUT__STATIC: + if (sprite[i].pal == 1) + S_PlaySound(BOS4_RECOG); + S_PlaySound(BOSS4_FIRSTSEE); + break; + case GREENSLIME__STATIC: + A_PlaySound(SLIM_RECOG,i); + break; + } +} - moveplayers(); //ST 10 - movefallers(); //ST 12 - moveexplosions(); //ST 5 - moveactors(); //ST 1 - moveeffectors(); //ST 3 +inline int A_CheckSpriteFlags(int iActor, int iType) +{ + if ((SpriteFlags[sprite[iActor].picnum]^ActorExtra[iActor].flags) & iType) return 1; + return 0; +} - movestandables(); //ST 6 +inline int A_CheckSpriteTileFlags(int iPicnum, int iType) +{ + if (SpriteFlags[iPicnum] & iType) return 1; + return 0; +} + +int A_CheckEnemyTile(int pn) +{ + //this case can't be handled by the dynamictostatic system because it adds + //stuff to the value from names.h so handling separately + if ((pn >= GREENSLIME) && (pn <= GREENSLIME+7)) return 1; + + if (A_CheckSpriteTileFlags(pn,SPRITE_BADGUY)) return 1; + + if (ActorType[pn]) return 1; + + switch (DynamicTileMap[pn]) + { + case SHARK__STATIC: + case RECON__STATIC: + case DRONE__STATIC: + case LIZTROOPONTOILET__STATIC: + case LIZTROOPJUSTSIT__STATIC: + case LIZTROOPSTAYPUT__STATIC: + case LIZTROOPSHOOT__STATIC: + case LIZTROOPJETPACK__STATIC: + case LIZTROOPDUCKING__STATIC: + case LIZTROOPRUNNING__STATIC: + case LIZTROOP__STATIC: + case OCTABRAIN__STATIC: + case COMMANDER__STATIC: + case COMMANDERSTAYPUT__STATIC: + case PIGCOP__STATIC: + case EGG__STATIC: + case PIGCOPSTAYPUT__STATIC: + case PIGCOPDIVE__STATIC: + case LIZMAN__STATIC: + case LIZMANSPITTING__STATIC: + case LIZMANFEEDING__STATIC: + case LIZMANJUMP__STATIC: + case ORGANTIC__STATIC: + case BOSS1__STATIC: + case BOSS2__STATIC: + case BOSS3__STATIC: + case BOSS4__STATIC: + //case GREENSLIME: + //case GREENSLIME+1: + //case GREENSLIME+2: + //case GREENSLIME+3: + //case GREENSLIME+4: + //case GREENSLIME+5: + //case GREENSLIME+6: + //case GREENSLIME+7: + case RAT__STATIC: + case ROTATEGUN__STATIC: + return 1; + } + return 0; +} + +inline int A_CheckEnemySprite(spritetype *s) +{ + return(A_CheckEnemyTile(s->picnum)); +} + +int A_CheckSwitchTile(int i) +{ + int j; + //MULTISWITCH has 4 states so deal with it separately + if ((PN >= MULTISWITCH) && (PN <=MULTISWITCH+3)) return 1; + // ACCESSSWITCH and ACCESSSWITCH2 are only active in 1 state so deal with them separately + if ((PN == ACCESSSWITCH) || (PN == ACCESSSWITCH2)) return 1; + //loop to catch both states of switches + for (j=0;j<=1;j++) + { + switch (DynamicTileMap[PN-j]) + { + case HANDPRINTSWITCH__STATIC: + //case HANDPRINTSWITCH+1: + case ALIENSWITCH__STATIC: + //case ALIENSWITCH+1: + case MULTISWITCH__STATIC: + //case MULTISWITCH+1: + //case MULTISWITCH+2: + //case MULTISWITCH+3: + //case ACCESSSWITCH: + //case ACCESSSWITCH2: + case PULLSWITCH__STATIC: + //case PULLSWITCH+1: + case HANDSWITCH__STATIC: + //case HANDSWITCH+1: + case SLOTDOOR__STATIC: + //case SLOTDOOR+1: + case LIGHTSWITCH__STATIC: + //case LIGHTSWITCH+1: + case SPACELIGHTSWITCH__STATIC: + //case SPACELIGHTSWITCH+1: + case SPACEDOORSWITCH__STATIC: + //case SPACEDOORSWITCH+1: + case FRANKENSTINESWITCH__STATIC: + //case FRANKENSTINESWITCH+1: + case LIGHTSWITCH2__STATIC: + //case LIGHTSWITCH2+1: + case POWERSWITCH1__STATIC: + //case POWERSWITCH1+1: + case LOCKSWITCH1__STATIC: + //case LOCKSWITCH1+1: + case POWERSWITCH2__STATIC: + //case POWERSWITCH2+1: + case DIPSWITCH__STATIC: + //case DIPSWITCH+1: + case DIPSWITCH2__STATIC: + //case DIPSWITCH2+1: + case TECHSWITCH__STATIC: + //case TECHSWITCH+1: + case DIPSWITCH3__STATIC: + //case DIPSWITCH3+1: + return 1; + } + } + return 0; +} + +void G_MoveWorld(void) +{ + G_MoveZombieActors(); //ST 2 + G_MoveWeapons(); //ST 4 + G_MoveTransports(); //ST 9 + + G_MovePlayers(); //ST 10 + G_MoveFallers(); //ST 12 + G_MoveMisc(); //ST 5 + + G_MoveActors(); //ST 1 + G_MoveEffectors(); //ST 3 + + G_MoveStandables(); //ST 6 if (apScriptGameEvent[EVENT_GAME]) { @@ -7542,8 +7757,8 @@ void moveobjects(void) do { j = nextspritestat[i]; - pl=findplayer(&sprite[i],&p); - OnEvent(EVENT_GAME,i, pl, p); + pl=A_FindPlayer(&sprite[i],&p); + X_OnEvent(EVENT_GAME,i, pl, p); i = j; } while (i >= 0); @@ -7551,7 +7766,7 @@ void moveobjects(void) while (k--); } - doanimations(); - movefx(); //ST 11 + G_DoSectorAnimations(); + G_MoveFX(); //ST 11 } diff --git a/polymer/eduke32/source/anim.c b/polymer/eduke32/source/anim.c index 2316f4c54..fd00afa9c 100644 --- a/polymer/eduke32/source/anim.c +++ b/polymer/eduke32/source/anim.c @@ -37,31 +37,31 @@ void endanimsounds(int fr) switch (fr) { case 1: - sound(WIND_AMBIENCE); + S_PlaySound(WIND_AMBIENCE); break; case 26: - sound(ENDSEQVOL2SND1); + S_PlaySound(ENDSEQVOL2SND1); break; case 36: - sound(ENDSEQVOL2SND2); + S_PlaySound(ENDSEQVOL2SND2); break; case 54: - sound(THUD); + S_PlaySound(THUD); break; case 62: - sound(ENDSEQVOL2SND3); + S_PlaySound(ENDSEQVOL2SND3); break; case 75: - sound(ENDSEQVOL2SND4); + S_PlaySound(ENDSEQVOL2SND4); break; case 81: - sound(ENDSEQVOL2SND5); + S_PlaySound(ENDSEQVOL2SND5); break; case 115: - sound(ENDSEQVOL2SND6); + S_PlaySound(ENDSEQVOL2SND6); break; case 124: - sound(ENDSEQVOL2SND7); + S_PlaySound(ENDSEQVOL2SND7); break; } break; @@ -69,23 +69,23 @@ void endanimsounds(int fr) switch (fr) { case 1: - sound(WIND_REPEAT); + S_PlaySound(WIND_REPEAT); break; case 98: - sound(DUKE_GRUNT); + S_PlaySound(DUKE_GRUNT); break; case 82+20: - sound(THUD); - sound(SQUISHED); + S_PlaySound(THUD); + S_PlaySound(SQUISHED); break; case 104+20: - sound(ENDSEQVOL3SND3); + S_PlaySound(ENDSEQVOL3SND3); break; case 114+20: - sound(ENDSEQVOL3SND2); + S_PlaySound(ENDSEQVOL3SND2); break; case 158: - sound(PIPEBOMB_EXPLODE); + S_PlaySound(PIPEBOMB_EXPLODE); break; } break; @@ -97,10 +97,10 @@ void logoanimsounds(int fr) switch (fr) { case 1: - sound(FLY_BY); + S_PlaySound(FLY_BY); break; case 19: - sound(PIPEBOMB_EXPLODE); + S_PlaySound(PIPEBOMB_EXPLODE); break; } } @@ -110,14 +110,14 @@ void intro4animsounds(int fr) switch (fr) { case 1: - sound(INTRO4_B); + S_PlaySound(INTRO4_B); break; case 12: case 34: - sound(SHORT_CIRCUIT); + S_PlaySound(SHORT_CIRCUIT); break; case 18: - sound(INTRO4_5); + S_PlaySound(INTRO4_5); break; } } @@ -127,16 +127,16 @@ void first4animsounds(int fr) switch (fr) { case 1: - sound(INTRO4_1); + S_PlaySound(INTRO4_1); break; case 12: - sound(INTRO4_2); + S_PlaySound(INTRO4_2); break; case 7: - sound(INTRO4_3); + S_PlaySound(INTRO4_3); break; case 26: - sound(INTRO4_4); + S_PlaySound(INTRO4_4); break; } } @@ -146,7 +146,7 @@ void intro42animsounds(int fr) switch (fr) { case 10: - sound(INTRO4_6); + S_PlaySound(INTRO4_6); break; } } @@ -156,10 +156,10 @@ void endanimvol41(int fr) switch (fr) { case 3: - sound(DUKE_UNDERWATER); + S_PlaySound(DUKE_UNDERWATER); break; case 35: - sound(VOL4ENDSND1); + S_PlaySound(VOL4ENDSND1); break; } } @@ -169,13 +169,13 @@ void endanimvol42(int fr) switch (fr) { case 11: - sound(DUKE_UNDERWATER); + S_PlaySound(DUKE_UNDERWATER); break; case 20: - sound(VOL4ENDSND1); + S_PlaySound(VOL4ENDSND1); break; case 39: - sound(VOL4ENDSND2); + S_PlaySound(VOL4ENDSND2); break; case 50: FX_StopAllSounds(); @@ -188,19 +188,19 @@ void endanimvol43(int fr) switch (fr) { case 1: - sound(BOSS4_DEADSPEECH); + S_PlaySound(BOSS4_DEADSPEECH); break; case 40: - sound(VOL4ENDSND1); - sound(DUKE_UNDERWATER); + S_PlaySound(VOL4ENDSND1); + S_PlaySound(DUKE_UNDERWATER); break; case 50: - sound(BIGBANG); + S_PlaySound(BIGBANG); break; } } -void playanm(const char *fn,char t) +void G_PlayAnim(const char *fn,char t) { char *animbuf; unsigned char *palptr; @@ -250,7 +250,7 @@ void playanm(const char *fn,char t) //setpalette(0L,256L,tempbuf); //setbrightness(ud.brightness>>2,tempbuf,2); - setgamepalette(g_player[myconnectindex].ps,animpal,10); + SetGamePalette(g_player[myconnectindex].ps,animpal,10); #if defined(POLYMOST) && defined(USE_OPENGL) gltexfiltermode = 0; @@ -275,10 +275,10 @@ void playanm(const char *fn,char t) goto ENDOFANIMLOOP; handleevents(); getpackets(); - if (restorepalette == 1) + if (g_restorePalette == 1) { - setgamepalette(g_player[myconnectindex].ps,animpal,0); - restorepalette = 0; + SetGamePalette(g_player[myconnectindex].ps,animpal,0); + g_restorePalette = 0; } idle(); } diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index 958a7d92e..eb0c2b85f 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -7331,7 +7331,7 @@ static void comlinehelp(void) wm_msgbox("Mapster32"VERSION BUILDDATE,s); } -static void addgamepath(const char *buffer) +static void AddGamePath(const char *buffer) { struct strllist *s; s = (struct strllist *)Bcalloc(1,sizeof(struct strllist)); @@ -7347,7 +7347,7 @@ static void addgamepath(const char *buffer) CommandPaths = s; } -static void addgroup(const char *buffer) +static void G_AddGroup(const char *buffer) { struct strllist *s; s = (struct strllist *)Bcalloc(1,sizeof(struct strllist)); @@ -7374,7 +7374,7 @@ static void addgroup(const char *buffer) extern char forcegl; #endif -static void checkcommandline(int argc, const char **argv) +static void G_CheckCommandLine(int argc, const char **argv) { int i = 1, j, maxlen=0, *lengths; char *c, *k; @@ -7406,7 +7406,7 @@ static void checkcommandline(int argc, const char **argv) { if (argc > i+1) { - addgroup(argv[i+1]); + G_AddGroup(argv[i+1]); COPYARG(i); COPYARG(i+1); i++; @@ -7419,7 +7419,7 @@ static void checkcommandline(int argc, const char **argv) { if (argc > i+1) { - addgamepath(argv[i+1]); + AddGamePath(argv[i+1]); COPYARG(i); COPYARG(i+1); i++; @@ -7516,14 +7516,14 @@ static void checkcommandline(int argc, const char **argv) case 'J': c++; if (!*c) break; - addgamepath(c); + AddGamePath(c); COPYARG(i); break; case 'g': case 'G': c++; if (!*c) break; - addgroup(c); + G_AddGroup(c); COPYARG(i); break; } @@ -7535,7 +7535,7 @@ static void checkcommandline(int argc, const char **argv) { if (!Bstrcasecmp(k,".grp") || !Bstrcasecmp(k,".zip")) { - addgroup(argv[i++]); + G_AddGroup(argv[i++]); COPYARG(i); continue; } @@ -7582,7 +7582,7 @@ int ExtPreInit(int argc,const char **argv) initprintf("Mapster32"VERSION BUILDDATE"\n"); initprintf("Copyright (c) 2008 EDuke32 team\n"); - checkcommandline(argc,argv); + G_CheckCommandLine(argc,argv); return 0; } @@ -8015,7 +8015,7 @@ static int getatoken(scriptfile *sf, tokenlist *tl, int ntokens) return T_ERROR; } -static void autoloadgrps(const char *fn) +static void DoAutoload(const char *fn) { Bsprintf(tempbuf,"autoload/%s",fn); getfilenames(tempbuf,"*.grp"); @@ -8062,7 +8062,7 @@ int parsegroupfiles(scriptfile *script) { initprintf("Using group file '%s'.\n",fn); if (!NoAutoLoad) - autoloadgrps(fn); + DoAutoload(fn); } } @@ -8529,7 +8529,7 @@ int ExtInit(void) while (findfiles) { Bsprintf(tempbuf,"autoload/%s",findfiles->name); initprintf("Using group file '%s'.\n",tempbuf); initgroupfile(tempbuf); findfiles = findfiles->next; } if (i != -1) - autoloadgrps(duke3dgrp); + DoAutoload(duke3dgrp); } if (getenv("DUKE3DDEF")) @@ -8553,7 +8553,7 @@ int ExtInit(void) { initprintf("Using group file '%s'.\n",CommandGrps->str); if (!NoAutoLoad) - autoloadgrps(CommandGrps->str); + DoAutoload(CommandGrps->str); } free(CommandGrps->str); diff --git a/polymer/eduke32/source/config.c b/polymer/eduke32/source/config.c index 7e52d0234..22fd2d971 100644 --- a/polymer/eduke32/source/config.c +++ b/polymer/eduke32/source/config.c @@ -202,7 +202,7 @@ void CONFIG_SetDefaults(void) ud.config.MusicDevice = 0; ud.config.MusicToggle = 1; ud.config.MusicVolume = 200; - myaimmode = g_player[0].ps->aim_mode = 1; + g_myAimMode = g_player[0].ps->aim_mode = 1; ud.config.NumBits = 16; ud.config.NumChannels = 2; ud.config.NumVoices = 32; @@ -253,7 +253,7 @@ void CONFIG_SetDefaults(void) ud.textscale = 100; Bstrcpy(ud.rtsname, "DUKE.RTS"); - Bstrcpy(myname, "Duke"); + Bstrcpy(szPlayerName, "Duke"); Bstrcpy(ud.ridecule[0], "An inspiration for birth control."); Bstrcpy(ud.ridecule[1], "You're gonna die for that!"); @@ -587,12 +587,12 @@ void CONFIG_SetupJoystick(void) =================== */ extern char *duke3dgrp; -extern void check_valid_color(int *color,int prev_color); -extern palette_t crosshair_colors; -extern palette_t default_crosshair_colors; +extern void G_CheckPlayerColor(int *color,int prev_color); +extern palette_t CrosshairColors; +extern palette_t DefaultCrosshairColors; extern char mod_dir[BMAX_PATH]; extern int r_maxfps; -extern int g_NoSetup; +extern int g_noSetup; int32 CONFIG_ReadSetup(void) { @@ -637,8 +637,8 @@ int32 CONFIG_ReadSetup(void) while (Bstrlen(stripcolorcodes(dummybuf,tempbuf)) > 10) tempbuf[Bstrlen(tempbuf)-1] = '\0'; - Bstrncpy(myname,tempbuf,sizeof(myname)-1); - myname[sizeof(myname)-1] = '\0'; + Bstrncpy(szPlayerName,tempbuf,sizeof(szPlayerName)-1); + szPlayerName[sizeof(szPlayerName)-1] = '\0'; SCRIPT_GetString(ud.config.scripthandle, "Comm Setup","RTSName",&ud.rtsname[0]); @@ -648,152 +648,208 @@ int32 CONFIG_ReadSetup(void) packetrate = min(max(packetrate,50),1000); #endif + SCRIPT_GetNumber(ud.config.scripthandle, "Setup","ConfigVersion",&ud.configversion); + SCRIPT_GetNumber(ud.config.scripthandle, "Setup","ForceSetup",&ud.config.ForceSetup); + +#ifdef _WIN32 + if (g_noSetup == 0 && mod_dir[0] == '/') + SCRIPT_GetString(ud.config.scripthandle, "Setup","ModDir",&mod_dir[0]); +#endif + { extern char defaultduke3dgrp[BMAX_PATH]; if (!Bstrcmp(defaultduke3dgrp,"duke3d.grp")) SCRIPT_GetString(ud.config.scripthandle, "Setup","SelectedGRP",&duke3dgrp[0]); } -#ifdef _WIN32 - if (g_NoSetup == 0 && mod_dir[0] == '/') - SCRIPT_GetString(ud.config.scripthandle, "Setup","ModDir",&mod_dir[0]); -#endif - - SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "Shadows",&ud.shadows); - - if (!NAM) { - SCRIPT_GetString(ud.config.scripthandle, "Screen Setup","Password",&ud.pwlockout[0]); - SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "Out",&ud.lockout); + tempbuf[0] = 0; + SCRIPT_GetString(ud.config.scripthandle, "Screen Setup", "AmbientLight",&tempbuf[0]); + if (atof(tempbuf)) + { + r_ambientlight = atof(tempbuf); + r_ambientlightrecip = 1.f/r_ambientlight; + } } SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "Detail",&ud.detail); - SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "Tilt",&ud.screen_tilting); - SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "Messages",&ud.fta_on); - SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenWidth",&ud.config.ScreenWidth); - SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenHeight",&ud.config.ScreenHeight); - SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenMode",&ud.config.ScreenMode); - SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenGamma",&ud.brightness); - SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenSize",&ud.screen_size); - tempbuf[0] = 0; - SCRIPT_GetString(ud.config.scripthandle, "Screen Setup", "VidGamma",&tempbuf[0]); - if (tempbuf[0]) vid_gamma = atof(tempbuf); - tempbuf[0] = 0; - SCRIPT_GetString(ud.config.scripthandle, "Screen Setup", "VidBrightness",&tempbuf[0]); - if (tempbuf[0]) vid_brightness = atof(tempbuf); - tempbuf[0] = 0; - SCRIPT_GetString(ud.config.scripthandle, "Screen Setup", "VidContrast",&tempbuf[0]); - if (tempbuf[0]) vid_contrast = atof(tempbuf); - tempbuf[0] = 0; - SCRIPT_GetString(ud.config.scripthandle, "Screen Setup", "AmbientLight",&tempbuf[0]); - if (atof(tempbuf)) { - r_ambientlight = atof(tempbuf); - r_ambientlightrecip = 1.f/r_ambientlight; - } + extern int g_frameDelay; - SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "MaxFPS",&r_maxfps); - r_maxfps = max(0,min(1000,r_maxfps)); - { - extern int g_FrameDelay; + SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "MaxFPS",&r_maxfps); + r_maxfps = max(0,min(1000,r_maxfps)); if (r_maxfps) - g_FrameDelay = (1000/r_maxfps); - else g_FrameDelay = 0; + g_frameDelay = (1000/r_maxfps); + else g_frameDelay = 0; } -#if defined(POLYMOST) && defined(USE_OPENGL) - SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenBPP", &ud.config.ScreenBPP); - if (ud.config.ScreenBPP < 8) ud.config.ScreenBPP = 32; + SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "Messages",&ud.fta_on); + + if (!NAM) + { + SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "Out",&ud.lockout); + SCRIPT_GetString(ud.config.scripthandle, "Screen Setup","Password",&ud.pwlockout[0]); + } + + SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenGamma",&ud.brightness); + SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenHeight",&ud.config.ScreenHeight); + SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenMode",&ud.config.ScreenMode); + SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenSize",&ud.screen_size); + SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenWidth",&ud.config.ScreenWidth); + SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "Shadows",&ud.shadows); + SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "Tilt",&ud.screen_tilting); + + { + tempbuf[0] = 0; + SCRIPT_GetString(ud.config.scripthandle, "Screen Setup", "VidGamma",&tempbuf[0]); + if (tempbuf[0]) vid_gamma = atof(tempbuf); + } + + { + tempbuf[0] = 0; + SCRIPT_GetString(ud.config.scripthandle, "Screen Setup", "VidBrightness",&tempbuf[0]); + if (tempbuf[0]) vid_brightness = atof(tempbuf); + } + + { + tempbuf[0] = 0; + SCRIPT_GetString(ud.config.scripthandle, "Screen Setup", "VidContrast",&tempbuf[0]); + if (tempbuf[0]) vid_contrast = atof(tempbuf); + } + +#ifdef RENDERTYPEWIN + { + SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "WindowPositioning", (int32 *)&windowpos); + windowx = -1; + SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "WindowPosX", (int32 *)&windowx); + windowy = -1; + SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "WindowPosY", (int32 *)&windowy); + } #endif + { +#ifdef _WIN32 + dummy = 0; +#else + dummy = 1; +#endif + SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "OSDTextMode",&dummy); + OSD_SetTextMode(dummy); + } + #ifdef RENDERTYPEWIN SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "MaxRefreshFreq", (int32*)&maxrefreshfreq); #endif + #if defined(POLYMOST) && defined(USE_OPENGL) - SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLTextureMode", &gltexfiltermode); - SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLAnisotropy", &glanisotropy); - SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLProjectionFix", &glprojectionhacks); - SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLUseTextureCompr", &glusetexcompr); - SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLWidescreen", &glwidescreen); - - SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLUseCompressedTextureCache", &glusetexcache); - SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLUseTextureCacheCompression", &glusetexcachecompression); - - SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLDepthPeeling", &r_depthpeeling); - SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLPeelsCount", &r_peelscount); - - SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLFullbrights", &r_fullbrights); - SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLDetailMapping", &r_detailmapping); - SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLGlowMapping", &r_glowmapping); - SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLVertexArrays", &r_vertexarrays); - SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLVBOs", &r_vbos); - SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLVBOCount", &r_vbocount); - - SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLVSync", &vsync); - SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLAnimationSmoothing", &r_animsmoothing); - + SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLAnisotropy", &glanisotropy); + SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLDepthPeeling", &r_depthpeeling); + SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLDetailMapping", &r_detailmapping); + SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLFullbrights", &r_fullbrights); + SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLGlowMapping", &r_glowmapping); + SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLOcclusionChecking", &r_modelocclusionchecking); SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLParallaxSkyClamping", &r_parallaxskyclamping); SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLParallaxSkyPanning", &r_parallaxskypanning); - SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLOcclusionChecking", &r_modelocclusionchecking); + SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLPeelsCount", &r_peelscount); + SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLProjectionFix", &glprojectionhacks); + SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLTextureMode", &gltexfiltermode); SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLTextureQuality", &r_downsize); - dummy = usemodels; - SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "UseModels",&dummy); - usemodels = dummy != 0; - dummy = usehightile; - SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "UseHightile",&dummy); - usehightile = dummy != 0; -#endif -#ifdef _WIN32 - dummy = 0; -#else - dummy = 1; -#endif - SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "OSDTextMode",&dummy); - OSD_SetTextMode(dummy); + SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLUseCompressedTextureCache", &glusetexcache); + SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLUseTextureCacheCompression", &glusetexcachecompression); + SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLUseTextureCompr", &glusetexcompr); + SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLVBOCount", &r_vbocount); + SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLVBOs", &r_vbos); + SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLVertexArrays", &r_vertexarrays); + SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLVSync", &vsync); + SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLWidescreen", &glwidescreen); SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "OSDHightile",&osdhightile); - SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "Executions",&ud.executions); - SCRIPT_GetNumber(ud.config.scripthandle, "Setup", "ForceSetup",&ud.config.ForceSetup); - SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "RunMode",&ud.config.RunMode); - SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "Crosshairs",&ud.crosshair); + + { + SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenBPP", &ud.config.ScreenBPP); + if (ud.config.ScreenBPP < 8) ud.config.ScreenBPP = 32; + } + + { + dummy = usehightile; + SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "UseHightile",&dummy); + usehightile = dummy != 0; + } + + { + dummy = usemodels; + SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "UseModels",&dummy); + usemodels = dummy != 0; + } +#endif + + SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "AltHud",&ud.althud); + SCRIPT_GetNumber(ud.config.scripthandle, "Misc","AngleInterpolation",&ud.angleinterpolation); + SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "AutoMsg",&ud.automsg); + SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "AutoVote",&ud.autovote); + + { + SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "Color",&ud.color); + G_CheckPlayerColor((int *)&ud.color,-1); + g_player[0].ps->palookup = g_player[0].pcolor = ud.color; + } + + { + tempbuf[0] = 0; + SCRIPT_GetString(ud.config.scripthandle, "Misc", "CrosshairColor",&tempbuf[0]); + if (tempbuf[0]) + { + char *ptr = strtok(tempbuf,","); + palette_t temppal; + char *palptr = (char *)&temppal; + + i = 0; + while (ptr != NULL && i < 3) + { + palptr[i++] = atoi(ptr); + ptr = strtok(NULL,","); + } + if (i == 3) + { + Bmemcpy(&CrosshairColors,&temppal,sizeof(palette_t)); + DefaultCrosshairColors.f = 1; + } + } + } SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "CrosshairScale",&ud.crosshairscale); - SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "StatusBarScale",&ud.statusbarscale); - SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "ShowLevelStats",&ud.levelstats); - SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "ShowOpponentWeapons",&ud.config.ShowOpponentWeapons); - ud.showweapons = ud.config.ShowOpponentWeapons; - SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "ShowViewWeapon",&ud.drawweapon); + SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "Crosshairs",&ud.crosshair); SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "DeathMessages",&ud.obituaries); SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "DemoCams",&ud.democams); - SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "ShowFPS",&ud.tickrate); - SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "Color",&ud.color); - check_valid_color((int *)&ud.color,-1); - g_player[0].ps->palookup = g_player[0].pcolor = ud.color; - SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "Team",&dummy); - ud.team = 0; - if (dummy < 4 && dummy > -1) ud.team = dummy; - g_player[0].pteam = ud.team; - SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "MPMessageDisplayTime",&ud.msgdisptime); - SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "StatusBarMode",&ud.statusbarmode); - SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "AutoVote",&ud.autovote); - SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "AutoMsg",&ud.automsg); + SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "Executions",&ud.executions); SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "IDPlayers",&ud.idplayers); - SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "ViewBobbing",&ud.viewbob); - SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "WeaponSway",&ud.weaponsway); - SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "AltHud",&ud.althud); + SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "MPMessageDisplayTime",&ud.msgdisptime); + SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "RunMode",&ud.config.RunMode); + SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "ShowFPS",&ud.tickrate); + SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "ShowLevelStats",&ud.levelstats); + SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "ShowOpponentWeapons",&ud.config.ShowOpponentWeapons); ud.showweapons = ud.config.ShowOpponentWeapons; + SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "ShowViewWeapon",&ud.drawweapon); + SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "StatusBarMode",&ud.statusbarmode); + SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "StatusBarScale",&ud.statusbarscale); + { + SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "Team",&dummy); + ud.team = 0; + if (dummy < 4 && dummy > -1) ud.team = dummy; + g_player[0].pteam = ud.team; + } + + SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "TextScale",&ud.textscale); dummy = ud.config.useprecache; SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "UsePrecache",&dummy); ud.config.useprecache = dummy != 0; - - SCRIPT_GetNumber(ud.config.scripthandle, "Misc","AngleInterpolation",&ud.angleinterpolation); - + SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "ViewBobbing",&ud.viewbob); SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "WeaponScale",&ud.weaponscale); - SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "TextScale",&ud.textscale); + SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "WeaponSway",&ud.weaponsway); - // weapon choices are defaulted in checkcommandline, which may override them + // weapon choices are defaulted in G_CheckCommandLine, which may override them if (!CommandWeaponChoice) for (i=0;i<10;i++) { @@ -803,68 +859,60 @@ int32 CONFIG_ReadSetup(void) if (dummy >= 0) g_player[0].wchoice[i] = dummy; } - SCRIPT_GetNumber(ud.config.scripthandle, "Setup","ConfigVersion",&ud.configversion); - - SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "FXDevice",&ud.config.FXDevice); - SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "MusicDevice",&ud.config.MusicDevice); - SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "FXVolume",&ud.config.FXVolume); - SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "MusicVolume",&ud.config.MusicVolume); - SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "SoundToggle",&ud.config.SoundToggle); - SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "MusicToggle",&ud.config.MusicToggle); - SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "VoiceToggle",&ud.config.VoiceToggle); - if (ud.config.VoiceToggle == 2) ud.config.VoiceToggle = 5; SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "AmbienceToggle",&ud.config.AmbienceToggle); - SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "NumVoices",&ud.config.NumVoices); - SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "NumChannels",&ud.config.NumChannels); - SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "NumBits",&ud.config.NumBits); + SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "FXDevice",&ud.config.FXDevice); + SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "FXVolume",&ud.config.FXVolume); SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "MixRate",&ud.config.MixRate); + SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "MusicDevice",&ud.config.MusicDevice); + SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "MusicToggle",&ud.config.MusicToggle); + SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "MusicVolume",&ud.config.MusicVolume); + SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "NumBits",&ud.config.NumBits); + SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "NumChannels",&ud.config.NumChannels); + SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "NumVoices",&ud.config.NumVoices); SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "ReverseStereo",&ud.config.ReverseStereo); + SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "SoundToggle",&ud.config.SoundToggle); + + { + SCRIPT_GetNumber(ud.config.scripthandle, "Sound Setup", "VoiceToggle",&ud.config.VoiceToggle); + if (ud.config.VoiceToggle == 2) ud.config.VoiceToggle = 5; + } + + SCRIPT_GetNumber(ud.config.scripthandle, "Controls","AimingFlag",(int32 *)&g_myAimMode); // (if toggle mode) gives state + + { + SCRIPT_GetNumber(ud.config.scripthandle, "Controls","AutoAim",&ud.config.AutoAim); // JBF 20031125 + g_player[0].ps->auto_aim = ud.config.AutoAim; + } SCRIPT_GetNumber(ud.config.scripthandle, "Controls","MouseAimingFlipped",&ud.mouseflip); // mouse aiming inverted - SCRIPT_GetNumber(ud.config.scripthandle, "Controls","MouseAiming",&ud.mouseaiming); // 1=momentary/0=toggle - g_player[0].ps->aim_mode = ud.mouseaiming; + + { + SCRIPT_GetNumber(ud.config.scripthandle, "Controls","MouseAiming",&ud.mouseaiming); // 1=momentary/0=toggle + g_player[0].ps->aim_mode = ud.mouseaiming; + } + SCRIPT_GetNumber(ud.config.scripthandle, "Controls","MouseBias",&ud.config.MouseBias); SCRIPT_GetNumber(ud.config.scripthandle, "Controls","MouseDeadZone",&ud.config.MouseDeadZone); - SCRIPT_GetNumber(ud.config.scripthandle, "Controls","SmoothInput",&ud.config.SmoothInput); - control_smoothmouse = ud.config.SmoothInput; + SCRIPT_GetNumber(ud.config.scripthandle, "Controls","RunKeyBehaviour",&ud.runkey_mode); // JBF 20031125 + + { + SCRIPT_GetNumber(ud.config.scripthandle, "Controls","SmoothInput",&ud.config.SmoothInput); + control_smoothmouse = ud.config.SmoothInput; + } + SCRIPT_GetNumber(ud.config.scripthandle, "Controls","UseJoystick",&ud.config.UseJoystick); SCRIPT_GetNumber(ud.config.scripthandle, "Controls","UseMouse",&ud.config.UseMouse); - SCRIPT_GetNumber(ud.config.scripthandle, "Controls","AimingFlag",(int32 *)&myaimmode); // (if toggle mode) gives state - SCRIPT_GetNumber(ud.config.scripthandle, "Controls","RunKeyBehaviour",&ud.runkey_mode); // JBF 20031125 - SCRIPT_GetNumber(ud.config.scripthandle, "Controls","AutoAim",&ud.config.AutoAim); // JBF 20031125 - g_player[0].ps->auto_aim = ud.config.AutoAim; - SCRIPT_GetNumber(ud.config.scripthandle, "Controls","WeaponSwitchMode",&ud.weaponswitch); - g_player[0].ps->weaponswitch = ud.weaponswitch; + + { + SCRIPT_GetNumber(ud.config.scripthandle, "Controls","WeaponSwitchMode",&ud.weaponswitch); + g_player[0].ps->weaponswitch = ud.weaponswitch; + } #ifdef _WIN32 SCRIPT_GetNumber(ud.config.scripthandle, "Updates", "CheckForUpdates", &ud.config.CheckForUpdates); SCRIPT_GetNumber(ud.config.scripthandle, "Updates", "LastUpdateCheck", &ud.config.LastUpdateCheck); - SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "WindowPositioning", (int32 *)&windowpos); - windowx = -1; - SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "WindowPosX", (int32 *)&windowx); - windowy = -1; - SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "WindowPosY", (int32 *)&windowy); #endif - tempbuf[0] = 0; - SCRIPT_GetString(ud.config.scripthandle, "Misc", "CrosshairColor",&tempbuf[0]); - if (tempbuf[0]) - { - char *ptr = strtok(tempbuf,","); - palette_t temppal; - char *palptr = (char *)&temppal; - i = 0; - while (ptr != NULL && i < 3) - { - palptr[i++] = atoi(ptr); - ptr = strtok(NULL,","); - } - if (i == 3) - { - Bmemcpy(&crosshair_colors,&temppal,sizeof(palette_t)); - default_crosshair_colors.f = 1; - } - } } CONFIG_ReadKeys(); @@ -934,28 +982,36 @@ void CONFIG_WriteSetup(void) if (ud.config.scripthandle < 0) ud.config.scripthandle = SCRIPT_Init(setupfilename); - SCRIPT_PutNumber(ud.config.scripthandle, "Controls","AimingFlag",(int) myaimmode,false,false); + SCRIPT_PutNumber(ud.config.scripthandle, "Controls","AimingFlag",(int) g_myAimMode,false,false); SCRIPT_PutNumber(ud.config.scripthandle, "Controls","AutoAim",ud.config.AutoAim,false,false); SCRIPT_PutNumber(ud.config.scripthandle, "Controls","MouseAimingFlipped",ud.mouseflip,false,false); SCRIPT_PutNumber(ud.config.scripthandle, "Controls","MouseAiming",ud.mouseaiming,false,false); SCRIPT_PutNumber(ud.config.scripthandle, "Controls","MouseBias",ud.config.MouseBias,false,false); SCRIPT_PutNumber(ud.config.scripthandle, "Controls","MouseDeadZone",ud.config.MouseDeadZone,false,false); - SCRIPT_PutNumber(ud.config.scripthandle, "Controls","SmoothInput",ud.config.SmoothInput,false,false); SCRIPT_PutNumber(ud.config.scripthandle, "Controls","RunKeyBehaviour",ud.runkey_mode,false,false); + SCRIPT_PutNumber(ud.config.scripthandle, "Controls","SmoothInput",ud.config.SmoothInput,false,false); SCRIPT_PutNumber(ud.config.scripthandle, "Controls","UseJoystick",ud.config.UseJoystick,false,false); SCRIPT_PutNumber(ud.config.scripthandle, "Controls","UseMouse",ud.config.UseMouse,false,false); SCRIPT_PutNumber(ud.config.scripthandle, "Controls","WeaponSwitchMode",ud.weaponswitch,false,false); + SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "AltHud",ud.althud,false,false); +// SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "AngleInterpolation",ud.angleinterpolation,false,false); SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "AutoMsg",ud.automsg,false,false); SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "AutoVote",ud.autovote,false,false); SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "Color",ud.color,false,false); - SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "Crosshairs",ud.crosshair,false,false); + + if (CrosshairColors.r != DefaultCrosshairColors.r || CrosshairColors.g != DefaultCrosshairColors.g + || CrosshairColors.b != DefaultCrosshairColors.b) + { + Bsprintf(tempbuf,"%d,%d,%d",CrosshairColors.r,CrosshairColors.g,CrosshairColors.b); + SCRIPT_PutString(ud.config.scripthandle, "Misc", "CrosshairColor",tempbuf); + } + SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "CrosshairScale",ud.crosshairscale,false,false); + SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "Crosshairs",ud.crosshair,false,false); SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "DeathMessages",ud.obituaries,false,false); SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "DemoCams",ud.democams,false,false); - ud.executions++; - SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "Executions",ud.executions,false,false); - SCRIPT_PutNumber(ud.config.scripthandle, "Setup", "ForceSetup",ud.config.ForceSetup,false,false); + SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "Executions",++ud.executions,false,false); SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "IDPlayers",ud.idplayers,false,false); SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "MPMessageDisplayTime",ud.msgdisptime,false,false); SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "RunMode",ud.config.RunMode,false,false); @@ -966,49 +1022,60 @@ void CONFIG_WriteSetup(void) SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "StatusBarMode",ud.statusbarmode,false,false); SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "StatusBarScale",ud.statusbarscale,false,false); SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "Team",ud.team,false,false); + SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "TextScale",ud.textscale,false,false); SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "UsePrecache",ud.config.useprecache,false,false); SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "ViewBobbing",ud.viewbob,false,false); - SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "WeaponSway",ud.weaponsway,false,false); - SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "AltHud",ud.althud,false,false); -// SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "AngleInterpolation",ud.angleinterpolation,false,false); + + for (dummy=0;dummy<10;dummy++) + { + Bsprintf(buf,"WeaponChoice%d",dummy); + SCRIPT_PutNumber(ud.config.scripthandle, "Misc",buf,g_player[myconnectindex].wchoice[dummy],false,false); + } SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "WeaponScale",ud.weaponscale,false,false); - SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "TextScale",ud.textscale,false,false); + SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "WeaponSway",ud.weaponsway,false,false); + + SCRIPT_PutNumber(ud.config.scripthandle, "Setup","ConfigVersion",BYTEVERSION_JF,false,false); + SCRIPT_PutNumber(ud.config.scripthandle, "Setup", "ForceSetup",ud.config.ForceSetup,false,false); + + { + Bsprintf(tempbuf,"%.2f",r_ambientlight); + SCRIPT_PutString(ud.config.scripthandle, "Screen Setup", "AmbientLight",tempbuf); + } SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "Detail",ud.detail,false,false); #if defined(POLYMOST) && defined(USE_OPENGL) + SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLAnimationSmoothing",r_animsmoothing,false,false); SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLAnisotropy",glanisotropy,false,false); + SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLDepthPeeling",r_depthpeeling,false,false); + SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLDetailMapping", r_detailmapping,false,false); + SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLFullbrights", r_fullbrights,false,false); + SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLGlowMapping", r_glowmapping,false,false); + SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLOcclusionChecking", r_modelocclusionchecking,false,false); + SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLParallaxSkyClamping",r_parallaxskyclamping,false,false); + SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLParallaxSkyPanning",r_parallaxskypanning,false,false); + SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLPeelsCount",r_peelscount,false,false); SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLProjectionFix",glprojectionhacks,false,false); SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLTextureMode",gltexfiltermode,false,false); + SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLTextureQuality", r_downsize,false,false); SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLUseCompressedTextureCache", glusetexcache,false,false); SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLUseTextureCacheCompression", glusetexcachecompression,false,false); SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLUseTextureCompr",glusetexcompr,false,false); - SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLWidescreen",glwidescreen,false,false); - - SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLDepthPeeling",r_depthpeeling,false,false); - SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLPeelsCount",r_peelscount,false,false); - - SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLFullbrights", r_fullbrights,false,false); - SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLDetailMapping", r_detailmapping,false,false); - SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLGlowMapping", r_glowmapping,false,false); - SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLVertexArrays", r_vertexarrays,false,false); - SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLVBOs", r_vbos,false,false); SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLVBOCount", r_vbocount,false,false); - + SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLVBOs", r_vbos,false,false); + SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLVertexArrays", r_vertexarrays,false,false); SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLVSync", vsync,false,false); - - SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLAnimationSmoothing",r_animsmoothing,false,false); - - SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLParallaxSkyClamping",r_parallaxskyclamping,false,false); - SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLParallaxSkyPanning",r_parallaxskypanning,false,false); - SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLOcclusionChecking", r_modelocclusionchecking,false,false); - SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLTextureQuality", r_downsize,false,false); + SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLWidescreen",glwidescreen,false,false); #endif + SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "MaxFPS", r_maxfps, false, false); #ifdef RENDERTYPEWIN SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "MaxRefreshFreq",maxrefreshfreq,false,false); #endif SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "Messages",ud.fta_on,false,false); + SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "OSDHightile",osdhightile,false,false); + SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "OSDTextMode",OSD_GetTextMode(),false,false); + if (!NAM) { SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "Out",ud.lockout,false,false); @@ -1023,12 +1090,27 @@ void CONFIG_WriteSetup(void) SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "ScreenWidth",ud.config.ScreenWidth,false,false); // JBF 20031206 SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "Shadows",ud.shadows,false,false); SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "Tilt",ud.screen_tilting,false,false); + #if defined(POLYMOST) && defined(USE_OPENGL) SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "UseHightile",usehightile,false,false); SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "UseModels",usemodels,false,false); #endif - SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "OSDTextMode",OSD_GetTextMode(),false,false); - SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "OSDHightile",osdhightile,false,false); + + { + Bsprintf(tempbuf,"%.2f",vid_brightness); + SCRIPT_PutString(ud.config.scripthandle, "Screen Setup", "VidBrightness",tempbuf); + Bsprintf(tempbuf,"%.2f",vid_contrast); + SCRIPT_PutString(ud.config.scripthandle, "Screen Setup", "VidContrast",tempbuf); + Bsprintf(tempbuf,"%.2f",vid_gamma); + SCRIPT_PutString(ud.config.scripthandle, "Screen Setup", "VidGamma",tempbuf); + } + +#ifdef RENDERTYPEWIN + SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "WindowPositioning", windowpos, false, false); + SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "WindowPosX", windowx, false, false); + SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "WindowPosY", windowy, false, false); +#endif + SCRIPT_PutNumber(ud.config.scripthandle, "Sound Setup", "AmbienceToggle",ud.config.AmbienceToggle,false,false); SCRIPT_PutNumber(ud.config.scripthandle, "Sound Setup", "FXVolume",ud.config.FXVolume,false,false); SCRIPT_PutNumber(ud.config.scripthandle, "Sound Setup", "MusicToggle",ud.config.MusicToggle,false,false); @@ -1041,30 +1123,11 @@ void CONFIG_WriteSetup(void) SCRIPT_PutNumber(ud.config.scripthandle, "Sound Setup", "SoundToggle",ud.config.SoundToggle,false,false); SCRIPT_PutNumber(ud.config.scripthandle, "Sound Setup", "VoiceToggle",ud.config.VoiceToggle,false,false); - Bsprintf(tempbuf,"%.2f",vid_gamma); - SCRIPT_PutString(ud.config.scripthandle, "Screen Setup", "VidGamma",tempbuf); - Bsprintf(tempbuf,"%.2f",vid_brightness); - SCRIPT_PutString(ud.config.scripthandle, "Screen Setup", "VidBrightness",tempbuf); - Bsprintf(tempbuf,"%.2f",vid_contrast); - SCRIPT_PutString(ud.config.scripthandle, "Screen Setup", "VidContrast",tempbuf); - Bsprintf(tempbuf,"%.2f",r_ambientlight); - SCRIPT_PutString(ud.config.scripthandle, "Screen Setup", "AmbientLight",tempbuf); - SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "MaxFPS", r_maxfps, false, false); #ifdef _WIN32 SCRIPT_PutNumber(ud.config.scripthandle, "Updates", "CheckForUpdates", ud.config.CheckForUpdates, false, false); SCRIPT_PutNumber(ud.config.scripthandle, "Updates", "LastUpdateCheck", ud.config.LastUpdateCheck, false, false); - SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "WindowPositioning", windowpos, false, false); - SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "WindowPosX", windowx, false, false); - SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "WindowPosY", windowy, false, false); #endif - if (crosshair_colors.r != default_crosshair_colors.r || crosshair_colors.g != default_crosshair_colors.g - || crosshair_colors.b != default_crosshair_colors.b) - { - Bsprintf(tempbuf,"%d,%d,%d",crosshair_colors.r,crosshair_colors.g,crosshair_colors.b); - SCRIPT_PutString(ud.config.scripthandle, "Misc", "CrosshairColor",tempbuf); - } - // JBF 20031211 for (dummy=0;dummysectnum,s->x+(TRAND&255)-128,s->y+(TRAND&255)-128,s->z-(8<<8)-(TRAND&8191),SCRAP6+(TRAND&15),-8,48,48,TRAND&2047,(TRAND&63)+64,-512-(TRAND&2047),i,5) +#define RANDOMSCRAP A_InsertSprite(s->sectnum,s->x+(krand()&255)-128,s->y+(krand()&255)-128,s->z-(8<<8)-(krand()&8191),SCRAP6+(krand()&15),-8,48,48,krand()&2047,(krand()&63)+64,-512-(krand()&2047),i,5) #define PHEIGHT (38<<8) -enum gamemodes { +enum GameMode_t { MODE_MENU = 1, MODE_DEMO = 2, MODE_GAME = 4, @@ -148,38 +165,16 @@ enum gamemodes { #define MAXQUOTES 16384 -#define PPDEATHSTRINGS MAXQUOTES-128 -#define PSDEATHSTRINGS MAXQUOTES-32 +#define FIRST_OBITUARY_QUOTE MAXQUOTES-128 +#define FIRST_SUICIDE_QUOTE MAXQUOTES-32 #define MAXCYCLERS 1024 #define MAXANIMATES 256 -#define SP sprite[i].yvel -#define SX sprite[i].x -#define SY sprite[i].y -#define SZ sprite[i].z -#define SS sprite[i].shade -#define PN sprite[i].picnum -#define SA sprite[i].ang -#define SV sprite[i].xvel -#define ZV sprite[i].zvel -#define RX sprite[i].xrepeat -#define RY sprite[i].yrepeat -#define OW sprite[i].owner -#define CS sprite[i].cstat -#define SH sprite[i].extra -#define CX sprite[i].xoffset -#define CY sprite[i].yoffset -#define CD sprite[i].clipdist -#define PL sprite[i].pal -#define SLT sprite[i].lotag -#define SHT sprite[i].hitag -#define SECT sprite[i].sectnum - // Defines the motion characteristics of an actor -enum actormotion_flags { +enum ActorMoveFlags_t { face_player = 1, geth = 2, getv = 4, @@ -200,7 +195,7 @@ enum actormotion_flags { // Defines for 'useractor' keyword -enum useractor_types { +enum UserActorTypes_t { notenemy, enemy, enemystayput @@ -208,7 +203,7 @@ enum useractor_types { // Player Actions. -enum player_action_flags { +enum PlayerActionFlags_t { pstanding = 1, pwalking = 2, prunning = 4, @@ -228,7 +223,7 @@ enum player_action_flags { pfacing = 65536 }; -enum inventory_indexes { +enum InventoryItem_t { GET_STEROIDS, GET_SHIELD, GET_SCUBA, @@ -240,9 +235,7 @@ enum inventory_indexes { GET_BOOTS }; -#define TRAND krand() - -enum weapon_indexes { +enum DukeWeapon_t { KNEE_WEAPON, PISTOL_WEAPON, SHOTGUN_WEAPON, @@ -258,31 +251,8 @@ enum weapon_indexes { MAX_WEAPONS }; -#define T1 hittype[i].temp_data[0] -#define T2 hittype[i].temp_data[1] -#define T3 hittype[i].temp_data[2] -#define T4 hittype[i].temp_data[3] -#define T5 hittype[i].temp_data[4] -#define T6 hittype[i].temp_data[5] -#define T7 hittype[i].temp_data[6] -#define T8 hittype[i].temp_data[7] -#define T9 hittype[i].temp_data[8] - -#define ESCESCAPE if(KB_KeyPressed( sc_Escape ) ) gameexit(" "); - -#define IFWITHIN(B,E) if((PN)>=(B) && (PN)<=(E)) - -#define deletesprite deletesprite_ -void deletesprite_(int s); -#define KILLIT(KX) {deletesprite(KX);goto BOLT;} - - -#define IFMOVING if(ssp(i,CLIPMASK0)) -#define IFHIT j=ifhitbyweapon(i);if(j >= 0) - -#define AFLAMABLE(X) (X==BOX||X==TREE1||X==TREE2||X==TIRE||X==CONE) - -#define rnd(X) ((TRAND>>8)>=(255-(X))) +#define deletesprite A_DeleteSprite +void A_DeleteSprite(int s); #define __USRHOOKS_H @@ -326,15 +296,15 @@ typedef struct { extern animwalltype animwall[MAXANIMWALLS]; -extern short numanimwalls; +extern short g_numAnimWalls; extern int probey; extern char typebuflen,typebuf[141]; extern char *MusicPtr; extern int Musicsize; extern int msx[2048],msy[2048]; -extern short cyclers[MAXCYCLERS][6],numcyclers; -extern char myname[32]; +extern short cyclers[MAXCYCLERS][6],g_numCyclers; +extern char szPlayerName[32]; struct savehead { char name[19]; @@ -446,12 +416,16 @@ typedef struct { typedef struct { int ox,oy,oz; short oa,os; -} playerspawn_t; +} PlayerSpawn_t; -extern char numplayersprites; +extern char g_numPlayerSprites; extern int fricxv,fricyv; +// TODO: make a dummy player struct for interpolation and sort the first members +// of this struct into the same order so we can just memcpy it and get rid of the +// mywhatever type globals + typedef struct { int zoom,exitx,exity; int posx, posy, posz, horiz, ohoriz, ohorizoff, invdisptime; @@ -513,40 +487,38 @@ typedef struct { char walking_snd_toggle, palookup, hard_landing; char /*fire_flag,*/pals[3]; char return_to_center, reloading, name[32]; -} player_struct; +} DukePlayer_t; extern char tempbuf[2048], packbuf[576], menutextbuf[128]; -extern int gc; +extern int SpriteGravity; -extern int impact_damage,respawnactortime,respawnitemtime; -extern int start_armour_amount; +extern int g_impactDamage,g_actorRespawnTime,g_itemRespawnTime; +extern int g_startArmorAmount; #define MOVFIFOSIZ 256 -extern short spriteq[1024],spriteqloc,spriteqamount; +extern short SpriteDeletionQueue[1024],g_spriteDeleteQueuePos,g_spriteDeleteQueueSize; extern user_defs ud; -extern short int moustat; -extern short int global_random; +extern short int g_globalRandom; extern char buf[1024]; //My own generic input buffer #define MAXQUOTELEN 128 -extern char *fta_quotes[MAXQUOTES],*redefined_quotes[MAXQUOTES]; +extern char *ScriptQuotes[MAXQUOTES],*ScriptQuoteRedefinitions[MAXQUOTES]; extern char ready2send; -void scriptinfo(void); -extern intptr_t *script,*scriptptr,*insptr,*labelcode,*labeltype; -extern int labelcnt,defaultlabelcnt; -extern int g_ScriptSize; +void X_ScriptInfo(void); +extern intptr_t *script,*insptr,*labelcode,*labeltype; +extern int g_numLabels,g_numDefaultLabels; +extern int g_scriptSize; extern char *label; -extern intptr_t *actorscrptr[MAXTILES],*parsing_actor; +extern intptr_t *actorscrptr[MAXTILES],*g_parsingActorPtr; extern intptr_t *actorLoadEventScrptr[MAXTILES]; -extern char actortype[MAXTILES]; -extern char *music_pointer; +extern char ActorType[MAXTILES]; -extern char music_select; -extern char env_music_fn[MAXVOLUMES+1][BMAX_PATH]; +extern char g_musicIndex; +extern char EnvMusicFilename[MAXVOLUMES+1][BMAX_PATH]; extern short camsprite; typedef struct { @@ -577,7 +549,7 @@ typedef struct { projectile_t projectile; } actordata_t; -extern actordata_t hittype[MAXSPRITES]; +extern actordata_t ActorExtra[MAXSPRITES]; extern input_t loc; extern input_t recsync[RECSYNCBUFSIZ]; @@ -587,13 +559,13 @@ extern int numplayers, myconnectindex; extern int connecthead, connectpoint2[MAXPLAYERS]; //Player linked list variables (indeces, not connection numbers) extern int screenpeek; -extern int current_menu; -extern int tempwallptr,animatecnt; +extern int g_currentMenu; +extern int tempwallptr,g_animateCount; extern int lockclock; extern intptr_t frameplace; -extern char display_mirror,loadfromgrouponly,rtsplaying; +extern char display_mirror,g_loadFromGroupOnly,g_RTSPlaying; -extern int groupfile; +extern int g_groupFileHandle; extern int ototalclock; extern int *animateptr[MAXANIMATES]; @@ -605,48 +577,48 @@ extern int neartaghitdist; extern short animatesect[MAXANIMATES]; extern int movefifoplc, vel,svel,angvel,horiz; -extern short mirrorwall[64], mirrorsector[64], mirrorcnt; +extern short g_mirrorWall[64], g_mirrorSector[64], g_mirrorCount; #include "funct.h" -extern int screencapt; -extern char volume_names[MAXVOLUMES][33]; -extern char skill_names[5][33]; +extern int g_screenCapture; +extern char EpisodeNames[MAXVOLUMES][33]; +extern char SkillNames[5][33]; -extern int framerate; +extern int g_currentFrameRate; #define MAXGAMETYPES 16 -extern char gametype_names[MAXGAMETYPES][33]; -extern int gametype_flags[MAXGAMETYPES]; -extern char num_gametypes; +extern char GametypeNames[MAXGAMETYPES][33]; +extern int GametypeFlags[MAXGAMETYPES]; +extern char g_numGametypes; -enum gametypeflags { - GAMETYPE_FLAG_COOP = 1, - GAMETYPE_FLAG_WEAPSTAY = 2, - GAMETYPE_FLAG_FRAGBAR = 4, - GAMETYPE_FLAG_SCORESHEET = 8, - GAMETYPE_FLAG_DMSWITCHES = 16, - GAMETYPE_FLAG_COOPSPAWN = 32, - GAMETYPE_FLAG_ACCESSCARDSPRITES = 64, - GAMETYPE_FLAG_COOPVIEW = 128, - GAMETYPE_FLAG_COOPSOUND = 256, - GAMETYPE_FLAG_OTHERPLAYERSINMAP = 512, - GAMETYPE_FLAG_ITEMRESPAWN = 1024, - GAMETYPE_FLAG_MARKEROPTION = 2048, - GAMETYPE_FLAG_PLAYERSFRIENDLY = 4096, - GAMETYPE_FLAG_FIXEDRESPAWN = 8192, - GAMETYPE_FLAG_ACCESSATSTART = 16384, - GAMETYPE_FLAG_PRESERVEINVENTORYDEATH = 32768, - GAMETYPE_FLAG_TDM = 65536, - GAMETYPE_FLAG_TDMSPAWN = 131072 +enum GametypeFlags_t { + GAMETYPE_COOP = 1, + GAMETYPE_WEAPSTAY = 2, + GAMETYPE_FRAGBAR = 4, + GAMETYPE_SCORESHEET = 8, + GAMETYPE_DMSWITCHES = 16, + GAMETYPE_COOPSPAWN = 32, + GAMETYPE_ACCESSCARDSPRITES = 64, + GAMETYPE_COOPVIEW = 128, + GAMETYPE_COOPSOUND = 256, + GAMETYPE_OTHERPLAYERSINMAP = 512, + GAMETYPE_ITEMRESPAWN = 1024, + GAMETYPE_MARKEROPTION = 2048, + GAMETYPE_PLAYERSFRIENDLY = 4096, + GAMETYPE_FIXEDRESPAWN = 8192, + GAMETYPE_ACCESSATSTART = 16384, + GAMETYPE_PRESERVEINVENTORYDEATH = 32768, + GAMETYPE_TDM = 65536, + GAMETYPE_TDMSPAWN = 131072 }; -#define GTFLAGS(x) (gametype_flags[ud.coop] & x) +#define GTFLAGS(x) (GametypeFlags[ud.coop] & x) -extern char num_volumes; +extern char g_numVolumes; -extern int lastsavedpos; -extern int restorepalette; +extern int g_lastSaveSlot; +extern int g_restorePalette; #ifndef RANCID_NETWORKING extern int packetrate; #endif @@ -654,21 +626,22 @@ extern int packetrate; extern int cachecount; extern char boardfilename[BMAX_PATH],waterpal[768],slimepal[768],titlepal[768],drealms[768],endingpal[768],animpal[768]; extern char currentboardfilename[BMAX_PATH]; -extern char cachedebug,earthquaketime; -extern int networkmode; +extern char cachedebug,g_earthquakeTime; +// 0: master/slave, 1: peer-to-peer +extern int g_networkBroadcastMode; extern char lumplockbyte[11]; //DUKE3D.H - replace the end "my's" with this extern int myx, omyx, myxvel, myy, omyy, myyvel, myz, omyz, myzvel; -extern short myhoriz, omyhoriz, myhorizoff, omyhorizoff, globalskillsound; +extern short myhoriz, omyhoriz, myhorizoff, omyhorizoff, g_skillSoundID; extern short myang, omyang, mycursectnum, myjumpingcounter; extern char myjumpingtoggle, myonground, myhardlanding,myreturntocenter; -extern int fakemovefifoplc; +extern int predictfifoplc; extern int myxbak[MOVEFIFOSIZ], myybak[MOVEFIFOSIZ], myzbak[MOVEFIFOSIZ]; extern int myhorizbak[MOVEFIFOSIZ]; extern short myangbak[MOVEFIFOSIZ]; -extern short weaponsandammosprites[15]; +extern short BlimpSpawnSprites[15]; //DUKE3D.H: typedef struct { @@ -681,38 +654,39 @@ typedef struct { } STATUSBARTYPE; extern STATUSBARTYPE sbar; -extern int cameradist, cameraclock, dukefriction,show_shareware; -extern int networkmode, movesperpacket; -extern int gamequit; +extern int g_cameraDistance, g_cameraClock, g_playerFriction,g_showShareware; +extern int g_networkBroadcastMode, g_movesPerPacket; +extern int g_gameQuit; extern char pus,pub; -extern int camerashitable,freezerhurtowner,lasermode; +extern int g_damageCameras,g_freezerSelfDamage,g_tripbombLaserMode; -// TENSW: on really bad network connections, the sync FIFO queue can overflow if it is the -// same size as the move fifo. -#define MAXSYNCBYTES 16 -#define SYNCFIFOSIZ 1024 +// TENSW: on really bad network connections, the sync FIFO queue can overflow if it is the +// same size as the move fifo. +#define MAXSYNCBYTES 16 +#define SYNCFIFOSIZ 1024 extern char syncstat[MAXSYNCBYTES]; extern signed char multiwho, multipos, multiwhat, multiflag; extern int syncvaltail, syncvaltottail; -extern int numfreezebounces,rpgblastradius,pipebombblastradius,tripbombblastradius,shrinkerblastradius,morterblastradius,bouncemineblastradius,seenineblastradius; +extern int g_numFreezeBounces,g_rpgBlastRadius,g_pipebombBlastRadius,g_tripbombBlastRadius; +extern int g_shrinkerBlastRadius,g_morterBlastRadius,g_bouncemineBlastRadius,g_seenineBlastRadius; extern int everyothertime; extern int mymaxlag, otherminlag, bufferjitter; -extern int numinterpolations, startofdynamicinterpolations; +extern int g_numInterpolations, startofdynamicinterpolations; extern int oldipos[MAXINTERPOLATIONS]; extern int bakipos[MAXINTERPOLATIONS]; extern int *curipos[MAXINTERPOLATIONS]; -extern short numclouds,clouds[128],cloudx[128],cloudy[128]; +extern short g_numClouds,clouds[128],cloudx[128],cloudy[128]; extern int cloudtotalclock,totalmemory; extern int stereomode, stereowidth, stereopixelwidth; -extern int myaimmode, myaimstat, omyaimstat; +extern int g_myAimMode, g_myAimStat, g_oldAimStat; -extern unsigned int MoveThingsCount; +extern unsigned int g_moveThingsCount; #define IFISGLMODE if (getrendermode() >= 3) #define IFISSOFTMODE if (getrendermode() < 3) @@ -723,7 +697,7 @@ extern unsigned int MoveThingsCount; #define TILE_ANIM (MAXTILES-4) #define TILE_VIEWSCR (MAXTILES-5) -enum events { +enum GameEvent_t { EVENT_INIT, EVENT_ENTERLEVEL, EVENT_RESETWEAPONS, @@ -815,7 +789,7 @@ enum events { MAXEVENTS }; -enum sysstrs { +enum SystemString_t { STR_MAPNAME, STR_MAPFILENAME, STR_PLAYERNAME, @@ -827,30 +801,30 @@ enum sysstrs { -enum gamevarflags { +enum GamevarFlags_t { MAXGAMEVARS = 2048, // must be a power of two MAXVARLABEL = 26, - GAMEVAR_FLAG_NORMAL = 0, // normal - GAMEVAR_FLAG_PERPLAYER = 1, // per-player variable - GAMEVAR_FLAG_PERACTOR = 2, // per-actor variable - GAMEVAR_FLAG_USER_MASK = 3, - GAMEVAR_FLAG_DEFAULT = 256, // allow override - GAMEVAR_FLAG_SECRET = 512, // don't dump... - GAMEVAR_FLAG_NODEFAULT = 1024, // don't reset on actor spawn - GAMEVAR_FLAG_SYSTEM = 2048, // cannot change mode flags...(only default value) - GAMEVAR_FLAG_READONLY = 4096, // values are read-only (no setvar allowed) - GAMEVAR_FLAG_INTPTR = 8192, // plValue is a pointer to an int - GAMEVAR_FLAG_SYNCCHECK = 16384, // check event sync when translating - GAMEVAR_FLAG_SHORTPTR = 32768, // plValue is a pointer to a short - GAMEVAR_FLAG_CHARPTR = 65536, // plValue is a pointer to a char - GAMEVAR_FLAG_NORESET = 131072, // var values are not reset when restoring map state + GAMEVAR_NORMAL = 0, // normal + GAMEVAR_PERPLAYER = 1, // per-player variable + GAMEVAR_PERACTOR = 2, // per-actor variable + GAMEVAR_USER_MASK = 3, + GAMEVAR_DEFAULT = 256, // allow override + GAMEVAR_SECRET = 512, // don't dump... + GAMEVAR_NODEFAULT = 1024, // don't reset on actor spawn + GAMEVAR_SYSTEM = 2048, // cannot change mode flags...(only default value) + GAMEVAR_READONLY = 4096, // values are read-only (no setvar allowed) + GAMEVAR_INTPTR = 8192, // plValue is a pointer to an int + GAMEVAR_SYNCCHECK = 16384, // check event sync when translating + GAMEVAR_SHORTPTR = 32768, // plValue is a pointer to a short + GAMEVAR_CHARPTR = 65536, // plValue is a pointer to a char + GAMEVAR_NORESET = 131072, // var values are not reset when restoring map state }; -enum gamearrayflags { +enum GamearrayFlags_t { MAXGAMEARRAYS = (MAXGAMEVARS>>2), // must be lower than MAXGAMEVARS MAXARRAYLABEL = MAXVARLABEL, - GAMEARRAY_FLAG_NORMAL = 0, - GAMEARRAY_FLAG_NORESET = 1, + GAMEARRAY_NORMAL = 0, + GAMEARRAY_NORESET = 1, }; typedef struct { @@ -871,22 +845,22 @@ typedef struct { extern gamevar_t aGameVars[MAXGAMEVARS]; extern gamearray_t aGameArrays[MAXGAMEARRAYS]; -extern int iGameVarCount; -extern int iGameArrayCount; +extern int g_gameVarCount; +extern int g_gameArrayCount; -extern int spriteflags[MAXTILES]; +extern int SpriteFlags[MAXTILES]; -enum spriteflags { - SPRITE_FLAG_SHADOW = 1, - SPRITE_FLAG_NVG = 2, - SPRITE_FLAG_NOSHADE = 4, - SPRITE_FLAG_PROJECTILE = 8, - SPRITE_FLAG_DECAL = 16, - SPRITE_FLAG_BADGUY = 32, - SPRITE_FLAG_NOPAL = 64 +enum SpriteFlags_t { + SPRITE_SHADOW = 1, + SPRITE_NVG = 2, + SPRITE_NOSHADE = 4, + SPRITE_PROJECTILE = 8, + SPRITE_DECAL = 16, + SPRITE_BADGUY = 32, + SPRITE_NOPAL = 64 }; -extern short spritecache[MAXTILES][3]; +extern short SpriteCacheList[MAXTILES][3]; extern int g_iReturnVarID; extern int g_iWeaponVarID; @@ -922,28 +896,29 @@ extern intptr_t *aplWeaponSound2Time[MAX_WEAPONS]; // Alternate sound time extern intptr_t *aplWeaponSound2Sound[MAX_WEAPONS]; // Alternate sound sound ID extern intptr_t *aplWeaponReloadSound1[MAX_WEAPONS]; // Sound of magazine being removed extern intptr_t *aplWeaponReloadSound2[MAX_WEAPONS]; // Sound of magazine being inserted +extern intptr_t *aplWeaponSelectSound[MAX_WEAPONS]; // Sound for weapon selection -extern short timer; +extern short g_timerTicsPerSecond; -enum weaponflags { - WEAPON_FLAG_HOLSTER_CLEARS_CLIP = 1, // 'holstering' clears the current clip - WEAPON_FLAG_GLOWS = 2, // weapon 'glows' (shrinker and grower) - WEAPON_FLAG_AUTOMATIC = 4, // automatic fire (continues while 'fire' is held down - WEAPON_FLAG_FIREEVERYOTHER = 8, // during 'hold time' fire every frame - WEAPON_FLAG_FIREEVERYTHIRD = 16, // during 'hold time' fire every third frame - WEAPON_FLAG_RANDOMRESTART = 32, // restart for automatic is 'randomized' by RND 3 - WEAPON_FLAG_AMMOPERSHOT = 64, // uses ammo for each shot (for automatic) - WEAPON_FLAG_BOMB_TRIGGER = 128, // weapon is the 'bomb' trigger - WEAPON_FLAG_NOVISIBLE = 256, // weapon use does not cause user to become 'visible' - WEAPON_FLAG_THROWIT = 512, // weapon 'throws' the 'shoots' item... - WEAPON_FLAG_CHECKATRELOAD = 1024, // check weapon availability at 'reload' time - WEAPON_FLAG_STANDSTILL = 2048, // player stops jumping before actual fire (like tripbomb in duke) - WEAPON_FLAG_SPAWNTYPE1 = 0, // just spawn - WEAPON_FLAG_SPAWNTYPE2 = 4096, // spawn like shotgun shells - WEAPON_FLAG_SPAWNTYPE3 = 8192, // spawn like chaingun shells - WEAPON_FLAG_SEMIAUTO = 16384, // cancel button press after each shot - WEAPON_FLAG_RELOAD_TIMING = 32768, // special casing for pistol reload sounds - WEAPON_FLAG_RESET = 65536 // cycle weapon back to frame 1 if fire is held, 0 if not +enum WeaponFlags_t { + WEAPON_HOLSTER_CLEARS_CLIP = 1, // 'holstering' clears the current clip + WEAPON_GLOWS = 2, // weapon 'glows' (shrinker and grower) + WEAPON_AUTOMATIC = 4, // automatic fire (continues while 'fire' is held down + WEAPON_FIREEVERYOTHER = 8, // during 'hold time' fire every frame + WEAPON_FIREEVERYTHIRD = 16, // during 'hold time' fire every third frame + WEAPON_RANDOMRESTART = 32, // restart for automatic is 'randomized' by RND 3 + WEAPON_AMMOPERSHOT = 64, // uses ammo for each shot (for automatic) + WEAPON_BOMB_TRIGGER = 128, // weapon is the 'bomb' trigger + WEAPON_NOVISIBLE = 256, // weapon use does not cause user to become 'visible' + WEAPON_THROWIT = 512, // weapon 'throws' the 'shoots' item... + WEAPON_CHECKATRELOAD = 1024, // check weapon availability at 'reload' time + WEAPON_STANDSTILL = 2048, // player stops jumping before actual fire (like tripbomb in duke) + WEAPON_SPAWNTYPE1 = 0, // just spawn + WEAPON_SPAWNTYPE2 = 4096, // spawn like shotgun shells + WEAPON_SPAWNTYPE3 = 8192, // spawn like chaingun shells + WEAPON_SEMIAUTO = 16384, // cancel button press after each shot + WEAPON_RELOAD_TIMING = 32768, // special casing for pistol reload sounds + WEAPON_RESET = 65536 // cycle weapon back to frame 1 if fire is held, 0 if not }; #define TRIPBOMB_TRIPWIRE 1 @@ -954,57 +929,57 @@ enum weaponflags { // custom projectiles -enum projectileflags { - PROJECTILE_FLAG_HITSCAN = 1, - PROJECTILE_FLAG_RPG = 2, - PROJECTILE_FLAG_BOUNCESOFFWALLS = 4, - PROJECTILE_FLAG_BOUNCESOFFMIRRORS = 8, - PROJECTILE_FLAG_KNEE = 16, - PROJECTILE_FLAG_WATERBUBBLES = 32, - PROJECTILE_FLAG_TIMED = 64, - PROJECTILE_FLAG_BOUNCESOFFSPRITES = 128, - PROJECTILE_FLAG_SPIT = 256, - PROJECTILE_FLAG_COOLEXPLOSION1 = 512, - PROJECTILE_FLAG_BLOOD = 1024, - PROJECTILE_FLAG_LOSESVELOCITY = 2048, - PROJECTILE_FLAG_NOAIM = 4096, - PROJECTILE_FLAG_RANDDECALSIZE = 8192, - PROJECTILE_FLAG_EXPLODEONTIMER = 16384, - PROJECTILE_FLAG_RPG_IMPACT = 32768, - PROJECTILE_FLAG_RADIUS_PICNUM = 65536, - PROJECTILE_FLAG_ACCURATE_AUTOAIM = 131072, - PROJECTILE_FLAG_FORCEIMPACT = 262144 +enum ProjectileFlags_t { + PROJECTILE_HITSCAN = 1, + PROJECTILE_RPG = 2, + PROJECTILE_BOUNCESOFFWALLS = 4, + PROJECTILE_BOUNCESOFFMIRRORS = 8, + PROJECTILE_KNEE = 16, + PROJECTILE_WATERBUBBLES = 32, + PROJECTILE_TIMED = 64, + PROJECTILE_BOUNCESOFFSPRITES = 128, + PROJECTILE_SPIT = 256, + PROJECTILE_COOLEXPLOSION1 = 512, + PROJECTILE_BLOOD = 1024, + PROJECTILE_LOSESVELOCITY = 2048, + PROJECTILE_NOAIM = 4096, + PROJECTILE_RANDDECALSIZE = 8192, + PROJECTILE_EXPLODEONTIMER = 16384, + PROJECTILE_RPG_IMPACT = 32768, + PROJECTILE_RADIUS_PICNUM = 65536, + PROJECTILE_ACCURATE_AUTOAIM = 131072, + PROJECTILE_FORCEIMPACT = 262144 }; -extern projectile_t projectile[MAXTILES], defaultprojectile[MAXTILES]; +extern projectile_t ProjectileData[MAXTILES], DefaultProjectileData[MAXTILES]; // logo control -enum logoflags { - LOGO_FLAG_ENABLED = 1, - LOGO_FLAG_PLAYANIM = 2, - LOGO_FLAG_PLAYMUSIC = 4, - LOGO_FLAG_3DRSCREEN = 8, - LOGO_FLAG_TITLESCREEN = 16, - LOGO_FLAG_DUKENUKEM = 32, - LOGO_FLAG_THREEDEE = 64, - LOGO_FLAG_PLUTOPAKSPRITE = 128, - LOGO_FLAG_SHAREWARESCREENS = 256, - LOGO_FLAG_TENSCREEN = 512 +enum LogoFlags_t { + LOGO_ENABLED = 1, + LOGO_PLAYANIM = 2, + LOGO_PLAYMUSIC = 4, + LOGO_3DRSCREEN = 8, + LOGO_TITLESCREEN = 16, + LOGO_DUKENUKEM = 32, + LOGO_THREEDEE = 64, + LOGO_PLUTOPAKSPRITE = 128, + LOGO_SHAREWARESCREENS = 256, + LOGO_TENSCREEN = 512 }; -extern int g_NumPalettes; -extern int g_ScriptDebug; +extern int g_numPalettes; +extern int g_scriptDebug; #define MAXCHEATLEN 20 -#define NUMCHEATCODES (signed int)(sizeof(cheatstrings)/sizeof(cheatstrings[0])) +#define NUMCHEATCODES (signed int)(sizeof(CheatStrings)/sizeof(CheatStrings[0])) -extern char cheatkey[2]; -extern char cheatstrings[][MAXCHEATLEN]; +extern char CheatKeys[2]; +extern char CheatStrings[][MAXCHEATLEN]; -extern short weapon_sprites[MAX_WEAPONS]; +extern short WeaponPickupSprites[MAX_WEAPONS]; -extern int redefined_quote_count; +extern int g_numQuoteRedefinitions; extern char setupfilename[BMAX_PATH]; @@ -1023,26 +998,26 @@ typedef struct { short headspritestat[MAXSTATUS+1]; short prevspritestat[MAXSPRITES]; short nextspritestat[MAXSPRITES]; - short numcyclers; + short g_numCyclers; short cyclers[MAXCYCLERS][6]; - playerspawn_t g_PlayerSpawnPoints[MAXPLAYERS]; - short numanimwalls; - short spriteq[1024],spriteqloc; + PlayerSpawn_t g_playerSpawnPoints[MAXPLAYERS]; + short g_numAnimWalls; + short SpriteDeletionQueue[1024],g_spriteDeleteQueuePos; animwalltype animwall[MAXANIMWALLS]; int msx[2048], msy[2048]; - short mirrorwall[64], mirrorsector[64], mirrorcnt; + short g_mirrorWall[64], g_mirrorSector[64], g_mirrorCount; char show2dsector[(MAXSECTORS+7)>>3]; - short numclouds,clouds[128],cloudx[128],cloudy[128]; - actordata_t hittype[MAXSPRITES]; + short g_numClouds,clouds[128],cloudx[128],cloudy[128]; + actordata_t ActorExtra[MAXSPRITES]; short pskyoff[MAXPSKYTILES], pskybits; - int animategoal[MAXANIMATES], animatevel[MAXANIMATES], animatecnt; + int animategoal[MAXANIMATES], animatevel[MAXANIMATES], g_animateCount; short animatesect[MAXANIMATES]; int animateptr[MAXANIMATES]; - char numplayersprites; - char earthquaketime; + char g_numPlayerSprites; + char g_earthquakeTime; int lockclock; - int randomseed, global_random; + int randomseed, g_globalRandom; char scriptptrs[MAXSPRITES]; intptr_t *vars[MAXGAMEVARS]; } mapstate_t; @@ -1053,10 +1028,10 @@ typedef struct { mapstate_t *savedstate; } map_t; -extern map_t map[(MAXVOLUMES+1)*MAXLEVELS]; // +1 volume for "intro", "briefing" music +extern map_t MapInfo[(MAXVOLUMES+1)*MAXLEVELS]; // +1 volume for "intro", "briefing" music typedef struct { - player_struct *ps; + DukePlayer_t *ps; input_t *sync; int32 movefifoend, syncvalhead, myminlag; @@ -1064,11 +1039,11 @@ typedef struct { char vote, gotvote, playerreadyflag, playerquitflag; char user_name[32]; - char syncval[SYNCFIFOSIZ][MAXSYNCBYTES]; + char syncval[SYNCFIFOSIZ][MAXSYNCBYTES]; } playerdata_t; extern input_t inputfifo[MOVEFIFOSIZ][MAXPLAYERS]; -extern playerspawn_t g_PlayerSpawnPoints[MAXPLAYERS]; +extern PlayerSpawn_t g_playerSpawnPoints[MAXPLAYERS]; extern playerdata_t g_player[MAXPLAYERS]; #include "funct.h" @@ -1089,6 +1064,37 @@ extern struct HASH_table arrayH; extern struct HASH_table keywH; extern struct HASH_table gamefuncH; +enum DukePacket_t +{ + PACKET_TYPE_MASTER_TO_SLAVE, + PACKET_TYPE_SLAVE_TO_MASTER, + PACKET_TYPE_BROADCAST, + SERVER_GENERATED_BROADCAST, + PACKET_TYPE_VERSION, + + /* don't change anything above this line */ + + PACKET_TYPE_MESSAGE, + + PACKET_TYPE_NEW_GAME, + PACKET_TYPE_RTS, + PACKET_TYPE_MENU_LEVEL_QUIT, + PACKET_TYPE_WEAPON_CHOICE, + PACKET_TYPE_PLAYER_OPTIONS, + PACKET_TYPE_PLAYER_NAME, + + PACKET_TYPE_USER_MAP, + + PACKET_TYPE_MAP_VOTE, + PACKET_TYPE_MAP_VOTE_INITIATE, + PACKET_TYPE_MAP_VOTE_CANCEL, + + PACKET_TYPE_LOAD_GAME, + PACKET_TYPE_NULL_PACKET, + PACKET_TYPE_PLAYER_READY, + PACKET_TYPE_QUIT = 255 // should match mmulti I think +}; + #ifdef __cplusplus } #endif diff --git a/polymer/eduke32/source/funct.h b/polymer/eduke32/source/funct.h index 85b004806..eedf7d710 100644 --- a/polymer/eduke32/source/funct.h +++ b/polymer/eduke32/source/funct.h @@ -26,50 +26,50 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define __funct_h__ extern void sendscore(const char *s); -extern void SoundStartup(void); -extern void SoundShutdown(void); -extern void MusicStartup(void); -extern void MusicShutdown(void); -extern void intomenusounds(void); -extern int playmusic(const char *fn, const int sel); -extern int loadsound(unsigned num); -extern int xyzsound(int num,int i,int x,int y,int z); -extern void sound(int num); -extern int spritesound(unsigned int num,int i); -extern void stopsound(int num); -extern void stopenvsound(int num,int i); +extern void S_SoundStartup(void); +extern void S_SoundShutdown(void); +extern void S_MusicStartup(void); +extern void S_MusicShutdown(void); +extern void S_MenuSound(void); +extern int S_PlayMusic(const char *fn, const int sel); +extern int S_LoadSound(unsigned num); +extern int S_PlaySoundXYZ(int num,int i,int x,int y,int z); +extern void S_PlaySound(int num); +extern int A_PlaySound(unsigned int num,int i); +extern void S_StopSound(int num); +extern void S_StopEnvSound(int num,int i); extern void pan3dsound(void); -extern void testcallback(unsigned int num); -extern void clearsoundlocks(void); -extern int callsound(int sn,int whatsprite); +extern void S_TestSoundCallback(unsigned int num); +extern void S_ClearSoundLocks(void); +extern int A_CallSound(int sn,int whatsprite); extern int check_activator_motion(int lotag); -extern int isadoorwall(int dapic); +extern int CheckDoorTile(int dapic); extern int isanunderoperator(int lotag); extern int isanearoperator(int lotag); -extern inline int checkcursectnums(int sect); +extern inline int CheckPlayerInSector(int sect); extern int ldist(spritetype *s1,spritetype *s2); extern int dist(spritetype *s1,spritetype *s2); -extern int findplayer(spritetype *s,int *d); -extern int findotherplayer(int p,int *d); -extern void doanimations(void); -extern int getanimationgoal(int *animptr); -extern int setanimation(int animsect,int *animptr,int thegoal,int thevel); -extern void animatecamsprite(void); -extern void animatewalls(void); -extern int activatewarpelevators(int s,int d); -extern void operatesectors(int sn,int ii); -extern void operaterespawns(int low); -extern void operateactivators(int low,int snum); -extern void operatemasterswitches(int low); -extern void operateforcefields(int s,int low); -extern int checkhitswitch(int snum,int w,int switchtype); +extern int A_FindPlayer(spritetype *s,int *d); +extern int P_FindOtherPlayer(int p,int *d); +extern void G_DoSectorAnimations(void); +extern int GetAnimationGoal(int *animptr); +extern int SetAnimation(int animsect,int *animptr,int thegoal,int thevel); +extern void G_AnimateCamSprite(void); +extern void G_AnimateWalls(void); +extern int G_ActivateWarpElevators(int s,int d); +extern void G_OperateSectors(int sn,int ii); +extern void G_OperateRespawns(int low); +extern void G_OperateActivators(int low,int snum); +extern void G_OperateMasterSwitches(int low); +extern void G_OperateForceFields(int s,int low); +extern int P_ActivateSwitch(int snum,int w,int switchtype); extern void activatebysector(int sect,int j); -extern void checkhitwall(int spr,int dawallnum,int x,int y,int z,int atwith); -extern void checkplayerhurt(player_struct *p,int j); -extern int checkhitceiling(int sn); -extern void checkhitsprite(int i,int sn); +extern void A_DamageWall(int spr,int dawallnum,int x,int y,int z,int atwith); +extern void P_CheckTouchDamage(DukePlayer_t *p,int j); +extern int Sect_DamageCeiling(int sn); +extern void A_DamageObject(int i,int sn); extern void allignwarpelevators(void); -extern void sharedkeys(int snum); +extern void G_HandleSharedKeys(int snum); extern void checksectors(int snum); extern int32 RTS_AddFile(const char *filename); extern void RTS_Init(const char *filename); @@ -78,76 +78,75 @@ extern int32 RTS_SoundLength(int32 lump); extern const char *RTS_GetSoundName(int32 i); extern void RTS_ReadLump(int32 lump,void *dest); extern void *RTS_GetSound(int32 lump); -extern void docacheit(void); +extern void G_CacheMapData(void); extern void xyzmirror(int i,int wn); -extern void vscrn(void); -extern void pickrandomspot(int snum); -extern void resetweapons(int snum); -extern void resetinventory(int snum); -extern void newgame(int vn,int ln,int sk); -extern void resettimevars(void); +extern void G_UpdateScreenArea(void); +extern void P_RandomSpawnPoint(int snum); +extern void P_ResetWeapons(int snum); +extern void P_ResetInventory(int snum); +extern void G_NewGame(int vn,int ln,int sk); +extern void G_ResetTimers(void); extern void waitforeverybody(void); -extern void cacheit(void); extern void clearfifo(void); -extern void resetmys(void); -extern int enterlevel(int g); -extern void backtomenu(void); -extern void setpal(player_struct *p); -extern void quickkill(player_struct *p); -extern int hits(int i); -extern int hitasprite(int i,short *hitsp); -extern int shoot(int i,int atwith); -extern void displaymasks(int snum); -extern void displayweapon(int snum); +extern void Net_ResetPrediction(void); +extern int G_EnterLevel(int g); +extern void G_BackToMenu(void); +extern void P_UpdateScreenPal(DukePlayer_t *p); +extern void P_QuickKill(DukePlayer_t *p); +extern int A_GetHitscanRange(int i); +extern int A_CheckHitSprite(int i,short *hitsp); +extern int A_Shoot(int i,int atwith); +extern void P_DisplayScubaMask(int snum); +extern void P_DisplayWeapons(int snum); extern void getinput(int snum); -extern void checkweapons(player_struct *p); -extern void processinput(int snum); -extern void cmenu(int cm); -extern void savetemp(const char *fn,int daptr,int dasiz); -// extern int loadpheader(char spot,int32 *vn,int32 *ln,int32 *psk,int32 *numplr); -extern int loadplayer(int spot); -extern int saveplayer(int spot); +extern void P_DropWeapon(DukePlayer_t *p); +extern void P_ProcessInput(int snum); +extern void ChangeToMenu(int cm); +// extern void savetemp(const char *fn,int daptr,int dasiz); +// extern int G_LoadSaveHeader(char spot,int32 *vn,int32 *ln,int32 *psk,int32 *numplr); +extern int G_LoadPlayer(int spot); +extern int G_SavePlayer(int spot); extern int menutext_(int x,int y,int s,int p,char *t,int bits); #define menutext(x,y,s,p,t) menutext_(x,y,s,p,(char *)stripcolorcodes(menutextbuf,t),10+16) -extern void menus(void); -extern void palto(int r,int g,int b,int e); -extern void playanm(const char *fn,char); -extern int getincangle(int a,int na); -extern void getglobalz(int iActor); -extern void makeitfall(int iActor); -extern void loadefs(const char *fn); -extern int furthestangle(int iActor,int angs); -extern void execute(int iActor,int iPlayer,int lDist); +extern void M_DisplayMenus(void); +extern void G_FadePalette(int r,int g,int b,int e); +extern void G_PlayAnim(const char *fn,char); +extern int G_GetAngleDelta(int a,int na); +extern void A_GetZLimits(int iActor); +extern void A_Fall(int iActor); +extern void C_Compile(const char *fn); +extern int A_GetFurthestAngle(int iActor,int angs); +extern void A_Execute(int iActor,int iPlayer,int lDist); extern void overwritesprite(int thex,int they,int tilenum,int shade,int stat,int dapalnum); extern void gamenumber(int x,int y,int n,int s); -extern void Shutdown(void); +extern void G_Shutdown(void); extern void getpackets(void); -extern void check_fta_sounds(int i); -extern inline int inventory(spritetype *s); -extern inline int badguy(spritetype *s); -extern int badguypic(int pn); -extern void myos(int x,int y,int tilenum,int shade,int orientation); -extern void myospal(int x,int y,int tilenum,int shade,int orientation,int p); -extern void displayfragbar(void); -extern void FTA(int q,player_struct *p); -extern void gameexit(const char *t); -extern inline int strget(int x,int y,char *t,int dalen,int c); -extern void displayrest(int smoothratio); +extern void A_PlayAlertSound(int i); +extern inline int A_CheckInventorySprite(spritetype *s); +extern inline int A_CheckEnemySprite(spritetype *s); +extern int A_CheckEnemyTile(int pn); +extern void G_DrawTile(int x,int y,int tilenum,int shade,int orientation); +extern void G_DrawTilePal(int x,int y,int tilenum,int shade,int orientation,int p); +extern void G_DrawFrags(void); +extern void P_DoQuote(int q,DukePlayer_t *p); +extern void G_GameExit(const char *t); +extern inline int G_EnterText(int x,int y,char *t,int dalen,int c); +extern void G_DisplayRest(int smoothratio); extern void updatesectorz(int x,int y,int z,short *sectnum); -extern void drawbackground(void); -extern void displayrooms(int snum,int smoothratio); -extern int EGS(int whatsect,int s_x,int s_y,int s_z,int s_pn,int s_s,int s_xr,int s_yr,int s_a,int s_ve,int s_zv,int s_ow,int s_ss); -extern int wallswitchcheck(int i); -extern int spawn(int j,int pn); -extern void animatesprites(int x,int y,int a,int smoothratio); +extern void G_DrawBackground(void); +extern void G_DrawRooms(int snum,int smoothratio); +extern int A_InsertSprite(int whatsect,int s_x,int s_y,int s_z,int s_pn,int s_s,int s_xr,int s_yr,int s_a,int s_ve,int s_zv,int s_ow,int s_ss); +extern int A_CheckSwitchTile(int i); +extern int A_Spawn(int j,int pn); +extern void G_DoSpriteAnimations(int x,int y,int a,int smoothratio); extern int main(int argc,char **argv); -extern void opendemowrite(void); -extern void closedemowrite(void); -extern void dobonus(int bonusonly); -extern void lotsofglass(int i,int wallnum,int n); -extern void spriteglass(int i,int n); -extern void ceilingglass(int i,int sectnum,int n); -extern void lotsofcolourglass(int i,int wallnum,int n); +extern void G_OpenDemoWrite(void); +extern void G_CloseDemoWrite(void); +extern void G_BonusScreen(int bonusonly); +extern void A_SpawnWallGlass(int i,int wallnum,int n); +extern void A_SpawnGlass(int i,int n); +extern void A_SpawnCeilingGlass(int i,int sectnum,int n); +extern void A_SpawnRandomGlass(int i,int wallnum,int n); extern inline int GetTime(void); extern void CONFIG_GetSetupFilename(void); extern int32 CONFIG_FunctionNameToNum(char *func); @@ -156,46 +155,46 @@ extern int32 CONFIG_AnalogNameToNum(char *func); extern char *CONFIG_AnalogNumToName(int32 func); extern void CONFIG_SetDefaults(void); extern void CONFIG_ReadKeys(void); -extern void readsavenames(void); +extern void ReadSaveGameHeaders(void); extern int32 CONFIG_ReadSetup(void); extern void CONFIG_WriteSetup(void); -extern inline void updateinterpolations(void); -extern void setinterpolation(int *posptr); -extern void stopinterpolation(int *posptr); -extern void dointerpolations(int smoothratio); -extern inline void restoreinterpolations(void); -extern inline int ceilingspace(int sectnum); -extern inline int floorspace(int sectnum); -extern void addammo(int weapon,player_struct *p,int amount); -extern void addweaponnoswitch(player_struct *p,int weapon); -extern void addweapon(player_struct *p,int weapon); -extern void checkavailinven(player_struct *p); -extern void checkavailweapon(player_struct *p); -extern void hitradius(int i,int r,int hp1,int hp2,int hp3,int hp4); -extern int movesprite(int spritenum,int xchange,int ychange,int zchange,unsigned int cliptype); -extern inline int ssp(int i,unsigned int cliptype); -extern void insertspriteq(int i); -extern void lotsofmoneymailpaper(int sp,int n,int pic); -extern void guts(int sp,int gtype,int n); -extern void setsectinterpolate(int i); -extern void clearsectinterpolate(int i); -extern int ifhitbyweapon(int sn); -extern void moveobjects(void); -extern void movecyclers(void); -extern void movedummyplayers(void); +extern inline void G_UpdateInterpolations(void); +extern void G_SetInterpolation(int *posptr); +extern void G_StopInterpolation(int *posptr); +extern void G_DoInterpolations(int smoothratio); +extern inline void G_RestoreInterpolations(void); +extern inline int G_CheckForSpaceCeiling(int sectnum); +extern inline int G_CheckForSpaceFloor(int sectnum); +extern void P_AddAmmo(int weapon,DukePlayer_t *p,int amount); +extern void P_AddWeaponNoSwitch(DukePlayer_t *p,int weapon); +extern void P_AddWeapon(DukePlayer_t *p,int weapon); +extern void P_SelectNextInventoryItem(DukePlayer_t *p); +extern void P_CheckWeapon(DukePlayer_t *p); +extern void A_RadiusDamage(int i,int r,int hp1,int hp2,int hp3,int hp4); +extern int A_MoveSprite(int spritenum,int xchange,int ychange,int zchange,unsigned int cliptype); +extern inline int A_SetSprite(int i,unsigned int cliptype); +extern void A_AddToDeleteQueue(int i); +extern void A_SpawnMultiple(int sp,int pic,int n); +extern void A_DoGuts(int sp,int gtype,int n); +extern void Sect_SetInterpolation(int i); +extern void Sect_ClearInterpolation(int i); +extern int A_IncurDamage(int sn); +extern void G_MoveWorld(void); +extern void A_MoveCyclers(void); +extern void A_MoveDummyPlayers(void); // game.c -extern inline void setstatusbarscale(int sc); +extern inline void G_SetStatusBarScale(int sc); -extern void setgamepalette(player_struct *player, char *pal, int set); +extern void SetGamePalette(DukePlayer_t *player, char *pal, int set); extern void fadepal(int r, int g, int b, int start, int end, int step); extern inline int gametext_z(int small, int starttile, int x,int y,const char *t,int s,int p,int orientation,int x1, int y1, int x2, int y2,int z); -extern void txdigitalnumberz(int starttile, int x,int y,int n,int s,int pal,int cs,int x1, int y1, int x2, int y2, int z); -extern void myosx(int x,int y,int tilenum,int shade,int orientation); -extern void myospalx(int x,int y,int tilenum,int shade,int orientation,int p); -extern void ResetGameVars(void); -extern void ResetActorGameVars(int iActor); +extern void G_DrawTXDigiNumZ(int starttile, int x,int y,int n,int s,int pal,int cs,int x1, int y1, int x2, int y2, int z); +extern void G_DrawTileSmall(int x,int y,int tilenum,int shade,int orientation); +extern void G_DrawTilePalSmall(int x,int y,int tilenum,int shade,int orientation,int p); +extern void Gv_ResetVarsToDefault(void); +extern void A_ResetGameVars(int iActor); extern int minitext_(int x,int y,const char *t,int s,int p,int sb); @@ -207,54 +206,55 @@ extern int minitext_(int x,int y,const char *t,int s,int p,int sb); #define gametextpal(x,y,t,s,p) gametext_z(0,STARTALPHANUM, x,y,t,s,p,26,0, 0, xdim-1, ydim-1, 65536) #define gametextpalbits(x,y,t,s,p,dabits) gametext_z(0,STARTALPHANUM, x,y,t,s,p,dabits,0, 0, xdim-1, ydim-1, 65536) -extern void setupdynamictostatic(); -extern void processnames(const char *szLabel, int lValue); +extern void G_InitDynamicTiles(); +extern void G_ProcessDynamicTileMapping(const char *szLabel, int lValue); -extern void LoadActor(int sActor); +extern void A_LoadActor(int sActor); -extern int GetGameVar(const char *szGameLabel, int lDefault, int iActor, int iPlayer); -extern void DumpGameVars(FILE *fp); +extern int Gv_GetVarByLabel(const char *szGameLabel, int lDefault, int iActor, int iPlayer); +extern void Gv_DumpValues(FILE *fp); // extern void AddLog(const char *psz, ...); -extern void ResetSystemDefaults(void); -extern void InitGameVarPointers(void); -extern void InitGameVars(void); -extern void SaveGameVars(FILE *fil); -extern int ReadGameVars(int fil); +extern void Gv_ResetSystemDefaults(void); +extern void Gv_InitWeaponPointers(void); +extern void Gv_Init(void); +extern void Gv_WriteSave(FILE *fil); +extern int Gv_ReadSave(int fil); -extern int GetGameVarID(int id, int iActor, int iPlayer); -extern void SetGameVarID(int id, int lValue, int iActor, int iPlayer); +extern int Gv_GetVar(int id, int iActor, int iPlayer); +extern void Gv_SetVar(int id, int lValue, int iActor, int iPlayer); // extern void SetGameArrayID(int id,int index, int lValue); -extern int AddGameVar(const char *pszLabel, int lValue, unsigned int dwFlags); -extern int AddGameArray(const char *pszLabel, int asize); -extern void ReportError(int iError); +extern int Gv_SetupVar(const char *pszLabel, int lValue, unsigned int dwFlags); +extern int Gv_AddArray(const char *pszLabel, int asize); +extern void C_ReportError(int iError); extern void onvideomodechange(int newmode); -extern void OnEvent(int iEventID, int sActor, int sPlayer, int lDist); +extern void X_OnEvent(int iEventID, int sActor, int sPlayer, int lDist); -extern int isspritemakingsound(int i, int num); -extern int issoundplaying(int i, int num); -extern void stopspritesound(int num, int i); -extern void updateplayer(void); -extern void sendboardname(void); -extern void sendquit(void); +extern int A_CheckSoundPlaying(int i, int num); +extern int S_CheckSoundPlaying(int i, int num); +extern void A_StopSound(int num, int i); +extern void G_UpdatePlayerFromMenu(void); +extern void Net_SendPlayerName(void); +extern void Net_SendUserMapName(void); +extern void Net_SendQuit(void); -extern void adduserquote(const char *daquote); -extern void mpchangemap(int volume, int level); +extern void G_AddUserQuote(const char *daquote); +extern void Net_NewGame(int volume, int level); -extern inline int checkspriteflags(int iActor, int iType); -extern inline int checkspriteflagsp(int iPicnum, int iType); +extern inline int A_CheckSpriteFlags(int iActor, int iType); +extern inline int A_CheckSpriteTileFlags(int iPicnum, int iType); -extern int getteampal(int team); +extern int G_GetTeamPalette(int team); extern void se40code(int x,int y,int z,int a,int h, int smoothratio); -extern void FreeMapState(int mapnum); -extern void getlevelfromfilename(const char *fn, char *volume, char *level); +extern void G_FreeMapState(int mapnum); +extern void G_FindLevelForFilename(const char *fn, char *volume, char *level); -extern void GetCrosshairColor(void); -extern void SetCrosshairColor(int r, int g, int b); +extern void G_GetCrosshairColor(void); +extern void G_SetCrosshairColor(int r, int g, int b); extern int kopen4loadfrommod(char *filename, char searchfirst); #endif // __funct_h__ diff --git a/polymer/eduke32/source/function.h b/polymer/eduke32/source/function.h index cde8258b2..a034beaae 100644 --- a/polymer/eduke32/source/function.h +++ b/polymer/eduke32/source/function.h @@ -36,14 +36,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern "C" { #endif -#define NUMKEYENTRIES 53 -#define NUMGAMEFUNCTIONS 53 +#define NUMKEYENTRIES 54 +#define NUMGAMEFUNCTIONS 54 #define MAXGAMEFUNCLEN 32 extern char gamefunctions[NUMGAMEFUNCTIONS][MAXGAMEFUNCLEN]; extern char keydefaults[NUMGAMEFUNCTIONS*3][MAXGAMEFUNCLEN]; -enum gamefuncs +enum GameFunction_t { gamefunc_Move_Forward, gamefunc_Move_Backward, @@ -97,7 +97,8 @@ enum gamefuncs gamefunc_Quick_Kick, gamefunc_Next_Weapon, gamefunc_Previous_Weapon, - gamefunc_Show_Console + gamefunc_Show_Console, + gamefunc_Show_DukeMatch_Scores }; #ifdef __cplusplus }; diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index f50b5c170..f26dc32d4 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -51,32 +51,32 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include #include -extern int getversionfromwebsite(char *buffer); +extern int G_GetVersionFromWebsite(char *buffer); #define UPDATEINTERVAL 604800 // 1w #else static int usecwd = 0; #endif /* _WIN32 */ -int checkCON = 1; +int g_scriptSanityChecks = 1; #define IDFSIZE 479985668 #define IDFILENAME "DUKE3D.IDF" #define TIMERUPDATESIZ 32 -int cameradist = 0, cameraclock = 0; +int g_cameraDistance = 0, g_cameraClock = 0; static int playerswhenstarted; static int qe,cp; -static int g_CommandSetup = 0; -int g_NoSetup = 0; -static int g_NoAutoLoad = 0; -static int g_NoSound = 0; -static int g_NoMusic = 0; +static int g_commandSetup = 0; +int g_noSetup = 0; +static int g_noAutoLoad = 0; +static int g_noSound = 0; +static int g_noMusic = 0; static char *CommandMap = NULL; static char *CommandName = NULL; #ifndef RANCID_NETWORKING static char *CommandNet = NULL; #endif -static int g_KeepAddr = 0; +static int g_keepAddr = 0; int CommandWeaponChoice = 0; static struct strllist { @@ -98,7 +98,7 @@ int voting = -1; int vote_map = -1, vote_episode = -1; int recfilep,totalreccnt; -int debug_on = 0,actor_tog = 0; +int debug_on = 0,g_noEnemies = 0; static char *rtsptr; //extern char syncstate; @@ -106,9 +106,9 @@ extern int numlumps; static FILE *frecfilep = (FILE *)NULL; -int restorepalette,screencapt; -static int g_NoLogoAnim = 0; -static int g_NoLogo = 0; +int g_restorePalette,g_screenCapture; +static int g_noLogoAnim = 0; +static int g_noLogo = 0; static int sendmessagecommand = -1; char defaultduke3dgrp[BMAX_PATH] = "duke3d.grp"; @@ -124,7 +124,7 @@ extern char TEXCACHEDIR[BMAX_PATH]; extern int lastvisinc; int g_Shareware = 0; -int g_GameType = 0; +int g_gameType = 0; #define MAXUSERQUOTES 6 static int quotebot, quotebotgoal; @@ -138,13 +138,13 @@ int tempwallptr; static int nonsharedtimer; -static void cameratext(short i); -static int moveloop(void); -static void doorders(void); -static void fakedomovethings(void); -static void fakedomovethingscorrect(void); -static int domovethings(void); -static int playback(void); +static void G_DrawCameraText(short i); +static int G_MoveLoop(void); +static void G_DoOrderScreen(void); +static void Net_DoPrediction(void); +static void Net_CorrectPrediction(void); +static int G_DoMoveThings(void); +static int G_PlaybackDemo(void); static char recbuf[180]; @@ -160,17 +160,17 @@ int althud_flashing = 1; int hud_glowingquotes = 1; int hud_showmapname = 1; -int leveltexttime = 0; +int g_levelTextTime = 0; int r_maxfps = 0; -unsigned int g_FrameDelay = 0; +unsigned int g_frameDelay = 0; #ifdef RENDERTYPEWIN extern char forcegl; #endif #ifdef _WIN32 -int getversionfromwebsite(char *buffer) // FIXME: this probably belongs in game land +int G_GetVersionFromWebsite(char *buffer) // FIXME: this probably belongs in game land { int wsainitialized = 0; int bytes_sent, i=0, j=0; @@ -188,7 +188,7 @@ int getversionfromwebsite(char *buffer) // FIXME: this probably belongs in game if (WSAStartup(0x101,&ws) == SOCKET_ERROR) { - initprintf("update: Winsock error in getversionfromwebsite() (%d)\n",errno); + initprintf("update: Winsock error in G_GetVersionFromWebsite() (%d)\n",errno); return(0); } wsainitialized = 1; @@ -197,7 +197,7 @@ int getversionfromwebsite(char *buffer) // FIXME: this probably belongs in game if ((h=gethostbyname(host)) == NULL) { - initprintf("update: gethostbyname() error in getversionfromwebsite() (%d)\n",h_errno); + initprintf("update: gethostbyname() error in G_GetVersionFromWebsite() (%d)\n",h_errno); return(0); } @@ -212,20 +212,20 @@ int getversionfromwebsite(char *buffer) // FIXME: this probably belongs in game if (mysock == INVALID_SOCKET) { - initprintf("update: socket() error in getversionfromwebsite() (%d)\n",errno); + initprintf("update: socket() error in G_GetVersionFromWebsite() (%d)\n",errno); return(0); } initprintf("Connecting to \"http://%s\"\n",host); if (connect(mysock, (struct sockaddr *)&dest_addr, sizeof(struct sockaddr)) == SOCKET_ERROR) { - initprintf("update: connect() error in getversionfromwebsite() (%d)\n",errno); + initprintf("update: connect() error in G_GetVersionFromWebsite() (%d)\n",errno); return(0); } bytes_sent = send(mysock, req, strlen(req), 0); if (bytes_sent == SOCKET_ERROR) { - initprintf("update: send() error in getversionfromwebsite() (%d)\n",errno); + initprintf("update: send() error in G_GetVersionFromWebsite() (%d)\n",errno); return(0); } @@ -317,10 +317,10 @@ static int getatoken(scriptfile *sf, tokenlist *tl, int ntokens) return T_ERROR; } -inline void setstatusbarscale(int sc) +inline void G_SetStatusBarScale(int sc) { ud.statusbarscale = min(100,max(10,sc)); - vscrn(); + G_UpdateScreenArea(); } static inline int sbarx(int x) @@ -376,7 +376,7 @@ static void patchstatusbar(int x1, int y1, int x2, int y2) // else rotatesprite(tx,ty,scl,0,BOTTOMSTATUSBAR,4,0,10+16+64,clx1,cly1,clx2+clofx-1,cly2+clofy-1); } -void setgamepalette(player_struct *player, char *pal, int set) +void SetGamePalette(DukePlayer_t *player, char *pal, int set) { if (player != g_player[screenpeek].ps) { @@ -523,7 +523,7 @@ int gametext_z(int small, int starttile, int x,int y,const char *t,int s,int p,i return (x); } -int gametextlen(int x,const char *t) +int G_GameTextLen(int x,const char *t) { int ac; @@ -609,7 +609,7 @@ static void allowtimetocorrecterrorswhenquitting(void) ready2send = 0; - for (j=7;j>=0;j--) + for (j=MAXPLAYERS-1;j>=0;j--) { oldtotalclock = totalclock; @@ -620,16 +620,16 @@ static void allowtimetocorrecterrorswhenquitting(void) } if (KB_KeyPressed(sc_Escape)) return; - packbuf[0] = 127; - for (i=connecthead;i>=0;i=connectpoint2[i]) + packbuf[0] = PACKET_TYPE_NULL_PACKET; + TRAVERSE_CONNECT(i) { if (i != myconnectindex) sendpacket(i,packbuf,1); - if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master + if ((!g_networkBroadcastMode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master } } } -void adduserquote(const char *daquote) +void G_AddUserQuote(const char *daquote) { int i; @@ -649,18 +649,8 @@ int lastpackettime = 0; #include "sync.c" -void getpackets(void) +void G_HandleSpecialKeys(void) { - int i, j, k, l; - int other; - int packbufleng; - int sb; - - input_t *osyn, *nsyn; - - sampletimer(); - AudioUpdate(); - CONTROL_ProcessBinds(); if (ALT_IS_PRESSED && KB_KeyPressed(sc_Enter)) @@ -669,19 +659,19 @@ void getpackets(void) { OSD_Printf(OSD_ERROR "Failed setting fullscreen video mode.\n"); if (setgamemode(ud.config.ScreenMode, ud.config.ScreenWidth, ud.config.ScreenHeight, ud.config.ScreenBPP)) - gameexit("Failed to recover from failure to set fullscreen video mode.\n"); + G_GameExit("Failed to recover from failure to set fullscreen video mode.\n"); } else ud.config.ScreenMode = !ud.config.ScreenMode; KB_ClearKeyDown(sc_Enter); - restorepalette = 1; - vscrn(); + g_restorePalette = 1; + G_UpdateScreenArea(); } if (KB_UnBoundKeyPressed(sc_F12)) { KB_ClearKeyDown(sc_F12); screencapture("duke0000.tga",0); - FTA(103,g_player[myconnectindex].ps); + P_DoQuote(103,g_player[myconnectindex].ps); } // only dispatch commands here when not in a game @@ -693,8 +683,22 @@ void getpackets(void) if (qe == 0 && KB_KeyPressed(sc_LeftControl) && KB_KeyPressed(sc_LeftAlt) && (KB_KeyPressed(sc_Delete)||KB_KeyPressed(sc_End))) { qe = 1; - gameexit("Quick Exit."); + G_GameExit("Quick Exit."); } +} + +void getpackets(void) +{ + int i, j, k, l; + int other; + int packbufleng; + + input_t *osyn, *nsyn; + + sampletimer(); + AudioUpdate(); + + G_HandleSpecialKeys(); if (numplayers < 2) return; while ((packbufleng = getpacket(&other,packbuf)) > 0) @@ -705,7 +709,7 @@ void getpackets(void) #endif switch (packbuf[0]) { - case 0: //[0] (receive master sync buffer) + case PACKET_TYPE_MASTER_TO_SLAVE: //[0] (receive master sync buffer) j = 1; if ((g_player[other].movefifoend&(TIMERUPDATESIZ-1)) == 0) @@ -721,9 +725,9 @@ void getpackets(void) nsyn = (input_t *)&inputfifo[(g_player[connecthead].movefifoend)&(MOVEFIFOSIZ-1)][0]; k = j; - for (i=connecthead;i>=0;i=connectpoint2[i]) - j += g_player[i].playerquitflag+g_player[i].playerquitflag; - for (i=connecthead;i>=0;i=connectpoint2[i]) + TRAVERSE_CONNECT(i) + j += g_player[i].playerquitflag+g_player[i].playerquitflag; + TRAVERSE_CONNECT(i) { if (g_player[i].playerquitflag == 0) continue; @@ -751,7 +755,7 @@ void getpackets(void) if (l&1024) nsyn[i].extbits = ((nsyn[i].extbits&0xff00ffff)|((int)packbuf[j++])<<16); if (l&2048) nsyn[i].extbits = ((nsyn[i].extbits&0x00ffffff)|((int)packbuf[j++])<<24); */ - if (nsyn[i].bits&(1<<26)) g_player[i].playerquitflag = 0; + if (TEST_SYNC_KEY(nsyn[i].bits,SK_GAMEQUIT)) g_player[i].playerquitflag = 0; g_player[i].movefifoend++; } @@ -765,38 +769,38 @@ void getpackets(void) } j++; } */ - while (j != packbufleng) - { - for (i = connecthead; i >= 0; i = connectpoint2[i]) - { - if (i != myconnectindex) - { - for (sb = 0; sb < NumSyncBytes; sb++) + /* while (j != packbufleng) { - g_player[i].syncval[g_player[i].syncvalhead & (SYNCFIFOSIZ - 1)][sb] = packbuf[j + sb]; - } + for (i = connecthead; i >= 0; i = connectpoint2[i]) + { + if (i != myconnectindex) + { + for (sb = 0; sb < NumSyncBytes; sb++) + { + g_player[i].syncval[g_player[i].syncvalhead & (SYNCFIFOSIZ - 1)][sb] = packbuf[j + sb]; + } - g_player[i].syncvalhead++; - } - } + g_player[i].syncvalhead++; + } + } - j += NumSyncBytes; - } + j += NumSyncBytes; + } */ GetSyncInfoFromPacket(packbuf, packbufleng, &j, other); - /* for (i=connecthead;i>=0;i=connectpoint2[i]) - if (i != myconnectindex) - for (j=movesperpacket-1;j>=1;j--) - { - copybufbyte(&nsyn[i],&inputfifo[g_player[i].movefifoend&(MOVEFIFOSIZ-1)][i],sizeof(input_t)); - g_player[i].movefifoend++; - } - */ - movefifosendplc += movesperpacket; + TRAVERSE_CONNECT(i) + if (i != myconnectindex) + for (j=g_movesPerPacket-1;j>=1;j--) + { + copybufbyte(&nsyn[i],&inputfifo[g_player[i].movefifoend&(MOVEFIFOSIZ-1)][i],sizeof(input_t)); + g_player[i].movefifoend++; + } + + movefifosendplc += g_movesPerPacket; break; - case 1: //[1] (receive slave sync buffer) + case PACKET_TYPE_SLAVE_TO_MASTER: //[1] (receive slave sync buffer) j = 3; k = packbuf[1] + (int)(packbuf[2]<<8); @@ -826,7 +830,7 @@ void getpackets(void) } */ GetSyncInfoFromPacket(packbuf, packbufleng, &j, other); - for (i=movesperpacket-1;i>=1;i--) + for (i=g_movesPerPacket-1;i>=1;i--) { copybufbyte(&nsyn[other],&inputfifo[g_player[other].movefifoend&(MOVEFIFOSIZ-1)][other],sizeof(input_t)); g_player[other].movefifoend++; @@ -834,10 +838,10 @@ void getpackets(void) break; - case 16: - g_player[other].movefifoend = movefifoplc = movefifosendplc = fakemovefifoplc = 0; + case PACKET_TYPE_BROADCAST: + g_player[other].movefifoend = movefifoplc = movefifosendplc = predictfifoplc = 0; g_player[other].syncvalhead = syncvaltottail = 0L; - case 17: + case SERVER_GENERATED_BROADCAST: j = 1; if ((g_player[other].movefifoend&(TIMERUPDATESIZ-1)) == 0) @@ -871,14 +875,12 @@ void getpackets(void) if (k&2048) nsyn[other].extbits = ((nsyn[other].extbits&0x00ffffff)|((int)packbuf[j++])<<24); */ g_player[other].movefifoend++; - for (i=movesperpacket-1;i>=1;i--) + for (i=g_movesPerPacket-1;i>=1;i--) { copybufbyte(&nsyn[other],&inputfifo[g_player[other].movefifoend&(MOVEFIFOSIZ-1)][other],sizeof(input_t)); g_player[other].movefifoend++; } - if (j > packbufleng) - initprintf("INVALID GAME PACKET!!! (packet %d, %d too many bytes (%d %d))\n",packbuf[0],j-packbufleng,packbufleng,k); /* while (j < packbufleng) { @@ -888,24 +890,27 @@ void getpackets(void) */ GetSyncInfoFromPacket(packbuf, packbufleng, &j, other); + if (j > packbufleng) + initprintf("INVALID GAME PACKET!!! (packet %d, %d too many bytes (%d %d))\n",packbuf[0],j-packbufleng,packbufleng,k); + break; - case 127: + case PACKET_TYPE_NULL_PACKET: break; - case 250: + case PACKET_TYPE_PLAYER_READY: if (g_player[other].playerreadyflag == 0) initprintf("Player %d is ready\n", other); g_player[other].playerreadyflag++; return; - case 255: - gameexit(" "); + case PACKET_TYPE_QUIT: + G_GameExit(" "); break; default: switch (packbuf[0]) { - case 4: + case PACKET_TYPE_MESSAGE: //slaves in M/S mode only send to master - if ((!networkmode) && (myconnectindex == connecthead)) + if ((!g_networkBroadcastMode) && (myconnectindex == connecthead)) { if (packbuf[1] == 255) { @@ -925,23 +930,23 @@ void getpackets(void) Bstrcpy(recbuf,packbuf+2); recbuf[packbufleng-2] = 0; - adduserquote(recbuf); - sound(EXITMENUSOUND); + G_AddUserQuote(recbuf); + S_PlaySound(EXITMENUSOUND); pus = NUMPAGES; pub = NUMPAGES; break; - case 5: + case PACKET_TYPE_NEW_GAME: //Slaves in M/S mode only send to master //Master re-transmits message to all others - if ((!networkmode) && (myconnectindex == connecthead)) + if ((!g_networkBroadcastMode) && (myconnectindex == connecthead)) for (i=connectpoint2[connecthead];i>=0;i=connectpoint2[i]) if (i != other) sendpacket(i,packbuf,packbufleng); if (vote_map != -1 || vote_episode != -1 || voting != -1) - adduserquote("VOTE SUCCEEDED"); + G_AddUserQuote("VOTE SUCCEEDED"); ud.m_level_number = ud.level_number = packbuf[1]; ud.m_volume_number = ud.volume_number = packbuf[2]; @@ -955,34 +960,47 @@ void getpackets(void) ud.m_ffire = ud.ffire = packbuf[10]; ud.m_noexits = ud.noexits = packbuf[11]; - for (i=connecthead;i>=0;i=connectpoint2[i]) + TRAVERSE_CONNECT(i) { - resetweapons(i); - resetinventory(i); + P_ResetWeapons(i); + P_ResetInventory(i); } - newgame(ud.volume_number,ud.level_number,ud.player_skill); + G_NewGame(ud.volume_number,ud.level_number,ud.player_skill); ud.coop = ud.m_coop; - if (enterlevel(MODE_GAME)) backtomenu(); + if (G_EnterLevel(MODE_GAME)) G_BackToMenu(); break; - case 6: + + case PACKET_TYPE_VERSION: //slaves in M/S mode only send to master //Master re-transmits message to all others - if ((!networkmode) && (myconnectindex == connecthead)) + if ((!g_networkBroadcastMode) && (myconnectindex == connecthead)) for (i=connectpoint2[connecthead];i>=0;i=connectpoint2[i]) if (i != other) sendpacket(i,packbuf,packbufleng); if (packbuf[2] != (char)atoi(s_builddate)) - gameexit("You cannot play with different versions of EDuke32!"); + { + initprintf("Player %d has version %d, expecting %d\n",packbuf[2],(char)atoi(s_builddate)); + G_GameExit("You cannot play with different versions of EDuke32!"); + } + if (packbuf[3] != BYTEVERSION) + { + initprintf("Player %d has version %d, expecting %d\n",packbuf[3],BYTEVERSION); + G_GameExit("You cannot play Duke with different versions!"); + } + break; + + case PACKET_TYPE_PLAYER_OPTIONS: + //slaves in M/S mode only send to master + //Master re-transmits message to all others + if ((!g_networkBroadcastMode) && (myconnectindex == connecthead)) + for (i=connectpoint2[connecthead];i>=0;i=connectpoint2[i]) + if (i != other) sendpacket(i,packbuf,packbufleng); other = packbuf[1]; - - for (i=3;packbuf[i];i++) - g_player[other].user_name[i-3] = packbuf[i]; - g_player[other].user_name[i-3] = 0; - i++; + i = 2; g_player[other].ps->aim_mode = packbuf[i++]; g_player[other].ps->auto_aim = packbuf[i++]; @@ -990,17 +1008,28 @@ void getpackets(void) g_player[other].ps->palookup = g_player[other].pcolor = packbuf[i++]; g_player[other].pteam = packbuf[i++]; - /* if(g_player[other].ps->team != j && sprite[g_player[other].ps->i].picnum == APLAYER) - { - hittype[g_player[other].ps->i].extra = 1000; - hittype[g_player[other].ps->i].picnum = APLAYERTOP; - } */ - break; - case 10: + + case PACKET_TYPE_PLAYER_NAME: //slaves in M/S mode only send to master //Master re-transmits message to all others - if ((!networkmode) && (myconnectindex == connecthead)) + if ((!g_networkBroadcastMode) && (myconnectindex == connecthead)) + for (i=connectpoint2[connecthead];i>=0;i=connectpoint2[i]) + if (i != other) sendpacket(i,packbuf,packbufleng); + + other = packbuf[1]; + + for (i=2;packbuf[i];i++) + g_player[other].user_name[i-2] = packbuf[i]; + g_player[other].user_name[i-2] = 0; + i++; + + break; + + case PACKET_TYPE_WEAPON_CHOICE: + //slaves in M/S mode only send to master + //Master re-transmits message to all others + if ((!g_networkBroadcastMode) && (myconnectindex == connecthead)) for (i=connectpoint2[connecthead];i>=0;i=connectpoint2[i]) if (i != other) sendpacket(i,packbuf,packbufleng); @@ -1012,10 +1041,10 @@ void getpackets(void) for (;i-j<10;i++) g_player[other].wchoice[i-j] = packbuf[i]; break; - case 7: + case PACKET_TYPE_RTS: //slaves in M/S mode only send to master //Master re-transmits message to all others - if ((!networkmode) && (myconnectindex == connecthead)) + if ((!g_networkBroadcastMode) && (myconnectindex == connecthead)) for (i=connectpoint2[connecthead];i>=0;i=connectpoint2[i]) if (i != other) sendpacket(i,packbuf,packbufleng); @@ -1028,10 +1057,10 @@ void getpackets(void) FX_PlayVOC3D(rtsptr,0,0,0,255,-packbuf[1]); else FX_PlayWAV3D(rtsptr,0,0,0,255,-packbuf[1]); - rtsplaying = 7; + g_RTSPlaying = 7; break; - case 254: + case PACKET_TYPE_MENU_LEVEL_QUIT: //slaves in M/S mode only send to master if (myconnectindex == connecthead) { @@ -1056,18 +1085,18 @@ void getpackets(void) ud.multimode--; Bsprintf(buf,"%s is history!",g_player[i].user_name); - adduserquote(buf); + G_AddUserQuote(buf); if (numplayers < 2) - sound(GENERIC_AMBIENCE17); + S_PlaySound(GENERIC_AMBIENCE17); - if(i == 0 && networkmode == 0) */ - gameexit("Game aborted from menu; disconnected."); + if(i == 0 && g_networkBroadcastMode == 0) */ + G_GameExit("Game aborted from menu; disconnected."); // } break; - case 9: + case PACKET_TYPE_USER_MAP: //slaves in M/S mode only send to master if (myconnectindex == connecthead) { @@ -1085,7 +1114,7 @@ void getpackets(void) if ((i = kopen4loadfrommod(boardfilename,0)) < 0) { Bmemset(boardfilename,0,sizeof(boardfilename)); - sendboardname(); + Net_SendUserMapName(); } else kclose(i); } @@ -1095,7 +1124,9 @@ void getpackets(void) break; - case 18: // map vote + case PACKET_TYPE_MAP_VOTE: + case PACKET_TYPE_MAP_VOTE_INITIATE: + case PACKET_TYPE_MAP_VOTE_CANCEL: if (myconnectindex == connecthead) { @@ -1105,26 +1136,34 @@ void getpackets(void) sendpacket(i,packbuf,packbufleng); } - switch (packbuf[1]) + switch (packbuf[0]) { - case 0: - if (voting == myconnectindex && g_player[(unsigned char)packbuf[2]].gotvote == 0) + case PACKET_TYPE_MAP_VOTE: + if (voting == myconnectindex && g_player[(unsigned char)packbuf[1]].gotvote == 0) { - g_player[(unsigned char)packbuf[2]].gotvote = 1; - g_player[(unsigned char)packbuf[2]].vote = packbuf[3]; - Bsprintf(tempbuf,"CONFIRMED VOTE FROM %s",g_player[(unsigned char)packbuf[2]].user_name); - adduserquote(tempbuf); + g_player[(unsigned char)packbuf[1]].gotvote = 1; + g_player[(unsigned char)packbuf[1]].vote = packbuf[2]; + Bsprintf(tempbuf,"CONFIRMED VOTE FROM %s",g_player[(unsigned char)packbuf[1]].user_name); + G_AddUserQuote(tempbuf); } break; - case 1: // call map vote - voting = packbuf[2]; - vote_episode = packbuf[3]; - vote_map = packbuf[4]; - Bsprintf(tempbuf,"%s^00 HAS CALLED A VOTE TO CHANGE MAP TO %s (E%dL%d)",g_player[(unsigned char)packbuf[2]].user_name,map[(unsigned char)(packbuf[3]*MAXLEVELS + packbuf[4])].name,packbuf[3]+1,packbuf[4]+1); - adduserquote(tempbuf); + case PACKET_TYPE_MAP_VOTE_INITIATE: // call map vote + /* if (g_networkBroadcastMode == 0 && packbuf[1] == connecthead) + break; // ignore this from master */ + voting = packbuf[1]; + vote_episode = packbuf[2]; + vote_map = packbuf[3]; + + Bsprintf(tempbuf,"%s^00 HAS CALLED A VOTE TO CHANGE MAP TO %s (E%dL%d)", + g_player[(unsigned char)packbuf[1]].user_name, + MapInfo[(unsigned char)(packbuf[2]*MAXLEVELS + packbuf[3])].name, + packbuf[2]+1,packbuf[3]+1); + G_AddUserQuote(tempbuf); + Bsprintf(tempbuf,"PRESS F1 TO ACCEPT, F2 TO DECLINE"); - adduserquote(tempbuf); + G_AddUserQuote(tempbuf); + for (i=MAXPLAYERS-1;i>=0;i--) { g_player[i].vote = 0; @@ -1133,8 +1172,8 @@ void getpackets(void) g_player[voting].gotvote = g_player[voting].vote = 1; break; - case 2: // cancel map vote - if (voting == packbuf[2]) + case PACKET_TYPE_MAP_VOTE_CANCEL: // cancel map vote + if (voting == packbuf[1]) { voting = -1; i = 0; @@ -1142,23 +1181,23 @@ void getpackets(void) i += g_player[j].gotvote; if (i != numplayers) - Bsprintf(tempbuf,"%s^00 HAS CANCELED THE VOTE",g_player[(unsigned char)packbuf[2]].user_name); + Bsprintf(tempbuf,"%s^00 HAS CANCELED THE VOTE",g_player[(unsigned char)packbuf[1]].user_name); else Bsprintf(tempbuf,"VOTE FAILED"); for (i=MAXPLAYERS-1;i>=0;i--) { g_player[i].vote = 0; g_player[i].gotvote = 0; } - adduserquote(tempbuf); + G_AddUserQuote(tempbuf); } break; } break; - case 126: + case PACKET_TYPE_LOAD_GAME: //Slaves in M/S mode only send to master //Master re-transmits message to all others - if ((!networkmode) && (myconnectindex == connecthead)) + if ((!g_networkBroadcastMode) && (myconnectindex == connecthead)) for (i=connectpoint2[connecthead];i>=0;i=connectpoint2[i]) if (i != other) sendpacket(i,packbuf,packbufleng); @@ -1166,7 +1205,7 @@ void getpackets(void) multiwhat = 0; multiwho = packbuf[2]; //other: need to send in m/s mode because of possible re-transmit multipos = packbuf[1]; - loadplayer(multipos); + G_LoadPlayer(multipos); multiflag = 0; break; } @@ -1184,7 +1223,7 @@ void faketimerhandler(void) if (qe == 0 && KB_KeyPressed(sc_LeftControl) && KB_KeyPressed(sc_LeftAlt) && KB_KeyPressed(sc_Delete)) { qe = 1; - gameexit("Quick Exit."); + G_GameExit("Quick Exit."); } sampletimer(); @@ -1193,7 +1232,8 @@ void faketimerhandler(void) ototalclock += TICSPERFRAME; getpackets(); - if (getoutputcirclesize() >= 16) return; + +// if (getoutputcirclesize() >= 16) return; // for (i=connecthead;i>=0;i=connectpoint2[i]) // if (i != myconnectindex) @@ -1210,7 +1250,7 @@ void faketimerhandler(void) avghorz += loc.horz; avgbits |= loc.bits; avgextbits |= loc.extbits; - if (g_player[myconnectindex].movefifoend&(movesperpacket-1)) + if (g_player[myconnectindex].movefifoend&(g_movesPerPacket-1)) { copybufbyte(&inputfifo[(g_player[myconnectindex].movefifoend-1)&(MOVEFIFOSIZ-1)][myconnectindex], &inputfifo[g_player[myconnectindex].movefifoend&(MOVEFIFOSIZ-1)][myconnectindex],sizeof(input_t)); @@ -1218,10 +1258,10 @@ void faketimerhandler(void) return; } nsyn = &inputfifo[g_player[myconnectindex].movefifoend&(MOVEFIFOSIZ-1)][myconnectindex]; - nsyn[0].fvel = avgfvel/movesperpacket; - nsyn[0].svel = avgsvel/movesperpacket; - nsyn[0].avel = avgavel/movesperpacket; - nsyn[0].horz = avghorz/movesperpacket; + nsyn[0].fvel = avgfvel/g_movesPerPacket; + nsyn[0].svel = avgsvel/g_movesPerPacket; + nsyn[0].avel = avgavel/g_movesPerPacket; + nsyn[0].horz = avghorz/g_movesPerPacket; nsyn[0].bits = avgbits; nsyn[0].extbits = avgextbits; avgfvel = avgsvel = avgavel = avghorz = avgbits = avgextbits = 0; @@ -1229,26 +1269,27 @@ void faketimerhandler(void) if (numplayers < 2) { - if (ud.multimode > 1) for (i=connecthead;i>=0;i=connectpoint2[i]) - if (i != myconnectindex) - { - //clearbufbyte(&inputfifo[g_player[i].movefifoend&(MOVEFIFOSIZ-1)][i],sizeof(input_t),0L); - if (ud.playerai) - computergetinput(i,&inputfifo[g_player[i].movefifoend&(MOVEFIFOSIZ-1)][i]); - inputfifo[g_player[i].movefifoend&(MOVEFIFOSIZ-1)][i].svel++; - inputfifo[g_player[i].movefifoend&(MOVEFIFOSIZ-1)][i].fvel++; - g_player[i].movefifoend++; - } + if (ud.multimode > 1) + TRAVERSE_CONNECT(i) + if (i != myconnectindex) + { + //clearbufbyte(&inputfifo[g_player[i].movefifoend&(MOVEFIFOSIZ-1)][i],sizeof(input_t),0L); + if (ud.playerai) + computergetinput(i,&inputfifo[g_player[i].movefifoend&(MOVEFIFOSIZ-1)][i]); + inputfifo[g_player[i].movefifoend&(MOVEFIFOSIZ-1)][i].svel++; + inputfifo[g_player[i].movefifoend&(MOVEFIFOSIZ-1)][i].fvel++; + g_player[i].movefifoend++; + } return; } - for (i=connecthead;i>=0;i=connectpoint2[i]) - if (i != myconnectindex) - { - k = (g_player[myconnectindex].movefifoend-1)-g_player[i].movefifoend; - g_player[i].myminlag = min(g_player[i].myminlag,k); - mymaxlag = max(mymaxlag,k); - } + TRAVERSE_CONNECT(i) + if (i != myconnectindex) + { + k = (g_player[myconnectindex].movefifoend-1)-g_player[i].movefifoend; + g_player[i].myminlag = min(g_player[i].myminlag,k); + mymaxlag = max(mymaxlag,k); + } if (((g_player[myconnectindex].movefifoend - 1) & (TIMERUPDATESIZ - 1)) == 0) { @@ -1260,10 +1301,10 @@ void faketimerhandler(void) bufferjitter -= ((2 - i) >> 2); } - if (networkmode == 1) + if (g_networkBroadcastMode == 1) { - packbuf[0] = 17; - if ((g_player[myconnectindex].movefifoend-1) == 0) packbuf[0] = 16; + packbuf[0] = SERVER_GENERATED_BROADCAST; + if ((g_player[myconnectindex].movefifoend-1) == 0) packbuf[0] = PACKET_TYPE_BROADCAST; j = 1; //Fix timers and buffer/jitter value @@ -1300,8 +1341,8 @@ void faketimerhandler(void) } } - for (i = connecthead; i >= 0; i = connectpoint2[i]) - g_player[i].myminlag = 0x7fffffff; + TRAVERSE_CONNECT(i) + g_player[i].myminlag = 0x7fffffff; } osyn = (input_t *)&inputfifo[(g_player[myconnectindex].movefifoend-2)&(MOVEFIFOSIZ-1)][myconnectindex]; @@ -1353,9 +1394,9 @@ void faketimerhandler(void) AddSyncInfoToPacket(&j); - for (i=connecthead;i>=0;i=connectpoint2[i]) - if (i != myconnectindex) - sendpacket(i,packbuf,j); + TRAVERSE_CONNECT(i) + if (i != myconnectindex) + sendpacket(i,packbuf,j); return; } @@ -1384,13 +1425,13 @@ void faketimerhandler(void) otherminlag += i; } - for (i = connecthead; i >= 0; i = connectpoint2[i]) + TRAVERSE_CONNECT(i) { g_player[i].myminlag = 0x7fffffff; } } - packbuf[0] = 1; + packbuf[0] = PACKET_TYPE_SLAVE_TO_MASTER; packbuf[1] = 0; packbuf[2] = 0; j = 3; @@ -1443,25 +1484,25 @@ void faketimerhandler(void) } //This allows allow packet resends - for (i=connecthead;i>=0;i=connectpoint2[i]) - if (g_player[i].movefifoend <= movefifosendplc) - { - packbuf[0] = 127; - for (i=connectpoint2[connecthead];i>=0;i=connectpoint2[i]) - sendpacket(i,packbuf,1); - return; - } + TRAVERSE_CONNECT(i) + if (g_player[i].movefifoend <= movefifosendplc) + { + packbuf[0] = PACKET_TYPE_NULL_PACKET; + for (i=connectpoint2[connecthead];i>=0;i=connectpoint2[i]) + sendpacket(i,packbuf,1); + return; + } while (1) //Master { - for (i=connecthead;i>=0;i=connectpoint2[i]) - if (g_player[i].playerquitflag && (g_player[i].movefifoend <= movefifosendplc)) return; + TRAVERSE_CONNECT(i) + if (g_player[i].playerquitflag && (g_player[i].movefifoend <= movefifosendplc)) return; osyn = (input_t *)&inputfifo[(movefifosendplc-1)&(MOVEFIFOSIZ-1)][0]; nsyn = (input_t *)&inputfifo[(movefifosendplc)&(MOVEFIFOSIZ-1)][0]; //MASTER -> SLAVE packet - packbuf[0] = 0; + packbuf[0] = PACKET_TYPE_MASTER_TO_SLAVE; j = 1; //Fix timers and buffer/jitter value @@ -1471,14 +1512,14 @@ void faketimerhandler(void) if (g_player[i].playerquitflag) packbuf[j++] = min(max(g_player[i].myminlag,-128),127); - for (i=connecthead;i>=0;i=connectpoint2[i]) - g_player[i].myminlag = 0x7fffffff; + TRAVERSE_CONNECT(i) + g_player[i].myminlag = 0x7fffffff; } k = j; - for (i=connecthead;i>=0;i=connectpoint2[i]) - j += g_player[i].playerquitflag + g_player[i].playerquitflag; - for (i=connecthead;i>=0;i=connectpoint2[i]) + TRAVERSE_CONNECT(i) + j += g_player[i].playerquitflag + g_player[i].playerquitflag; + TRAVERSE_CONNECT(i) { if (g_player[i].playerquitflag == 0) continue; @@ -1531,11 +1572,11 @@ void faketimerhandler(void) if (g_player[i].playerquitflag) { sendpacket(i,packbuf,j); - if (nsyn[i].bits&(1<<26)) + if (TEST_SYNC_KEY(nsyn[i].bits,SK_GAMEQUIT)) g_player[i].playerquitflag = 0; } - movefifosendplc += movesperpacket; + movefifosendplc += g_movesPerPacket; } } @@ -1548,7 +1589,7 @@ typedef struct cactype; extern cactype cac[]; -static void caches(void) +static void G_ShowCacheLocks(void) { short i,k; @@ -1571,114 +1612,10 @@ static void caches(void) k += 6; } } -/* -static void checksync(void) + +int A_CheckInventorySprite(spritetype *s) { - int i; - - for (i=connecthead;i>=0;i=connectpoint2[i]) - if (g_player[i].syncvalhead == syncvaltottail) break; - if (i < 0) - { - syncstat = 0; - do - { - for (i=connectpoint2[connecthead];i>=0;i=connectpoint2[i]) - if (g_player[i].syncval[syncvaltottail&(MOVEFIFOSIZ-1)] != - g_player[connecthead].syncval[syncvaltottail&(MOVEFIFOSIZ-1)]) - syncstat = 1; - - syncvaltottail++; - for (i=connecthead;i>=0;i=connectpoint2[i]) - if (g_player[i].syncvalhead == syncvaltottail) break; - } - while (i < 0); - } - if (connectpoint2[connecthead] < 0) syncstat = 0; - - if (syncstat) - { - printext256(4L,130L,31,0,"Out Of Sync - Please restart game",0); - printext256(4L,138L,31,0,"RUN DN3DHELP.EXE for information.",0); - } -#if 0 - if (syncstate) - { - printext256(4L,160L,31,0,"Missed Network packet!",0); - printext256(4L,138L,31,0,"RUN DN3DHELP.EXE for information.",0); - } -#endif -} -*/ -void check_fta_sounds(int i) -{ - if (sprite[i].extra > 0) - switch (dynamictostatic[PN]) - { - case LIZTROOPONTOILET__STATIC: - case LIZTROOPJUSTSIT__STATIC: - case LIZTROOPSHOOT__STATIC: - case LIZTROOPJETPACK__STATIC: - case LIZTROOPDUCKING__STATIC: - case LIZTROOPRUNNING__STATIC: - case LIZTROOP__STATIC: - spritesound(PRED_RECOG,i); - break; - case LIZMAN__STATIC: - case LIZMANSPITTING__STATIC: - case LIZMANFEEDING__STATIC: - case LIZMANJUMP__STATIC: - spritesound(CAPT_RECOG,i); - break; - case PIGCOP__STATIC: - case PIGCOPDIVE__STATIC: - spritesound(PIG_RECOG,i); - break; - case RECON__STATIC: - spritesound(RECO_RECOG,i); - break; - case DRONE__STATIC: - spritesound(DRON_RECOG,i); - break; - case COMMANDER__STATIC: - case COMMANDERSTAYPUT__STATIC: - spritesound(COMM_RECOG,i); - break; - case ORGANTIC__STATIC: - spritesound(TURR_RECOG,i); - break; - case OCTABRAIN__STATIC: - case OCTABRAINSTAYPUT__STATIC: - spritesound(OCTA_RECOG,i); - break; - case BOSS1__STATIC: - sound(BOS1_RECOG); - break; - case BOSS2__STATIC: - if (sprite[i].pal == 1) - sound(BOS2_RECOG); - else sound(WHIPYOURASS); - break; - case BOSS3__STATIC: - if (sprite[i].pal == 1) - sound(BOS3_RECOG); - else sound(RIPHEADNECK); - break; - case BOSS4__STATIC: - case BOSS4STAYPUT__STATIC: - if (sprite[i].pal == 1) - sound(BOS4_RECOG); - sound(BOSS4_FIRSTSEE); - break; - case GREENSLIME__STATIC: - spritesound(SLIM_RECOG,i); - break; - } -} - -int inventory(spritetype *s) -{ - switch (dynamictostatic[s->picnum]) + switch (DynamicTileMap[s->picnum]) { case FIRSTAID__STATIC: case STEROIDS__STATIC: @@ -1692,78 +1629,7 @@ int inventory(spritetype *s) return 0; } -inline int checkspriteflags(int iActor, int iType) -{ - if ((spriteflags[sprite[iActor].picnum]^hittype[iActor].flags) & iType) return 1; - return 0; -} - -inline int checkspriteflagsp(int iPicnum, int iType) -{ - if (spriteflags[iPicnum] & iType) return 1; - return 0; -} - -int badguypic(int pn) -{ - //this case can't be handled by the dynamictostatic system because it adds - //stuff to the value from names.h so handling separately - if ((pn >= GREENSLIME) && (pn <= GREENSLIME+7)) return 1; - - if (checkspriteflagsp(pn,SPRITE_FLAG_BADGUY)) return 1; - - if (actortype[pn]) return 1; - - switch (dynamictostatic[pn]) - { - case SHARK__STATIC: - case RECON__STATIC: - case DRONE__STATIC: - case LIZTROOPONTOILET__STATIC: - case LIZTROOPJUSTSIT__STATIC: - case LIZTROOPSTAYPUT__STATIC: - case LIZTROOPSHOOT__STATIC: - case LIZTROOPJETPACK__STATIC: - case LIZTROOPDUCKING__STATIC: - case LIZTROOPRUNNING__STATIC: - case LIZTROOP__STATIC: - case OCTABRAIN__STATIC: - case COMMANDER__STATIC: - case COMMANDERSTAYPUT__STATIC: - case PIGCOP__STATIC: - case EGG__STATIC: - case PIGCOPSTAYPUT__STATIC: - case PIGCOPDIVE__STATIC: - case LIZMAN__STATIC: - case LIZMANSPITTING__STATIC: - case LIZMANFEEDING__STATIC: - case LIZMANJUMP__STATIC: - case ORGANTIC__STATIC: - case BOSS1__STATIC: - case BOSS2__STATIC: - case BOSS3__STATIC: - case BOSS4__STATIC: - //case GREENSLIME: - //case GREENSLIME+1: - //case GREENSLIME+2: - //case GREENSLIME+3: - //case GREENSLIME+4: - //case GREENSLIME+5: - //case GREENSLIME+6: - //case GREENSLIME+7: - case RAT__STATIC: - case ROTATEGUN__STATIC: - return 1; - } - return 0; -} - -inline int badguy(spritetype *s) -{ - return(badguypic(s->picnum)); -} - -void myos(int x, int y, int tilenum, int shade, int orientation) +void G_DrawTile(int x, int y, int tilenum, int shade, int orientation) { int p = sector[g_player[screenpeek].ps->cursectnum].floorpal, a = 0; @@ -1773,7 +1639,7 @@ void myos(int x, int y, int tilenum, int shade, int orientation) rotatesprite((orientation&256)?x:(x<<16),(orientation&256)?y:(y<<16),65536L,a,tilenum,shade,p,2|orientation,windowx1,windowy1,windowx2,windowy2); } -void myospal(int x, int y, int tilenum, int shade, int orientation, int p) +void G_DrawTilePal(int x, int y, int tilenum, int shade, int orientation, int p) { int a = 0; @@ -1783,7 +1649,7 @@ void myospal(int x, int y, int tilenum, int shade, int orientation, int p) rotatesprite((orientation&256)?x:(x<<16),(orientation&256)?y:(y<<16),65536L,a,tilenum,shade,p,2|orientation,windowx1,windowy1,windowx2,windowy2); } -void myosx(int x, int y, int tilenum, int shade, int orientation) +void G_DrawTileSmall(int x, int y, int tilenum, int shade, int orientation) { int p = sector[g_player[screenpeek].ps->cursectnum].floorpal, a = 0; @@ -1793,7 +1659,7 @@ void myosx(int x, int y, int tilenum, int shade, int orientation) rotatesprite((orientation&256)?x:(x<<16),(orientation&256)?y:(y<<16),32768L,a,tilenum,shade,p,2|orientation,windowx1,windowy1,windowx2,windowy2); } -void myospalx(int x, int y, int tilenum, int shade, int orientation, int p) +void G_DrawTilePalSmall(int x, int y, int tilenum, int shade, int orientation, int p) { int a = 0; @@ -1803,7 +1669,7 @@ void myospalx(int x, int y, int tilenum, int shade, int orientation, int p) rotatesprite((orientation&256)?x:(x<<16),(orientation&256)?y:(y<<16),32768L,a,tilenum,shade,p,2|orientation,windowx1,windowy1,windowx2,windowy2); } -static void invennum(int x,int y,char num1,char ha,char sbits) +static void G_DrawInvNum(int x,int y,char num1,char ha,char sbits) { char dabuf[80] = {0}; int shd = (x < 0); @@ -1840,7 +1706,7 @@ static void invennum(int x,int y,char num1,char ha,char sbits) rotatesprite(sbarx(x+4),sbary(y),sbarsc(65536L),0,THREEBYFIVE+dabuf[0]-'0',ha,0,sbits,0,0,xdim-1,ydim-1); } -static void weaponnum(short ind,int x,int y,int num1, int num2,char ha) +static void G_DrawWeapNum(short ind,int x,int y,int num1, int num2,char ha) { char dabuf[80] = {0}; @@ -1876,7 +1742,7 @@ static void weaponnum(short ind,int x,int y,int num1, int num2,char ha) rotatesprite(sbarx(x+13),sbary(y),sbarsc(65536L),0,THREEBYFIVE+dabuf[0]-'0',ha,0,10,0,0,xdim-1,ydim-1); } -static void weaponnum999(char ind,int x,int y,int num1, int num2,char ha) +static void G_DrawWeapNum2(char ind,int x,int y,int num1, int num2,char ha) { char dabuf[80] = {0}; @@ -1915,95 +1781,95 @@ static void weaponnum999(char ind,int x,int y,int num1, int num2,char ha) rotatesprite(sbarx(x+25),sbary(y),sbarsc(65536L),0,THREEBYFIVE+dabuf[0]-'0',ha,0,10,0,0,xdim-1,ydim-1); } -static void weapon_amounts(player_struct *p,int x,int y,int u) +static void G_DrawWeapAmounts(DukePlayer_t *p,int x,int y,int u) { int cw = p->curr_weapon; if (u&4) { if (u != -1) patchstatusbar(88,178,88+37,178+6); //original code: (96,178,96+12,178+6); - weaponnum999(PISTOL_WEAPON,x,y, - p->ammo_amount[PISTOL_WEAPON],p->max_ammo_amount[PISTOL_WEAPON], - 12-20*(cw == PISTOL_WEAPON)); + G_DrawWeapNum2(PISTOL_WEAPON,x,y, + p->ammo_amount[PISTOL_WEAPON],p->max_ammo_amount[PISTOL_WEAPON], + 12-20*(cw == PISTOL_WEAPON)); } if (u&8) { if (u != -1) patchstatusbar(88,184,88+37,184+6); //original code: (96,184,96+12,184+6); - weaponnum999(SHOTGUN_WEAPON,x,y+6, - p->ammo_amount[SHOTGUN_WEAPON],p->max_ammo_amount[SHOTGUN_WEAPON], - (!p->gotweapon[SHOTGUN_WEAPON]*9)+12-18* - (cw == SHOTGUN_WEAPON)); + G_DrawWeapNum2(SHOTGUN_WEAPON,x,y+6, + p->ammo_amount[SHOTGUN_WEAPON],p->max_ammo_amount[SHOTGUN_WEAPON], + (!p->gotweapon[SHOTGUN_WEAPON]*9)+12-18* + (cw == SHOTGUN_WEAPON)); } if (u&16) { if (u != -1) patchstatusbar(88,190,88+37,190+6); //original code: (96,190,96+12,190+6); - weaponnum999(CHAINGUN_WEAPON,x,y+12, - p->ammo_amount[CHAINGUN_WEAPON],p->max_ammo_amount[CHAINGUN_WEAPON], - (!p->gotweapon[CHAINGUN_WEAPON]*9)+12-18* - (cw == CHAINGUN_WEAPON)); + G_DrawWeapNum2(CHAINGUN_WEAPON,x,y+12, + p->ammo_amount[CHAINGUN_WEAPON],p->max_ammo_amount[CHAINGUN_WEAPON], + (!p->gotweapon[CHAINGUN_WEAPON]*9)+12-18* + (cw == CHAINGUN_WEAPON)); } if (u&32) { if (u != -1) patchstatusbar(127,178,127+29,178+6); //original code: (135,178,135+8,178+6); - weaponnum(RPG_WEAPON,x+39,y, - p->ammo_amount[RPG_WEAPON],p->max_ammo_amount[RPG_WEAPON], - (!p->gotweapon[RPG_WEAPON]*9)+12-19* - (cw == RPG_WEAPON)); + G_DrawWeapNum(RPG_WEAPON,x+39,y, + p->ammo_amount[RPG_WEAPON],p->max_ammo_amount[RPG_WEAPON], + (!p->gotweapon[RPG_WEAPON]*9)+12-19* + (cw == RPG_WEAPON)); } if (u&64) { if (u != -1) patchstatusbar(127,184,127+29,184+6); //original code: (135,184,135+8,184+6); - weaponnum(HANDBOMB_WEAPON,x+39,y+6, - p->ammo_amount[HANDBOMB_WEAPON],p->max_ammo_amount[HANDBOMB_WEAPON], - (((!p->ammo_amount[HANDBOMB_WEAPON])|(!p->gotweapon[HANDBOMB_WEAPON]))*9)+12-19* - ((cw == HANDBOMB_WEAPON) || (cw == HANDREMOTE_WEAPON))); + G_DrawWeapNum(HANDBOMB_WEAPON,x+39,y+6, + p->ammo_amount[HANDBOMB_WEAPON],p->max_ammo_amount[HANDBOMB_WEAPON], + (((!p->ammo_amount[HANDBOMB_WEAPON])|(!p->gotweapon[HANDBOMB_WEAPON]))*9)+12-19* + ((cw == HANDBOMB_WEAPON) || (cw == HANDREMOTE_WEAPON))); } if (u&128) { if (u != -1) patchstatusbar(127,190,127+29,190+6); //original code: (135,190,135+8,190+6); if (p->subweapon&(1<ammo_amount[GROW_WEAPON],p->max_ammo_amount[GROW_WEAPON], - (!p->gotweapon[GROW_WEAPON]*9)+12-18* - (cw == GROW_WEAPON)); + G_DrawWeapNum(SHRINKER_WEAPON,x+39,y+12, + p->ammo_amount[GROW_WEAPON],p->max_ammo_amount[GROW_WEAPON], + (!p->gotweapon[GROW_WEAPON]*9)+12-18* + (cw == GROW_WEAPON)); else - weaponnum(SHRINKER_WEAPON,x+39,y+12, - p->ammo_amount[SHRINKER_WEAPON],p->max_ammo_amount[SHRINKER_WEAPON], - (!p->gotweapon[SHRINKER_WEAPON]*9)+12-18* - (cw == SHRINKER_WEAPON)); + G_DrawWeapNum(SHRINKER_WEAPON,x+39,y+12, + p->ammo_amount[SHRINKER_WEAPON],p->max_ammo_amount[SHRINKER_WEAPON], + (!p->gotweapon[SHRINKER_WEAPON]*9)+12-18* + (cw == SHRINKER_WEAPON)); } if (u&256) { if (u != -1) patchstatusbar(158,178,162+29,178+6); //original code: (166,178,166+8,178+6); - weaponnum(DEVISTATOR_WEAPON,x+70,y, - p->ammo_amount[DEVISTATOR_WEAPON],p->max_ammo_amount[DEVISTATOR_WEAPON], - (!p->gotweapon[DEVISTATOR_WEAPON]*9)+12-18* - (cw == DEVISTATOR_WEAPON)); + G_DrawWeapNum(DEVISTATOR_WEAPON,x+70,y, + p->ammo_amount[DEVISTATOR_WEAPON],p->max_ammo_amount[DEVISTATOR_WEAPON], + (!p->gotweapon[DEVISTATOR_WEAPON]*9)+12-18* + (cw == DEVISTATOR_WEAPON)); } if (u&512) { if (u != -1) patchstatusbar(158,184,162+29,184+6); //original code: (166,184,166+8,184+6); - weaponnum(TRIPBOMB_WEAPON,x+70,y+6, - p->ammo_amount[TRIPBOMB_WEAPON],p->max_ammo_amount[TRIPBOMB_WEAPON], - (!p->gotweapon[TRIPBOMB_WEAPON]*9)+12-18* - (cw == TRIPBOMB_WEAPON)); + G_DrawWeapNum(TRIPBOMB_WEAPON,x+70,y+6, + p->ammo_amount[TRIPBOMB_WEAPON],p->max_ammo_amount[TRIPBOMB_WEAPON], + (!p->gotweapon[TRIPBOMB_WEAPON]*9)+12-18* + (cw == TRIPBOMB_WEAPON)); } if (u&65536L) { if (u != -1) patchstatusbar(158,190,162+29,190+6); //original code: (166,190,166+8,190+6); - weaponnum(-1,x+70,y+12, - p->ammo_amount[FREEZE_WEAPON],p->max_ammo_amount[FREEZE_WEAPON], - (!p->gotweapon[FREEZE_WEAPON]*9)+12-18* - (cw == FREEZE_WEAPON)); + G_DrawWeapNum(-1,x+70,y+12, + p->ammo_amount[FREEZE_WEAPON],p->max_ammo_amount[FREEZE_WEAPON], + (!p->gotweapon[FREEZE_WEAPON]*9)+12-18* + (cw == FREEZE_WEAPON)); } } -static void digitalnumber(int x,int y,int n,char s,char cs) +static void G_DrawDigiNum(int x,int y,int n,char s,char cs) { int i, j = 0, k, p, c; char b[10]; @@ -2027,7 +1893,7 @@ static void digitalnumber(int x,int y,int n,char s,char cs) } } -void txdigitalnumberz(int starttile, int x,int y,int n,int s,int pal,int cs,int x1, int y1, int x2, int y2, int z) +void G_DrawTXDigiNumZ(int starttile, int x,int y,int n,int s,int pal,int cs,int x1, int y1, int x2, int y2, int z) { int i, j = 0, k, p, c; char b[10]; @@ -2056,7 +1922,7 @@ void txdigitalnumberz(int starttile, int x,int y,int n,int s,int pal,int cs,int } } -static void altdigitalnumber(int x,int y,int n,char s,char cs) +static void G_DrawAltDigiNum(int x,int y,int n,char s,char cs) { int i, j = 0, k, p, c; char b[10]; @@ -2100,7 +1966,7 @@ static void altdigitalnumber(int x,int y,int n,char s,char cs) } } -static void displayinventory(player_struct *p) +static void G_DrawInventory(DukePlayer_t *p) { int n, j = 0, xoff = 0, y; @@ -2173,19 +2039,19 @@ static void displayinventory(player_struct *p) } } -void displayfragbar(void) +void G_DrawFrags(void) { int i, j = 0; - for (i=connecthead;i>=0;i=connectpoint2[i]) - if (i > j) j = i; + TRAVERSE_CONNECT(i) + if (i > j) j = i; rotatesprite(0,0,65600L,0,FRAGBAR,0,0,2+8+16+64,0,0,xdim-1,ydim-1); if (j >= 4) rotatesprite(319,(8)<<16,65600L,0,FRAGBAR,0,0,10+16+64,0,0,xdim-1,ydim-1); if (j >= 8) rotatesprite(319,(16)<<16,65600L,0,FRAGBAR,0,0,10+16+64,0,0,xdim-1,ydim-1); if (j >= 12) rotatesprite(319,(24)<<16,65600L,0,FRAGBAR,0,0,10+16+64,0,0,xdim-1,ydim-1); - for (i=connecthead;i>=0;i=connectpoint2[i]) + TRAVERSE_CONNECT(i) { minitext(21+(73*(i&3)),2+((i&28)<<1),&g_player[i].user_name[0],/*sprite[g_player[i].ps->i].pal*/g_player[i].ps->palookup,2+8+16); Bsprintf(tempbuf,"%d",g_player[i].ps->frag-g_player[i].ps->fraggedself); @@ -2195,39 +2061,39 @@ void displayfragbar(void) #define SBY (200-tilesizy[BOTTOMSTATUSBAR]) -static void coolgaugetext(int snum) +static void G_DrawStatusBar(int snum) { - player_struct *p = g_player[snum].ps; + DukePlayer_t *p = g_player[snum].ps; int i, j, o, ss = ud.screen_size, u; int permbit = 0; if (ss < 4) return; if (g_player[snum].ps->gm&MODE_MENU) - if ((current_menu >= 400 && current_menu <= 405)) + if ((g_currentMenu >= 400 && g_currentMenu <= 405)) return; if (getrendermode() >= 3) pus = NUMPAGES; // JBF 20040101: always redraw in GL - if (ud.multimode > 1 && (gametype_flags[ud.coop] & GAMETYPE_FLAG_FRAGBAR)) + if (ud.multimode > 1 && (GametypeFlags[ud.coop] & GAMETYPE_FRAGBAR)) { if (pus) { - displayfragbar(); + G_DrawFrags(); } else { - for (i=connecthead;i>=0;i=connectpoint2[i]) - if (g_player[i].ps->frag != sbar.frag[i]) - { - displayfragbar(); - break; - } + TRAVERSE_CONNECT(i) + if (g_player[i].ps->frag != sbar.frag[i]) + { + G_DrawFrags(); + break; + } } - for (i=connecthead;i>=0;i=connectpoint2[i]) - if (i != myconnectindex) - sbar.frag[i] = g_player[i].ps->frag; + TRAVERSE_CONNECT(i) + if (i != myconnectindex) + sbar.frag[i] = g_player[i].ps->frag; } if (ss == 4) //DRAW MINI STATUS BAR: @@ -2257,20 +2123,20 @@ static void coolgaugetext(int snum) rotatesprite(sbarx(2),sbary(200-21),sbarsc(49152L),0,COLA,0,0,10+16,0,0,xdim-1,ydim-1); if (sprite[p->i].pal == 1 && p->last_extra < 2) - altdigitalnumber(40,-(200-22),1,-16,10+16); + G_DrawAltDigiNum(40,-(200-22),1,-16,10+16); else if (!althud_flashing || p->last_extra > (p->max_player_health>>2) || totalclock&32) { int s = -8; if (althud_flashing && p->last_extra > p->max_player_health) s += (sintable[(totalclock<<5)&2047]>>10); - altdigitalnumber(40,-(200-22),p->last_extra,s,10+16); + G_DrawAltDigiNum(40,-(200-22),p->last_extra,s,10+16); } if (althud_shadows) rotatesprite(sbarx(62+1),sbary(200-25+1),sbarsc(49152L),0,SHIELD,0,4,10+16+1+32,0,0,xdim-1,ydim-1); rotatesprite(sbarx(62),sbary(200-25),sbarsc(49152L),0,SHIELD,0,0,10+16,0,0,xdim-1,ydim-1); - altdigitalnumber(105,-(200-22),p->shield_amount,-16,10+16); + G_DrawAltDigiNum(105,-(200-22),p->shield_amount,-16,10+16); if (althud_shadows) { @@ -2293,7 +2159,7 @@ static void coolgaugetext(int snum) else i = p->curr_weapon; if (p->curr_weapon != KNEE_WEAPON && (!althud_flashing || totalclock&32 || p->ammo_amount[i] > (p->max_ammo_amount[i]/10))) - altdigitalnumber(-20,-(200-22),p->ammo_amount[i],-16,10+16); + G_DrawAltDigiNum(-20,-(200-22),p->ammo_amount[i],-16,10+16); o = 102; permbit = 0; @@ -2365,7 +2231,7 @@ static void coolgaugetext(int snum) i = (p->boot_amount>>1); break; } - invennum(-(284-30-o),200-6-3,(char)i,0,10+permbit); + G_DrawInvNum(-(284-30-o),200-6-3,(char)i,0,10+permbit); if (j > 0) { if (althud_shadows) @@ -2393,14 +2259,14 @@ static void coolgaugetext(int snum) rotatesprite(sbarx(69),sbary(200-30),sbarsc(65536L),0,INVENTORYBOX,0,21,10+16,0,0,xdim-1,ydim-1); if (sprite[p->i].pal == 1 && p->last_extra < 2) - digitalnumber(20,200-17,1,-16,10+16); - else digitalnumber(20,200-17,p->last_extra,-16,10+16); + G_DrawDigiNum(20,200-17,1,-16,10+16); + else G_DrawDigiNum(20,200-17,p->last_extra,-16,10+16); rotatesprite(sbarx(37),sbary(200-28),sbarsc(65536L),0,AMMOBOX,0,21,10+16,0,0,xdim-1,ydim-1); if (p->curr_weapon == HANDREMOTE_WEAPON) i = HANDBOMB_WEAPON; else i = p->curr_weapon; - digitalnumber(53,200-17,p->ammo_amount[i],-16,10+16); + G_DrawDigiNum(53,200-17,p->ammo_amount[i],-16,10+16); o = 158; permbit = 0; @@ -2464,7 +2330,7 @@ static void coolgaugetext(int snum) i = (p->boot_amount>>1); break; } - invennum(284-30-o,200-6,(char)i,0,10+permbit); + G_DrawInvNum(284-30-o,200-6,(char)i,0,10+permbit); if (j > 0) minitext(288-30-o,180,"ON",0,10+16+permbit + 256); else if ((unsigned int)j != 0x80000000) minitext(284-30-o,180,"OFF",2,10+16+permbit + 256); if (p->inven_icon >= 6) minitext(284-35-o,180,"AUTO",2,10+16+permbit + 256); @@ -2499,7 +2365,7 @@ static void coolgaugetext(int snum) } { - int lAmount=GetGameVar("PLR_MORALE",-1, p->i, snum); + int lAmount=Gv_GetVarByLabel("PLR_MORALE",-1, p->i, snum); if (lAmount == -1) { if (sbar.shield_amount != p->shield_amount) @@ -2622,15 +2488,15 @@ static void coolgaugetext(int snum) if (u == -1) { patchstatusbar(0,0,320,200); - if (ud.multimode > 1 && (gametype_flags[ud.coop] & GAMETYPE_FLAG_FRAGBAR)) + if (ud.multimode > 1 && (GametypeFlags[ud.coop] & GAMETYPE_FRAGBAR)) rotatesprite(sbarx(277+1),sbary(SBY+7-1),sbarsc(65536L),0,KILLSICON,0,0,10+16,0,0,xdim-1,ydim-1); } - if (ud.multimode > 1 && (gametype_flags[ud.coop] & GAMETYPE_FLAG_FRAGBAR)) + if (ud.multimode > 1 && (GametypeFlags[ud.coop] & GAMETYPE_FRAGBAR)) { if (u&32768) { if (u != -1) patchstatusbar(276,SBY+17,299,SBY+17+10); - digitalnumber(287,SBY+17,max(p->frag-p->fraggedself,0),-16,10+16); + G_DrawDigiNum(287,SBY+17,max(p->frag-p->fraggedself,0),-16,10+16); } } else @@ -2643,23 +2509,23 @@ static void coolgaugetext(int snum) if (p->got_access&1) rotatesprite(sbarx(281),sbary(SBY+23),sbarsc(65536L),0,ACCESS_ICON,0,0,10+16,0,0,xdim-1,ydim-1); } } - if (u&(4+8+16+32+64+128+256+512+65536L)) weapon_amounts(p,96,SBY+16,u); + if (u&(4+8+16+32+64+128+256+512+65536L)) G_DrawWeapAmounts(p,96,SBY+16,u); if (u&1) { if (u != -1) patchstatusbar(20,SBY+17,43,SBY+17+11); if (sprite[p->i].pal == 1 && p->last_extra < 2) - digitalnumber(32,SBY+17,1,-16,10+16); - else digitalnumber(32,SBY+17,p->last_extra,-16,10+16); + G_DrawDigiNum(32,SBY+17,1,-16,10+16); + else G_DrawDigiNum(32,SBY+17,p->last_extra,-16,10+16); } if (u&2) { - int lAmount=GetGameVar("PLR_MORALE",-1, p->i, snum); + int lAmount=Gv_GetVarByLabel("PLR_MORALE",-1, p->i, snum); if (u != -1) patchstatusbar(52,SBY+17,75,SBY+17+11); if (lAmount == -1) - digitalnumber(64,SBY+17,p->shield_amount,-16,10+16); + G_DrawDigiNum(64,SBY+17,p->shield_amount,-16,10+16); else - digitalnumber(64,SBY+17,lAmount,-16,10+16); + G_DrawDigiNum(64,SBY+17,lAmount,-16,10+16); } if (u&1024) @@ -2669,7 +2535,7 @@ static void coolgaugetext(int snum) { if (p->curr_weapon == HANDREMOTE_WEAPON) i = HANDBOMB_WEAPON; else i = p->curr_weapon; - digitalnumber(230-22,SBY+17,p->ammo_amount[i],-16,10+16); + G_DrawDigiNum(230-22,SBY+17,p->ammo_amount[i],-16,10+16); } } @@ -2767,7 +2633,7 @@ static void coolgaugetext(int snum) i = (p->boot_amount>>1); break; } - invennum(284-30-o,SBY+28,(char)i,0,10+permbit); + G_DrawInvNum(284-30-o,SBY+28,(char)i,0,10+permbit); } } } @@ -2777,7 +2643,7 @@ static void coolgaugetext(int snum) #define COLOR_WHITE 31 #define LOW_FPS 30 -static void ShowFrameRate(void) +static void G_PrintFrameRate(void) { // adapted from ZDoom because I like it better than what we had // applicable ZDoom code available under GPL from csDoom @@ -2807,7 +2673,7 @@ static void ShowFrameRate(void) if (LastSec < thisSec) { - framerate = LastCount = FrameCount / (thisSec - LastSec); + g_currentFrameRate = LastCount = FrameCount / (thisSec - LastSec); LastSec = thisSec; FrameCount = 0; } @@ -2816,11 +2682,11 @@ static void ShowFrameRate(void) LastMS = ms; } -static void ShowCoordinates(int snum) +static void G_PrintCoords(int snum) { int y = 16; - if ((gametype_flags[ud.coop] & GAMETYPE_FLAG_FRAGBAR)) + if ((GametypeFlags[ud.coop] & GAMETYPE_FRAGBAR)) { if (ud.multimode > 4) y = 32; @@ -2843,17 +2709,20 @@ static void ShowCoordinates(int snum) printext256(250L,y+54L+7,31,-1,tempbuf,0); } -static void operatefta(void) +// this handles both multiplayer and item pickup message type text +// both are passed on to gametext + +static void G_PrintGameQuotes(void) { int i, j, k, l; k = 1; - if (GTFLAGS(GAMETYPE_FLAG_FRAGBAR) && ud.screen_size > 0 && ud.multimode > 1) + if (GTFLAGS(GAMETYPE_FRAGBAR) && ud.screen_size > 0 && ud.multimode > 1) { j = 0; k += 8; - for (i=connecthead;i>=0;i=connectpoint2[i]) - if (i > j) j = i; + TRAVERSE_CONNECT(i) + if (i > j) j = i; if (j >= 4 && j <= 8) k += 8; else if (j > 8 && j <= 12) k += 16; @@ -2896,7 +2765,7 @@ static void operatefta(void) else if (k > 2) { mpgametext(j,user_quote[i],0,2+8+16+1); j += textsc(k<<1); } else { mpgametext(j,user_quote[i],0,2+8+16+1+32); j += textsc(k<<1); } } - l = gametextlen(USERQUOTE_LEFTOFFSET,stripcolorcodes(tempbuf,user_quote[i])); + l = G_GameTextLen(USERQUOTE_LEFTOFFSET,stripcolorcodes(tempbuf,user_quote[i])); while (l > (ud.config.ScreenWidth - USERQUOTE_RIGHTOFFSET)) { l -= (ud.config.ScreenWidth-USERQUOTE_RIGHTOFFSET); @@ -2913,7 +2782,7 @@ static void operatefta(void) if (g_player[screenpeek].ps->fta <= 1) return; - if (fta_quotes[g_player[screenpeek].ps->ftq] == NULL) + if (ScriptQuotes[g_player[screenpeek].ps->ftq] == NULL) { OSD_Printf(OSD_ERROR "%s %d null quote %d\n",__FILE__,__LINE__,g_player[screenpeek].ps->ftq); return; @@ -2925,12 +2794,12 @@ static void operatefta(void) { k = 140;//quotebot-8-4; } - else if (GTFLAGS(GAMETYPE_FLAG_FRAGBAR) && ud.screen_size > 0 && ud.multimode > 1) + else if (GTFLAGS(GAMETYPE_FRAGBAR) && ud.screen_size > 0 && ud.multimode > 1) { j = 0; k = 8; - for (i=connecthead;i>=0;i=connectpoint2[i]) - if (i > j) j = i; + TRAVERSE_CONNECT(i) + if (i > j) j = i; if (j >= 4 && j <= 8) k += 8; else if (j > 8 && j <= 12) k += 16; @@ -2940,17 +2809,17 @@ static void operatefta(void) j = g_player[screenpeek].ps->fta; if (!hud_glowingquotes) { - if (j > 4) gametext(320>>1,k,fta_quotes[g_player[screenpeek].ps->ftq],0,2+8+16); - else if (j > 2) gametext(320>>1,k,fta_quotes[g_player[screenpeek].ps->ftq],0,2+8+16+1); - else gametext(320>>1,k,fta_quotes[g_player[screenpeek].ps->ftq],0,2+8+16+1+32); + if (j > 4) gametext(320>>1,k,ScriptQuotes[g_player[screenpeek].ps->ftq],0,2+8+16); + else if (j > 2) gametext(320>>1,k,ScriptQuotes[g_player[screenpeek].ps->ftq],0,2+8+16+1); + else gametext(320>>1,k,ScriptQuotes[g_player[screenpeek].ps->ftq],0,2+8+16+1+32); return; } - if (j > 4) gametext(320>>1,k,fta_quotes[g_player[screenpeek].ps->ftq],(sintable[(totalclock<<5)&2047]>>11),2+8+16); - else if (j > 2) gametext(320>>1,k,fta_quotes[g_player[screenpeek].ps->ftq],(sintable[(totalclock<<5)&2047]>>11),2+8+16+1); - else gametext(320>>1,k,fta_quotes[g_player[screenpeek].ps->ftq],(sintable[(totalclock<<5)&2047]>>11),2+8+16+1+32); + if (j > 4) gametext(320>>1,k,ScriptQuotes[g_player[screenpeek].ps->ftq],(sintable[(totalclock<<5)&2047]>>11),2+8+16); + else if (j > 2) gametext(320>>1,k,ScriptQuotes[g_player[screenpeek].ps->ftq],(sintable[(totalclock<<5)&2047]>>11),2+8+16+1); + else gametext(320>>1,k,ScriptQuotes[g_player[screenpeek].ps->ftq],(sintable[(totalclock<<5)&2047]>>11),2+8+16+1+32); } -void FTA(int q, player_struct *p) +void P_DoQuote(int q, DukePlayer_t *p) { int cq = 0; @@ -2960,7 +2829,7 @@ void FTA(int q, player_struct *p) q &= ~MAXQUOTES; } - if (fta_quotes[q] == NULL) + if (ScriptQuotes[q] == NULL) { OSD_Printf(OSD_ERROR "%s %d null quote %d\n",__FILE__,__LINE__,q); return; @@ -2980,8 +2849,8 @@ void FTA(int q, player_struct *p) if (p->ftq != q) if (p == g_player[screenpeek].ps) { - if (cq) OSD_Printf(OSDTEXT_BLUE "%s\n",fta_quotes[q]); - else OSD_Printf("%s\n",fta_quotes[q]); + if (cq) OSD_Printf(OSDTEXT_BLUE "%s\n",ScriptQuotes[q]); + else OSD_Printf("%s\n",ScriptQuotes[q]); } p->ftq = q; @@ -2993,23 +2862,23 @@ void FTA(int q, player_struct *p) void fadepal(int r, int g, int b, int start, int end, int step) { if (getrendermode() >= 3) return; - if (step > 0) for (; start < end; start += step) palto(r,g,b,start); - else for (; start >= end; start += step) palto(r,g,b,start); + if (step > 0) for (; start < end; start += step) G_FadePalette(r,g,b,start); + else for (; start >= end; start += step) G_FadePalette(r,g,b,start); } -static void showtwoscreens(void) +static void G_DisplayExtraScreens(void) { - int flags = GetGameVar("LOGO_FLAGS",255, -1, -1); + int flags = Gv_GetVarByLabel("LOGO_FLAGS",255, -1, -1); MUSIC_StopSong(); FX_StopAllSounds(); - if (!VOLUMEALL || flags & LOGO_FLAG_SHAREWARESCREENS) + if (!VOLUMEALL || flags & LOGO_SHAREWARESCREENS) { setview(0,0,xdim-1,ydim-1); flushperms(); //g_player[myconnectindex].ps->palette = palette; - setgamepalette(g_player[myconnectindex].ps, palette, 1); // JBF 20040308 + SetGamePalette(g_player[myconnectindex].ps, palette, 1); // JBF 20040308 fadepal(0,0,0, 0,64,7); KB_FlushKeyboardQueue(); rotatesprite(0,0,65536L,0,3291,0,0,2+8+16+64, 0,0,xdim-1,ydim-1); @@ -3033,12 +2902,12 @@ static void showtwoscreens(void) } } - if (flags & LOGO_FLAG_TENSCREEN) + if (flags & LOGO_TENSCREEN) { setview(0,0,xdim-1,ydim-1); flushperms(); //g_player[myconnectindex].ps->palette = palette; - setgamepalette(g_player[myconnectindex].ps, palette, 1); // JBF 20040308 + SetGamePalette(g_player[myconnectindex].ps, palette, 1); // JBF 20040308 fadepal(0,0,0, 0,64,7); KB_FlushKeyboardQueue(); rotatesprite(0,0,65536L,0,TENSCREEN,0,0,2+8+16+64, 0,0,xdim-1,ydim-1); @@ -3053,9 +2922,9 @@ static void showtwoscreens(void) } extern int qsetmode; -extern int doquicksave; +extern int g_doQuickSave; -void gameexit(const char *t) +void G_GameExit(const char *t) { if (*t != 0) g_player[myconnectindex].ps->palette = (char *) &palette[0]; @@ -3064,7 +2933,7 @@ void gameexit(const char *t) uninitmultiplayers(); - if (ud.recstat == 1) closedemowrite(); + if (ud.recstat == 1) G_CloseDemoWrite(); else if (ud.recstat == 2) { if (frecfilep) fclose(frecfilep); @@ -3072,20 +2941,20 @@ void gameexit(const char *t) if (!qe && !cp) { - if (playerswhenstarted > 1 && g_player[myconnectindex].ps->gm&MODE_GAME && GTFLAGS(GAMETYPE_FLAG_SCORESHEET) && *t == ' ') + if (playerswhenstarted > 1 && g_player[myconnectindex].ps->gm&MODE_GAME && GTFLAGS(GAMETYPE_SCORESHEET) && *t == ' ') { - dobonus(1); + G_BonusScreen(1); setgamemode(ud.config.ScreenMode,ud.config.ScreenWidth,ud.config.ScreenHeight,ud.config.ScreenBPP); } if (*t != 0 && *(t+1) != 'V' && *(t+1) != 'Y') - showtwoscreens(); + G_DisplayExtraScreens(); } if (*t != 0) initprintf("%s\n",t); if (qsetmode == 200) - Shutdown(); + G_Shutdown(); if (*t != 0) { @@ -3110,7 +2979,7 @@ void gameexit(const char *t) char inputloc = 0; -static int strget_(int small,int x,int y,char *t,int dalen,int c) +static int _EnterText(int small,int x,int y,char *t,int dalen,int c) { char ch; int i; @@ -3172,7 +3041,7 @@ static int strget_(int small,int x,int y,char *t,int dalen,int c) } c = 4-(sintable[(totalclock<<4)&2047]>>11); - i = gametextlen(USERQUOTE_LEFTOFFSET,stripcolorcodes(tempbuf,t)); + i = G_GameTextLen(USERQUOTE_LEFTOFFSET,stripcolorcodes(tempbuf,t)); while (i > (ud.config.ScreenWidth - USERQUOTE_RIGHTOFFSET)) { i -= (ud.config.ScreenWidth - USERQUOTE_RIGHTOFFSET); @@ -3187,25 +3056,25 @@ static int strget_(int small,int x,int y,char *t,int dalen,int c) return (0); } -inline int strget(int x,int y,char *t,int dalen,int c) +inline int G_EnterText(int x,int y,char *t,int dalen,int c) { - return(strget_(0,x,y,t,dalen,c)); + return(_EnterText(0,x,y,t,dalen,c)); } -inline int mpstrget(int x,int y,char *t,int dalen,int c) +inline int Net_EnterText(int x,int y,char *t,int dalen,int c) { - return(strget_(1,x,y,t,dalen,c)); + return(_EnterText(1,x,y,t,dalen,c)); } -static void typemode(void) +static void Net_EnterMessage(void) { short ch, hitstate, i, j, l; if (g_player[myconnectindex].ps->gm&MODE_SENDTOWHOM) { - if (sendmessagecommand != -1 || ud.multimode < 3 || movesperpacket == 4) + if (sendmessagecommand != -1 || ud.multimode < 3 || g_movesPerPacket == 4) { - tempbuf[0] = 4; + tempbuf[0] = PACKET_TYPE_MESSAGE; tempbuf[2] = 0; recbuf[0] = 0; @@ -3237,17 +3106,17 @@ static void typemode(void) recbuf[j] = 0; Bstrcat(tempbuf+2,recbuf); - if (sendmessagecommand >= ud.multimode || movesperpacket == 4) + if (sendmessagecommand >= ud.multimode || g_movesPerPacket == 4) { tempbuf[1] = 255; - for (ch=connecthead;ch >= 0;ch=connectpoint2[ch]) + TRAVERSE_CONNECT(ch) { if (ch != myconnectindex) sendpacket(ch,tempbuf,j+2); - if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master + if ((!g_networkBroadcastMode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master } - adduserquote(recbuf); + G_AddUserQuote(recbuf); quotebot += 8; - l = gametextlen(USERQUOTE_LEFTOFFSET,stripcolorcodes(tempbuf,recbuf)); + l = G_GameTextLen(USERQUOTE_LEFTOFFSET,stripcolorcodes(tempbuf,recbuf)); while (l > (ud.config.ScreenWidth - USERQUOTE_RIGHTOFFSET)) { l -= (ud.config.ScreenWidth - USERQUOTE_RIGHTOFFSET); @@ -3258,7 +3127,7 @@ static void typemode(void) else if (sendmessagecommand >= 0) { tempbuf[1] = (char)sendmessagecommand; - if ((!networkmode) && (myconnectindex != connecthead)) + if ((!g_networkBroadcastMode) && (myconnectindex != connecthead)) sendmessagecommand = connecthead; sendpacket(sendmessagecommand,tempbuf,j+2); } @@ -3271,7 +3140,7 @@ static void typemode(void) j = 50; gametext(320>>1,j,"SEND MESSAGE TO...",0,2+8+16); j += 8; - for (i=connecthead;i>=0;i=connectpoint2[i]) + TRAVERSE_CONNECT(i) { if (i == myconnectindex) { @@ -3335,7 +3204,7 @@ static void typemode(void) else j = 200-8; if (xdim >= 640 && ydim >= 480) j = scale(j,ydim,200); - hitstate = mpstrget(320>>1,j,typebuf,120,1); + hitstate = Net_EnterText(320>>1,j,typebuf,120,1); if (hitstate == 1) { @@ -3358,7 +3227,7 @@ static void typemode(void) } } -static void moveclouds(void) +static void G_MoveClouds(void) { if (totalclock > cloudtotalclock || totalclock < (cloudtotalclock-7)) { @@ -3366,7 +3235,7 @@ static void moveclouds(void) cloudtotalclock = totalclock+6; - for (i=numclouds-1;i>=0;i--) + for (i=g_numClouds-1;i>=0;i--) { cloudx[i] += (sintable[(g_player[screenpeek].ps->ang+512)&2047]>>9); cloudy[i] += (sintable[g_player[screenpeek].ps->ang&2047]>>9); @@ -3377,7 +3246,7 @@ static void moveclouds(void) } } -static void drawoverheadmap(int cposx, int cposy, int czoom, short cang) +static void G_DrawOverheadMap(int cposx, int cposy, int czoom, short cang) { int i, j, k, l, x1, y1, x2=0, y2=0, x3, y3, x4, y4, ox, oy, xoff, yoff; int dax, day, cosang, sinang, xspan, yspan, sprx, spry; @@ -3627,7 +3496,7 @@ static void drawoverheadmap(int cposx, int cposy, int czoom, short cang) } } - for (p=connecthead;p >= 0;p=connectpoint2[p]) + TRAVERSE_CONNECT(p) { if (ud.scrollmode && p == screenpeek) continue; @@ -3643,7 +3512,7 @@ static void drawoverheadmap(int cposx, int cposy, int czoom, short cang) x1 = mulscale(ox,xvect,16) - mulscale(oy,yvect,16); y1 = mulscale(oy,xvect2,16) + mulscale(ox,yvect2,16); - if (p == screenpeek || GTFLAGS(GAMETYPE_FLAG_OTHERPLAYERSINMAP)) + if (p == screenpeek || GTFLAGS(GAMETYPE_OTHERPLAYERSINMAP)) { if (sprite[g_player[p].ps->i].xvel > 16 && g_player[p].ps->on_ground) i = APLAYERTOP+((totalclock>>4)&3); @@ -3666,13 +3535,13 @@ static void drawoverheadmap(int cposx, int cposy, int czoom, short cang) #define CROSSHAIR_PAL (MAXPALOOKUPS-RESERVEDPALS-1) extern int getclosestcol(int r, int g, int b); -palette_t crosshair_colors = { 255, 255, 255, 0 }; -palette_t default_crosshair_colors = { 0, 0, 0, 0 }; +palette_t CrosshairColors = { 255, 255, 255, 0 }; +palette_t DefaultCrosshairColors = { 0, 0, 0, 0 }; int crosshair_sum; -void GetCrosshairColor(void) +void G_GetCrosshairColor(void) { - if (default_crosshair_colors.f == 0) + if (DefaultCrosshairColors.f == 0) { // use the brightest color in the original 8-bit tile int bri = 0, j = 0, i; @@ -3701,24 +3570,24 @@ void GetCrosshairColor(void) } while (ii > 0); - default_crosshair_colors.r = crosshair_colors.r = curpalette[bri].r; - default_crosshair_colors.g = crosshair_colors.g = curpalette[bri].g; - default_crosshair_colors.b = crosshair_colors.b = curpalette[bri].b; - default_crosshair_colors.f = 1; // this flag signifies that the color has been detected + DefaultCrosshairColors.r = CrosshairColors.r = curpalette[bri].r; + DefaultCrosshairColors.g = CrosshairColors.g = curpalette[bri].g; + DefaultCrosshairColors.b = CrosshairColors.b = curpalette[bri].b; + DefaultCrosshairColors.f = 1; // this flag signifies that the color has been detected } } -void SetCrosshairColor(int r, int g, int b) +void G_SetCrosshairColor(int r, int g, int b) { char *ptr = (char *)waloff[CROSSHAIR]; int i, ii; - if (default_crosshair_colors.f == 0 || crosshair_sum == r+(g<<1)+(b<<2)) return; + if (DefaultCrosshairColors.f == 0 || crosshair_sum == r+(g<<1)+(b<<2)) return; crosshair_sum = r+(g<<1)+(b<<2); - crosshair_colors.r = r; - crosshair_colors.g = g; - crosshair_colors.b = b; + CrosshairColors.r = r; + CrosshairColors.g = g; + CrosshairColors.b = b; if (waloff[CROSSHAIR] == 0) { @@ -3730,7 +3599,7 @@ void SetCrosshairColor(int r, int g, int b) if (ii <= 0) return; if (getrendermode() < 3) - i = getclosestcol(crosshair_colors.r>>2, crosshair_colors.g>>2, crosshair_colors.b>>2); + i = getclosestcol(CrosshairColors.r>>2, CrosshairColors.g>>2, CrosshairColors.b>>2); else i = getclosestcol(63, 63, 63); // use white in GL so we can tint it to the right color do @@ -3745,18 +3614,18 @@ void SetCrosshairColor(int r, int g, int b) for (i = 255; i >= 0; i--) tempbuf[i] = i; - makepalookup(CROSSHAIR_PAL,tempbuf,crosshair_colors.r>>2, crosshair_colors.g>>2, crosshair_colors.b>>2,1); + makepalookup(CROSSHAIR_PAL,tempbuf,CrosshairColors.r>>2, CrosshairColors.g>>2, CrosshairColors.b>>2,1); #if defined(USE_OPENGL) && defined(POLYMOST) - hictinting[CROSSHAIR_PAL].r = crosshair_colors.r; - hictinting[CROSSHAIR_PAL].g = crosshair_colors.g; - hictinting[CROSSHAIR_PAL].b = crosshair_colors.b; + hictinting[CROSSHAIR_PAL].r = CrosshairColors.r; + hictinting[CROSSHAIR_PAL].g = CrosshairColors.g; + hictinting[CROSSHAIR_PAL].b = CrosshairColors.b; hictinting[CROSSHAIR_PAL].f = 9; #endif invalidatetile(CROSSHAIR, -1, -1); } -void palto(int r,int g,int b,int e) +void G_FadePalette(int r,int g,int b,int e) { int tc; /* @@ -3781,12 +3650,14 @@ void palto(int r,int g,int b,int e) } } -void displayrest(int smoothratio) +void G_DisplayRest(int smoothratio) { int a, i, j; - char fader=0,fadeg=0,fadeb=0,fadef=0,tintr=0,tintg=0,tintb=0,tintf=0,dotint=0; + int dotint=0; + palette_t FadeTemp = { 0, 0, 0, 0 }; + palette_t TintTemp = { 0, 0, 0, 0 }; - player_struct *pp = g_player[screenpeek].ps; + DukePlayer_t *pp = g_player[screenpeek].ps; walltype *wal; int cposx,cposy,cang; @@ -3830,36 +3701,36 @@ void displayrest(int smoothratio) // this does pain tinting etc from the CON if (pp->pals_time >= 0 && pp->loogcnt == 0) // JBF 20040101: pals_time > 0 now >= 0 { - fader = pp->pals[0]; - fadeg = pp->pals[1]; - fadeb = pp->pals[2]; - fadef = pp->pals_time; - restorepalette = 1; // JBF 20040101 + FadeTemp.r = pp->pals[0]; + FadeTemp.g = pp->pals[1]; + FadeTemp.b = pp->pals[2]; + FadeTemp.f = pp->pals_time; + g_restorePalette = 1; // JBF 20040101 dotint = 1; } // reset a normal palette - else if (restorepalette) + else if (g_restorePalette) { //setbrightness(ud.brightness>>2,&pp->palette[0],0); - setgamepalette(pp,pp->palette,2); - restorepalette = 0; + SetGamePalette(pp,pp->palette,2); + g_restorePalette = 0; } // loogies courtesy of being snotted on else if (pp->loogcnt > 0) { - //palto(0,64,0,(pp->loogcnt>>1)+128); - fader = 0; - fadeg = 64; - fadeb = 0; - fadef = pp->loogcnt>>1; + //G_FadePalette(0,64,0,(pp->loogcnt>>1)+128); + FadeTemp.r = 0; + FadeTemp.g = 64; + FadeTemp.b = 0; + FadeTemp.f = pp->loogcnt>>1; dotint = 1; } - if (fadef > tintf) + if (FadeTemp.f > TintTemp.f) { - tintr = fader; - tintg = fadeg; - tintb = fadeb; - tintf = fadef; + TintTemp.r = FadeTemp.r; + TintTemp.g = FadeTemp.g; + TintTemp.b = FadeTemp.b; + TintTemp.f = FadeTemp.f; } if (ud.show_help) @@ -3884,9 +3755,9 @@ void displayrest(int smoothratio) ready2send = 1; totalclock = ototalclock; } - vscrn(); + G_UpdateScreenArea(); } - if (tintf > 0 || dotint) palto(tintr,tintg,tintb,tintf|128); + if (TintTemp.f > 0 || dotint) G_FadePalette(TintTemp.r,TintTemp.g,TintTemp.b,TintTemp.f|128); return; } @@ -3912,21 +3783,21 @@ void displayrest(int smoothratio) if (ud.overhead_on != 2) { if (pp->newowner >= 0) - cameratext(pp->newowner); + G_DrawCameraText(pp->newowner); else { - displayweapon(screenpeek); + P_DisplayWeapons(screenpeek); if (pp->over_shoulder_on == 0) - displaymasks(screenpeek); + P_DisplayScubaMask(screenpeek); } - moveclouds(); + G_MoveClouds(); } if (ud.overhead_on > 0) { // smoothratio = min(max(smoothratio,0),65536); smoothratio = min(max((totalclock - ototalclock) * (65536 / TICSPERFRAME),0),65536); - dointerpolations(smoothratio); + G_DoInterpolations(smoothratio); if (ud.scrollmode == 0) { if (pp->newowner == -1 && !ud.pause_on) @@ -3969,43 +3840,43 @@ void displayrest(int smoothratio) clearview(0L); drawmapview(cposx,cposy,pp->zoom,cang); } - drawoverheadmap(cposx,cposy,pp->zoom,cang); + G_DrawOverheadMap(cposx,cposy,pp->zoom,cang); - restoreinterpolations(); + G_RestoreInterpolations(); if (ud.overhead_on == 2) { if (ud.screen_size > 0) a = 147; else a = 179; - minitext(5,a+6,volume_names[ud.volume_number],0,2+8+16); - minitext(5,a+6+6,map[ud.volume_number*MAXLEVELS + ud.level_number].name,0,2+8+16); + minitext(5,a+6,EpisodeNames[ud.volume_number],0,2+8+16); + minitext(5,a+6+6,MapInfo[ud.volume_number*MAXLEVELS + ud.level_number].name,0,2+8+16); } } } - if (pp->invdisptime > 0) displayinventory(pp); + if (pp->invdisptime > 0) G_DrawInventory(pp); - SetGameVarID(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); - OnEvent(EVENT_DISPLAYSBAR, g_player[screenpeek].ps->i, screenpeek, -1); - if (GetGameVarID(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) - coolgaugetext(screenpeek); + Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); + X_OnEvent(EVENT_DISPLAYSBAR, g_player[screenpeek].ps->i, screenpeek, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) + G_DrawStatusBar(screenpeek); - operatefta(); + G_PrintGameQuotes(); - if (ud.show_level_text && hud_showmapname && leveltexttime > 1) + if (ud.show_level_text && hud_showmapname && g_levelTextTime > 1) { int bits = 10+16; - if (leveltexttime > 4) + if (g_levelTextTime > 4) bits = bits; - else if (leveltexttime > 2) + else if (g_levelTextTime > 2) bits |= 1; else bits |= 1+32; - if (map[(ud.volume_number*MAXLEVELS) + ud.level_number].name != NULL) + if (MapInfo[(ud.volume_number*MAXLEVELS) + ud.level_number].name != NULL) { if (currentboardfilename[0] != 0 && ud.volume_number == 0 && ud.level_number == 7) - menutext_(160,75,-leveltexttime+22/*(sintable[(totalclock<<5)&2047]>>11)*/,0,currentboardfilename,bits); - else menutext_(160,75,-leveltexttime+22/*(sintable[(totalclock<<5)&2047]>>11)*/,0,map[(ud.volume_number*MAXLEVELS) + ud.level_number].name,bits); + menutext_(160,75,-g_levelTextTime+22/*(sintable[(totalclock<<5)&2047]>>11)*/,0,currentboardfilename,bits); + else menutext_(160,75,-g_levelTextTime+22/*(sintable[(totalclock<<5)&2047]>>11)*/,0,MapInfo[(ud.volume_number*MAXLEVELS) + ud.level_number].name,bits); } } @@ -4013,7 +3884,7 @@ void displayrest(int smoothratio) && ud.show_help == 0 && g_player[myconnectindex].ps->newowner == -1) { - if ((g_player[myconnectindex].ps->gm&MODE_MENU) == MODE_MENU && current_menu < 51) + if ((g_player[myconnectindex].ps->gm&MODE_MENU) == MODE_MENU && g_currentMenu < 51) { KB_ClearKeyDown(sc_Escape); g_player[myconnectindex].ps->gm &= ~MODE_MENU; @@ -4021,11 +3892,11 @@ void displayrest(int smoothratio) { ready2send = 1; totalclock = ototalclock; - cameraclock = totalclock; - cameradist = 65536L; + g_cameraClock = totalclock; + g_cameraDistance = 65536L; } walock[TILE_SAVESHOT] = 199; - vscrn(); + G_UpdateScreenArea(); } else if ((g_player[myconnectindex].ps->gm&MODE_MENU) != MODE_MENU && g_player[myconnectindex].ps->newowner == -1 && @@ -4033,37 +3904,37 @@ void displayrest(int smoothratio) { KB_ClearKeyDown(sc_Escape); FX_StopAllSounds(); - clearsoundlocks(); + S_ClearSoundLocks(); - intomenusounds(); + S_MenuSound(); g_player[myconnectindex].ps->gm |= MODE_MENU; if (ud.multimode < 2 && ud.recstat != 2) ready2send = 0; - if (g_player[myconnectindex].ps->gm&MODE_GAME) cmenu(50); - else cmenu(0); + if (g_player[myconnectindex].ps->gm&MODE_GAME) ChangeToMenu(50); + else ChangeToMenu(0); screenpeek = myconnectindex; } } - OnEvent(EVENT_DISPLAYREST, g_player[screenpeek].ps->i, screenpeek, -1); + X_OnEvent(EVENT_DISPLAYREST, g_player[screenpeek].ps->i, screenpeek, -1); if (g_player[myconnectindex].ps->newowner == -1 && ud.overhead_on == 0 && ud.crosshair && ud.camerasprite == -1) { - SetGameVarID(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); - OnEvent(EVENT_DISPLAYCROSSHAIR, g_player[screenpeek].ps->i, screenpeek, -1); - if (GetGameVarID(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) + Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); + X_OnEvent(EVENT_DISPLAYCROSSHAIR, g_player[screenpeek].ps->i, screenpeek, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) rotatesprite((160L-(g_player[myconnectindex].ps->look_ang>>1))<<16,100L<<16,scale(65536,ud.crosshairscale,100),0,CROSSHAIR,0,CROSSHAIR_PAL,2+1,windowx1,windowy1,windowx2,windowy2); } #if 0 - if (gametype_flags[ud.coop] & GAMETYPE_FLAG_TDM) + if (GametypeFlags[ud.coop] & GAMETYPE_TDM) { for (i=0;iteam == g_player[myconnectindex].ps->team) { - j = min(max((getincangle(getangle(g_player[i].ps->posx-g_player[myconnectindex].ps->posx,g_player[i].ps->posy-g_player[myconnectindex].ps->posy),g_player[myconnectindex].ps->ang))>>1,-160),160); + j = min(max((G_GetAngleDelta(getangle(g_player[i].ps->posx-g_player[myconnectindex].ps->posx,g_player[i].ps->posy-g_player[myconnectindex].ps->posy),g_player[myconnectindex].ps->ang))>>1,-160),160); rotatesprite((160-j)<<16,100L<<16,65536L,0,DUKEICON,0,0,2+1,windowx1,windowy1,windowx2,windowy2); } } @@ -4074,7 +3945,7 @@ void displayrest(int smoothratio) menutext(160,100,0,0,"GAME PAUSED"); if (ud.coords) - ShowCoordinates(screenpeek); + G_PrintCoords(screenpeek); #if defined(POLYMOST) && defined(USE_OPENGL) { @@ -4086,7 +3957,7 @@ void displayrest(int smoothratio) } #endif - ShowFrameRate(); + G_PrintFrameRate(); // JBF 20040124: display level stats in screen corner if ((ud.overhead_on != 2 && ud.levelstats) && (g_player[myconnectindex].ps->gm&MODE_MENU) == 0) @@ -4115,8 +3986,8 @@ void displayrest(int smoothratio) ); gametext_z(13,STARTALPHANUM, j,scale(200-i,ud.config.ScreenHeight,200)-textsc(21),tempbuf,0,10,26,0, 0, xdim-1, ydim-1, 65536); - if (ud.player_skill > 3 || (ud.multimode > 1 && !GTFLAGS(GAMETYPE_FLAG_PLAYERSFRIENDLY))) - Bsprintf(tempbuf,"K:^15%d",(ud.multimode>1 &&!GTFLAGS(GAMETYPE_FLAG_PLAYERSFRIENDLY))?g_player[myconnectindex].ps->frag-g_player[myconnectindex].ps->fraggedself:g_player[myconnectindex].ps->actors_killed); + if (ud.player_skill > 3 || (ud.multimode > 1 && !GTFLAGS(GAMETYPE_PLAYERSFRIENDLY))) + Bsprintf(tempbuf,"K:^15%d",(ud.multimode>1 &&!GTFLAGS(GAMETYPE_PLAYERSFRIENDLY))?g_player[myconnectindex].ps->frag-g_player[myconnectindex].ps->fraggedself:g_player[myconnectindex].ps->actors_killed); else { if (g_player[myconnectindex].ps->actors_killed >= g_player[myconnectindex].ps->max_actors_killed) @@ -4137,14 +4008,15 @@ void displayrest(int smoothratio) } if (g_player[myconnectindex].ps->gm&MODE_TYPE) - typemode(); + Net_EnterMessage(); else - menus(); + M_DisplayMenus(); - if (tintf > 0 || dotint) palto(tintr,tintg,tintb,tintf|128); + if (TintTemp.f > 0 || dotint) + G_FadePalette(TintTemp.r,TintTemp.g,TintTemp.b,TintTemp.f|128); } -static void view(player_struct *pp, int *vx, int *vy,int *vz,short *vsectnum, int ang, int horiz) +static void G_DoThirdPerson(DukePlayer_t *pp, int *vx, int *vy,int *vz,short *vsectnum, int ang, int horiz) { spritetype *sp = &sprite[pp->i]; int i, hx, hy, hitx, hity, hitz; @@ -4186,14 +4058,14 @@ static void view(player_struct *pp, int *vx, int *vy,int *vz,short *vsectnum, in } if (klabs(nx) > klabs(ny)) i = divscale16(hx,nx); else i = divscale16(hy,ny); - if (i < cameradist) cameradist = i; + if (i < g_cameraDistance) g_cameraDistance = i; } - *vx = (*vx)+mulscale16(nx,cameradist); - *vy = (*vy)+mulscale16(ny,cameradist); - *vz = (*vz)+mulscale16(nz,cameradist); + *vx = (*vx)+mulscale16(nx,g_cameraDistance); + *vy = (*vy)+mulscale16(ny,g_cameraDistance); + *vz = (*vz)+mulscale16(nz,g_cameraDistance); - cameradist = min(cameradist+((totalclock-cameraclock)<<10),65536); - cameraclock = totalclock; + g_cameraDistance = min(g_cameraDistance+((totalclock-g_cameraClock)<<10),65536); + g_cameraClock = totalclock; updatesectorz(*vx,*vy,*vz,vsectnum); @@ -4201,7 +4073,7 @@ static void view(player_struct *pp, int *vx, int *vy,int *vz,short *vsectnum, in } //REPLACE FULLY -void drawbackground(void) +void G_DrawBackground(void) { int dapicnum; int x,y,x1,y1,x2,y2,rx; @@ -4235,7 +4107,7 @@ void drawbackground(void) // if (ud.screen_size == 8 && ud.statusbarmode == 0) // y1 = scale(ydim,200-scale(tilesizy[BOTTOMSTATUSBAR],ud.statusbarscale,100),200); //else - if (gametype_flags[ud.coop] & GAMETYPE_FLAG_FRAGBAR) + if (GametypeFlags[ud.coop] & GAMETYPE_FRAGBAR) { if (ud.multimode > 1) y1 += scale(ydim,8,200); if (ud.multimode > 4) y1 += scale(ydim,8,200); @@ -4245,15 +4117,15 @@ void drawbackground(void) { // when not rendering a game, fullscreen wipe #define MENUTILE (!getrendermode()?MENUSCREEN:LOADSCREEN) - SetGameVarID(g_iReturnVarID,tilesizx[MENUTILE]==320&&tilesizy[MENUTILE]==200?MENUTILE:BIGHOLE, -1, -1); - OnEvent(EVENT_GETMENUTILE, -1, myconnectindex, -1); - if (GetGameVar("MENU_TILE", tilesizx[MENUTILE]==320&&tilesizy[MENUTILE]==200?0:1, -1, -1)) + Gv_SetVar(g_iReturnVarID,tilesizx[MENUTILE]==320&&tilesizy[MENUTILE]==200?MENUTILE:BIGHOLE, -1, -1); + X_OnEvent(EVENT_GETMENUTILE, -1, myconnectindex, -1); + if (Gv_GetVarByLabel("MENU_TILE", tilesizx[MENUTILE]==320&&tilesizy[MENUTILE]==200?0:1, -1, -1)) { - for (y=y1;y 8) { y = 0; - if (gametype_flags[ud.coop] & GAMETYPE_FLAG_FRAGBAR) + if (GametypeFlags[ud.coop] & GAMETYPE_FRAGBAR) { if (ud.multimode > 1) y += 8; if (ud.multimode > 4) y += 8; @@ -4466,7 +4338,7 @@ static void SE40_Draw(int spnum,int x,int y,int z,int a,int h,int smoothratio) } drawrooms(x+offx,y+offy,z+offz,a,h,sprite[floor2].sectnum); - animatesprites(x,y,a,smoothratio); + G_DoSpriteAnimations(x,y,a,smoothratio); drawmasks(); if (draw_both) @@ -4492,7 +4364,7 @@ static void SE40_Draw(int spnum,int x,int y,int z,int a,int h,int smoothratio) // Now re-draw drawrooms(x+offx,y+offy,z+offz,a,h,sprite[floor2].sectnum); - animatesprites(x,y,a,smoothratio); + G_DoSpriteAnimations(x,y,a,smoothratio); drawmasks(); } } // end SE40 @@ -4526,19 +4398,19 @@ void se40code(int x,int y,int z,int a,int h, int smoothratio) static int oyrepeat=-1; extern float r_ambientlight; -void displayrooms(int snum,int smoothratio) +void G_DrawRooms(int snum,int smoothratio) { int dst,j,fz,cz; int tposx,tposy,i; short k; - player_struct *p = g_player[snum].ps; + DukePlayer_t *p = g_player[snum].ps; short tang; int tiltcx,tiltcy,tiltcs=0; // JBF 20030807 if (pub > 0 || getrendermode() >= 3) // JBF 20040101: redraw background always { if (getrendermode() >= 3 || ud.screen_size > 8 || (ud.screen_size == 8 && ud.statusbarscale<100)) - drawbackground(); + G_DrawBackground(); pub = 0; } @@ -4556,9 +4428,9 @@ void displayrooms(int snum,int smoothratio) if (getrendermode() < 3 && (ud.camerasect < 0 || ud.camerasect >= MAXSECTORS)) return; - dointerpolations(smoothratio); + G_DoInterpolations(smoothratio); - animatecamsprite(); + G_AnimateCamSprite(); if (ud.camerasprite >= 0) { @@ -4567,16 +4439,16 @@ void displayrooms(int snum,int smoothratio) if (s->yvel < 0) s->yvel = -100; else if (s->yvel > 199) s->yvel = 300; - ud.cameraang = hittype[ud.camerasprite].tempang+mulscale16((int)(((s->ang+1024-hittype[ud.camerasprite].tempang)&2047)-1024),smoothratio); + ud.cameraang = ActorExtra[ud.camerasprite].tempang+mulscale16((int)(((s->ang+1024-ActorExtra[ud.camerasprite].tempang)&2047)-1024),smoothratio); #ifdef SE40 se40code(s->x,s->y,s->z,ud.cameraang,s->yvel,smoothratio); #endif #ifdef POLYMER if (getrendermode() == 4) - polymer_setanimatesprites(animatesprites, s->x, s->y, ud.cameraang, smoothratio); + polymer_setanimatesprites(G_DoSpriteAnimations, s->x, s->y, ud.cameraang, smoothratio); #endif drawrooms(s->x,s->y,s->z-(4<<8),ud.cameraang,s->yvel,s->sectnum); - animatesprites(s->x,s->y,ud.cameraang,smoothratio); + G_DoSpriteAnimations(s->x,s->y,ud.cameraang,smoothratio); drawmasks(); } else @@ -4588,7 +4460,7 @@ void displayrooms(int snum,int smoothratio) setaspect(oyrepeat,yxaspect); } - if (screencapt) + if (g_screenCapture) { walock[TILE_SAVESHOT] = 199; if (waloff[TILE_SAVESHOT] == 0) @@ -4681,15 +4553,15 @@ void displayrooms(int snum,int smoothratio) if (ud.viewbob) ud.cameraz += p->opyoff+mulscale16((int)(p->pyoff-p->opyoff),smoothratio); } - else view(p,&ud.camerax,&ud.cameray,&ud.cameraz,&ud.camerasect,ud.cameraang,ud.camerahoriz); + else G_DoThirdPerson(p,&ud.camerax,&ud.cameray,&ud.cameraz,&ud.camerasect,ud.cameraang,ud.camerahoriz); - cz = hittype[p->i].ceilingz; - fz = hittype[p->i].floorz; + cz = ActorExtra[p->i].ceilingz; + fz = ActorExtra[p->i].floorz; - if (earthquaketime > 0 && p->on_ground == 1) + if (g_earthquakeTime > 0 && p->on_ground == 1) { - ud.cameraz += 256-(((earthquaketime)&1)<<9); - ud.cameraang += (2-((earthquaketime)&2))<<2; + ud.cameraz += 256-(((g_earthquakeTime)&1)<<9); + ud.cameraang += (2-((g_earthquakeTime)&2))<<2; } if (sprite[p->i].pal == 1) ud.cameraz -= (18<<8); @@ -4712,7 +4584,7 @@ void displayrooms(int snum,int smoothratio) if (ud.camerahoriz > HORIZ_MAX) ud.camerahoriz = HORIZ_MAX; else if (ud.camerahoriz < HORIZ_MIN) ud.camerahoriz = HORIZ_MIN; - OnEvent(EVENT_DISPLAYROOMS, g_player[screenpeek].ps->i, screenpeek, -1); + X_OnEvent(EVENT_DISPLAYROOMS, g_player[screenpeek].ps->i, screenpeek, -1); #ifdef SE40 se40code(ud.camerax,ud.cameray,ud.cameraz,ud.cameraang,ud.camerahoriz,smoothratio); @@ -4725,24 +4597,24 @@ void displayrooms(int snum,int smoothratio) { dst = 0x7fffffff; i = 0; - for (k=mirrorcnt-1;k>=0;k--) + for (k=g_mirrorCount-1;k>=0;k--) { - j = klabs(wall[mirrorwall[k]].x-ud.camerax); - j += klabs(wall[mirrorwall[k]].y-ud.cameray); + j = klabs(wall[g_mirrorWall[k]].x-ud.camerax); + j += klabs(wall[g_mirrorWall[k]].y-ud.cameray); if (j < dst) dst = j, i = k; } - if (wall[mirrorwall[i]].overpicnum == MIRROR) + if (wall[g_mirrorWall[i]].overpicnum == MIRROR) { - preparemirror(ud.camerax,ud.cameray,ud.cameraz,ud.cameraang,ud.camerahoriz,mirrorwall[i],mirrorsector[i],&tposx,&tposy,&tang); + preparemirror(ud.camerax,ud.cameray,ud.cameraz,ud.cameraang,ud.camerahoriz,g_mirrorWall[i],g_mirrorSector[i],&tposx,&tposy,&tang); j = visibility; visibility = (j>>1) + (j>>2); - drawrooms(tposx,tposy,ud.cameraz,tang,ud.camerahoriz,mirrorsector[i]+MAXSECTORS); + drawrooms(tposx,tposy,ud.cameraz,tang,ud.camerahoriz,g_mirrorSector[i]+MAXSECTORS); display_mirror = 1; - animatesprites(tposx,tposy,tang,smoothratio); + G_DoSpriteAnimations(tposx,tposy,tang,smoothratio); display_mirror = 0; drawmasks(); @@ -4754,16 +4626,16 @@ void displayrooms(int snum,int smoothratio) #ifdef POLYMER if (getrendermode() == 4) - polymer_setanimatesprites(animatesprites, ud.camerax,ud.cameray,ud.cameraang,smoothratio); + polymer_setanimatesprites(G_DoSpriteAnimations, ud.camerax,ud.cameray,ud.cameraang,smoothratio); #endif drawrooms(ud.camerax,ud.cameray,ud.cameraz,ud.cameraang,ud.camerahoriz,ud.camerasect); - animatesprites(ud.camerax,ud.cameray,ud.cameraang,smoothratio); + G_DoSpriteAnimations(ud.camerax,ud.cameray,ud.cameraang,smoothratio); drawmasks(); - if (screencapt == 1) + if (g_screenCapture == 1) { setviewback(); - screencapt = 0; + g_screenCapture = 0; // walock[TILE_SAVESHOT] = 1; } else if (getrendermode() == 0 && ((ud.screen_tilting && p->rotscrnang) || ud.detail==0)) @@ -4786,7 +4658,7 @@ void displayrooms(int snum,int smoothratio) } } - restoreinterpolations(); + G_RestoreInterpolations(); if (totalclock < lastvisinc) { @@ -4796,7 +4668,7 @@ void displayrooms(int snum,int smoothratio) else p->visibility = ud.const_visibility; } -static void dumpdebugdata(void) +static void G_DumpDebugInfo(void) { int i,j,x; FILE * fp=fopen("debug.con","w"); @@ -4822,6 +4694,7 @@ static void dumpdebugdata(void) fprintf(fp,"WEAPON%d_SOUND2SOUND %" PRIdPTR "\n",i,aplWeaponSound2Sound[i][j]); fprintf(fp,"WEAPON%d_RELOADSOUND1 %" PRIdPTR "\n",i,aplWeaponReloadSound1[i][j]); fprintf(fp,"WEAPON%d_RELOADSOUND2 %" PRIdPTR "\n",i,aplWeaponReloadSound2[i][j]); + fprintf(fp,"WEAPON%d_SELECTSOUND %" PRIdPTR "\n",i,aplWeaponSelectSound[i][j]); } fprintf(fp,"\n"); } @@ -4831,19 +4704,19 @@ static void dumpdebugdata(void) while (j >= 0) { fprintf(fp,"Sprite %d (%d,%d,%d) (picnum: %d)\n",j,sprite[j].x,sprite[j].y,sprite[j].z,sprite[j].picnum); - for (i=0;iposx,&g_player[myconnectindex].ps->posy,&g_player[myconnectindex].ps->posz,&g_player[myconnectindex].ps->ang,&g_player[myconnectindex].ps->cursectnum); } -int EGS(int whatsect,int s_x,int s_y,int s_z,int s_pn,int s_s,int s_xr,int s_yr,int s_a,int s_ve,int s_zv,int s_ow,int s_ss) +int A_InsertSprite(int whatsect,int s_x,int s_y,int s_z,int s_pn,int s_s,int s_xr,int s_yr,int s_a,int s_ve,int s_zv,int s_ow,int s_ss) { int i = insertsprite(whatsect,s_ss); int p; @@ -4869,14 +4742,14 @@ int EGS(int whatsect,int s_x,int s_y,int s_z,int s_pn,int s_s,int s_xr,int s_yr, if (i < 0) { - dumpdebugdata(); + G_DumpDebugInfo(); OSD_Printf("Failed spawning sprite with tile %d from sprite %d (%d) at x:%d,y:%d,z:%d,sector:%d\n",s_pn,s_ow,sprite[s_ow].picnum,s_x,s_y,s_z,whatsect); - gameexit("Too many sprites spawned."); + G_GameExit("Too many sprites spawned."); } - hittype[i].bposx = s_x; - hittype[i].bposy = s_y; - hittype[i].bposz = s_z; + ActorExtra[i].bposx = s_x; + ActorExtra[i].bposy = s_y; + ActorExtra[i].bposz = s_z; s->x = s_x; s->y = s_y; @@ -4901,26 +4774,26 @@ int EGS(int whatsect,int s_x,int s_y,int s_z,int s_pn,int s_s,int s_xr,int s_yr, if (s_ow > -1 && s_ow < MAXSPRITES) { - hittype[i].picnum = sprite[s_ow].picnum; - hittype[i].floorz = hittype[s_ow].floorz; - hittype[i].ceilingz = hittype[s_ow].ceilingz; + ActorExtra[i].picnum = sprite[s_ow].picnum; + ActorExtra[i].floorz = ActorExtra[s_ow].floorz; + ActorExtra[i].ceilingz = ActorExtra[s_ow].ceilingz; } - hittype[i].lastvx = 0; - hittype[i].lastvy = 0; + ActorExtra[i].lastvx = 0; + ActorExtra[i].lastvy = 0; - hittype[i].timetosleep = 0; - hittype[i].actorstayput = -1; - hittype[i].extra = -1; - hittype[i].owner = s_ow; - hittype[i].cgg = 0; - hittype[i].movflag = 0; - hittype[i].tempang = 0; - hittype[i].dispicnum = 0; + ActorExtra[i].timetosleep = 0; + ActorExtra[i].actorstayput = -1; + ActorExtra[i].extra = -1; + ActorExtra[i].owner = s_ow; + ActorExtra[i].cgg = 0; + ActorExtra[i].movflag = 0; + ActorExtra[i].tempang = 0; + ActorExtra[i].dispicnum = 0; T1=T3=T4=T6=T7=T8=T9=0; - hittype[i].flags = 0; + ActorExtra[i].flags = 0; sprpos[i].ang = sprpos[i].oldang = sprite[i].ang; @@ -4951,81 +4824,23 @@ int EGS(int whatsect,int s_x,int s_y,int s_z,int s_pn,int s_s,int s_xr,int s_yr, changespritestat(i,5); } */ - ResetActorGameVars(i); - hittype[i].flags = 0; + A_ResetGameVars(i); + ActorExtra[i].flags = 0; if (apScriptGameEvent[EVENT_EGS]) { extern int block_deletesprite; - int pl=findplayer(&sprite[i],&p); + int pl=A_FindPlayer(&sprite[i],&p); block_deletesprite++; - OnEvent(EVENT_EGS,i, pl, p); + X_OnEvent(EVENT_EGS,i, pl, p); block_deletesprite--; } return(i); } -int wallswitchcheck(int i) -{ - int j; - //MULTISWITCH has 4 states so deal with it separately - if ((PN >= MULTISWITCH) && (PN <=MULTISWITCH+3)) return 1; - // ACCESSSWITCH and ACCESSSWITCH2 are only active in 1 state so deal with them separately - if ((PN == ACCESSSWITCH) || (PN == ACCESSSWITCH2)) return 1; - //loop to catch both states of switches - for (j=0;j<=1;j++) - { - switch (dynamictostatic[PN-j]) - { - case HANDPRINTSWITCH__STATIC: - //case HANDPRINTSWITCH+1: - case ALIENSWITCH__STATIC: - //case ALIENSWITCH+1: - case MULTISWITCH__STATIC: - //case MULTISWITCH+1: - //case MULTISWITCH+2: - //case MULTISWITCH+3: - //case ACCESSSWITCH: - //case ACCESSSWITCH2: - case PULLSWITCH__STATIC: - //case PULLSWITCH+1: - case HANDSWITCH__STATIC: - //case HANDSWITCH+1: - case SLOTDOOR__STATIC: - //case SLOTDOOR+1: - case LIGHTSWITCH__STATIC: - //case LIGHTSWITCH+1: - case SPACELIGHTSWITCH__STATIC: - //case SPACELIGHTSWITCH+1: - case SPACEDOORSWITCH__STATIC: - //case SPACEDOORSWITCH+1: - case FRANKENSTINESWITCH__STATIC: - //case FRANKENSTINESWITCH+1: - case LIGHTSWITCH2__STATIC: - //case LIGHTSWITCH2+1: - case POWERSWITCH1__STATIC: - //case POWERSWITCH1+1: - case LOCKSWITCH1__STATIC: - //case LOCKSWITCH1+1: - case POWERSWITCH2__STATIC: - //case POWERSWITCH2+1: - case DIPSWITCH__STATIC: - //case DIPSWITCH+1: - case DIPSWITCH2__STATIC: - //case DIPSWITCH2+1: - case TECHSWITCH__STATIC: - //case TECHSWITCH+1: - case DIPSWITCH3__STATIC: - //case DIPSWITCH3+1: - return 1; - } - } - return 0; -} - -int spawn(int j, int pn) +int A_Spawn(int j, int pn) { int i, s, startwall, endwall, sect, clostest=0; int x, y, d, p; @@ -5033,36 +4848,36 @@ int spawn(int j, int pn) if (j >= 0) { - i = EGS(sprite[j].sectnum,sprite[j].x,sprite[j].y,sprite[j].z - ,pn,0,0,0,0,0,0,j,0); - hittype[i].picnum = sprite[j].picnum; + i = A_InsertSprite(sprite[j].sectnum,sprite[j].x,sprite[j].y,sprite[j].z + ,pn,0,0,0,0,0,0,j,0); + ActorExtra[i].picnum = sprite[j].picnum; } else { i = pn; - hittype[i].picnum = PN; - hittype[i].timetosleep = 0; - hittype[i].extra = -1; + ActorExtra[i].picnum = PN; + ActorExtra[i].timetosleep = 0; + ActorExtra[i].extra = -1; - hittype[i].bposx = SX; - hittype[i].bposy = SY; - hittype[i].bposz = SZ; + ActorExtra[i].bposx = SX; + ActorExtra[i].bposy = SY; + ActorExtra[i].bposz = SZ; - OW = hittype[i].owner = i; - hittype[i].cgg = 0; - hittype[i].movflag = 0; - hittype[i].tempang = 0; - hittype[i].dispicnum = 0; - hittype[i].floorz = sector[SECT].floorz; - hittype[i].ceilingz = sector[SECT].ceilingz; + OW = ActorExtra[i].owner = i; + ActorExtra[i].cgg = 0; + ActorExtra[i].movflag = 0; + ActorExtra[i].tempang = 0; + ActorExtra[i].dispicnum = 0; + ActorExtra[i].floorz = sector[SECT].floorz; + ActorExtra[i].ceilingz = sector[SECT].ceilingz; - hittype[i].lastvx = 0; - hittype[i].lastvy = 0; - hittype[i].actorstayput = -1; + ActorExtra[i].lastvx = 0; + ActorExtra[i].lastvy = 0; + ActorExtra[i].actorstayput = -1; T1 = T2 = T3 = T4 = T5 = T6 = T7 = T8 = T9 = 0; - hittype[i].flags = 0; + ActorExtra[i].flags = 0; sprpos[i].ang = sprpos[i].oldang = sprite[i].ang; @@ -5070,11 +4885,11 @@ int spawn(int j, int pn) if (!(PN >= CRACK1 && PN <= CRACK4)) { if (SS == 127) return i; - if (wallswitchcheck(i) == 1 && (CS&16)) + if (A_CheckSwitchTile(i) == 1 && (CS&16)) { if (PN != ACCESSSWITCH && PN != ACCESSSWITCH2 && sprite[i].pal) { - if ((ud.multimode < 2) || (ud.multimode > 1 && !GTFLAGS(GAMETYPE_FLAG_DMSWITCHES))) + if ((ud.multimode < 2) || (ud.multimode > 1 && !GTFLAGS(GAMETYPE_DMSWITCHES))) { sprite[i].xrepeat = sprite[i].yrepeat = 0; sprite[i].cstat = SLT = SHT = 0; @@ -5091,7 +4906,7 @@ int spawn(int j, int pn) { changespritestat(i,12); CS |= 257; - SH = impact_damage; + SH = g_impactDamage; return i; } } @@ -5128,7 +4943,7 @@ int spawn(int j, int pn) { sp->extra = 1; - if (camerashitable) sp->cstat = 257; + if (g_damageCameras) sp->cstat = 257; else sp->cstat = 0; } if (ud.multimode < 2 && sp->pal != 0) @@ -5147,7 +4962,7 @@ int spawn(int j, int pn) } } } - else switch (dynamictostatic[sp->picnum]) + else switch (DynamicTileMap[sp->picnum]) { default: if (actorscrptr[sp->picnum]) @@ -5163,7 +4978,7 @@ int spawn(int j, int pn) if (sp->xrepeat == 0 || sp->yrepeat == 0) sp->xrepeat = sp->yrepeat = 1; - if (actortype[sp->picnum] & 3) + if (ActorType[sp->picnum] & 3) { if (ud.monsters_off == 1) { @@ -5172,17 +4987,17 @@ int spawn(int j, int pn) break; } - makeitfall(i); + A_Fall(i); - if (actortype[sp->picnum] & 2) - hittype[i].actorstayput = sp->sectnum; + if (ActorType[sp->picnum] & 2) + ActorExtra[i].actorstayput = sp->sectnum; g_player[myconnectindex].ps->max_actors_killed++; sp->clipdist = 80; if (j >= 0) { if (sprite[j].picnum == RESPAWN) - hittype[i].tempang = sprite[i].pal = sprite[j].pal; + ActorExtra[i].tempang = sprite[i].pal = sprite[j].pal; changespritestat(i,1); } else changespritestat(i,2); @@ -5194,7 +5009,7 @@ int spawn(int j, int pn) changespritestat(i,1); } - hittype[i].timetosleep = 0; + ActorExtra[i].timetosleep = 0; if (j >= 0) sp->ang = sprite[j].ang; @@ -5208,9 +5023,9 @@ int spawn(int j, int pn) if (j >= 0) { setsprite(i,sprite[j].x,sprite[j].y,sprite[j].z); - sp->xrepeat = sp->yrepeat = 8+(TRAND&7); + sp->xrepeat = sp->yrepeat = 8+(krand()&7); } - else sp->xrepeat = sp->yrepeat = 16+(TRAND&15); + else sp->xrepeat = sp->yrepeat = 16+(krand()&15); sp->shade = -16; sp->cstat |= 128; @@ -5261,8 +5076,8 @@ int spawn(int j, int pn) if (j >= 0) sp->ang = sprite[j].ang; sp->z -= 38<<8; - sp->zvel = 256-(TRAND&511); - sp->xvel = 64-(TRAND&127); + sp->zvel = 256-(krand()&511); + sp->xvel = 64-(krand()&127); changespritestat(i,4); break; case NATURALLIGHTNING__STATIC: @@ -5289,7 +5104,7 @@ int spawn(int j, int pn) { sp->xrepeat = 48; sp->yrepeat = 64; - if (sprite[j].statnum == 10 || badguy(&sprite[j])) + if (sprite[j].statnum == 10 || A_CheckEnemySprite(&sprite[j])) sp->z -= (32<<8); } } @@ -5300,7 +5115,7 @@ int spawn(int j, int pn) sp->xvel = 128; changespritestat(i,5); - ssp(i,CLIPMASK0); + A_SetSprite(i,CLIPMASK0); setsprite(i,sp->x,sp->y,sp->z); break; @@ -5323,9 +5138,9 @@ int spawn(int j, int pn) sp->yrepeat = 6; sp->xrepeat = 32; - if (lasermode == 1) + if (g_tripbombLaserMode == 1) sp->cstat = 16 + 2; - else if (lasermode == 0 || lasermode == 2) + else if (g_tripbombLaserMode == 0 || g_tripbombLaserMode == 2) sp->cstat = 16; else { @@ -5333,7 +5148,7 @@ int spawn(int j, int pn) sp->yrepeat = 0; } - if (j >= 0) sp->ang = hittype[j].temp_data[5]+512; + if (j >= 0) sp->ang = ActorExtra[j].temp_data[5]+512; changespritestat(i,5); break; @@ -5439,12 +5254,12 @@ int spawn(int j, int pn) case BLOODSPLAT3__STATIC: case BLOODSPLAT4__STATIC: sp->cstat |= 16; - sp->xrepeat = 7+(TRAND&7); - sp->yrepeat = 7+(TRAND&7); + sp->xrepeat = 7+(krand()&7); + sp->yrepeat = 7+(krand()&7); sp->z -= (16<<8); if (j >= 0 && sprite[j].pal == 6) sp->pal = 6; - insertspriteq(i); + A_AddToDeleteQueue(i); changespritestat(i,5); break; @@ -5463,10 +5278,10 @@ int spawn(int j, int pn) sp->hitag = i; sp->xvel = 16; - ssp(i,CLIPMASK0); - hittype[i].temp_data[0] = 17; - hittype[i].temp_data[2] = 0; - hittype[i].temp_data[5] = sp->ang; + A_SetSprite(i,CLIPMASK0); + ActorExtra[i].temp_data[0] = 17; + ActorExtra[i].temp_data[2] = 0; + ActorExtra[i].temp_data[5] = sp->ang; case SPACEMARINE__STATIC: if (sp->picnum == SPACEMARINE) @@ -5636,7 +5451,7 @@ int spawn(int j, int pn) if (sector[sect].lotag != 1 && sector[sect].lotag != 2) sp->xrepeat = sp->yrepeat = 32; - insertspriteq(i); + A_AddToDeleteQueue(i); changespritestat(i,5); break; @@ -5697,7 +5512,7 @@ int spawn(int j, int pn) if (sp->picnum == RESPAWNMARKERRED) { sp->xrepeat = sp->yrepeat = 24; - if (j >= 0) sp->z = hittype[j].floorz; // -(1<<4); + if (j >= 0) sp->z = ActorExtra[j].floorz; // -(1<<4); } else { @@ -5721,16 +5536,16 @@ int spawn(int j, int pn) case BULLETHOLE__STATIC: sp->xrepeat = sp->yrepeat = 3; sp->cstat = 16+(krand()&12); - insertspriteq(i); + A_AddToDeleteQueue(i); case MONEY__STATIC: case MAIL__STATIC: case PAPER__STATIC: if (sp->picnum == MONEY || sp->picnum == MAIL || sp->picnum == PAPER) { - hittype[i].temp_data[0] = TRAND&2047; - sp->cstat = TRAND&12; + ActorExtra[i].temp_data[0] = krand()&2047; + sp->cstat = krand()&12; sp->xrepeat = sp->yrepeat = 8; - sp->ang = TRAND&2047; + sp->ang = krand()&2047; } changespritestat(i,5); break; @@ -5752,14 +5567,14 @@ int spawn(int j, int pn) if (sprite[j].picnum == APLAYER) { snum = sprite[j].yvel; - a = g_player[snum].ps->ang-(TRAND&63)+8; //Fine tune + a = g_player[snum].ps->ang-(krand()&63)+8; //Fine tune - T1 = TRAND&1; + T1 = krand()&1; sp->z = (3<<8)+g_player[snum].ps->pyoff+g_player[snum].ps->posz- ((g_player[snum].ps->horizoff+g_player[snum].ps->horiz-100)<<4); if (sp->picnum == SHOTGUNSHELL) sp->z += (3<<8); - sp->zvel = -(TRAND&255); + sp->zvel = -(krand()&255); } else { @@ -5813,7 +5628,7 @@ int spawn(int j, int pn) { sp->ang = sprite[j].ang; sp->shade = -64; - sp->cstat = 128|(TRAND&4); + sp->cstat = 128|(krand()&4); } if (sp->picnum == EXPLOSION2 || sp->picnum == EXPLOSION2BOT) @@ -5867,7 +5682,7 @@ int spawn(int j, int pn) sp->xrepeat = sp->yrepeat = 0; //j = ud.coop; //if(j == 2) j = 0; - j=(gametype_flags[ud.coop] & GAMETYPE_FLAG_COOPSPAWN) / GAMETYPE_FLAG_COOPSPAWN ; + j=(GametypeFlags[ud.coop] & GAMETYPE_COOPSPAWN) / GAMETYPE_COOPSPAWN ; if (ud.multimode < 2 || (ud.multimode > 1 && j != sp->lotag)) changespritestat(i,5); else @@ -5899,7 +5714,7 @@ int spawn(int j, int pn) msy[tempwallptr] = sp->y; msx[tempwallptr+2] = sp->z; - s = headspritestat[0]; + s = headspritestat[STAT_DEFAULT]; while (s >= 0) { if (sprite[s].picnum == CRANEPOLE && SHT == (sprite[s].hitag)) @@ -5942,19 +5757,19 @@ int spawn(int j, int pn) } else sp->z -= (13<<8); sp->ang = getangle(g_player[connecthead].ps->posx-sp->x,g_player[connecthead].ps->posy-sp->y); - sp->xvel = 48-(TRAND&31); - ssp(i,CLIPMASK0); + sp->xvel = 48-(krand()&31); + A_SetSprite(i,CLIPMASK0); } else if (j == -1) { sp->z += (4<<8); T1 = sp->z; - T2 = TRAND&127; + T2 = krand()&127; } case TRASH__STATIC: if (sp->picnum != WATERDRIP) - sp->ang = TRAND&2047; + sp->ang = krand()&2047; case WATERDRIPSPLASH__STATIC: @@ -5981,7 +5796,7 @@ int spawn(int j, int pn) case WATERBUBBLEMAKER__STATIC: if (sp->hitag && sp->picnum == WATERBUBBLEMAKER) { - // JBF 20030913: Pisses off move(), eg. in bobsp2 + // JBF 20030913: Pisses off X_Move(), eg. in bobsp2 OSD_Printf(OSD_ERROR "WARNING: WATERBUBBLEMAKER %d @ %d,%d with hitag!=0. Applying fixup.\n", i,sp->x,sp->y); sp->hitag = 0; @@ -6020,7 +5835,7 @@ int spawn(int j, int pn) case PIGCOPDIVE__STATIC: case COMMANDERSTAYPUT__STATIC: case BOSS4STAYPUT__STATIC: - hittype[i].actorstayput = sp->sectnum; + ActorExtra[i].actorstayput = sp->sectnum; case BOSS1__STATIC: case BOSS2__STATIC: case BOSS3__STATIC: @@ -6050,7 +5865,7 @@ int spawn(int j, int pn) if (sp->pal == 0) { - switch (dynamictostatic[sp->picnum]) + switch (DynamicTileMap[sp->picnum]) { case LIZTROOPONTOILET__STATIC: case LIZTROOPSHOOT__STATIC: @@ -6108,11 +5923,11 @@ int spawn(int j, int pn) } else { - makeitfall(i); + A_Fall(i); if (sp->picnum == RAT) { - sp->ang = TRAND&2047; + sp->ang = krand()&2047; sp->xrepeat = sp->yrepeat = 48; sp->cstat = 0; } @@ -6128,8 +5943,8 @@ int spawn(int j, int pn) if (j >= 0) { - hittype[i].timetosleep = 0; - check_fta_sounds(i); + ActorExtra[i].timetosleep = 0; + A_PlayAlertSound(i); changespritestat(i,1); } else changespritestat(i,2); @@ -6167,18 +5982,18 @@ int spawn(int j, int pn) { if (sprite[j].picnum == NUKEBARREL) sp->pal = 8; - insertspriteq(i); + A_AddToDeleteQueue(i); } changespritestat(i,1); - getglobalz(i); + A_GetZLimits(i); - j = (hittype[i].floorz-hittype[i].ceilingz)>>9; + j = (ActorExtra[i].floorz-ActorExtra[i].ceilingz)>>9; sp->yrepeat = j; sp->xrepeat = 25-(j>>1); - sp->cstat |= (TRAND&4); + sp->cstat |= (krand()&4); break; @@ -6201,7 +6016,7 @@ int spawn(int j, int pn) return i; } g_player[myconnectindex].ps->max_actors_killed++; - hittype[i].temp_data[5] = 0; + ActorExtra[i].temp_data[5] = 0; if (ud.monsters_off == 1) { sp->xrepeat = sp->yrepeat = 0; @@ -6212,7 +6027,7 @@ int spawn(int j, int pn) } if (sp->picnum == REACTOR || sp->picnum == REACTOR2) - sp->extra = impact_damage; + sp->extra = g_impactDamage; CS |= 257; // Make it hitable @@ -6265,8 +6080,8 @@ int spawn(int j, int pn) sp->lotag = 0; sp->z -= (32<<8); sp->zvel = -1024; - ssp(i,CLIPMASK0); - sp->cstat = TRAND&4; + A_SetSprite(i,CLIPMASK0); + sp->cstat = krand()&4; } else { @@ -6288,7 +6103,7 @@ int spawn(int j, int pn) if (sp->picnum == ATOMICHEALTH) sp->cstat |= 128; - if (ud.multimode > 1 && !GTFLAGS(GAMETYPE_FLAG_ACCESSCARDSPRITES) && sp->picnum == ACCESSCARD) + if (ud.multimode > 1 && !GTFLAGS(GAMETYPE_ACCESSCARDSPRITES) && sp->picnum == ACCESSCARD) { sp->xrepeat = sp->yrepeat = 0; changespritestat(i,5); @@ -6307,7 +6122,7 @@ int spawn(int j, int pn) else { changespritestat(i,2); - makeitfall(i); + A_Fall(i); } break; @@ -6334,7 +6149,7 @@ int spawn(int j, int pn) sp->cstat |= 1+256; //Make it hitable sp->xrepeat = sp->yrepeat = 24; sp->shade = -127; - sp->extra = impact_damage<<2; + sp->extra = g_impactDamage<<2; changespritestat(i,2); break; @@ -6345,7 +6160,7 @@ int spawn(int j, int pn) sp->cstat = 16+128+2; sp->xrepeat=sp->yrepeat=1; sp->xvel = -8; - ssp(i,CLIPMASK0); + A_SetSprite(i,CLIPMASK0); } case CEILINGSTEAM__STATIC: changespritestat(i,6); @@ -6407,7 +6222,7 @@ int spawn(int j, int pn) T4 = sector[sect].ceilingz; T5 = 1; sector[sect].ceilingz = sp->z; - setinterpolation(§or[sect].ceilingz); + G_SetInterpolation(§or[sect].ceilingz); break; case 35: sector[sect].ceilingz = sp->z; @@ -6416,7 +6231,7 @@ int spawn(int j, int pn) if (ud.recstat == 1) { sp->xrepeat=sp->yrepeat=64; - sp->cstat &= 32767; + sp->cstat &= 32768; } break; case 12: @@ -6492,8 +6307,8 @@ int spawn(int j, int pn) if (numplayers < 2) { - setinterpolation(§or[sect].floorz); - setinterpolation(§or[sect].ceilingz); + G_SetInterpolation(§or[sect].floorz); + G_SetInterpolation(§or[sect].ceilingz); } break; @@ -6583,7 +6398,7 @@ int spawn(int j, int pn) for (s=startwall;sx,sp->y); -// gameexit(tempbuf); +// G_GameExit(tempbuf); OSD_Printf(OSD_ERROR "Found lonely Sector Effector (lotag 0) at (%d,%d)\n",sp->x,sp->y); changespritestat(i,1); if (apScriptGameEvent[EVENT_SPAWN]) { - int pl=findplayer(&sprite[i],&p); - OnEvent(EVENT_SPAWN,i, pl, p); + int pl=A_FindPlayer(&sprite[i],&p); + X_OnEvent(EVENT_SPAWN,i, pl, p); } return i; } @@ -6704,7 +6519,7 @@ int spawn(int j, int pn) if (tempwallptr > 2047) { Bsprintf(tempbuf,"Too many moving sectors at (%d,%d).\n",wall[s].x,wall[s].y); - gameexit(tempbuf); + G_GameExit(tempbuf); } } if (sp->lotag == 30 || sp->lotag == 6 || sp->lotag == 14 || sp->lotag == 5) @@ -6736,7 +6551,7 @@ int spawn(int j, int pn) if (j == 0) { Bsprintf(tempbuf,"Subway found no zero'd sectors with locators\nat (%d,%d).\n",sp->x,sp->y); - gameexit(tempbuf); + G_GameExit(tempbuf); } sp->owner = -1; @@ -6771,9 +6586,9 @@ int spawn(int j, int pn) { case 6: case 14: - j = callsound(sect,i); + j = A_CallSound(sect,i); if (j == -1) j = SUBWAY; - hittype[i].lastvx = j; + ActorExtra[i].lastvx = j; case 30: if (numplayers > 1) break; case 0: @@ -6783,7 +6598,7 @@ int spawn(int j, int pn) case 15: case 16: case 26: - setsectinterpolate(i); + Sect_SetInterpolation(i); break; } @@ -6814,7 +6629,7 @@ int spawn(int j, int pn) sp->xrepeat=sp->yrepeat=0; } else sp->cstat = 1+256; - sp->extra = impact_damage<<2; + sp->extra = g_impactDamage<<2; sp->owner = i; changespritestat(i,6); @@ -6828,7 +6643,7 @@ int spawn(int j, int pn) if (sp->picnum == FIREEXT) { sp->cstat = 257; - sp->extra = impact_damage<<2; + sp->extra = g_impactDamage<<2; } else { @@ -6847,7 +6662,7 @@ int spawn(int j, int pn) sp->owner = i; changespritestat(i,6); sp->xvel = 8; - ssp(i,CLIPMASK0); + A_SetSprite(i,CLIPMASK0); break; case TOILET__STATIC: @@ -6875,7 +6690,7 @@ int spawn(int j, int pn) if (j >= 0) sp->xrepeat = sp->yrepeat = 32; sp->clipdist = 72; - makeitfall(i); + A_Fall(i); if (j >= 0) sp->owner = j; else sp->owner = i; @@ -6889,7 +6704,7 @@ int spawn(int j, int pn) { if (sp->picnum == EGG) sp->clipdist = 24; - sp->cstat = 257|(TRAND&4); + sp->cstat = 257|(krand()&4); changespritestat(i,2); } break; @@ -6901,8 +6716,8 @@ int spawn(int j, int pn) if (apScriptGameEvent[EVENT_SPAWN]) { - int pl=findplayer(&sprite[i],&p); - OnEvent(EVENT_SPAWN,i, pl, p); + int pl=A_FindPlayer(&sprite[i],&p); + X_OnEvent(EVENT_SPAWN,i, pl, p); } return i; @@ -6914,7 +6729,7 @@ int spawn(int j, int pn) //#pragma auto_inline(off) #pragma optimize("g",off) #endif -void animatesprites(int x,int y,int a,int smoothratio) +void G_DoSpriteAnimations(int x,int y,int a,int smoothratio) { int i, j, k, p, sect; intptr_t l, t1,t3,t4; @@ -6932,7 +6747,7 @@ void animatesprites(int x,int y,int a,int smoothratio) //greenslime can't be handled through the dynamictostatic system due to addition on constant if ((t->picnum >= GREENSLIME)&&(t->picnum <= GREENSLIME+7)) {} - else switch (dynamictostatic[t->picnum]) + else switch (DynamicTileMap[t->picnum]) { case BLOODPOOL__STATIC: case PUKE__STATIC: @@ -6999,11 +6814,11 @@ void animatesprites(int x,int y,int a,int smoothratio) //case GREENSLIME+7: // break; default: - if (((t->cstat&16)) || (badguy(t) && t->extra > 0) || t->statnum == 10) + if (((t->cstat&16)) || (A_CheckEnemySprite(t) && t->extra > 0) || t->statnum == 10) continue; } - if (checkspriteflags(t->owner,SPRITE_FLAG_NOSHADE)) + if (A_CheckSpriteFlags(t->owner,SPRITE_NOSHADE)) l = sprite[t->owner].shade; else { @@ -7024,7 +6839,7 @@ void animatesprites(int x,int y,int a,int smoothratio) i = t->owner; s = &sprite[i]; - switch (dynamictostatic[s->picnum]) + switch (DynamicTileMap[s->picnum]) { case SECTOREFFECTOR__STATIC: if (t->lotag == 27 && ud.recstat == 1) @@ -7124,9 +6939,9 @@ void animatesprites(int x,int y,int a,int smoothratio) } else if ((s->statnum == 0 && s->picnum != CRANEPOLE) || s->statnum == 10 || s->statnum == 6 || s->statnum == 4 || s->statnum == 5 || s->statnum == 1) { - t->x -= mulscale16(65536-smoothratio,s->x-hittype[i].bposx); - t->y -= mulscale16(65536-smoothratio,s->y-hittype[i].bposy); - t->z -= mulscale16(65536-smoothratio,s->z-hittype[i].bposz); + t->x -= mulscale16(65536-smoothratio,s->x-ActorExtra[i].bposx); + t->y -= mulscale16(65536-smoothratio,s->y-ActorExtra[i].bposy); + t->z -= mulscale16(65536-smoothratio,s->z-ActorExtra[i].bposz); } sect = s->sectnum; @@ -7140,7 +6955,7 @@ void animatesprites(int x,int y,int a,int smoothratio) else if ((s->picnum==MONEY+1)||(s->picnum==MAIL+1)||(s->picnum==PAPER+1)) switchpic--; - switch (dynamictostatic[switchpic]) + switch (DynamicTileMap[switchpic]) { case DUKELYINGDEAD__STATIC: t->z += (24<<8); @@ -7181,7 +6996,7 @@ void animatesprites(int x,int y,int a,int smoothratio) sprite[s->owner].x-t->x, sprite[s->owner].y-t->y); - if (klabs(getincangle(sqa,sqb)) > 512) + if (klabs(G_GetAngleDelta(sqa,sqb)) > 512) if (ldist(&sprite[s->owner],t) < ldist(&sprite[g_player[screenpeek].ps->i],&sprite[s->owner])) t->xrepeat = t->yrepeat = 0; } @@ -7211,7 +7026,7 @@ void animatesprites(int x,int y,int a,int smoothratio) continue; case VIEWSCREEN__STATIC: case VIEWSCREEN2__STATIC: - if (camsprite >= 0 && hittype[OW].temp_data[0] == 1) + if (camsprite >= 0 && ActorExtra[OW].temp_data[0] == 1) { t->picnum = STATIC; t->cstat |= (rand()&12); @@ -7314,7 +7129,7 @@ void animatesprites(int x,int y,int a,int smoothratio) tsprite[spritesortcnt].cstat = 0; tsprite[spritesortcnt].pal = 0; - tsprite[spritesortcnt].picnum = (g_player[p].ps->curr_weapon==GROW_WEAPON?GROWSPRITEICON:weapon_sprites[g_player[p].ps->curr_weapon]); + tsprite[spritesortcnt].picnum = (g_player[p].ps->curr_weapon==GROW_WEAPON?GROWSPRITEICON:WeaponPickupSprites[g_player[p].ps->curr_weapon]); if (s->owner >= 0) tsprite[spritesortcnt].z = g_player[p].ps->posz-(12<<8); @@ -7378,7 +7193,7 @@ void animatesprites(int x,int y,int a,int smoothratio) } if (sector[t->sectnum].lotag == 2) k += 1795-1405; - else if ((hittype[i].floorz-s->z) > (64<<8)) k += 60; + else if ((ActorExtra[i].floorz-s->z) > (64<<8)) k += 60; t->picnum += k; t->pal = g_player[p].ps->palookup; @@ -7388,7 +7203,7 @@ void animatesprites(int x,int y,int a,int smoothratio) if (g_player[p].ps->on_crane == -1 && (sector[s->sectnum].lotag&0x7ff) != 1) { - l = s->z-hittype[g_player[p].ps->i].floorz+(3<<8); + l = s->z-ActorExtra[g_player[p].ps->i].floorz+(3<<8); if (l > 1024 && s->yrepeat > 32 && s->extra > 0) s->yoffset = (signed char)(l/(s->yrepeat<<2)); else s->yoffset=0; @@ -7412,13 +7227,13 @@ void animatesprites(int x,int y,int a,int smoothratio) PALONLY: - if (sector[sect].floorpal && sector[sect].floorpal < g_NumPalettes && !checkspriteflags(t->owner,SPRITE_FLAG_NOPAL)) + if (sector[sect].floorpal && sector[sect].floorpal < g_numPalettes && !A_CheckSpriteFlags(t->owner,SPRITE_NOPAL)) t->pal = sector[sect].floorpal; if (s->owner == -1) continue; - if (t->z > hittype[i].floorz && t->xrepeat < 32) - t->z = hittype[i].floorz; + if (t->z > ActorExtra[i].floorz && t->xrepeat < 32) + t->z = ActorExtra[i].floorz; break; @@ -7448,12 +7263,12 @@ PALONLY: case SCRAP3__STATIC: case SCRAP4__STATIC: case SCRAP5__STATIC: - if (hittype[i].picnum == BLIMP && t->picnum == SCRAP1 && s->yvel >= 0) + if (ActorExtra[i].picnum == BLIMP && t->picnum == SCRAP1 && s->yvel >= 0) t->picnum = s->yvel; else t->picnum += T1; t->shade -= 6; - if (sector[sect].floorpal && sector[sect].floorpal < g_NumPalettes && !checkspriteflags(t->owner,SPRITE_FLAG_NOPAL)) + if (sector[sect].floorpal && sector[sect].floorpal < g_numPalettes && !A_CheckSpriteFlags(t->owner,SPRITE_NOPAL)) t->pal = sector[sect].floorpal; break; @@ -7464,7 +7279,7 @@ PALONLY: break; } default: - if (sector[sect].floorpal && sector[sect].floorpal < g_NumPalettes && !checkspriteflags(t->owner,SPRITE_FLAG_NOPAL)) + if (sector[sect].floorpal && sector[sect].floorpal < g_numPalettes && !A_CheckSpriteFlags(t->owner,SPRITE_NOPAL)) t->pal = sector[sect].floorpal; break; } @@ -7542,26 +7357,26 @@ PALONLY: if (l > 0) while (tilesizx[t->picnum] == 0 && t->picnum > 0) t->picnum -= l; //Hack, for actors - if (hittype[i].dispicnum >= 0) - hittype[i].dispicnum = t->picnum; + if (ActorExtra[i].dispicnum >= 0) + ActorExtra[i].dispicnum = t->picnum; } else if (display_mirror == 1) t->cstat |= 4; } - if (g_player[screenpeek].ps->heat_amount > 0 && g_player[screenpeek].ps->heat_on && (badguy(s) || checkspriteflags(t->owner,SPRITE_FLAG_NVG) || s->picnum == APLAYER || s->statnum == 13)) + if (g_player[screenpeek].ps->heat_amount > 0 && g_player[screenpeek].ps->heat_on && (A_CheckEnemySprite(s) || A_CheckSpriteFlags(t->owner,SPRITE_NVG) || s->picnum == APLAYER || s->statnum == 13)) { t->pal = 6; t->shade = 0; } - if (s->statnum == 13 || badguy(s) || checkspriteflags(t->owner,SPRITE_FLAG_SHADOW) || (s->picnum == APLAYER && s->owner >= 0)) + if (s->statnum == 13 || A_CheckEnemySprite(s) || A_CheckSpriteFlags(t->owner,SPRITE_SHADOW) || (s->picnum == APLAYER && s->owner >= 0)) if (t->statnum != TSPR_TEMP && s->picnum != EXPLOSION2 && s->picnum != HANGLIGHT && s->picnum != DOMELITE) if (s->picnum != HOTMEAT) { - if (hittype[i].dispicnum < 0) + if (ActorExtra[i].dispicnum < 0) { - hittype[i].dispicnum++; + ActorExtra[i].dispicnum++; continue; } else if (ud.shadows && spritesortcnt < (MAXSPRITESONSCREEN-2)) @@ -7571,7 +7386,7 @@ PALONLY: if ((sector[sect].lotag&0xff) > 2 || s->statnum == 4 || s->statnum == 5 || s->picnum == DRONE || s->picnum == COMMANDER) daz = sector[sect].floorz; else - daz = hittype[i].floorz; + daz = ActorExtra[i].floorz; if ((s->z-daz) < (8<<8)) if (g_player[screenpeek].ps->posz < daz) @@ -7618,12 +7433,12 @@ PALONLY: } } - switch (dynamictostatic[s->picnum]) + switch (DynamicTileMap[s->picnum]) { case LASERLINE__STATIC: if (sector[t->sectnum].lotag == 2) t->pal = 8; t->z = sprite[s->owner].z-(3<<8); - if (lasermode == 2 && g_player[screenpeek].ps->heat_on == 0) + if (g_tripbombLaserMode == 2 && g_player[screenpeek].ps->heat_on == 0) t->yrepeat = 0; case EXPLOSION2__STATIC: case EXPLOSION2BOT__STATIC: @@ -7640,7 +7455,7 @@ PALONLY: { g_player[screenpeek].ps->visibility = -127; lastvisinc = totalclock+32; - //restorepalette = 1; // JBF 20040101: why? + //g_restorePalette = 1; // JBF 20040101: why? } t->shade = -127; break; @@ -7707,9 +7522,9 @@ PALONLY: } if ((sprite[s->owner].cstat&32768) == 0) { - if (!hittype[s->owner].dispicnum) - t->picnum = hittype[i].temp_data[1]; - else t->picnum = hittype[s->owner].dispicnum; + if (!ActorExtra[s->owner].dispicnum) + t->picnum = ActorExtra[i].temp_data[1]; + else t->picnum = ActorExtra[s->owner].dispicnum; t->pal = sprite[s->owner].pal; t->shade = sprite[s->owner].shade; t->ang = sprite[s->owner].ang; @@ -7740,7 +7555,7 @@ PALONLY: break; } - hittype[i].dispicnum = t->picnum; + ActorExtra[i].dispicnum = t->picnum; if (sector[t->sectnum].floorpicnum == MIRROR) t->xrepeat = t->yrepeat = 0; } @@ -7752,7 +7567,7 @@ PALONLY: if (tsprite[j].owner < MAXSPRITES && tsprite[j].owner > 0 && spriteext[tsprite[j].owner].flags & SPREXT_TSPRACCESS) { spriteext[tsprite[j].owner].tspr = (spritetype *)&tsprite[j]; - OnEvent(EVENT_ANIMATESPRITES,tsprite[j].owner, myconnectindex, -1); + X_OnEvent(EVENT_ANIMATESPRITES,tsprite[j].owner, myconnectindex, -1); } } while (j--); @@ -7763,7 +7578,7 @@ PALONLY: if (tsprite[j].owner > 0 && tsprite[j].owner < MAXSPRITES && spriteext[tsprite[j].owner].flags & SPREXT_TSPRACCESS) { spriteext[tsprite[j].owner].tspr = (spritetype *)&tsprite[j]; - OnEvent(EVENT_ANIMATESPRITES,tsprite[j].owner, myconnectindex, -1); + X_OnEvent(EVENT_ANIMATESPRITES,tsprite[j].owner, myconnectindex, -1); } } #ifdef _MSC_VER @@ -7771,7 +7586,7 @@ PALONLY: #pragma optimize("",on) #endif -char cheatstrings[][MAXCHEATLEN] = +char CheatStrings[][MAXCHEATLEN] = { "cornholio", // 0 "stuff", // 1 @@ -7835,74 +7650,74 @@ enum cheats void CheatGetInventory(void) { - SetGameVarID(g_iReturnVarID, 400, g_player[myconnectindex].ps->i, myconnectindex); - OnEvent(EVENT_CHEATGETSTEROIDS, g_player[myconnectindex].ps->i, myconnectindex, -1); - if (GetGameVarID(g_iReturnVarID, g_player[myconnectindex].ps->i, myconnectindex) >=0) + Gv_SetVar(g_iReturnVarID, 400, g_player[myconnectindex].ps->i, myconnectindex); + X_OnEvent(EVENT_CHEATGETSTEROIDS, g_player[myconnectindex].ps->i, myconnectindex, -1); + if (Gv_GetVar(g_iReturnVarID, g_player[myconnectindex].ps->i, myconnectindex) >=0) { g_player[myconnectindex].ps->steroids_amount = - GetGameVarID(g_iReturnVarID, g_player[myconnectindex].ps->i, myconnectindex); + Gv_GetVar(g_iReturnVarID, g_player[myconnectindex].ps->i, myconnectindex); } - SetGameVarID(g_iReturnVarID, 1200, g_player[myconnectindex].ps->i, myconnectindex); - OnEvent(EVENT_CHEATGETHEAT, g_player[myconnectindex].ps->i, myconnectindex, -1); - if (GetGameVarID(g_iReturnVarID, g_player[myconnectindex].ps->i, myconnectindex) >=0) + Gv_SetVar(g_iReturnVarID, 1200, g_player[myconnectindex].ps->i, myconnectindex); + X_OnEvent(EVENT_CHEATGETHEAT, g_player[myconnectindex].ps->i, myconnectindex, -1); + if (Gv_GetVar(g_iReturnVarID, g_player[myconnectindex].ps->i, myconnectindex) >=0) { g_player[myconnectindex].ps->heat_amount = - GetGameVarID(g_iReturnVarID, g_player[myconnectindex].ps->i, myconnectindex); + Gv_GetVar(g_iReturnVarID, g_player[myconnectindex].ps->i, myconnectindex); } - SetGameVarID(g_iReturnVarID, 200, g_player[myconnectindex].ps->i, myconnectindex); - OnEvent(EVENT_CHEATGETBOOT, g_player[myconnectindex].ps->i, myconnectindex, -1); - if (GetGameVarID(g_iReturnVarID, g_player[myconnectindex].ps->i, myconnectindex) >=0) + Gv_SetVar(g_iReturnVarID, 200, g_player[myconnectindex].ps->i, myconnectindex); + X_OnEvent(EVENT_CHEATGETBOOT, g_player[myconnectindex].ps->i, myconnectindex, -1); + if (Gv_GetVar(g_iReturnVarID, g_player[myconnectindex].ps->i, myconnectindex) >=0) { g_player[myconnectindex].ps->boot_amount = - GetGameVarID(g_iReturnVarID, g_player[myconnectindex].ps->i, myconnectindex); + Gv_GetVar(g_iReturnVarID, g_player[myconnectindex].ps->i, myconnectindex); } - SetGameVarID(g_iReturnVarID, 100, g_player[myconnectindex].ps->i, myconnectindex); - OnEvent(EVENT_CHEATGETSHIELD, g_player[myconnectindex].ps->i, myconnectindex, -1); - if (GetGameVarID(g_iReturnVarID, g_player[myconnectindex].ps->i, myconnectindex) >=0) + Gv_SetVar(g_iReturnVarID, 100, g_player[myconnectindex].ps->i, myconnectindex); + X_OnEvent(EVENT_CHEATGETSHIELD, g_player[myconnectindex].ps->i, myconnectindex, -1); + if (Gv_GetVar(g_iReturnVarID, g_player[myconnectindex].ps->i, myconnectindex) >=0) { g_player[myconnectindex].ps->shield_amount = - GetGameVarID(g_iReturnVarID, g_player[myconnectindex].ps->i, myconnectindex); + Gv_GetVar(g_iReturnVarID, g_player[myconnectindex].ps->i, myconnectindex); } - SetGameVarID(g_iReturnVarID, 6400, g_player[myconnectindex].ps->i, myconnectindex); - OnEvent(EVENT_CHEATGETSCUBA, g_player[myconnectindex].ps->i, myconnectindex, -1); - if (GetGameVarID(g_iReturnVarID, g_player[myconnectindex].ps->i, myconnectindex) >=0) + Gv_SetVar(g_iReturnVarID, 6400, g_player[myconnectindex].ps->i, myconnectindex); + X_OnEvent(EVENT_CHEATGETSCUBA, g_player[myconnectindex].ps->i, myconnectindex, -1); + if (Gv_GetVar(g_iReturnVarID, g_player[myconnectindex].ps->i, myconnectindex) >=0) { g_player[myconnectindex].ps->scuba_amount = - GetGameVarID(g_iReturnVarID, g_player[myconnectindex].ps->i, myconnectindex); + Gv_GetVar(g_iReturnVarID, g_player[myconnectindex].ps->i, myconnectindex); } - SetGameVarID(g_iReturnVarID, 2400, g_player[myconnectindex].ps->i, myconnectindex); - OnEvent(EVENT_CHEATGETHOLODUKE, g_player[myconnectindex].ps->i, myconnectindex, -1); - if (GetGameVarID(g_iReturnVarID, g_player[myconnectindex].ps->i, myconnectindex) >=0) + Gv_SetVar(g_iReturnVarID, 2400, g_player[myconnectindex].ps->i, myconnectindex); + X_OnEvent(EVENT_CHEATGETHOLODUKE, g_player[myconnectindex].ps->i, myconnectindex, -1); + if (Gv_GetVar(g_iReturnVarID, g_player[myconnectindex].ps->i, myconnectindex) >=0) { g_player[myconnectindex].ps->holoduke_amount = - GetGameVarID(g_iReturnVarID, g_player[myconnectindex].ps->i, myconnectindex); + Gv_GetVar(g_iReturnVarID, g_player[myconnectindex].ps->i, myconnectindex); } - SetGameVarID(g_iReturnVarID, 1600, g_player[myconnectindex].ps->i, myconnectindex); - OnEvent(EVENT_CHEATGETJETPACK, g_player[myconnectindex].ps->i, myconnectindex, -1); - if (GetGameVarID(g_iReturnVarID, g_player[myconnectindex].ps->i, myconnectindex) >=0) + Gv_SetVar(g_iReturnVarID, 1600, g_player[myconnectindex].ps->i, myconnectindex); + X_OnEvent(EVENT_CHEATGETJETPACK, g_player[myconnectindex].ps->i, myconnectindex, -1); + if (Gv_GetVar(g_iReturnVarID, g_player[myconnectindex].ps->i, myconnectindex) >=0) { g_player[myconnectindex].ps->jetpack_amount = - GetGameVarID(g_iReturnVarID, g_player[myconnectindex].ps->i, myconnectindex); + Gv_GetVar(g_iReturnVarID, g_player[myconnectindex].ps->i, myconnectindex); } - SetGameVarID(g_iReturnVarID, g_player[myconnectindex].ps->max_player_health, g_player[myconnectindex].ps->i, myconnectindex); - OnEvent(EVENT_CHEATGETFIRSTAID, g_player[myconnectindex].ps->i, myconnectindex, -1); - if (GetGameVarID(g_iReturnVarID, g_player[myconnectindex].ps->i, myconnectindex) >=0) + Gv_SetVar(g_iReturnVarID, g_player[myconnectindex].ps->max_player_health, g_player[myconnectindex].ps->i, myconnectindex); + X_OnEvent(EVENT_CHEATGETFIRSTAID, g_player[myconnectindex].ps->i, myconnectindex, -1); + if (Gv_GetVar(g_iReturnVarID, g_player[myconnectindex].ps->i, myconnectindex) >=0) { g_player[myconnectindex].ps->firstaid_amount = - GetGameVarID(g_iReturnVarID, g_player[myconnectindex].ps->i, myconnectindex); + Gv_GetVar(g_iReturnVarID, g_player[myconnectindex].ps->i, myconnectindex); } } signed char cheatbuf[MAXCHEATLEN],cheatbuflen; -static void cheats(void) +static void DoCheats(void) { short ch, i, j, k=0, weapon; static int z=0; @@ -7921,8 +7736,8 @@ static void cheats(void) if (VOLUMEONE && !z) { - Bstrcpy(cheatstrings[2],"scotty##"); - Bstrcpy(cheatstrings[6],""); + Bstrcpy(CheatStrings[2],"scotty##"); + Bstrcpy(CheatStrings[6],""); z=1; } @@ -7938,7 +7753,7 @@ static void cheats(void) if (!((ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9'))) { g_player[myconnectindex].ps->cheat_phase = 0; - // FTA(46,g_player[myconnectindex].ps); + // P_DoQuote(46,g_player[myconnectindex].ps); return; } @@ -7956,9 +7771,9 @@ static void cheats(void) { for (j = 0;j= '0' && ch <= '9')) + if (cheatbuf[j] == CheatStrings[k][j] || (CheatStrings[k][j] == '#' && ch >= '0' && ch <= '9')) { - if (cheatstrings[k][j+1] == 0) goto FOUNDCHEAT; + if (CheatStrings[k][j+1] == 0) goto FOUNDCHEAT; if (j == cheatbuflen-1) return; } else break; @@ -7981,20 +7796,20 @@ FOUNDCHEAT: for (weapon = PISTOL_WEAPON;weapon < MAX_WEAPONS-j;weapon++) { - addammo(weapon, g_player[myconnectindex].ps, g_player[myconnectindex].ps->max_ammo_amount[weapon]); + P_AddAmmo(weapon, g_player[myconnectindex].ps, g_player[myconnectindex].ps->max_ammo_amount[weapon]); g_player[myconnectindex].ps->gotweapon[weapon] = 1; } KB_FlushKeyBoardQueue(); g_player[myconnectindex].ps->cheat_phase = 0; - FTA(119,g_player[myconnectindex].ps); + P_DoQuote(119,g_player[myconnectindex].ps); return; case CHEAT_INVENTORY: KB_FlushKeyBoardQueue(); g_player[myconnectindex].ps->cheat_phase = 0; CheatGetInventory(); - FTA(120,g_player[myconnectindex].ps); + P_DoQuote(120,g_player[myconnectindex].ps); g_player[myconnectindex].ps->cheat_phase = 0; return; @@ -8002,7 +7817,7 @@ FOUNDCHEAT: g_player[myconnectindex].ps->got_access = 7; KB_FlushKeyBoardQueue(); g_player[myconnectindex].ps->cheat_phase = 0; - FTA(121,g_player[myconnectindex].ps); + P_DoQuote(121,g_player[myconnectindex].ps); return; case CHEAT_DEBUG: @@ -8010,18 +7825,18 @@ FOUNDCHEAT: KB_FlushKeyBoardQueue(); g_player[myconnectindex].ps->cheat_phase = 0; - dumpdebugdata(); + G_DumpDebugInfo(); Bsprintf(tempbuf,"GAMEVARS DUMPED TO DEBUG.CON"); - adduserquote(tempbuf); + G_AddUserQuote(tempbuf); Bsprintf(tempbuf,"MAP DUMPED TO DEBUG.MAP"); - adduserquote(tempbuf); + G_AddUserQuote(tempbuf); break; case CHEAT_CLIP: ud.clipping = 1-ud.clipping; KB_FlushKeyBoardQueue(); g_player[myconnectindex].ps->cheat_phase = 0; - FTA(112+ud.clipping,g_player[myconnectindex].ps); + P_DoQuote(112+ud.clipping,g_player[myconnectindex].ps); return; case CHEAT_RESERVED2: @@ -8031,7 +7846,7 @@ FOUNDCHEAT: return; case CHEAT_ALLEN: - FTA(79,g_player[myconnectindex].ps); + P_DoQuote(79,g_player[myconnectindex].ps); g_player[myconnectindex].ps->cheat_phase = 0; KB_ClearKeyDown(sc_N); return; @@ -8046,30 +7861,30 @@ FOUNDCHEAT: pub = 1; sprite[g_player[myconnectindex].ps->i].cstat = 257; - hittype[g_player[myconnectindex].ps->i].temp_data[0] = 0; - hittype[g_player[myconnectindex].ps->i].temp_data[1] = 0; - hittype[g_player[myconnectindex].ps->i].temp_data[2] = 0; - hittype[g_player[myconnectindex].ps->i].temp_data[3] = 0; - hittype[g_player[myconnectindex].ps->i].temp_data[4] = 0; - hittype[g_player[myconnectindex].ps->i].temp_data[5] = 0; + ActorExtra[g_player[myconnectindex].ps->i].temp_data[0] = 0; + ActorExtra[g_player[myconnectindex].ps->i].temp_data[1] = 0; + ActorExtra[g_player[myconnectindex].ps->i].temp_data[2] = 0; + ActorExtra[g_player[myconnectindex].ps->i].temp_data[3] = 0; + ActorExtra[g_player[myconnectindex].ps->i].temp_data[4] = 0; + ActorExtra[g_player[myconnectindex].ps->i].temp_data[5] = 0; sprite[g_player[myconnectindex].ps->i].hitag = 0; sprite[g_player[myconnectindex].ps->i].lotag = 0; sprite[g_player[myconnectindex].ps->i].pal = g_player[myconnectindex].ps->palookup; - FTA(17,g_player[myconnectindex].ps); + P_DoQuote(17,g_player[myconnectindex].ps); } else { ud.god = 0; sprite[g_player[myconnectindex].ps->i].extra = g_player[myconnectindex].ps->max_player_health; - hittype[g_player[myconnectindex].ps->i].extra = -1; + ActorExtra[g_player[myconnectindex].ps->i].extra = -1; g_player[myconnectindex].ps->last_extra = g_player[myconnectindex].ps->max_player_health; - FTA(18,g_player[myconnectindex].ps); + P_DoQuote(18,g_player[myconnectindex].ps); } sprite[g_player[myconnectindex].ps->i].extra = g_player[myconnectindex].ps->max_player_health; - hittype[g_player[myconnectindex].ps->i].extra = 0; + ActorExtra[g_player[myconnectindex].ps->i].extra = 0; g_player[myconnectindex].ps->cheat_phase = 0; KB_FlushKeyBoardQueue(); return; @@ -8083,18 +7898,18 @@ FOUNDCHEAT: pub = 1; sprite[g_player[myconnectindex].ps->i].cstat = 257; - hittype[g_player[myconnectindex].ps->i].temp_data[0] = 0; - hittype[g_player[myconnectindex].ps->i].temp_data[1] = 0; - hittype[g_player[myconnectindex].ps->i].temp_data[2] = 0; - hittype[g_player[myconnectindex].ps->i].temp_data[3] = 0; - hittype[g_player[myconnectindex].ps->i].temp_data[4] = 0; - hittype[g_player[myconnectindex].ps->i].temp_data[5] = 0; + ActorExtra[g_player[myconnectindex].ps->i].temp_data[0] = 0; + ActorExtra[g_player[myconnectindex].ps->i].temp_data[1] = 0; + ActorExtra[g_player[myconnectindex].ps->i].temp_data[2] = 0; + ActorExtra[g_player[myconnectindex].ps->i].temp_data[3] = 0; + ActorExtra[g_player[myconnectindex].ps->i].temp_data[4] = 0; + ActorExtra[g_player[myconnectindex].ps->i].temp_data[5] = 0; sprite[g_player[myconnectindex].ps->i].hitag = 0; sprite[g_player[myconnectindex].ps->i].lotag = 0; sprite[g_player[myconnectindex].ps->i].pal = g_player[myconnectindex].ps->palookup; - Bstrcpy(fta_quotes[122],"Scream for me, Long Beach!"); - FTA(122,g_player[myconnectindex].ps); + Bstrcpy(ScriptQuotes[122],"Scream for me, Long Beach!"); + P_DoQuote(122,g_player[myconnectindex].ps); CheatGetInventory(); for (weapon = PISTOL_WEAPON;weapon < MAX_WEAPONS;weapon++) g_player[myconnectindex].ps->gotweapon[weapon] = 1; @@ -8102,19 +7917,19 @@ FOUNDCHEAT: for (weapon = PISTOL_WEAPON; weapon < (MAX_WEAPONS); weapon++) - addammo(weapon, g_player[myconnectindex].ps, g_player[myconnectindex].ps->max_ammo_amount[weapon]); + P_AddAmmo(weapon, g_player[myconnectindex].ps, g_player[myconnectindex].ps->max_ammo_amount[weapon]); g_player[myconnectindex].ps->got_access = 7; } else { sprite[g_player[myconnectindex].ps->i].extra = g_player[myconnectindex].ps->max_player_health; - hittype[g_player[myconnectindex].ps->i].extra = -1; + ActorExtra[g_player[myconnectindex].ps->i].extra = -1; g_player[myconnectindex].ps->last_extra = g_player[myconnectindex].ps->max_player_health; - FTA(18,g_player[myconnectindex].ps); + P_DoQuote(18,g_player[myconnectindex].ps); } sprite[g_player[myconnectindex].ps->i].extra = g_player[myconnectindex].ps->max_player_health; - hittype[g_player[myconnectindex].ps->i].extra = 0; + ActorExtra[g_player[myconnectindex].ps->i].extra = 0; g_player[myconnectindex].ps->cheat_phase = 0; KB_FlushKeyBoardQueue(); return; @@ -8132,13 +7947,13 @@ FOUNDCHEAT: for (weapon = PISTOL_WEAPON; weapon < (MAX_WEAPONS-j); weapon++) - addammo(weapon, g_player[myconnectindex].ps, g_player[myconnectindex].ps->max_ammo_amount[weapon]); + P_AddAmmo(weapon, g_player[myconnectindex].ps, g_player[myconnectindex].ps->max_ammo_amount[weapon]); CheatGetInventory(); g_player[myconnectindex].ps->got_access = 7; - FTA(5,g_player[myconnectindex].ps); + P_DoQuote(5,g_player[myconnectindex].ps); g_player[myconnectindex].ps->cheat_phase = 0; - // FTA(21,g_player[myconnectindex].ps); + // P_DoQuote(21,g_player[myconnectindex].ps); g_player[myconnectindex].ps->cheat_phase = 0; KB_FlushKeyBoardQueue(); g_player[myconnectindex].ps->inven_icon = 1; @@ -8148,7 +7963,7 @@ FOUNDCHEAT: case CHEAT_SKILL: if (k == CHEAT_SCOTTY) { - i = Bstrlen(cheatstrings[k])-3+VOLUMEONE; + i = Bstrlen(CheatStrings[k])-3+VOLUMEONE; if (!consolecheat) { // JBF 20030914 @@ -8167,8 +7982,8 @@ FOUNDCHEAT: volnume--; levnume--; - if ((VOLUMEONE && volnume > 0) || volnume > num_volumes-1 || - levnume >= MAXLEVELS || map[volnume*MAXLEVELS+levnume].filename == NULL) + if ((VOLUMEONE && volnume > 0) || volnume > g_numVolumes-1 || + levnume >= MAXLEVELS || MapInfo[volnume*MAXLEVELS+levnume].filename == NULL) { g_player[myconnectindex].ps->cheat_phase = 0; KB_FlushKeyBoardQueue(); @@ -8187,11 +8002,11 @@ FOUNDCHEAT: } else { - i = Bstrlen(cheatstrings[k])-1; + i = Bstrlen(CheatStrings[k])-1; ud.m_player_skill = ud.player_skill = cheatbuf[i] - '1'; } if (numplayers > 1 && myconnectindex == connecthead) - mpchangemap(ud.m_volume_number,ud.m_level_number); + Net_NewGame(ud.m_volume_number,ud.m_level_number); else g_player[myconnectindex].ps->gm |= MODE_RESTART; g_player[myconnectindex].ps->cheat_phase = 0; @@ -8210,17 +8025,17 @@ FOUNDCHEAT: else { g_player[myconnectindex].ps->over_shoulder_on = 1; - cameradist = 0; - cameraclock = totalclock; + g_cameraDistance = 0; + g_cameraClock = totalclock; } - FTA(22,g_player[myconnectindex].ps); + P_DoQuote(22,g_player[myconnectindex].ps); g_player[myconnectindex].ps->cheat_phase = 0; KB_FlushKeyBoardQueue(); return; case CHEAT_TIME: - FTA(21,g_player[myconnectindex].ps); + P_DoQuote(21,g_player[myconnectindex].ps); g_player[myconnectindex].ps->cheat_phase = 0; KB_FlushKeyBoardQueue(); return; @@ -8236,12 +8051,12 @@ FOUNDCHEAT: { if (j&(0xffff-16384)) sector[i].lotag &= (0xffff-16384); - operatesectors(i,g_player[myconnectindex].ps->i); + G_OperateSectors(i,g_player[myconnectindex].ps->i); } } - operateforcefields(g_player[myconnectindex].ps->i,-1); + G_OperateForceFields(g_player[myconnectindex].ps->i,-1); - FTA(100,g_player[myconnectindex].ps); + P_DoQuote(100,g_player[myconnectindex].ps); g_player[myconnectindex].ps->cheat_phase = 0; KB_FlushKeyBoardQueue(); return; @@ -8255,7 +8070,7 @@ FOUNDCHEAT: case CHEAT_ITEMS: CheatGetInventory(); g_player[myconnectindex].ps->got_access = 7; - FTA(5,g_player[myconnectindex].ps); + P_DoQuote(5,g_player[myconnectindex].ps); g_player[myconnectindex].ps->cheat_phase = 0; KB_FlushKeyBoardQueue(); return; @@ -8268,7 +8083,7 @@ FOUNDCHEAT: show2dsector[i] = 255; for (i=0;i<(MAXWALLS>>3);i++) show2dwall[i] = 255; - FTA(111,g_player[myconnectindex].ps); + P_DoQuote(111,g_player[myconnectindex].ps); } else { @@ -8276,14 +8091,14 @@ FOUNDCHEAT: show2dsector[i] = 0; for (i=0;i<(MAXWALLS>>3);i++) show2dwall[i] = 0; - FTA(1,g_player[myconnectindex].ps); + P_DoQuote(1,g_player[myconnectindex].ps); } g_player[myconnectindex].ps->cheat_phase = 0; KB_FlushKeyBoardQueue(); return; case CHEAT_TODD: - FTA(99,g_player[myconnectindex].ps); + P_DoQuote(99,g_player[myconnectindex].ps); g_player[myconnectindex].ps->cheat_phase = 0; KB_FlushKeyBoardQueue(); return; @@ -8295,7 +8110,7 @@ FOUNDCHEAT: return; case CHEAT_BETA: - FTA(105,g_player[myconnectindex].ps); + P_DoQuote(105,g_player[myconnectindex].ps); KB_ClearKeyDown(sc_H); g_player[myconnectindex].ps->cheat_phase = 0; KB_FlushKeyBoardQueue(); @@ -8305,7 +8120,7 @@ FOUNDCHEAT: g_player[myconnectindex].ps->steroids_amount = 399; g_player[myconnectindex].ps->heat_amount = 1200; g_player[myconnectindex].ps->cheat_phase = 0; - FTA(37,g_player[myconnectindex].ps); + P_DoQuote(37,g_player[myconnectindex].ps); KB_FlushKeyBoardQueue(); return; @@ -8313,11 +8128,11 @@ FOUNDCHEAT: { char *s[] = { "ON", "OFF", "ON" }; - actor_tog++; - if (actor_tog == 3) actor_tog = 0; + g_noEnemies++; + if (g_noEnemies == 3) g_noEnemies = 0; g_player[screenpeek].ps->cheat_phase = 0; - Bsprintf(fta_quotes[122],"MONSTERS: %s",s[(unsigned char)actor_tog]); - FTA(122,g_player[myconnectindex].ps); + Bsprintf(ScriptQuotes[122],"MONSTERS: %s",s[(unsigned char)g_noEnemies]); + P_DoQuote(122,g_player[myconnectindex].ps); KB_FlushKeyBoardQueue(); return; } @@ -8333,29 +8148,29 @@ FOUNDCHEAT: } else { - if (KB_KeyPressed((unsigned char)cheatkey[0])) + if (KB_KeyPressed((unsigned char)CheatKeys[0])) { if (g_player[myconnectindex].ps->cheat_phase >= 0 && numplayers < 2 && ud.recstat == 0) { - if (cheatkey[0] == cheatkey[1]) - KB_ClearKeyDown((unsigned char)cheatkey[0]); + if (CheatKeys[0] == CheatKeys[1]) + KB_ClearKeyDown((unsigned char)CheatKeys[0]); g_player[myconnectindex].ps->cheat_phase = -1; } } - if (KB_KeyPressed((unsigned char)cheatkey[1])) + if (KB_KeyPressed((unsigned char)CheatKeys[1])) { if (g_player[myconnectindex].ps->cheat_phase == -1) { if (ud.player_skill == 4) { - FTA(22,g_player[myconnectindex].ps); + P_DoQuote(22,g_player[myconnectindex].ps); g_player[myconnectindex].ps->cheat_phase = 0; } else { g_player[myconnectindex].ps->cheat_phase = 1; - // FTA(25,g_player[myconnectindex].ps); + // P_DoQuote(25,g_player[myconnectindex].ps); cheatbuflen = 0; } KB_FlushKeyboardQueue(); @@ -8363,14 +8178,89 @@ FOUNDCHEAT: else if (g_player[myconnectindex].ps->cheat_phase != 0) { g_player[myconnectindex].ps->cheat_phase = 0; - KB_ClearKeyDown((unsigned char)cheatkey[0]); - KB_ClearKeyDown((unsigned char)cheatkey[1]); + KB_ClearKeyDown((unsigned char)CheatKeys[0]); + KB_ClearKeyDown((unsigned char)CheatKeys[1]); } } } } -static void nonsharedkeys(void) +static void ShowScores(void) +{ + int t, i, y,xfragtotal,yfragtotal; + + if (playerswhenstarted > 1 && (GametypeFlags[ud.coop]&GAMETYPE_SCORESHEET)) + { + rotatesprite(160<<16,34<<16,65536L,0,INGAMEDUKETHREEDEE,0,0,10,0,0,xdim-1,ydim-1); + if (PLUTOPAK) // JBF 20030804 + rotatesprite((260)<<16,36<<16,65536L,0,PLUTOPAKSPRITE+2,0,0,2+8,0,0,xdim-1,ydim-1); + gametext(160,58+2,"MULTIPLAYER TOTALS",0,2+8+16); + gametext(160,58+10,MapInfo[(ud.volume_number*MAXLEVELS)+ud.last_level-1].name,0,2+8+16); + +// gametext(160,165,"PRESS ANY KEY TO CONTINUE",0,2+8+16); + + t = 0; + minitext(23,80," NAME KILLS",8,2+8+16+128); + for (i=0;ipalookup,2+8+16+128); + + for (y=0;yfraggedself); + minitext(92+(y*23),90+t,tempbuf,2,2+8+16+128); + xfragtotal -= g_player[y].ps->fraggedself; + } + else + { + Bsprintf(tempbuf,"%-4d",g_player[i].frags[y]); + minitext(92+(y*23),90+t,tempbuf,0,2+8+16+128); + xfragtotal += g_player[i].frags[y]; + } + + if (myconnectindex == connecthead) + { + Bsprintf(tempbuf,"stats %d killed %d %d\n",i+1,y+1,g_player[i].frags[y]); + sendscore(tempbuf); + } + } + + Bsprintf(tempbuf,"%-4d",xfragtotal); + minitext(101+(8*23),90+t,tempbuf,2,2+8+16+128); + + t += 7; + } + + for (y=0;yfraggedself; + yfragtotal += g_player[i].frags[y]; + } + Bsprintf(tempbuf,"%-4d",yfragtotal); + minitext(92+(y*23),96+(8*7),tempbuf,2,2+8+16+128); + } + + minitext(45,96+(8*7),"DEATHS",8,2+8+16+128); + } +} + +static void HandleLocalKeys(void) { int i,ch; int j; @@ -8387,17 +8277,16 @@ static void nonsharedkeys(void) { if (KB_UnBoundKeyPressed(sc_F1) || KB_UnBoundKeyPressed(sc_F2) || ud.autovote) { - tempbuf[0] = 18; - tempbuf[1] = 0; - tempbuf[2] = myconnectindex; - tempbuf[3] = (KB_UnBoundKeyPressed(sc_F1) || ud.autovote?ud.autovote-1:0); + tempbuf[0] = PACKET_TYPE_MAP_VOTE; + tempbuf[1] = myconnectindex; + tempbuf[2] = (KB_UnBoundKeyPressed(sc_F1) || ud.autovote?ud.autovote-1:0); - for (i=connecthead;i >= 0;i=connectpoint2[i]) + TRAVERSE_CONNECT(i) { - if (i != myconnectindex) sendpacket(i,tempbuf,4); - if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master + if (i != myconnectindex) sendpacket(i,tempbuf,3); + if ((!g_networkBroadcastMode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master } - adduserquote("VOTE CAST"); + G_AddUserQuote("VOTE CAST"); g_player[myconnectindex].gotvote = 1; KB_ClearKeyDown(sc_F1); KB_ClearKeyDown(sc_F2); @@ -8413,7 +8302,7 @@ static void nonsharedkeys(void) if (!SHIFTS_IS_PRESSED) { if (ud.screen_size > 0) - sound(THUD); + S_PlaySound(THUD); if (getrendermode() >= 3 && ud.screen_size == 8 && ud.statusbarmode == 0) ud.statusbarmode = 1; else ud.screen_size -= 4; @@ -8427,9 +8316,9 @@ static void nonsharedkeys(void) else { ud.statusbarscale += 4; - setstatusbarscale(ud.statusbarscale); + G_SetStatusBarScale(ud.statusbarscale); } - vscrn(); + G_UpdateScreenArea(); } if (BUTTON(gamefunc_Shrink_Screen)) @@ -8437,7 +8326,7 @@ static void nonsharedkeys(void) CONTROL_ClearButton(gamefunc_Shrink_Screen); if (!SHIFTS_IS_PRESSED) { - if (ud.screen_size < 64) sound(THUD); + if (ud.screen_size < 64) S_PlaySound(THUD); if (getrendermode() >= 3 && ud.screen_size == 8 && ud.statusbarmode == 1) ud.statusbarmode = 0; else ud.screen_size += 4; @@ -8447,20 +8336,20 @@ static void nonsharedkeys(void) ud.statusbarscale -= 4; if (ud.statusbarscale < 37) ud.statusbarscale = 37; - setstatusbarscale(ud.statusbarscale); + G_SetStatusBarScale(ud.statusbarscale); } - vscrn(); + G_UpdateScreenArea(); } } if (g_player[myconnectindex].ps->cheat_phase == 1 || (g_player[myconnectindex].ps->gm&(MODE_MENU|MODE_TYPE))) return; - if (BUTTON(gamefunc_See_Coop_View) && (GTFLAGS(GAMETYPE_FLAG_COOPVIEW) || ud.recstat == 2)) + if (BUTTON(gamefunc_See_Coop_View) && (GTFLAGS(GAMETYPE_COOPVIEW) || ud.recstat == 2)) { CONTROL_ClearButton(gamefunc_See_Coop_View); screenpeek = connectpoint2[screenpeek]; if (screenpeek == -1) screenpeek = connecthead; - restorepalette = 1; + g_restorePalette = 1; } if (ud.multimode > 1 && BUTTON(gamefunc_Show_Opponents_Weapon)) @@ -8468,7 +8357,7 @@ static void nonsharedkeys(void) CONTROL_ClearButton(gamefunc_Show_Opponents_Weapon); ud.showweapons = 1-ud.showweapons; ud.config.ShowOpponentWeapons = ud.showweapons; - FTA(82-ud.showweapons,g_player[screenpeek].ps); + P_DoQuote(82-ud.showweapons,g_player[screenpeek].ps); } if (BUTTON(gamefunc_Toggle_Crosshair)) @@ -8476,8 +8365,8 @@ static void nonsharedkeys(void) CONTROL_ClearButton(gamefunc_Toggle_Crosshair); ud.crosshair = !ud.crosshair; if (ud.crosshair) - FTA(20,g_player[screenpeek].ps); - else FTA(21,g_player[screenpeek].ps); + P_DoQuote(20,g_player[screenpeek].ps); + else P_DoQuote(21,g_player[screenpeek].ps); } if (ud.overhead_on && BUTTON(gamefunc_Map_Follow_Mode)) @@ -8490,7 +8379,7 @@ static void nonsharedkeys(void) ud.foly = g_player[screenpeek].ps->oposy; ud.fola = g_player[screenpeek].ps->oang; } - FTA(83+ud.scrollmode,g_player[myconnectindex].ps); + P_DoQuote(83+ud.scrollmode,g_player[myconnectindex].ps); } if (SHIFTS_IS_PRESSED || ALT_IS_PRESSED) @@ -8554,27 +8443,27 @@ static void nonsharedkeys(void) if (i == 5 && g_player[myconnectindex].ps->fta > 0 && g_player[myconnectindex].ps->ftq == 26) { i = (VOLUMEALL?MAXVOLUMES*MAXLEVELS:6); - music_select++; - while ((map[(unsigned char)music_select].musicfn == NULL) && music_select < i) - music_select++; - if (music_select == i) - music_select = 0; - if (map[(unsigned char)music_select].musicfn != NULL) + g_musicIndex++; + while ((MapInfo[(unsigned char)g_musicIndex].musicfn == NULL) && g_musicIndex < i) + g_musicIndex++; + if (g_musicIndex == i) + g_musicIndex = 0; + if (MapInfo[(unsigned char)g_musicIndex].musicfn != NULL) { - if (playmusic(&map[(unsigned char)music_select].musicfn[0],music_select)) - Bsprintf(fta_quotes[26],"PLAYING %s",&map[(unsigned char)music_select].musicfn1[0]); + if (S_PlayMusic(&MapInfo[(unsigned char)g_musicIndex].musicfn[0],g_musicIndex)) + Bsprintf(ScriptQuotes[26],"PLAYING %s",&MapInfo[(unsigned char)g_musicIndex].musicfn1[0]); else - Bsprintf(fta_quotes[26],"PLAYING %s",&map[(unsigned char)music_select].musicfn[0]); - FTA(26,g_player[myconnectindex].ps); + Bsprintf(ScriptQuotes[26],"PLAYING %s",&MapInfo[(unsigned char)g_musicIndex].musicfn[0]); + P_DoQuote(26,g_player[myconnectindex].ps); } return; } - adduserquote(ud.ridecule[i-1]); + G_AddUserQuote(ud.ridecule[i-1]); ch = 0; - tempbuf[ch] = 4; + tempbuf[ch] = PACKET_TYPE_MESSAGE; tempbuf[ch+1] = 255; tempbuf[ch+2] = 0; Bstrcat(tempbuf+2,ud.ridecule[i-1]); @@ -8582,11 +8471,11 @@ static void nonsharedkeys(void) i = 2+strlen(ud.ridecule[i-1]); if (ud.multimode > 1) - for (ch=connecthead;ch>=0;ch=connectpoint2[ch]) - { - if (ch != myconnectindex) sendpacket(ch,tempbuf,i); - if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master - } + TRAVERSE_CONNECT(ch) + { + if (ch != myconnectindex) sendpacket(ch,tempbuf,i); + if ((!g_networkBroadcastMode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master + } pus = NUMPAGES; pub = NUMPAGES; @@ -8596,24 +8485,24 @@ static void nonsharedkeys(void) } if (ud.lockout == 0) - if (ud.config.SoundToggle && ALT_IS_PRESSED && (RTS_NumSounds() > 0) && rtsplaying == 0 && (ud.config.VoiceToggle & 1)) + if (ud.config.SoundToggle && ALT_IS_PRESSED && (RTS_NumSounds() > 0) && g_RTSPlaying == 0 && (ud.config.VoiceToggle & 1)) { rtsptr = (char *)RTS_GetSound(i-1); if (*rtsptr == 'C') FX_PlayVOC3D(rtsptr,0,0,0,255,-i); else FX_PlayWAV3D(rtsptr,0,0,0,255,-i); - rtsplaying = 7; + g_RTSPlaying = 7; if (ud.multimode > 1) { - tempbuf[0] = 7; + tempbuf[0] = PACKET_TYPE_RTS; tempbuf[1] = i; - for (ch=connecthead;ch>=0;ch=connectpoint2[ch]) + TRAVERSE_CONNECT(ch) { if (ch != myconnectindex) sendpacket(ch,tempbuf,2); - if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master + if ((!g_networkBroadcastMode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master } } @@ -8650,7 +8539,7 @@ static void nonsharedkeys(void) { ud.show_help = 0; if (ud.multimode < 2 && ud.recstat != 2) ready2send = 1; - vscrn(); + G_UpdateScreenArea(); } else { @@ -8669,22 +8558,22 @@ static void nonsharedkeys(void) { KB_ClearKeyDown(sc_F2); - if (movesperpacket == 4 && connecthead != myconnectindex) + if (g_movesPerPacket == 4 && connecthead != myconnectindex) return; FAKE_F2: if (sprite[g_player[myconnectindex].ps->i].extra <= 0) { - FTA(118,g_player[myconnectindex].ps); + P_DoQuote(118,g_player[myconnectindex].ps); return; } - cmenu(350); - screencapt = 1; - displayrooms(myconnectindex,65536); + ChangeToMenu(350); + g_screenCapture = 1; + G_DrawRooms(myconnectindex,65536); //savetemp("duke3d.tmp",waloff[TILE_SAVESHOT],160*100); - screencapt = 0; + g_screenCapture = 0; FX_StopAllSounds(); - clearsoundlocks(); + S_ClearSoundLocks(); // setview(0,0,xdim-1,ydim-1); g_player[myconnectindex].ps->gm |= MODE_MENU; @@ -8701,12 +8590,12 @@ FAKE_F2: { KB_ClearKeyDown(sc_F3); - if (movesperpacket == 4 && connecthead != myconnectindex) + if (g_movesPerPacket == 4 && connecthead != myconnectindex) return; FAKE_F3: - cmenu(300); + ChangeToMenu(300); FX_StopAllSounds(); - clearsoundlocks(); + S_ClearSoundLocks(); // setview(0,0,xdim-1,ydim-1); g_player[myconnectindex].ps->gm |= MODE_MENU; @@ -8723,7 +8612,7 @@ FAKE_F3: { KB_ClearKeyDown(sc_F4); FX_StopAllSounds(); - clearsoundlocks(); + S_ClearSoundLocks(); g_player[myconnectindex].ps->gm |= MODE_MENU; if (ud.multimode < 2 && ud.recstat != 2) @@ -8731,39 +8620,39 @@ FAKE_F3: ready2send = 0; totalclock = ototalclock; } - cmenu(701); + ChangeToMenu(701); } - if ((KB_UnBoundKeyPressed(sc_F6) || doquicksave == 1) && (g_player[myconnectindex].ps->gm&MODE_GAME)) + if ((KB_UnBoundKeyPressed(sc_F6) || g_doQuickSave == 1) && (g_player[myconnectindex].ps->gm&MODE_GAME)) { KB_ClearKeyDown(sc_F6); - doquicksave = 0; + g_doQuickSave = 0; - if (movesperpacket == 4 && connecthead != myconnectindex) + if (g_movesPerPacket == 4 && connecthead != myconnectindex) return; - if (lastsavedpos == -1) goto FAKE_F2; + if (g_lastSaveSlot == -1) goto FAKE_F2; KB_FlushKeyboardQueue(); if (sprite[g_player[myconnectindex].ps->i].extra <= 0) { - FTA(118,g_player[myconnectindex].ps); + P_DoQuote(118,g_player[myconnectindex].ps); return; } - screencapt = 1; - displayrooms(myconnectindex,65536); + g_screenCapture = 1; + G_DrawRooms(myconnectindex,65536); //savetemp("duke3d.tmp",waloff[TILE_SAVESHOT],160*100); - screencapt = 0; - if (lastsavedpos >= 0) + g_screenCapture = 0; + if (g_lastSaveSlot >= 0) { - /* inputloc = Bstrlen(&ud.savegame[lastsavedpos][0]); - current_menu = 360+lastsavedpos; - probey = lastsavedpos; */ + /* inputloc = Bstrlen(&ud.savegame[g_lastSaveSlot][0]); + g_currentMenu = 360+g_lastSaveSlot; + probey = g_lastSaveSlot; */ if (ud.multimode > 1) - saveplayer(-1-(lastsavedpos)); - else saveplayer(lastsavedpos); + G_SavePlayer(-1-(g_lastSaveSlot)); + else G_SavePlayer(g_lastSaveSlot); } } @@ -8775,50 +8664,50 @@ FAKE_F3: else { g_player[myconnectindex].ps->over_shoulder_on = 1; - cameradist = 0; - cameraclock = totalclock; + g_cameraDistance = 0; + g_cameraClock = totalclock; } - FTA(109+g_player[myconnectindex].ps->over_shoulder_on,g_player[myconnectindex].ps); + P_DoQuote(109+g_player[myconnectindex].ps->over_shoulder_on,g_player[myconnectindex].ps); } if (KB_UnBoundKeyPressed(sc_F5) && ud.config.MusicDevice >= 0) { KB_ClearKeyDown(sc_F5); - if (map[(unsigned char)music_select].musicfn1 != NULL) - Bstrcpy(fta_quotes[26],&map[(unsigned char)music_select].musicfn1[0]); - else if (map[(unsigned char)music_select].musicfn != NULL) + if (MapInfo[(unsigned char)g_musicIndex].musicfn1 != NULL) + Bstrcpy(ScriptQuotes[26],&MapInfo[(unsigned char)g_musicIndex].musicfn1[0]); + else if (MapInfo[(unsigned char)g_musicIndex].musicfn != NULL) { - Bstrcpy(fta_quotes[26],&map[(unsigned char)music_select].musicfn[0]); - Bstrcat(fta_quotes[26],". USE SHIFT-F5 TO CHANGE."); + Bstrcpy(ScriptQuotes[26],&MapInfo[(unsigned char)g_musicIndex].musicfn[0]); + Bstrcat(ScriptQuotes[26],". USE SHIFT-F5 TO CHANGE."); } - else fta_quotes[26][0] = '\0'; - FTA(26,g_player[myconnectindex].ps); + else ScriptQuotes[26][0] = '\0'; + P_DoQuote(26,g_player[myconnectindex].ps); } if (KB_UnBoundKeyPressed(sc_F8)) { KB_ClearKeyDown(sc_F8); ud.fta_on = !ud.fta_on; - if (ud.fta_on) FTA(23,g_player[myconnectindex].ps); + if (ud.fta_on) P_DoQuote(23,g_player[myconnectindex].ps); else { ud.fta_on = 1; - FTA(24,g_player[myconnectindex].ps); + P_DoQuote(24,g_player[myconnectindex].ps); ud.fta_on = 0; } } - if ((KB_UnBoundKeyPressed(sc_F9) || doquicksave == 2) && (g_player[myconnectindex].ps->gm&MODE_GAME)) + if ((KB_UnBoundKeyPressed(sc_F9) || g_doQuickSave == 2) && (g_player[myconnectindex].ps->gm&MODE_GAME)) { KB_ClearKeyDown(sc_F9); - doquicksave = 0; + g_doQuickSave = 0; - if (movesperpacket == 4 && myconnectindex != connecthead) + if (g_movesPerPacket == 4 && myconnectindex != connecthead) return; - if (lastsavedpos == -1) goto FAKE_F3; + if (g_lastSaveSlot == -1) goto FAKE_F3; - if (lastsavedpos >= 0) + if (g_lastSaveSlot >= 0) { KB_FlushKeyboardQueue(); KB_ClearKeysDown(); @@ -8826,12 +8715,12 @@ FAKE_F3: if (ud.multimode > 1) { - loadplayer(-1-lastsavedpos); + G_LoadPlayer(-1-g_lastSaveSlot); g_player[myconnectindex].ps->gm = MODE_GAME; } else { - i = loadplayer(lastsavedpos); + i = G_LoadPlayer(g_lastSaveSlot); if (i == 0) g_player[myconnectindex].ps->gm = MODE_GAME; } @@ -8841,9 +8730,9 @@ FAKE_F3: if (KB_UnBoundKeyPressed(sc_F10)) { KB_ClearKeyDown(sc_F10); - cmenu(500); + ChangeToMenu(500); FX_StopAllSounds(); - clearsoundlocks(); + S_ClearSoundLocks(); g_player[myconnectindex].ps->gm |= MODE_MENU; if (ud.multimode < 2 && ud.recstat != 2) { @@ -8876,7 +8765,7 @@ FAKE_F3: ud.last_overhead = ud.overhead_on; ud.overhead_on = 0; ud.scrollmode = 0; - vscrn(); + G_UpdateScreenArea(); } if (BUTTON(gamefunc_AutoRun)) @@ -8884,7 +8773,7 @@ FAKE_F3: CONTROL_ClearButton(gamefunc_AutoRun); ud.auto_run = 1-ud.auto_run; ud.config.RunMode = ud.auto_run; - FTA(85+ud.auto_run,g_player[myconnectindex].ps); + P_DoQuote(85+ud.auto_run,g_player[myconnectindex].ps); } if (BUTTON(gamefunc_Map)) @@ -8901,8 +8790,8 @@ FAKE_F3: if (ud.overhead_on == 3) ud.overhead_on = 0; ud.last_overhead = ud.overhead_on; } - restorepalette = 1; - vscrn(); + g_restorePalette = 1; + G_UpdateScreenArea(); } /* if (KB_UnBoundKeyPressed(sc_F11)) @@ -8917,16 +8806,16 @@ FAKE_F3: ud.brightness = (7<<3); setbrightness(ud.brightness>>2,&g_player[myconnectindex].ps->palette[0],0); - if (ud.brightness < 40) FTA(29 + (ud.brightness>>3) ,g_player[myconnectindex].ps); - else if (ud.brightness < 80) FTA(96 + (ud.brightness>>3) - 5,g_player[myconnectindex].ps); + if (ud.brightness < 40) P_DoQuote(29 + (ud.brightness>>3) ,g_player[myconnectindex].ps); + else if (ud.brightness < 80) P_DoQuote(96 + (ud.brightness>>3) - 5,g_player[myconnectindex].ps); } */ if (KB_UnBoundKeyPressed(sc_F11)) { KB_ClearKeyDown(sc_F11); - cmenu(232); + ChangeToMenu(232); FX_StopAllSounds(); - clearsoundlocks(); + S_ClearSoundLocks(); g_player[myconnectindex].ps->gm |= MODE_MENU; if (ud.multimode < 2 && ud.recstat != 2) { @@ -9096,11 +8985,11 @@ static void setup_rancid_net(const char *fn) initprintf("rmnet: Interface not defined!\n"); if (!Bstrlen(rancid_ip_strings[1])) initprintf("rmnet: No peers configured!\n"); - gameexit("Malformed network configuration file!"); + G_GameExit("Malformed network configuration file!"); return; } - if (g_KeepAddr == 0) + if (g_keepAddr == 0) { for (i=0;i=MAXLEVELS||ep>=MAXVOLUMES) return 1; sel=(ep*MAXLEVELS)+lev; - ID=map[sel].musicfn; + ID=MapInfo[sel].musicfn; } - map[sel].musicfn1=makename(map[sel].musicfn1,name,ID); + MapInfo[sel].musicfn1=makename(MapInfo[sel].musicfn1,name,ID); // initprintf("%-15s | ",ID); -// initprintf("%3d %2d %2d | %s\n",sel,ep,lev,map[sel].musicfn1); -// playmusic(ID,sel); +// initprintf("%3d %2d %2d | %s\n",sel,ep,lev,MapInfo[sel].musicfn1); +// S_PlayMusic(ID,sel); return 0; } @@ -9348,8 +9237,8 @@ static int parsedefinitions_game(scriptfile *script, const int preload) else { initprintf("Using group file '%s'.\n",fn); - if (!g_NoAutoLoad) - autoloadgrps(fn); + if (!g_noAutoLoad) + DoAutoload(fn); } } @@ -9386,7 +9275,7 @@ static int parsedefinitions_game(scriptfile *script, const int preload) } case T_NOAUTOLOAD: if (preload) - g_NoAutoLoad = 1; + g_noAutoLoad = 1; break; case T_MUSIC: { @@ -9517,7 +9406,7 @@ static int loaddefinitions_game(const char *fn, int preload) return 0; } -static void addgroup(const char *buffer) +static void G_AddGroup(const char *buffer) { struct strllist *s; s = (struct strllist *)Bcalloc(1,sizeof(struct strllist)); @@ -9535,7 +9424,7 @@ static void addgroup(const char *buffer) CommandGrps = s; } -static void addgamepath(const char *buffer) +static void G_AddPath(const char *buffer) { struct strllist *s; s = (struct strllist *)Bcalloc(1,sizeof(struct strllist)); @@ -9552,7 +9441,7 @@ static void addgamepath(const char *buffer) } -static void checkcommandline(int argc, const char **argv) +static void G_CheckCommandLine(int argc, const char **argv) { short i, j; char *c; @@ -9603,7 +9492,7 @@ static void checkcommandline(int argc, const char **argv) { if (argc > i+1) { - addgroup(argv[i+1]); + G_AddGroup(argv[i+1]); i++; } i++; @@ -9614,7 +9503,7 @@ static void checkcommandline(int argc, const char **argv) if (argc > i+1) { Bstrcpy(mod_dir,argv[i+1]); - addgamepath(argv[i+1]); + G_AddPath(argv[i+1]); i++; } i++; @@ -9644,7 +9533,7 @@ static void checkcommandline(int argc, const char **argv) { strcpy(defaultduke3dgrp, "nam.grp"); strcpy(defaultconfilename, "nam.con"); - g_GameType = GAMENAM; + g_gameType = GAMENAM; i++; continue; } @@ -9652,33 +9541,33 @@ static void checkcommandline(int argc, const char **argv) { strcpy(defaultduke3dgrp, "ww2gi.grp"); strcpy(defaultconfilename, "ww2gi.con"); - g_GameType = GAMEWW2; + g_gameType = GAMEWW2; i++; continue; } if (!Bstrcasecmp(c+1,"setup")) { - g_CommandSetup = TRUE; + g_commandSetup = TRUE; i++; continue; } if (!Bstrcasecmp(c+1,"nosetup")) { - g_NoSetup = 1; - g_CommandSetup = 0; + g_noSetup = 1; + g_commandSetup = 0; i++; continue; } if (!Bstrcasecmp(c+1,"noautoload")) { initprintf("Autoload disabled\n"); - g_NoAutoLoad = 1; + g_noAutoLoad = 1; i++; continue; } if (!Bstrcasecmp(c+1,"keepaddr")) { - g_KeepAddr = 1; + g_keepAddr = 1; i++; continue; } @@ -9693,8 +9582,8 @@ static void checkcommandline(int argc, const char **argv) { if (argc > i+1) { - g_NoSetup = TRUE; - networkmode = 1; + g_noSetup = TRUE; + g_networkBroadcastMode = 1; CommandNet = (char *)argv[i+1]; i++; } @@ -9708,7 +9597,7 @@ static void checkcommandline(int argc, const char **argv) #endif ) { - g_NoSetup = TRUE; + g_noSetup = TRUE; firstnet = i; netparamcount = argc - i - 1; netparam = (char **)Bcalloc(netparamcount, sizeof(char**)); @@ -9737,13 +9626,13 @@ static void checkcommandline(int argc, const char **argv) } if (!Bstrcasecmp(c+1,"condebug")) { - g_ScriptDebug = 1; + g_scriptDebug = 1; i++; continue; } if (!Bstrcasecmp(c+1,"nologo")) { - g_NoLogo = 1; + g_noLogo = 1; i++; continue; } @@ -9757,7 +9646,7 @@ static void checkcommandline(int argc, const char **argv) #endif if (!Bstrcasecmp(c+1,"sloppycmd")) { - checkCON = 0; + g_scriptSanityChecks = 0; i++; continue; } @@ -9795,12 +9684,12 @@ static void checkcommandline(int argc, const char **argv) c++; if (((c[0] == 'n') || (c[0] == 'N')) && (c[1] == '0')) { - networkmode = 0; + g_networkBroadcastMode = 0; initprintf("Network mode: master/slave\n"); } else if (((c[0] == 'n') || (c[0] == 'N')) && (c[1] == '1')) { - networkmode = 1; + g_networkBroadcastMode = 1; initprintf("Network mode: peer-to-peer\n"); } @@ -9861,12 +9750,12 @@ static void checkcommandline(int argc, const char **argv) case 'F': c++; if (*c == '1') - movesperpacket = 1; + g_movesPerPacket = 1; if (*c == '2') - movesperpacket = 2; + g_movesPerPacket = 2; if (*c == '4') { - movesperpacket = 4; + g_movesPerPacket = 4; setpackettimeout(0x3fffffff,0x3fffffff); // this doesn't do anything anymore } break; @@ -9874,7 +9763,7 @@ static void checkcommandline(int argc, const char **argv) case 'G': c++; if (!*c) break; - addgroup(c); + G_AddGroup(c); break; case 'h': case 'H': @@ -9888,15 +9777,15 @@ static void checkcommandline(int argc, const char **argv) case 'i': case 'I': c++; - if (*c == '0') networkmode = 0; - if (*c == '1') networkmode = 1; - initprintf("Network Mode %d\n",networkmode); + if (*c == '0') g_networkBroadcastMode = 0; + if (*c == '1') g_networkBroadcastMode = 1; + initprintf("Network Mode %d\n",g_networkBroadcastMode); break; case 'j': case 'J': c++; if (!*c) break; - addgamepath(c); + G_AddPath(c); break; case 'l': case 'L': @@ -9918,19 +9807,19 @@ static void checkcommandline(int argc, const char **argv) c++; if (*c == 's' || *c == 'S') { - g_NoSound = 2; + g_noSound = 2; initprintf("Sound off.\n"); } else if (*c == 'm' || *c == 'M') { - g_NoMusic = 1; + g_noMusic = 1; initprintf("Music off.\n"); } else if (*c == 'd' || *c == 'D') { FILE * fp=fopen("gamevars.txt","w"); - InitGameVars(); - DumpGameVars(fp); + Gv_Init(); + Gv_DumpValues(fp); fclose(fp); initprintf("Game variables saved to gamevars.txt.\n"); } @@ -10051,9 +9940,9 @@ static void checkcommandline(int argc, const char **argv) case 'z': case 'Z': c++; - g_ScriptDebug = atoi(c); - if (!g_ScriptDebug) - g_ScriptDebug = 1; + g_scriptDebug = atoi(c); + if (!g_scriptDebug) + g_scriptDebug = 1; break; } } @@ -10069,7 +9958,7 @@ static void checkcommandline(int argc, const char **argv) } if (!Bstrcasecmp(k,".grp") || !Bstrcasecmp(k,".zip")) { - addgroup(argv[i++]); + G_AddGroup(argv[i++]); continue; } if (!Bstrcasecmp(k,".con")) @@ -10092,10 +9981,10 @@ static void checkcommandline(int argc, const char **argv) } } -static void Logo(void) +static void G_DisplayLogo(void) { int soundanm = 0; - int logoflags=GetGameVar("LOGO_FLAGS",255, -1, -1); + int logoflags=Gv_GetVarByLabel("LOGO_FLAGS",255, -1, -1); ready2send = 0; @@ -10104,7 +9993,7 @@ static void Logo(void) setview(0,0,xdim-1,ydim-1); clearview(0L); - IFISSOFTMODE palto(0,0,0,63); + IFISSOFTMODE G_FadePalette(0,0,0,63); flushperms(); nextpage(); @@ -10114,17 +10003,17 @@ static void Logo(void) MUSIC_StopSong(); FX_StopAllSounds(); // JBF 20031228 - clearsoundlocks(); // JBF 20031228 - if (ud.multimode < 2 && (logoflags & LOGO_FLAG_ENABLED) && !g_NoLogo) + S_ClearSoundLocks(); // JBF 20031228 + if (ud.multimode < 2 && (logoflags & LOGO_ENABLED) && !g_noLogo) { - if (VOLUMEALL && (logoflags & LOGO_FLAG_PLAYANIM)) + if (VOLUMEALL && (logoflags & LOGO_PLAYANIM)) { - if (!KB_KeyWaiting() && g_NoLogoAnim == 0) + if (!KB_KeyWaiting() && g_noLogoAnim == 0) { getpackets(); - playanm("logo.anm",5); - IFISSOFTMODE palto(0,0,0,63); + G_PlayAnim("logo.anm",5); + IFISSOFTMODE G_FadePalette(0,0,0,63); KB_FlushKeyboardQueue(); KB_ClearKeysDown(); // JBF } @@ -10133,20 +10022,20 @@ static void Logo(void) nextpage(); } - if (logoflags & LOGO_FLAG_PLAYMUSIC) + if (logoflags & LOGO_PLAYMUSIC) { - music_select = -1; // hack - playmusic(&env_music_fn[0][0],MAXVOLUMES*MAXLEVELS); + g_musicIndex = -1; // hack + S_PlayMusic(&EnvMusicFilename[0][0],MAXVOLUMES*MAXLEVELS); } if (!NAM) { fadepal(0,0,0, 0,64,7); //g_player[myconnectindex].ps->palette = drealms; - //palto(0,0,0,63); - if (logoflags & LOGO_FLAG_3DRSCREEN) + //G_FadePalette(0,0,0,63); + if (logoflags & LOGO_3DRSCREEN) { - setgamepalette(g_player[myconnectindex].ps, drealms, 11); // JBF 20040308 + SetGamePalette(g_player[myconnectindex].ps, drealms, 11); // JBF 20040308 rotatesprite(0,0,65536L,0,DREALMS,0,0,2+8+16+64, 0,0,xdim-1,ydim-1); nextpage(); fadepal(0,0,0, 63,0,-7); @@ -10155,10 +10044,10 @@ static void Logo(void) { handleevents(); getpackets(); - if (restorepalette) + if (g_restorePalette) { - setgamepalette(g_player[myconnectindex].ps,g_player[myconnectindex].ps->palette,0); - restorepalette = 0; + SetGamePalette(g_player[myconnectindex].ps,g_player[myconnectindex].ps->palette,0); + g_restorePalette = 0; } } } @@ -10169,10 +10058,10 @@ static void Logo(void) fadepal(0,0,0, 0,64,7); clearview(0L); nextpage(); - if (logoflags & LOGO_FLAG_TITLESCREEN) + if (logoflags & LOGO_TITLESCREEN) { //g_player[myconnectindex].ps->palette = titlepal; - setgamepalette(g_player[myconnectindex].ps, titlepal, 11); // JBF 20040308 + SetGamePalette(g_player[myconnectindex].ps, titlepal, 11); // JBF 20040308 flushperms(); rotatesprite(0,0,65536L,0,BETASCREEN,0,0,2+8+16+64,0,0,xdim-1,ydim-1); KB_FlushKeyboardQueue(); @@ -10182,14 +10071,14 @@ static void Logo(void) while (totalclock < (860+120) && !KB_KeyWaiting() && !MOUSE_GetButtons()&LEFT_MOUSE) { rotatesprite(0,0,65536L,0,BETASCREEN,0,0,2+8+16+64,0,0,xdim-1,ydim-1); - if (logoflags & LOGO_FLAG_DUKENUKEM) + if (logoflags & LOGO_DUKENUKEM) { if (totalclock > 120 && totalclock < (120+60)) { if (soundanm == 0) { soundanm = 1; - sound(PIPEBOMB_EXPLODE); + S_PlaySound(PIPEBOMB_EXPLODE); } rotatesprite(160<<16,104<<16,(totalclock-120)<<10,0,DUKENUKEM,0,0,2+8,0,0,xdim-1,ydim-1); } @@ -10197,14 +10086,14 @@ static void Logo(void) rotatesprite(160<<16,(104)<<16,60<<10,0,DUKENUKEM,0,0,2+8,0,0,xdim-1,ydim-1); } else soundanm = 1; - if (logoflags & LOGO_FLAG_THREEDEE) + if (logoflags & LOGO_THREEDEE) { if (totalclock > 220 && totalclock < (220+30)) { if (soundanm == 1) { soundanm = 2; - sound(PIPEBOMB_EXPLODE); + S_PlaySound(PIPEBOMB_EXPLODE); } rotatesprite(160<<16,(104)<<16,60<<10,0,DUKENUKEM,0,0,2+8,0,0,xdim-1,ydim-1); @@ -10214,7 +10103,7 @@ static void Logo(void) rotatesprite(160<<16,(129)<<16,30<<11,0,THREEDEE,0,0,2+8,0,0,xdim-1,ydim-1); } else soundanm = 2; - if (PLUTOPAK && (logoflags & LOGO_FLAG_PLUTOPAKSPRITE)) + if (PLUTOPAK && (logoflags & LOGO_PLUTOPAKSPRITE)) { // JBF 20030804 if (totalclock >= 280 && totalclock < 395) @@ -10223,7 +10112,7 @@ static void Logo(void) if (soundanm == 2) { soundanm = 3; - sound(FLY_BY); + S_PlaySound(FLY_BY); } } else if (totalclock >= 395) @@ -10231,18 +10120,18 @@ static void Logo(void) if (soundanm == 3) { soundanm = 4; - sound(PIPEBOMB_EXPLODE); + S_PlaySound(PIPEBOMB_EXPLODE); } rotatesprite(160<<16,(151)<<16,30<<11,0,PLUTOPAKSPRITE+1,0,0,2+8,0,0,xdim-1,ydim-1); } } - OnEvent(EVENT_LOGO, -1, screenpeek, -1); + X_OnEvent(EVENT_LOGO, -1, screenpeek, -1); handleevents(); getpackets(); - if (restorepalette) + if (g_restorePalette) { - setgamepalette(g_player[myconnectindex].ps,g_player[myconnectindex].ps->palette,0); - restorepalette = 0; + SetGamePalette(g_player[myconnectindex].ps,g_player[myconnectindex].ps->palette,0); + g_restorePalette = 0; } nextpage(); } @@ -10250,21 +10139,7 @@ static void Logo(void) KB_ClearKeysDown(); // JBF MOUSE_ClearButton(LEFT_MOUSE); } - /* - if (ud.multimode > 1) - { - setgamepalette(g_player[myconnectindex].ps, titlepal, 11); - rotatesprite(0,0,65536L,0,BETASCREEN,0,0,2+8+16+64,0,0,xdim-1,ydim-1); - rotatesprite(160<<16,(104)<<16,60<<10,0,DUKENUKEM,0,0,2+8,0,0,xdim-1,ydim-1); - rotatesprite(160<<16,(129)<<16,30<<11,0,THREEDEE,0,0,2+8,0,0,xdim-1,ydim-1); - if (PLUTOPAK) // JBF 20030804 - rotatesprite(160<<16,(151)<<16,30<<11,0,PLUTOPAKSPRITE+1,0,0,2+8,0,0,xdim-1,ydim-1); - - gametext(160,190,"WAITING FOR PLAYERS",14,2); - nextpage(); - } - */ waitforeverybody(); flushperms(); @@ -10272,10 +10147,10 @@ static void Logo(void) nextpage(); //g_player[myconnectindex].ps->palette = palette; - setgamepalette(g_player[myconnectindex].ps, palette, 0); // JBF 20040308 - sound(NITEVISION_ONOFF); + SetGamePalette(g_player[myconnectindex].ps, palette, 0); // JBF 20040308 + S_PlaySound(NITEVISION_ONOFF); - //palto(0,0,0,0); + //G_FadePalette(0,0,0,0); clearview(0L); } @@ -10293,34 +10168,34 @@ static void loadtmb(void) } void freehash(); -static void freeconmem(void) +static void CON_FreeMem(void) { int i; extern char *bitptr; for (i=(MAXLEVELS*(MAXVOLUMES+1))-1;i>=0;i--) // +1 volume for "intro", "briefing" music { - if (map[i].name != NULL) - Bfree(map[i].name); - if (map[i].filename != NULL) - Bfree(map[i].filename); - if (map[i].musicfn != NULL) - Bfree(map[i].musicfn); - if (map[i].musicfn1 != NULL) - Bfree(map[i].musicfn1); - if (map[i].savedstate != NULL) - FreeMapState(i); + if (MapInfo[i].name != NULL) + Bfree(MapInfo[i].name); + if (MapInfo[i].filename != NULL) + Bfree(MapInfo[i].filename); + if (MapInfo[i].musicfn != NULL) + Bfree(MapInfo[i].musicfn); + if (MapInfo[i].musicfn1 != NULL) + Bfree(MapInfo[i].musicfn1); + if (MapInfo[i].savedstate != NULL) + G_FreeMapState(i); } for (i=MAXQUOTES-1;i>=0;i--) { - if (fta_quotes[i] != NULL) - Bfree(fta_quotes[i]); - if (redefined_quotes[i] != NULL) - Bfree(redefined_quotes[i]); + if (ScriptQuotes[i] != NULL) + Bfree(ScriptQuotes[i]); + if (ScriptQuoteRedefinitions[i] != NULL) + Bfree(ScriptQuoteRedefinitions[i]); } - for (i=iGameVarCount-1;i>=0;i--) + for (i=g_gameVarCount-1;i>=0;i--) { if (aGameVars[i].szLabel != NULL) Bfree(aGameVars[i].szLabel); @@ -10328,7 +10203,7 @@ static void freeconmem(void) Bfree(aGameVars[i].plValues); } - for (i=iGameArrayCount-1;i>=0;i--) + for (i=g_gameArrayCount-1;i>=0;i--) { if (aGameArrays[i].szLabel != NULL) Bfree(aGameArrays[i].szLabel); @@ -10373,27 +10248,27 @@ static void freeconmem(void) =================== */ -void Shutdown(void) +void G_Shutdown(void) { - SoundShutdown(); - MusicShutdown(); + S_SoundShutdown(); + S_MusicShutdown(); uninittimer(); CONTROL_Shutdown(); CONFIG_WriteSetup(); KB_Shutdown(); - freeconmem(); + CON_FreeMem(); uninitengine(); } /* =================== = -= Startup += G_Startup = =================== */ -static void compilecons(void) +static void G_CompileScripts(void) { int i, psm = pathsearchmode; label = (char *)&sprite[0]; // V8: 16384*44/64 = 11264 V7: 4096*44/64 = 2816 @@ -10410,9 +10285,9 @@ static void compilecons(void) kclose(i); else Bsprintf(confilename,"GAME.CON"); } - loadefs(confilename); + C_Compile(confilename); - if (loadfromgrouponly) + if (g_loadFromGroupOnly) { if (userconfiles == 0) { @@ -10424,26 +10299,26 @@ static void compilecons(void) } else Bsprintf(confilename,"GAME.CON"); } - loadefs(confilename); + C_Compile(confilename); } - if ((unsigned int)labelcnt > MAXSPRITES*sizeof(spritetype)/64) // see the arithmetic above for why - gameexit("Error: too many labels defined!"); + if ((unsigned int)g_numLabels > MAXSPRITES*sizeof(spritetype)/64) // see the arithmetic above for why + G_GameExit("Error: too many labels defined!"); else { char *newlabel; intptr_t *newlabelcode; - newlabel = (char *)malloc(labelcnt<<6); - newlabelcode = (intptr_t *)malloc(labelcnt*sizeof(intptr_t)); + newlabel = (char *)malloc(g_numLabels<<6); + newlabelcode = (intptr_t *)malloc(g_numLabels*sizeof(intptr_t)); if (!newlabel || !newlabelcode) { - gameexit("Error: out of memory retaining labels\n"); + G_GameExit("Error: out of memory retaining labels\n"); } - copybuf(label, newlabel, (labelcnt*64)/4); - copybuf(labelcode, newlabelcode, (labelcnt*sizeof(intptr_t))/4); + copybuf(label, newlabel, (g_numLabels*64)/4); + copybuf(labelcode, newlabelcode, (g_numLabels*sizeof(intptr_t))/4); label = newlabel; labelcode = newlabelcode; @@ -10452,25 +10327,22 @@ static void compilecons(void) clearbufbyte(§or[0], sizeof(sectortype) * MAXSECTORS, 0); clearbufbyte(&wall[0], sizeof(walltype) * MAXWALLS, 0); - OnEvent(EVENT_INIT, -1, -1, -1); + X_OnEvent(EVENT_INIT, -1, -1, -1); pathsearchmode = psm; } -static void sanitizegametype() +static void G_CheckGametype(void) { // initprintf("ud.m_coop=%i before sanitization\n",ud.m_coop); - if (ud.m_coop >= num_gametypes || ud.m_coop < 0) - { - ud.m_coop = 0; - } - Bsprintf(tempbuf,"%s\n",gametype_names[ud.m_coop]); + ud.m_coop = clamp(ud.m_coop, 0, g_numGametypes-1); + Bsprintf(tempbuf,"%s\n",GametypeNames[ud.m_coop]); initprintf(tempbuf); - if (gametype_flags[ud.m_coop] & GAMETYPE_FLAG_ITEMRESPAWN) + if (GametypeFlags[ud.m_coop] & GAMETYPE_ITEMRESPAWN) ud.m_respawn_items = ud.m_respawn_inventory = 1; // initprintf("ud.m_coop=%i after sanitisation\n",ud.m_coop); } -static void genspriteremaps(void) +static void G_LoadExtraPalettes(void) { int j,fp; signed char look_pos; @@ -10478,16 +10350,16 @@ static void genspriteremaps(void) fp = kopen4loadfrommod(lookfn,0); if (fp != -1) - kread(fp,(char *)&g_NumPalettes,1); + kread(fp,(char *)&g_numPalettes,1); else - gameexit("\nERROR: File 'lookup.dat' not found."); + G_GameExit("\nERROR: File 'lookup.dat' not found."); #if defined(__APPLE__) && B_BIG_ENDIAN != 0 // this is almost as bad as just setting the value to 25 :P - g_NumPalettes = (g_NumPalettes * (uint64)0x0202020202 & (uint64)0x010884422010) % 1023; + g_numPalettes = (g_numPalettes * (uint64)0x0202020202 & (uint64)0x010884422010) % 1023; #endif - for (j=g_NumPalettes-1;j>=0;j--) + for (j=g_numPalettes-1;j>=0;j--) { kread(fp,(signed char *)&look_pos,1); kread(fp,tempbuf,256); @@ -10496,11 +10368,11 @@ static void genspriteremaps(void) for (j = 255; j>=0; j--) tempbuf[j] = j; - g_NumPalettes++; - makepalookup(g_NumPalettes, tempbuf, 15, 15, 15, 1); - makepalookup(g_NumPalettes + 1, tempbuf, 15, 0, 0, 1); - makepalookup(g_NumPalettes + 2, tempbuf, 0, 15, 0, 1); - makepalookup(g_NumPalettes + 3, tempbuf, 0, 0, 15, 1); + g_numPalettes++; + makepalookup(g_numPalettes, tempbuf, 15, 15, 15, 1); + makepalookup(g_numPalettes + 1, tempbuf, 15, 0, 0, 1); + makepalookup(g_numPalettes + 2, tempbuf, 0, 15, 0, 1); + makepalookup(g_numPalettes + 3, tempbuf, 0, 0, 15, 1); kread(fp,&waterpal[0],768); kread(fp,&slimepal[0],768); @@ -10516,15 +10388,15 @@ static void genspriteremaps(void) } extern int startwin_run(void); -static void SetupGameButtons(void); +static void G_SetupGameButtons(void); -static void Startup(void) +static void G_Startup(void) { int i; inittimer(TICRATE); - compilecons(); + G_CompileScripts(); CONFIG_ReadKeys(); // we re-read the keys after compiling the CONs @@ -10532,28 +10404,28 @@ static void Startup(void) { wm_msgbox("Build Engine Initialization Error", "There was a problem initializing the Build engine: %s", engineerrstr); - freeconmem(); + CON_FreeMem(); exit(1); } - setupdynamictostatic(); + G_InitDynamicTiles(); - if (ud.multimode > 1) sanitizegametype(); + if (ud.multimode > 1) G_CheckGametype(); - if (g_NoSound) ud.config.SoundToggle = 0; - if (g_NoMusic) ud.config.MusicToggle = 0; + if (g_noSound) ud.config.SoundToggle = 0; + if (g_noMusic) ud.config.MusicToggle = 0; if (CommandName) { - // Bstrncpy(myname, CommandName, 9); - // myname[10] = '\0'; + // Bstrncpy(szPlayerName, CommandName, 9); + // szPlayerName[10] = '\0'; Bstrcpy(tempbuf,CommandName); while (Bstrlen(stripcolorcodes(tempbuf,tempbuf)) > 10) tempbuf[Bstrlen(tempbuf)-1] = '\0'; - Bstrncpy(myname,tempbuf,sizeof(myname)-1); - myname[sizeof(myname)-1] = '\0'; + Bstrncpy(szPlayerName,tempbuf,sizeof(szPlayerName)-1); + szPlayerName[sizeof(szPlayerName)-1] = '\0'; } if (CommandMap) @@ -10624,7 +10496,7 @@ static void Startup(void) if (quitevent) { - Shutdown(); + G_Shutdown(); return; } @@ -10637,7 +10509,7 @@ static void Startup(void) handleevents(); if (quitevent) { - Shutdown(); + G_Shutdown(); return; } } @@ -10665,25 +10537,25 @@ static void Startup(void) { chdir(cwd); if (loadpics("tiles000.art",MAXCACHE1DSIZE) < 0) - gameexit("Failed loading art."); + G_GameExit("Failed loading art."); } chdir(cwd); } else if (loadpics("tiles000.art",MAXCACHE1DSIZE) < 0) - gameexit("Failed loading art."); + G_GameExit("Failed loading art."); } // initprintf("Loading palette/lookups...\n"); - genspriteremaps(); + G_LoadExtraPalettes(); - readsavenames(); + ReadSaveGameHeaders(); tilesizx[MIRROR] = tilesizy[MIRROR] = 0; screenpeek = myconnectindex; - if (networkmode == 255) - networkmode = 1; + if (g_networkBroadcastMode == 255) + g_networkBroadcastMode = 1; } void sendscore(const char *s) @@ -10693,11 +10565,44 @@ void sendscore(const char *s) // genericmultifunction(-1,(char *)s,strlen(s)+1,5); } -static void sendwchoice(void) +int quittimer = 0; + +void Net_SendQuit(void) +{ + if (g_gameQuit == 0 && (numplayers > 1)) + { + if (g_player[myconnectindex].ps->gm&MODE_GAME) + { + g_gameQuit = 1; + quittimer = totalclock+120; + } + else + { + int i; + + tempbuf[0] = PACKET_TYPE_MENU_LEVEL_QUIT; + tempbuf[1] = myconnectindex; + + TRAVERSE_CONNECT(i) + { + if (i != myconnectindex) sendpacket(i,tempbuf,2); + if ((!g_networkBroadcastMode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master + } + G_GameExit(" "); + } + } + else if (numplayers < 2) + G_GameExit(" "); + + if ((totalclock > quittimer) && (g_gameQuit == 1)) + G_GameExit("Timed out."); +} + +static void Net_SendWeaponChoice(void) { int i,l; - buf[0] = 10; + buf[0] = PACKET_TYPE_WEAPON_CHOICE; buf[1] = myconnectindex; l = 2; @@ -10707,25 +10612,43 @@ static void sendwchoice(void) buf[l++] = (char)g_player[0].wchoice[i]; } - for (i=connecthead;i>=0;i=connectpoint2[i]) + TRAVERSE_CONNECT(i) { if (i != myconnectindex) sendpacket(i,&buf[0],l); - if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master + if ((!g_networkBroadcastMode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master } } -static void sendplayerupdate(void) +static void Net_SendVersion(void) +{ + int i; + + if (numplayers < 2) return; + + buf[0] = PACKET_TYPE_VERSION; + buf[1] = myconnectindex; + buf[2] = (char)atoi(s_builddate); + buf[3] = BYTEVERSION; + + TRAVERSE_CONNECT(i) + { + if (i != myconnectindex) sendpacket(i,&buf[0],4); + if ((!g_networkBroadcastMode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master + } + waitforeverybody(); +} + +static void Net_SendPlayerOptions(void) { int i,l; - buf[0] = 6; + buf[0] = PACKET_TYPE_PLAYER_OPTIONS; buf[1] = myconnectindex; - buf[2] = (char)atoi(s_builddate); - l = 3; + l = 2; //null terminated player name to send - for (i=0;myname[i];i++) buf[l++] = Btoupper(myname[i]); - buf[l++] = 0; +// for (i=0;szPlayerName[i];i++) buf[l++] = Btoupper(szPlayerName[i]); +// buf[l++] = 0; buf[l++] = g_player[myconnectindex].ps->aim_mode = ud.mouseaiming; buf[l++] = g_player[myconnectindex].ps->auto_aim = ud.config.AutoAim; @@ -10734,42 +10657,66 @@ static void sendplayerupdate(void) buf[l++] = g_player[myconnectindex].pteam = ud.team; - for (i=connecthead;i>=0;i=connectpoint2[i]) + TRAVERSE_CONNECT(i) { if (i != myconnectindex) sendpacket(i,&buf[0],l); - if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master + if ((!g_networkBroadcastMode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master } } -void sendboardname(void) +void Net_SendPlayerName(void) +{ + int i,l; + + for (l=0;(unsigned)l 1) { int j; int ch; - packbuf[0] = 9; + packbuf[0] = PACKET_TYPE_USER_MAP; packbuf[1] = 0; Bcorrectfilename(boardfilename,0); j = Bstrlen(boardfilename); - boardfilename[j] = 0; + boardfilename[j++] = 0; Bstrcat(packbuf+1,boardfilename); - for (ch=connecthead;ch >= 0;ch=connectpoint2[ch]) + TRAVERSE_CONNECT(ch) { - if (ch != myconnectindex) sendpacket(ch,packbuf,j+1); - if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master + if (ch != myconnectindex) sendpacket(ch,packbuf,j); + if ((!g_networkBroadcastMode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master } } } -void mpchangemap(int volume, int level) +void Net_NewGame(int volume, int level) { int i; - packbuf[0] = 5; + packbuf[0] = PACKET_TYPE_NEW_GAME; packbuf[1] = ud.m_level_number = level; packbuf[2] = ud.m_volume_number = volume; packbuf[3] = ud.m_player_skill+1; @@ -10782,46 +10729,42 @@ void mpchangemap(int volume, int level) packbuf[10] = ud.m_ffire; packbuf[11] = ud.m_noexits; - for (i=connecthead;i>=0;i=connectpoint2[i]) + TRAVERSE_CONNECT(i) { if (i != myconnectindex) sendpacket(i,packbuf,12); - if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master + if ((!g_networkBroadcastMode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master } } +#if 0 static void getnames(void) { int l; - for (l=0;(unsigned)l 1) { - sendplayerupdate(); - sendwchoice(); - sendboardname(); + Net_SendVersion(); + Net_SendPlayerName(); + Net_SendPlayerOptions(); + Net_SendWeaponChoice(); + Net_SendUserMapName(); getpackets(); waitforeverybody(); } if (cp == 1 && numplayers < 2) - gameexit("Please put the Duke Nukem 3D Atomic Edition CD in the CD-ROM drive."); + G_GameExit("Please put the Duke Nukem 3D Atomic Edition CD in the CD-ROM drive."); } +#endif -void updateplayer(void) +void G_UpdatePlayerFromMenu(void) { - int l; - if (ud.recstat != 0) return; - for (l=0;(unsigned)l 1) { - sendplayerupdate(); + Net_SendPlayerOptions(); if (sprite[g_player[myconnectindex].ps->i].picnum == APLAYER && sprite[g_player[myconnectindex].ps->i].pal != 1) sprite[g_player[myconnectindex].ps->i].pal = g_player[myconnectindex].pcolor; } @@ -10878,13 +10821,13 @@ static void copyprotect(void) } #endif -void backtomenu(void) +void G_BackToMenu(void) { boardfilename[0] = 0; - if (ud.recstat == 1) closedemowrite(); + if (ud.recstat == 1) G_CloseDemoWrite(); ud.warp_on = 0; g_player[myconnectindex].ps->gm = MODE_MENU; - cmenu(0); + ChangeToMenu(0); KB_FlushKeyboardQueue(); Bsprintf(tempbuf,APPNAME " - %s",duke3dgrpstring); wm_setapptitle(tempbuf); @@ -10893,9 +10836,9 @@ void backtomenu(void) #ifdef RENDERTYPEWIN void app_crashhandler(void) { - closedemowrite(); - scriptinfo(); - sendquit(); + G_CloseDemoWrite(); + X_ScriptInfo(); + Net_SendQuit(); } #endif @@ -10969,13 +10912,13 @@ void app_main(int argc,const char **argv) initsynccrc(); - checkcommandline(argc,argv); + G_CheckCommandLine(argc,argv); #ifdef RENDERTYPEWIN if (forcegl) initprintf("GL driver blacklist disabled.\n"); #endif - g_player[0].ps = (player_struct *) Bcalloc(1, sizeof(player_struct)); + g_player[0].ps = (DukePlayer_t *) Bcalloc(1, sizeof(DukePlayer_t)); g_player[0].sync = (input_t *) Bcalloc(1, sizeof(input_t)); if (getcwd(cwd,BMAX_PATH)) @@ -11080,7 +11023,7 @@ void app_main(int argc,const char **argv) if (time(NULL) - ud.config.LastUpdateCheck > UPDATEINTERVAL) { initprintf("Checking for updates...\n"); - if (getversionfromwebsite(tempbuf)) + if (G_GetVersionFromWebsite(tempbuf)) { initprintf("Current version is %d",atoi(tempbuf)); ud.config.LastUpdateCheck = time(NULL); @@ -11106,7 +11049,7 @@ void app_main(int argc,const char **argv) CONFIG_SetupMouse(); CONFIG_SetupJoystick(); CONFIG_WriteSetup(); - gameexit(" "); + G_GameExit(" "); } } else initprintf("... no upgrade available\n"); @@ -11139,7 +11082,7 @@ void app_main(int argc,const char **argv) if (!first) first = fg; if (!Bstrcasecmp(fg->name, defaultduke3dgrp)) { - g_GameType = grpfiles[i].game; + g_gameType = grpfiles[i].game; duke3dgrpstring = (char *)grpfiles[i].name; break; } @@ -11147,14 +11090,14 @@ void app_main(int argc,const char **argv) if (!fg && first) { Bstrcpy(defaultduke3dgrp, first->name); - g_GameType = first->game; + g_gameType = first->game; duke3dgrpstring = (char *)grpfiles[0].name; } else if (!fg) duke3dgrpstring = "Unknown GRP"; } #if (defined RENDERTYPEWIN || (defined RENDERTYPESDL && !defined __APPLE__ && defined HAVE_GTK2)) - if (i < 0 || (!g_NoSetup && (ud.configversion != BYTEVERSION_JF || ud.config.ForceSetup)) || g_CommandSetup) + if (i < 0 || (!g_noSetup && (ud.configversion != BYTEVERSION_JF || ud.config.ForceSetup)) || g_commandSetup) { if (quitevent || !startwin_run()) { @@ -11172,8 +11115,8 @@ void app_main(int argc,const char **argv) // something different, they get what they asked for Bsprintf(defaultduke3dgrp,"ww2gi.grp"); Bsprintf(defaultconfilename, "ww2gi.con"); - Bsprintf(gametype_names[0],"GRUNTMATCH (SPAWN)"); - Bsprintf(gametype_names[2],"GRUNTMATCH (NO SPAWN)"); + Bsprintf(GametypeNames[0],"GRUNTMATCH (SPAWN)"); + Bsprintf(GametypeNames[2],"GRUNTMATCH (NO SPAWN)"); } else if (NAM) { @@ -11181,8 +11124,8 @@ void app_main(int argc,const char **argv) // something different, they get what they asked for Bsprintf(defaultduke3dgrp,"nam.grp"); Bsprintf(defaultconfilename, "nam.con"); - Bsprintf(gametype_names[0],"GRUNTMATCH (SPAWN)"); - Bsprintf(gametype_names[2],"GRUNTMATCH (NO SPAWN)"); + Bsprintf(GametypeNames[0],"GRUNTMATCH (SPAWN)"); + Bsprintf(GametypeNames[2],"GRUNTMATCH (NO SPAWN)"); } if (mod_dir[0] != '/') @@ -11203,7 +11146,7 @@ void app_main(int argc,const char **argv) else initprintf("Using group file '%s' as main group file.\n", duke3dgrp); - if (!g_NoAutoLoad) + if (!g_noAutoLoad) { getfilenames("autoload","*.grp"); while (findfiles) { Bsprintf(tempbuf,"autoload/%s",findfiles->name); initprintf("Using group file '%s'.\n",tempbuf); initgroupfile(tempbuf); findfiles = findfiles->next; } @@ -11213,7 +11156,7 @@ void app_main(int argc,const char **argv) while (findfiles) { Bsprintf(tempbuf,"autoload/%s",findfiles->name); initprintf("Using group file '%s'.\n",tempbuf); initgroupfile(tempbuf); findfiles = findfiles->next; } if (i != -1) - autoloadgrps(duke3dgrp); + DoAutoload(duke3dgrp); } if (mod_dir[0] != '/') @@ -11242,10 +11185,10 @@ void app_main(int argc,const char **argv) if (j == -1) initprintf("Could not find group file '%s'.\n",CommandGrps->str); else { - groupfile = j; + g_groupFileHandle = j; initprintf("Using group file '%s'.\n",CommandGrps->str); - if (!g_NoAutoLoad) - autoloadgrps(CommandGrps->str); + if (!g_noAutoLoad) + DoAutoload(CommandGrps->str); } free(CommandGrps->str); @@ -11277,10 +11220,10 @@ void app_main(int argc,const char **argv) // initprintf("\n"); - if (g_ScriptDebug) - initprintf("CON debugging activated (level %d).\n",g_ScriptDebug); + if (g_scriptDebug) + initprintf("CON debugging activated (level %d).\n",g_scriptDebug); - RegisterShutdownFunction(Shutdown); + RegisterShutdownFunction(G_Shutdown); if (VOLUMEONE) { @@ -11288,14 +11231,14 @@ void app_main(int argc,const char **argv) initprintf("Please read LICENSE.DOC for more details.\n"); } - Startup(); // a bunch of stuff including compiling cons + G_Startup(); // a bunch of stuff including compiling cons if (numplayers > 1) ud.multimode = numplayers; for (i=1;i 1) { sendlogon(); + Net_SendPlayerOptions(); + Net_SendWeaponChoice(); + Net_SendUserMapName(); + getpackets(); + waitforeverybody(); } else if (boardfilename[0] != 0) { @@ -11330,7 +11281,7 @@ void app_main(int argc,const char **argv) ud.warp_on = 1; } - getnames(); + // getnames(); if (ud.multimode > 1) { @@ -11387,7 +11338,7 @@ void app_main(int argc,const char **argv) uninitengine(); exit(1); } - SetupGameButtons(); + G_SetupGameButtons(); CONFIG_SetupMouse(); CONFIG_SetupJoystick(); @@ -11421,7 +11372,7 @@ void app_main(int argc,const char **argv) j = 0; } if (i == 4) - gameexit("Unable to set failsafe video mode!"); + G_GameExit("Unable to set failsafe video mode!"); } } #else @@ -11437,23 +11388,23 @@ void app_main(int argc,const char **argv) } initprintf("Initializing music...\n"); - MusicStartup(); + S_MusicStartup(); initprintf("Initializing sound...\n"); - SoundStartup(); + S_SoundStartup(); loadtmb(); /* if (VOLUMEONE) { if (numplayers > 4 || ud.multimode > 4) - gameexit(" The full version of Duke Nukem 3D supports 5 or more players."); + G_GameExit(" The full version of Duke Nukem 3D supports 5 or more players."); } */ setbrightness(ud.brightness>>2,&g_player[myconnectindex].ps->palette[0],0); - // if(KB_KeyPressed( sc_Escape ) ) gameexit(" "); + // if(KB_KeyPressed( sc_Escape ) ) G_GameExit(" "); FX_StopAllSounds(); - clearsoundlocks(); + S_ClearSoundLocks(); OSD_Exec("autoexec.cfg"); @@ -11469,13 +11420,13 @@ void app_main(int argc,const char **argv) { clearview(0L); //g_player[myconnectindex].ps->palette = palette; - //palto(0,0,0,0); - setgamepalette(g_player[myconnectindex].ps, palette, 0); // JBF 20040308 + //G_FadePalette(0,0,0,0); + SetGamePalette(g_player[myconnectindex].ps, palette, 0); // JBF 20040308 rotatesprite(320<<15,200<<15,65536L,0,LOADSCREEN,0,0,2+8+64,0,0,xdim-1,ydim-1); menutext(160,105,0,0,"LOADING SAVED GAME..."); nextpage(); - if (loadplayer(ud.warp_on-2)) + if (G_LoadPlayer(ud.warp_on-2)) ud.warp_on = 0; } @@ -11496,31 +11447,31 @@ MAIN_LOOP_RESTART: waitforeverybody(); - for (i=connecthead;i>=0;i=connectpoint2[i]) + TRAVERSE_CONNECT(i) { - resetweapons(i); - resetinventory(i); + P_ResetWeapons(i); + P_ResetInventory(i); } - newgame(ud.m_volume_number,ud.m_level_number,ud.m_player_skill); + G_NewGame(ud.m_volume_number,ud.m_level_number,ud.m_player_skill); - if (enterlevel(MODE_GAME)) backtomenu(); + if (G_EnterLevel(MODE_GAME)) G_BackToMenu(); } - else Logo(); + else G_DisplayLogo(); } else if (ud.warp_on == 1) { - newgame(ud.m_volume_number,ud.m_level_number,ud.m_player_skill); + G_NewGame(ud.m_volume_number,ud.m_level_number,ud.m_player_skill); - if (enterlevel(MODE_GAME)) backtomenu(); + if (G_EnterLevel(MODE_GAME)) G_BackToMenu(); } - else vscrn(); + else G_UpdateScreenArea(); - if (ud.warp_on == 0 && playback()) + if (ud.warp_on == 0 && G_PlaybackDemo()) { FX_StopAllSounds(); - clearsoundlocks(); - g_NoLogoAnim = 1; + S_ClearSoundLocks(); + g_noLogoAnim = 1; goto MAIN_LOOP_RESTART; } @@ -11531,8 +11482,8 @@ MAIN_LOOP_RESTART: g_player[myconnectindex].ps->weaponswitch = ud.weaponswitch; g_player[myconnectindex].pteam = ud.team; - if (gametype_flags[ud.coop] & GAMETYPE_FLAG_TDM) - g_player[myconnectindex].ps->palookup = g_player[myconnectindex].pcolor = getteampal(g_player[myconnectindex].pteam); + if (GametypeFlags[ud.coop] & GAMETYPE_TDM) + g_player[myconnectindex].ps->palookup = g_player[myconnectindex].pcolor = G_GetTeamPalette(g_player[myconnectindex].pteam); else { if (ud.color) g_player[myconnectindex].ps->palookup = g_player[myconnectindex].pcolor = ud.color; @@ -11563,16 +11514,17 @@ MAIN_LOOP_RESTART: if (ud.recstat == 2 || ud.multimode > 1 || (ud.show_help == 0 && (g_player[myconnectindex].ps->gm&MODE_MENU) != MODE_MENU)) if (g_player[myconnectindex].ps->gm&MODE_GAME) - if (moveloop()) continue; + if (G_MoveLoop()) continue; if (g_player[myconnectindex].ps->gm&MODE_EOL || g_player[myconnectindex].ps->gm&MODE_RESTART) { - setgamepalette(g_player[myconnectindex].ps, palette, 0); - setpal(g_player[myconnectindex].ps); + SetGamePalette(g_player[myconnectindex].ps, palette, 0); + P_UpdateScreenPal(g_player[myconnectindex].ps); if (g_player[myconnectindex].ps->gm&MODE_EOL) { - closedemowrite(); + G_CloseDemoWrite(); + waitforeverybody(); ready2send = 0; @@ -11580,9 +11532,9 @@ MAIN_LOOP_RESTART: { i = ud.screen_size; ud.screen_size = 0; - vscrn(); + G_UpdateScreenArea(); ud.screen_size = i; - dobonus(0); + G_BonusScreen(0); } if (ud.eog) { @@ -11591,10 +11543,10 @@ MAIN_LOOP_RESTART: { if (!VOLUMEALL) { - doorders(); + G_DoOrderScreen(); } g_player[myconnectindex].ps->gm = MODE_MENU; - cmenu(0); + ChangeToMenu(0); probey = 0; goto MAIN_LOOP_RESTART; } @@ -11607,17 +11559,18 @@ MAIN_LOOP_RESTART: } ud.display_bonus_screen = 1; ready2send = 0; + waitforeverybody(); if (numplayers > 1) g_player[myconnectindex].ps->gm = MODE_GAME; - if (enterlevel(g_player[myconnectindex].ps->gm)) + if (G_EnterLevel(g_player[myconnectindex].ps->gm)) { - backtomenu(); + G_BackToMenu(); goto MAIN_LOOP_RESTART; } continue; } - cheats(); - nonsharedkeys(); + DoCheats(); + HandleLocalKeys(); if ((ud.show_help == 0 && ud.multimode < 2 && !(g_player[myconnectindex].ps->gm&MODE_MENU)) || ud.multimode > 1 || ud.recstat == 2) i = min(max((totalclock-ototalclock)*(65536L/TICSPERFRAME),0),65536); @@ -11627,42 +11580,44 @@ MAIN_LOOP_RESTART: if (ud.statusbarmode == 1 && (ud.statusbarscale == 100 || !getrendermode())) { ud.statusbarmode = 0; - vscrn(); + G_UpdateScreenArea(); } { static unsigned int nextrender = 0; unsigned int j = getticks(); - if (j > nextrender+g_FrameDelay) + if (j > nextrender+g_frameDelay) nextrender = j; if (r_maxfps == 0 || j >= nextrender) { - nextrender += g_FrameDelay; + nextrender += g_frameDelay; - displayrooms(screenpeek,i); + G_DrawRooms(screenpeek,i); if (getrendermode() >= 3) - drawbackground(); - displayrest(i); + G_DrawBackground(); + G_DisplayRest(i); if (g_player[myconnectindex].gotvote == 0 && voting != -1 && voting != myconnectindex) { Bsprintf(tempbuf,"%s^00 HAS CALLED A VOTE FOR MAP",g_player[voting].user_name); gametext(160,40,tempbuf,0,2+8+16); - Bsprintf(tempbuf,"%s (E%dL%d)",map[vote_episode*MAXLEVELS + vote_map].name,vote_episode+1,vote_map+1); + Bsprintf(tempbuf,"%s (E%dL%d)",MapInfo[vote_episode*MAXLEVELS + vote_map].name,vote_episode+1,vote_map+1); gametext(160,48,tempbuf,0,2+8+16); gametext(160,70,"PRESS F1 TO ACCEPT, F2 TO DECLINE",0,2+8+16); } - if (debug_on) caches(); + if (BUTTON(gamefunc_Show_DukeMatch_Scores)) ShowScores(); + + if (debug_on) G_ShowCacheLocks(); // checksync(); SyncStatMessage(); if (VOLUMEONE) { - if (ud.show_help == 0 && show_shareware > 0 && (g_player[myconnectindex].ps->gm&MODE_MENU) == 0) + if (ud.show_help == 0 && g_showShareware > 0 && (g_player[myconnectindex].ps->gm&MODE_MENU) == 0) rotatesprite((320-50)<<16,9<<16,65536L,0,BETAVERSION,0,0,2+8+16+128,0,0,xdim-1,ydim-1); } @@ -11677,12 +11632,12 @@ MAIN_LOOP_RESTART: faketimerhandler(); } - gameexit(" "); + G_GameExit(" "); } static int demo_version; -static int opendemoread(int which_demo) // 0 = mine +static int G_OpenDemoRead(int g_whichDemo) // 0 = mine { char d[13]; char ver; @@ -11690,19 +11645,19 @@ static int opendemoread(int which_demo) // 0 = mine Bstrcpy(d, "demo_.dmo"); - if (which_demo == 10) + if (g_whichDemo == 10) d[4] = 'x'; else - d[4] = '0' + which_demo; + d[4] = '0' + g_whichDemo; ud.reccnt = 0; - if (which_demo == 1 && firstdemofile[0] != 0) + if (g_whichDemo == 1 && firstdemofile[0] != 0) { - if ((recfilep = kopen4loadfrommod(firstdemofile,loadfromgrouponly)) == -1) return(0); + if ((recfilep = kopen4loadfrommod(firstdemofile,g_loadFromGroupOnly)) == -1) return(0); } else - if ((recfilep = kopen4loadfrommod(d,loadfromgrouponly)) == -1) return(0); + if ((recfilep = kopen4loadfrommod(d,g_loadFromGroupOnly)) == -1) return(0); if (kread(recfilep,&ud.reccnt,sizeof(int)) != sizeof(int)) goto corrupt; if (kread(recfilep,&ver,sizeof(char)) != sizeof(char)) goto corrupt; @@ -11762,7 +11717,7 @@ static int opendemoread(int which_demo) // 0 = mine for (i=0;i=0;i=connectpoint2[i]) + TRAVERSE_CONNECT(i) { copybufbyte(g_player[i].sync,&recsync[ud.reccnt],sizeof(input_t)); ud.reccnt++; @@ -11860,7 +11815,7 @@ static void record(void) } } -void closedemowrite(void) +void G_CloseDemoWrite(void) { if (ud.recstat == 1) { @@ -11876,14 +11831,14 @@ void closedemowrite(void) } } -static int which_demo = 1; -static int in_menu = 0; +static int g_whichDemo = 1; // extern int syncs[]; -static int playback(void) +static int G_PlaybackDemo(void) { int i,j,k,l; int foundemo = 0; + static int in_menu = 0; if (ready2send) return 0; @@ -11896,19 +11851,19 @@ RECHECK: flushperms(); - if (ud.multimode < 2) foundemo = opendemoread(which_demo); + if (ud.multimode < 2) foundemo = G_OpenDemoRead(g_whichDemo); if (foundemo == 0) { - if (which_demo > 1) + if (g_whichDemo > 1) { - which_demo = 1; + g_whichDemo = 1; goto RECHECK; } fadepal(0,0,0, 0,63,7); - setgamepalette(g_player[myconnectindex].ps, palette, 1); // JBF 20040308 - drawbackground(); - menus(); + SetGamePalette(g_player[myconnectindex].ps, palette, 1); // JBF 20040308 + G_DrawBackground(); + M_DisplayMenus(); //g_player[myconnectindex].ps->palette = palette; nextpage(); fadepal(0,0,0, 63,0,-7); @@ -11917,15 +11872,15 @@ RECHECK: else { ud.recstat = 2; - which_demo++; - if (which_demo == 10) which_demo = 1; - if (enterlevel(MODE_DEMO)) ud.recstat = foundemo = 0; + g_whichDemo++; + if (g_whichDemo == 10) g_whichDemo = 1; + if (G_EnterLevel(MODE_DEMO)) ud.recstat = foundemo = 0; } if (foundemo == 0 || in_menu || KB_KeyWaiting() || numplayers > 1) { FX_StopAllSounds(); - clearsoundlocks(); + S_ClearSoundLocks(); g_player[myconnectindex].ps->gm |= MODE_MENU; } @@ -11947,7 +11902,7 @@ RECHECK: l = min(ud.reccnt,RECSYNCBUFSIZ); if (kdfread(recsync,sizeof(input_t)*ud.multimode,l/ud.multimode,recfilep) != l/ud.multimode) { - OSD_Printf(OSD_ERROR "Demo %d is corrupt.\n", which_demo-1); + OSD_Printf(OSD_ERROR "Demo %d is corrupt.\n", g_whichDemo-1); foundemo = 0; ud.reccnt = 0; kclose(recfilep); @@ -11956,25 +11911,25 @@ RECHECK: } } - for (j=connecthead;j>=0;j=connectpoint2[j]) + TRAVERSE_CONNECT(j) { copybufbyte(&recsync[i],&inputfifo[g_player[j].movefifoend&(MOVEFIFOSIZ-1)][j],sizeof(input_t)); g_player[j].movefifoend++; i++; ud.reccnt--; } - domovethings(); + G_DoMoveThings(); } if (foundemo == 0) - drawbackground(); + G_DrawBackground(); else { - nonsharedkeys(); + HandleLocalKeys(); j = min(max((totalclock-lockclock)*(65536/TICSPERFRAME),0),65536); - displayrooms(screenpeek,j); - displayrest(j); + G_DrawRooms(screenpeek,j); + G_DisplayRest(j); if (ud.multimode > 1 && g_player[myconnectindex].ps->gm) getpackets(); @@ -11990,23 +11945,23 @@ RECHECK: { KB_ClearKeyDown(sc_Escape); FX_StopAllSounds(); - clearsoundlocks(); + S_ClearSoundLocks(); g_player[myconnectindex].ps->gm |= MODE_MENU; - cmenu(0); - intomenusounds(); + ChangeToMenu(0); + S_MenuSound(); } if (g_player[myconnectindex].ps->gm&MODE_TYPE) { - typemode(); + Net_EnterMessage(); if ((g_player[myconnectindex].ps->gm&MODE_TYPE) != MODE_TYPE) g_player[myconnectindex].ps->gm = MODE_MENU; } else { if (ud.recstat != 2) - menus(); - if (ud.multimode > 1 && current_menu != 20003 && current_menu != 20005 && current_menu != 210) + M_DisplayMenus(); + if (ud.multimode > 1 && g_currentMenu != 20003 && g_currentMenu != 20005 && g_currentMenu != 210) { ControlInfo noshareinfo; CONTROL_GetInput(&noshareinfo); @@ -12021,7 +11976,7 @@ RECHECK: } } - operatefta(); + G_PrintGameQuotes(); if (ud.last_camsprite != ud.camerasprite) { @@ -12066,30 +12021,30 @@ RECHECK: return 1; } -static int moveloop() +static int G_MoveLoop() { int i; if (numplayers > 1) - while (fakemovefifoplc < g_player[myconnectindex].movefifoend) fakedomovethings(); + while (predictfifoplc < g_player[myconnectindex].movefifoend) Net_DoPrediction(); getpackets(); if (numplayers < 2) bufferjitter = 0; while (g_player[myconnectindex].movefifoend-movefifoplc > bufferjitter) { - for (i=connecthead;i>=0;i=connectpoint2[i]) - if (movefifoplc == g_player[i].movefifoend) break; + TRAVERSE_CONNECT(i) + if (movefifoplc == g_player[i].movefifoend) break; if (i >= 0) break; - if (domovethings()) return 1; + if (G_DoMoveThings()) return 1; } return 0; } -static void fakedomovethingscorrect(void) +static void Net_CorrectPrediction(void) { int i; - player_struct *p; + DukePlayer_t *p; if (numplayers < 2) return; @@ -12121,21 +12076,21 @@ static void fakedomovethingscorrect(void) myhardlanding = p->hard_landing; myreturntocenter = p->return_to_center; - fakemovefifoplc = movefifoplc; - while (fakemovefifoplc < g_player[myconnectindex].movefifoend) - fakedomovethings(); + predictfifoplc = movefifoplc; + while (predictfifoplc < g_player[myconnectindex].movefifoend) + Net_DoPrediction(); } -static void fakedomovethings(void) +static void Net_DoPrediction(void) { input_t *syn; - player_struct *p; + DukePlayer_t *p; int i, j, k, doubvel, fz, cz, hz, lz, x, y; unsigned int sb_snum; short psect, psectlotag, tempsect, backcstat; char shrunk, spritebridge; - syn = (input_t *)&inputfifo[fakemovefifoplc&(MOVEFIFOSIZ-1)][myconnectindex]; + syn = (input_t *)&inputfifo[predictfifoplc&(MOVEFIFOSIZ-1)][myconnectindex]; p = g_player[myconnectindex].ps; @@ -12209,7 +12164,7 @@ static void fakedomovethings(void) psectlotag = 0; spritebridge = 1; } - if (badguy(&sprite[j]) && sprite[j].xrepeat > 24 && klabs(sprite[p->i].z-sprite[j].z) < (84<<8)) + if (A_CheckEnemySprite(&sprite[j]) && sprite[j].xrepeat > 24 && klabs(sprite[p->i].z-sprite[j].z) < (84<<8)) { j = getangle(sprite[j].x-myx,sprite[j].y-myy); myxvel -= sintable[(j+512)&2047]<<4; @@ -12250,13 +12205,13 @@ static void fakedomovethings(void) { myjumpingcounter = 0; - if (sb_snum&1) + if (TEST_SYNC_KEY(sb_snum, SK_JUMP)) { if (myzvel > 0) myzvel = 0; myzvel -= 348; if (myzvel < -(256*6)) myzvel = -(256*6); } - else if (sb_snum&(1<<1)) + else if (TEST_SYNC_KEY(sb_snum, SK_CROUCH)) { if (myzvel < 0) myzvel = 0; myzvel += 348; @@ -12304,9 +12259,9 @@ static void fakedomovethings(void) if (shrunk) j = 512; else j = 2048; - if (sb_snum&1) //A + if (TEST_SYNC_KEY(sb_snum, SK_JUMP)) //A myz -= j; - if (sb_snum&(1<<1)) //Z + if (TEST_SYNC_KEY(sb_snum, SK_CROUCH)) //Z myz += j; if (shrunk == 0 && (psectlotag == 0 || psectlotag == 2)) k = 32; @@ -12324,15 +12279,15 @@ static void fakedomovethings(void) if (shrunk == 0) i = 34; else i = 12; } - if (myz < (fz-(i<<8)) && (floorspace(psect)|ceilingspace(psect)) == 0) //falling + if (myz < (fz-(i<<8)) && (G_CheckForSpaceFloor(psect)|G_CheckForSpaceCeiling(psect)) == 0) //falling { - if ((sb_snum&3) == 0 && myonground && (sector[psect].floorstat&2) && myz >= (fz-(i<<8)-(16<<8))) + if (TEST_SYNC_KEY(sb_snum, SK_JUMP|SK_CROUCH) == 0 && myonground && (sector[psect].floorstat&2) && myz >= (fz-(i<<8)-(16<<8))) myz = fz-(i<<8); else { myonground = 0; - myzvel += (gc+80); + myzvel += (SpriteGravity+80); if (myzvel >= (4096+2048)) myzvel = (4096+2048); } @@ -12364,13 +12319,13 @@ static void fakedomovethings(void) } } - if (sb_snum&2) + if (TEST_SYNC_KEY(sb_snum, SK_CROUCH)) myz += (2048+768); - if ((sb_snum&1) == 0 && myjumpingtoggle == 1) + if (TEST_SYNC_KEY(sb_snum, SK_JUMP) == 0 && myjumpingtoggle == 1) myjumpingtoggle = 0; - else if ((sb_snum&1) && myjumpingtoggle == 0) + else if (TEST_SYNC_KEY(sb_snum, SK_JUMP) && myjumpingtoggle == 0) { if (myjumpingcounter == 0) if ((fz-cz) > (56<<8)) @@ -12379,13 +12334,13 @@ static void fakedomovethings(void) myjumpingtoggle = 1; } } - if (myjumpingcounter && (sb_snum&1) == 0) + if (myjumpingcounter && TEST_SYNC_KEY(sb_snum, SK_JUMP) == 0) myjumpingcounter = 0; } if (myjumpingcounter) { - if ((sb_snum&1) == 0 && myjumpingtoggle == 1) + if (TEST_SYNC_KEY(sb_snum, SK_JUMP) == 0 && myjumpingtoggle == 1) myjumpingtoggle = 0; if (myjumpingcounter < (1024+256)) @@ -12453,7 +12408,7 @@ static void fakedomovethings(void) myxvel += ((syn->fvel*doubvel)<<6); myyvel += ((syn->svel*doubvel)<<6); - if ((p->curr_weapon == KNEE_WEAPON && p->kickback_pic > 10 && myonground) || (myonground && (sb_snum&2))) + if ((p->curr_weapon == KNEE_WEAPON && p->kickback_pic > 10 && myonground) || (myonground && TEST_SYNC_KEY(sb_snum, SK_CROUCH))) { myxvel = mulscale16(myxvel,p->runspeed-0x2000); myyvel = mulscale16(myyvel,p->runspeed-0x2000); @@ -12494,34 +12449,34 @@ FAKEHORIZONLY: if (p->jetpack_on == 0 && psectlotag != 1 && psectlotag != 2 && shrunk) myz += 30<<8; - if ((sb_snum&(1<<18)) || myhardlanding) + if (TEST_SYNC_KEY(sb_snum, SK_CENTER_VIEW) || myhardlanding) myreturntocenter = 9; - if (sb_snum&(1<<13)) + if (TEST_SYNC_KEY(sb_snum, SK_LOOK_UP)) { myreturntocenter = 9; - if (sb_snum&(1<<5)) myhoriz += 6; + if (TEST_SYNC_KEY(sb_snum, SK_RUN)) myhoriz += 6; myhoriz += 6; } - else if (sb_snum&(1<<14)) + else if (TEST_SYNC_KEY(sb_snum, SK_LOOK_DOWN)) { myreturntocenter = 9; - if (sb_snum&(1<<5)) myhoriz -= 6; + if (TEST_SYNC_KEY(sb_snum, SK_RUN)) myhoriz -= 6; myhoriz -= 6; } - else if (sb_snum&(1<<3)) + else if (TEST_SYNC_KEY(sb_snum, SK_AIM_UP)) { - if (sb_snum&(1<<5)) myhoriz += 6; + if (TEST_SYNC_KEY(sb_snum, SK_RUN)) myhoriz += 6; myhoriz += 6; } - else if (sb_snum&(1<<4)) + else if (TEST_SYNC_KEY(sb_snum, SK_AIM_DOWN)) { - if (sb_snum&(1<<5)) myhoriz -= 6; + if (TEST_SYNC_KEY(sb_snum, SK_RUN)) myhoriz -= 6; myhoriz -= 6; } if (myreturntocenter > 0) - if ((sb_snum&(1<<13)) == 0 && (sb_snum&(1<<14)) == 0) + if (TEST_SYNC_KEY(sb_snum, SK_LOOK_UP) == 0 && TEST_SYNC_KEY(sb_snum, SK_LOOK_DOWN) == 0) { myreturntocenter--; myhoriz += 33-(myhoriz/3); @@ -12552,78 +12507,78 @@ FAKEHORIZONLY: ENDFAKEPROCESSINPUT: - OnEvent(EVENT_FAKEDOMOVETHINGS, g_player[myconnectindex].ps->i, myconnectindex, -1); + X_OnEvent(EVENT_FAKEDOMOVETHINGS, g_player[myconnectindex].ps->i, myconnectindex, -1); - myxbak[fakemovefifoplc&(MOVEFIFOSIZ-1)] = myx; - myybak[fakemovefifoplc&(MOVEFIFOSIZ-1)] = myy; - myzbak[fakemovefifoplc&(MOVEFIFOSIZ-1)] = myz; - myangbak[fakemovefifoplc&(MOVEFIFOSIZ-1)] = myang; - myhorizbak[fakemovefifoplc&(MOVEFIFOSIZ-1)] = myhoriz; - fakemovefifoplc++; + myxbak[predictfifoplc&(MOVEFIFOSIZ-1)] = myx; + myybak[predictfifoplc&(MOVEFIFOSIZ-1)] = myy; + myzbak[predictfifoplc&(MOVEFIFOSIZ-1)] = myz; + myangbak[predictfifoplc&(MOVEFIFOSIZ-1)] = myang; + myhorizbak[predictfifoplc&(MOVEFIFOSIZ-1)] = myhoriz; + predictfifoplc++; sprite[p->i].cstat = backcstat; } -static int domovethings(void) +static int G_DoMoveThings(void) { int i, j; // char ch; - for (i=connecthead;i>=0;i=connectpoint2[i]) - if (g_player[i].sync->bits&(1<<17)) + TRAVERSE_CONNECT(i) + if (TEST_SYNC_KEY(g_player[i].sync->bits, SK_MULTIFLAG)) + { + multiflag = 2; + multiwhat = (g_player[i].sync->bits>>(SK_MULTIFLAG+1))&1; + multipos = (unsigned)(g_player[i].sync->bits>>(SK_MULTIFLAG+2))&15; + multiwho = i; + + if (multiwhat) { - multiflag = 2; - multiwhat = (g_player[i].sync->bits>>18)&1; - multipos = (unsigned)(g_player[i].sync->bits>>19)&15; - multiwho = i; + G_SavePlayer(multipos); + multiflag = 0; - if (multiwhat) + if (multiwho != myconnectindex) { - saveplayer(multipos); - multiflag = 0; - - if (multiwho != myconnectindex) - { - Bsprintf(fta_quotes[122],"%s^00 SAVED A MULTIPLAYER GAME",&g_player[multiwho].user_name[0]); - FTA(122,g_player[myconnectindex].ps); - } - else - { - Bstrcpy(fta_quotes[122],"MULTIPLAYER GAME SAVED"); - FTA(122,g_player[myconnectindex].ps); - } - break; + Bsprintf(ScriptQuotes[122],"%s^00 SAVED A MULTIPLAYER GAME",&g_player[multiwho].user_name[0]); + P_DoQuote(122,g_player[myconnectindex].ps); } else { - // waitforeverybody(); + Bstrcpy(ScriptQuotes[122],"MULTIPLAYER GAME SAVED"); + P_DoQuote(122,g_player[myconnectindex].ps); + } + break; + } + else + { + // waitforeverybody(); - j = loadplayer(multipos); + j = G_LoadPlayer(multipos); - multiflag = 0; + multiflag = 0; - if (j == 0) + if (j == 0) + { + if (multiwho != myconnectindex) { - if (multiwho != myconnectindex) - { - Bsprintf(fta_quotes[122],"%s^00 LOADED A MULTIPLAYER GAME",&g_player[multiwho].user_name[0]); - FTA(122,g_player[myconnectindex].ps); - } - else - { - Bstrcpy(fta_quotes[122],"MULTIPLAYER GAME LOADED"); - FTA(122,g_player[myconnectindex].ps); - } - return 1; + Bsprintf(ScriptQuotes[122],"%s^00 LOADED A MULTIPLAYER GAME",&g_player[multiwho].user_name[0]); + P_DoQuote(122,g_player[myconnectindex].ps); } + else + { + Bstrcpy(ScriptQuotes[122],"MULTIPLAYER GAME LOADED"); + P_DoQuote(122,g_player[myconnectindex].ps); + } + return 1; } } + } ud.camerasprite = -1; lockclock += TICSPERFRAME; - if (earthquaketime > 0) earthquaketime--; - if (rtsplaying > 0) rtsplaying--; + if (g_earthquakeTime > 0) g_earthquakeTime--; + if (g_RTSPlaying > 0) g_RTSPlaying--; for (i=0;ii],&sprite[hs]) < 9216) { - Bsprintf(fta_quotes[117],"%s",&g_player[sprite[hs].yvel].user_name[0]); + Bsprintf(ScriptQuotes[117],"%s",&g_player[sprite[hs].yvel].user_name[0]); g_player[screenpeek].ps->fta = 12, g_player[screenpeek].ps->ftq = 117; } } @@ -12666,10 +12621,10 @@ static int domovethings(void) } } - if (show_shareware > 0) + if (g_showShareware > 0) { - show_shareware--; - if (show_shareware == 0) + g_showShareware--; + if (g_showShareware == 0) { pus = NUMPAGES; pub = NUMPAGES; @@ -12678,24 +12633,24 @@ static int domovethings(void) everyothertime++; - for (i=connecthead;i>=0;i=connectpoint2[i]) - copybufbyte(&inputfifo[movefifoplc&(MOVEFIFOSIZ-1)][i],g_player[i].sync,sizeof(input_t)); + TRAVERSE_CONNECT(i) + copybufbyte(&inputfifo[movefifoplc&(MOVEFIFOSIZ-1)][i],g_player[i].sync,sizeof(input_t)); movefifoplc++; - updateinterpolations(); + G_UpdateInterpolations(); j = -1; - for (i=connecthead;i>=0;i=connectpoint2[i]) + TRAVERSE_CONNECT(i) { - if ((g_player[i].sync->bits&(1<<26)) == 0) + if (TEST_SYNC_KEY(g_player[i].sync->bits,SK_GAMEQUIT) == 0) { j = i; continue; } - closedemowrite(); + G_CloseDemoWrite(); - if (i == myconnectindex) gameexit(" "); + if (i == myconnectindex) G_GameExit(" "); if (screenpeek == i) { screenpeek = connectpoint2[i]; @@ -12709,18 +12664,18 @@ static int domovethings(void) ud.multimode--; if (numplayers < 2) - sound(GENERIC_AMBIENCE17); + S_PlaySound(GENERIC_AMBIENCE17); pub = NUMPAGES; pus = NUMPAGES; - vscrn(); + G_UpdateScreenArea(); - quickkill(g_player[i].ps); + P_QuickKill(g_player[i].ps); deletesprite(g_player[i].ps->i); Bsprintf(buf,"%s^00 is history!",g_player[i].user_name); - adduserquote(buf); - Bstrcpy(fta_quotes[116],buf); + G_AddUserQuote(buf); + Bstrcpy(ScriptQuotes[116],buf); if (voting == i) { @@ -12734,8 +12689,8 @@ static int domovethings(void) g_player[myconnectindex].ps->ftq = 116, g_player[myconnectindex].ps->fta = 180; - if (j < 0 && networkmode == 0) - gameexit("Server terminated"); + if (j < 0 && g_networkBroadcastMode == 0) + G_GameExit("Server terminated"); } /* if ((numplayers >= 2) && ((movefifoplc&7) == 7)) @@ -12750,51 +12705,51 @@ static int domovethings(void) getsyncstat(); - MoveThingsCount++; + g_moveThingsCount++; - if (ud.recstat == 1) record(); + if (ud.recstat == 1) G_DemoRecord(); if (ud.pause_on == 0) { - global_random = TRAND; - movedummyplayers();//ST 13 + g_globalRandom = krand(); + A_MoveDummyPlayers();//ST 13 } - for (i=connecthead;i>=0;i=connectpoint2[i]) + TRAVERSE_CONNECT(i) { if (g_player[i].sync->extbits&(1<<6)) { g_player[i].ps->team = g_player[i].pteam; - if (gametype_flags[ud.coop] & GAMETYPE_FLAG_TDM) + if (GametypeFlags[ud.coop] & GAMETYPE_TDM) { - hittype[g_player[i].ps->i].picnum = APLAYERTOP; - quickkill(g_player[i].ps); + ActorExtra[g_player[i].ps->i].picnum = APLAYERTOP; + P_QuickKill(g_player[i].ps); } } - if (gametype_flags[ud.coop] & GAMETYPE_FLAG_TDM) - g_player[i].ps->palookup = g_player[i].pcolor = getteampal(g_player[i].ps->team); + if (GametypeFlags[ud.coop] & GAMETYPE_TDM) + g_player[i].ps->palookup = g_player[i].pcolor = G_GetTeamPalette(g_player[i].ps->team); if (sprite[g_player[i].ps->i].pal != 1) sprite[g_player[i].ps->i].pal = g_player[i].pcolor; - sharedkeys(i); + G_HandleSharedKeys(i); if (ud.pause_on == 0) { - processinput(i); + P_ProcessInput(i); checksectors(i); } } if (ud.pause_on == 0) - moveobjects(); + G_MoveWorld(); - fakedomovethingscorrect(); + Net_CorrectPrediction(); if ((everyothertime&1) == 0) { - animatewalls(); - movecyclers(); + G_AnimateWalls(); + A_MoveCyclers(); pan3dsound(); } @@ -12806,13 +12761,13 @@ static int domovethings(void) return 0; } -static void doorders(void) +static void G_DoOrderScreen(void) { setview(0,0,xdim-1,ydim-1); fadepal(0,0,0, 0,63,7); //g_player[myconnectindex].ps->palette = palette; - setgamepalette(g_player[myconnectindex].ps, palette, 1); // JBF 20040308 + SetGamePalette(g_player[myconnectindex].ps, palette, 1); // JBF 20040308 KB_FlushKeyboardQueue(); rotatesprite(0,0,65536L,0,ORDERING,0,0,2+8+16+64, 0,0,xdim-1,ydim-1); fadepal(0,0,0, 63,0,-7); @@ -12853,7 +12808,7 @@ static void doorders(void) } } -void dobonus(int bonusonly) +void G_BonusScreen(int bonusonly) { int t, tinc,gfx_offset; int i, y,xfragtotal,yfragtotal; @@ -12889,7 +12844,7 @@ void dobonus(int bonusonly) if (!lastmapname) lastmapname = Bstrrchr(boardfilename,'/'); if (!lastmapname) lastmapname = boardfilename; } - else lastmapname = map[(ud.volume_number*MAXLEVELS)+ud.last_level-1].name; + else lastmapname = MapInfo[(ud.volume_number*MAXLEVELS)+ud.last_level-1].name; bonuscnt = 0; @@ -12900,7 +12855,7 @@ void dobonus(int bonusonly) flushperms(); FX_StopAllSounds(); - clearsoundlocks(); + S_ClearSoundLocks(); FX_SetReverb(0L); bindsenabled = 1; // so you can use your screenshot bind on the score screens @@ -12912,7 +12867,7 @@ void dobonus(int bonusonly) case 0: if (ud.lockout == 0) { - setgamepalette(g_player[myconnectindex].ps, endingpal, 11); // JBF 20040308 + SetGamePalette(g_player[myconnectindex].ps, endingpal, 11); // JBF 20040308 clearview(0L); rotatesprite(0,50<<16,65536L,0,VICTORY1,0,0,2+8+16+64+128,0,0,xdim-1,ydim-1); nextpage(); @@ -12933,8 +12888,8 @@ void dobonus(int bonusonly) { if (t==10 && bonuscnt == 1) { - sound(SHOTGUN_FIRE); - sound(SQUISHED); + S_PlaySound(SHOTGUN_FIRE); + S_PlaySound(SQUISHED); bonuscnt++; } rotatesprite(bossmove[t+3]<<16,bossmove[t+4]<<16,65536L,0,bossmove[t+2],0,0,2+8+16+64+128,0,0,xdim-1,ydim-1); @@ -12948,7 +12903,7 @@ void dobonus(int bonusonly) rotatesprite(86<<16,59<<16,65536L,0,VICTORY1+8,0,0,2+8+16+64+128,0,0,xdim-1,ydim-1); if (totalclock >= 750 && bonuscnt == 2) { - sound(DUKETALKTOBOSS); + S_PlaySound(DUKETALKTOBOSS); bonuscnt++; } @@ -12958,7 +12913,7 @@ void dobonus(int bonusonly) { if (t==5 && bonuscnt == 0) { - sound(BOSSTALKTODUKE); + S_PlaySound(BOSSTALKTODUKE); bonuscnt++; } rotatesprite(breathe[t+3]<<16,breathe[t+4]<<16,65536L,0,breathe[t+2],0,0,2+8+16+64+128,0,0,xdim-1,ydim-1); @@ -12975,7 +12930,7 @@ void dobonus(int bonusonly) KB_FlushKeyboardQueue(); //g_player[myconnectindex].ps->palette = palette; - setgamepalette(g_player[myconnectindex].ps, palette, 11); // JBF 20040308 + SetGamePalette(g_player[myconnectindex].ps, palette, 11); // JBF 20040308 rotatesprite(0,0,65536L,0,3292,0,0,2+8+16+64, 0,0,xdim-1,ydim-1); IFISSOFTMODE fadepal(0,0,0, 63,0,-1); @@ -12988,7 +12943,7 @@ void dobonus(int bonusonly) fadepal(0,0,0, 0,64,1); MUSIC_StopSong(); FX_StopAllSounds(); - clearsoundlocks(); + S_ClearSoundLocks(); break; case 1: MUSIC_StopSong(); @@ -12997,19 +12952,19 @@ void dobonus(int bonusonly) if (ud.lockout == 0) { - playanm("cineov2.anm",1); + G_PlayAnim("cineov2.anm",1); KB_FlushKeyBoardQueue(); clearview(0L); nextpage(); } - sound(PIPEBOMB_EXPLODE); + S_PlaySound(PIPEBOMB_EXPLODE); fadepal(0,0,0, 0,64,1); setview(0,0,xdim-1,ydim-1); KB_FlushKeyboardQueue(); //g_player[myconnectindex].ps->palette = palette; - setgamepalette(g_player[myconnectindex].ps, palette, 11); // JBF 20040308 + SetGamePalette(g_player[myconnectindex].ps, palette, 11); // JBF 20040308 rotatesprite(0,0,65536L,0,3293,0,0,2+8+16+64, 0,0,xdim-1,ydim-1); IFISSOFTMODE fadepal(0,0,0, 63,0,-1); else nextpage(); @@ -13033,25 +12988,25 @@ void dobonus(int bonusonly) if (ud.lockout == 0) { KB_FlushKeyboardQueue(); - playanm("vol4e1.anm",8); + G_PlayAnim("vol4e1.anm",8); clearview(0L); nextpage(); - playanm("vol4e2.anm",10); + G_PlayAnim("vol4e2.anm",10); clearview(0L); nextpage(); - playanm("vol4e3.anm",11); + G_PlayAnim("vol4e3.anm",11); clearview(0L); nextpage(); } FX_StopAllSounds(); - clearsoundlocks(); - sound(ENDSEQVOL3SND4); + S_ClearSoundLocks(); + S_PlaySound(ENDSEQVOL3SND4); KB_FlushKeyBoardQueue(); //g_player[myconnectindex].ps->palette = palette; - setgamepalette(g_player[myconnectindex].ps, palette, 11); // JBF 20040308 - IFISSOFTMODE palto(0,0,0,63); + SetGamePalette(g_player[myconnectindex].ps, palette, 11); // JBF 20040308 + IFISSOFTMODE G_FadePalette(0,0,0,63); clearview(0L); menutext(160,60,0,0,"THANKS TO ALL OUR"); menutext(160,60+16,0,0,"FANS FOR GIVING"); @@ -13073,7 +13028,7 @@ void dobonus(int bonusonly) nextpage(); MOUSE_ClearButton(LEFT_MOUSE); - playanm("DUKETEAM.ANM",4); + G_PlayAnim("DUKETEAM.ANM",4); KB_FlushKeyBoardQueue(); while (!KB_KeyWaiting() && !MOUSE_GetButtons()&LEFT_MOUSE) @@ -13084,10 +13039,10 @@ void dobonus(int bonusonly) clearview(0L); nextpage(); - IFISSOFTMODE palto(0,0,0,63); + IFISSOFTMODE G_FadePalette(0,0,0,63); FX_StopAllSounds(); - clearsoundlocks(); + S_ClearSoundLocks(); KB_FlushKeyBoardQueue(); MOUSE_ClearButton(LEFT_MOUSE); @@ -13101,7 +13056,7 @@ void dobonus(int bonusonly) if (ud.lockout == 0) { fadepal(0,0,0, 63,0,-1); - playanm("cineov3.anm",2); + G_PlayAnim("cineov3.anm",2); KB_FlushKeyBoardQueue(); ototalclock = totalclock+200; while (totalclock < ototalclock) @@ -13113,43 +13068,43 @@ void dobonus(int bonusonly) nextpage(); FX_StopAllSounds(); - clearsoundlocks(); + S_ClearSoundLocks(); } - playanm("RADLOGO.ANM",3); + G_PlayAnim("RADLOGO.ANM",3); if (ud.lockout == 0 && !KB_KeyWaiting() && !MOUSE_GetButtons()&LEFT_MOUSE) { - sound(ENDSEQVOL3SND5); - while (issoundplaying(-1,ENDSEQVOL3SND5)) + S_PlaySound(ENDSEQVOL3SND5); + while (S_CheckSoundPlaying(-1,ENDSEQVOL3SND5)) { handleevents(); getpackets(); } if (KB_KeyWaiting() || MOUSE_GetButtons()&LEFT_MOUSE) goto ENDANM; - sound(ENDSEQVOL3SND6); - while (issoundplaying(-1,ENDSEQVOL3SND6)) + S_PlaySound(ENDSEQVOL3SND6); + while (S_CheckSoundPlaying(-1,ENDSEQVOL3SND6)) { handleevents(); getpackets(); } if (KB_KeyWaiting() || MOUSE_GetButtons()&LEFT_MOUSE) goto ENDANM; - sound(ENDSEQVOL3SND7); - while (issoundplaying(-1,ENDSEQVOL3SND7)) + S_PlaySound(ENDSEQVOL3SND7); + while (S_CheckSoundPlaying(-1,ENDSEQVOL3SND7)) { handleevents(); getpackets(); } if (KB_KeyWaiting() || MOUSE_GetButtons()&LEFT_MOUSE) goto ENDANM; - sound(ENDSEQVOL3SND8); - while (issoundplaying(-1,ENDSEQVOL3SND8)) + S_PlaySound(ENDSEQVOL3SND8); + while (S_CheckSoundPlaying(-1,ENDSEQVOL3SND8)) { handleevents(); getpackets(); } if (KB_KeyWaiting() || MOUSE_GetButtons()&LEFT_MOUSE) goto ENDANM; - sound(ENDSEQVOL3SND9); - while (issoundplaying(-1,ENDSEQVOL3SND9)) + S_PlaySound(ENDSEQVOL3SND9); + while (S_CheckSoundPlaying(-1,ENDSEQVOL3SND9)) { handleevents(); getpackets(); @@ -13168,7 +13123,7 @@ void dobonus(int bonusonly) ENDANM: MOUSE_ClearButton(LEFT_MOUSE); FX_StopAllSounds(); - clearsoundlocks(); + S_ClearSoundLocks(); KB_FlushKeyBoardQueue(); @@ -13180,8 +13135,8 @@ ENDANM: FRAGBONUS: //g_player[myconnectindex].ps->palette = palette; - setgamepalette(g_player[myconnectindex].ps, palette, 11); // JBF 20040308 - IFISSOFTMODE palto(0,0,0,63); // JBF 20031228 + SetGamePalette(g_player[myconnectindex].ps, palette, 11); // JBF 20040308 + IFISSOFTMODE G_FadePalette(0,0,0,63); // JBF 20031228 KB_FlushKeyboardQueue(); totalclock = 0; tinc = 0; @@ -13189,19 +13144,19 @@ FRAGBONUS: MUSIC_StopSong(); FX_StopAllSounds(); - clearsoundlocks(); + S_ClearSoundLocks(); - if (playerswhenstarted > 1 && (gametype_flags[ud.coop]&GAMETYPE_FLAG_SCORESHEET)) + if (playerswhenstarted > 1 && (GametypeFlags[ud.coop]&GAMETYPE_SCORESHEET)) { if (!(ud.config.MusicToggle == 0 || ud.config.MusicDevice < 0)) - sound(BONUSMUSIC); + S_PlaySound(BONUSMUSIC); rotatesprite(0,0,65536L,0,MENUSCREEN,16,0,2+8+16+64,0,0,xdim-1,ydim-1); rotatesprite(160<<16,34<<16,65536L,0,INGAMEDUKETHREEDEE,0,0,10,0,0,xdim-1,ydim-1); if (PLUTOPAK) // JBF 20030804 rotatesprite((260)<<16,36<<16,65536L,0,PLUTOPAKSPRITE+2,0,0,2+8,0,0,xdim-1,ydim-1); gametext(160,58+2,"MULTIPLAYER TOTALS",0,2+8+16); - gametext(160,58+10,map[(ud.volume_number*MAXLEVELS)+ud.last_level-1].name,0,2+8+16); + gametext(160,58+10,MapInfo[(ud.volume_number*MAXLEVELS)+ud.last_level-1].name,0,2+8+16); gametext(160,165,"PRESS ANY KEY TO CONTINUE",0,2+8+16); @@ -13273,7 +13228,8 @@ FRAGBONUS: int tc = totalclock; while (KB_KeyWaiting()==0) { - if (totalclock > tc + 600) break; + // continue after 10 seconds... + if (totalclock > tc + (120*10)) break; handleevents(); getpackets(); } @@ -13304,7 +13260,7 @@ FRAGBONUS: gametext(160,192,"PRESS ANY KEY TO CONTINUE",16,2+8+16); if (!(ud.config.MusicToggle == 0 || ud.config.MusicDevice < 0)) - sound(BONUSMUSIC); + S_PlaySound(BONUSMUSIC); nextpage(); KB_FlushKeyboardQueue(); @@ -13313,11 +13269,11 @@ FRAGBONUS: totalclock = 0; tinc = 0; - playerbest = CONFIG_GetMapBestTime(map[ud.volume_number*MAXLEVELS+ud.last_level-1].filename); + playerbest = CONFIG_GetMapBestTime(MapInfo[ud.volume_number*MAXLEVELS+ud.last_level-1].filename); if (g_player[myconnectindex].ps->player_par < playerbest || playerbest < 0) { - CONFIG_SetMapBestTime(map[ud.volume_number*MAXLEVELS+ud.last_level-1].filename, g_player[myconnectindex].ps->player_par); + CONFIG_SetMapBestTime(MapInfo[ud.volume_number*MAXLEVELS+ud.last_level-1].filename, g_player[myconnectindex].ps->player_par); // if(playerbest != -1) // playerbest = g_player[myconnectindex].ps->player_par; } @@ -13329,11 +13285,11 @@ FRAGBONUS: clockpad = max(clockpad,ij); if (!(ud.volume_number == 0 && ud.last_level-1 == 7)) { - for (ii=map[ud.volume_number*MAXLEVELS+ud.last_level-1].partime/(26*60), ij=1; ii>9; ii/=10, ij++) ; + for (ii=MapInfo[ud.volume_number*MAXLEVELS+ud.last_level-1].partime/(26*60), ij=1; ii>9; ii/=10, ij++) ; clockpad = max(clockpad,ij); if (!NAM) { - for (ii=map[ud.volume_number*MAXLEVELS+ud.last_level-1].designertime/(26*60), ij=1; ii>9; ii/=10, ij++) ; + for (ii=MapInfo[ud.volume_number*MAXLEVELS+ud.last_level-1].designertime/(26*60), ij=1; ii>9; ii/=10, ij++) ; clockpad = max(clockpad,ij); } } @@ -13361,20 +13317,20 @@ FRAGBONUS: if (bonuscnt == 6) { bonuscnt++; - sound(SHOTGUN_COCK); + S_PlaySound(SHOTGUN_COCK); switch (rand()&3) { case 0: - sound(BONUS_SPEECH1); + S_PlaySound(BONUS_SPEECH1); break; case 1: - sound(BONUS_SPEECH2); + S_PlaySound(BONUS_SPEECH2); break; case 2: - sound(BONUS_SPEECH3); + S_PlaySound(BONUS_SPEECH3); break; case 3: - sound(BONUS_SPEECH4); + S_PlaySound(BONUS_SPEECH4); break; } } @@ -13440,7 +13396,7 @@ FRAGBONUS: if (bonuscnt == 1) { bonuscnt++; - sound(PIPEBOMB_EXPLODE); + S_PlaySound(PIPEBOMB_EXPLODE); } Bsprintf(tempbuf,"%0*d:%02d.%02d",clockpad, @@ -13456,16 +13412,16 @@ FRAGBONUS: if (!(ud.volume_number == 0 && ud.last_level-1 == 7)) { Bsprintf(tempbuf,"%0*d:%02d",clockpad, - (map[ud.volume_number*MAXLEVELS+ud.last_level-1].partime/(26*60)), - (map[ud.volume_number*MAXLEVELS+ud.last_level-1].partime/26)%60); + (MapInfo[ud.volume_number*MAXLEVELS+ud.last_level-1].partime/(26*60)), + (MapInfo[ud.volume_number*MAXLEVELS+ud.last_level-1].partime/26)%60); gametext((320>>2)+71,yy+9,tempbuf,0,2+8+16); yy+=10; if (!NAM) { Bsprintf(tempbuf,"%0*d:%02d",clockpad, - (map[ud.volume_number*MAXLEVELS+ud.last_level-1].designertime/(26*60)), - (map[ud.volume_number*MAXLEVELS+ud.last_level-1].designertime/26)%60); + (MapInfo[ud.volume_number*MAXLEVELS+ud.last_level-1].designertime/(26*60)), + (MapInfo[ud.volume_number*MAXLEVELS+ud.last_level-1].designertime/26)%60); gametext((320>>2)+71,yy+9,tempbuf,0,2+8+16); yy+=10; } @@ -13495,7 +13451,7 @@ FRAGBONUS: if (bonuscnt == 2) { bonuscnt++; - sound(FLY_BY); + S_PlaySound(FLY_BY); } yy = zz; @@ -13505,7 +13461,7 @@ FRAGBONUS: if (bonuscnt == 3) { bonuscnt++; - sound(PIPEBOMB_EXPLODE); + S_PlaySound(PIPEBOMB_EXPLODE); } sprintf(tempbuf,"%-3d",g_player[myconnectindex].ps->actors_killed); gametext((320>>2)+70,yy+9,tempbuf,0,2+8+16); @@ -13542,7 +13498,7 @@ FRAGBONUS: if (bonuscnt == 5) { bonuscnt++; - sound(PIPEBOMB_EXPLODE); + S_PlaySound(PIPEBOMB_EXPLODE); } sprintf(tempbuf,"%-3d",g_player[myconnectindex].ps->secret_rooms); gametext((320>>2)+70,yy+9,tempbuf,0,2+8+16); @@ -13571,12 +13527,12 @@ FRAGBONUS: } } else break; - OnEvent(EVENT_DISPLAYBONUSSCREEN, g_player[screenpeek].ps->i, screenpeek, -1); + X_OnEvent(EVENT_DISPLAYBONUSSCREEN, g_player[screenpeek].ps->i, screenpeek, -1); nextpage(); } } -static void cameratext(short i) +static void G_DrawCameraText(short i) { char flipbits; int x , y; @@ -13610,11 +13566,11 @@ void vglass(int x,int y,short a,short wn,short n) zincs = (sector[sect].floorz-sector[sect].ceilingz) / n; for (z = sector[sect].ceilingz;z < sector[sect].floorz; z += zincs) - EGS(sect,x,y,z-(TRAND&8191),GLASSPIECES+(z&(TRAND%3)),-32,36,36,a+128-(TRAND&255),16+(TRAND&31),0,-1,5); + A_InsertSprite(sect,x,y,z-(krand()&8191),GLASSPIECES+(z&(krand()%3)),-32,36,36,a+128-(krand()&255),16+(krand()&31),0,-1,5); } #endif -void lotsofglass(int i,int wallnum,int n) +void A_SpawnWallGlass(int i,int wallnum,int n) { int j, xv, yv, z, x1, y1; short sect; @@ -13626,8 +13582,8 @@ void lotsofglass(int i,int wallnum,int n) { for (j=n-1; j >= 0 ;j--) { - a = SA-256+(TRAND&511)+1024; - EGS(SECT,SX,SY,SZ,GLASSPIECES+(j%3),-32,36,36,a,32+(TRAND&63),1024-(TRAND&1023),i,5); + a = SA-256+(krand()&511)+1024; + A_InsertSprite(SECT,SX,SY,SZ,GLASSPIECES+(j%3),-32,36,36,a,32+(krand()&63),1024-(krand()&1023),i,5); } return; } @@ -13654,29 +13610,29 @@ void lotsofglass(int i,int wallnum,int n) updatesector(x1,y1,§); if (sect >= 0) { - z = sector[sect].floorz-(TRAND&(klabs(sector[sect].ceilingz-sector[sect].floorz))); + z = sector[sect].floorz-(krand()&(klabs(sector[sect].ceilingz-sector[sect].floorz))); if (z < -(32<<8) || z > (32<<8)) - z = SZ-(32<<8)+(TRAND&((64<<8)-1)); + z = SZ-(32<<8)+(krand()&((64<<8)-1)); a = SA-1024; - EGS(SECT,x1,y1,z,GLASSPIECES+(j%3),-32,36,36,a,32+(TRAND&63),-(TRAND&1023),i,5); + A_InsertSprite(SECT,x1,y1,z,GLASSPIECES+(j%3),-32,36,36,a,32+(krand()&63),-(krand()&1023),i,5); } } } -void spriteglass(int i,int n) +void A_SpawnGlass(int i,int n) { int j, k, a, z; for (j=n;j>0;j--) { - a = TRAND&2047; - z = SZ-((TRAND&16)<<8); - k = EGS(SECT,SX,SY,z,GLASSPIECES+(j%3),TRAND&15,36,36,a,32+(TRAND&63),-512-(TRAND&2047),i,5); + a = krand()&2047; + z = SZ-((krand()&16)<<8); + k = A_InsertSprite(SECT,SX,SY,z,GLASSPIECES+(j%3),krand()&15,36,36,a,32+(krand()&63),-512-(krand()&2047),i,5); sprite[k].pal = sprite[i].pal; } } -void ceilingglass(int i,int sectnum,int n) +void A_SpawnCeilingGlass(int i,int sectnum,int n) { int j, xv, yv, z, x1, y1, a,s; int startwall = sector[sectnum].wallptr; @@ -13694,14 +13650,14 @@ void ceilingglass(int i,int sectnum,int n) { x1 += xv; y1 += yv; - a = TRAND&2047; - z = sector[sectnum].ceilingz+((TRAND&15)<<8); - EGS(sectnum,x1,y1,z,GLASSPIECES+(j%3),-32,36,36,a,(TRAND&31),0,i,5); + a = krand()&2047; + z = sector[sectnum].ceilingz+((krand()&15)<<8); + A_InsertSprite(sectnum,x1,y1,z,GLASSPIECES+(j%3),-32,36,36,a,(krand()&31),0,i,5); } } } -void lotsofcolourglass(int i,int wallnum,int n) +void A_SpawnRandomGlass(int i,int wallnum,int n) { int j, xv, yv, z, x1, y1; short sect = -1; @@ -13711,9 +13667,9 @@ void lotsofcolourglass(int i,int wallnum,int n) { for (j=n-1; j >= 0 ;j--) { - a = TRAND&2047; - k = EGS(SECT,SX,SY,SZ-(TRAND&(63<<8)),GLASSPIECES+(j%3),-32,36,36,a,32+(TRAND&63),1024-(TRAND&2047),i,5); - sprite[k].pal = TRAND&15; + a = krand()&2047; + k = A_InsertSprite(SECT,SX,SY,SZ-(krand()&(63<<8)),GLASSPIECES+(j%3),-32,36,36,a,32+(krand()&63),1024-(krand()&2047),i,5); + sprite[k].pal = krand()&15; } return; } @@ -13731,16 +13687,16 @@ void lotsofcolourglass(int i,int wallnum,int n) y1 += yv; updatesector(x1,y1,§); - z = sector[sect].floorz-(TRAND&(klabs(sector[sect].ceilingz-sector[sect].floorz))); + z = sector[sect].floorz-(krand()&(klabs(sector[sect].ceilingz-sector[sect].floorz))); if (z < -(32<<8) || z > (32<<8)) - z = SZ-(32<<8)+(TRAND&((64<<8)-1)); + z = SZ-(32<<8)+(krand()&((64<<8)-1)); a = SA-1024; - k = EGS(SECT,x1,y1,z,GLASSPIECES+(j%3),-32,36,36,a,32+(TRAND&63),-(TRAND&2047),i,5); - sprite[k].pal = TRAND&7; + k = A_InsertSprite(SECT,x1,y1,z,GLASSPIECES+(j%3),-32,36,36,a,32+(krand()&63),-(krand()&2047),i,5); + sprite[k].pal = krand()&7; } } -static void SetupGameButtons(void) +static void G_SetupGameButtons(void) { CONTROL_DefineFlag(gamefunc_Move_Forward,false); CONTROL_DefineFlag(gamefunc_Move_Backward,false); diff --git a/polymer/eduke32/source/gamedef.c b/polymer/eduke32/source/gamedef.c index ed5cd4a42..9ea9b7dec 100644 --- a/polymer/eduke32/source/gamedef.c +++ b/polymer/eduke32/source/gamedef.c @@ -27,25 +27,27 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "osd.h" -int g_ScriptVersion = 13; // 13 = 1.3D-style CON files, 14 = 1.4/1.5 style CON files +intptr_t *g_scriptPtr; -char compilefile[BMAX_PATH] = "(none)"; // file we're currently compiling -static char parsing_item_name[MAXVARLABEL] = "(none)", previous_item_name[MAXVARLABEL] = "NULL"; +int g_scriptVersion = 13; // 13 = 1.3D-style CON files, 14 = 1.4/1.5 style CON files -int total_lines,line_number; -static int checking_ifelse,parsing_state; +char g_szScriptFileName[BMAX_PATH] = "(none)"; // file we're currently compiling +static char g_szCurrentBlockName[MAXVARLABEL] = "(none)", g_szLastBlockName[MAXVARLABEL] = "NULL"; + +int g_totalLines,g_lineNumber; +static int g_checkingIfElse,g_processingState; char g_szBuf[1024]; -intptr_t *casescriptptr=NULL; // the pointer to the start of the case table in a switch statement +intptr_t *g_caseScriptPtr=NULL; // the pointer to the start of the case table in a switch statement // first entry is 'default' code. -static int casecount = 0; -static int checking_switch = 0, current_event = -1; -static int labelsonly = 0, nokeywordcheck = 0, dynamicremap = 0; -static int num_braces = 0; +static int g_numCases = 0; +static int g_checkingSwitch = 0, g_currentEvent = -1; +static int g_labelsOnly = 0, g_skipKeywordCheck = 0, g_dynamicTileMapping = 0; +static int g_numBraces = 0; -static int increasescriptsize(int size); +static int C_IncreaseScriptSize(int size); -int redefined_quote_count = 0; +int g_numQuoteRedefinitions = 0; intptr_t *aplWeaponClip[MAX_WEAPONS]; // number of items in magazine intptr_t *aplWeaponReload[MAX_WEAPONS]; // delay to reload (include fire) @@ -64,6 +66,7 @@ intptr_t *aplWeaponSound2Time[MAX_WEAPONS]; // Alternate sound time intptr_t *aplWeaponSound2Sound[MAX_WEAPONS]; // Alternate sound sound ID intptr_t *aplWeaponReloadSound1[MAX_WEAPONS]; // Sound of magazine being removed intptr_t *aplWeaponReloadSound2[MAX_WEAPONS]; // Sound of magazine being inserted +intptr_t *aplWeaponSelectSound[MAX_WEAPONS]; // Sound of weapon being selected int g_iReturnVarID=-1; // var ID of "RETURN" int g_iWeaponVarID=-1; // var ID of "WEAPON" @@ -79,22 +82,22 @@ int g_iThisActorID=-1; // var ID of "THISACTOR" intptr_t *actorLoadEventScrptr[MAXTILES]; intptr_t *apScriptGameEvent[MAXGAMEEVENTS]; -intptr_t *parsing_event=NULL; +intptr_t *g_parsingEventPtr=NULL; gamevar_t aGameVars[MAXGAMEVARS]; gamearray_t aGameArrays[MAXGAMEARRAYS]; -int iGameVarCount=0; -int iGameArrayCount=0; +int g_gameVarCount=0; +int g_gameArrayCount=0; extern int qsetmode; char *textptr; -int error,warning; +int g_numCompilerErrors,g_numCompilerWarnings; extern char *duke3dgrpstring; extern char *duke3ddef; -enum labeltypes +enum ScriptLabel_t { LABEL_ANY = -1, LABEL_DEFINE = 1, @@ -105,7 +108,7 @@ enum labeltypes LABEL_MOVE = 32, }; -static const char *labeltypenames[] = +static const char *LabelTypeText[] = { "define", "state", @@ -115,7 +118,7 @@ static const char *labeltypenames[] = "move" }; -static const char *translatelabeltype(int type) +static const char *C_GetLabelType(int type) { int i; char x[64]; @@ -125,7 +128,7 @@ static const char *translatelabeltype(int type) { if (!(type & (1<", 1, 0, 0 }, { "god", USERDEFS_GOD, 0, 0 }, @@ -919,7 +922,7 @@ const memberlabel_t userdefslabels[]= { "", -1, 0, 0 } // END OF LIST }; -const memberlabel_t inputlabels[]= +const memberlabel_t InputLabels[]= { { "avel", INPUT_AVEL, 0, 0 }, { "horz", INPUT_HORZ, 0, 0 }, @@ -933,26 +936,6 @@ const memberlabel_t inputlabels[]= char *bitptr; // pointer to bitmap of which bytecode positions contain pointers #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); -*/ - struct HASH_table gamevarH = { MAXGAMEVARS, NULL }; struct HASH_table arrayH = { MAXGAMEARRAYS, NULL }; struct HASH_table labelH = { 11264, NULL }; @@ -985,30 +968,30 @@ void inithash() HASH_add(&keywH,keyw[i],i); HASH_init(§orH); - for (i=0;sectorlabels[i].lId >=0 ; i++) - HASH_add(§orH,sectorlabels[i].name,i); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + for (i=0;TsprLabels[i].lId >=0 ; i++) + HASH_add(&tspriteH,TsprLabels[i].name,i); } void freehash() @@ -1018,16 +1001,16 @@ void freehash() HASH_free(&labelH); } -static int increasescriptsize(int size) +static int C_IncreaseScriptSize(int size) { - intptr_t oscriptptr = (unsigned)(scriptptr-script); - intptr_t ocasescriptptr = (unsigned)(casescriptptr-script); - intptr_t oparsing_event = (unsigned)(parsing_event-script); - intptr_t oparsing_actor = (unsigned)(parsing_actor-script); + intptr_t oscriptPtr = (unsigned)(g_scriptPtr-script); + intptr_t ocaseScriptPtr = (unsigned)(g_caseScriptPtr-script); + intptr_t oparsingEventPtr = (unsigned)(g_parsingEventPtr-script); + intptr_t oparsingActorPtr = (unsigned)(g_parsingActorPtr-script); char *scriptptrs; intptr_t *newscript; intptr_t i, j; - int osize = g_ScriptSize; + int osize = g_scriptSize; char *newbitptr; for (i=MAXSECTORS-1;i>=0;i--) @@ -1038,18 +1021,18 @@ static int increasescriptsize(int size) } } - scriptptrs = Bcalloc(1,g_ScriptSize * sizeof(char)); - for (i=g_ScriptSize-1;i>=0;i--) + scriptptrs = Bcalloc(1,g_scriptSize * sizeof(char)); + for (i=g_scriptSize-1;i>=0;i--) { // initprintf("%d\n",i); - if (bitptr[i>>3]&(BITPTR_POINTER<<(i&7)) && !((intptr_t)script[i] >= (intptr_t)(&script[0]) && (intptr_t)script[i] < (intptr_t)(&script[g_ScriptSize]))) + if (bitptr[i>>3]&(BITPTR_POINTER<<(i&7)) && !((intptr_t)script[i] >= (intptr_t)(&script[0]) && (intptr_t)script[i] < (intptr_t)(&script[g_scriptSize]))) { - error++; + g_numCompilerErrors++; initprintf("Internal compiler error at %d (0x%x)\n",i,i); } -// if (bitptr[i] == 0 && ((intptr_t)script[i] >= (intptr_t)(&script[0]) && (intptr_t)script[i] < (intptr_t)(&script[g_ScriptSize]))) +// if (bitptr[i] == 0 && ((intptr_t)script[i] >= (intptr_t)(&script[0]) && (intptr_t)script[i] < (intptr_t)(&script[g_scriptSize]))) // initprintf("oh no!\n"); - if (bitptr[i>>3]&(BITPTR_POINTER<<(i&7)) /*&& ((intptr_t)script[i] >= (intptr_t)(&script[0]) && (intptr_t)script[i] < (intptr_t)(&script[g_ScriptSize]))*/) + if (bitptr[i>>3]&(BITPTR_POINTER<<(i&7)) /*&& ((intptr_t)script[i] >= (intptr_t)(&script[0]) && (intptr_t)script[i] < (intptr_t)(&script[g_scriptSize]))*/) { scriptptrs[i] = 1; script[i] -= (intptr_t)&script[0]; @@ -1078,29 +1061,29 @@ static int increasescriptsize(int size) apScriptGameEvent[i] = (intptr_t *)j; } - //initprintf("offset: %d\n",(unsigned)(scriptptr-script)); + //initprintf("offset: %d\n",(unsigned)(g_scriptPtr-script)); if (size <= osize) { - g_ScriptSize = size; - initprintf("Shrinking bytecode buffer, final size: %d*%d bytes\n",g_ScriptSize, sizeof(intptr_t)); + g_scriptSize = size; + initprintf("Shrinking bytecode buffer, final size: %d*%d bytes\n",g_scriptSize, sizeof(intptr_t)); } else { - g_ScriptSize = size; - initprintf("Increasing bytecode buffer size to %d*%d bytes...\n",g_ScriptSize, sizeof(intptr_t)); + g_scriptSize = size; + initprintf("Increasing bytecode buffer size to %d*%d bytes...\n",g_scriptSize, sizeof(intptr_t)); } - newscript = (intptr_t *)Brealloc(script, g_ScriptSize * sizeof(intptr_t)); + newscript = (intptr_t *)Brealloc(script, g_scriptSize * sizeof(intptr_t)); -// bitptr = (char *)Brealloc(bitptr, g_ScriptSize * sizeof(char)); +// bitptr = (char *)Brealloc(bitptr, g_scriptSize * sizeof(char)); newbitptr = Bcalloc(1,(((size+7)>>3)+1) * sizeof(char)); if (newscript == NULL || newbitptr == NULL) { - ReportError(-1); - initprintf("%s:%d: out of memory: Aborted (%ud)\n",compilefile,line_number,(unsigned)(scriptptr-script)); + C_ReportError(-1); + initprintf("%s:%d: out of memory: Aborted (%ud)\n",g_szScriptFileName,g_lineNumber,(unsigned)(g_scriptPtr-script)); initprintf(tempbuf); - error++; + g_numCompilerErrors++; return 1; } @@ -1116,16 +1099,16 @@ static int increasescriptsize(int size) Bfree(bitptr); bitptr = newbitptr; script = newscript; - scriptptr = (intptr_t *)(script+oscriptptr); + g_scriptPtr = (intptr_t *)(script+oscriptPtr); // initprintf("script: %d, bitptr: %d\n",script,bitptr); - //initprintf("offset: %d\n",(unsigned)(scriptptr-script)); - if (casescriptptr != NULL) - casescriptptr = (intptr_t *)(script+ocasescriptptr); - if (parsing_event != NULL) - parsing_event = (intptr_t *)(script+oparsing_event); - if (parsing_actor != NULL) - parsing_actor = (intptr_t *)(script+oparsing_actor); + //initprintf("offset: %d\n",(unsigned)(g_scriptPtr-script)); + if (g_caseScriptPtr != NULL) + g_caseScriptPtr = (intptr_t *)(script+ocaseScriptPtr); + if (g_parsingEventPtr != NULL) + g_parsingEventPtr = (intptr_t *)(script+oparsingEventPtr); + if (g_parsingActorPtr != NULL) + g_parsingActorPtr = (intptr_t *)(script+oparsingActorPtr); for (i=MAXSECTORS-1;i>=0;i--) { @@ -1137,7 +1120,7 @@ static int increasescriptsize(int size) if (size > osize) { - for (i=g_ScriptSize-(size-osize)-1;i>=0;i--) + for (i=g_scriptSize-(size-osize)-1;i>=0;i--) if (scriptptrs[i]) { j = (intptr_t)script[i]+(intptr_t)&script[0]; @@ -1146,7 +1129,7 @@ static int increasescriptsize(int size) } else { - for (i=g_ScriptSize-1;i>=0;i--) + for (i=g_scriptSize-1;i>=0;i--) if (scriptptrs[i]) { j = (intptr_t)script[i]+(intptr_t)&script[0]; @@ -1178,7 +1161,7 @@ static int increasescriptsize(int size) return 0; } -static int skipcomments(void) +static int C_SkipComments(void) { char c = *textptr; @@ -1188,37 +1171,37 @@ static int skipcomments(void) textptr++; else if (c == '\n') { - line_number++; + g_lineNumber++; textptr++; } else if (c == '/' && textptr[1] == '/') { - if (!(error || warning) && g_ScriptDebug > 1) - initprintf("%s:%d: debug: got comment.\n",compilefile,line_number); + if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug > 1) + initprintf("%s:%d: debug: got comment.\n",g_szScriptFileName,g_lineNumber); while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) textptr++; } else if (c == '/' && textptr[1] == '*') { - if (!(error || warning) && g_ScriptDebug > 1) - initprintf("%s:%d: debug: got start of comment block.\n",compilefile,line_number); + if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug > 1) + initprintf("%s:%d: debug: got start of comment block.\n",g_szScriptFileName,g_lineNumber); while (*textptr && !(textptr[0] == '*' && textptr[1] == '/')) { if (*textptr == '\n') - line_number++; + g_lineNumber++; textptr++; } - if ((!(error || warning) && g_ScriptDebug > 1) && (textptr[0] == '*' && textptr[1] == '/')) - initprintf("%s:%d: debug: got end of comment block.\n",compilefile,line_number); + if ((!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug > 1) && (textptr[0] == '*' && textptr[1] == '/')) + initprintf("%s:%d: debug: got end of comment block.\n",g_szScriptFileName,g_lineNumber); if (!*textptr) { - if (!(error || warning) && g_ScriptDebug) - initprintf("%s:%d: debug: EOF in comment!\n",compilefile,line_number); - ReportError(-1); - initprintf("%s:%d: error: found `/*' with no `*/'.\n",compilefile,line_number); - parsing_state = num_braces = 0; - parsing_actor = 0; - error++; + if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug) + initprintf("%s:%d: debug: EOF in comment!\n",g_szScriptFileName,g_lineNumber); + C_ReportError(-1); + initprintf("%s:%d: error: found `/*' with no `*/'.\n",g_szScriptFileName,g_lineNumber); + g_processingState = g_numBraces = 0; + g_parsingActorPtr = 0; + g_numCompilerErrors++; break; } else textptr+=2; @@ -1227,141 +1210,141 @@ static int skipcomments(void) } while ((c = *textptr)); - if ((unsigned)(scriptptr-script) > (unsigned)(g_ScriptSize-32)) - return increasescriptsize(g_ScriptSize<<1); + if ((unsigned)(g_scriptPtr-script) > (unsigned)(g_scriptSize-32)) + return C_IncreaseScriptSize(g_scriptSize<<1); return 0; } -static void DefineProjectile(int lVar1, int lLabelID, int lVar2) +static void C_SetProjectile(int lVar1, int lLabelID, int lVar2) { switch (lLabelID) { case PROJ_WORKSLIKE: - projectile[lVar1].workslike=lVar2; + ProjectileData[lVar1].workslike=lVar2; break; case PROJ_SPAWNS: - projectile[lVar1].spawns=lVar2; + ProjectileData[lVar1].spawns=lVar2; break; case PROJ_SXREPEAT: - projectile[lVar1].sxrepeat=lVar2; + ProjectileData[lVar1].sxrepeat=lVar2; break; case PROJ_SYREPEAT: - projectile[lVar1].syrepeat=lVar2; + ProjectileData[lVar1].syrepeat=lVar2; break; case PROJ_SOUND: - projectile[lVar1].sound=lVar2; + ProjectileData[lVar1].sound=lVar2; break; case PROJ_ISOUND: - projectile[lVar1].isound=lVar2; + ProjectileData[lVar1].isound=lVar2; break; case PROJ_VEL: - projectile[lVar1].vel=lVar2; + ProjectileData[lVar1].vel=lVar2; break; case PROJ_EXTRA: - projectile[lVar1].extra=lVar2; + ProjectileData[lVar1].extra=lVar2; break; case PROJ_DECAL: - projectile[lVar1].decal=lVar2; + ProjectileData[lVar1].decal=lVar2; break; case PROJ_TRAIL: - projectile[lVar1].trail=lVar2; + ProjectileData[lVar1].trail=lVar2; break; case PROJ_TXREPEAT: - projectile[lVar1].txrepeat=lVar2; + ProjectileData[lVar1].txrepeat=lVar2; break; case PROJ_TYREPEAT: - projectile[lVar1].tyrepeat=lVar2; + ProjectileData[lVar1].tyrepeat=lVar2; break; case PROJ_TOFFSET: - projectile[lVar1].toffset=lVar2; + ProjectileData[lVar1].toffset=lVar2; break; case PROJ_TNUM: - projectile[lVar1].tnum=lVar2; + ProjectileData[lVar1].tnum=lVar2; break; case PROJ_DROP: - projectile[lVar1].drop=lVar2; + ProjectileData[lVar1].drop=lVar2; break; case PROJ_CSTAT: - projectile[lVar1].cstat=lVar2; + ProjectileData[lVar1].cstat=lVar2; break; case PROJ_CLIPDIST: - projectile[lVar1].clipdist=lVar2; + ProjectileData[lVar1].clipdist=lVar2; break; case PROJ_SHADE: - projectile[lVar1].shade=lVar2; + ProjectileData[lVar1].shade=lVar2; break; case PROJ_XREPEAT: - projectile[lVar1].xrepeat=lVar2; + ProjectileData[lVar1].xrepeat=lVar2; break; case PROJ_YREPEAT: - projectile[lVar1].yrepeat=lVar2; + ProjectileData[lVar1].yrepeat=lVar2; break; case PROJ_PAL: - projectile[lVar1].pal=lVar2; + ProjectileData[lVar1].pal=lVar2; break; case PROJ_EXTRA_RAND: - projectile[lVar1].extra_rand=lVar2; + ProjectileData[lVar1].extra_rand=lVar2; break; case PROJ_HITRADIUS: - projectile[lVar1].hitradius=lVar2; + ProjectileData[lVar1].hitradius=lVar2; break; case PROJ_VEL_MULT: - projectile[lVar1].velmult=lVar2; + ProjectileData[lVar1].velmult=lVar2; break; case PROJ_OFFSET: - projectile[lVar1].offset=lVar2; + ProjectileData[lVar1].offset=lVar2; break; case PROJ_BOUNCES: - projectile[lVar1].bounces=lVar2; + ProjectileData[lVar1].bounces=lVar2; break; case PROJ_BSOUND: - projectile[lVar1].bsound=lVar2; + ProjectileData[lVar1].bsound=lVar2; break; case PROJ_RANGE: - projectile[lVar1].range=lVar2; + ProjectileData[lVar1].range=lVar2; break; default: break; } - // defaultprojectile[lVar1] = projectile[lVar1]; - Bmemcpy(&defaultprojectile[lVar1], &projectile[lVar1], sizeof(projectile[lVar1])); + // DefaultProjectileData[lVar1] = ProjectileData[lVar1]; + Bmemcpy(&DefaultProjectileData[lVar1], &ProjectileData[lVar1], sizeof(ProjectileData[lVar1])); return; } -static int CheckEventSync(int iEventID) +static int C_CheckEventSync(int iEventID) { - if (parsing_event || parsing_actor) + if (g_parsingEventPtr || g_parsingActorPtr) { switch (iEventID) { @@ -1426,7 +1409,7 @@ static int ispecial(char c) { if (c == 0x0a) { - line_number++; + g_lineNumber++; return 1; } @@ -1455,7 +1438,7 @@ static char *strtolower(char *str, int len) return str; } -inline static int getlabelid(const memberlabel_t *pLabel, struct HASH_table *tH, const char *psz) +inline static int GetLabelNameid(const memberlabel_t *pLabel, struct HASH_table *tH, const char *psz) { // find the label psz in the table pLabel. // returns the ID for the label, or -1 @@ -1468,7 +1451,7 @@ inline static int getlabelid(const memberlabel_t *pLabel, struct HASH_table *tH, return l; } -inline static int getlabeloffset(struct HASH_table *tH, const char *psz) +inline static int C_GetLabelNameOffset(struct HASH_table *tH, const char *psz) { // find the label psz in the table pLabel. // returns the offset in the array for the label, or -1 @@ -1476,15 +1459,15 @@ inline static int getlabeloffset(struct HASH_table *tH, const char *psz) return HASH_findcase(tH,psz); } -static void getlabel(void) +static void C_GetNextLabelName(void) { int i; - skipcomments(); + C_SkipComments(); while (isalnum(*textptr) == 0) { - if (*textptr == 0x0a) line_number++; + if (*textptr == 0x0a) g_lineNumber++; textptr++; if (*textptr == 0) return; @@ -1492,19 +1475,19 @@ static void getlabel(void) i = 0; while (ispecial(*textptr) == 0 && *textptr!='['&& *textptr!=']' && *textptr!='\t' && *textptr!='\n' && *textptr!='\r') - label[(labelcnt<<6)+(i++)] = *(textptr++); + label[(g_numLabels<<6)+(i++)] = *(textptr++); - label[(labelcnt<<6)+i] = 0; - if (!(error || warning) && g_ScriptDebug > 1) - initprintf("%s:%d: debug: got label `%s'.\n",compilefile,line_number,label+(labelcnt<<6)); + label[(g_numLabels<<6)+i] = 0; + if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug > 1) + initprintf("%s:%d: debug: got label `%s'.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); } -static int keyword(void) +static int C_GetKeyword(void) { int i; char *temptextptr; - skipcomments(); + C_SkipComments(); temptextptr = textptr; @@ -1522,15 +1505,15 @@ static int keyword(void) return HASH_find(&keywH,tempbuf); } -static int transword(void) //Returns its code # +static int C_GetNextKeyword(void) //Returns its code # { int i, l; - skipcomments(); + C_SkipComments(); while (isaltok(*textptr) == 0) { - if (*textptr == 0x0a) line_number++; + if (*textptr == 0x0a) g_lineNumber++; if (*textptr == 0) return -1; textptr++; @@ -1552,12 +1535,12 @@ static int transword(void) //Returns its code # i = HASH_find(&keywH,tempbuf); if (i>=0) { - *scriptptr = i + (line_number<<12); - bitptr[(scriptptr-script)>>3] &= ~(1<<((scriptptr-script)&7)); + *g_scriptPtr = i + (g_lineNumber<<12); + bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); textptr += l; - scriptptr++; - if (!(error || warning) && g_ScriptDebug) - initprintf("%s:%d: debug: translating keyword `%s'.\n",compilefile,line_number,keyw[i]); + g_scriptPtr++; + if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug) + initprintf("%s:%d: debug: translating keyword `%s'.\n",g_szScriptFileName,g_lineNumber,keyw[i]); return i; } @@ -1565,181 +1548,181 @@ static int transword(void) //Returns its code # if (tempbuf[0] == '{' && tempbuf[1] != 0) { - ReportError(-1); - initprintf("%s:%d: error: expected a SPACE or CR between `{' and `%s'.\n",compilefile,line_number,tempbuf+1); + C_ReportError(-1); + initprintf("%s:%d: error: expected a SPACE or CR between `{' and `%s'.\n",g_szScriptFileName,g_lineNumber,tempbuf+1); } else if (tempbuf[0] == '}' && tempbuf[1] != 0) { - ReportError(-1); - initprintf("%s:%d: error: expected a SPACE or CR between `}' and `%s'.\n",compilefile,line_number,tempbuf+1); + C_ReportError(-1); + initprintf("%s:%d: error: expected a SPACE or CR between `}' and `%s'.\n",g_szScriptFileName,g_lineNumber,tempbuf+1); } - else ReportError(ERROR_EXPECTEDKEYWORD); - error++; + else C_ReportError(ERROR_EXPECTEDKEYWORD); + g_numCompilerErrors++; return -1; } -static void transvartype(int type) +static void C_GetNextVarType(int type) { int i=0,f=0; - skipcomments(); - if (!type && !labelsonly && (isdigit(*textptr) || ((*textptr == '-') && (isdigit(*(textptr+1)))))) + C_SkipComments(); + if (!type && !g_labelsOnly && (isdigit(*textptr) || ((*textptr == '-') && (isdigit(*(textptr+1)))))) { - if (!(error || warning) && g_ScriptDebug) - initprintf("%s:%d: debug: accepted constant %d in place of gamevar.\n",compilefile,line_number,atol(textptr)); - bitptr[(scriptptr-script)>>3] &= ~(1<<((scriptptr-script)&7)); - *scriptptr++=MAXGAMEVARS; + if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug) + initprintf("%s:%d: debug: accepted constant %d in place of gamevar.\n",g_szScriptFileName,g_lineNumber,atol(textptr)); + bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); + *g_scriptPtr++=MAXGAMEVARS; if (tolower(textptr[1])=='x') - sscanf(textptr+2,"%" PRIxPTR "",scriptptr); + sscanf(textptr+2,"%" PRIxPTR "",g_scriptPtr); else - *scriptptr=atol(textptr); - bitptr[(scriptptr-script)>>3] &= ~(1<<((scriptptr-script)&7)); - scriptptr++; - getlabel(); + *g_scriptPtr=atol(textptr); + bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); + g_scriptPtr++; + C_GetNextLabelName(); return; } else if ((*textptr == '-')/* && !isdigit(*(textptr+1))*/) { if (!type) { - if (!(error || warning) && g_ScriptDebug) - initprintf("%s:%d: debug: flagging gamevar as negative.\n",compilefile,line_number,atol(textptr)); + if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug) + initprintf("%s:%d: debug: flagging gamevar as negative.\n",g_szScriptFileName,g_lineNumber,atol(textptr)); f = (MAXGAMEVARS<<1); } else { - error++; - ReportError(ERROR_SYNTAXERROR); - getlabel(); + g_numCompilerErrors++; + C_ReportError(ERROR_SYNTAXERROR); + C_GetNextLabelName(); return; } } - getlabel(); + C_GetNextLabelName(); - if (!nokeywordcheck && HASH_find(&keywH,label+(labelcnt<<6))>=0) + if (!g_skipKeywordCheck && HASH_find(&keywH,label+(g_numLabels<<6))>=0) { - error++; - ReportError(ERROR_ISAKEYWORD); + g_numCompilerErrors++; + C_ReportError(ERROR_ISAKEYWORD); return; } - skipcomments(); //skip comments and whitespace + C_SkipComments(); //skip comments and whitespace if ((*textptr == '[')) //read of array as a gamevar { f |= (MAXGAMEVARS<<2); // initprintf("got an array"); textptr++; - i=GetADefID(label+(labelcnt<<6)); + i=GetADefID(label+(g_numLabels<<6)); if (i < 0) { - error++; - ReportError(ERROR_NOTAGAMEARRAY); + g_numCompilerErrors++; + C_ReportError(ERROR_NOTAGAMEARRAY); return; } - bitptr[(scriptptr-script)>>3] &= ~(1<<((scriptptr-script)&7)); - *scriptptr++=(i|f); - transvartype(0); - skipcomments(); //skip comments and whitespace + bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); + *g_scriptPtr++=(i|f); + C_GetNextVarType(0); + C_SkipComments(); //skip comments and whitespace if (*textptr != ']') { - error++; - ReportError(ERROR_GAMEARRAYBNC); + g_numCompilerErrors++; + C_ReportError(ERROR_GAMEARRAYBNC); return; } textptr++; if (type) //writing arrays in this way is not supported because it would require too many changes to other code { - error++; - ReportError(ERROR_INVALIDARRAYWRITE); + g_numCompilerErrors++; + C_ReportError(ERROR_INVALIDARRAYWRITE); return; } return; } // initprintf("not an array"); - i=GetDefID(label+(labelcnt<<6)); + i=GetDefID(label+(g_numLabels<<6)); if (i<0) //gamevar not found { - if (!type && !labelsonly) + if (!type && !g_labelsOnly) { //try looking for a define instead - Bstrcpy(tempbuf,label+(labelcnt<<6)); + Bstrcpy(tempbuf,label+(g_numLabels<<6)); i = HASH_find(&labelH,tempbuf); if (i>=0) { if (labeltype[i] & LABEL_DEFINE) { - if (!(error || warning) && g_ScriptDebug) - initprintf("%s:%d: debug: accepted defined label `%s' instead of gamevar.\n",compilefile,line_number,label+(i<<6)); - bitptr[(scriptptr-script)>>3] &= ~(1<<((scriptptr-script)&7)); - *scriptptr++=MAXGAMEVARS; - bitptr[(scriptptr-script)>>3] &= ~(1<<((scriptptr-script)&7)); - *scriptptr++=labelcode[i]; + if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug) + initprintf("%s:%d: debug: accepted defined label `%s' instead of gamevar.\n",g_szScriptFileName,g_lineNumber,label+(i<<6)); + bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); + *g_scriptPtr++=MAXGAMEVARS; + bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); + *g_scriptPtr++=labelcode[i]; return; } } - error++; - ReportError(ERROR_NOTAGAMEVAR); + g_numCompilerErrors++; + C_ReportError(ERROR_NOTAGAMEVAR); return; } - error++; - ReportError(ERROR_NOTAGAMEVAR); + g_numCompilerErrors++; + C_ReportError(ERROR_NOTAGAMEVAR); textptr++; return; } - if (type == GAMEVAR_FLAG_READONLY && aGameVars[i].dwFlags & GAMEVAR_FLAG_READONLY) + if (type == GAMEVAR_READONLY && aGameVars[i].dwFlags & GAMEVAR_READONLY) { - error++; - ReportError(ERROR_VARREADONLY); + g_numCompilerErrors++; + C_ReportError(ERROR_VARREADONLY); return; } else if (aGameVars[i].dwFlags & type) { - error++; - ReportError(ERROR_VARTYPEMISMATCH); + g_numCompilerErrors++; + C_ReportError(ERROR_VARTYPEMISMATCH); return; } - if ((aGameVars[i].dwFlags & GAMEVAR_FLAG_SYNCCHECK) && parsing_actor && CheckEventSync(current_event)) + if ((aGameVars[i].dwFlags & GAMEVAR_SYNCCHECK) && g_parsingActorPtr && C_CheckEventSync(g_currentEvent)) { - ReportError(-1); - initprintf("%s:%d: warning: found local gamevar `%s' used within %s; expect multiplayer synchronization issues.\n",compilefile,line_number,label+(labelcnt<<6),parsing_event?"a synced event":"an actor"); - warning++; + C_ReportError(-1); + initprintf("%s:%d: warning: found local gamevar `%s' used within %s; expect multiplayer synchronization issues.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6),g_parsingEventPtr?"a synced event":"an actor"); + g_numCompilerWarnings++; } - if (!(error || warning) && g_ScriptDebug > 1) - initprintf("%s:%d: debug: accepted gamevar `%s'.\n",compilefile,line_number,label+(labelcnt<<6)); + if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug > 1) + initprintf("%s:%d: debug: accepted gamevar `%s'.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); - bitptr[(scriptptr-script)>>3] &= ~(1<<((scriptptr-script)&7)); - *scriptptr++=(i|f); + bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); + *g_scriptPtr++=(i|f); } -static inline void transvar(void) +static inline void C_GetNextVar(void) { - transvartype(0); + C_GetNextVarType(0); } -static inline void transmultvarstype(int type, int num) +static inline void C_GetManyVarsType(int type, int num) { int i; for (i=num-1;i>=0;i--) - transvartype(type); + C_GetNextVarType(type); } -static inline void transmultvars(int num) +static inline void C_GetManyVars(int num) { - transmultvarstype(0,num); + C_GetManyVarsType(0,num); } -static int transnum(int type) +static int C_GetNextValue(int type) { int i, l; - skipcomments(); + C_SkipComments(); while (isaltok(*textptr) == 0) { - if (*textptr == 0x0a) line_number++; + if (*textptr == 0x0a) g_lineNumber++; textptr++; if (*textptr == 0) return -1; // eof @@ -1753,10 +1736,10 @@ static int transnum(int type) } tempbuf[l] = 0; - if (!nokeywordcheck && HASH_find(&keywH,label+(labelcnt<<6))>=0) + if (!g_skipKeywordCheck && HASH_find(&keywH,label+(g_numLabels<<6))>=0) { - error++; - ReportError(ERROR_ISAKEYWORD); + g_numCompilerErrors++; + C_ReportError(ERROR_ISAKEYWORD); textptr+=l; } @@ -1767,27 +1750,27 @@ static int transnum(int type) if (labeltype[i] & type) { - if (!(error || warning) && g_ScriptDebug > 1) + if (!(g_numCompilerErrors || g_numCompilerWarnings) && 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 *)C_GetLabelType(labeltype[i]); + initprintf("%s:%d: debug: accepted %s label `%s'.\n",g_szScriptFileName,g_lineNumber,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)>>3] |= (BITPTR_POINTER<<((scriptptr-script)&7)); - else bitptr[(scriptptr-script)>>3] &= ~(1<<((scriptptr-script)&7)); - *(scriptptr++) = labelcode[i]; + if (labeltype[i] != LABEL_DEFINE && labelcode[i] >= (intptr_t)&script[0] && labelcode[i] < (intptr_t)&script[g_scriptSize]) + bitptr[(g_scriptPtr-script)>>3] |= (BITPTR_POINTER<<((g_scriptPtr-script)&7)); + else bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); + *(g_scriptPtr++) = labelcode[i]; textptr += l; return labeltype[i]; } - bitptr[(scriptptr-script)>>3] &= ~(1<<((scriptptr-script)&7)); - *(scriptptr++) = 0; + bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); + *(g_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); - warning++; + el = (char *)C_GetLabelType(type); + gl = (char *)C_GetLabelType(labeltype[i]); + C_ReportError(-1); + initprintf("%s:%d: warning: expected a %s, found a %s.\n",g_szScriptFileName,g_lineNumber,el,gl); + g_numCompilerWarnings++; Bfree(el); Bfree(gl); return -1; // valid label name, but wrong type @@ -1795,70 +1778,70 @@ static int transnum(int type) if (isdigit(*textptr) == 0 && *textptr != '-') { - ReportError(ERROR_PARAMUNDEFINED); - error++; - bitptr[(scriptptr-script)>>3] &= ~(1<<((scriptptr-script)&7)); - *scriptptr = 0; - scriptptr++; + C_ReportError(ERROR_PARAMUNDEFINED); + g_numCompilerErrors++; + bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); + *g_scriptPtr = 0; + g_scriptPtr++; textptr+=l; return -1; // error! } - if (isdigit(*textptr) && labelsonly) + if (isdigit(*textptr) && g_labelsOnly) { - ReportError(WARNING_LABELSONLY); - warning++; + C_ReportError(WARNING_LABELSONLY); + g_numCompilerWarnings++; } - if (!(error || warning) && g_ScriptDebug > 1) - initprintf("%s:%d: debug: accepted constant %d.\n",compilefile,line_number,atol(textptr)); - bitptr[(scriptptr-script)>>3] &= ~(1<<((scriptptr-script)&7)); - if (tolower(textptr[1])=='x')sscanf(textptr+2,"%" PRIxPTR "",scriptptr); + if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug > 1) + initprintf("%s:%d: debug: accepted constant %d.\n",g_szScriptFileName,g_lineNumber,atol(textptr)); + bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); + if (tolower(textptr[1])=='x')sscanf(textptr+2,"%" PRIxPTR "",g_scriptPtr); else - *scriptptr = atol(textptr); - scriptptr++; + *g_scriptPtr = atol(textptr); + g_scriptPtr++; textptr += l; return 0; // literal value } -static int parsecommand(void); +static int C_ParseCommand(void); -static int CountCaseStatements() +static int C_CountCaseStatements() { int lCount; char *temptextptr = textptr; - int temp_line_number = line_number; - intptr_t scriptoffset = (unsigned)(scriptptr-script); - intptr_t caseoffset = (unsigned)(casescriptptr-script); + int temp_ScriptLineNumber = g_lineNumber; + intptr_t scriptoffset = (unsigned)(g_scriptPtr-script); + intptr_t caseoffset = (unsigned)(g_caseScriptPtr-script); // int i; - casecount=0; - casescriptptr=NULL; + g_numCases=0; + g_caseScriptPtr=NULL; //Bsprintf(g_szBuf,"CSS: %.12s",textptr); //AddLog(g_szBuf); - while (parsecommand() == 0) + while (C_ParseCommand() == 0) { //Bsprintf(g_szBuf,"CSSL: %.20s",textptr); //AddLog(g_szBuf); ; } - // since we processed the endswitch, we need to re-increment checking_switch - checking_switch++; + // since we processed the endswitch, we need to re-increment g_checkingSwitch + g_checkingSwitch++; textptr=temptextptr; - scriptptr = (intptr_t *)(script+scriptoffset); + g_scriptPtr = (intptr_t *)(script+scriptoffset); - line_number = temp_line_number; + g_lineNumber = temp_ScriptLineNumber; - lCount=casecount; - casecount=0; - casescriptptr = (intptr_t *)(script+caseoffset); - casecount = 0; + lCount=g_numCases; + g_numCases=0; + g_caseScriptPtr = (intptr_t *)(script+caseoffset); + g_numCases = 0; return lCount; } -static int parsecommand(void) +static int C_ParseCommand(void) { int i, j=0, k=0, done, tw; char *temptextptr; @@ -1867,25 +1850,25 @@ static int parsecommand(void) if (quitevent) { initprintf("Aborted.\n"); - Shutdown(); + G_Shutdown(); exit(0); } - if (error > 63 || (*textptr == '\0') || (*(textptr+1) == '\0')) return 1; + if (g_numCompilerErrors > 63 || (*textptr == '\0') || (*(textptr+1) == '\0')) return 1; - if (g_ScriptDebug) - ReportError(-1); + if (g_scriptDebug) + C_ReportError(-1); - if (checking_switch > 0) + if (g_checkingSwitch > 0) { //Bsprintf(g_szBuf,"PC(): '%.25s'",textptr); //AddLog(g_szBuf); } - tw = transword(); + tw = C_GetNextKeyword(); // Bsprintf(tempbuf,"%s",keyw[tw]); // AddLog(tempbuf); - if (skipcomments()) + if (C_SkipComments()) return 1; switch (tw) @@ -1894,107 +1877,107 @@ static int parsecommand(void) case -1: return 0; //End case CON_STATE: - if (parsing_actor == 0 && parsing_state == 0) + if (g_parsingActorPtr == 0 && g_processingState == 0) { - getlabel(); - scriptptr--; - labelcode[labelcnt] = (intptr_t) scriptptr; - labeltype[labelcnt] = LABEL_STATE; + C_GetNextLabelName(); + g_scriptPtr--; + labelcode[g_numLabels] = (intptr_t) g_scriptPtr; + labeltype[g_numLabels] = LABEL_STATE; - parsing_state = 1; - Bsprintf(parsing_item_name,"%s",label+(labelcnt<<6)); - HASH_add(&labelH,label+(labelcnt<<6),labelcnt); - labelcnt++; + g_processingState = 1; + Bsprintf(g_szCurrentBlockName,"%s",label+(g_numLabels<<6)); + HASH_add(&labelH,label+(g_numLabels<<6),g_numLabels); + g_numLabels++; return 0; } - getlabel(); + C_GetNextLabelName(); - if (HASH_find(&keywH,label+(labelcnt<<6))>=0) + if (HASH_find(&keywH,label+(g_numLabels<<6))>=0) { - error++; - ReportError(ERROR_ISAKEYWORD); + g_numCompilerErrors++; + C_ReportError(ERROR_ISAKEYWORD); return 0; } - i = HASH_find(&gamevarH,label+(labelcnt<<6)); + i = HASH_find(&gamevarH,label+(g_numLabels<<6)); if (i>=0) { - warning++; - ReportError(WARNING_NAMEMATCHESVAR); + g_numCompilerWarnings++; + C_ReportError(WARNING_NAMEMATCHESVAR); } - j = HASH_find(&labelH,label+(labelcnt<<6)); + j = HASH_find(&labelH,label+(g_numLabels<<6)); if (j>=0) { if (labeltype[j] & LABEL_STATE) { - if (!(error || warning) && g_ScriptDebug > 1) - 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)>>3] |= (BITPTR_POINTER<<((scriptptr-script)&7)); - else bitptr[(scriptptr-script)>>3] &= ~(1<<((scriptptr-script)&7)); - scriptptr++; + if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug > 1) + initprintf("%s:%d: debug: accepted state label `%s'.\n",g_szScriptFileName,g_lineNumber,label+(j<<6)); + *g_scriptPtr = labelcode[j]; + if (labelcode[j] >= (intptr_t)&script[0] && labelcode[j] < (intptr_t)&script[g_scriptSize]) + bitptr[(g_scriptPtr-script)>>3] |= (BITPTR_POINTER<<((g_scriptPtr-script)&7)); + else bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); + g_scriptPtr++; return 0; } else { - char *gl = (char *)translatelabeltype(labeltype[j]); - ReportError(-1); - initprintf("%s:%d: warning: expected a state, found a %s.\n",compilefile,line_number,gl); - warning++; + char *gl = (char *)C_GetLabelType(labeltype[j]); + C_ReportError(-1); + initprintf("%s:%d: warning: expected a state, found a %s.\n",g_szScriptFileName,g_lineNumber,gl); + g_numCompilerWarnings++; Bfree(gl); - *(scriptptr-1) = CON_NULLOP; // get rid of the state, leaving a nullop to satisfy if conditions - bitptr[(scriptptr-script-1)>>3] &= ~(1<<((scriptptr-script-1)&7)); + *(g_scriptPtr-1) = CON_NULLOP; // get rid of the state, leaving a nullop to satisfy if conditions + bitptr[(g_scriptPtr-script-1)>>3] &= ~(1<<((g_scriptPtr-script-1)&7)); return 0; // valid label name, but wrong type } } else { - ReportError(-1); - initprintf("%s:%d: error: state `%s' not found.\n",compilefile,line_number,label+(labelcnt<<6)); - error++; + C_ReportError(-1); + initprintf("%s:%d: error: state `%s' not found.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); + g_numCompilerErrors++; } - scriptptr++; + g_scriptPtr++; return 0; case CON_ENDS: - if (parsing_state == 0) + if (g_processingState == 0) { - ReportError(-1); - initprintf("%s:%d: error: found `ends' without open `state'.\n",compilefile,line_number); - error++; + C_ReportError(-1); + initprintf("%s:%d: error: found `ends' without open `state'.\n",g_szScriptFileName,g_lineNumber); + g_numCompilerErrors++; } // else { - if (num_braces > 0) + if (g_numBraces > 0) { - ReportError(ERROR_OPENBRACKET); - error++; + C_ReportError(ERROR_OPENBRACKET); + g_numCompilerErrors++; } - if (num_braces < 0) + if (g_numBraces < 0) { - ReportError(ERROR_CLOSEBRACKET); - error++; + C_ReportError(ERROR_CLOSEBRACKET); + g_numCompilerErrors++; } - if (checking_switch > 0) + if (g_checkingSwitch > 0) { - ReportError(ERROR_NOENDSWITCH); - error++; + C_ReportError(ERROR_NOENDSWITCH); + g_numCompilerErrors++; - checking_switch = 0; // can't be checking anymore... + g_checkingSwitch = 0; // can't be checking anymore... } - parsing_state = 0; - Bsprintf(parsing_item_name,"(none)"); + g_processingState = 0; + Bsprintf(g_szCurrentBlockName,"(none)"); } return 0; case CON_SETTHISPROJECTILE: case CON_SETPROJECTILE: - if (!CheckEventSync(current_event)) - ReportError(WARNING_EVENTSYNC); + if (!C_CheckEventSync(g_currentEvent)) + C_ReportError(WARNING_EVENTSYNC); case CON_GETTHISPROJECTILE: case CON_GETPROJECTILE: { @@ -2013,9 +1996,9 @@ static int parsecommand(void) // get the ID of the DEF if (tw == CON_SETTHISPROJECTILE) - labelsonly = 1; - transvar(); - labelsonly = 0; + g_labelsOnly = 1; + C_GetNextVar(); + g_labelsOnly = 0; // now get name of .xxx while (*textptr != '.') { @@ -2028,28 +2011,28 @@ static int parsecommand(void) } if (*textptr!='.') { - error++; - ReportError(ERROR_SYNTAXERROR); + g_numCompilerErrors++; + C_ReportError(ERROR_SYNTAXERROR); return 0; } textptr++; /// now pointing at 'xxx' - getlabel(); - //printf("found xxx label of '%s'\n", label+(labelcnt<<6)); + C_GetNextLabelName(); + //printf("found xxx label of '%s'\n", label+(g_numLabels<<6)); - lLabelID=getlabeloffset(&projectileH,strtolower(label+(labelcnt<<6),Bstrlen(label+(labelcnt<<6)))); + lLabelID=C_GetLabelNameOffset(&projectileH,strtolower(label+(g_numLabels<<6),Bstrlen(label+(g_numLabels<<6)))); //printf("LabelID is %d\n",lLabelID); if (lLabelID == -1) { - error++; - ReportError(ERROR_SYMBOLNOTRECOGNIZED); + g_numCompilerErrors++; + C_ReportError(ERROR_SYMBOLNOTRECOGNIZED); return 0; } - bitptr[(scriptptr-script)>>3] &= ~(1<<((scriptptr-script)&7)); - *scriptptr++=projectilelabels[lLabelID].lId; + bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); + *g_scriptPtr++=ProjectileLabels[lLabelID].lId; - //printf("member's flags are: %02Xh\n",playerlabels[lLabelID].flags); + //printf("member's flags are: %02Xh\n",PlayerLabels[lLabelID].flags); // now at target VAR... @@ -2058,10 +2041,10 @@ static int parsecommand(void) { case CON_SETPROJECTILE: case CON_SETTHISPROJECTILE: - transvar(); + C_GetNextVar(); break; default: - transvartype(GAMEVAR_FLAG_READONLY); + C_GetNextVarType(GAMEVAR_READONLY); break; } break; @@ -2076,221 +2059,221 @@ static int parsecommand(void) if (isdigit(*textptr) || (*textptr == '-')) { - getlabel(); - error++; - ReportError(ERROR_SYNTAXERROR); - transnum(LABEL_DEFINE); - transnum(LABEL_DEFINE); - scriptptr -= 3; // we complete the process anyways just to skip past the fucked up section + C_GetNextLabelName(); + g_numCompilerErrors++; + C_ReportError(ERROR_SYNTAXERROR); + C_GetNextValue(LABEL_DEFINE); + C_GetNextValue(LABEL_DEFINE); + g_scriptPtr -= 3; // we complete the process anyways just to skip past the fucked up section return 0; } - getlabel(); + C_GetNextLabelName(); //printf("Got Label '%.20s'\n",textptr); // Check to see it's already defined - if (HASH_find(&keywH,label+(labelcnt<<6))>=0) + if (HASH_find(&keywH,label+(g_numLabels<<6))>=0) { - error++; - ReportError(ERROR_ISAKEYWORD); + g_numCompilerErrors++; + C_ReportError(ERROR_ISAKEYWORD); return 0; } //printf("Translating number '%.20s'\n",textptr); - transnum(LABEL_DEFINE); // get initial value + C_GetNextValue(LABEL_DEFINE); // get initial value //printf("Done Translating number. '%.20s'\n",textptr); - transnum(LABEL_DEFINE); // get flags - //Bsprintf(g_szBuf,"Adding GameVar='%s', val=%l, flags=%lX",label+(labelcnt<<6), - // *(scriptptr-2), *(scriptptr-1)); + C_GetNextValue(LABEL_DEFINE); // get flags + //Bsprintf(g_szBuf,"Adding GameVar='%s', val=%l, flags=%lX",label+(g_numLabels<<6), + // *(g_scriptPtr-2), *(g_scriptPtr-1)); //AddLog(g_szBuf); - if ((*(scriptptr-1)&GAMEVAR_FLAG_USER_MASK)==3) + if ((*(g_scriptPtr-1)&GAMEVAR_USER_MASK)==3) { - warning++; - *(scriptptr-1)^=GAMEVAR_FLAG_PERPLAYER; - ReportError(WARNING_BADGAMEVAR); + g_numCompilerWarnings++; + *(g_scriptPtr-1)^=GAMEVAR_PERPLAYER; + C_ReportError(WARNING_BADGAMEVAR); } - AddGameVar(label+(labelcnt<<6),*(scriptptr-2), - (*(scriptptr-1)) - // can't define default or secret - & (~(GAMEVAR_FLAG_DEFAULT | GAMEVAR_FLAG_SECRET)) - ); + Gv_SetupVar(label+(g_numLabels<<6),*(g_scriptPtr-2), + (*(g_scriptPtr-1)) + // can't define default or secret + & (~(GAMEVAR_DEFAULT | GAMEVAR_SECRET)) + ); //AddLog("Added gamevar"); - scriptptr -= 3; // no need to save in script... + g_scriptPtr -= 3; // no need to save in script... return 0; case CON_GAMEARRAY: if (isdigit(*textptr) || (*textptr == '-')) { - getlabel(); - error++; - ReportError(ERROR_SYNTAXERROR); - transnum(LABEL_DEFINE); - transnum(LABEL_DEFINE); - scriptptr -= 2; // we complete the process anyways just to skip past the fucked up section + C_GetNextLabelName(); + g_numCompilerErrors++; + C_ReportError(ERROR_SYNTAXERROR); + C_GetNextValue(LABEL_DEFINE); + C_GetNextValue(LABEL_DEFINE); + g_scriptPtr -= 2; // we complete the process anyways just to skip past the fucked up section return 0; } - getlabel(); + C_GetNextLabelName(); //printf("Got Label '%.20s'\n",textptr); // Check to see it's already defined - if (HASH_find(&keywH,label+(labelcnt<<6))>=0) + if (HASH_find(&keywH,label+(g_numLabels<<6))>=0) { - error++; - ReportError(ERROR_ISAKEYWORD); + g_numCompilerErrors++; + C_ReportError(ERROR_ISAKEYWORD); return 0; } - i = HASH_find(&gamevarH,label+(labelcnt<<6)); + i = HASH_find(&gamevarH,label+(g_numLabels<<6)); if (i>=0) { - warning++; - ReportError(WARNING_NAMEMATCHESVAR); + g_numCompilerWarnings++; + C_ReportError(WARNING_NAMEMATCHESVAR); } - transnum(LABEL_DEFINE); - AddGameArray(label+(labelcnt<<6),*(scriptptr-1)); + C_GetNextValue(LABEL_DEFINE); + Gv_AddArray(label+(g_numLabels<<6),*(g_scriptPtr-1)); - scriptptr -= 2; // no need to save in script... + g_scriptPtr -= 2; // no need to save in script... return 0; case CON_DEFINE: { //printf("Got definition. Getting Label. '%.20s'\n",textptr); - getlabel(); + C_GetNextLabelName(); //printf("Got label. '%.20s'\n",textptr); // Check to see it's already defined - if (HASH_find(&keywH,label+(labelcnt<<6))>=0) + if (HASH_find(&keywH,label+(g_numLabels<<6))>=0) { - error++; - ReportError(ERROR_ISAKEYWORD); + g_numCompilerErrors++; + C_ReportError(ERROR_ISAKEYWORD); return 0; } - i = HASH_find(&gamevarH,label+(labelcnt<<6)); + i = HASH_find(&gamevarH,label+(g_numLabels<<6)); if (i>=0) { - warning++; - ReportError(WARNING_NAMEMATCHESVAR); + g_numCompilerWarnings++; + C_ReportError(WARNING_NAMEMATCHESVAR); } - i = HASH_find(&labelH,label+(labelcnt<<6)); + i = HASH_find(&labelH,label+(g_numLabels<<6)); if (i>=0) { - /* if (i >= defaultlabelcnt) + /* if (i >= g_numDefaultLabels) { - warning++; - ReportError(WARNING_DUPLICATEDEFINITION); + g_numCompilerWarnings++; + C_ReportError(WARNING_DUPLICATEDEFINITION); } */ } //printf("Translating. '%.20s'\n",textptr); - transnum(LABEL_DEFINE); + C_GetNextValue(LABEL_DEFINE); //printf("Translated. '%.20s'\n",textptr); if (i == -1) { - // printf("Defining Definition '%s' to be '%d'\n",label+(labelcnt<<6),*(scriptptr-1)); - HASH_replace(&labelH,label+(labelcnt<<6),labelcnt); - labeltype[labelcnt] = LABEL_DEFINE; - labelcode[labelcnt++] = *(scriptptr-1); - if (*(scriptptr-1) >= 0 && *(scriptptr-1) < MAXTILES && dynamicremap) - processnames(label+((labelcnt-1)<<6),*(scriptptr-1)); + // printf("Defining Definition '%s' to be '%d'\n",label+(g_numLabels<<6),*(g_scriptPtr-1)); + HASH_replace(&labelH,label+(g_numLabels<<6),g_numLabels); + labeltype[g_numLabels] = LABEL_DEFINE; + labelcode[g_numLabels++] = *(g_scriptPtr-1); + if (*(g_scriptPtr-1) >= 0 && *(g_scriptPtr-1) < MAXTILES && g_dynamicTileMapping) + G_ProcessDynamicTileMapping(label+((g_numLabels-1)<<6),*(g_scriptPtr-1)); } - scriptptr -= 2; + g_scriptPtr -= 2; return 0; } case CON_PALFROM: for (j=3;j>=0;j--) { - if (keyword() == -1) - transnum(LABEL_DEFINE); + if (C_GetKeyword() == -1) + C_GetNextValue(LABEL_DEFINE); else break; } while (j>-1) { - bitptr[(scriptptr-script)>>3] &= ~(1<<((scriptptr-script)&7)); - *scriptptr = 0; - scriptptr++; + bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); + *g_scriptPtr = 0; + g_scriptPtr++; j--; } return 0; case CON_MOVE: - if (parsing_actor || parsing_state) + if (g_parsingActorPtr || g_processingState) { - if (!CheckEventSync(current_event)) + if (!C_CheckEventSync(g_currentEvent)) { - warning++; - ReportError(WARNING_EVENTSYNC); + g_numCompilerWarnings++; + C_ReportError(WARNING_EVENTSYNC); } - if ((transnum(LABEL_MOVE|LABEL_DEFINE) == 0) && (*(scriptptr-1) != 0) && (*(scriptptr-1) != 1)) + if ((C_GetNextValue(LABEL_MOVE|LABEL_DEFINE) == 0) && (*(g_scriptPtr-1) != 0) && (*(g_scriptPtr-1) != 1)) { - ReportError(-1); - bitptr[(scriptptr-script-1)>>3] &= ~(1<<((scriptptr-script-1)&7)); - *(scriptptr-1) = 0; - initprintf("%s:%d: warning: expected a move, found a constant.\n",compilefile,line_number); - warning++; + C_ReportError(-1); + bitptr[(g_scriptPtr-script-1)>>3] &= ~(1<<((g_scriptPtr-script-1)&7)); + *(g_scriptPtr-1) = 0; + initprintf("%s:%d: warning: expected a move, found a constant.\n",g_szScriptFileName,g_lineNumber); + g_numCompilerWarnings++; } j = 0; - while (keyword() == -1) + while (C_GetKeyword() == -1) { - transnum(LABEL_DEFINE); - scriptptr--; - j |= *scriptptr; + C_GetNextValue(LABEL_DEFINE); + g_scriptPtr--; + j |= *g_scriptPtr; } - bitptr[(scriptptr-script)>>3] &= ~(1<<((scriptptr-script)&7)); - *scriptptr = j; + bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); + *g_scriptPtr = j; - scriptptr++; + g_scriptPtr++; } else { - scriptptr--; - getlabel(); + g_scriptPtr--; + C_GetNextLabelName(); // Check to see it's already defined - if (HASH_find(&keywH,label+(labelcnt<<6))>=0) + if (HASH_find(&keywH,label+(g_numLabels<<6))>=0) { - error++; - ReportError(ERROR_ISAKEYWORD); + g_numCompilerErrors++; + C_ReportError(ERROR_ISAKEYWORD); return 0; } - i = HASH_find(&gamevarH,label+(labelcnt<<6)); + i = HASH_find(&gamevarH,label+(g_numLabels<<6)); if (i>=0) { - warning++; - ReportError(WARNING_NAMEMATCHESVAR); + g_numCompilerWarnings++; + C_ReportError(WARNING_NAMEMATCHESVAR); } - i = HASH_find(&labelH,label+(labelcnt<<6)); + i = HASH_find(&labelH,label+(g_numLabels<<6)); if (i>=0) { - warning++; - initprintf("%s:%d: warning: duplicate move `%s' ignored.\n",compilefile,line_number,label+(labelcnt<<6)); + g_numCompilerWarnings++; + initprintf("%s:%d: warning: duplicate move `%s' ignored.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); } if (i == -1) { - HASH_add(&labelH,label+(labelcnt<<6),labelcnt); - labeltype[labelcnt] = LABEL_MOVE; - labelcode[labelcnt++] = (intptr_t) scriptptr; + HASH_add(&labelH,label+(g_numLabels<<6),g_numLabels); + labeltype[g_numLabels] = LABEL_MOVE; + labelcode[g_numLabels++] = (intptr_t) g_scriptPtr; } for (j=1;j>=0;j--) { - if (keyword() >= 0) break; - transnum(LABEL_DEFINE); + if (C_GetKeyword() >= 0) break; + C_GetNextValue(LABEL_DEFINE); } for (k=j;k>=0;k--) { - bitptr[(scriptptr-script)>>3] &= ~(1<<((scriptptr-script)&7)); - *scriptptr = 0; - scriptptr++; + bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); + *g_scriptPtr = 0; + g_scriptPtr++; } } return 0; @@ -2301,21 +2284,21 @@ static int parsecommand(void) // music 1 stalker.mid dethtoll.mid streets.mid watrwld1.mid snake1.mid // thecall.mid ahgeez.mid dethtoll.mid streets.mid watrwld1.mid snake1.mid - scriptptr--; - transnum(LABEL_DEFINE); // Volume Number (0/4) - scriptptr--; + g_scriptPtr--; + C_GetNextValue(LABEL_DEFINE); // Volume Number (0/4) + g_scriptPtr--; - k = *scriptptr-1; + k = *g_scriptPtr-1; if (k >= 0) // if it's background music { i = 0; // get the file name... - while (keyword() == -1) + while (C_GetKeyword() == -1) { while (isaltok(*textptr) == 0) { - if (*textptr == 0x0a) line_number++; + if (*textptr == 0x0a) g_lineNumber++; textptr++; if (*textptr == 0) break; } @@ -2328,12 +2311,12 @@ static int parsecommand(void) } tempbuf[j+1] = '\0'; - if (map[(k*MAXLEVELS)+i].musicfn == NULL) - map[(k*MAXLEVELS)+i].musicfn = Bcalloc(Bstrlen(tempbuf)+1,sizeof(char)); - else if ((Bstrlen(tempbuf)+1) > sizeof(map[(k*MAXLEVELS)+i].musicfn)) - map[(k*MAXLEVELS)+i].musicfn = Brealloc(map[(k*MAXLEVELS)+i].musicfn,(Bstrlen(tempbuf)+1)); + if (MapInfo[(k*MAXLEVELS)+i].musicfn == NULL) + MapInfo[(k*MAXLEVELS)+i].musicfn = Bcalloc(Bstrlen(tempbuf)+1,sizeof(char)); + else if ((Bstrlen(tempbuf)+1) > sizeof(MapInfo[(k*MAXLEVELS)+i].musicfn)) + MapInfo[(k*MAXLEVELS)+i].musicfn = Brealloc(MapInfo[(k*MAXLEVELS)+i].musicfn,(Bstrlen(tempbuf)+1)); - Bstrcpy(map[(k*MAXLEVELS)+i].musicfn,tempbuf); + Bstrcpy(MapInfo[(k*MAXLEVELS)+i].musicfn,tempbuf); textptr += j; if (i > MAXLEVELS-1) break; @@ -2343,11 +2326,11 @@ static int parsecommand(void) else { i = 0; - while (keyword() == -1) + while (C_GetKeyword() == -1) { while (isaltok(*textptr) == 0) { - if (*textptr == 0x0a) line_number++; + if (*textptr == 0x0a) g_lineNumber++; textptr++; if (*textptr == 0) break; } @@ -2355,10 +2338,10 @@ static int parsecommand(void) while (isaltok(*(textptr+j))) { - env_music_fn[i][j] = textptr[j]; + EnvMusicFilename[i][j] = textptr[j]; j++; } - env_music_fn[i][j] = '\0'; + EnvMusicFilename[i][j] = '\0'; textptr += j; if (i > MAXVOLUMES-1) break; @@ -2369,10 +2352,10 @@ static int parsecommand(void) return 0; case CON_INCLUDE: - scriptptr--; + g_scriptPtr--; while (isaltok(*textptr) == 0) { - if (*textptr == 0x0a) line_number++; + if (*textptr == 0x0a) g_lineNumber++; textptr++; if (*textptr == 0) break; } @@ -2385,17 +2368,17 @@ static int parsecommand(void) tempbuf[j] = '\0'; { - int temp_line_number; + int temp_ScriptLineNumber; int temp_ifelse_check; char *origtptr, *mptr; - char parentcompilefile[255]; + char parentScriptFileName[255]; int fp; - fp = kopen4loadfrommod(tempbuf,loadfromgrouponly); + fp = kopen4loadfrommod(tempbuf,g_loadFromGroupOnly); if (fp < 0) { - error++; - initprintf("%s:%d: error: could not find file `%s'.\n",compilefile,line_number,tempbuf); + g_numCompilerErrors++; + initprintf("%s:%d: error: could not find file `%s'.\n",g_szScriptFileName,g_lineNumber,tempbuf); return 0; } @@ -2405,9 +2388,9 @@ static int parsecommand(void) if (!mptr) { kclose(fp); - error++; + g_numCompilerErrors++; initprintf("%s:%d: error: could not allocate %d bytes to include `%s'.\n", - line_number,compilefile,j,tempbuf); + g_lineNumber,g_szScriptFileName,j,tempbuf); return 0; } @@ -2420,21 +2403,21 @@ static int parsecommand(void) textptr++; origtptr = textptr; - Bstrcpy(parentcompilefile, compilefile); - Bstrcpy(compilefile, tempbuf); - temp_line_number = line_number; - line_number = 1; - temp_ifelse_check = checking_ifelse; - checking_ifelse = 0; + Bstrcpy(parentScriptFileName, g_szScriptFileName); + Bstrcpy(g_szScriptFileName, tempbuf); + temp_ScriptLineNumber = g_lineNumber; + g_lineNumber = 1; + temp_ifelse_check = g_checkingIfElse; + g_checkingIfElse = 0; textptr = mptr; - do done = parsecommand(); + do done = C_ParseCommand(); while (!done); - Bstrcpy(compilefile, parentcompilefile); - total_lines += line_number; - line_number = temp_line_number; - checking_ifelse = temp_ifelse_check; + Bstrcpy(g_szScriptFileName, parentScriptFileName); + g_totalLines += g_lineNumber; + g_lineNumber = temp_ScriptLineNumber; + g_checkingIfElse = temp_ifelse_check; textptr = origtptr; @@ -2443,419 +2426,419 @@ static int parsecommand(void) return 0; case CON_AI: - if (parsing_actor || parsing_state) + if (g_parsingActorPtr || g_processingState) { - if (!CheckEventSync(current_event)) + if (!C_CheckEventSync(g_currentEvent)) { - ReportError(WARNING_EVENTSYNC); - warning++; + C_ReportError(WARNING_EVENTSYNC); + g_numCompilerWarnings++; } - transnum(LABEL_AI); + C_GetNextValue(LABEL_AI); } else { - scriptptr--; - getlabel(); + g_scriptPtr--; + C_GetNextLabelName(); - if (HASH_find(&keywH,label+(labelcnt<<6))>=0) + if (HASH_find(&keywH,label+(g_numLabels<<6))>=0) { - error++; - ReportError(ERROR_ISAKEYWORD); + g_numCompilerErrors++; + C_ReportError(ERROR_ISAKEYWORD); return 0; } - i = HASH_find(&gamevarH,label+(labelcnt<<6)); + i = HASH_find(&gamevarH,label+(g_numLabels<<6)); if (i>=0) { - warning++; - ReportError(WARNING_NAMEMATCHESVAR); + g_numCompilerWarnings++; + C_ReportError(WARNING_NAMEMATCHESVAR); } - i = HASH_find(&labelH,label+(labelcnt<<6)); + i = HASH_find(&labelH,label+(g_numLabels<<6)); if (i>=0) { - warning++; - initprintf("%s:%d: warning: duplicate ai `%s' ignored.\n",compilefile,line_number,label+(labelcnt<<6)); + g_numCompilerWarnings++; + initprintf("%s:%d: warning: duplicate ai `%s' ignored.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); } if (i == -1) { - labeltype[labelcnt] = LABEL_AI; - HASH_add(&labelH,label+(labelcnt<<6),labelcnt); - labelcode[labelcnt++] = (intptr_t) scriptptr; + labeltype[g_numLabels] = LABEL_AI; + HASH_add(&labelH,label+(g_numLabels<<6),g_numLabels); + labelcode[g_numLabels++] = (intptr_t) g_scriptPtr; } for (j=0;j<3;j++) { - if (keyword() >= 0) break; + if (C_GetKeyword() >= 0) break; if (j == 1) - transnum(LABEL_ACTION); + C_GetNextValue(LABEL_ACTION); else if (j == 2) { - if ((transnum(LABEL_MOVE|LABEL_DEFINE) == 0) && (*(scriptptr-1) != 0) && (*(scriptptr-1) != 1)) + if ((C_GetNextValue(LABEL_MOVE|LABEL_DEFINE) == 0) && (*(g_scriptPtr-1) != 0) && (*(g_scriptPtr-1) != 1)) { - ReportError(-1); - bitptr[(scriptptr-script-1)>>3] &= ~(1<<((scriptptr-script-1)&7)); - *(scriptptr-1) = 0; - initprintf("%s:%d: warning: expected a move, found a constant.\n",compilefile,line_number); - warning++; + C_ReportError(-1); + bitptr[(g_scriptPtr-script-1)>>3] &= ~(1<<((g_scriptPtr-script-1)&7)); + *(g_scriptPtr-1) = 0; + initprintf("%s:%d: warning: expected a move, found a constant.\n",g_szScriptFileName,g_lineNumber); + g_numCompilerWarnings++; } k = 0; - while (keyword() == -1) + while (C_GetKeyword() == -1) { - transnum(LABEL_DEFINE); - scriptptr--; - k |= *scriptptr; + C_GetNextValue(LABEL_DEFINE); + g_scriptPtr--; + k |= *g_scriptPtr; } - bitptr[(scriptptr-script)>>3] &= ~(1<<((scriptptr-script)&7)); - *scriptptr = k; - scriptptr++; + bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); + *g_scriptPtr = k; + g_scriptPtr++; return 0; } } for (k=j;k<3;k++) { - bitptr[(scriptptr-script)>>3] &= ~(1<<((scriptptr-script)&7)); - *scriptptr = 0; - scriptptr++; + bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); + *g_scriptPtr = 0; + g_scriptPtr++; } } return 0; case CON_ACTION: - if (parsing_actor || parsing_state) + if (g_parsingActorPtr || g_processingState) { - if (!CheckEventSync(current_event)) + if (!C_CheckEventSync(g_currentEvent)) { - ReportError(WARNING_EVENTSYNC); - warning++; + C_ReportError(WARNING_EVENTSYNC); + g_numCompilerWarnings++; } - transnum(LABEL_ACTION); + C_GetNextValue(LABEL_ACTION); } else { - scriptptr--; - getlabel(); + g_scriptPtr--; + C_GetNextLabelName(); // Check to see it's already defined - if (HASH_find(&keywH,label+(labelcnt<<6))>=0) + if (HASH_find(&keywH,label+(g_numLabels<<6))>=0) { - error++; - ReportError(ERROR_ISAKEYWORD); + g_numCompilerErrors++; + C_ReportError(ERROR_ISAKEYWORD); return 0; } - i = HASH_find(&gamevarH,label+(labelcnt<<6)); + i = HASH_find(&gamevarH,label+(g_numLabels<<6)); if (i>=0) { - warning++; - ReportError(WARNING_NAMEMATCHESVAR); + g_numCompilerWarnings++; + C_ReportError(WARNING_NAMEMATCHESVAR); } - i = HASH_find(&labelH,label+(labelcnt<<6)); + i = HASH_find(&labelH,label+(g_numLabels<<6)); if (i>=0) { - warning++; - initprintf("%s:%d: warning: duplicate action `%s' ignored.\n",compilefile,line_number,label+(labelcnt<<6)); + g_numCompilerWarnings++; + initprintf("%s:%d: warning: duplicate action `%s' ignored.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); } if (i == -1) { - labeltype[labelcnt] = LABEL_ACTION; - labelcode[labelcnt] = (intptr_t) scriptptr; - HASH_add(&labelH,label+(labelcnt<<6),labelcnt); - labelcnt++; + labeltype[g_numLabels] = LABEL_ACTION; + labelcode[g_numLabels] = (intptr_t) g_scriptPtr; + HASH_add(&labelH,label+(g_numLabels<<6),g_numLabels); + g_numLabels++; } for (j=4;j>=0;j--) { - if (keyword() >= 0) break; - transnum(LABEL_DEFINE); + if (C_GetKeyword() >= 0) break; + C_GetNextValue(LABEL_DEFINE); } for (k=j;k>=0;k--) { - bitptr[(scriptptr-script)>>3] &= ~(1<<((scriptptr-script)&7)); - *scriptptr = 0; - scriptptr++; + bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); + *g_scriptPtr = 0; + g_scriptPtr++; } } return 0; case CON_ACTOR: - if (parsing_state || parsing_actor) + if (g_processingState || g_parsingActorPtr) { - ReportError(ERROR_FOUNDWITHIN); - error++; + C_ReportError(ERROR_FOUNDWITHIN); + g_numCompilerErrors++; } - num_braces = 0; - scriptptr--; - parsing_actor = scriptptr; + g_numBraces = 0; + g_scriptPtr--; + g_parsingActorPtr = g_scriptPtr; - skipcomments(); + C_SkipComments(); j = 0; while (isaltok(*(textptr+j))) { - parsing_item_name[j] = textptr[j]; + g_szCurrentBlockName[j] = textptr[j]; j++; } - parsing_item_name[j] = 0; - transnum(LABEL_DEFINE); - // Bsprintf(parsing_item_name,"%s",label+(labelcnt<<6)); - scriptptr--; - actorscrptr[*scriptptr] = parsing_actor; + g_szCurrentBlockName[j] = 0; + C_GetNextValue(LABEL_DEFINE); + // Bsprintf(g_szCurrentBlockName,"%s",label+(g_numLabels<<6)); + g_scriptPtr--; + actorscrptr[*g_scriptPtr] = g_parsingActorPtr; for (j=0;j<4;j++) { - bitptr[(parsing_actor+j-script)>>3] &= ~(1<<((parsing_actor+j-script)&7)); - *(parsing_actor+j) = 0; + bitptr[(g_parsingActorPtr+j-script)>>3] &= ~(1<<((g_parsingActorPtr+j-script)&7)); + *(g_parsingActorPtr+j) = 0; if (j == 3) { j = 0; - while (keyword() == -1) + while (C_GetKeyword() == -1) { - transnum(LABEL_DEFINE); - scriptptr--; - j |= *scriptptr; + C_GetNextValue(LABEL_DEFINE); + g_scriptPtr--; + j |= *g_scriptPtr; } - bitptr[(scriptptr-script)>>3] &= ~(1<<((scriptptr-script)&7)); - *scriptptr = j; - scriptptr++; + bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); + *g_scriptPtr = j; + g_scriptPtr++; break; } else { - if (keyword() >= 0) + if (C_GetKeyword() >= 0) { for (i=4-j; i; i--) { - bitptr[(scriptptr-script)>>3] &= ~(1<<((scriptptr-script)&7)); - *(scriptptr++) = 0; + bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); + *(g_scriptPtr++) = 0; } break; } switch (j) { case 0: - transnum(LABEL_DEFINE); + C_GetNextValue(LABEL_DEFINE); break; case 1: - transnum(LABEL_ACTION); + C_GetNextValue(LABEL_ACTION); break; case 2: - if ((transnum(LABEL_MOVE|LABEL_DEFINE) == 0) && (*(scriptptr-1) != 0) && (*(scriptptr-1) != 1)) + if ((C_GetNextValue(LABEL_MOVE|LABEL_DEFINE) == 0) && (*(g_scriptPtr-1) != 0) && (*(g_scriptPtr-1) != 1)) { - ReportError(-1); - bitptr[(scriptptr-script-1)>>3] &= ~(1<<((scriptptr-script-1)&7)); - *(scriptptr-1) = 0; - initprintf("%s:%d: warning: expected a move, found a constant.\n",compilefile,line_number); - warning++; + C_ReportError(-1); + bitptr[(g_scriptPtr-script-1)>>3] &= ~(1<<((g_scriptPtr-script-1)&7)); + *(g_scriptPtr-1) = 0; + initprintf("%s:%d: warning: expected a move, found a constant.\n",g_szScriptFileName,g_lineNumber); + g_numCompilerWarnings++; } break; } - if (*(scriptptr-1) >= (intptr_t)&script[0] && *(scriptptr-1) < (intptr_t)&script[g_ScriptSize]) - bitptr[(parsing_actor+j-script)>>3] |= (BITPTR_POINTER<<((parsing_actor+j-script)&7)); - else bitptr[(parsing_actor+j-script)>>3] &= ~(1<<((parsing_actor+j-script)&7)); - *(parsing_actor+j) = *(scriptptr-1); + if (*(g_scriptPtr-1) >= (intptr_t)&script[0] && *(g_scriptPtr-1) < (intptr_t)&script[g_scriptSize]) + bitptr[(g_parsingActorPtr+j-script)>>3] |= (BITPTR_POINTER<<((g_parsingActorPtr+j-script)&7)); + else bitptr[(g_parsingActorPtr+j-script)>>3] &= ~(1<<((g_parsingActorPtr+j-script)&7)); + *(g_parsingActorPtr+j) = *(g_scriptPtr-1); } } - checking_ifelse = 0; + g_checkingIfElse = 0; return 0; case CON_ONEVENT: - if (parsing_state || parsing_actor) + if (g_processingState || g_parsingActorPtr) { - ReportError(ERROR_FOUNDWITHIN); - error++; + C_ReportError(ERROR_FOUNDWITHIN); + g_numCompilerErrors++; } - num_braces = 0; - scriptptr--; - parsing_event = scriptptr; - parsing_actor = scriptptr; + g_numBraces = 0; + g_scriptPtr--; + g_parsingEventPtr = g_scriptPtr; + g_parsingActorPtr = g_scriptPtr; - skipcomments(); + C_SkipComments(); j = 0; while (isaltok(*(textptr+j))) { - parsing_item_name[j] = textptr[j]; + g_szCurrentBlockName[j] = textptr[j]; j++; } - parsing_item_name[j] = 0; -// labelsonly = 1; - transnum(LABEL_DEFINE); - labelsonly = 0; - scriptptr--; - j= *scriptptr; // type of event - current_event = j; - //Bsprintf(g_szBuf,"Adding Event for %d at %lX",j, parsing_event); + g_szCurrentBlockName[j] = 0; +// g_labelsOnly = 1; + C_GetNextValue(LABEL_DEFINE); + g_labelsOnly = 0; + g_scriptPtr--; + j= *g_scriptPtr; // type of event + g_currentEvent = j; + //Bsprintf(g_szBuf,"Adding Event for %d at %lX",j, g_parsingEventPtr); //AddLog(g_szBuf); if (j > MAXGAMEEVENTS-1 || j < 0) { - initprintf("%s:%d: error: invalid event ID.\n",compilefile,line_number); - error++; + initprintf("%s:%d: error: invalid event ID.\n",g_szScriptFileName,g_lineNumber); + g_numCompilerErrors++; return 0; } if (apScriptGameEvent[j]) { - tempscrptr = parsing_event; - parsing_event = parsing_actor = 0; - ReportError(-1); - parsing_event = parsing_actor = tempscrptr; - initprintf("%s:%d: warning: duplicate event `%s'.\n",compilefile,line_number,parsing_item_name); - warning++; + tempscrptr = g_parsingEventPtr; + g_parsingEventPtr = g_parsingActorPtr = 0; + C_ReportError(-1); + g_parsingEventPtr = g_parsingActorPtr = tempscrptr; + initprintf("%s:%d: warning: duplicate event `%s'.\n",g_szScriptFileName,g_lineNumber,g_szCurrentBlockName); + g_numCompilerWarnings++; } - else apScriptGameEvent[j]=parsing_event; + else apScriptGameEvent[j]=g_parsingEventPtr; - checking_ifelse = 0; + g_checkingIfElse = 0; return 0; case CON_EVENTLOADACTOR: - if (parsing_state || parsing_actor) + if (g_processingState || g_parsingActorPtr) { - ReportError(ERROR_FOUNDWITHIN); - error++; + C_ReportError(ERROR_FOUNDWITHIN); + g_numCompilerErrors++; } - num_braces = 0; - scriptptr--; - parsing_actor = scriptptr; + g_numBraces = 0; + g_scriptPtr--; + g_parsingActorPtr = g_scriptPtr; - skipcomments(); + C_SkipComments(); j = 0; while (isaltok(*(textptr+j))) { - parsing_item_name[j] = textptr[j]; + g_szCurrentBlockName[j] = textptr[j]; j++; } - parsing_item_name[j] = 0; - transnum(LABEL_DEFINE); - scriptptr--; - actorLoadEventScrptr[*scriptptr] = parsing_actor; + g_szCurrentBlockName[j] = 0; + C_GetNextValue(LABEL_DEFINE); + g_scriptPtr--; + actorLoadEventScrptr[*g_scriptPtr] = g_parsingActorPtr; - checking_ifelse = 0; + g_checkingIfElse = 0; return 0; case CON_USERACTOR: - if (parsing_state || parsing_actor) + if (g_processingState || g_parsingActorPtr) { - ReportError(ERROR_FOUNDWITHIN); - error++; + C_ReportError(ERROR_FOUNDWITHIN); + g_numCompilerErrors++; } - num_braces = 0; - scriptptr--; - parsing_actor = scriptptr; + g_numBraces = 0; + g_scriptPtr--; + g_parsingActorPtr = g_scriptPtr; - transnum(LABEL_DEFINE); - scriptptr--; + C_GetNextValue(LABEL_DEFINE); + g_scriptPtr--; - skipcomments(); + C_SkipComments(); j = 0; while (isaltok(*(textptr+j))) { - parsing_item_name[j] = textptr[j]; + g_szCurrentBlockName[j] = textptr[j]; j++; } - parsing_item_name[j] = 0; + g_szCurrentBlockName[j] = 0; - j = *scriptptr; + j = *g_scriptPtr; if (j > 2) { - ReportError(-1); - initprintf("%s:%d: warning: invalid useractor type.\n",compilefile,line_number); - warning++; + C_ReportError(-1); + initprintf("%s:%d: warning: invalid useractor type.\n",g_szScriptFileName,g_lineNumber); + g_numCompilerWarnings++; j = 0; } - transnum(LABEL_DEFINE); - scriptptr--; - actorscrptr[*scriptptr] = parsing_actor; - actortype[*scriptptr] = j; + C_GetNextValue(LABEL_DEFINE); + g_scriptPtr--; + actorscrptr[*g_scriptPtr] = g_parsingActorPtr; + ActorType[*g_scriptPtr] = j; for (j=0;j<4;j++) { - bitptr[(scriptptr-script)>>3] &= ~(1<<((scriptptr-script)&7)); - *(parsing_actor+j) = 0; + bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); + *(g_parsingActorPtr+j) = 0; if (j == 3) { j = 0; - while (keyword() == -1) + while (C_GetKeyword() == -1) { - transnum(LABEL_DEFINE); - scriptptr--; - j |= *scriptptr; + C_GetNextValue(LABEL_DEFINE); + g_scriptPtr--; + j |= *g_scriptPtr; } - bitptr[(scriptptr-script)>>3] &= ~(1<<((scriptptr-script)&7)); - *scriptptr = j; - scriptptr++; + bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); + *g_scriptPtr = j; + g_scriptPtr++; break; } else { - if (keyword() >= 0) + if (C_GetKeyword() >= 0) { for (i=4-j; i; i--) { - bitptr[(scriptptr-script)>>3] &= ~(1<<((scriptptr-script)&7)); - *(scriptptr++) = 0; + bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); + *(g_scriptPtr++) = 0; } break; } switch (j) { case 0: - transnum(LABEL_DEFINE); + C_GetNextValue(LABEL_DEFINE); break; case 1: - transnum(LABEL_ACTION); + C_GetNextValue(LABEL_ACTION); break; case 2: - if ((transnum(LABEL_MOVE|LABEL_DEFINE) == 0) && (*(scriptptr-1) != 0) && (*(scriptptr-1) != 1)) + if ((C_GetNextValue(LABEL_MOVE|LABEL_DEFINE) == 0) && (*(g_scriptPtr-1) != 0) && (*(g_scriptPtr-1) != 1)) { - ReportError(-1); - bitptr[(scriptptr-script-1)>>3] &= ~(1<<((scriptptr-script-1)&7)); - *(scriptptr-1) = 0; - initprintf("%s:%d: warning: expected a move, found a constant.\n",compilefile,line_number); - warning++; + C_ReportError(-1); + bitptr[(g_scriptPtr-script-1)>>3] &= ~(1<<((g_scriptPtr-script-1)&7)); + *(g_scriptPtr-1) = 0; + initprintf("%s:%d: warning: expected a move, found a constant.\n",g_szScriptFileName,g_lineNumber); + g_numCompilerWarnings++; } break; } - if (*(scriptptr-1) >= (intptr_t)&script[0] && *(scriptptr-1) < (intptr_t)&script[g_ScriptSize]) - bitptr[(parsing_actor+j-script)>>3] |= (BITPTR_POINTER<<((parsing_actor+j-script)&7)); - else bitptr[(parsing_actor+j-script)>>3] &= ~(1<<((parsing_actor+j-script)&7)); - *(parsing_actor+j) = *(scriptptr-1); + if (*(g_scriptPtr-1) >= (intptr_t)&script[0] && *(g_scriptPtr-1) < (intptr_t)&script[g_scriptSize]) + bitptr[(g_parsingActorPtr+j-script)>>3] |= (BITPTR_POINTER<<((g_parsingActorPtr+j-script)&7)); + else bitptr[(g_parsingActorPtr+j-script)>>3] &= ~(1<<((g_parsingActorPtr+j-script)&7)); + *(g_parsingActorPtr+j) = *(g_scriptPtr-1); } } - checking_ifelse = 0; + g_checkingIfElse = 0; return 0; case CON_INSERTSPRITEQ: - if (!CheckEventSync(current_event)) + if (!C_CheckEventSync(g_currentEvent)) { - ReportError(WARNING_EVENTSYNC); - warning++; + C_ReportError(WARNING_EVENTSYNC); + g_numCompilerWarnings++; } return 0; case CON_QSPRINTF: - transnum(LABEL_DEFINE); - transnum(LABEL_DEFINE); + C_GetNextValue(LABEL_DEFINE); + C_GetNextValue(LABEL_DEFINE); for (j=3;j>=0;j--) { - if (keyword() == -1) - transvar(); + if (C_GetKeyword() == -1) + C_GetNextVar(); else break; } while (j > -1) { - bitptr[(scriptptr-script)>>3] &= ~(1<<((scriptptr-script)&7)); - *scriptptr = 0; - scriptptr++; + bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); + *g_scriptPtr = 0; + g_scriptPtr++; j--; } return 0; @@ -2885,10 +2868,10 @@ static int parsecommand(void) case CON_LOTSOFGLASS: case CON_SAVENN: case CON_SAVE: - if (!CheckEventSync(current_event)) + if (!C_CheckEventSync(g_currentEvent)) { - ReportError(WARNING_EVENTSYNC); - warning++; + C_ReportError(WARNING_EVENTSYNC); + g_numCompilerWarnings++; } case CON_ANGOFF: case CON_QUOTE: @@ -2896,39 +2879,39 @@ static int parsecommand(void) case CON_GLOBALSOUND: case CON_SOUNDONCE: case CON_STOPSOUND: - transnum(LABEL_DEFINE); + C_GetNextValue(LABEL_DEFINE); if (tw == CON_CSTAT) { - if (*(scriptptr-1) == 32767) + if (*(g_scriptPtr-1) == 32767) { - *(scriptptr-1) = 32768; - ReportError(-1); - initprintf("%s:%d: warning: tried to set cstat 32767, using 32768 instead.\n",compilefile,line_number); - warning++; + *(g_scriptPtr-1) = 32768; + C_ReportError(-1); + initprintf("%s:%d: warning: tried to set cstat 32767, using 32768 instead.\n",g_szScriptFileName,g_lineNumber); + g_numCompilerWarnings++; } - else if ((*(scriptptr-1) & 32) && (*(scriptptr-1) & 16)) + else if ((*(g_scriptPtr-1) & 32) && (*(g_scriptPtr-1) & 16)) { - i = *(scriptptr-1); - *(scriptptr-1) ^= 48; - ReportError(-1); - initprintf("%s:%d: warning: tried to set cstat %d, using %d instead.\n",compilefile,line_number,i,*(scriptptr-1)); - warning++; + i = *(g_scriptPtr-1); + *(g_scriptPtr-1) ^= 48; + C_ReportError(-1); + initprintf("%s:%d: warning: tried to set cstat %d, using %d instead.\n",g_szScriptFileName,g_lineNumber,i,*(g_scriptPtr-1)); + g_numCompilerWarnings++; } } return 0; case CON_HITRADIUSVAR: - if (!CheckEventSync(current_event)) + if (!C_CheckEventSync(g_currentEvent)) { - ReportError(WARNING_EVENTSYNC); - warning++; + C_ReportError(WARNING_EVENTSYNC); + g_numCompilerWarnings++; } - transmultvars(5); + C_GetManyVars(5); break; case CON_HITRADIUS: - transnum(LABEL_DEFINE); - transnum(LABEL_DEFINE); - transnum(LABEL_DEFINE); + C_GetNextValue(LABEL_DEFINE); + C_GetNextValue(LABEL_DEFINE); + C_GetNextValue(LABEL_DEFINE); case CON_ADDAMMO: case CON_ADDWEAPON: case CON_SIZETO: @@ -2936,42 +2919,42 @@ static int parsecommand(void) case CON_DEBRIS: case CON_ADDINVENTORY: case CON_GUTS: - if (!CheckEventSync(current_event)) + if (!C_CheckEventSync(g_currentEvent)) { - ReportError(WARNING_EVENTSYNC); - warning++; + C_ReportError(WARNING_EVENTSYNC); + g_numCompilerWarnings++; } - transnum(LABEL_DEFINE); - transnum(LABEL_DEFINE); + C_GetNextValue(LABEL_DEFINE); + C_GetNextValue(LABEL_DEFINE); break; case CON_ELSE: - if (checking_ifelse) + if (g_checkingIfElse) { intptr_t offset; - checking_ifelse--; - tempscrptr = scriptptr; + g_checkingIfElse--; + tempscrptr = g_scriptPtr; offset = (unsigned)(tempscrptr-script); - scriptptr++; //Leave a spot for the fail location - parsecommand(); + g_scriptPtr++; //Leave a spot for the fail location + C_ParseCommand(); tempscrptr = (intptr_t *)script+offset; - *tempscrptr = (intptr_t) scriptptr; + *tempscrptr = (intptr_t) g_scriptPtr; bitptr[(tempscrptr-script)>>3] |= (BITPTR_POINTER<<((tempscrptr-script)&7)); } else { - scriptptr--; - error++; - ReportError(-1); - initprintf("%s:%d: error: found `else' with no `if'.\n",compilefile,line_number); + g_scriptPtr--; + g_numCompilerErrors++; + C_ReportError(-1); + initprintf("%s:%d: error: found `else' with no `if'.\n",g_szScriptFileName,g_lineNumber); } return 0; case CON_SETSECTOR: - if (!CheckEventSync(current_event)) + if (!C_CheckEventSync(g_currentEvent)) { - ReportError(WARNING_EVENTSYNC); - warning++; + C_ReportError(WARNING_EVENTSYNC); + g_numCompilerWarnings++; } case CON_GETSECTOR: { @@ -2989,9 +2972,9 @@ static int parsecommand(void) textptr++; // get the ID of the DEF - labelsonly = 1; - transvar(); - labelsonly = 0; + g_labelsOnly = 1; + C_GetNextVar(); + g_labelsOnly = 0; // now get name of .xxx while (*textptr != '.') { @@ -3004,33 +2987,33 @@ static int parsecommand(void) } if (*textptr!='.') { - error++; - ReportError(ERROR_SYNTAXERROR); + g_numCompilerErrors++; + C_ReportError(ERROR_SYNTAXERROR); return 0; } textptr++; /// now pointing at 'xxx' - getlabel(); - //printf("found xxx label of '%s'\n", label+(labelcnt<<6)); + C_GetNextLabelName(); + //printf("found xxx label of '%s'\n", label+(g_numLabels<<6)); - lLabelID=getlabelid(sectorlabels,§orH,strtolower(label+(labelcnt<<6),Bstrlen(label+(labelcnt<<6)))); + lLabelID=GetLabelNameid(SectorLabels,§orH,strtolower(label+(g_numLabels<<6),Bstrlen(label+(g_numLabels<<6)))); if (lLabelID == -1) { - error++; - ReportError(ERROR_SYMBOLNOTRECOGNIZED); + g_numCompilerErrors++; + C_ReportError(ERROR_SYMBOLNOTRECOGNIZED); return 0; } - bitptr[(scriptptr-script)>>3] &= ~(1<<((scriptptr-script)&7)); - *scriptptr++=lLabelID; + bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); + *g_scriptPtr++=lLabelID; // now at target VAR... // get the ID of the DEF if (tw==CON_GETSECTOR) - transvartype(GAMEVAR_FLAG_READONLY); + C_GetNextVarType(GAMEVAR_READONLY); else - transvar(); + C_GetNextVar(); break; } @@ -3046,21 +3029,21 @@ static int parsecommand(void) // that is of into // -1 for none found - transnum(LABEL_DEFINE); // get - transnum(LABEL_DEFINE); // get maxdist + C_GetNextValue(LABEL_DEFINE); // get + C_GetNextValue(LABEL_DEFINE); // get maxdist switch (tw) { case CON_FINDNEARACTORZ: case CON_FINDNEARSPRITEZ: - transnum(LABEL_DEFINE); + C_GetNextValue(LABEL_DEFINE); default: break; } // target var // get the ID of the DEF - transvartype(GAMEVAR_FLAG_READONLY); + C_GetNextVarType(GAMEVAR_READONLY); break; } @@ -3071,21 +3054,21 @@ static int parsecommand(void) case CON_FINDNEARACTORZVAR: case CON_FINDNEARSPRITEZVAR: { - transnum(LABEL_DEFINE); // get + C_GetNextValue(LABEL_DEFINE); // get // get the ID of the DEF - transvar(); + C_GetNextVar(); switch (tw) { case CON_FINDNEARACTORZVAR: case CON_FINDNEARSPRITEZVAR: - transvar(); + C_GetNextVar(); default: break; } // target var // get the ID of the DEF - transvartype(GAMEVAR_FLAG_READONLY); + C_GetNextVarType(GAMEVAR_READONLY); break; } @@ -3095,18 +3078,18 @@ static int parsecommand(void) // gets the sqrt of invar into outvar // get the ID of the DEF - transvar(); + C_GetNextVar(); // target var // get the ID of the DEF - transvartype(GAMEVAR_FLAG_READONLY); + C_GetNextVarType(GAMEVAR_READONLY); break; } case CON_SETWALL: - if (!CheckEventSync(current_event)) + if (!C_CheckEventSync(g_currentEvent)) { - ReportError(WARNING_EVENTSYNC); - warning++; + C_ReportError(WARNING_EVENTSYNC); + g_numCompilerWarnings++; } case CON_GETWALL: { @@ -3124,9 +3107,9 @@ static int parsecommand(void) textptr++; // get the ID of the DEF - labelsonly = 1; - transvar(); - labelsonly = 0; + g_labelsOnly = 1; + C_GetNextVar(); + g_labelsOnly = 0; // now get name of .xxx while (*textptr != '.') { @@ -3139,41 +3122,41 @@ static int parsecommand(void) } if (*textptr!='.') { - error++; - ReportError(ERROR_SYNTAXERROR); + g_numCompilerErrors++; + C_ReportError(ERROR_SYNTAXERROR); return 0; } textptr++; /// now pointing at 'xxx' - getlabel(); - //printf("found xxx label of '%s'\n", label+(labelcnt<<6)); + C_GetNextLabelName(); + //printf("found xxx label of '%s'\n", label+(g_numLabels<<6)); - lLabelID=getlabelid(walllabels,&wallH,strtolower(label+(labelcnt<<6),Bstrlen(label+(labelcnt<<6)))); + lLabelID=GetLabelNameid(WallLabels,&wallH,strtolower(label+(g_numLabels<<6),Bstrlen(label+(g_numLabels<<6)))); if (lLabelID == -1) { - error++; - ReportError(ERROR_SYMBOLNOTRECOGNIZED); + g_numCompilerErrors++; + C_ReportError(ERROR_SYMBOLNOTRECOGNIZED); return 0; } - bitptr[(scriptptr-script)>>3] &= ~(1<<((scriptptr-script)&7)); - *scriptptr++=lLabelID; + bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); + *g_scriptPtr++=lLabelID; // now at target VAR... // get the ID of the DEF if (tw == CON_GETWALL) - transvartype(GAMEVAR_FLAG_READONLY); + C_GetNextVarType(GAMEVAR_READONLY); else - transvar(); + C_GetNextVar(); break; } case CON_SETPLAYER: - if (!CheckEventSync(current_event)) + if (!C_CheckEventSync(g_currentEvent)) { - ReportError(WARNING_EVENTSYNC); - warning++; + C_ReportError(WARNING_EVENTSYNC); + g_numCompilerWarnings++; } case CON_GETPLAYER: { @@ -3191,9 +3174,9 @@ static int parsecommand(void) textptr++; // get the ID of the DEF - labelsonly = 1; - transvar(); - labelsonly = 0; + g_labelsOnly = 1; + C_GetNextVar(); + g_labelsOnly = 0; // now get name of .xxx while (*textptr != '.') { @@ -3206,34 +3189,34 @@ static int parsecommand(void) } if (*textptr!='.') { - error++; - ReportError(ERROR_SYNTAXERROR); + g_numCompilerErrors++; + C_ReportError(ERROR_SYNTAXERROR); return 0; } textptr++; /// now pointing at 'xxx' - getlabel(); - //printf("found xxx label of '%s'\n", label+(labelcnt<<6)); + C_GetNextLabelName(); + //printf("found xxx label of '%s'\n", label+(g_numLabels<<6)); - lLabelID=getlabeloffset(&playerH,strtolower(label+(labelcnt<<6),Bstrlen(label+(labelcnt<<6)))); + lLabelID=C_GetLabelNameOffset(&playerH,strtolower(label+(g_numLabels<<6),Bstrlen(label+(g_numLabels<<6)))); //printf("LabelID is %d\n",lLabelID); if (lLabelID == -1) { - error++; - ReportError(ERROR_SYMBOLNOTRECOGNIZED); + g_numCompilerErrors++; + C_ReportError(ERROR_SYMBOLNOTRECOGNIZED); return 0; } - bitptr[(scriptptr-script)>>3] &= ~(1<<((scriptptr-script)&7)); - *scriptptr++=playerlabels[lLabelID].lId; + bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); + *g_scriptPtr++=PlayerLabels[lLabelID].lId; - //printf("member's flags are: %02Xh\n",playerlabels[lLabelID].flags); - if (playerlabels[lLabelID].flags & LABEL_HASPARM2) + //printf("member's flags are: %02Xh\n",PlayerLabels[lLabelID].flags); + if (PlayerLabels[lLabelID].flags & LABEL_HASPARM2) { //printf("Member has PARM2\n"); // get parm2 // get the ID of the DEF - transvar(); + C_GetNextVar(); } else { @@ -3244,17 +3227,17 @@ static int parsecommand(void) // get the ID of the DEF if (tw==CON_GETPLAYER) - transvartype(GAMEVAR_FLAG_READONLY); + C_GetNextVarType(GAMEVAR_READONLY); else - transvar(); + C_GetNextVar(); break; } case CON_SETINPUT: - if (!CheckEventSync(current_event)) + if (!C_CheckEventSync(g_currentEvent)) { - ReportError(WARNING_EVENTSYNC); - warning++; + C_ReportError(WARNING_EVENTSYNC); + g_numCompilerWarnings++; } case CON_GETINPUT: { @@ -3272,9 +3255,9 @@ static int parsecommand(void) textptr++; // get the ID of the DEF - labelsonly = 1; - transvar(); - labelsonly = 0; + g_labelsOnly = 1; + C_GetNextVar(); + g_labelsOnly = 0; // now get name of .xxx while (*textptr != '.') { @@ -3287,34 +3270,34 @@ static int parsecommand(void) } if (*textptr!='.') { - error++; - ReportError(ERROR_SYNTAXERROR); + g_numCompilerErrors++; + C_ReportError(ERROR_SYNTAXERROR); return 0; } textptr++; /// now pointing at 'xxx' - getlabel(); - //printf("found xxx label of '%s'\n", label+(labelcnt<<6)); + C_GetNextLabelName(); + //printf("found xxx label of '%s'\n", label+(g_numLabels<<6)); - lLabelID=getlabeloffset(&inputH,strtolower(label+(labelcnt<<6),Bstrlen(label+(labelcnt<<6)))); + lLabelID=C_GetLabelNameOffset(&inputH,strtolower(label+(g_numLabels<<6),Bstrlen(label+(g_numLabels<<6)))); //printf("LabelID is %d\n",lLabelID); if (lLabelID == -1) { - error++; - ReportError(ERROR_SYMBOLNOTRECOGNIZED); + g_numCompilerErrors++; + C_ReportError(ERROR_SYMBOLNOTRECOGNIZED); return 0; } - bitptr[(scriptptr-script)>>3] &= ~(1<<((scriptptr-script)&7)); - *scriptptr++=inputlabels[lLabelID].lId; + bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); + *g_scriptPtr++=InputLabels[lLabelID].lId; // now at target VAR... // get the ID of the DEF if (tw==CON_GETINPUT) - transvartype(GAMEVAR_FLAG_READONLY); + C_GetNextVarType(GAMEVAR_READONLY); else - transvar(); + C_GetNextVar(); break; } @@ -3338,42 +3321,42 @@ static int parsecommand(void) } if (*textptr!='.') { - error++; - ReportError(ERROR_SYNTAXERROR); + g_numCompilerErrors++; + C_ReportError(ERROR_SYNTAXERROR); return 0; } textptr++; /// now pointing at 'xxx' - getlabel(); - //printf("found xxx label of '%s'\n", label+(labelcnt<<6)); + C_GetNextLabelName(); + //printf("found xxx label of '%s'\n", label+(g_numLabels<<6)); - lLabelID=getlabelid(userdefslabels,&userdefH,strtolower(label+(labelcnt<<6),Bstrlen(label+(labelcnt<<6)))); + lLabelID=GetLabelNameid(UserdefsLabels,&userdefH,strtolower(label+(g_numLabels<<6),Bstrlen(label+(g_numLabels<<6)))); if (lLabelID == -1) { - error++; - ReportError(ERROR_SYMBOLNOTRECOGNIZED); + g_numCompilerErrors++; + C_ReportError(ERROR_SYMBOLNOTRECOGNIZED); return 0; } - bitptr[(scriptptr-script)>>3] &= ~(1<<((scriptptr-script)&7)); - *scriptptr++=lLabelID; + bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); + *g_scriptPtr++=lLabelID; // now at target VAR... // get the ID of the DEF if (tw==CON_GETUSERDEF) - transvartype(GAMEVAR_FLAG_READONLY); + C_GetNextVarType(GAMEVAR_READONLY); else - transvar(); + C_GetNextVar(); break; } case CON_SETACTORVAR: case CON_SETPLAYERVAR: - if (!CheckEventSync(current_event)) + if (!C_CheckEventSync(g_currentEvent)) { - ReportError(WARNING_EVENTSYNC); - warning++; + C_ReportError(WARNING_EVENTSYNC); + g_numCompilerWarnings++; } case CON_GETACTORVAR: case CON_GETPLAYERVAR: @@ -3390,9 +3373,9 @@ static int parsecommand(void) textptr++; // get the ID of the DEF - labelsonly = 1; - transvar(); - labelsonly = 0; + g_labelsOnly = 1; + C_GetNextVar(); + g_labelsOnly = 0; // now get name of . while (*textptr != '.') { @@ -3405,28 +3388,28 @@ static int parsecommand(void) } if (*textptr!='.') { - error++; - ReportError(ERROR_SYNTAXERROR); + g_numCompilerErrors++; + C_ReportError(ERROR_SYNTAXERROR); return 0; } textptr++; - if (scriptptr[-1] == g_iThisActorID) // convert to "setvarvar" + if (g_scriptPtr[-1] == g_iThisActorID) // convert to "setvarvar" { - scriptptr--; - scriptptr[-1]=CON_SETVARVAR; + g_scriptPtr--; + g_scriptPtr[-1]=CON_SETVARVAR; if (tw == CON_SETACTORVAR || tw == CON_SETPLAYERVAR) { - transvartype(GAMEVAR_FLAG_READONLY); - transvar(); + C_GetNextVarType(GAMEVAR_READONLY); + C_GetNextVar(); } else { - scriptptr++; - transvar(); - scriptptr-=2; - transvartype(GAMEVAR_FLAG_READONLY); - scriptptr++; + g_scriptPtr++; + C_GetNextVar(); + g_scriptPtr-=2; + C_GetNextVarType(GAMEVAR_READONLY); + g_scriptPtr++; } break; } @@ -3434,30 +3417,30 @@ static int parsecommand(void) /// now pointing at 'xxx' // get the ID of the DEF - getlabel(); - //printf("found label of '%s'\n", label+(labelcnt<<6)); + C_GetNextLabelName(); + //printf("found label of '%s'\n", label+(g_numLabels<<6)); // Check to see if it's a keyword - if (HASH_find(&keywH,label+(labelcnt<<6))>=0) + if (HASH_find(&keywH,label+(g_numLabels<<6))>=0) { - error++; - ReportError(ERROR_ISAKEYWORD); + g_numCompilerErrors++; + C_ReportError(ERROR_ISAKEYWORD); return 0; } - i=GetDefID(label+(labelcnt<<6)); - //printf("Label '%s' ID is %d\n",label+(labelcnt<<6), i); + i=GetDefID(label+(g_numLabels<<6)); + //printf("Label '%s' ID is %d\n",label+(g_numLabels<<6), i); if (i<0) { // not a defined DEF - error++; - ReportError(ERROR_NOTAGAMEVAR); + g_numCompilerErrors++; + C_ReportError(ERROR_NOTAGAMEVAR); return 0; } - if (aGameVars[i].dwFlags & GAMEVAR_FLAG_READONLY) + if (aGameVars[i].dwFlags & GAMEVAR_READONLY) { - error++; - ReportError(ERROR_VARREADONLY); + g_numCompilerErrors++; + C_ReportError(ERROR_VARREADONLY); return 0; } @@ -3466,11 +3449,11 @@ static int parsecommand(void) { case CON_SETACTORVAR: { - if (!(aGameVars[i].dwFlags & GAMEVAR_FLAG_PERACTOR)) + if (!(aGameVars[i].dwFlags & GAMEVAR_PERACTOR)) { - error++; - ReportError(-1); - initprintf("%s:%d: error: variable `%s' is not per-actor.\n",compilefile,line_number,label+(labelcnt<<6)); + g_numCompilerErrors++; + C_ReportError(-1); + initprintf("%s:%d: error: variable `%s' is not per-actor.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); return 0; } @@ -3478,11 +3461,11 @@ static int parsecommand(void) } case CON_SETPLAYERVAR: { - if (!(aGameVars[i].dwFlags & GAMEVAR_FLAG_PERPLAYER)) + if (!(aGameVars[i].dwFlags & GAMEVAR_PERPLAYER)) { - error++; - ReportError(-1); - initprintf("%s:%d: error: variable `%s' is not per-player.\n",compilefile,line_number,label+(labelcnt<<6)); + g_numCompilerErrors++; + C_ReportError(-1); + initprintf("%s:%d: error: variable `%s' is not per-player.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); return 0; } @@ -3490,27 +3473,27 @@ static int parsecommand(void) } } - bitptr[(scriptptr-script)>>3] &= ~(1<<((scriptptr-script)&7)); - *scriptptr++=i; // the ID of the DEF (offset into array...) + bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); + *g_scriptPtr++=i; // the ID of the DEF (offset into array...) switch (tw) { case CON_GETACTORVAR: case CON_GETPLAYERVAR: - transvartype(GAMEVAR_FLAG_READONLY); + C_GetNextVarType(GAMEVAR_READONLY); break; default: - transvar(); + C_GetNextVar(); break; } break; } case CON_SETACTOR: - if (!CheckEventSync(current_event)) + if (!C_CheckEventSync(g_currentEvent)) { - ReportError(WARNING_EVENTSYNC); - warning++; + C_ReportError(WARNING_EVENTSYNC); + g_numCompilerWarnings++; } case CON_GETACTOR: { @@ -3528,9 +3511,9 @@ static int parsecommand(void) textptr++; // get the ID of the DEF - labelsonly = 1; - transvar(); - labelsonly = 0; + g_labelsOnly = 1; + C_GetNextVar(); + g_labelsOnly = 0; // now get name of .xxx while (*textptr != '.') { @@ -3543,34 +3526,34 @@ static int parsecommand(void) } if (*textptr!='.') { - error++; - ReportError(ERROR_SYNTAXERROR); + g_numCompilerErrors++; + C_ReportError(ERROR_SYNTAXERROR); return 0; } textptr++; /// now pointing at 'xxx' - getlabel(); - //printf("found xxx label of '%s'\n", label+(labelcnt<<6)); + C_GetNextLabelName(); + //printf("found xxx label of '%s'\n", label+(g_numLabels<<6)); - lLabelID=getlabeloffset(&actorH,strtolower(label+(labelcnt<<6),Bstrlen(label+(labelcnt<<6)))); + lLabelID=C_GetLabelNameOffset(&actorH,strtolower(label+(g_numLabels<<6),Bstrlen(label+(g_numLabels<<6)))); //printf("LabelID is %d\n",lLabelID); if (lLabelID == -1) { - error++; - ReportError(ERROR_SYMBOLNOTRECOGNIZED); + g_numCompilerErrors++; + C_ReportError(ERROR_SYMBOLNOTRECOGNIZED); return 0; } - bitptr[(scriptptr-script)>>3] &= ~(1<<((scriptptr-script)&7)); - *scriptptr++=actorlabels[lLabelID].lId; + bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); + *g_scriptPtr++=ActorLabels[lLabelID].lId; - //printf("member's flags are: %02Xh\n",actorlabels[lLabelID].flags); - if (actorlabels[lLabelID].flags & LABEL_HASPARM2) + //printf("member's flags are: %02Xh\n",ActorLabels[lLabelID].flags); + if (ActorLabels[lLabelID].flags & LABEL_HASPARM2) { //printf("Member has PARM2\n"); // get parm2 // get the ID of the DEF - transvar(); + C_GetNextVar(); } else { @@ -3581,9 +3564,9 @@ static int parsecommand(void) // get the ID of the DEF if (tw == CON_GETACTOR) - transvartype(GAMEVAR_FLAG_READONLY); + C_GetNextVarType(GAMEVAR_READONLY); else - transvar(); + C_GetNextVar(); break; } @@ -3592,11 +3575,11 @@ static int parsecommand(void) { int lLabelID; - if (current_event != EVENT_ANIMATESPRITES) + if (g_currentEvent != EVENT_ANIMATESPRITES) { - ReportError(-1); - initprintf("%s:%d: warning: found `%s' outside of EVENT_ANIMATESPRITES\n",compilefile,line_number,tempbuf); - warning++; + C_ReportError(-1); + initprintf("%s:%d: warning: found `%s' outside of EVENT_ANIMATESPRITES\n",g_szScriptFileName,g_lineNumber,tempbuf); + g_numCompilerWarnings++; } // syntax getwall[].x @@ -3611,9 +3594,9 @@ static int parsecommand(void) textptr++; // get the ID of the DEF - labelsonly = 1; - transvar(); - labelsonly = 0; + g_labelsOnly = 1; + C_GetNextVar(); + g_labelsOnly = 0; // now get name of .xxx while (*textptr != '.') { @@ -3626,47 +3609,47 @@ static int parsecommand(void) } if (*textptr!='.') { - error++; - ReportError(ERROR_SYNTAXERROR); + g_numCompilerErrors++; + C_ReportError(ERROR_SYNTAXERROR); return 0; } textptr++; /// now pointing at 'xxx' - getlabel(); - //printf("found xxx label of '%s'\n", label+(labelcnt<<6)); + C_GetNextLabelName(); + //printf("found xxx label of '%s'\n", label+(g_numLabels<<6)); - lLabelID=getlabeloffset(&tspriteH,strtolower(label+(labelcnt<<6),Bstrlen(label+(labelcnt<<6)))); + lLabelID=C_GetLabelNameOffset(&tspriteH,strtolower(label+(g_numLabels<<6),Bstrlen(label+(g_numLabels<<6)))); //printf("LabelID is %d\n",lLabelID); if (lLabelID == -1) { - error++; - ReportError(ERROR_SYMBOLNOTRECOGNIZED); + g_numCompilerErrors++; + C_ReportError(ERROR_SYMBOLNOTRECOGNIZED); return 0; } - bitptr[(scriptptr-script)>>3] &= ~(1<<((scriptptr-script)&7)); - *scriptptr++=tsprlabels[lLabelID].lId; + bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); + *g_scriptPtr++=TsprLabels[lLabelID].lId; - //printf("member's flags are: %02Xh\n",actorlabels[lLabelID].flags); + //printf("member's flags are: %02Xh\n",ActorLabels[lLabelID].flags); // now at target VAR... // get the ID of the DEF if (tw == CON_GETTSPR) - transvartype(GAMEVAR_FLAG_READONLY); + C_GetNextVarType(GAMEVAR_READONLY); else - transvar(); + C_GetNextVar(); break; } case CON_GETTICKS: - if (CheckEventSync(current_event)) + if (C_CheckEventSync(g_currentEvent)) { - ReportError(WARNING_REVEVENTSYNC); - warning++; + C_ReportError(WARNING_REVEVENTSYNC); + g_numCompilerWarnings++; } case CON_GETCURRADDRESS: - transvartype(GAMEVAR_FLAG_READONLY); + C_GetNextVarType(GAMEVAR_READONLY); return 0; case CON_ESHOOTVAR: @@ -3681,10 +3664,10 @@ static int parsecommand(void) case CON_LOCKPLAYER: case CON_SHOOTVAR: case CON_QUAKE: - if (!CheckEventSync(current_event)) + if (!C_CheckEventSync(g_currentEvent)) { - ReportError(WARNING_EVENTSYNC); - warning++; + C_ReportError(WARNING_EVENTSYNC); + g_numCompilerWarnings++; } case CON_JUMP: case CON_CMENU: @@ -3703,31 +3686,31 @@ static int parsecommand(void) case CON_CLEARMAPSTATE: case CON_ACTIVATECHEAT: case CON_SETGAMEPALETTE: - transvar(); + C_GetNextVar(); return 0; case CON_ENHANCED: { // don't store in pCode... - scriptptr--; + g_scriptPtr--; //printf("We are enhanced, baby...\n"); - transnum(LABEL_DEFINE); - scriptptr--; - if (*scriptptr > BYTEVERSION_JF) + C_GetNextValue(LABEL_DEFINE); + g_scriptPtr--; + if (*g_scriptPtr > BYTEVERSION_JF) { - warning++; - initprintf("%s:%d: warning: need build %d, found build %d\n",compilefile,line_number,k,BYTEVERSION_JF); + g_numCompilerWarnings++; + initprintf("%s:%d: warning: need build %d, found build %d\n",g_szScriptFileName,g_lineNumber,k,BYTEVERSION_JF); } break; } case CON_DYNAMICREMAP: { - scriptptr--; - if (dynamicremap++) + g_scriptPtr--; + if (g_dynamicTileMapping++) { - initprintf("%s:%d: warning: duplicate dynamicremap statement\n",compilefile,line_number); - warning++; + initprintf("%s:%d: warning: duplicate g_dynamicTileMapping statement\n",g_szScriptFileName,g_lineNumber); + g_numCompilerWarnings++; } else initprintf("Using dynamic tile remapping\n"); break; @@ -3736,10 +3719,10 @@ static int parsecommand(void) case CON_RANDVAR: case CON_ZSHOOT: case CON_EZSHOOT: - if (!CheckEventSync(current_event)) + if (!C_CheckEventSync(g_currentEvent)) { - ReportError(WARNING_EVENTSYNC); - warning++; + C_ReportError(WARNING_EVENTSYNC); + g_numCompilerWarnings++; } case CON_SETVAR: case CON_ADDVAR: @@ -3757,63 +3740,63 @@ static int parsecommand(void) // syntax: [rand|add|set]var // sets var1 to const1 // adds const1 to var1 (const1 can be negative...) - //printf("Found [add|set]var at line= %d\n",line_number); + //printf("Found [add|set]var at line= %d\n",g_lineNumber); // get the ID of the DEF if (tw != CON_ZSHOOT && tw != CON_EZSHOOT) - transvartype(GAMEVAR_FLAG_READONLY); - else transvar(); + C_GetNextVarType(GAMEVAR_READONLY); + else C_GetNextVar(); - transnum(LABEL_DEFINE); // the number to check against... + C_GetNextValue(LABEL_DEFINE); // the number to check against... return 0; case CON_SETARRAY: - getlabel(); - i=GetADefID(label+(labelcnt<<6)); + C_GetNextLabelName(); + i=GetADefID(label+(g_numLabels<<6)); if (i > (-1)) { - bitptr[(scriptptr-script)>>3] &= ~(1<<((scriptptr-script)&7)); - *scriptptr++=i; + bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); + *g_scriptPtr++=i; } else - ReportError(ERROR_NOTAGAMEARRAY); - skipcomments();// skip comments and whitespace + C_ReportError(ERROR_NOTAGAMEARRAY); + C_SkipComments();// skip comments and whitespace if (*textptr != '[') { - error++; - ReportError(ERROR_GAMEARRAYBNO); + g_numCompilerErrors++; + C_ReportError(ERROR_GAMEARRAYBNO); return 1; } textptr++; - transvar(); - skipcomments();// skip comments and whitespace + C_GetNextVar(); + C_SkipComments();// skip comments and whitespace if (*textptr != ']') { - error++; - ReportError(ERROR_GAMEARRAYBNC); + g_numCompilerErrors++; + C_ReportError(ERROR_GAMEARRAYBNC); return 1; } textptr++; - transvar(); + C_GetNextVar(); return 0; case CON_GETARRAYSIZE: case CON_RESIZEARRAY: - getlabel(); - i=GetADefID(label+(labelcnt<<6)); + C_GetNextLabelName(); + i=GetADefID(label+(g_numLabels<<6)); if (i > (-1)) { - bitptr[(scriptptr-script)>>3] &= ~(1<<((scriptptr-script)&7)); - *scriptptr++=i; + bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); + *g_scriptPtr++=i; } else - ReportError(ERROR_NOTAGAMEARRAY); - skipcomments(); - transvar(); + C_ReportError(ERROR_NOTAGAMEARRAY); + C_SkipComments(); + C_GetNextVar(); return 0; case CON_RANDVARVAR: - if (!CheckEventSync(current_event)) + if (!C_CheckEventSync(g_currentEvent)) { - ReportError(WARNING_EVENTSYNC); - warning++; + C_ReportError(WARNING_EVENTSYNC); + g_numCompilerWarnings++; } case CON_SETVARVAR: case CON_ADDVARVAR: @@ -3827,8 +3810,8 @@ static int parsecommand(void) case CON_DISPLAYRANDVARVAR: case CON_SIN: case CON_COS: - transvartype(GAMEVAR_FLAG_READONLY); - transvar(); + C_GetNextVarType(GAMEVAR_READONLY); + C_GetNextVar(); return 0; case CON_SMAXAMMO: @@ -3837,10 +3820,10 @@ static int parsecommand(void) case CON_OPERATESECTORS: case CON_OPERATEACTIVATORS: case CON_SSP: - if (!CheckEventSync(current_event)) + if (!C_CheckEventSync(g_currentEvent)) { - ReportError(WARNING_EVENTSYNC); - warning++; + C_ReportError(WARNING_EVENTSYNC); + g_numCompilerWarnings++; } case CON_GMAXAMMO: case CON_DIST: @@ -3856,17 +3839,17 @@ static int parsecommand(void) case CON_LDIST: case CON_GETANGLE: case CON_GETINCANGLE: - transvartype(GAMEVAR_FLAG_READONLY); + C_GetNextVarType(GAMEVAR_READONLY); break; default: - transvar(); + C_GetNextVar(); break; } // get the ID of the DEF if (tw == CON_GMAXAMMO) - transvartype(GAMEVAR_FLAG_READONLY); - else transvar(); + C_GetNextVarType(GAMEVAR_READONLY); + else C_GetNextVar(); switch (tw) { @@ -3874,10 +3857,10 @@ static int parsecommand(void) case CON_LDIST: case CON_GETANGLE: case CON_GETINCANGLE: - transvar(); + C_GetNextVar(); break; case CON_MULSCALE: - transmultvars(2); + C_GetManyVars(2); break; } return 0; @@ -3889,13 +3872,13 @@ static int parsecommand(void) case CON_DRAGPOINT: case CON_GETKEYNAME: - transmultvars(3); + C_GetManyVars(3); return 0; case CON_GETFLORZOFSLOPE: case CON_GETCEILZOFSLOPE: - transmultvars(3); - transvartype(GAMEVAR_FLAG_READONLY); + C_GetManyVars(3); + C_GetNextVarType(GAMEVAR_READONLY); return 0; case CON_DEFINEPROJECTILE: @@ -3903,61 +3886,61 @@ static int parsecommand(void) int y; signed int z; - if (parsing_state || parsing_actor) + if (g_processingState || g_parsingActorPtr) { - ReportError(ERROR_FOUNDWITHIN); - error++; + C_ReportError(ERROR_FOUNDWITHIN); + g_numCompilerErrors++; } - scriptptr--; + g_scriptPtr--; - transnum(LABEL_DEFINE); - j = *(scriptptr-1); + C_GetNextValue(LABEL_DEFINE); + j = *(g_scriptPtr-1); if (j > MAXTILES-1) { - ReportError(ERROR_EXCEEDSMAXTILES); - error++; + C_ReportError(ERROR_EXCEEDSMAXTILES); + g_numCompilerErrors++; } - transnum(LABEL_DEFINE); - y = *(scriptptr-1); - transnum(LABEL_DEFINE); - z = *(scriptptr-1); + C_GetNextValue(LABEL_DEFINE); + y = *(g_scriptPtr-1); + C_GetNextValue(LABEL_DEFINE); + z = *(g_scriptPtr-1); - DefineProjectile(j,y,z); - spriteflags[j] |= SPRITE_FLAG_PROJECTILE; + C_SetProjectile(j,y,z); + SpriteFlags[j] |= SPRITE_PROJECTILE; return 0; } case CON_SPRITEFLAGS: { - if (parsing_actor == 0 && parsing_state == 0) + if (g_parsingActorPtr == 0 && g_processingState == 0) { - scriptptr--; + g_scriptPtr--; - transnum(LABEL_DEFINE); - scriptptr--; - j = *scriptptr; + C_GetNextValue(LABEL_DEFINE); + g_scriptPtr--; + j = *g_scriptPtr; if (j > MAXTILES-1) { - ReportError(ERROR_EXCEEDSMAXTILES); - error++; + C_ReportError(ERROR_EXCEEDSMAXTILES); + g_numCompilerErrors++; } - transnum(LABEL_DEFINE); - scriptptr--; - spriteflags[j] = *scriptptr; + C_GetNextValue(LABEL_DEFINE); + g_scriptPtr--; + SpriteFlags[j] = *g_scriptPtr; return 0; } - if (!CheckEventSync(current_event)) + if (!C_CheckEventSync(g_currentEvent)) { - ReportError(WARNING_EVENTSYNC); - warning++; + C_ReportError(WARNING_EVENTSYNC); + g_numCompilerWarnings++; } - transvar(); + C_GetNextVar(); return 0; } @@ -3967,53 +3950,53 @@ static int parsecommand(void) case CON_SPRITENOPAL: case CON_PRECACHE: { - if (parsing_state || parsing_actor) + if (g_processingState || g_parsingActorPtr) { - ReportError(ERROR_FOUNDWITHIN); - error++; + C_ReportError(ERROR_FOUNDWITHIN); + g_numCompilerErrors++; } - scriptptr--; + g_scriptPtr--; - transnum(LABEL_DEFINE); - scriptptr--; - j = *scriptptr; + C_GetNextValue(LABEL_DEFINE); + g_scriptPtr--; + j = *g_scriptPtr; if (j > MAXTILES-1) { - ReportError(ERROR_EXCEEDSMAXTILES); - error++; + C_ReportError(ERROR_EXCEEDSMAXTILES); + g_numCompilerErrors++; } switch (tw) { case CON_SPRITESHADOW: - spriteflags[*scriptptr] |= SPRITE_FLAG_SHADOW; + SpriteFlags[*g_scriptPtr] |= SPRITE_SHADOW; break; case CON_SPRITENVG: - spriteflags[*scriptptr] |= SPRITE_FLAG_NVG; + SpriteFlags[*g_scriptPtr] |= SPRITE_NVG; break; case CON_SPRITENOSHADE: - spriteflags[*scriptptr] |= SPRITE_FLAG_NOSHADE; + SpriteFlags[*g_scriptPtr] |= SPRITE_NOSHADE; break; case CON_SPRITENOPAL: - spriteflags[*scriptptr] |= SPRITE_FLAG_NOPAL; + SpriteFlags[*g_scriptPtr] |= SPRITE_NOPAL; break; case CON_PRECACHE: - spritecache[*scriptptr][0] = j; - transnum(LABEL_DEFINE); - scriptptr--; - i = *scriptptr; + SpriteCacheList[*g_scriptPtr][0] = j; + C_GetNextValue(LABEL_DEFINE); + g_scriptPtr--; + i = *g_scriptPtr; if (i > MAXTILES-1) { - ReportError(ERROR_EXCEEDSMAXTILES); - error++; + C_ReportError(ERROR_EXCEEDSMAXTILES); + g_numCompilerErrors++; } - spritecache[j][1] = i; - transnum(LABEL_DEFINE); - scriptptr--; - i = *scriptptr; - spritecache[j][2] = i; + SpriteCacheList[j][1] = i; + C_GetNextValue(LABEL_DEFINE); + g_scriptPtr--; + i = *g_scriptPtr; + SpriteCacheList[j][2] = i; break; } return 0; @@ -4031,19 +4014,19 @@ static int parsecommand(void) { intptr_t offset; - transmultvars(2); - tempscrptr = scriptptr; - offset = (unsigned)(scriptptr-script); - scriptptr++; // Leave a spot for the fail location + C_GetManyVars(2); + tempscrptr = g_scriptPtr; + offset = (unsigned)(g_scriptPtr-script); + g_scriptPtr++; // Leave a spot for the fail location - j = keyword(); - parsecommand(); + j = C_GetKeyword(); + C_ParseCommand(); tempscrptr = (intptr_t *)script+offset; - *tempscrptr = (intptr_t) scriptptr; + *tempscrptr = (intptr_t) g_scriptPtr; bitptr[(tempscrptr-script)>>3] |= (BITPTR_POINTER<<((tempscrptr-script)&7)); - if (tw != CON_WHILEVARVARN) checking_ifelse++; + if (tw != CON_WHILEVARVARN) g_checkingIfElse++; return 0; } @@ -4058,7 +4041,7 @@ static int parsecommand(void) case CON_STARTTRACK: // one parameter (track#) - transnum(LABEL_DEFINE); + C_GetNextValue(LABEL_DEFINE); return 0; case CON_IFVARL: @@ -4074,21 +4057,21 @@ static int parsecommand(void) intptr_t offset; // get the ID of the DEF - transvar(); - transnum(LABEL_DEFINE); // the number to check against... + C_GetNextVar(); + C_GetNextValue(LABEL_DEFINE); // the number to check against... - tempscrptr = scriptptr; + tempscrptr = g_scriptPtr; offset = (unsigned)(tempscrptr-script); - scriptptr++; //Leave a spot for the fail location + g_scriptPtr++; //Leave a spot for the fail location - j = keyword(); - parsecommand(); + j = C_GetKeyword(); + C_ParseCommand(); tempscrptr = (intptr_t *)script+offset; - *tempscrptr = (intptr_t) scriptptr; + *tempscrptr = (intptr_t) g_scriptPtr; bitptr[(tempscrptr-script)>>3] |= (BITPTR_POINTER<<((tempscrptr-script)&7)); - if (tw != CON_WHILEVARN) checking_ifelse++; + if (tw != CON_WHILEVARN) g_checkingIfElse++; return 0; } case CON_ADDLOGVAR: @@ -4096,19 +4079,19 @@ static int parsecommand(void) // syntax: addlogvar // prints the line number in the log file. - /* *scriptptr=line_number; - scriptptr++; */ + /* *g_scriptPtr=g_lineNumber; + g_scriptPtr++; */ // get the ID of the DEF - transvar(); + C_GetNextVar(); return 0; case CON_ROTATESPRITE16: case CON_ROTATESPRITE: - if (parsing_event == 0 && parsing_state == 0) + if (g_parsingEventPtr == 0 && g_processingState == 0) { - ReportError(ERROR_EVENTONLY); - error++; + C_ReportError(ERROR_EVENTONLY); + g_numCompilerErrors++; } // syntax: @@ -4117,65 +4100,65 @@ static int parsecommand(void) // get the ID of the DEFs - transmultvars(12); + C_GetManyVars(12); break; case CON_SHOWVIEW: - if (parsing_event == 0 && parsing_state == 0) + if (g_parsingEventPtr == 0 && g_processingState == 0) { - ReportError(ERROR_EVENTONLY); - error++; + C_ReportError(ERROR_EVENTONLY); + g_numCompilerErrors++; } - transmultvars(10); + C_GetManyVars(10); break; case CON_GETZRANGE: - transmultvars(4); - transmultvarstype(GAMEVAR_FLAG_READONLY,4); - transmultvars(2); + C_GetManyVars(4); + C_GetManyVarsType(GAMEVAR_READONLY,4); + C_GetManyVars(2); break; case CON_HITSCAN: case CON_CANSEE: // get the ID of the DEF - transmultvars(tw==CON_CANSEE?8:7); - transmultvarstype(GAMEVAR_FLAG_READONLY,tw==CON_CANSEE?1:6); - if (tw==CON_HITSCAN) transvar(); + C_GetManyVars(tw==CON_CANSEE?8:7); + C_GetManyVarsType(GAMEVAR_READONLY,tw==CON_CANSEE?1:6); + if (tw==CON_HITSCAN) C_GetNextVar(); break; case CON_CANSEESPR: - transmultvars(2); - transvartype(GAMEVAR_FLAG_READONLY); + C_GetManyVars(2); + C_GetNextVarType(GAMEVAR_READONLY); break; case CON_ROTATEPOINT: case CON_NEARTAG: - transmultvars(5); - transmultvarstype(GAMEVAR_FLAG_READONLY,2); + C_GetManyVars(5); + C_GetManyVarsType(GAMEVAR_READONLY,2); if (tw == CON_NEARTAG) { - transmultvarstype(GAMEVAR_FLAG_READONLY,2); - transmultvars(2); + C_GetManyVarsType(GAMEVAR_READONLY,2); + C_GetManyVars(2); } break; case CON_GETTIMEDATE: - transmultvarstype(GAMEVAR_FLAG_READONLY,8); + C_GetManyVarsType(GAMEVAR_READONLY,8); break; case CON_MOVESPRITE: case CON_SETSPRITE: - if (!CheckEventSync(current_event)) + if (!C_CheckEventSync(g_currentEvent)) { - ReportError(WARNING_EVENTSYNC); - warning++; + C_ReportError(WARNING_EVENTSYNC); + g_numCompilerWarnings++; } - transmultvars(4); + C_GetManyVars(4); if (tw == CON_MOVESPRITE) { - transvar(); - transvartype(GAMEVAR_FLAG_READONLY); + C_GetNextVar(); + C_GetNextVarType(GAMEVAR_READONLY); } break; @@ -4184,55 +4167,55 @@ static int parsecommand(void) case CON_GAMETEXTZ: case CON_DIGITALNUMBER: case CON_DIGITALNUMBERZ: - if (parsing_event == 0 && parsing_state == 0) + if (g_parsingEventPtr == 0 && g_processingState == 0) { - ReportError(ERROR_EVENTONLY); - error++; + C_ReportError(ERROR_EVENTONLY); + g_numCompilerErrors++; } switch (tw) { case CON_GAMETEXTZ: case CON_DIGITALNUMBERZ: - transmultvars(1); + C_GetManyVars(1); case CON_GAMETEXT: case CON_DIGITALNUMBER: - transmultvars(6); + C_GetManyVars(6); default: - transmultvars(5); + C_GetManyVars(5); break; } break; case CON_UPDATESECTOR: case CON_UPDATESECTORZ: - transmultvars(2); + C_GetManyVars(2); if (tw==CON_UPDATESECTORZ) - transvar(); - transvartype(GAMEVAR_FLAG_READONLY); + C_GetNextVar(); + C_GetNextVarType(GAMEVAR_READONLY); break; case CON_MYOS: case CON_MYOSPAL: case CON_MYOSX: case CON_MYOSPALX: - if (parsing_event == 0 && parsing_state == 0) + if (g_parsingEventPtr == 0 && g_processingState == 0) { - ReportError(ERROR_EVENTONLY); - error++; + C_ReportError(ERROR_EVENTONLY); + g_numCompilerErrors++; } // syntax: // int x, int y, short tilenum, signed char shade, char orientation // myospal adds char pal - transmultvars(5); + C_GetManyVars(5); if (tw==CON_MYOSPAL || tw==CON_MYOSPALX) { // Parse: pal // get the ID of the DEF - transvar(); + C_GetNextVar(); } break; @@ -4244,7 +4227,7 @@ static int parsecommand(void) // gets rand (not game rand) into // Get The ID of the DEF - transvartype(GAMEVAR_FLAG_READONLY); + C_GetNextVarType(GAMEVAR_READONLY); break; case CON_SWITCH: @@ -4252,42 +4235,42 @@ static int parsecommand(void) intptr_t tempoffset; //AddLog("Got Switch statement"); - if (checking_switch) + if (g_checkingSwitch) { - // Bsprintf(g_szBuf,"ERROR::%s %d: Checking_switch=",__FILE__,__LINE__, checking_switch); + // Bsprintf(g_szBuf,"ERROR::%s %d: g_checkingSwitch=",__FILE__,__LINE__, g_checkingSwitch); // AddLog(g_szBuf); } - checking_switch++; // allow nesting (if other things work) + g_checkingSwitch++; // allow nesting (if other things work) // Get The ID of the DEF - transvar(); + C_GetNextVar(); - tempscrptr= scriptptr; + tempscrptr= g_scriptPtr; tempoffset = (unsigned)(tempscrptr-script); - bitptr[(scriptptr-script)>>3] &= ~(1<<((scriptptr-script)&7)); - *scriptptr++=0; // leave spot for end location (for after processing) - bitptr[(scriptptr-script)>>3] &= ~(1<<((scriptptr-script)&7)); - *scriptptr++=0; // count of case statements - casescriptptr=scriptptr; // the first case's pointer. - bitptr[(scriptptr-script)>>3] &= ~(1<<((scriptptr-script)&7)); - *scriptptr++=0; // leave spot for 'default' location (null if none) + bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); + *g_scriptPtr++=0; // leave spot for end location (for after processing) + bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); + *g_scriptPtr++=0; // count of case statements + g_caseScriptPtr=g_scriptPtr; // the first case's pointer. + bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); + *g_scriptPtr++=0; // leave spot for 'default' location (null if none) - j = keyword(); + j = C_GetKeyword(); temptextptr=textptr; // probably does not allow nesting... //AddLog("Counting Case Statements..."); - j=CountCaseStatements(); -// initprintf("Done Counting Case Statements for switch %d: found %d.\n", checking_switch,j); - scriptptr+=j*2; - skipcomments(); - scriptptr-=j*2; // allocate buffer for the table + j=C_CountCaseStatements(); +// initprintf("Done Counting Case Statements for switch %d: found %d.\n", g_checkingSwitch,j); + g_scriptPtr+=j*2; + C_SkipComments(); + g_scriptPtr-=j*2; // allocate buffer for the table tempscrptr = (intptr_t *)(script+tempoffset); //AddLog(g_szBuf); - if (checking_switch>1) + if (g_checkingSwitch>1) { - // Bsprintf(g_szBuf,"ERROR::%s %d: Checking_switch=",__FILE__,__LINE__, checking_switch); + // Bsprintf(g_szBuf,"ERROR::%s %d: g_checkingSwitch=",__FILE__,__LINE__, g_checkingSwitch); // AddLog(g_szBuf); } if (j<0) @@ -4307,18 +4290,18 @@ static int parsecommand(void) while (j--) { // leave room for statements - bitptr[(scriptptr-script)>>3] &= ~(1<<((scriptptr-script)&7)); - *scriptptr++=0; // value check - bitptr[(scriptptr-script)>>3] &= ~(1<<((scriptptr-script)&7)); - *scriptptr++=0; // code offset - skipcomments(); + bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); + *g_scriptPtr++=0; // value check + bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); + *g_scriptPtr++=0; // code offset + C_SkipComments(); } //Bsprintf(g_szBuf,"SWITCH1: '%.22s'",textptr); //AddLog(g_szBuf); - casecount=0; - while (parsecommand() == 0) + g_numCases=0; + while (C_ParseCommand() == 0) { //Bsprintf(g_szBuf,"SWITCH2: '%.22s'",textptr); //AddLog(g_szBuf); @@ -4328,12 +4311,12 @@ static int parsecommand(void) //Bsprintf(g_szBuf,"SWITCHXX: '%.22s'",textptr); //AddLog(g_szBuf); // done processing switch. clean up. - if (checking_switch<1) + if (g_checkingSwitch<1) { - // Bsprintf(g_szBuf,"ERROR::%s %d: Checking_switch=%d",__FILE__,__LINE__, checking_switch); + // Bsprintf(g_szBuf,"ERROR::%s %d: g_checkingSwitch=%d",__FILE__,__LINE__, g_checkingSwitch); // AddLog(g_szBuf); } - casecount=0; + g_numCases=0; if (tempscrptr) { intptr_t t,n; @@ -4349,7 +4332,7 @@ static int parsecommand(void) } } // for (j=3;j<3+tempscrptr[1]*2;j+=2)initprintf("%5d %8x\n",tempscrptr[j],tempscrptr[j+1]); - tempscrptr[0]= (intptr_t)scriptptr - (intptr_t)&script[0]; // save 'end' location + tempscrptr[0]= (intptr_t)g_scriptPtr - (intptr_t)&script[0]; // save 'end' location // bitptr[(tempscrptr-script)>>3] |= (BITPTR_POINTER<<((tempscrptr-script)&7)); } else @@ -4357,13 +4340,13 @@ static int parsecommand(void) //Bsprintf(g_szBuf,"ERROR::%s %d",__FILE__,__LINE__); //AddLog(g_szBuf); } - casescriptptr=NULL; + g_caseScriptPtr=NULL; // decremented in endswitch. Don't decrement here... - // checking_switch--; // allow nesting (maybe if other things work) + // g_checkingSwitch--; // allow nesting (maybe if other things work) tempscrptr=NULL; - if (checking_switch) + if (g_checkingSwitch) { - //Bsprintf(g_szBuf,"ERROR::%s %d: Checking_switch=%d",__FILE__,__LINE__, checking_switch); + //Bsprintf(g_szBuf,"ERROR::%s %d: g_checkingSwitch=%d",__FILE__,__LINE__, g_checkingSwitch); //AddLog(g_szBuf); } //AddLog("End of Switch statement"); @@ -4375,62 +4358,62 @@ static int parsecommand(void) intptr_t tempoffset = 0; //AddLog("Found Case"); repeatcase: - scriptptr--; // don't save in code - if (checking_switch<1) + g_scriptPtr--; // don't save in code + if (g_checkingSwitch<1) { - error++; - ReportError(-1); - initprintf("%s:%d: error: found `case' statement when not in switch\n",compilefile,line_number); + g_numCompilerErrors++; + C_ReportError(-1); + initprintf("%s:%d: error: found `case' statement when not in switch\n",g_szScriptFileName,g_lineNumber); return 1; } - casecount++; + g_numCases++; //Bsprintf(g_szBuf,"case1: %.12s",textptr); //AddLog(g_szBuf); - transnum(LABEL_DEFINE); + C_GetNextValue(LABEL_DEFINE); if (*textptr == ':') textptr++; //Bsprintf(g_szBuf,"case2: %.12s",textptr); //AddLog(g_szBuf); - j=*(--scriptptr); // get value - //Bsprintf(g_szBuf,"case: Value of case %d is %d",(int)casecount,(int)j); + j=*(--g_scriptPtr); // get value + //Bsprintf(g_szBuf,"case: Value of case %d is %d",(int)g_numCases,(int)j); //AddLog(g_szBuf); - if (casescriptptr) + if (g_caseScriptPtr) { - for (i=(casecount/2)-1;i>=0;i--) - if (casescriptptr[i*2+1]==j) + for (i=(g_numCases/2)-1;i>=0;i--) + if (g_caseScriptPtr[i*2+1]==j) { - warning++; - ReportError(WARNING_DUPLICATECASE); + g_numCompilerWarnings++; + C_ReportError(WARNING_DUPLICATECASE); break; } //AddLog("Adding value to script"); - casescriptptr[casecount++]=j; // save value - casescriptptr[casecount]=(intptr_t)((intptr_t*)scriptptr-&script[0]); // save offset + g_caseScriptPtr[g_numCases++]=j; // save value + g_caseScriptPtr[g_numCases]=(intptr_t)((intptr_t*)g_scriptPtr-&script[0]); // save offset } - // j = keyword(); + // j = C_GetKeyword(); //Bsprintf(g_szBuf,"case3: %.12s",textptr); //AddLog(g_szBuf); - j = keyword(); + j = C_GetKeyword(); if (j == CON_CASE) { //AddLog("Found Repeat Case"); - transword(); // eat 'case' + C_GetNextKeyword(); // eat 'case' goto repeatcase; } //Bsprintf(g_szBuf,"case4: '%.12s'",textptr); //AddLog(g_szBuf); tempoffset = (unsigned)(tempscrptr-script); - while (parsecommand() == 0) + while (C_ParseCommand() == 0) { //Bsprintf(g_szBuf,"case5 '%.25s'",textptr); //AddLog(g_szBuf); - j = keyword(); + j = C_GetKeyword(); if (j == CON_CASE) { //AddLog("Found Repeat Case"); - transword(); // eat 'case' + C_GetNextKeyword(); // eat 'case' tempscrptr = (intptr_t *)(script+tempoffset); goto repeatcase; } @@ -4441,29 +4424,29 @@ repeatcase: // break; } case CON_DEFAULT: - scriptptr--; // don't save - if (checking_switch<1) + g_scriptPtr--; // don't save + if (g_checkingSwitch<1) { - error++; - ReportError(-1); - initprintf("%s:%d: error: found `default' statement when not in switch\n",compilefile,line_number); + g_numCompilerErrors++; + C_ReportError(-1); + initprintf("%s:%d: error: found `default' statement when not in switch\n",g_szScriptFileName,g_lineNumber); return 1; } - if (casescriptptr && casescriptptr[0]!=0) + if (g_caseScriptPtr && g_caseScriptPtr[0]!=0) { // duplicate default statement - error++; - ReportError(-1); - initprintf("%s:%d: error: multiple `default' statements found in switch\n",compilefile,line_number); + g_numCompilerErrors++; + C_ReportError(-1); + initprintf("%s:%d: error: multiple `default' statements found in switch\n",g_szScriptFileName,g_lineNumber); } - if (casescriptptr) + if (g_caseScriptPtr) { - casescriptptr[0]=(intptr_t)(scriptptr-&script[0]); // save offset -// bitptr[(casescriptptr-script)>>3] |= (BITPTR_POINTER<<((casescriptptr-script)&7)); + g_caseScriptPtr[0]=(intptr_t)(g_scriptPtr-&script[0]); // save offset +// bitptr[(g_caseScriptPtr-script)>>3] |= (BITPTR_POINTER<<((g_caseScriptPtr-script)&7)); } //Bsprintf(g_szBuf,"default: '%.22s'",textptr); //AddLog(g_szBuf); - while (parsecommand() == 0) + while (C_ParseCommand() == 0) { //Bsprintf(g_szBuf,"defaultParse: '%.22s'",textptr); //AddLog(g_szBuf); @@ -4473,12 +4456,12 @@ repeatcase: case CON_ENDSWITCH: //AddLog("End Switch"); - checking_switch--; - if (checking_switch < 0) + g_checkingSwitch--; + if (g_checkingSwitch < 0) { - error++; - ReportError(-1); - initprintf("%s:%d: error: found `endswitch' without matching `switch'\n",compilefile,line_number); + g_numCompilerErrors++; + C_ReportError(-1); + initprintf("%s:%d: error: found `endswitch' without matching `switch'\n",g_szScriptFileName,g_lineNumber); } return 1; // end of block break; @@ -4487,10 +4470,10 @@ repeatcase: case CON_CHANGESPRITESECT: case CON_ZSHOOTVAR: case CON_EZSHOOTVAR: - if (!CheckEventSync(current_event)) + if (!C_CheckEventSync(g_currentEvent)) { - warning++; - ReportError(WARNING_EVENTSYNC); + g_numCompilerWarnings++; + C_ReportError(WARNING_EVENTSYNC); } case CON_GETPNAME: case CON_STARTLEVEL: @@ -4504,17 +4487,17 @@ repeatcase: case CON_HEADSPRITESECT: case CON_PREVSPRITESECT: case CON_NEXTSPRITESECT: - transmultvars(2); + C_GetManyVars(2); return 0; case CON_QSUBSTR: - transmultvars(4); + C_GetManyVars(4); return 0; case CON_SETACTORANGLE: case CON_SETPLAYERANGLE: - if (!CheckEventSync(current_event)) + if (!C_CheckEventSync(g_currentEvent)) { - warning++; - ReportError(WARNING_EVENTSYNC); + g_numCompilerWarnings++; + C_ReportError(WARNING_EVENTSYNC); } case CON_GETANGLETOTARGET: case CON_GETACTORANGLE: @@ -4522,23 +4505,23 @@ repeatcase: // Syntax: // get the ID of the DEF - transvar(); + C_GetNextVar(); return 0; case CON_ADDLOG: // syntax: addlog // prints the line number in the log file. - /* *scriptptr=line_number; - scriptptr++; */ + /* *g_scriptPtr=g_lineNumber; + g_scriptPtr++; */ return 0; case CON_IFPINVENTORY: case CON_IFRND: - if (!CheckEventSync(current_event)) + if (!C_CheckEventSync(g_currentEvent)) { - ReportError(WARNING_EVENTSYNC); - warning++; + C_ReportError(WARNING_EVENTSYNC); + g_numCompilerWarnings++; } case CON_IFPDISTL: case CON_IFPDISTG: @@ -4563,32 +4546,32 @@ repeatcase: switch (tw) { case CON_IFAI: - transnum(LABEL_AI); + C_GetNextValue(LABEL_AI); break; case CON_IFACTION: - transnum(LABEL_ACTION); + C_GetNextValue(LABEL_ACTION); break; case CON_IFMOVE: - if ((transnum(LABEL_MOVE|LABEL_DEFINE) == 0) && (*(scriptptr-1) != 0) && (*(scriptptr-1) != 1)) + if ((C_GetNextValue(LABEL_MOVE|LABEL_DEFINE) == 0) && (*(g_scriptPtr-1) != 0) && (*(g_scriptPtr-1) != 1)) { - ReportError(-1); - *(scriptptr-1) = 0; - initprintf("%s:%d: warning: expected a move, found a constant.\n",compilefile,line_number); - warning++; + C_ReportError(-1); + *(g_scriptPtr-1) = 0; + initprintf("%s:%d: warning: expected a move, found a constant.\n",g_szScriptFileName,g_lineNumber); + g_numCompilerWarnings++; } break; case CON_IFPINVENTORY: - transnum(LABEL_DEFINE); - transnum(LABEL_DEFINE); + C_GetNextValue(LABEL_DEFINE); + C_GetNextValue(LABEL_DEFINE); break; case CON_IFSOUND: - if (CheckEventSync(current_event)) + if (C_CheckEventSync(g_currentEvent)) { - ReportError(WARNING_REVEVENTSYNC); - warning++; + C_ReportError(WARNING_REVEVENTSYNC); + g_numCompilerWarnings++; } default: - transnum(LABEL_DEFINE); + C_GetNextValue(LABEL_DEFINE); break; } @@ -4619,76 +4602,76 @@ repeatcase: j = 0; do { - transnum(LABEL_DEFINE); - scriptptr--; - j |= *scriptptr; + C_GetNextValue(LABEL_DEFINE); + g_scriptPtr--; + j |= *g_scriptPtr; } - while (keyword() == -1); - bitptr[(scriptptr-script)>>3] &= ~(1<<((scriptptr-script)&7)); - *scriptptr = j; - scriptptr++; + while (C_GetKeyword() == -1); + bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); + *g_scriptPtr = j; + g_scriptPtr++; } - tempscrptr = scriptptr; + tempscrptr = g_scriptPtr; offset = (unsigned)(tempscrptr-script); - scriptptr++; //Leave a spot for the fail location + g_scriptPtr++; //Leave a spot for the fail location - j = keyword(); - parsecommand(); + j = C_GetKeyword(); + C_ParseCommand(); tempscrptr = (intptr_t *)script+offset; - *tempscrptr = (intptr_t) scriptptr; + *tempscrptr = (intptr_t) g_scriptPtr; bitptr[(tempscrptr-script)>>3] |= (BITPTR_POINTER<<((tempscrptr-script)&7)); - checking_ifelse++; + g_checkingIfElse++; return 0; } case CON_LEFTBRACE: - if (!(parsing_state || parsing_actor || parsing_event)) + if (!(g_processingState || g_parsingActorPtr || g_parsingEventPtr)) { - error++; - ReportError(ERROR_SYNTAXERROR); + g_numCompilerErrors++; + C_ReportError(ERROR_SYNTAXERROR); } - num_braces++; + g_numBraces++; do - done = parsecommand(); + done = C_ParseCommand(); while (done == 0); return 0; case CON_RIGHTBRACE: - num_braces--; - if (num_braces < 0) + g_numBraces--; + if (g_numBraces < 0) { - if (checking_switch) + if (g_checkingSwitch) { - ReportError(ERROR_NOENDSWITCH); + C_ReportError(ERROR_NOENDSWITCH); } - ReportError(-1); - initprintf("%s:%d: error: found more `}' than `{'.\n",compilefile,line_number); - error++; + C_ReportError(-1); + initprintf("%s:%d: error: found more `}' than `{'.\n",g_szScriptFileName,g_lineNumber); + g_numCompilerErrors++; } return 1; case CON_BETANAME: - scriptptr--; + g_scriptPtr--; j = 0; while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) textptr++; return 0; case CON_DEFINEVOLUMENAME: - scriptptr--; + g_scriptPtr--; - transnum(LABEL_DEFINE); - scriptptr--; - j = *scriptptr; + C_GetNextValue(LABEL_DEFINE); + g_scriptPtr--; + j = *g_scriptPtr; while (*textptr == ' ' || *textptr == '\t') textptr++; if (j < 0 || j > MAXVOLUMES-1) { - initprintf("%s:%d: error: volume number exceeds maximum volume count.\n",compilefile,line_number); - error++; + initprintf("%s:%d: error: volume number exceeds maximum volume count.\n",g_szScriptFileName,g_lineNumber); + g_numCompilerErrors++; while (*textptr != 0x0a && *textptr != 0) textptr++; break; } @@ -4697,31 +4680,31 @@ repeatcase: while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) { - volume_names[j][i] = toupper(*textptr); + EpisodeNames[j][i] = toupper(*textptr); textptr++,i++; - if (i >= (signed)sizeof(volume_names[j])-1) + if (i >= (signed)sizeof(EpisodeNames[j])-1) { - initprintf("%s:%d: error: volume name exceeds limit of %d characters.\n",compilefile,line_number,sizeof(volume_names[j])-1); - error++; + initprintf("%s:%d: error: volume name exceeds limit of %d characters.\n",g_szScriptFileName,g_lineNumber,sizeof(EpisodeNames[j])-1); + g_numCompilerErrors++; while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) textptr++; break; } } - num_volumes = j+1; - volume_names[j][i] = '\0'; + g_numVolumes = j+1; + EpisodeNames[j][i] = '\0'; return 0; case CON_DEFINEGAMEFUNCNAME: - scriptptr--; - transnum(LABEL_DEFINE); - scriptptr--; - j = *scriptptr; + g_scriptPtr--; + C_GetNextValue(LABEL_DEFINE); + g_scriptPtr--; + j = *g_scriptPtr; while (*textptr == ' ' || *textptr == '\t') textptr++; if (j < 0 || j > NUMGAMEFUNCTIONS-1) { - initprintf("%s:%d: error: function number exceeds number of game functions.\n",compilefile,line_number); - error++; + initprintf("%s:%d: error: function number exceeds number of game functions.\n",g_szScriptFileName,g_lineNumber); + g_numCompilerErrors++; while (*textptr != 0x0a && *textptr != 0) textptr++; break; } @@ -4735,15 +4718,15 @@ repeatcase: textptr++,i++; if (*textptr == '/' || *textptr == ' ') { - initprintf("%s:%d: warning: invalid character in function name.\n",compilefile,line_number); - warning++; + initprintf("%s:%d: warning: invalid character in function name.\n",g_szScriptFileName,g_lineNumber); + g_numCompilerWarnings++; while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) textptr++; break; } if (i >= MAXGAMEFUNCLEN-1) { - initprintf("%s:%d: warning: function name exceeds limit of %d characters, truncating.\n",compilefile,line_number,MAXGAMEFUNCLEN); - warning++; + initprintf("%s:%d: warning: function name exceeds limit of %d characters, truncating.\n",g_szScriptFileName,g_lineNumber,MAXGAMEFUNCLEN); + g_numCompilerWarnings++; while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) textptr++; break; } @@ -4754,17 +4737,17 @@ repeatcase: return 0; case CON_DEFINESKILLNAME: - scriptptr--; + g_scriptPtr--; - transnum(LABEL_DEFINE); - scriptptr--; - j = *scriptptr; + C_GetNextValue(LABEL_DEFINE); + g_scriptPtr--; + j = *g_scriptPtr; while (*textptr == ' ' || *textptr == '\t') textptr++; if (j < 0 || j > 4) { - initprintf("%s:%d: error: skill number exceeds maximum skill count.\n",compilefile,line_number); - error++; + initprintf("%s:%d: error: skill number exceeds maximum skill count.\n",g_szScriptFileName,g_lineNumber); + g_numCompilerErrors++; while (*textptr != 0x0a && *textptr != 0) textptr++; break; } @@ -4773,23 +4756,23 @@ repeatcase: while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) { - skill_names[j][i] = toupper(*textptr); + SkillNames[j][i] = toupper(*textptr); textptr++,i++; - if (i >= (signed)sizeof(skill_names[j])-1) + if (i >= (signed)sizeof(SkillNames[j])-1) { - initprintf("%s:%d: error: skill name exceeds limit of %d characters.\n",compilefile,line_number,sizeof(skill_names[j])-1); - error++; + initprintf("%s:%d: error: skill name exceeds limit of %d characters.\n",g_szScriptFileName,g_lineNumber,sizeof(SkillNames[j])-1); + g_numCompilerErrors++; while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) textptr++; break; } } - skill_names[j][i] = '\0'; + SkillNames[j][i] = '\0'; return 0; case CON_SETGAMENAME: { char gamename[32]; - scriptptr--; + g_scriptPtr--; while (*textptr == ' ' || *textptr == '\t') textptr++; @@ -4801,8 +4784,8 @@ repeatcase: textptr++,i++; if (i >= (signed)sizeof(gamename)-1) { - initprintf("%s:%d: error: game name exceeds limit of %d characters.\n",compilefile,line_number,sizeof(gamename)-1); - error++; + initprintf("%s:%d: error: game name exceeds limit of %d characters.\n",g_szScriptFileName,g_lineNumber,sizeof(gamename)-1); + g_numCompilerErrors++; while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) textptr++; break; } @@ -4816,10 +4799,10 @@ repeatcase: case CON_SETDEFNAME: { - scriptptr--; + g_scriptPtr--; while (isaltok(*textptr) == 0) { - if (*textptr == 0x0a) line_number++; + if (*textptr == 0x0a) g_lineNumber++; textptr++; if (*textptr == 0) break; } @@ -4837,10 +4820,10 @@ repeatcase: case CON_SETCFGNAME: { - scriptptr--; + g_scriptPtr--; while (isaltok(*textptr) == 0) { - if (*textptr == 0x0a) line_number++; + if (*textptr == 0x0a) g_lineNumber++; textptr++; if (*textptr == 0) break; } @@ -4888,64 +4871,64 @@ repeatcase: return 0; case CON_DEFINEGAMETYPE: - scriptptr--; - transnum(LABEL_DEFINE); - scriptptr--; - j = *scriptptr; + g_scriptPtr--; + C_GetNextValue(LABEL_DEFINE); + g_scriptPtr--; + j = *g_scriptPtr; - transnum(LABEL_DEFINE); - scriptptr--; - gametype_flags[j] = *scriptptr; + C_GetNextValue(LABEL_DEFINE); + g_scriptPtr--; + GametypeFlags[j] = *g_scriptPtr; while (*textptr == ' ' || *textptr == '\t') textptr++; if (j < 0 || j > MAXGAMETYPES-1) { - initprintf("%s:%d: error: gametype number exceeds maximum gametype count.\n",compilefile,line_number); - error++; + initprintf("%s:%d: error: gametype number exceeds maximum gametype count.\n",g_szScriptFileName,g_lineNumber); + g_numCompilerErrors++; while (*textptr != 0x0a && *textptr != 0) textptr++; break; } - num_gametypes = j+1; + g_numGametypes = j+1; i = 0; while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) { - gametype_names[j][i] = toupper(*textptr); + GametypeNames[j][i] = toupper(*textptr); textptr++,i++; - if (i >= (signed)sizeof(gametype_names[j])-1) + if (i >= (signed)sizeof(GametypeNames[j])-1) { - initprintf("%s:%d: error: gametype name exceeds limit of %d characters.\n",compilefile,line_number,sizeof(gametype_names[j])-1); - error++; + initprintf("%s:%d: error: gametype name exceeds limit of %d characters.\n",g_szScriptFileName,g_lineNumber,sizeof(GametypeNames[j])-1); + g_numCompilerErrors++; while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) textptr++; break; } } - gametype_names[j][i] = '\0'; + GametypeNames[j][i] = '\0'; return 0; case CON_DEFINELEVELNAME: - scriptptr--; - transnum(LABEL_DEFINE); - scriptptr--; - j = *scriptptr; - transnum(LABEL_DEFINE); - scriptptr--; - k = *scriptptr; + g_scriptPtr--; + C_GetNextValue(LABEL_DEFINE); + g_scriptPtr--; + j = *g_scriptPtr; + C_GetNextValue(LABEL_DEFINE); + g_scriptPtr--; + k = *g_scriptPtr; while (*textptr == ' ' || *textptr == '\t') textptr++; if (j < 0 || j > MAXVOLUMES-1) { - initprintf("%s:%d: error: volume number exceeds maximum volume count.\n",compilefile,line_number); - error++; + initprintf("%s:%d: error: volume number exceeds maximum volume count.\n",g_szScriptFileName,g_lineNumber); + g_numCompilerErrors++; while (*textptr != 0x0a && *textptr != 0) textptr++; break; } if (k < 0 || k > MAXLEVELS-1) { - initprintf("%s:%d: error: level number exceeds maximum number of levels per episode.\n",compilefile,line_number); - error++; + initprintf("%s:%d: error: level number exceeds maximum number of levels per episode.\n",g_szScriptFileName,g_lineNumber); + g_numCompilerErrors++; while (*textptr != 0x0a && *textptr != 0) textptr++; break; } @@ -4960,8 +4943,8 @@ repeatcase: textptr++,i++; if (i >= BMAX_PATH) { - initprintf("%s:%d: error: level file name exceeds limit of %d characters.\n",compilefile,line_number,BMAX_PATH); - error++; + initprintf("%s:%d: error: level file name exceeds limit of %d characters.\n",g_szScriptFileName,g_lineNumber,BMAX_PATH); + g_numCompilerErrors++; while (*textptr != ' ' && *textptr != '\t') textptr++; break; } @@ -4970,25 +4953,25 @@ repeatcase: Bcorrectfilename(tempbuf,0); - if (map[j*MAXLEVELS+k].filename == NULL) - map[j*MAXLEVELS+k].filename = Bcalloc(Bstrlen(tempbuf)+1,sizeof(char)); - else if ((Bstrlen(tempbuf)+1) > sizeof(map[j*MAXLEVELS+k].filename)) - map[j*MAXLEVELS+k].filename = Brealloc(map[j*MAXLEVELS+k].filename,(Bstrlen(tempbuf)+1)); + if (MapInfo[j*MAXLEVELS+k].filename == NULL) + MapInfo[j*MAXLEVELS+k].filename = Bcalloc(Bstrlen(tempbuf)+1,sizeof(char)); + else if ((Bstrlen(tempbuf)+1) > sizeof(MapInfo[j*MAXLEVELS+k].filename)) + MapInfo[j*MAXLEVELS+k].filename = Brealloc(MapInfo[j*MAXLEVELS+k].filename,(Bstrlen(tempbuf)+1)); /* initprintf("level file name string len: %d\n",Bstrlen(tempbuf)); */ - Bstrcpy(map[j*MAXLEVELS+k].filename,tempbuf); + Bstrcpy(MapInfo[j*MAXLEVELS+k].filename,tempbuf); while (*textptr == ' ' || *textptr == '\t') textptr++; - map[j*MAXLEVELS+k].partime = + MapInfo[j*MAXLEVELS+k].partime = (((*(textptr+0)-'0')*10+(*(textptr+1)-'0'))*26*60)+ (((*(textptr+3)-'0')*10+(*(textptr+4)-'0'))*26); textptr += 5; while (*textptr == ' ' || *textptr == '\t') textptr++; - map[j*MAXLEVELS+k].designertime = + MapInfo[j*MAXLEVELS+k].designertime = (((*(textptr+0)-'0')*10+(*(textptr+1)-'0'))*26*60)+ (((*(textptr+3)-'0')*10+(*(textptr+4)-'0'))*26); @@ -5003,8 +4986,8 @@ repeatcase: textptr++,i++; if (i >= 32) { - initprintf("%s:%d: error: level name exceeds limit of %d characters.\n",compilefile,line_number,32); - error++; + initprintf("%s:%d: error: level name exceeds limit of %d characters.\n",g_szScriptFileName,g_lineNumber,32); + g_numCompilerErrors++; while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) textptr++; break; } @@ -5012,14 +4995,14 @@ repeatcase: tempbuf[i] = '\0'; - if (map[j*MAXLEVELS+k].name == NULL) - map[j*MAXLEVELS+k].name = Bcalloc(Bstrlen(tempbuf)+1,sizeof(char)); - else if ((Bstrlen(tempbuf)+1) > sizeof(map[j*MAXLEVELS+k].name)) - map[j*MAXLEVELS+k].name = Brealloc(map[j*MAXLEVELS+k].name,(Bstrlen(tempbuf)+1)); + if (MapInfo[j*MAXLEVELS+k].name == NULL) + MapInfo[j*MAXLEVELS+k].name = Bcalloc(Bstrlen(tempbuf)+1,sizeof(char)); + else if ((Bstrlen(tempbuf)+1) > sizeof(MapInfo[j*MAXLEVELS+k].name)) + MapInfo[j*MAXLEVELS+k].name = Brealloc(MapInfo[j*MAXLEVELS+k].name,(Bstrlen(tempbuf)+1)); /* initprintf("level name string len: %d\n",Bstrlen(tempbuf)); */ - Bstrcpy(map[j*MAXLEVELS+k].name,tempbuf); + Bstrcpy(MapInfo[j*MAXLEVELS+k].name,tempbuf); return 0; @@ -5027,30 +5010,30 @@ repeatcase: case CON_REDEFINEQUOTE: if (tw == CON_DEFINEQUOTE) { - scriptptr--; + g_scriptPtr--; } - transnum(LABEL_DEFINE); + C_GetNextValue(LABEL_DEFINE); - k = *(scriptptr-1); + k = *(g_scriptPtr-1); if (k >= MAXQUOTES) { - initprintf("%s:%d: error: quote number exceeds limit of %d.\n",compilefile,line_number,MAXQUOTES); - error++; + initprintf("%s:%d: error: quote number exceeds limit of %d.\n",g_szScriptFileName,g_lineNumber,MAXQUOTES); + g_numCompilerErrors++; } - if (fta_quotes[k] == NULL) - fta_quotes[k] = Bcalloc(MAXQUOTELEN,sizeof(char)); - if (!fta_quotes[k]) + if (ScriptQuotes[k] == NULL) + ScriptQuotes[k] = Bcalloc(MAXQUOTELEN,sizeof(char)); + if (!ScriptQuotes[k]) { - fta_quotes[k] = NULL; + ScriptQuotes[k] = NULL; Bsprintf(tempbuf,"Failed allocating %" PRIdPTR " byte quote text buffer.",sizeof(char) * MAXQUOTELEN); - gameexit(tempbuf); + G_GameExit(tempbuf); } if (tw == CON_DEFINEQUOTE) - scriptptr--; + g_scriptPtr--; i = 0; @@ -5059,13 +5042,13 @@ repeatcase: if (tw == CON_REDEFINEQUOTE) { - if (redefined_quotes[redefined_quote_count] == NULL) - redefined_quotes[redefined_quote_count] = Bcalloc(MAXQUOTELEN,sizeof(char)); - if (!redefined_quotes[redefined_quote_count]) + if (ScriptQuoteRedefinitions[g_numQuoteRedefinitions] == NULL) + ScriptQuoteRedefinitions[g_numQuoteRedefinitions] = Bcalloc(MAXQUOTELEN,sizeof(char)); + if (!ScriptQuoteRedefinitions[g_numQuoteRedefinitions]) { - redefined_quotes[redefined_quote_count] = NULL; + ScriptQuoteRedefinitions[g_numQuoteRedefinitions] = NULL; Bsprintf(tempbuf,"Failed allocating %" PRIdPTR " byte quote text buffer.",sizeof(char) * MAXQUOTELEN); - gameexit(tempbuf); + G_GameExit(tempbuf); } } @@ -5073,94 +5056,94 @@ repeatcase: { if (*textptr == '%' && *(textptr+1) == 's') { - initprintf("%s:%d: error: quote text contains string identifier.\n",compilefile,line_number); - error++; + initprintf("%s:%d: error: quote text contains string identifier.\n",g_szScriptFileName,g_lineNumber); + g_numCompilerErrors++; while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) textptr++; break; } if (tw == CON_DEFINEQUOTE) - *(fta_quotes[k]+i) = *textptr; + *(ScriptQuotes[k]+i) = *textptr; else - *(redefined_quotes[redefined_quote_count]+i) = *textptr; + *(ScriptQuoteRedefinitions[g_numQuoteRedefinitions]+i) = *textptr; textptr++,i++; if (i >= MAXQUOTELEN-1) { - initprintf("%s:%d: error: quote text exceeds limit of %d characters.\n",compilefile,line_number,MAXQUOTELEN-1); - error++; + initprintf("%s:%d: error: quote text exceeds limit of %d characters.\n",g_szScriptFileName,g_lineNumber,MAXQUOTELEN-1); + g_numCompilerErrors++; while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) textptr++; break; } } if (tw == CON_DEFINEQUOTE) - *(fta_quotes[k]+i) = '\0'; + *(ScriptQuotes[k]+i) = '\0'; else { - *(redefined_quotes[redefined_quote_count]+i) = '\0'; - bitptr[(scriptptr-script)>>3] &= ~(1<<((scriptptr-script)&7)); - *scriptptr++=redefined_quote_count; - redefined_quote_count++; + *(ScriptQuoteRedefinitions[g_numQuoteRedefinitions]+i) = '\0'; + bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7)); + *g_scriptPtr++=g_numQuoteRedefinitions; + g_numQuoteRedefinitions++; } return 0; case CON_CHEATKEYS: - scriptptr--; - transnum(LABEL_DEFINE); - cheatkey[0] = *(scriptptr-1); - transnum(LABEL_DEFINE); - cheatkey[1] = *(scriptptr-1); - scriptptr -= 2; + g_scriptPtr--; + C_GetNextValue(LABEL_DEFINE); + CheatKeys[0] = *(g_scriptPtr-1); + C_GetNextValue(LABEL_DEFINE); + CheatKeys[1] = *(g_scriptPtr-1); + g_scriptPtr -= 2; return 0; case CON_DEFINECHEAT: - scriptptr--; - transnum(LABEL_DEFINE); - k = *(scriptptr-1); + g_scriptPtr--; + C_GetNextValue(LABEL_DEFINE); + k = *(g_scriptPtr-1); if (k > 25) { - initprintf("%s:%d: error: cheat redefinition attempts to redefine nonexistant cheat.\n",compilefile,line_number); - error++; + initprintf("%s:%d: error: cheat redefinition attempts to redefine nonexistant cheat.\n",g_szScriptFileName,g_lineNumber); + g_numCompilerErrors++; while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) textptr++; break; } - scriptptr--; + g_scriptPtr--; i = 0; while (*textptr == ' ' || *textptr == '\t') textptr++; while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0 && *textptr != ' ') { - cheatstrings[k][i] = *textptr; + CheatStrings[k][i] = *textptr; textptr++,i++; - if (i >= (signed)sizeof(cheatstrings[k])-1) + if (i >= (signed)sizeof(CheatStrings[k])-1) { - initprintf("%s:%d: error: cheat exceeds limit of %d characters.\n",compilefile,line_number,MAXCHEATLEN,sizeof(cheatstrings[k])-1); - error++; + initprintf("%s:%d: error: cheat exceeds limit of %d characters.\n",g_szScriptFileName,g_lineNumber,MAXCHEATLEN,sizeof(CheatStrings[k])-1); + g_numCompilerErrors++; while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0 && *textptr != ' ') textptr++; break; } } - cheatstrings[k][i] = '\0'; + CheatStrings[k][i] = '\0'; return 0; case CON_DEFINESOUND: - scriptptr--; - transnum(LABEL_DEFINE); - k = *(scriptptr-1); + g_scriptPtr--; + C_GetNextValue(LABEL_DEFINE); + k = *(g_scriptPtr-1); if (k >= MAXSOUNDS) { - initprintf("%s:%ld: error: exceeded sound limit of %ld.\n",compilefile,line_number,MAXSOUNDS); - error++; + initprintf("%s:%ld: error: exceeded sound limit of %ld.\n",g_szScriptFileName,g_lineNumber,MAXSOUNDS); + g_numCompilerErrors++; } - scriptptr--; + g_scriptPtr--; i = 0; - skipcomments(); + C_SkipComments(); if (g_sounds[k].filename == NULL) g_sounds[k].filename = Bcalloc(BMAX_PATH,sizeof(char)); if (!g_sounds[k].filename) { Bsprintf(tempbuf,"Failed allocating %" PRIdPTR " byte buffer.",sizeof(char) * BMAX_PATH); - gameexit(tempbuf); + G_GameExit(tempbuf); } while (*textptr != ' ' || *textptr == '\t') @@ -5169,92 +5152,92 @@ repeatcase: textptr++,i++; if (i >= BMAX_PATH) { - initprintf("%s:%d: error: sound filename exceeds limit of %d characters.\n",compilefile,line_number,BMAX_PATH); - error++; - skipcomments(); + initprintf("%s:%d: error: sound filename exceeds limit of %d characters.\n",g_szScriptFileName,g_lineNumber,BMAX_PATH); + g_numCompilerErrors++; + C_SkipComments(); break; } } g_sounds[k].filename[i] = '\0'; - transnum(LABEL_DEFINE); - g_sounds[k].ps = *(scriptptr-1); - scriptptr--; - transnum(LABEL_DEFINE); - g_sounds[k].pe = *(scriptptr-1); - scriptptr--; - transnum(LABEL_DEFINE); - g_sounds[k].pr = *(scriptptr-1); - scriptptr--; - transnum(LABEL_DEFINE); - g_sounds[k].m = *(scriptptr-1); - scriptptr--; - transnum(LABEL_DEFINE); - g_sounds[k].vo = *(scriptptr-1); - scriptptr--; + C_GetNextValue(LABEL_DEFINE); + g_sounds[k].ps = *(g_scriptPtr-1); + g_scriptPtr--; + C_GetNextValue(LABEL_DEFINE); + g_sounds[k].pe = *(g_scriptPtr-1); + g_scriptPtr--; + C_GetNextValue(LABEL_DEFINE); + g_sounds[k].pr = *(g_scriptPtr-1); + g_scriptPtr--; + C_GetNextValue(LABEL_DEFINE); + g_sounds[k].m = *(g_scriptPtr-1); + g_scriptPtr--; + C_GetNextValue(LABEL_DEFINE); + g_sounds[k].vo = *(g_scriptPtr-1); + g_scriptPtr--; return 0; case CON_ENDEVENT: - if (parsing_event == 0) + if (g_parsingEventPtr == 0) { - ReportError(-1); - initprintf("%s:%d: error: found `endevent' without open `onevent'.\n",compilefile,line_number); - error++; + C_ReportError(-1); + initprintf("%s:%d: error: found `endevent' without open `onevent'.\n",g_szScriptFileName,g_lineNumber); + g_numCompilerErrors++; } - if (num_braces > 0) + if (g_numBraces > 0) { - ReportError(ERROR_OPENBRACKET); - error++; + C_ReportError(ERROR_OPENBRACKET); + g_numCompilerErrors++; } - if (num_braces < 0) + if (g_numBraces < 0) { - ReportError(ERROR_CLOSEBRACKET); - error++; + C_ReportError(ERROR_CLOSEBRACKET); + g_numCompilerErrors++; } - parsing_event = 0; - parsing_actor = 0; - current_event = -1; - Bsprintf(parsing_item_name,"(none)"); + g_parsingEventPtr = 0; + g_parsingActorPtr = 0; + g_currentEvent = -1; + Bsprintf(g_szCurrentBlockName,"(none)"); return 0; case CON_ENDA: - if (parsing_actor == 0) + if (g_parsingActorPtr == 0) { - ReportError(-1); - initprintf("%s:%d: error: found `enda' without open `actor'.\n",compilefile,line_number); - error++; + C_ReportError(-1); + initprintf("%s:%d: error: found `enda' without open `actor'.\n",g_szScriptFileName,g_lineNumber); + g_numCompilerErrors++; } - if (num_braces > 0) + if (g_numBraces > 0) { - ReportError(ERROR_OPENBRACKET); - error++; + C_ReportError(ERROR_OPENBRACKET); + g_numCompilerErrors++; } - if (num_braces < 0) + if (g_numBraces < 0) { - ReportError(ERROR_CLOSEBRACKET); - error++; + C_ReportError(ERROR_CLOSEBRACKET); + g_numCompilerErrors++; } - parsing_actor = 0; - Bsprintf(parsing_item_name,"(none)"); + g_parsingActorPtr = 0; + Bsprintf(g_szCurrentBlockName,"(none)"); return 0; case CON_BREAK: - if (checking_switch) + if (g_checkingSwitch) { - //Bsprintf(g_szBuf," * (L%d) case Break statement.\n",line_number); + //Bsprintf(g_szBuf," * (L%d) case Break statement.\n",g_lineNumber); //AddLog(g_szBuf); return 1; } return 0; case CON_SCRIPTSIZE: - scriptptr--; - transnum(LABEL_DEFINE); - j = *(scriptptr-1); - scriptptr--; - skipcomments(); - return increasescriptsize(j); + g_scriptPtr--; + C_GetNextValue(LABEL_DEFINE); + j = *(g_scriptPtr-1); + g_scriptPtr--; + C_SkipComments(); + return C_IncreaseScriptSize(j); case CON_FALL: case CON_TIP: @@ -5271,10 +5254,10 @@ repeatcase: case CON_PKICK: case CON_MIKESND: case CON_TOSSWEAPON: - if (!CheckEventSync(current_event)) + if (!C_CheckEventSync(g_currentEvent)) { - ReportError(WARNING_EVENTSYNC); - warning++; + C_ReportError(WARNING_EVENTSYNC); + g_numCompilerWarnings++; } case CON_NULLOP: case CON_STOPALLSOUNDS: @@ -5283,23 +5266,23 @@ repeatcase: { int params[30]; - scriptptr--; + g_scriptPtr--; for (j = 0; j < 30; j++) { - transnum(LABEL_DEFINE); - scriptptr--; - params[j] = *scriptptr; + C_GetNextValue(LABEL_DEFINE); + g_scriptPtr--; + params[j] = *g_scriptPtr; if (j != 25) continue; - if (keyword() != -1) + if (C_GetKeyword() != -1) { // initprintf("Duke Nukem 3D v1.3D style CON files detected.\n"); break; } else { - g_ScriptVersion = 14; + g_scriptVersion = 14; // initprintf("Duke Nukem 3D v1.4+ style CON files detected.\n"); } @@ -5341,20 +5324,20 @@ repeatcase: j = 0; ud.const_visibility = params[j++]; - impact_damage = params[j++]; + g_impactDamage = params[j++]; g_player[0].ps->max_player_health = g_player[0].ps->max_shield_amount = params[j++]; - start_armour_amount = params[j++]; - respawnactortime = params[j++]; - respawnitemtime = params[j++]; - dukefriction = params[j++]; - if (g_ScriptVersion == 14) gc = params[j++]; - rpgblastradius = params[j++]; - pipebombblastradius = params[j++]; - shrinkerblastradius = params[j++]; - tripbombblastradius = params[j++]; - morterblastradius = params[j++]; - bouncemineblastradius = params[j++]; - seenineblastradius = params[j++]; + g_startArmorAmount = params[j++]; + g_actorRespawnTime = params[j++]; + g_itemRespawnTime = params[j++]; + g_playerFriction = params[j++]; + if (g_scriptVersion == 14) SpriteGravity = params[j++]; + g_rpgBlastRadius = params[j++]; + g_pipebombBlastRadius = params[j++]; + g_shrinkerBlastRadius = params[j++]; + g_tripbombBlastRadius = params[j++]; + g_morterBlastRadius = params[j++]; + g_bouncemineBlastRadius = params[j++]; + g_seenineBlastRadius = params[j++]; g_player[0].ps->max_ammo_amount[PISTOL_WEAPON] = params[j++]; g_player[0].ps->max_ammo_amount[SHOTGUN_WEAPON] = params[j++]; g_player[0].ps->max_ammo_amount[CHAINGUN_WEAPON] = params[j++]; @@ -5364,17 +5347,17 @@ repeatcase: g_player[0].ps->max_ammo_amount[DEVISTATOR_WEAPON] = params[j++]; g_player[0].ps->max_ammo_amount[TRIPBOMB_WEAPON] = params[j++]; g_player[0].ps->max_ammo_amount[FREEZE_WEAPON] = params[j++]; - if (g_ScriptVersion == 14) g_player[0].ps->max_ammo_amount[GROW_WEAPON] = params[j++]; - camerashitable = params[j++]; - numfreezebounces = params[j++]; - freezerhurtowner = params[j++]; - if (g_ScriptVersion == 14) + if (g_scriptVersion == 14) g_player[0].ps->max_ammo_amount[GROW_WEAPON] = params[j++]; + g_damageCameras = params[j++]; + g_numFreezeBounces = params[j++]; + g_freezerSelfDamage = params[j++]; + if (g_scriptVersion == 14) { - spriteqamount = params[j++]; - if (spriteqamount > 1024) spriteqamount = 1024; - else if (spriteqamount < 0) spriteqamount = 0; + g_spriteDeleteQueueSize = params[j++]; + if (g_spriteDeleteQueueSize > 1024) g_spriteDeleteQueueSize = 1024; + else if (g_spriteDeleteQueueSize < 0) g_spriteDeleteQueueSize = 0; - lasermode = params[j++]; + g_tripbombLaserMode = params[j++]; } } return 0; @@ -5382,25 +5365,6 @@ repeatcase: return 0; } -static void passone(void) -{ - while (parsecommand() == 0); - - if (error > 63) - initprintf("fatal error: too many errors: Aborted\n"); - -#ifdef DEBUG - { - int i=0; - initprintf("Game Definitions\n"); - for (;i=0;i--) - Bmemcpy(&projectile[i],&DefaultProjectile,sizeof(projectile_t)); + Bmemcpy(&ProjectileData[i],&DefaultProjectile,sizeof(projectile_t)); - Bmemcpy(&defaultprojectile[0], &projectile[0], sizeof(projectile)); + Bmemcpy(&DefaultProjectileData[0], &ProjectileData[0], sizeof(ProjectileData)); } -extern int g_NumObituaries; -extern int g_NumSelfObituaries; +extern int g_numObituaries; +extern int g_numSelfObituaries; -void loadefs(const char *filenam) +void C_Compile(const char *filenam) { char *mptr; int i; @@ -5616,12 +5580,12 @@ void loadefs(const char *filenam) clearbuf(apScriptGameEvent,MAXGAMEEVENTS,0L); inithash(); - InitGameVars(); - InitProjectiles(); + Gv_Init(); + C_InitProjectiles(); /* JBF 20040109: Don't prompt to extract CONs from GRP if they're missing. * If someone really wants them they can Kextract them. - if(!SafeFileExists(filenam) && loadfromgrouponly == 0) + if(!SafeFileExists(filenam) && g_loadFromGroupOnly == 0) { initprintf("Missing external CON file(s).\n"); initprintf("COPY INTERNAL DEFAULTS TO DIRECTORY(Y/n)?\n"); @@ -5636,12 +5600,12 @@ void loadefs(const char *filenam) } } */ - fp = kopen4loadfrommod((char *)filenam,loadfromgrouponly); + fp = kopen4loadfrommod((char *)filenam,g_loadFromGroupOnly); if (fp == -1) // JBF: was 0 { extern int numgroupfiles; - if (loadfromgrouponly == 1) + if (g_loadFromGroupOnly == 1) { Bsprintf(tempbuf,"'%s' missing CON files, reinstall Duke Nukem 3D.",duke3dgrp); } @@ -5653,9 +5617,9 @@ void loadefs(const char *filenam) duke3dgrp,duke3dgrp); } else Bsprintf(tempbuf,"CON file `%s' missing.", filenam); - gameexit(tempbuf); + G_GameExit(tempbuf); - //loadfromgrouponly = 1; + //g_loadFromGroupOnly = 1; return; //Not there } @@ -5669,7 +5633,7 @@ void loadefs(const char *filenam) if (!mptr) { Bsprintf(tempbuf,"Failed allocating %d byte CON text buffer.", fs+1); - gameexit(tempbuf); + G_GameExit(tempbuf); } mptr[fs] = 0; @@ -5680,37 +5644,42 @@ void loadefs(const char *filenam) clearbuf(actorscrptr,MAXTILES,0L); // JBF 20040531: MAXSPRITES? I think Todd meant MAXTILES... clearbuf(actorLoadEventScrptr,MAXTILES,0L); // I think this should be here... - clearbufbyte(actortype,MAXTILES,0L); + clearbufbyte(ActorType,MAXTILES,0L); // clearbufbyte(script,sizeof(script),0l); // JBF 20040531: yes? no? if (script != NULL) Bfree(script); - script = Bcalloc(1,g_ScriptSize * sizeof(intptr_t)); - bitptr = Bcalloc(1,(((g_ScriptSize+7)>>3)+1) * sizeof(char)); + script = Bcalloc(1,g_scriptSize * sizeof(intptr_t)); + bitptr = Bcalloc(1,(((g_scriptSize+7)>>3)+1) * sizeof(char)); // initprintf("script: %d, bitptr: %d\n",script,bitptr); - labelcnt = defaultlabelcnt = 0; - scriptptr = script+1; - warning = 0; - error = 0; - line_number = 1; - total_lines = 0; + g_numLabels = g_numDefaultLabels = 0; + g_scriptPtr = script+1; + g_numCompilerWarnings = 0; + g_numCompilerErrors = 0; + g_lineNumber = 1; + g_totalLines = 0; - AddDefaultDefinitions(); + C_AddDefaultDefinitions(); - Bstrcpy(compilefile, filenam); // JBF 20031130: Store currently compiling file name - passone(); //Tokenize - //*script = (intptr_t) scriptptr; + Bstrcpy(g_szScriptFileName, filenam); // JBF 20031130: Store currently compiling file name + + while (C_ParseCommand() == 0); + + if (g_numCompilerErrors > 63) + initprintf("fatal error: too many errors: Aborted\n"); + + //*script = (intptr_t) g_scriptPtr; Bfree(mptr); mptr = NULL; - if (warning|error) - initprintf("Found %d warning(s), %d error(s).\n",warning,error); + if (g_numCompilerWarnings|g_numCompilerErrors) + initprintf("Found %d warning(s), %d error(s).\n",g_numCompilerWarnings,g_numCompilerErrors); /* if (error == 0 && warning != 0) { - if (groupfile != -1 && loadfromgrouponly == 0) + if (g_groupFileHandle != -1 && g_loadFromGroupOnly == 0) { initprintf("Warning(s) found in file `%s'. Do you want to use the INTERNAL DEFAULTS (y/N)?",filenam); @@ -5719,23 +5688,23 @@ void loadefs(const char *filenam) if (i) i = 'y'; if (i == 'y' || i == 'Y') { - loadfromgrouponly = 1; + g_loadFromGroupOnly = 1; initprintf(" Yes\n"); return; } } } */ - if (error) + if (g_numCompilerErrors) { - if (loadfromgrouponly) + if (g_loadFromGroupOnly) { sprintf(buf,"Error compiling CON files."); - gameexit(buf); + G_GameExit(buf); } else { - if (groupfile != -1 && loadfromgrouponly == 0) + if (g_groupFileHandle != -1 && g_loadFromGroupOnly == 0) { // initprintf("Error(s) found in file `%s'. Do you want to use the INTERNAL DEFAULTS (y/N)?\n",filenam); @@ -5745,7 +5714,7 @@ void loadefs(const char *filenam) if (i == 'y' || i == 'Y') { initprintf(" Yes\n"); - loadfromgrouponly = 1; + g_loadFromGroupOnly = 1; return; } else @@ -5754,7 +5723,7 @@ void loadefs(const char *filenam) while (!quitevent) // keep the window open so people can copy CON errors out of it handleevents(); #endif - gameexit(""); + G_GameExit(""); } } } @@ -5776,21 +5745,21 @@ void loadefs(const char *filenam) HASH_free(&actorH); HASH_free(&tspriteH); - total_lines += line_number; + g_totalLines += g_lineNumber; - increasescriptsize(scriptptr-script+8); + C_IncreaseScriptSize(g_scriptPtr-script+8); - initprintf("Compile completed in %dms\n",getticks()-startcompiletime); + initprintf("Script compiled in %dms\n",getticks()-startcompiletime); - initprintf("Compiled code size: %ld*%d bytes, version %s\n",(unsigned)(scriptptr-script),sizeof(intptr_t),(g_ScriptVersion == 14?"1.4+":"1.3D")); - initprintf("Pointer bitmap size: %ld bytes\n",(g_ScriptSize+7)>>3); - initprintf("%ld/%ld labels, %d/%d variables\n",labelcnt,min((MAXSECTORS * sizeof(sectortype)/sizeof(int)),(MAXSPRITES * sizeof(spritetype)/(1<<6))),iGameVarCount,MAXGAMEVARS); + initprintf("Compiled code size: %ld*%d bytes, version %s\n",(unsigned)(g_scriptPtr-script),sizeof(intptr_t),(g_scriptVersion == 14?"1.4+":"1.3D")); + initprintf("Pointer bitmap size: %ld bytes\n",(g_scriptSize+7)>>3); + initprintf("%ld/%ld labels, %d/%d variables\n",g_numLabels,min((MAXSECTORS * sizeof(sectortype)/sizeof(int)),(MAXSPRITES * sizeof(spritetype)/(1<<6))),g_gameVarCount,MAXGAMEVARS); for (i=MAXQUOTES-1;i>=0;i--) - if (fta_quotes[i]) + if (ScriptQuotes[i]) j++; - initprintf("%ld/%d quotes, %d quote redefinitions\n",j,MAXQUOTES,redefined_quote_count); + initprintf("%ld/%d quotes, %d quote redefinitions\n",j,MAXQUOTES,g_numQuoteRedefinitions); j = 0; for (i=MAXGAMEEVENTS-1;i>=0;i--) @@ -5803,71 +5772,26 @@ void loadefs(const char *filenam) initprintf("%ld/%d event definitions, %ld defined actors\n",j,MAXEVENTS,k); for (i=127;i>=0;i--) - if (fta_quotes[i] == NULL) - fta_quotes[i] = Bcalloc(MAXQUOTELEN,sizeof(char)); + if (ScriptQuotes[i] == NULL) + ScriptQuotes[i] = Bcalloc(MAXQUOTELEN,sizeof(char)); -// if (!Bstrcmp(fta_quotes[13],"PRESS SPACE TO RESTART LEVEL")) -// Bstrcpy(fta_quotes[13],"PRESS USE TO RESTART LEVEL"); +// if (!Bstrcmp(ScriptQuotes[13],"PRESS SPACE TO RESTART LEVEL")) +// Bstrcpy(ScriptQuotes[13],"PRESS USE TO RESTART LEVEL"); for (i=MAXQUOTELEN-7;i>=0;i--) - if (Bstrncmp(&fta_quotes[13][i],"SPACE",5) == 0) + if (Bstrncmp(&ScriptQuotes[13][i],"SPACE",5) == 0) { Bmemset(tempbuf,0,sizeof(tempbuf)); - Bstrncpy(tempbuf,fta_quotes[13],i); + Bstrncpy(tempbuf,ScriptQuotes[13],i); Bstrcat(tempbuf,"OPEN"); - Bstrcat(tempbuf,&fta_quotes[13][i+5]); - Bstrncpy(fta_quotes[13],tempbuf,MAXQUOTELEN-1); + Bstrcat(tempbuf,&ScriptQuotes[13][i+5]); + Bstrncpy(ScriptQuotes[13],tempbuf,MAXQUOTELEN-1); i = MAXQUOTELEN-7; } + // most of these are based on Blood, obviously { - /* - const char *ppdeathstrings[] = - { - "^2%s ^2was kicked to the curb by %s", - "^2%s ^2was picked off by %s", - "^2%s ^2took %s^2's shot to the face", - "^2%s ^did the chaingun cha-cha for %s", - "^2%s ^2tried to make a bong out of %s^2's rocket", - "^2%s ^2exploded. Blame %s^2!", - "^2%s ^2became one with the gum on %s^2's shoe", - "^2%s ^2was too cool for %s", - "^2%s^2's ego was inflated by %s", - "^2%s ^2thinks %s ^2should check his glasses", - - "^2%s ^2took %s^2's boot to the head", - "^2%s ^2underestimated %s^2's marksmanship", - "^2%s ^2was chased off of %s^2's porch", - "^2%s ^2couldn't dance fast enough for %s", - "^2%s ^2tried to outrun %s^2's rocket", - "^2%s ^2found %s^2's hidden weapons of mass destruction", - "^2%s ^2was just trying to help %s ^2tie his shoelaces", - "^2%s^2's igloo was wrecked by %s", - "^2%s ^2became a sticky film on %s^2's boots", - "^2%s ^2wishes %s ^2had practiced before playing", - - "^2%s ^2was walked all over by %s", - "^2%s ^2was picked off by %s", - "^2%s ^2sucked %s^2's shotgun", - "^2%s ^2was ventilated by %s", - "^2%s ^2was turned into %s^2 brand chunky salsa", - "^2%s ^2found a present from %s", - "^2%s ^2was scathed by %s^2's shrink ray", - "^2%s ^2went to pieces. %s^2, how could you?", - "^2%s ^2expanded his horizons with help from %s", - "^2%s ^wonders if %s ^2even knows what \"cooperative\" means", - }; - - const char *podeathstrings[] = - { - "^2%s ^2killed himself. What a tool!", - "^2%s ^2tried to leave", - "^2%s ^2got fragged by a monster. It was probably a liztroop.", - "^2%s ^2switched to team %d" - }; - */ - - const char *ppdeathstrings[] = + const char *PlayerObituaries[] = { "^02%s^02 beat %s^02 like a cur", "^02%s^02 broke %s", @@ -5879,7 +5803,9 @@ void loadefs(const char *filenam) "^02%s^02 destroyed %s", "^02%s^02 diced %s", "^02%s^02 disemboweled %s", + "^02%s^02 erased %s", "^02%s^02 eviscerated %s", + "^02%s^02 flailed %s", "^02%s^02 flattened %s", "^02%s^02 gave AnAl MaDnEsS to %s", "^02%s^02 gave %s^02 Anal Justice", @@ -5888,6 +5814,7 @@ void loadefs(const char *filenam) "^02%s^02 killed %s", "^02%s^02 made dog meat out of %s", "^02%s^02 made mincemeat out of %s", + "^02%s^02 manhandled %s", "^02%s^02 massacred %s", "^02%s^02 mutilated %s", "^02%s^02 murdered %s", @@ -5896,8 +5823,10 @@ void loadefs(const char *filenam) "^02%s^02 ripped %s^02 a new orifice", "^02%s^02 rocked %s", "^02%s^02 sent %s^02 to hell", + "^02%s^02 shredded %s", "^02%s^02 slaughtered %s", "^02%s^02 sliced %s", + "^02%s^02 smacked %s around", "^02%s^02 smashed %s", "^02%s^02 snuffed %s", "^02%s^02 sodomized %s", @@ -5906,130 +5835,133 @@ void loadefs(const char *filenam) "^02%s^02 squashed %s", "^02%s^02 throttled %s", "^02%s^02 toasted %s", + "^02%s^02 vented %s", "^02%s^02 ventilated %s", "^02%s^02 wasted %s", + "^02%s^02 wrecked %s", }; - const char *psdeathstrings[] = + const char *PlayerSelfObituaries[] = { "^02%s^02 is excrement", "^02%s^02 is hamburger", "^02%s^02 suffered scrotum separation", "^02%s^02 volunteered for population control", "^02%s^02 has suicided", + "^02%s^02 bled out", }; - g_NumObituaries = (sizeof(ppdeathstrings)/sizeof(ppdeathstrings[0])); - for (i=g_NumObituaries-1;i>=0;i--) + g_numObituaries = (sizeof(PlayerObituaries)/sizeof(PlayerObituaries[0])); + for (i=g_numObituaries-1;i>=0;i--) { - if (fta_quotes[i+PPDEATHSTRINGS] == NULL) + if (ScriptQuotes[i+FIRST_OBITUARY_QUOTE] == NULL) { - fta_quotes[i+PPDEATHSTRINGS] = Bcalloc(MAXQUOTELEN,sizeof(char)); - Bstrcpy(fta_quotes[i+PPDEATHSTRINGS],ppdeathstrings[i]); + ScriptQuotes[i+FIRST_OBITUARY_QUOTE] = Bcalloc(MAXQUOTELEN,sizeof(char)); + Bstrcpy(ScriptQuotes[i+FIRST_OBITUARY_QUOTE],PlayerObituaries[i]); } } - g_NumSelfObituaries = (sizeof(psdeathstrings)/sizeof(psdeathstrings[0])); - for (i=g_NumSelfObituaries-1;i>=0;i--) + g_numSelfObituaries = (sizeof(PlayerSelfObituaries)/sizeof(PlayerSelfObituaries[0])); + for (i=g_numSelfObituaries-1;i>=0;i--) { - if (fta_quotes[i+PSDEATHSTRINGS] == NULL) + if (ScriptQuotes[i+FIRST_SUICIDE_QUOTE] == NULL) { - fta_quotes[i+PSDEATHSTRINGS] = Bcalloc(MAXQUOTELEN,sizeof(char)); - Bstrcpy(fta_quotes[i+PSDEATHSTRINGS],psdeathstrings[i]); + ScriptQuotes[i+FIRST_SUICIDE_QUOTE] = Bcalloc(MAXQUOTELEN,sizeof(char)); + Bstrcpy(ScriptQuotes[i+FIRST_SUICIDE_QUOTE],PlayerSelfObituaries[i]); } } } } } -void ReportError(int iError) +void C_ReportError(int iError) { - if (Bstrcmp(parsing_item_name,previous_item_name)) + if (Bstrcmp(g_szCurrentBlockName,g_szLastBlockName)) { - if (parsing_event || parsing_state || parsing_actor) - initprintf("%s: In %s `%s':\n",compilefile,parsing_event?"event":parsing_actor?"actor":"state",parsing_item_name); - else initprintf("%s: At top level:\n",compilefile); - Bstrcpy(previous_item_name,parsing_item_name); + if (g_parsingEventPtr || g_processingState || g_parsingActorPtr) + initprintf("%s: In %s `%s':\n",g_szScriptFileName,g_parsingEventPtr?"event":g_parsingActorPtr?"actor":"state",g_szCurrentBlockName); + else initprintf("%s: At top level:\n",g_szScriptFileName); + Bstrcpy(g_szLastBlockName,g_szCurrentBlockName); } switch (iError) { case ERROR_CLOSEBRACKET: - initprintf("%s:%d: error: found more `}' than `{' before `%s'.\n",compilefile,line_number,tempbuf); + initprintf("%s:%d: error: found more `}' than `{' before `%s'.\n",g_szScriptFileName,g_lineNumber,tempbuf); break; case ERROR_EVENTONLY: - initprintf("%s:%d: error: command `%s' only valid during events.\n",compilefile,line_number,tempbuf); + initprintf("%s:%d: error: command `%s' only valid during events.\n",g_szScriptFileName,g_lineNumber,tempbuf); break; case ERROR_EXCEEDSMAXTILES: - initprintf("%s:%d: error: `%s' value exceeds MAXTILES. Maximum is %d.\n",compilefile,line_number,tempbuf,MAXTILES-1); + initprintf("%s:%d: error: `%s' value exceeds MAXTILES. Maximum is %d.\n",g_szScriptFileName,g_lineNumber,tempbuf,MAXTILES-1); break; case ERROR_EXPECTEDKEYWORD: - initprintf("%s:%d: error: expected a keyword but found `%s'.\n",compilefile,line_number,tempbuf); + initprintf("%s:%d: error: expected a keyword but found `%s'.\n",g_szScriptFileName,g_lineNumber,tempbuf); break; case ERROR_FOUNDWITHIN: - initprintf("%s:%d: error: found `%s' within %s.\n",compilefile,line_number,tempbuf,parsing_event?"an event":parsing_actor?"an actor":"a state"); + initprintf("%s:%d: error: found `%s' within %s.\n",g_szScriptFileName,g_lineNumber,tempbuf,g_parsingEventPtr?"an event":g_parsingActorPtr?"an actor":"a state"); break; case ERROR_ISAKEYWORD: - initprintf("%s:%d: error: symbol `%s' is a keyword.\n",compilefile,line_number,label+(labelcnt<<6)); + initprintf("%s:%d: error: symbol `%s' is a keyword.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); break; case ERROR_NOENDSWITCH: - initprintf("%s:%d: error: did not find `endswitch' before `%s'.\n",compilefile,line_number,label+(labelcnt<<6)); + initprintf("%s:%d: error: did not find `endswitch' before `%s'.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); break; case ERROR_NOTAGAMEDEF: - initprintf("%s:%d: error: symbol `%s' is not a game definition.\n",compilefile,line_number,label+(labelcnt<<6)); + initprintf("%s:%d: error: symbol `%s' is not a game definition.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); break; case ERROR_NOTAGAMEVAR: - initprintf("%s:%d: error: symbol `%s' is not a game variable.\n",compilefile,line_number,label+(labelcnt<<6)); + initprintf("%s:%d: error: symbol `%s' is not a game variable.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); break; case ERROR_NOTAGAMEARRAY: - initprintf("%s:%d: error: symbol `%s' is not a game array.\n",compilefile,line_number,label+(labelcnt<<6)); + initprintf("%s:%d: error: symbol `%s' is not a game array.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); break; case ERROR_GAMEARRAYBNC: - initprintf("%s:%d: error: square brackets for index of game array not closed, expected ] found %c\n",compilefile,line_number,*textptr); + initprintf("%s:%d: error: square brackets for index of game array not closed, expected ] found %c\n",g_szScriptFileName,g_lineNumber,*textptr); break; case ERROR_GAMEARRAYBNO: - initprintf("%s:%d: error: square brackets for index of game array not opened, expected [ found %c\n",compilefile,line_number,*textptr); + initprintf("%s:%d: error: square brackets for index of game array not opened, expected [ found %c\n",g_szScriptFileName,g_lineNumber,*textptr); break; case ERROR_INVALIDARRAYWRITE: - initprintf("%s:%d: error: arrays can only be written using setarray %c\n",compilefile,line_number,*textptr); + initprintf("%s:%d: error: arrays can only be written using setarray %c\n",g_szScriptFileName,g_lineNumber,*textptr); break; case ERROR_OPENBRACKET: - initprintf("%s:%d: error: found more `{' than `}' before `%s'.\n",compilefile,line_number,tempbuf); + initprintf("%s:%d: error: found more `{' than `}' before `%s'.\n",g_szScriptFileName,g_lineNumber,tempbuf); break; case ERROR_PARAMUNDEFINED: - initprintf("%s:%d: error: parameter `%s' is undefined.\n",compilefile,line_number,tempbuf); + initprintf("%s:%d: error: parameter `%s' is undefined.\n",g_szScriptFileName,g_lineNumber,tempbuf); break; case ERROR_SYMBOLNOTRECOGNIZED: - initprintf("%s:%d: error: symbol `%s' is not recognized.\n",compilefile,line_number,label+(labelcnt<<6)); + initprintf("%s:%d: error: symbol `%s' is not recognized.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); break; case ERROR_SYNTAXERROR: - initprintf("%s:%d: error: syntax error.\n",compilefile,line_number); + initprintf("%s:%d: error: syntax error.\n",g_szScriptFileName,g_lineNumber); break; case ERROR_VARREADONLY: - initprintf("%s:%d: error: variable `%s' is read-only.\n",compilefile,line_number,label+(labelcnt<<6)); + initprintf("%s:%d: error: variable `%s' is read-only.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); break; case ERROR_VARTYPEMISMATCH: - initprintf("%s:%d: error: variable `%s' is of the wrong type.\n",compilefile,line_number,label+(labelcnt<<6)); + initprintf("%s:%d: error: variable `%s' is of the wrong type.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); break; case WARNING_BADGAMEVAR: - initprintf("%s:%ld: warning: variable `%s' should be either per-player OR per-actor, not both.\n",compilefile,line_number,label+(labelcnt<<6)); + initprintf("%s:%ld: warning: variable `%s' should be either per-player OR per-actor, not both.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); break; case WARNING_DUPLICATECASE: - initprintf("%s:%ld: warning: duplicate case ignored.\n",compilefile,line_number); + initprintf("%s:%ld: warning: duplicate case ignored.\n",g_szScriptFileName,g_lineNumber); break; case WARNING_DUPLICATEDEFINITION: - initprintf("%s:%d: warning: duplicate game definition `%s' ignored.\n",compilefile,line_number,label+(labelcnt<<6)); + initprintf("%s:%d: warning: duplicate game definition `%s' ignored.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); break; case WARNING_EVENTSYNC: - initprintf("%s:%d: warning: found `%s' within a local event.\n",compilefile,line_number,tempbuf); + initprintf("%s:%d: warning: found `%s' within a local event.\n",g_szScriptFileName,g_lineNumber,tempbuf); break; case WARNING_LABELSONLY: - initprintf("%s:%d: warning: expected a label, found a constant.\n",compilefile,line_number); + initprintf("%s:%d: warning: expected a label, found a constant.\n",g_szScriptFileName,g_lineNumber); break; case WARNING_NAMEMATCHESVAR: - initprintf("%s:%d: warning: symbol `%s' already used for game variable.\n",compilefile,line_number,label+(labelcnt<<6)); + initprintf("%s:%d: warning: symbol `%s' already used for game variable.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); break; case WARNING_REVEVENTSYNC: - initprintf("%s:%d: warning: found `%s' outside of a local event.\n",compilefile,line_number,tempbuf); + initprintf("%s:%d: warning: found `%s' outside of a local event.\n",g_szScriptFileName,g_lineNumber,tempbuf); break; } } diff --git a/polymer/eduke32/source/gamedef.h b/polymer/eduke32/source/gamedef.h index 6fcb31f38..e7d6e4da5 100644 --- a/polymer/eduke32/source/gamedef.h +++ b/polymer/eduke32/source/gamedef.h @@ -51,10 +51,10 @@ extern int g_gs; extern int g_kb; extern int g_looking_angSR1; extern int lastvisinc; -extern char cheatstrings[][MAXCHEATLEN]; -extern char compilefile[BMAX_PATH]; -extern int total_lines,line_number; -extern int error,warning; +extern char CheatStrings[][MAXCHEATLEN]; +extern char g_szScriptFileName[BMAX_PATH]; +extern int g_totalLines,g_lineNumber; +extern int g_numCompilerErrors,g_numCompilerWarnings; typedef struct { @@ -64,36 +64,36 @@ typedef struct int maxParm2; } memberlabel_t; -extern const memberlabel_t sectorlabels[]; -extern const memberlabel_t walllabels[]; -extern const memberlabel_t actorlabels[]; -extern const memberlabel_t playerlabels[]; -extern const memberlabel_t projectilelabels[]; +extern const memberlabel_t SectorLabels[]; +extern const memberlabel_t WallLabels[]; +extern const memberlabel_t ActorLabels[]; +extern const memberlabel_t PlayerLabels[]; +extern const memberlabel_t ProjectileLabels[]; extern const memberlabel_t userdeflabels[]; -extern const memberlabel_t inputlabels[]; -extern const memberlabel_t tsprlabels[]; +extern const memberlabel_t InputLabels[]; +extern const memberlabel_t TsprLabels[]; -extern void DoUserDef(int iSet, int lLabelID, int lVar2); -extern void DoThisProjectile(int iSet, int lVar1, int lLabelID, int lVar2); -extern void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2); -extern void DoInput(int iSet, int lVar1, int lLabelID, int lVar2); -extern void DoWall(int iSet, int lVar1, int lLabelID, int lVar2); -extern void DoSector(int iSet, int lVar1, int lLabelID, int lVar2); -extern void DoActor(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2); -extern void DoTsprite(int iSet, int lVar1, int lLabelID, int lVar2); -extern void DoProjectile(int iSet, int lVar1, int lLabelID, int lVar2); +extern void X_AccessUserdef(int iSet, int lLabelID, int lVar2); +extern void X_AccessActiveProjectile(int iSet, int lVar1, int lLabelID, int lVar2); +extern void X_AccessPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2); +extern void X_AccessPlayerInput(int iSet, int lVar1, int lLabelID, int lVar2); +extern void X_AccessWall(int iSet, int lVar1, int lLabelID, int lVar2); +extern void X_AccessSector(int iSet, int lVar1, int lLabelID, int lVar2); +extern void X_AccessSprite(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2); +extern void X_AccessTsprite(int iSet, int lVar1, int lLabelID, int lVar2); +extern void X_AccessProjectile(int iSet, int lVar1, int lLabelID, int lVar2); #define CON_ERROR OSD_ERROR "Line %d, %s: " extern int g_i,g_p; -extern int checkCON; +extern int g_scriptSanityChecks; -extern int line_num; +extern int g_errorLineNum; extern int g_tw; extern const char *keyw[]; extern spritetype *g_sp; -enum errors +enum ScriptError_t { ERROR_CLOSEBRACKET, ERROR_EVENTONLY, @@ -123,7 +123,7 @@ enum errors WARNING_REVEVENTSYNC }; -enum playerlabels +enum PlayerLabel_t { PLAYER_ZOOM, PLAYER_EXITX, @@ -274,7 +274,7 @@ enum playerlabels PLAYER_END }; -enum userdefslabels +enum UserdefsLabel_t { USERDEFS_GOD, USERDEFS_WARP_ON, @@ -374,7 +374,7 @@ enum userdefslabels USERDEFS_END }; -enum sectorlabels +enum SectorLabel_t { SECTOR_WALLPTR, SECTOR_WALLNUM, @@ -402,7 +402,7 @@ enum sectorlabels SECTOR_END }; -enum walllabels +enum WallLabel_t { WALL_X, WALL_Y, @@ -424,7 +424,7 @@ enum walllabels WALL_END }; -enum actorlabels +enum ActorLabel_t { ACTOR_X, ACTOR_Y, @@ -480,7 +480,7 @@ enum actorlabels ACTOR_END }; -enum inputlabels +enum InputLabel_t { INPUT_AVEL, INPUT_HORZ, @@ -491,7 +491,7 @@ enum inputlabels INPUT_END }; -enum projectilelabels +enum ProjectileLabel_t { PROJ_WORKSLIKE, PROJ_SPAWNS, @@ -524,7 +524,7 @@ enum projectilelabels PROJ_END }; -enum keywords +enum ScriptKeywords_t { CON_DEFINELEVELNAME, // 0 CON_ACTOR, // 1 diff --git a/polymer/eduke32/source/gameexec.c b/polymer/eduke32/source/gameexec.c index 60c9029ec..02d98f3ba 100644 --- a/polymer/eduke32/source/gameexec.c +++ b/polymer/eduke32/source/gameexec.c @@ -31,20 +31,20 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "osdcmds.h" #include "osd.h" -void restoremapstate(mapstate_t *save); -void savemapstate(mapstate_t *save); +void G_RestoreMapState(mapstate_t *save); +void G_SaveMapState(mapstate_t *save); int g_i,g_p; static int g_x; static intptr_t *g_t; spritetype *g_sp; -static int killit_flag; -int line_num; +static int g_killitFlag; +int g_errorLineNum; int g_tw; -static int parse(void); +static int X_DoExecute(void); -void scriptinfo(void) +void X_ScriptInfo(void) { if (script) { @@ -57,15 +57,15 @@ void scriptinfo(void) initprintf(" %d",*p); } initprintf("current actor: %d (%d)\n",g_i,g_sp->picnum); - initprintf("line_num: %d, g_tw: %d\n",line_num,g_tw); + initprintf("g_errorLineNum: %d, g_tw: %d\n",g_errorLineNum,g_tw); } } -void OnEvent(int iEventID, int iActor, int iPlayer, int lDist) +void X_OnEvent(int iEventID, int iActor, int iPlayer, int lDist) { - if ((iEventID<0 || iEventID >= MAXGAMEEVENTS) && checkCON) + if ((iEventID<0 || iEventID >= MAXGAMEEVENTS) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "invalid event ID",line_num,keyw[g_tw]); + OSD_Printf(CON_ERROR "invalid event ID",g_errorLineNum,keyw[g_tw]); return; } @@ -77,7 +77,7 @@ void OnEvent(int iEventID, int iActor, int iPlayer, int lDist) } { - int og_i=g_i, og_p=g_p, okillit_flag=killit_flag; + int og_i=g_i, og_p=g_p, okillit_flag=g_killitFlag; int og_x=g_x;// *og_t=g_t; intptr_t *oinsptr=insptr, *og_t=g_t; spritetype *og_sp=g_sp; @@ -86,17 +86,17 @@ void OnEvent(int iEventID, int iActor, int iPlayer, int lDist) g_p = iPlayer; // current player ID g_x = lDist; // ? g_sp = &sprite[g_i]; - g_t = &hittype[g_i].temp_data[0]; + g_t = &ActorExtra[g_i].temp_data[0]; insptr = (apScriptGameEvent[iEventID]); //Bsprintf(g_szBuf,"Executing event for %d at %lX",iEventID, insptr); //AddLog(g_szBuf); - killit_flag = 0; + g_killitFlag = 0; - while (1) if (parse()) break; + while (1) if (X_DoExecute()) break; - if (killit_flag == 1) + if (g_killitFlag == 1) { // if player was set to squish, first stop that... if (g_p >= 0) @@ -113,14 +113,14 @@ void OnEvent(int iEventID, int iActor, int iPlayer, int lDist) g_x=og_x; g_sp=og_sp; g_t=og_t; - killit_flag=okillit_flag; + g_killitFlag=okillit_flag; insptr=oinsptr; //AddLog("End of Execution"); } } -static int ifsquished(int i, int p) +static int A_CheckSquished(int i, int p) { sectortype *sc = §or[SECT]; int squishme = 0; @@ -138,14 +138,14 @@ static int ifsquished(int i, int p) if (squishme) { - FTA(10,g_player[p].ps); + P_DoQuote(10,g_player[p].ps); - if (badguy(&sprite[i])) sprite[i].xvel = 0; + if (A_CheckEnemySprite(&sprite[i])) sprite[i].xvel = 0; if (sprite[i].pal == 1) { - hittype[i].picnum = SHOTSPARK1; - hittype[i].extra = 1; + ActorExtra[i].picnum = SHOTSPARK1; + ActorExtra[i].extra = 1; return 0; } @@ -154,9 +154,9 @@ static int ifsquished(int i, int p) return 0; } -static void forceplayerangle(player_struct *p) +static void P_ForceAngle(DukePlayer_t *p) { - int n = 128-(TRAND&255); + int n = 128-(krand()&255); p->horiz += 64; p->return_to_center = 9; @@ -164,14 +164,14 @@ static void forceplayerangle(player_struct *p) p->rotscrnang = n>>1; } -static char dodge(spritetype *s) +static char A_Dodge(spritetype *s) { int bx,by,bxvect,byvect,d,i; int mx = s->x, my = s->y; int mxvect = sintable[(s->ang+512)&2047]; int myvect = sintable[s->ang&2047]; - for (i=headspritestat[4];i>=0;i=nextspritestat[i]) //weapons list + for (i=headspritestat[STAT_PROJECTILE];i>=0;i=nextspritestat[i]) //weapons list { if (OW == i || SECT != s->sectnum) continue; @@ -187,7 +187,7 @@ static char dodge(spritetype *s) d = bxvect*by - byvect*bx; if (klabs(d) < 65536*64) { - s->ang -= 512+(TRAND&1024); + s->ang -= 512+(krand()&1024); return 1; } } @@ -195,11 +195,11 @@ static char dodge(spritetype *s) return 0; } -int furthestangle(int iActor,int angs) +int A_GetFurthestAngle(int iActor,int angs) { spritetype *s = &sprite[iActor]; - if (s->picnum != APLAYER && (g_t[0]&63) > 2) + if (s->picnum != APLAYER && (ActorExtra[iActor].temp_data[0]&63) > 2) return(s->ang + 1024); { @@ -228,10 +228,9 @@ int furthestangle(int iActor,int angs) } } -int furthestcanseepoint(int iActor,spritetype *ts,int *dax,int *day) +int A_FurthestVisiblePoint(int iActor,spritetype *ts,int *dax,int *day) { - if ((g_t[0]&63)) return -1; - + if ((ActorExtra[iActor].temp_data[0]&63)) return -1; { short hitsect,hitwall,hitspr, angincs; int hx, hy, hz, d, da;//, d, cd, ca,tempx,tempy,cx,cy; @@ -240,13 +239,13 @@ int furthestcanseepoint(int iActor,spritetype *ts,int *dax,int *day) if (ud.multimode < 2 && ud.player_skill < 3) angincs = 2048/2; - else angincs = 2048/(1+(TRAND&1)); + else angincs = 2048/(1+(krand()&1)); - for (j=ts->ang;j<(2048+ts->ang);j+=(angincs-(TRAND&511))) + for (j=ts->ang;j<(2048+ts->ang);j+=(angincs-(krand()&511))) { hitscan(ts->x, ts->y, ts->z-(16<<8), ts->sectnum, sintable[(j+512)&2047], - sintable[j&2047],16384-(TRAND&32767), + sintable[j&2047],16384-(krand()&32767), &hitsect,&hitwall,&hitspr,&hx,&hy,&hz,CLIPMASK1); d = klabs(hx-ts->x)+klabs(hy-ts->y); @@ -264,7 +263,7 @@ int furthestcanseepoint(int iActor,spritetype *ts,int *dax,int *day) } } -void getglobalz(int iActor) +void A_GetZLimits(int iActor) { spritetype *s = &sprite[iActor]; @@ -275,63 +274,63 @@ void getglobalz(int iActor) if (s->statnum == 4) zr = 4L; - getzrange(s->x,s->y,s->z-(FOURSLEIGHT),s->sectnum,&hittype[iActor].ceilingz,&hz,&hittype[iActor].floorz,&lz,zr,CLIPMASK0); + getzrange(s->x,s->y,s->z-(FOURSLEIGHT),s->sectnum,&ActorExtra[iActor].ceilingz,&hz,&ActorExtra[iActor].floorz,&lz,zr,CLIPMASK0); if ((lz&49152) == 49152 && (sprite[lz&(MAXSPRITES-1)].cstat&48) == 0) { lz &= (MAXSPRITES-1); - if (badguy(&sprite[lz]) && sprite[lz].pal != 1) + if (A_CheckEnemySprite(&sprite[lz]) && sprite[lz].pal != 1) { if (s->statnum != 4) { - hittype[iActor].dispicnum = -4; // No shadows on actors + ActorExtra[iActor].dispicnum = -4; // No shadows on actors s->xvel = -256; - ssp(iActor,CLIPMASK0); + A_SetSprite(iActor,CLIPMASK0); } } - else if (sprite[lz].picnum == APLAYER && badguy(s)) + else if (sprite[lz].picnum == APLAYER && A_CheckEnemySprite(s)) { - hittype[iActor].dispicnum = -4; // No shadows on actors + ActorExtra[iActor].dispicnum = -4; // No shadows on actors s->xvel = -256; - ssp(iActor,CLIPMASK0); + A_SetSprite(iActor,CLIPMASK0); } else if (s->statnum == 4 && sprite[lz].picnum == APLAYER) if (s->owner == lz) { - hittype[iActor].ceilingz = sector[s->sectnum].ceilingz; - hittype[iActor].floorz = sector[s->sectnum].floorz; + ActorExtra[iActor].ceilingz = sector[s->sectnum].ceilingz; + ActorExtra[iActor].floorz = sector[s->sectnum].floorz; } } } else { - hittype[iActor].ceilingz = sector[s->sectnum].ceilingz; - hittype[iActor].floorz = sector[s->sectnum].floorz; + ActorExtra[iActor].ceilingz = sector[s->sectnum].ceilingz; + ActorExtra[iActor].floorz = sector[s->sectnum].floorz; } } -void makeitfall(int iActor) +void A_Fall(int iActor) { spritetype *s = &sprite[iActor]; - int hz,lz,c = gc; + int hz,lz,c = SpriteGravity; - if (floorspace(s->sectnum)) + if (G_CheckForSpaceFloor(s->sectnum)) c = 0; else { - if (ceilingspace(s->sectnum) || sector[s->sectnum].lotag == 2) - c = gc/6; + if (G_CheckForSpaceCeiling(s->sectnum) || sector[s->sectnum].lotag == 2) + c = SpriteGravity/6; } if ((s->statnum == 1 || s->statnum == 10 || s->statnum == 2 || s->statnum == 6)) - getzrange(s->x,s->y,s->z-(FOURSLEIGHT),s->sectnum,&hittype[iActor].ceilingz,&hz,&hittype[iActor].floorz,&lz,127L,CLIPMASK0); + getzrange(s->x,s->y,s->z-(FOURSLEIGHT),s->sectnum,&ActorExtra[iActor].ceilingz,&hz,&ActorExtra[iActor].floorz,&lz,127L,CLIPMASK0); else { - hittype[iActor].ceilingz = sector[s->sectnum].ceilingz; - hittype[iActor].floorz = sector[s->sectnum].floorz; + ActorExtra[iActor].ceilingz = sector[s->sectnum].ceilingz; + ActorExtra[iActor].floorz = sector[s->sectnum].floorz; } - if (s->z < hittype[iActor].floorz-(FOURSLEIGHT)) + if (s->z < ActorExtra[iActor].floorz-(FOURSLEIGHT)) { if (sector[s->sectnum].lotag == 2 && s->zvel > 3122) s->zvel = 3144; @@ -340,21 +339,21 @@ void makeitfall(int iActor) else s->zvel = 6144; s->z += s->zvel; } - if (s->z >= hittype[iActor].floorz-(FOURSLEIGHT)) + if (s->z >= ActorExtra[iActor].floorz-(FOURSLEIGHT)) { - s->z = hittype[iActor].floorz - FOURSLEIGHT; + s->z = ActorExtra[iActor].floorz - FOURSLEIGHT; s->zvel = 0; } } -int getincangle(int a,int na) +int G_GetAngleDelta(int a,int na) { a &= 2047; na &= 2047; if (klabs(a-na) < 1024) { -// OSD_Printf("getincangle() returning %d\n",na-a); +// OSD_Printf("G_GetAngleDelta() returning %d\n",na-a); return (na-a); } @@ -363,11 +362,11 @@ int getincangle(int a,int na) na -= 2048; a -= 2048; -// OSD_Printf("getincangle() returning %d\n",na-a); +// OSD_Printf("G_GetAngleDelta() returning %d\n",na-a); return (na-a); } -static void alterang(int a) +static void X_AlterAng(int a) { intptr_t *moveptr = (intptr_t *)g_t[1]; int ticselapsed = (g_t[0])&31; @@ -387,21 +386,21 @@ static void alterang(int a) else g_sp->owner = g_player[g_p].ps->i; if (sprite[g_sp->owner].picnum == APLAYER) - goalang = getangle(hittype[g_i].lastvx-g_sp->x,hittype[g_i].lastvy-g_sp->y); + goalang = getangle(ActorExtra[g_i].lastvx-g_sp->x,ActorExtra[g_i].lastvy-g_sp->y); else goalang = getangle(sprite[g_sp->owner].x-g_sp->x,sprite[g_sp->owner].y-g_sp->y); if (g_sp->xvel && g_sp->picnum != DRONE) { - angdif = getincangle(aang,goalang); + angdif = G_GetAngleDelta(aang,goalang); if (ticselapsed < 2) { if (klabs(angdif) < 256) { - j = 128-(TRAND&256); + j = 128-(krand()&256); g_sp->ang += j; - if (hits(g_i) < 844) + if (A_GetHitscanRange(g_i) < 844) g_sp->ang -= j; } } @@ -419,18 +418,18 @@ static void alterang(int a) int j = 2; if (a&furthestdir) { - g_sp->ang = furthestangle(g_i,j); + g_sp->ang = A_GetFurthestAngle(g_i,j); g_sp->owner = g_player[g_p].ps->i; } if (a&fleeenemy) { - g_sp->ang = furthestangle(g_i,j); // += angdif; // = getincangle(aang,goalang)>>1; + g_sp->ang = A_GetFurthestAngle(g_i,j); // += angdif; // = G_GetAngleDelta(aang,goalang)>>1; } } } -static void move(void) +static void X_Move(void) { int l; intptr_t *moveptr; @@ -446,7 +445,7 @@ static void move(void) if (g_player[g_p].ps->newowner >= 0) goalang = getangle(g_player[g_p].ps->oposx-g_sp->x,g_player[g_p].ps->oposy-g_sp->y); else goalang = getangle(g_player[g_p].ps->posx-g_sp->x,g_player[g_p].ps->posy-g_sp->y); - angdif = getincangle(g_sp->ang,goalang)>>2; + angdif = G_GetAngleDelta(g_sp->ang,goalang)>>2; if ((angdif > -8 && angdif < 0) || (angdif < 8 && angdif > 0)) angdif *= 2; g_sp->ang += angdif; @@ -460,7 +459,7 @@ static void move(void) if (g_player[g_p].ps->newowner >= 0) goalang = getangle(g_player[g_p].ps->oposx-g_sp->x,g_player[g_p].ps->oposy-g_sp->y); else goalang = getangle(g_player[g_p].ps->posx-g_sp->x,g_player[g_p].ps->posy-g_sp->y); - angdif = getincangle(g_sp->ang,goalang)>>4; + angdif = G_GetAngleDelta(g_sp->ang,goalang)>>4; if ((angdif > -8 && angdif < 0) || (angdif < 8 && angdif > 0)) angdif *= 2; g_sp->ang += angdif; @@ -478,7 +477,7 @@ static void move(void) int newy = g_player[g_p].ps->posy+(g_player[g_p].ps->posyv/768); goalang = getangle(newx-g_sp->x,newy-g_sp->y); - angdif = getincangle(g_sp->ang,goalang)>>2; + angdif = G_GetAngleDelta(g_sp->ang,goalang)>>2; if ((angdif > -8 && angdif < 0) || (angdif < 8 && angdif > 0)) angdif *= 2; g_sp->ang += angdif; @@ -486,10 +485,10 @@ static void move(void) if (g_t[1] == 0 || a == 0) { - if ((badguy(g_sp) && g_sp->extra <= 0) || (hittype[g_i].bposx != g_sp->x) || (hittype[g_i].bposy != g_sp->y)) + if ((A_CheckEnemySprite(g_sp) && g_sp->extra <= 0) || (ActorExtra[g_i].bposx != g_sp->x) || (ActorExtra[g_i].bposy != g_sp->y)) { - hittype[g_i].bposx = g_sp->x; - hittype[g_i].bposy = g_sp->y; + ActorExtra[g_i].bposx = g_sp->x; + ActorExtra[g_i].bposy = g_sp->y; setsprite(g_i,g_sp->x,g_sp->y,g_sp->z); } return; @@ -501,14 +500,14 @@ static void move(void) if (a&getv) g_sp->zvel += ((*(moveptr+1)<<4)-g_sp->zvel)>>1; if (a&dodgebullet) - dodge(g_sp); + A_Dodge(g_sp); if (g_sp->picnum != APLAYER) - alterang(a); + X_AlterAng(a); if (g_sp->xvel > -6 && g_sp->xvel < 6) g_sp->xvel = 0; - a = badguy(g_sp); + a = A_CheckEnemySprite(g_sp); if (g_sp->xvel || g_sp->zvel) { @@ -518,14 +517,14 @@ static void move(void) { if (g_sp->picnum == COMMANDER) { - hittype[g_i].floorz = l = getflorzofslope(g_sp->sectnum,g_sp->x,g_sp->y); + ActorExtra[g_i].floorz = l = getflorzofslope(g_sp->sectnum,g_sp->x,g_sp->y); if (g_sp->z > (l-(8<<8))) { if (g_sp->z > (l-(8<<8))) g_sp->z = l-(8<<8); g_sp->zvel = 0; } - hittype[g_i].ceilingz = l = getceilzofslope(g_sp->sectnum,g_sp->x,g_sp->y); + ActorExtra[g_i].ceilingz = l = getceilzofslope(g_sp->sectnum,g_sp->x,g_sp->y); if ((g_sp->z-l) < (80<<8)) { g_sp->z = l+(80<<8); @@ -536,13 +535,13 @@ static void move(void) { if (g_sp->zvel > 0) { - hittype[g_i].floorz = l = getflorzofslope(g_sp->sectnum,g_sp->x,g_sp->y); + ActorExtra[g_i].floorz = l = getflorzofslope(g_sp->sectnum,g_sp->x,g_sp->y); if (g_sp->z > (l-(30<<8))) g_sp->z = l-(30<<8); } else { - hittype[g_i].ceilingz = l = getceilzofslope(g_sp->sectnum,g_sp->x,g_sp->y); + ActorExtra[g_i].ceilingz = l = getceilzofslope(g_sp->sectnum,g_sp->x,g_sp->y); if ((g_sp->z-l) < (50<<8)) { g_sp->z = l+(50<<8); @@ -553,8 +552,8 @@ static void move(void) } else if (g_sp->picnum != ORGANTIC) { - if (g_sp->zvel > 0 && hittype[g_i].floorz < g_sp->z) - g_sp->z = hittype[g_i].floorz; + if (g_sp->zvel > 0 && ActorExtra[g_i].floorz < g_sp->z) + g_sp->z = ActorExtra[g_i].floorz; if (g_sp->zvel < 0) { l = getceilzofslope(g_sp->sectnum,g_sp->x,g_sp->y); @@ -567,8 +566,8 @@ static void move(void) } } else if (g_sp->picnum == APLAYER) - if ((g_sp->z-hittype[g_i].ceilingz) < (32<<8)) - g_sp->z = hittype[g_i].ceilingz+(32<<8); + if ((g_sp->z-ActorExtra[g_i].ceilingz) < (32<<8)) + g_sp->z = ActorExtra[g_i].ceilingz+(32<<8); daxvel = g_sp->xvel; angdif = g_sp->ang; @@ -594,7 +593,7 @@ static void move(void) } else if (g_sp->picnum != DRONE && g_sp->picnum != SHARK && g_sp->picnum != COMMANDER) { - if (hittype[g_i].bposz != g_sp->z || (ud.multimode < 2 && ud.player_skill < 2)) + if (ActorExtra[g_i].bposz != g_sp->z || (ud.multimode < 2 && ud.player_skill < 2)) { if ((g_t[0]&1) || g_player[g_p].ps->actorsqu == g_i) return; else daxvel <<= 1; @@ -607,9 +606,9 @@ static void move(void) } } - hittype[g_i].movflag = movesprite(g_i, - (daxvel*(sintable[(angdif+512)&2047]))>>14, - (daxvel*(sintable[angdif&2047]))>>14,g_sp->zvel,CLIPMASK0); + ActorExtra[g_i].movflag = A_MoveSprite(g_i, + (daxvel*(sintable[(angdif+512)&2047]))>>14, + (daxvel*(sintable[angdif&2047]))>>14,g_sp->zvel,CLIPMASK0); } if (a) @@ -623,13 +622,13 @@ static void move(void) } } -static inline void parseifelse(int condition) +static inline void X_DoConditional(int condition) { if (condition) { // skip 'else' pointer.. and... insptr+=2; - parse(); + X_DoExecute(); return; } insptr = (intptr_t *) *(insptr+1); @@ -638,23 +637,23 @@ static inline void parseifelse(int condition) // else... // skip 'else' and... insptr+=2; - parse(); + X_DoExecute(); } } // int *it = 0x00589a04; -static int parse(void) +static int X_DoExecute(void) { int j, l, s, tw = *insptr; - if (killit_flag) return 1; + if (g_killitFlag) return 1; - // if(*it == 1668249134L) gameexit("\nERR"); + // if(*it == 1668249134L) G_GameExit("\nERR"); // Bsprintf(g_szBuf,"Parsing: %d",*insptr); // AddLog(g_szBuf); - line_num = tw>>12; + g_errorLineNum = tw>>12; g_tw = tw &= 0xFFF; switch (tw) @@ -663,12 +662,12 @@ static int parse(void) insptr++; { int q = *insptr++, i = *insptr++; - if ((fta_quotes[q] == NULL || redefined_quotes[i] == NULL) && checkCON) + if ((ScriptQuotes[q] == NULL || ScriptQuoteRedefinitions[i] == NULL) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "%s %d null quote\n",line_num,keyw[g_tw],q,i); + OSD_Printf(CON_ERROR "%s %d null quote\n",g_errorLineNum,keyw[g_tw],q,i); break; } - Bstrcpy(fta_quotes[q],redefined_quotes[i]); + Bstrcpy(ScriptQuotes[q],ScriptQuoteRedefinitions[i]); break; } @@ -680,13 +679,13 @@ static int parse(void) // int lVar1=*insptr++, lLabelID=*insptr++, lVar2=*insptr++; - DoThisProjectile(tw==CON_SETTHISPROJECTILE,lVar1,lLabelID,lVar2); + X_AccessActiveProjectile(tw==CON_SETTHISPROJECTILE,lVar1,lLabelID,lVar2); break; } case CON_IFRND: insptr++; - parseifelse(rnd(*insptr)); + X_DoConditional(rnd(*insptr)); break; case CON_IFCANSHOOTTARGET: @@ -694,16 +693,16 @@ static int parse(void) { short temphit, sclip = 768, angdif = 16; - if (badguy(g_sp) && g_sp->xrepeat > 56) + if (A_CheckEnemySprite(g_sp) && g_sp->xrepeat > 56) { sclip = 3084; angdif = 48; } - j = hitasprite(g_i,&temphit); + j = A_CheckHitSprite(g_i,&temphit); if (j == (1<<30)) { - parseifelse(1); + X_DoConditional(1); break; } if (j > sclip) @@ -713,7 +712,7 @@ static int parse(void) else { g_sp->ang += angdif; - j = hitasprite(g_i,&temphit); + j = A_CheckHitSprite(g_i,&temphit); g_sp->ang -= angdif; if (j > sclip) { @@ -722,7 +721,7 @@ static int parse(void) else { g_sp->ang -= angdif; - j = hitasprite(g_i,&temphit); + j = A_CheckHitSprite(g_i,&temphit); g_sp->ang += angdif; if (j > 768) { @@ -740,17 +739,17 @@ static int parse(void) } else j = 1; - parseifelse(j); + X_DoConditional(j); break; case CON_IFCANSEETARGET: - j = cansee(g_sp->x,g_sp->y,g_sp->z-((TRAND&41)<<8),g_sp->sectnum,g_player[g_p].ps->posx,g_player[g_p].ps->posy,g_player[g_p].ps->posz/*-((TRAND&41)<<8)*/,sprite[g_player[g_p].ps->i].sectnum); - parseifelse(j); - if (j) hittype[g_i].timetosleep = SLEEPTIME; + j = cansee(g_sp->x,g_sp->y,g_sp->z-((krand()&41)<<8),g_sp->sectnum,g_player[g_p].ps->posx,g_player[g_p].ps->posy,g_player[g_p].ps->posz/*-((krand()&41)<<8)*/,sprite[g_player[g_p].ps->i].sectnum); + X_DoConditional(j); + if (j) ActorExtra[g_i].timetosleep = SLEEPTIME; break; case CON_IFACTORNOTSTAYPUT: - parseifelse(hittype[g_i].actorstayput == -1); + X_DoConditional(ActorExtra[g_i].actorstayput == -1); break; case CON_IFCANSEE: @@ -763,7 +762,7 @@ static int parse(void) if (g_player[g_p].ps->holoduke_on >= 0) { s = &sprite[g_player[g_p].ps->holoduke_on]; - j = cansee(g_sp->x,g_sp->y,g_sp->z-(TRAND&((32<<8)-1)),g_sp->sectnum, + j = cansee(g_sp->x,g_sp->y,g_sp->z-(krand()&((32<<8)-1)),g_sp->sectnum, s->x,s->y,s->z,s->sectnum); if (j == 0) @@ -776,7 +775,7 @@ static int parse(void) else s = &sprite[g_player[g_p].ps->i]; // holoduke not on. look for player // can they see player, (or player's holoduke) - j = cansee(g_sp->x,g_sp->y,g_sp->z-(TRAND&((47<<8))),g_sp->sectnum, + j = cansee(g_sp->x,g_sp->y,g_sp->z-(krand()&((47<<8))),g_sp->sectnum, s->x,s->y,s->z-(24<<8),s->sectnum); if (j == 0) @@ -785,8 +784,8 @@ static int parse(void) // Huh?. This does nothing.... // (the result is always j==0....) - if ((klabs(hittype[g_i].lastvx-g_sp->x)+klabs(hittype[g_i].lastvy-g_sp->y)) < - (klabs(hittype[g_i].lastvx-s->x)+klabs(hittype[g_i].lastvy-s->y))) + if ((klabs(ActorExtra[g_i].lastvx-g_sp->x)+klabs(ActorExtra[g_i].lastvy-g_sp->y)) < + (klabs(ActorExtra[g_i].lastvx-s->x)+klabs(ActorExtra[g_i].lastvy-s->y))) j = 0; // um yeah, this if() will always fire.... @@ -796,7 +795,7 @@ static int parse(void) // also modifies 'target' x&y if found.. - j = furthestcanseepoint(g_i,s,&hittype[g_i].lastvx,&hittype[g_i].lastvy); + j = A_FurthestVisiblePoint(g_i,s,&ActorExtra[g_i].lastvx,&ActorExtra[g_i].lastvy); if (j == -1) j = 0; else j = 1; @@ -806,30 +805,30 @@ static int parse(void) { // else, they did see it. // save where we were looking... - hittype[g_i].lastvx = s->x; - hittype[g_i].lastvy = s->y; + ActorExtra[g_i].lastvx = s->x; + ActorExtra[g_i].lastvy = s->y; } if (j == 1 && (g_sp->statnum == 1 || g_sp->statnum == 6)) - hittype[g_i].timetosleep = SLEEPTIME; + ActorExtra[g_i].timetosleep = SLEEPTIME; - parseifelse(j == 1); + X_DoConditional(j == 1); break; } case CON_IFHITWEAPON: - parseifelse(ifhitbyweapon(g_i) >= 0); + X_DoConditional(A_IncurDamage(g_i) >= 0); break; case CON_IFSQUISHED: - parseifelse(ifsquished(g_i, g_p) == 1); + X_DoConditional(A_CheckSquished(g_i, g_p) == 1); break; case CON_IFDEAD: j = g_sp->extra; if (g_sp->picnum == APLAYER) j--; - parseifelse(j < 0); + X_DoConditional(j < 0); break; case CON_AI: @@ -841,7 +840,7 @@ static int parse(void) g_sp->hitag = *(((intptr_t *)g_t[5])+2); // move flags g_t[0] = g_t[2] = g_t[3] = 0; // count, actioncount... g_t[3] = ??? if (g_sp->hitag&random_angle) - g_sp->ang = TRAND&2047; + g_sp->ang = krand()&2047; break; case CON_ACTION: @@ -853,16 +852,16 @@ static int parse(void) case CON_IFPDISTL: insptr++; - parseifelse(g_x < *insptr); - if (g_x > MAXSLEEPDIST && hittype[g_i].timetosleep == 0) - hittype[g_i].timetosleep = SLEEPTIME; + X_DoConditional(g_x < *insptr); + if (g_x > MAXSLEEPDIST && ActorExtra[g_i].timetosleep == 0) + ActorExtra[g_i].timetosleep = SLEEPTIME; break; case CON_IFPDISTG: insptr++; - parseifelse(g_x > *insptr); - if (g_x > MAXSLEEPDIST && hittype[g_i].timetosleep == 0) - hittype[g_i].timetosleep = SLEEPTIME; + X_DoConditional(g_x > *insptr); + if (g_x > MAXSLEEPDIST && ActorExtra[g_i].timetosleep == 0) + ActorExtra[g_i].timetosleep = SLEEPTIME; break; case CON_ELSE: @@ -882,7 +881,7 @@ static int parse(void) case CON_IFGOTWEAPONCE: insptr++; - if ((gametype_flags[ud.coop]&GAMETYPE_FLAG_WEAPSTAY) && ud.multimode > 1) + if ((GametypeFlags[ud.coop]&GAMETYPE_WEAPSTAY) && ud.multimode > 1) { if (*insptr == 0) { @@ -890,29 +889,29 @@ static int parse(void) if (g_player[g_p].ps->weaprecs[j] == g_sp->picnum) break; - parseifelse(j < g_player[g_p].ps->weapreccnt && g_sp->owner == g_i); + X_DoConditional(j < g_player[g_p].ps->weapreccnt && g_sp->owner == g_i); } else if (g_player[g_p].ps->weapreccnt < 16) { g_player[g_p].ps->weaprecs[g_player[g_p].ps->weapreccnt++] = g_sp->picnum; - parseifelse(g_sp->owner == g_i); + X_DoConditional(g_sp->owner == g_i); } - else parseifelse(0); + else X_DoConditional(0); } - else parseifelse(0); + else X_DoConditional(0); break; case CON_GETLASTPAL: insptr++; if (g_sp->picnum == APLAYER) g_sp->pal = g_player[g_sp->yvel].ps->palookup; - else g_sp->pal = hittype[g_i].tempang; - hittype[g_i].tempang = 0; + else g_sp->pal = ActorExtra[g_i].tempang; + ActorExtra[g_i].tempang = 0; break; case CON_TOSSWEAPON: insptr++; - checkweapons(g_player[g_sp->yvel].ps); + P_DropWeapon(g_player[g_sp->yvel].ps); break; case CON_NULLOP: @@ -921,14 +920,14 @@ static int parse(void) case CON_MIKESND: insptr++; - if ((g_sp->yvel<0 || g_sp->yvel>=MAXSOUNDS) && checkCON) + if ((g_sp->yvel<0 || g_sp->yvel>=MAXSOUNDS) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "Invalid sound %d\n",line_num,keyw[g_tw],g_sp->yvel); + OSD_Printf(CON_ERROR "Invalid sound %d\n",g_errorLineNum,keyw[g_tw],g_sp->yvel); insptr++; break; } - if (!isspritemakingsound(g_i,g_sp->yvel)) - spritesound(g_sp->yvel,g_i); + if (!A_CheckSoundPlaying(g_i,g_sp->yvel)) + A_PlaySound(g_sp->yvel,g_i); break; case CON_PKICK: @@ -949,7 +948,7 @@ static int parse(void) j = (*insptr++-g_sp->xrepeat)<<1; g_sp->xrepeat += ksgn(j); - if ((g_sp->picnum == APLAYER && g_sp->yrepeat < 36) || *insptr < g_sp->yrepeat || ((g_sp->yrepeat*(tilesizy[g_sp->picnum]+8))<<2) < (hittype[g_i].floorz - hittype[g_i].ceilingz)) + if ((g_sp->picnum == APLAYER && g_sp->yrepeat < 36) || *insptr < g_sp->yrepeat || ((g_sp->yrepeat*(tilesizy[g_sp->picnum]+8))<<2) < (ActorExtra[g_i].floorz - ActorExtra[g_i].ceilingz)) { j = ((*insptr)-g_sp->yrepeat)<<1; if (klabs(j)) g_sp->yrepeat += ksgn(j); @@ -966,64 +965,64 @@ static int parse(void) case CON_SHOOT: insptr++; - shoot(g_i,(short)*insptr++); + A_Shoot(g_i,(short)*insptr++); break; case CON_SOUNDONCE: insptr++; - if ((*insptr<0 || *insptr>=MAXSOUNDS) && checkCON) + if ((*insptr<0 || *insptr>=MAXSOUNDS) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "Invalid sound %d\n",line_num,keyw[g_tw],*insptr); + OSD_Printf(CON_ERROR "Invalid sound %d\n",g_errorLineNum,keyw[g_tw],*insptr); insptr++;break; } - if (!isspritemakingsound(g_i,*insptr)) - spritesound((short) *insptr,g_i); + if (!A_CheckSoundPlaying(g_i,*insptr)) + A_PlaySound((short) *insptr,g_i); insptr++; break; case CON_IFSOUND: insptr++; - if ((*insptr<0 || *insptr>=MAXSOUNDS) && checkCON) + if ((*insptr<0 || *insptr>=MAXSOUNDS) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "Invalid sound %d\n",line_num,keyw[g_tw],*insptr); + OSD_Printf(CON_ERROR "Invalid sound %d\n",g_errorLineNum,keyw[g_tw],*insptr); insptr++;break; } - parseifelse(isspritemakingsound(g_i,*insptr)); - // parseifelse(SoundOwner[*insptr][0].i == g_i); + X_DoConditional(A_CheckSoundPlaying(g_i,*insptr)); + // X_DoConditional(SoundOwner[*insptr][0].i == g_i); break; case CON_STOPSOUND: insptr++; - if ((*insptr<0 || *insptr>=MAXSOUNDS) && checkCON) + if ((*insptr<0 || *insptr>=MAXSOUNDS) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "Invalid sound %d\n",line_num,keyw[g_tw],*insptr); + OSD_Printf(CON_ERROR "Invalid sound %d\n",g_errorLineNum,keyw[g_tw],*insptr); insptr++;break; } - if (isspritemakingsound(g_i,*insptr)) - stopspritesound((short)*insptr,g_i); + if (A_CheckSoundPlaying(g_i,*insptr)) + A_StopSound((short)*insptr,g_i); insptr++; break; case CON_GLOBALSOUND: insptr++; - if ((*insptr<0 || *insptr>=MAXSOUNDS) && checkCON) + if ((*insptr<0 || *insptr>=MAXSOUNDS) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "Invalid sound %d\n",line_num,keyw[g_tw],*insptr); + OSD_Printf(CON_ERROR "Invalid sound %d\n",g_errorLineNum,keyw[g_tw],*insptr); insptr++;break; } - if (g_p == screenpeek || (gametype_flags[ud.coop]&GAMETYPE_FLAG_COOPSOUND)) - spritesound((short) *insptr,g_player[screenpeek].ps->i); + if (g_p == screenpeek || (GametypeFlags[ud.coop]&GAMETYPE_COOPSOUND)) + A_PlaySound((short) *insptr,g_player[screenpeek].ps->i); insptr++; break; case CON_SOUND: insptr++; - if ((*insptr<0 || *insptr>=MAXSOUNDS) && checkCON) + if ((*insptr<0 || *insptr>=MAXSOUNDS) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "Invalid sound %d\n",line_num,keyw[g_tw],*insptr); + OSD_Printf(CON_ERROR "Invalid sound %d\n",g_errorLineNum,keyw[g_tw],*insptr); insptr++;break; } - spritesound((short) *insptr++,g_i); + A_PlaySound((short) *insptr++,g_i); break; case CON_TIP: @@ -1035,43 +1034,43 @@ static int parse(void) insptr++; g_sp->xoffset = g_sp->yoffset = 0; - j = gc; + j = SpriteGravity; - if (ceilingspace(g_sp->sectnum) || sector[g_sp->sectnum].lotag == 2) - j = gc/6; - else if (floorspace(g_sp->sectnum)) + if (G_CheckForSpaceCeiling(g_sp->sectnum) || sector[g_sp->sectnum].lotag == 2) + j = SpriteGravity/6; + else if (G_CheckForSpaceFloor(g_sp->sectnum)) j = 0; - if (!hittype[g_i].cgg-- || (sector[g_sp->sectnum].floorstat&2)) + if (!ActorExtra[g_i].cgg-- || (sector[g_sp->sectnum].floorstat&2)) { - getglobalz(g_i); - hittype[g_i].cgg = 3; + A_GetZLimits(g_i); + ActorExtra[g_i].cgg = 3; } - if (g_sp->z < (hittype[g_i].floorz-FOURSLEIGHT)) + if (g_sp->z < (ActorExtra[g_i].floorz-FOURSLEIGHT)) { g_sp->z += g_sp->zvel += j; if (g_sp->zvel > 6144) g_sp->zvel = 6144; - if (g_sp->z > (hittype[g_i].floorz - FOURSLEIGHT)) - g_sp->z = (hittype[g_i].floorz - FOURSLEIGHT); + if (g_sp->z > (ActorExtra[g_i].floorz - FOURSLEIGHT)) + g_sp->z = (ActorExtra[g_i].floorz - FOURSLEIGHT); break; } - g_sp->z = hittype[g_i].floorz - FOURSLEIGHT; + g_sp->z = ActorExtra[g_i].floorz - FOURSLEIGHT; - if (badguy(g_sp) || (g_sp->picnum == APLAYER && g_sp->owner >= 0)) + if (A_CheckEnemySprite(g_sp) || (g_sp->picnum == APLAYER && g_sp->owner >= 0)) { if (g_sp->zvel > 3084 && g_sp->extra <= 1) { if (!(g_sp->picnum == APLAYER && g_sp->extra > 0) && g_sp->pal != 1 && g_sp->picnum != DRONE) { - guts(g_i,JIBS6,15); - spritesound(SQUISHED,g_i); - spawn(g_i,BLOODPOOL); + A_DoGuts(g_i,JIBS6,15); + A_PlaySound(SQUISHED,g_i); + A_Spawn(g_i,BLOODPOOL); } - hittype[g_i].picnum = SHOTSPARK1; - hittype[g_i].extra = 1; + ActorExtra[g_i].picnum = SHOTSPARK1; + ActorExtra[g_i].extra = 1; g_sp->zvel = 0; } else if (g_sp->zvel > 2048 && sector[g_sp->sectnum].lotag != 1) @@ -1080,21 +1079,21 @@ static int parse(void) pushmove(&g_sp->x,&g_sp->y,&g_sp->z,(short*)&j,128L,(4L<<8),(4L<<8),CLIPMASK0); if (j != g_sp->sectnum && j >= 0 && j < MAXSECTORS) changespritesect(g_i,j); - spritesound(THUD,g_i); + A_PlaySound(THUD,g_i); } } - if (g_sp->z > (hittype[g_i].floorz - FOURSLEIGHT)) + if (g_sp->z > (ActorExtra[g_i].floorz - FOURSLEIGHT)) { - getglobalz(g_i); - if (hittype[g_i].floorz != sector[g_sp->sectnum].floorz) - g_sp->z = (hittype[g_i].floorz - FOURSLEIGHT); + A_GetZLimits(g_i); + if (ActorExtra[g_i].floorz != sector[g_sp->sectnum].floorz) + g_sp->z = (ActorExtra[g_i].floorz - FOURSLEIGHT); break; } else if (sector[g_sp->sectnum].lotag == 1) { intptr_t *moveptr = (intptr_t *)g_t[1]; - switch (dynamictostatic[g_sp->picnum]) + switch (DynamicTileMap[g_sp->picnum]) { default: // fix for flying/jumping monsters getting stuck in water @@ -1125,83 +1124,83 @@ static int parse(void) return 1; case CON_ADDAMMO: insptr++; - if ((*insptr<0 || *insptr>=MAX_WEAPONS) && checkCON) + if ((*insptr<0 || *insptr>=MAX_WEAPONS) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "Invalid weapon ID %d\n",line_num,keyw[g_tw],*insptr); + OSD_Printf(CON_ERROR "Invalid weapon ID %d\n",g_errorLineNum,keyw[g_tw],*insptr); insptr+=2;break; } if (g_player[g_p].ps->ammo_amount[*insptr] >= g_player[g_p].ps->max_ammo_amount[*insptr]) { - killit_flag = 2; + g_killitFlag = 2; break; } - addammo(*insptr, g_player[g_p].ps, *(insptr+1)); + P_AddAmmo(*insptr, g_player[g_p].ps, *(insptr+1)); if (g_player[g_p].ps->curr_weapon == KNEE_WEAPON && g_player[g_p].ps->gotweapon[*insptr]) { - if (!(g_player[g_p].ps->weaponswitch & 1)) addweaponnoswitch(g_player[g_p].ps, *insptr); - else addweapon(g_player[g_p].ps, *insptr); + if (!(g_player[g_p].ps->weaponswitch & 1)) P_AddWeaponNoSwitch(g_player[g_p].ps, *insptr); + else P_AddWeapon(g_player[g_p].ps, *insptr); } insptr += 2; break; case CON_MONEY: insptr++; - lotsofmoneymailpaper(g_i,*insptr++,MONEY); + A_SpawnMultiple(g_i, MONEY, *insptr++); break; case CON_MAIL: insptr++; - lotsofmoneymailpaper(g_i,*insptr++,MAIL); + A_SpawnMultiple(g_i, MAIL, *insptr++); break; case CON_SLEEPTIME: insptr++; - hittype[g_i].timetosleep = (short)*insptr++; + ActorExtra[g_i].timetosleep = (short)*insptr++; break; case CON_PAPER: insptr++; - lotsofmoneymailpaper(g_i,*insptr++,PAPER); + A_SpawnMultiple(g_i, PAPER, *insptr++); break; case CON_ADDKILLS: insptr++; g_player[g_p].ps->actors_killed += *insptr++; - hittype[g_i].actorstayput = -1; + ActorExtra[g_i].actorstayput = -1; break; case CON_LOTSOFGLASS: insptr++; - spriteglass(g_i,*insptr++); + A_SpawnGlass(g_i,*insptr++); break; case CON_KILLIT: insptr++; - killit_flag = 1; + g_killitFlag = 1; break; case CON_ADDWEAPON: insptr++; - if ((*insptr<0 ||*insptr>=MAX_WEAPONS) && checkCON) + if ((*insptr<0 ||*insptr>=MAX_WEAPONS) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "Invalid weapon ID %d\n",line_num,keyw[g_tw],*insptr); + OSD_Printf(CON_ERROR "Invalid weapon ID %d\n",g_errorLineNum,keyw[g_tw],*insptr); insptr+=2;break; } if (g_player[g_p].ps->gotweapon[*insptr] == 0) { - if (!(g_player[g_p].ps->weaponswitch & 1)) addweaponnoswitch(g_player[g_p].ps, *insptr); - else addweapon(g_player[g_p].ps, *insptr); + if (!(g_player[g_p].ps->weaponswitch & 1)) P_AddWeaponNoSwitch(g_player[g_p].ps, *insptr); + else P_AddWeapon(g_player[g_p].ps, *insptr); } else if (g_player[g_p].ps->ammo_amount[*insptr] >= g_player[g_p].ps->max_ammo_amount[*insptr]) { - killit_flag = 2; + g_killitFlag = 2; break; } - addammo(*insptr, g_player[g_p].ps, *(insptr+1)); + P_AddAmmo(*insptr, g_player[g_p].ps, *(insptr+1)); if (g_player[g_p].ps->curr_weapon == KNEE_WEAPON && g_player[g_p].ps->gotweapon[*insptr]) { - if (!(g_player[g_p].ps->weaponswitch & 1)) addweaponnoswitch(g_player[g_p].ps, *insptr); - else addweapon(g_player[g_p].ps, *insptr); + if (!(g_player[g_p].ps->weaponswitch & 1)) P_AddWeaponNoSwitch(g_player[g_p].ps, *insptr); + else P_AddWeapon(g_player[g_p].ps, *insptr); } insptr+=2; break; @@ -1229,9 +1228,9 @@ static int parse(void) g_player[g_p].ps->posz = g_player[g_p].ps->oposz; g_player[g_p].ps->ang = g_player[g_p].ps->oang; updatesector(g_player[g_p].ps->posx,g_player[g_p].ps->posy,&g_player[g_p].ps->cursectnum); - setpal(g_player[g_p].ps); + P_UpdateScreenPal(g_player[g_p].ps); - j = headspritestat[1]; + j = headspritestat[STAT_ACTOR]; while (j >= 0) { if (sprite[j].picnum==CAMERA1) @@ -1273,7 +1272,7 @@ static int parse(void) { if ((j - *insptr) < (g_player[g_p].ps->max_player_health>>2) && j >= (g_player[g_p].ps->max_player_health>>2)) - spritesound(DUKE_GOTHEALTHATLOW,g_player[g_p].ps->i); + A_PlaySound(DUKE_GOTHEALTHATLOW,g_player[g_p].ps->i); g_player[g_p].ps->last_extra = j; } @@ -1289,14 +1288,14 @@ static int parse(void) intptr_t *tempscrptr=insptr+2; insptr = (intptr_t *) *(insptr+1); - while (1) if (parse()) break; + while (1) if (X_DoExecute()) break; insptr = tempscrptr; } break; case CON_LEFTBRACE: insptr++; - while (1) if (parse()) break; + while (1) if (X_DoExecute()) break; break; case CON_MOVE: @@ -1305,26 +1304,26 @@ static int parse(void) g_t[1] = *insptr++; g_sp->hitag = *insptr++; if (g_sp->hitag&random_angle) - g_sp->ang = TRAND&2047; + g_sp->ang = krand()&2047; break; case CON_ADDWEAPONVAR: insptr++; - if (g_player[g_p].ps->gotweapon[GetGameVarID(*(insptr),g_i,g_p)] == 0) + if (g_player[g_p].ps->gotweapon[Gv_GetVar(*(insptr),g_i,g_p)] == 0) { - if (!(g_player[g_p].ps->weaponswitch & 1)) addweaponnoswitch(g_player[g_p].ps, GetGameVarID(*(insptr),g_i,g_p)); - else addweapon(g_player[g_p].ps, GetGameVarID(*(insptr),g_i,g_p)); + if (!(g_player[g_p].ps->weaponswitch & 1)) P_AddWeaponNoSwitch(g_player[g_p].ps, Gv_GetVar(*(insptr),g_i,g_p)); + else P_AddWeapon(g_player[g_p].ps, Gv_GetVar(*(insptr),g_i,g_p)); } - else if (g_player[g_p].ps->ammo_amount[GetGameVarID(*(insptr),g_i,g_p)] >= g_player[g_p].ps->max_ammo_amount[GetGameVarID(*(insptr),g_i,g_p)]) + else if (g_player[g_p].ps->ammo_amount[Gv_GetVar(*(insptr),g_i,g_p)] >= g_player[g_p].ps->max_ammo_amount[Gv_GetVar(*(insptr),g_i,g_p)]) { - killit_flag = 2; + g_killitFlag = 2; break; } - addammo(GetGameVarID(*(insptr),g_i,g_p), g_player[g_p].ps, GetGameVarID(*(insptr+1),g_i,g_p)); - if (g_player[g_p].ps->curr_weapon == KNEE_WEAPON && g_player[g_p].ps->gotweapon[GetGameVarID(*(insptr),g_i,g_p)]) + P_AddAmmo(Gv_GetVar(*(insptr),g_i,g_p), g_player[g_p].ps, Gv_GetVar(*(insptr+1),g_i,g_p)); + if (g_player[g_p].ps->curr_weapon == KNEE_WEAPON && g_player[g_p].ps->gotweapon[Gv_GetVar(*(insptr),g_i,g_p)]) { - if (!(g_player[g_p].ps->weaponswitch & 1)) addweaponnoswitch(g_player[g_p].ps, GetGameVarID(*(insptr),g_i,g_p)); - else addweapon(g_player[g_p].ps, GetGameVarID(*(insptr),g_i,g_p)); + if (!(g_player[g_p].ps->weaponswitch & 1)) P_AddWeaponNoSwitch(g_player[g_p].ps, Gv_GetVar(*(insptr),g_i,g_p)); + else P_AddWeapon(g_player[g_p].ps, Gv_GetVar(*(insptr),g_i,g_p)); } insptr+=2; break; @@ -1336,34 +1335,34 @@ static int parse(void) case CON_SSP: insptr++; { - int var1 = GetGameVarID(*insptr++,g_i,g_p), var2; + int var1 = Gv_GetVar(*insptr++,g_i,g_p), var2; if (tw == CON_OPERATEACTIVATORS && *insptr == g_iThisActorID) { var2 = g_p; insptr++; } - else var2 = GetGameVarID(*insptr++,g_i,g_p); + else var2 = Gv_GetVar(*insptr++,g_i,g_p); switch (tw) { case CON_ACTIVATEBYSECTOR: - if ((var1<0 || var1>=numsectors) && checkCON) {OSD_Printf(CON_ERROR "Invalid sector %d\n",line_num,keyw[g_tw],var1);break;} + if ((var1<0 || var1>=numsectors) && g_scriptSanityChecks) {OSD_Printf(CON_ERROR "Invalid sector %d\n",g_errorLineNum,keyw[g_tw],var1);break;} activatebysector(var1, var2); break; case CON_OPERATESECTORS: - if ((var1<0 || var1>=numsectors) && checkCON) {OSD_Printf(CON_ERROR "Invalid sector %d\n",line_num,keyw[g_tw],var1);break;} - operatesectors(var1, var2); + if ((var1<0 || var1>=numsectors) && g_scriptSanityChecks) {OSD_Printf(CON_ERROR "Invalid sector %d\n",g_errorLineNum,keyw[g_tw],var1);break;} + G_OperateSectors(var1, var2); break; case CON_OPERATEACTIVATORS: - if ((var2<0 || var2>=ud.multimode) && checkCON) {OSD_Printf(CON_ERROR "Invalid player %d\n",line_num,keyw[g_tw],var2);break;} - operateactivators(var1, var2); + if ((var2<0 || var2>=ud.multimode) && g_scriptSanityChecks) {OSD_Printf(CON_ERROR "Invalid player %d\n",g_errorLineNum,keyw[g_tw],var2);break;} + G_OperateActivators(var1, var2); break; case CON_SETASPECT: setaspect(var1, var2); break; case CON_SSP: - if ((var1<0 || var1>=MAXSPRITES) && checkCON) { OSD_Printf(CON_ERROR "Invalid sprite %d\n",line_num,keyw[g_tw],var1);break;} - ssp(var1, var2); + if ((var1<0 || var1>=MAXSPRITES) && g_scriptSanityChecks) { OSD_Printf(CON_ERROR "Invalid sprite %d\n",g_errorLineNum,keyw[g_tw],var1);break;} + A_SetSprite(var1, var2); break; } break; @@ -1372,17 +1371,17 @@ static int parse(void) case CON_CANSEESPR: insptr++; { - int lVar1 = GetGameVarID(*insptr++,g_i,g_p), lVar2 = GetGameVarID(*insptr++,g_i,g_p), res; + int lVar1 = Gv_GetVar(*insptr++,g_i,g_p), lVar2 = Gv_GetVar(*insptr++,g_i,g_p), res; - if ((lVar1<0 || lVar1>=MAXSPRITES || lVar2<0 || lVar2>=MAXSPRITES) && checkCON) + if ((lVar1<0 || lVar1>=MAXSPRITES || lVar2<0 || lVar2>=MAXSPRITES) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "Invalid sprite %d\n",line_num,keyw[g_tw],lVar1<0||lVar1>=MAXSPRITES?lVar1:lVar2); + OSD_Printf(CON_ERROR "Invalid sprite %d\n",g_errorLineNum,keyw[g_tw],lVar1<0||lVar1>=MAXSPRITES?lVar1:lVar2); res=0; } else res=cansee(sprite[lVar1].x,sprite[lVar1].y,sprite[lVar1].z,sprite[lVar1].sectnum, sprite[lVar2].x,sprite[lVar2].y,sprite[lVar2].z,sprite[lVar2].sectnum); - SetGameVarID(*insptr++, res, g_i, g_p); + Gv_SetVar(*insptr++, res, g_i, g_p); break; } @@ -1391,18 +1390,18 @@ static int parse(void) case CON_CHECKACTIVATORMOTION: insptr++; { - int var1 = GetGameVarID(*insptr++,g_i,g_p); + int var1 = Gv_GetVar(*insptr++,g_i,g_p); switch (tw) { case CON_OPERATERESPAWNS: - operaterespawns(var1); + G_OperateRespawns(var1); break; case CON_OPERATEMASTERSWITCHES: - operatemasterswitches(var1); + G_OperateMasterSwitches(var1); break; case CON_CHECKACTIVATORMOTION: - SetGameVarID(g_iReturnVarID, check_activator_motion(var1), g_i, g_p); + Gv_SetVar(g_iReturnVarID, check_activator_motion(var1), g_i, g_p); break; } break; @@ -1410,21 +1409,21 @@ static int parse(void) case CON_INSERTSPRITEQ: insptr++; - insertspriteq(g_i); + A_AddToDeleteQueue(g_i); break; case CON_QSTRLEN: insptr++; { int i=*insptr++; - j=GetGameVarID(*insptr++, g_i, g_p); - if ((fta_quotes[j] == NULL) && checkCON) + j=Gv_GetVar(*insptr++, g_i, g_p); + if ((ScriptQuotes[j] == NULL) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "null quote %d\n",line_num,keyw[g_tw],j); - SetGameVarID(i,-1,g_i,g_p); + OSD_Printf(CON_ERROR "null quote %d\n",g_errorLineNum,keyw[g_tw],j); + Gv_SetVar(i,-1,g_i,g_p); break; } - SetGameVarID(i,Bstrlen(fta_quotes[j]),g_i,g_p); + Gv_SetVar(i,Bstrlen(ScriptQuotes[j]),g_i,g_p); break; } @@ -1437,56 +1436,56 @@ static int parse(void) insptr++; { int i=*insptr++; - j=GetGameVarID(*insptr++, g_i, g_p); + j=Gv_GetVar(*insptr++, g_i, g_p); switch (tw) { case CON_HEADSPRITESTAT: - if ((j < 0 || j > MAXSTATUS) && checkCON) + if ((j < 0 || j > MAXSTATUS) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "invalid status list %d\n",line_num,keyw[g_tw],j); + OSD_Printf(CON_ERROR "invalid status list %d\n",g_errorLineNum,keyw[g_tw],j); break; } - SetGameVarID(i,headspritestat[j],g_i,g_p); + Gv_SetVar(i,headspritestat[j],g_i,g_p); break; case CON_PREVSPRITESTAT: - if ((j < 0 || j >= MAXSPRITES) && checkCON) + if ((j < 0 || j >= MAXSPRITES) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "invalid sprite ID %d\n",line_num,keyw[g_tw],j); + OSD_Printf(CON_ERROR "invalid sprite ID %d\n",g_errorLineNum,keyw[g_tw],j); break; } - SetGameVarID(i,prevspritestat[j],g_i,g_p); + Gv_SetVar(i,prevspritestat[j],g_i,g_p); break; case CON_NEXTSPRITESTAT: - if ((j < 0 || j >= MAXSPRITES) && checkCON) + if ((j < 0 || j >= MAXSPRITES) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "invalid sprite ID %d\n",line_num,keyw[g_tw],j); + OSD_Printf(CON_ERROR "invalid sprite ID %d\n",g_errorLineNum,keyw[g_tw],j); break; } - SetGameVarID(i,nextspritestat[j],g_i,g_p); + Gv_SetVar(i,nextspritestat[j],g_i,g_p); break; case CON_HEADSPRITESECT: - if ((j < 0 || j > numsectors) && checkCON) + if ((j < 0 || j > numsectors) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "invalid sector %d\n",line_num,keyw[g_tw],j); + OSD_Printf(CON_ERROR "invalid sector %d\n",g_errorLineNum,keyw[g_tw],j); break; } - SetGameVarID(i,headspritesect[j],g_i,g_p); + Gv_SetVar(i,headspritesect[j],g_i,g_p); break; case CON_PREVSPRITESECT: - if ((j < 0 || j >= MAXSPRITES) && checkCON) + if ((j < 0 || j >= MAXSPRITES) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "invalid sprite ID %d\n",line_num,keyw[g_tw],j); + OSD_Printf(CON_ERROR "invalid sprite ID %d\n",g_errorLineNum,keyw[g_tw],j); break; } - SetGameVarID(i,prevspritesect[j],g_i,g_p); + Gv_SetVar(i,prevspritesect[j],g_i,g_p); break; case CON_NEXTSPRITESECT: - if ((j < 0 || j >= MAXSPRITES) && checkCON) + if ((j < 0 || j >= MAXSPRITES) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "invalid sprite ID %d\n",line_num,keyw[g_tw],j); + OSD_Printf(CON_ERROR "invalid sprite ID %d\n",g_errorLineNum,keyw[g_tw],j); break; } - SetGameVarID(i,nextspritesect[j],g_i,g_p); + Gv_SetVar(i,nextspritesect[j],g_i,g_p); break; } break; @@ -1495,15 +1494,15 @@ static int parse(void) case CON_GETKEYNAME: insptr++; { - int i = GetGameVarID(*insptr++, g_i, g_p), - f=GetGameVarID(*insptr++, g_i, g_p); - j=GetGameVarID(*insptr++, g_i, g_p); - if ((i<0 || i>=MAXQUOTES) && checkCON) - OSD_Printf(CON_ERROR "invalid quote ID %d\n",line_num,keyw[g_tw],i); - else if ((fta_quotes[i] == NULL) && checkCON) - OSD_Printf(CON_ERROR "null quote %d\n",line_num,keyw[g_tw],i); - else if ((f<0 || f>=NUMGAMEFUNCTIONS) && checkCON) - OSD_Printf(CON_ERROR "invalid function %d\n",line_num,keyw[g_tw],f); + int i = Gv_GetVar(*insptr++, g_i, g_p), + f=Gv_GetVar(*insptr++, g_i, g_p); + j=Gv_GetVar(*insptr++, g_i, g_p); + if ((i<0 || i>=MAXQUOTES) && g_scriptSanityChecks) + OSD_Printf(CON_ERROR "invalid quote ID %d\n",g_errorLineNum,keyw[g_tw],i); + else if ((ScriptQuotes[i] == NULL) && g_scriptSanityChecks) + OSD_Printf(CON_ERROR "null quote %d\n",g_errorLineNum,keyw[g_tw],i); + else if ((f<0 || f>=NUMGAMEFUNCTIONS) && g_scriptSanityChecks) + OSD_Printf(CON_ERROR "invalid function %d\n",g_errorLineNum,keyw[g_tw],f); else { if (j<2) @@ -1517,7 +1516,7 @@ static int parse(void) } if (*tempbuf) - Bstrcpy(fta_quotes[i],tempbuf); + Bstrcpy(ScriptQuotes[i],tempbuf); break; } case CON_QSUBSTR: @@ -1526,19 +1525,19 @@ static int parse(void) char *s1,*s2; int q1,q2,st,ln; - q1 = GetGameVarID(*insptr++, g_i, g_p), - q2 = GetGameVarID(*insptr++, g_i, g_p); - st = GetGameVarID(*insptr++, g_i, g_p); - ln = GetGameVarID(*insptr++, g_i, g_p); + q1 = Gv_GetVar(*insptr++, g_i, g_p), + q2 = Gv_GetVar(*insptr++, g_i, g_p); + st = Gv_GetVar(*insptr++, g_i, g_p); + ln = Gv_GetVar(*insptr++, g_i, g_p); - if ((q1<0 || q1>=MAXQUOTES) && checkCON) OSD_Printf(CON_ERROR "invalid quote ID %d\n",line_num,keyw[g_tw],q1); - else if ((fta_quotes[q1] == NULL) && checkCON) OSD_Printf(CON_ERROR "null quote %d\n",line_num,keyw[g_tw],q1); - else if ((q2<0 || q2>=MAXQUOTES) && checkCON) OSD_Printf(CON_ERROR "invalid quote ID %d\n",line_num,keyw[g_tw],q2); - else if ((fta_quotes[q2] == NULL) && checkCON) OSD_Printf(CON_ERROR "null quote %d\n",line_num,keyw[g_tw],q2); + if ((q1<0 || q1>=MAXQUOTES) && g_scriptSanityChecks) OSD_Printf(CON_ERROR "invalid quote ID %d\n",g_errorLineNum,keyw[g_tw],q1); + else if ((ScriptQuotes[q1] == NULL) && g_scriptSanityChecks) OSD_Printf(CON_ERROR "null quote %d\n",g_errorLineNum,keyw[g_tw],q1); + else if ((q2<0 || q2>=MAXQUOTES) && g_scriptSanityChecks) OSD_Printf(CON_ERROR "invalid quote ID %d\n",g_errorLineNum,keyw[g_tw],q2); + else if ((ScriptQuotes[q2] == NULL) && g_scriptSanityChecks) OSD_Printf(CON_ERROR "null quote %d\n",g_errorLineNum,keyw[g_tw],q2); else { - s1=fta_quotes[q1]; - s2=fta_quotes[q2]; + s1=ScriptQuotes[q1]; + s2=ScriptQuotes[q2]; while (*s2&&st--)s2++; while ((*s1=*s2)&&ln--) {s1++;s2++;} *s1=0; @@ -1554,79 +1553,79 @@ static int parse(void) case CON_CHANGESPRITESECT: insptr++; { - int i = GetGameVarID(*insptr++, g_i, g_p), j; + int i = Gv_GetVar(*insptr++, g_i, g_p), j; if (tw == CON_GETPNAME && *insptr == g_iThisActorID) { j = g_p; insptr++; } - else j = GetGameVarID(*insptr++, g_i, g_p); + else j = Gv_GetVar(*insptr++, g_i, g_p); switch (tw) { case CON_GETPNAME: - if ((fta_quotes[i] == NULL) && checkCON) + if ((ScriptQuotes[i] == NULL) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "null quote %d\n",line_num,keyw[g_tw],i); + OSD_Printf(CON_ERROR "null quote %d\n",g_errorLineNum,keyw[g_tw],i); break; } if (g_player[j].user_name[0]) - Bstrcpy(fta_quotes[i],g_player[j].user_name); - else Bsprintf(fta_quotes[i],"%d",j); + Bstrcpy(ScriptQuotes[i],g_player[j].user_name); + else Bsprintf(ScriptQuotes[i],"%d",j); break; case CON_QGETSYSSTR: - if ((fta_quotes[i] == NULL) && checkCON) + if ((ScriptQuotes[i] == NULL) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "null quote %d %d\n",line_num,keyw[g_tw],i,j); + OSD_Printf(CON_ERROR "null quote %d %d\n",g_errorLineNum,keyw[g_tw],i,j); break; } switch (j) { case STR_MAPNAME: - Bstrcpy(fta_quotes[i],map[ud.volume_number*MAXLEVELS + ud.level_number].name); + Bstrcpy(ScriptQuotes[i],MapInfo[ud.volume_number*MAXLEVELS + ud.level_number].name); break; case STR_MAPFILENAME: - Bstrcpy(fta_quotes[i],map[ud.volume_number*MAXLEVELS + ud.level_number].filename); + Bstrcpy(ScriptQuotes[i],MapInfo[ud.volume_number*MAXLEVELS + ud.level_number].filename); break; case STR_PLAYERNAME: - Bstrcpy(fta_quotes[i],g_player[g_p].user_name); + Bstrcpy(ScriptQuotes[i],g_player[g_p].user_name); break; case STR_VERSION: Bsprintf(tempbuf,HEAD2 " %s",s_builddate); - Bstrcpy(fta_quotes[i],tempbuf); + Bstrcpy(ScriptQuotes[i],tempbuf); break; case STR_GAMETYPE: - Bstrcpy(fta_quotes[i],gametype_names[ud.coop]); + Bstrcpy(ScriptQuotes[i],GametypeNames[ud.coop]); break; default: - OSD_Printf(CON_ERROR "unknown str ID %d %d\n",line_num,keyw[g_tw],i,j); + OSD_Printf(CON_ERROR "unknown str ID %d %d\n",g_errorLineNum,keyw[g_tw],i,j); } break; case CON_QSTRCAT: - if ((fta_quotes[i] == NULL || fta_quotes[j] == NULL) && checkCON) + if ((ScriptQuotes[i] == NULL || ScriptQuotes[j] == NULL) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "null quote %d\n",line_num,keyw[g_tw],fta_quotes[i] ? j : i); + OSD_Printf(CON_ERROR "null quote %d\n",g_errorLineNum,keyw[g_tw],ScriptQuotes[i] ? j : i); break; } - Bstrncat(fta_quotes[i],fta_quotes[j],(MAXQUOTELEN-1)-Bstrlen(fta_quotes[i])); + Bstrncat(ScriptQuotes[i],ScriptQuotes[j],(MAXQUOTELEN-1)-Bstrlen(ScriptQuotes[i])); break; case CON_QSTRCPY: - if ((fta_quotes[i] == NULL || fta_quotes[j] == NULL) && checkCON) + if ((ScriptQuotes[i] == NULL || ScriptQuotes[j] == NULL) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "null quote %d\n",line_num,keyw[g_tw],fta_quotes[i] ? j : i); + OSD_Printf(CON_ERROR "null quote %d\n",g_errorLineNum,keyw[g_tw],ScriptQuotes[i] ? j : i); break; } - Bstrcpy(fta_quotes[i],fta_quotes[j]); + Bstrcpy(ScriptQuotes[i],ScriptQuotes[j]); break; case CON_CHANGESPRITESTAT: - if ((i<0 || i>=MAXSPRITES) && checkCON) + if ((i<0 || i>=MAXSPRITES) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "Invalid sprite: %d\n",line_num,keyw[g_tw],i); + OSD_Printf(CON_ERROR "Invalid sprite: %d\n",g_errorLineNum,keyw[g_tw],i); break; } - if ((j<0 || j>=MAXSTATUS) && checkCON) + if ((j<0 || j>=MAXSTATUS) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "Invalid statnum: %d\n",line_num,keyw[g_tw],j); + OSD_Printf(CON_ERROR "Invalid statnum: %d\n",g_errorLineNum,keyw[g_tw],j); break; } if (sprite[i].statnum == j) break; @@ -1636,15 +1635,15 @@ static int parse(void) if (j == 1 || j == 2) { - hittype[i].lastvx = 0; - hittype[i].lastvy = 0; - hittype[i].timetosleep = 0; - hittype[i].cgg = 0; - hittype[i].movflag = 0; - hittype[i].tempang = 0; - hittype[i].dispicnum = 0; + ActorExtra[i].lastvx = 0; + ActorExtra[i].lastvy = 0; + ActorExtra[i].timetosleep = 0; + ActorExtra[i].cgg = 0; + ActorExtra[i].movflag = 0; + ActorExtra[i].tempang = 0; + ActorExtra[i].dispicnum = 0; T1=T2=T3=T4=T5=T6=T7=T8=T9=0; - hittype[i].flags = 0; + ActorExtra[i].flags = 0; sprite[i].hitag = 0; // pointers @@ -1658,8 +1657,8 @@ static int parse(void) changespritestat(i,j); break; case CON_CHANGESPRITESECT: - if ((i<0 || i>=MAXSPRITES) && checkCON) {OSD_Printf(CON_ERROR "Invalid sprite %d\n",line_num,keyw[g_tw],i);break;} - if ((j<0 || j>=numsectors) && checkCON) {OSD_Printf(CON_ERROR "Invalid sector %d\n",line_num,keyw[g_tw],j);break;} + if ((i<0 || i>=MAXSPRITES) && g_scriptSanityChecks) {OSD_Printf(CON_ERROR "Invalid sprite %d\n",g_errorLineNum,keyw[g_tw],i);break;} + if ((j<0 || j>=numsectors) && g_scriptSanityChecks) {OSD_Printf(CON_ERROR "Invalid sector %d\n",g_errorLineNum,keyw[g_tw],j);break;} changespritesect(i,j); break; } @@ -1670,24 +1669,24 @@ static int parse(void) insptr++; // skip command { // from 'level' cheat in game.c (about line 6250) - int volnume=GetGameVarID(*insptr++,g_i,g_p), levnume=GetGameVarID(*insptr++,g_i,g_p); + int volnume=Gv_GetVar(*insptr++,g_i,g_p), levnume=Gv_GetVar(*insptr++,g_i,g_p); - if ((volnume > MAXVOLUMES-1 || volnume < 0) && checkCON) + if ((volnume > MAXVOLUMES-1 || volnume < 0) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "invalid volume (%d)\n",line_num,keyw[g_tw],volnume); + OSD_Printf(CON_ERROR "invalid volume (%d)\n",g_errorLineNum,keyw[g_tw],volnume); break; } - if ((levnume > MAXLEVELS-1 || levnume < 0) && checkCON) + if ((levnume > MAXLEVELS-1 || levnume < 0) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "invalid level (%d)\n",line_num,keyw[g_tw],levnume); + OSD_Printf(CON_ERROR "invalid level (%d)\n",g_errorLineNum,keyw[g_tw],levnume); break; } ud.m_volume_number = ud.volume_number = volnume; ud.m_level_number = ud.level_number = levnume; if (numplayers > 1 && myconnectindex == connecthead) - mpchangemap(volnume,levnume); + Net_NewGame(volnume,levnume); else { g_player[myconnectindex].ps->gm |= MODE_EOL; @@ -1703,27 +1702,27 @@ static int parse(void) case CON_MYOSPAL: insptr++; { - int x=GetGameVarID(*insptr++,g_i,g_p), y=GetGameVarID(*insptr++,g_i,g_p), tilenum=GetGameVarID(*insptr++,g_i,g_p); - int shade=GetGameVarID(*insptr++,g_i,g_p), orientation=GetGameVarID(*insptr++,g_i,g_p); + int x=Gv_GetVar(*insptr++,g_i,g_p), y=Gv_GetVar(*insptr++,g_i,g_p), tilenum=Gv_GetVar(*insptr++,g_i,g_p); + int shade=Gv_GetVar(*insptr++,g_i,g_p), orientation=Gv_GetVar(*insptr++,g_i,g_p); switch (tw) { case CON_MYOS: - myos(x,y,tilenum,shade,orientation); + G_DrawTile(x,y,tilenum,shade,orientation); break; case CON_MYOSPAL: { - int pal=GetGameVarID(*insptr++,g_i,g_p); - myospal(x,y,tilenum,shade,orientation,pal); + int pal=Gv_GetVar(*insptr++,g_i,g_p); + G_DrawTilePal(x,y,tilenum,shade,orientation,pal); break; } case CON_MYOSX: - myosx(x,y,tilenum,shade,orientation); + G_DrawTileSmall(x,y,tilenum,shade,orientation); break; case CON_MYOSPALX: { - int pal=GetGameVarID(*insptr++,g_i,g_p); - myospalx(x,y,tilenum,shade,orientation,pal); + int pal=Gv_GetVar(*insptr++,g_i,g_p); + G_DrawTilePalSmall(x,y,tilenum,shade,orientation,pal); break; } } @@ -1740,7 +1739,7 @@ static int parse(void) // script offset to default case (null if none) // For each case: value, ptr to code //AddLog("Processing Switch..."); - int lValue=GetGameVarID(*insptr++, g_i, g_p), lEnd=*insptr++, lCases=*insptr++; + int lValue=Gv_GetVar(*insptr++, g_i, g_p), lEnd=*insptr++, lCases=*insptr++; intptr_t *lpDefault=insptr++, *lpCases=insptr, *lTempInsPtr; int bMatched=0, lCheckCase; int left,right; @@ -1774,7 +1773,7 @@ static int parse(void) //AddLog(g_szBuf); while (1) { - if (parse()) + if (X_DoExecute()) break; } //AddLog("Done Executing Case"); @@ -1789,7 +1788,7 @@ static int parse(void) { //AddLog("No Matching Case: Using Default"); insptr=(intptr_t*)(*lpDefault + &script[0]); - while (1) if (parse()) break; + while (1) if (X_DoExecute()) break; } else { @@ -1808,21 +1807,20 @@ static int parse(void) case CON_ENDEVENT: insptr++; return 1; - break; case CON_DISPLAYRAND: insptr++; - SetGameVarID(*insptr++, rand(), g_i, g_p); + Gv_SetVar(*insptr++, rand(), g_i, g_p); break; case CON_DRAGPOINT: insptr++; { - int wallnum = GetGameVarID(*insptr++, g_i, g_p), newx = GetGameVarID(*insptr++, g_i, g_p), newy = GetGameVarID(*insptr++, g_i, g_p); + int wallnum = Gv_GetVar(*insptr++, g_i, g_p), newx = Gv_GetVar(*insptr++, g_i, g_p), newy = Gv_GetVar(*insptr++, g_i, g_p); - if ((wallnum<0 || wallnum>=numwalls) && checkCON) + if ((wallnum<0 || wallnum>=numwalls) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "Invalid wall %d\n",line_num,keyw[g_tw],wallnum); + OSD_Printf(CON_ERROR "Invalid wall %d\n",g_errorLineNum,keyw[g_tw],wallnum); break; } dragpoint(wallnum,newx,newy); @@ -1833,17 +1831,17 @@ static int parse(void) case CON_LDIST: insptr++; { - int distvar = *insptr++, xvar = GetGameVarID(*insptr++, g_i, g_p), yvar = GetGameVarID(*insptr++, g_i, g_p), distx=0; + int distvar = *insptr++, xvar = Gv_GetVar(*insptr++, g_i, g_p), yvar = Gv_GetVar(*insptr++, g_i, g_p), distx=0; - if ((xvar < 0 || yvar < 0 || xvar >= MAXSPRITES || yvar >= MAXSPRITES) && checkCON) + if ((xvar < 0 || yvar < 0 || xvar >= MAXSPRITES || yvar >= MAXSPRITES) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "invalid sprite\n",line_num,keyw[g_tw]); + OSD_Printf(CON_ERROR "invalid sprite\n",g_errorLineNum,keyw[g_tw]); break; } if (tw == CON_DIST) distx = dist(&sprite[xvar],&sprite[yvar]); else distx = ldist(&sprite[xvar],&sprite[yvar]); - SetGameVarID(distvar, distx, g_i, g_p); + Gv_SetVar(distvar, distx, g_i, g_p); break; } @@ -1852,36 +1850,36 @@ static int parse(void) insptr++; { int angvar = *insptr++; - int xvar = GetGameVarID(*insptr++, g_i, g_p); - int yvar = GetGameVarID(*insptr++, g_i, g_p); + int xvar = Gv_GetVar(*insptr++, g_i, g_p); + int yvar = Gv_GetVar(*insptr++, g_i, g_p); if (tw==CON_GETANGLE) { - SetGameVarID(angvar, getangle(xvar,yvar), g_i, g_p); + Gv_SetVar(angvar, getangle(xvar,yvar), g_i, g_p); break; } - SetGameVarID(angvar, getincangle(xvar,yvar), g_i, g_p); + Gv_SetVar(angvar, G_GetAngleDelta(xvar,yvar), g_i, g_p); break; } case CON_MULSCALE: insptr++; { - int var1 = *insptr++, var2 = GetGameVarID(*insptr++, g_i, g_p); - int var3 = GetGameVarID(*insptr++, g_i, g_p), var4 = GetGameVarID(*insptr++, g_i, g_p); + int var1 = *insptr++, var2 = Gv_GetVar(*insptr++, g_i, g_p); + int var3 = Gv_GetVar(*insptr++, g_i, g_p), var4 = Gv_GetVar(*insptr++, g_i, g_p); - SetGameVarID(var1, mulscale(var2, var3, var4), g_i, g_p); + Gv_SetVar(var1, mulscale(var2, var3, var4), g_i, g_p); break; } case CON_INITTIMER: insptr++; - j = GetGameVarID(*insptr++, g_i, g_p); - if (timer == j) + j = Gv_GetVar(*insptr++, g_i, g_p); + if (g_timerTicsPerSecond == j) break; uninittimer(); inittimer(j); - timer = j; + g_timerTicsPerSecond = j; break; case CON_TIME: @@ -1893,24 +1891,24 @@ static int parse(void) case CON_QSPAWNVAR: insptr++; { - int lIn=GetGameVarID(*insptr++, g_i, g_p); - if ((g_sp->sectnum < 0 || g_sp->sectnum >= numsectors) && checkCON) + int lIn=Gv_GetVar(*insptr++, g_i, g_p); + if ((g_sp->sectnum < 0 || g_sp->sectnum >= numsectors) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "Invalid sector %d\n",line_num,keyw[g_tw],g_sp->sectnum); + OSD_Printf(CON_ERROR "Invalid sector %d\n",g_errorLineNum,keyw[g_tw],g_sp->sectnum); break; } - j = spawn(g_i, lIn); + j = A_Spawn(g_i, lIn); switch (tw) { case CON_EQSPAWNVAR: if (j != -1) - insertspriteq(j); + A_AddToDeleteQueue(j); case CON_ESPAWNVAR: - SetGameVarID(g_iReturnVarID, j, g_i, g_p); + Gv_SetVar(g_iReturnVarID, j, g_i, g_p); break; case CON_QSPAWNVAR: if (j != -1) - insertspriteq(j); + A_AddToDeleteQueue(j); break; } break; @@ -1921,26 +1919,26 @@ static int parse(void) case CON_QSPAWN: insptr++; - if ((g_sp->sectnum < 0 || g_sp->sectnum >= numsectors) && checkCON) + if ((g_sp->sectnum < 0 || g_sp->sectnum >= numsectors) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "Invalid sector %d\n",line_num,keyw[g_tw],g_sp->sectnum); + OSD_Printf(CON_ERROR "Invalid sector %d\n",g_errorLineNum,keyw[g_tw],g_sp->sectnum); insptr++; break; } - j = spawn(g_i,*insptr++); + j = A_Spawn(g_i,*insptr++); switch (tw) { case CON_EQSPAWN: if (j != -1) - insertspriteq(j); + A_AddToDeleteQueue(j); case CON_ESPAWN: - SetGameVarID(g_iReturnVarID, j, g_i, g_p); + Gv_SetVar(g_iReturnVarID, j, g_i, g_p); break; case CON_QSPAWN: if (j != -1) - insertspriteq(j); + A_AddToDeleteQueue(j); break; } break; @@ -1952,25 +1950,25 @@ static int parse(void) if (tw == CON_ZSHOOT || tw == CON_EZSHOOT) { - hittype[g_i].temp_data[9] = GetGameVarID(*insptr++, g_i, g_p); - if (hittype[g_i].temp_data[9] == 0) - hittype[g_i].temp_data[9] = 1; + ActorExtra[g_i].temp_data[9] = Gv_GetVar(*insptr++, g_i, g_p); + if (ActorExtra[g_i].temp_data[9] == 0) + ActorExtra[g_i].temp_data[9] = 1; } - if ((g_sp->sectnum < 0 || g_sp->sectnum >= numsectors) && checkCON) + if ((g_sp->sectnum < 0 || g_sp->sectnum >= numsectors) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "Invalid sector %d\n",line_num,keyw[g_tw],g_sp->sectnum); + OSD_Printf(CON_ERROR "Invalid sector %d\n",g_errorLineNum,keyw[g_tw],g_sp->sectnum); insptr++; - hittype[g_i].temp_data[9]=0; + ActorExtra[g_i].temp_data[9]=0; break; } - j = shoot(g_i,*insptr++); + j = A_Shoot(g_i,*insptr++); if (tw == CON_EZSHOOT || tw == CON_ESHOOT) - SetGameVarID(g_iReturnVarID, j, g_i, g_p); + Gv_SetVar(g_iReturnVarID, j, g_i, g_p); - hittype[g_i].temp_data[9]=0; + ActorExtra[g_i].temp_data[9]=0; break; case CON_SHOOTVAR: @@ -1984,30 +1982,30 @@ static int parse(void) if (tw == CON_ZSHOOTVAR || tw == CON_EZSHOOTVAR) { - hittype[g_i].temp_data[9] = GetGameVarID(*insptr++, g_i, g_p); - if (hittype[g_i].temp_data[9] == 0) - hittype[g_i].temp_data[9] = 1; + ActorExtra[g_i].temp_data[9] = Gv_GetVar(*insptr++, g_i, g_p); + if (ActorExtra[g_i].temp_data[9] == 0) + ActorExtra[g_i].temp_data[9] = 1; } - j=GetGameVarID(*insptr++, g_i, g_p); + j=Gv_GetVar(*insptr++, g_i, g_p); - if ((g_sp->sectnum < 0 || g_sp->sectnum >= numsectors) && checkCON) + if ((g_sp->sectnum < 0 || g_sp->sectnum >= numsectors) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "Invalid sector %d\n",line_num,keyw[g_tw],g_sp->sectnum); - hittype[g_i].temp_data[9]=0; + OSD_Printf(CON_ERROR "Invalid sector %d\n",g_errorLineNum,keyw[g_tw],g_sp->sectnum); + ActorExtra[g_i].temp_data[9]=0; break; } - lReturn = shoot(g_i, j); + lReturn = A_Shoot(g_i, j); if (tw == CON_ESHOOTVAR || tw == CON_EZSHOOTVAR) - SetGameVarID(g_iReturnVarID, lReturn, g_i, g_p); - hittype[g_i].temp_data[9]=0; + Gv_SetVar(g_iReturnVarID, lReturn, g_i, g_p); + ActorExtra[g_i].temp_data[9]=0; break; } case CON_CMENU: insptr++; - j=GetGameVarID(*insptr++, g_i, g_p); - cmenu(j); + j=Gv_GetVar(*insptr++, g_i, g_p); + ChangeToMenu(j); break; case CON_SOUNDVAR: @@ -2015,27 +2013,27 @@ static int parse(void) case CON_SOUNDONCEVAR: case CON_GLOBALSOUNDVAR: insptr++; - j=GetGameVarID(*insptr++, g_i, g_p); + j=Gv_GetVar(*insptr++, g_i, g_p); switch (tw) { case CON_SOUNDONCEVAR: - if ((j<0 || j>=MAXSOUNDS) && checkCON) {OSD_Printf(CON_ERROR "Invalid sound %d\n",line_num,keyw[g_tw],j);break;} - if (!isspritemakingsound(g_i,j)) - spritesound((short)j,g_i); + if ((j<0 || j>=MAXSOUNDS) && g_scriptSanityChecks) {OSD_Printf(CON_ERROR "Invalid sound %d\n",g_errorLineNum,keyw[g_tw],j);break;} + if (!A_CheckSoundPlaying(g_i,j)) + A_PlaySound((short)j,g_i); break; case CON_GLOBALSOUNDVAR: - if ((j<0 || j>=MAXSOUNDS) && checkCON) {OSD_Printf(CON_ERROR "Invalid sound %d\n",line_num,keyw[g_tw],j);break;} - spritesound((short)j,g_player[screenpeek].ps->i); + if ((j<0 || j>=MAXSOUNDS) && g_scriptSanityChecks) {OSD_Printf(CON_ERROR "Invalid sound %d\n",g_errorLineNum,keyw[g_tw],j);break;} + A_PlaySound((short)j,g_player[screenpeek].ps->i); break; case CON_STOPSOUNDVAR: - if ((j<0 || j>=MAXSOUNDS) && checkCON) {OSD_Printf(CON_ERROR "Invalid sound %d\n",line_num,keyw[g_tw],j);break;} - if (isspritemakingsound(g_i,j)) - stopspritesound((short)j,g_i); + if ((j<0 || j>=MAXSOUNDS) && g_scriptSanityChecks) {OSD_Printf(CON_ERROR "Invalid sound %d\n",g_errorLineNum,keyw[g_tw],j);break;} + if (A_CheckSoundPlaying(g_i,j)) + A_StopSound((short)j,g_i); break; case CON_SOUNDVAR: - if ((j<0 || j>=MAXSOUNDS) && checkCON) {OSD_Printf(CON_ERROR "Invalid sound %d\n",line_num,keyw[g_tw],j);break;} - spritesound((short)j,g_i); + if ((j<0 || j>=MAXSOUNDS) && g_scriptSanityChecks) {OSD_Printf(CON_ERROR "Invalid sound %d\n",g_errorLineNum,keyw[g_tw],j);break;} + A_PlaySound((short)j,g_i); break; } break; @@ -2043,11 +2041,11 @@ static int parse(void) case CON_GUNIQHUDID: insptr++; { - j=GetGameVarID(*insptr++, g_i, g_p); + j=Gv_GetVar(*insptr++, g_i, g_p); if (j >= 0 && j < MAXUNIQHUDID-1) guniqhudid = j; else - OSD_Printf(CON_ERROR "Invalid ID %d\n",line_num,keyw[g_tw],j); + OSD_Printf(CON_ERROR "Invalid ID %d\n",g_errorLineNum,keyw[g_tw],j); break; } @@ -2064,12 +2062,12 @@ static int parse(void) switch (tw) { case CON_SAVEGAMEVAR: - i=GetGameVarID(*insptr, g_i, g_p); + i=Gv_GetVar(*insptr, g_i, g_p); SCRIPT_PutNumber(ud.config.scripthandle, "Gamevars",aGameVars[*insptr++].szLabel,i,false,false); break; case CON_READGAMEVAR: SCRIPT_GetNumber(ud.config.scripthandle, "Gamevars",aGameVars[*insptr].szLabel,&i); - SetGameVarID(*insptr++, i, g_i, g_p); + Gv_SetVar(*insptr++, i, g_i, g_p); break; } break; @@ -2078,29 +2076,29 @@ static int parse(void) case CON_SHOWVIEW: insptr++; { - int x=GetGameVarID(*insptr++,g_i,g_p); - int y=GetGameVarID(*insptr++,g_i,g_p); - int z=GetGameVarID(*insptr++,g_i,g_p); - int a=GetGameVarID(*insptr++,g_i,g_p); - int horiz=GetGameVarID(*insptr++,g_i,g_p); - int sect=GetGameVarID(*insptr++,g_i,g_p); - int x1=scale(GetGameVarID(*insptr++,g_i,g_p),xdim,320); - int y1=scale(GetGameVarID(*insptr++,g_i,g_p),ydim,200); - int x2=scale(GetGameVarID(*insptr++,g_i,g_p),xdim,320); - int y2=scale(GetGameVarID(*insptr++,g_i,g_p),ydim,200); + int x=Gv_GetVar(*insptr++,g_i,g_p); + int y=Gv_GetVar(*insptr++,g_i,g_p); + int z=Gv_GetVar(*insptr++,g_i,g_p); + int a=Gv_GetVar(*insptr++,g_i,g_p); + int horiz=Gv_GetVar(*insptr++,g_i,g_p); + int sect=Gv_GetVar(*insptr++,g_i,g_p); + int x1=scale(Gv_GetVar(*insptr++,g_i,g_p),xdim,320); + int y1=scale(Gv_GetVar(*insptr++,g_i,g_p),ydim,200); + int x2=scale(Gv_GetVar(*insptr++,g_i,g_p),xdim,320); + int y2=scale(Gv_GetVar(*insptr++,g_i,g_p),ydim,200); int smoothratio = min(max((totalclock - ototalclock) * (65536 / TICSPERFRAME),0),65536); if (x1 > x2) swaplong(&x1,&x2); if (y1 > y2) swaplong(&y1,&y2); - if ((x1 < 0 || y1 < 0 || x2 > xdim-1 || y2 > ydim-1 || x2-x1 < 2 || y2-y1 < 2) && checkCON) + if ((x1 < 0 || y1 < 0 || x2 > xdim-1 || y2 > ydim-1 || x2-x1 < 2 || y2-y1 < 2) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "incorrect coordinates\n",line_num,keyw[g_tw]); + OSD_Printf(CON_ERROR "incorrect coordinates\n",g_errorLineNum,keyw[g_tw]); break; } - if ((sect<0 || sect>=numsectors) && checkCON) + if ((sect<0 || sect>=numsectors) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "Invalid sector %d\n",line_num,keyw[g_tw],sect); + OSD_Printf(CON_ERROR "Invalid sector %d\n",g_errorLineNum,keyw[g_tw],sect); break; } @@ -2114,7 +2112,7 @@ static int parse(void) if (!ud.pause_on && ((ud.show_help == 0 && ud.multimode < 2 && !(g_player[myconnectindex].ps->gm&MODE_MENU)) || ud.multimode > 1 || ud.recstat == 2)) smoothratio = min(max((totalclock-ototalclock)*(65536L/TICSPERFRAME),0),65536); #endif - dointerpolations(smoothratio); + G_DoInterpolations(smoothratio); #define SE40 @@ -2129,27 +2127,27 @@ static int parse(void) { int j, i = 0, k, dst = 0x7fffffff; - for (k=mirrorcnt-1;k>=0;k--) + for (k=g_mirrorCount-1;k>=0;k--) { - j = klabs(wall[mirrorwall[k]].x-x); - j += klabs(wall[mirrorwall[k]].y-y); + j = klabs(wall[g_mirrorWall[k]].x-x); + j += klabs(wall[g_mirrorWall[k]].y-y); if (j < dst) dst = j, i = k; } - if (wall[mirrorwall[i]].overpicnum == MIRROR) + if (wall[g_mirrorWall[i]].overpicnum == MIRROR) { int tposx,tposy; short tang; - preparemirror(x,y,z,a,horiz,mirrorwall[i],mirrorsector[i],&tposx,&tposy,&tang); + preparemirror(x,y,z,a,horiz,g_mirrorWall[i],g_mirrorSector[i],&tposx,&tposy,&tang); j = visibility; visibility = (j>>1) + (j>>2); - drawrooms(tposx,tposy,z,tang,horiz,mirrorsector[i]+MAXSECTORS); + drawrooms(tposx,tposy,z,tang,horiz,g_mirrorSector[i]+MAXSECTORS); display_mirror = 1; - animatesprites(tposx,tposy,tang,smoothratio); + G_DoSpriteAnimations(tposx,tposy,tang,smoothratio); display_mirror = 0; drawmasks(); @@ -2161,15 +2159,15 @@ static int parse(void) #ifdef POLYMER if (getrendermode() == 4) - polymer_setanimatesprites(animatesprites, x,y,a,smoothratio); + polymer_setanimatesprites(G_DoSpriteAnimations, x,y,a,smoothratio); #endif drawrooms(x,y,z,a,horiz,sect); display_mirror = 2; - animatesprites(x,y,a,smoothratio); + G_DoSpriteAnimations(x,y,a,smoothratio); display_mirror = 0; drawmasks(); - restoreinterpolations(); - vscrn(); + G_RestoreInterpolations(); + G_UpdateScreenArea(); #if defined(USE_OPENGL) && defined(POLYMOST) glprojectionhacks = j; #endif @@ -2180,11 +2178,11 @@ static int parse(void) case CON_ROTATESPRITE: insptr++; { - int x=GetGameVarID(*insptr++,g_i,g_p), y=GetGameVarID(*insptr++,g_i,g_p), z=GetGameVarID(*insptr++,g_i,g_p); - int a=GetGameVarID(*insptr++,g_i,g_p), tilenum=GetGameVarID(*insptr++,g_i,g_p), shade=GetGameVarID(*insptr++,g_i,g_p); - int pal=GetGameVarID(*insptr++,g_i,g_p), orientation=GetGameVarID(*insptr++,g_i,g_p); - int x1=GetGameVarID(*insptr++,g_i,g_p), y1=GetGameVarID(*insptr++,g_i,g_p); - int x2=GetGameVarID(*insptr++,g_i,g_p), y2=GetGameVarID(*insptr++,g_i,g_p); + int x=Gv_GetVar(*insptr++,g_i,g_p), y=Gv_GetVar(*insptr++,g_i,g_p), z=Gv_GetVar(*insptr++,g_i,g_p); + int a=Gv_GetVar(*insptr++,g_i,g_p), tilenum=Gv_GetVar(*insptr++,g_i,g_p), shade=Gv_GetVar(*insptr++,g_i,g_p); + int pal=Gv_GetVar(*insptr++,g_i,g_p), orientation=Gv_GetVar(*insptr++,g_i,g_p); + int x1=Gv_GetVar(*insptr++,g_i,g_p), y1=Gv_GetVar(*insptr++,g_i,g_p); + int x2=Gv_GetVar(*insptr++,g_i,g_p), y2=Gv_GetVar(*insptr++,g_i,g_p); if (tw == CON_ROTATESPRITE && !(orientation & 256)) {x<<=16;y<<=16;} rotatesprite(x,y,z,a,tilenum,shade,pal,2|orientation,x1,y1,x2,y2); @@ -2198,40 +2196,40 @@ static int parse(void) case CON_DIGITALNUMBERZ: insptr++; { - int tilenum = (tw == CON_GAMETEXT || tw == CON_GAMETEXTZ || tw == CON_DIGITALNUMBER || tw == CON_DIGITALNUMBERZ)?GetGameVarID(*insptr++,g_i,g_p):0; - int x=GetGameVarID(*insptr++,g_i,g_p), y=GetGameVarID(*insptr++,g_i,g_p), q=GetGameVarID(*insptr++,g_i,g_p); - int shade=GetGameVarID(*insptr++,g_i,g_p), pal=GetGameVarID(*insptr++,g_i,g_p); + int tilenum = (tw == CON_GAMETEXT || tw == CON_GAMETEXTZ || tw == CON_DIGITALNUMBER || tw == CON_DIGITALNUMBERZ)?Gv_GetVar(*insptr++,g_i,g_p):0; + int x=Gv_GetVar(*insptr++,g_i,g_p), y=Gv_GetVar(*insptr++,g_i,g_p), q=Gv_GetVar(*insptr++,g_i,g_p); + int shade=Gv_GetVar(*insptr++,g_i,g_p), pal=Gv_GetVar(*insptr++,g_i,g_p); if (tw == CON_GAMETEXT || tw == CON_GAMETEXTZ || tw == CON_DIGITALNUMBER || tw == CON_DIGITALNUMBERZ) { - int orientation=GetGameVarID(*insptr++,g_i,g_p); - int x1=GetGameVarID(*insptr++,g_i,g_p), y1=GetGameVarID(*insptr++,g_i,g_p); - int x2=GetGameVarID(*insptr++,g_i,g_p), y2=GetGameVarID(*insptr++,g_i,g_p); + int orientation=Gv_GetVar(*insptr++,g_i,g_p); + int x1=Gv_GetVar(*insptr++,g_i,g_p), y1=Gv_GetVar(*insptr++,g_i,g_p); + int x2=Gv_GetVar(*insptr++,g_i,g_p), y2=Gv_GetVar(*insptr++,g_i,g_p); int z=65536; if (tw == CON_GAMETEXT || tw == CON_GAMETEXTZ) { int z=65536; - if ((fta_quotes[q] == NULL) && checkCON) + if ((ScriptQuotes[q] == NULL) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "null quote %d\n",line_num,keyw[g_tw],q); + OSD_Printf(CON_ERROR "null quote %d\n",g_errorLineNum,keyw[g_tw],q); break; } - if (tw == CON_GAMETEXTZ)z=GetGameVarID(*insptr++,g_i,g_p); - gametext_z(0,tilenum,x>>1,y,fta_quotes[q],shade,pal,orientation,x1,y1,x2,y2,z); + if (tw == CON_GAMETEXTZ)z=Gv_GetVar(*insptr++,g_i,g_p); + gametext_z(0,tilenum,x>>1,y,ScriptQuotes[q],shade,pal,orientation,x1,y1,x2,y2,z); break; } - if (tw == CON_DIGITALNUMBERZ)z=GetGameVarID(*insptr++,g_i,g_p); - txdigitalnumberz(tilenum,x,y,q,shade,pal,orientation,x1,y1,x2,y2,z); + if (tw == CON_DIGITALNUMBERZ)z=Gv_GetVar(*insptr++,g_i,g_p); + G_DrawTXDigiNumZ(tilenum,x,y,q,shade,pal,orientation,x1,y1,x2,y2,z); break; } - if ((fta_quotes[q] == NULL) && checkCON) + if ((ScriptQuotes[q] == NULL) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "null quote %d\n",line_num,keyw[g_tw],q); + OSD_Printf(CON_ERROR "null quote %d\n",g_errorLineNum,keyw[g_tw],q); break; } - minitextshade(x,y,fta_quotes[q],shade,pal,26); + minitextshade(x,y,ScriptQuotes[q],shade,pal,26); break; } @@ -2243,80 +2241,80 @@ static int parse(void) case CON_GETZRANGE: insptr++; { - int x=GetGameVarID(*insptr++,g_i,g_p), y=GetGameVarID(*insptr++,g_i,g_p), z=GetGameVarID(*insptr++,g_i,g_p); - int sectnum=GetGameVarID(*insptr++,g_i,g_p); + int x=Gv_GetVar(*insptr++,g_i,g_p), y=Gv_GetVar(*insptr++,g_i,g_p), z=Gv_GetVar(*insptr++,g_i,g_p); + int sectnum=Gv_GetVar(*insptr++,g_i,g_p); int ceilzvar=*insptr++, ceilhitvar=*insptr++, florzvar=*insptr++, florhitvar=*insptr++; - int walldist=GetGameVarID(*insptr++,g_i,g_p), clipmask=GetGameVarID(*insptr++,g_i,g_p); + int walldist=Gv_GetVar(*insptr++,g_i,g_p), clipmask=Gv_GetVar(*insptr++,g_i,g_p); int ceilz, ceilhit, florz, florhit; - if ((sectnum<0 || sectnum>=numsectors) && checkCON) + if ((sectnum<0 || sectnum>=numsectors) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "Invalid sector %d\n",line_num,keyw[g_tw],sectnum); + OSD_Printf(CON_ERROR "Invalid sector %d\n",g_errorLineNum,keyw[g_tw],sectnum); break; } getzrange(x, y, z, sectnum, &ceilz, &ceilhit, &florz, &florhit, walldist, clipmask); - SetGameVarID(ceilzvar, ceilz, g_i, g_p); - SetGameVarID(ceilhitvar, ceilhit, g_i, g_p); - SetGameVarID(florzvar, florz, g_i, g_p); - SetGameVarID(florhitvar, florhit, g_i, g_p); + Gv_SetVar(ceilzvar, ceilz, g_i, g_p); + Gv_SetVar(ceilhitvar, ceilhit, g_i, g_p); + Gv_SetVar(florzvar, florz, g_i, g_p); + Gv_SetVar(florhitvar, florhit, g_i, g_p); break; } case CON_HITSCAN: insptr++; { - int xs=GetGameVarID(*insptr++,g_i,g_p), ys=GetGameVarID(*insptr++,g_i,g_p), zs=GetGameVarID(*insptr++,g_i,g_p); - int sectnum=GetGameVarID(*insptr++,g_i,g_p); - int vx=GetGameVarID(*insptr++,g_i,g_p), vy=GetGameVarID(*insptr++,g_i,g_p), vz=GetGameVarID(*insptr++,g_i,g_p); + int xs=Gv_GetVar(*insptr++,g_i,g_p), ys=Gv_GetVar(*insptr++,g_i,g_p), zs=Gv_GetVar(*insptr++,g_i,g_p); + int sectnum=Gv_GetVar(*insptr++,g_i,g_p); + int vx=Gv_GetVar(*insptr++,g_i,g_p), vy=Gv_GetVar(*insptr++,g_i,g_p), vz=Gv_GetVar(*insptr++,g_i,g_p); int hitsectvar=*insptr++, hitwallvar=*insptr++, hitspritevar=*insptr++; - int hitxvar=*insptr++, hityvar=*insptr++, hitzvar=*insptr++, cliptype=GetGameVarID(*insptr++,g_i,g_p); + int hitxvar=*insptr++, hityvar=*insptr++, hitzvar=*insptr++, cliptype=Gv_GetVar(*insptr++,g_i,g_p); short hitsect, hitwall, hitsprite; int hitx, hity, hitz; - if ((sectnum<0 || sectnum>=numsectors) && checkCON) + if ((sectnum<0 || sectnum>=numsectors) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "Invalid sector %d\n",line_num,keyw[g_tw],sectnum); + OSD_Printf(CON_ERROR "Invalid sector %d\n",g_errorLineNum,keyw[g_tw],sectnum); break; } hitscan(xs, ys, zs, sectnum, vx, vy, vz, &hitsect, &hitwall, &hitsprite, &hitx, &hity, &hitz, cliptype); - SetGameVarID(hitsectvar, hitsect, g_i, g_p); - SetGameVarID(hitwallvar, hitwall, g_i, g_p); - SetGameVarID(hitspritevar, hitsprite, g_i, g_p); - SetGameVarID(hitxvar, hitx, g_i, g_p); - SetGameVarID(hityvar, hity, g_i, g_p); - SetGameVarID(hitzvar, hitz, g_i, g_p); + Gv_SetVar(hitsectvar, hitsect, g_i, g_p); + Gv_SetVar(hitwallvar, hitwall, g_i, g_p); + Gv_SetVar(hitspritevar, hitsprite, g_i, g_p); + Gv_SetVar(hitxvar, hitx, g_i, g_p); + Gv_SetVar(hityvar, hity, g_i, g_p); + Gv_SetVar(hitzvar, hitz, g_i, g_p); break; } case CON_CANSEE: insptr++; { - int x1=GetGameVarID(*insptr++,g_i,g_p), y1=GetGameVarID(*insptr++,g_i,g_p), z1=GetGameVarID(*insptr++,g_i,g_p); - int sect1=GetGameVarID(*insptr++,g_i,g_p); - int x2=GetGameVarID(*insptr++,g_i,g_p), y2=GetGameVarID(*insptr++,g_i,g_p), z2=GetGameVarID(*insptr++,g_i,g_p); - int sect2=GetGameVarID(*insptr++,g_i,g_p), rvar=*insptr++; + int x1=Gv_GetVar(*insptr++,g_i,g_p), y1=Gv_GetVar(*insptr++,g_i,g_p), z1=Gv_GetVar(*insptr++,g_i,g_p); + int sect1=Gv_GetVar(*insptr++,g_i,g_p); + int x2=Gv_GetVar(*insptr++,g_i,g_p), y2=Gv_GetVar(*insptr++,g_i,g_p), z2=Gv_GetVar(*insptr++,g_i,g_p); + int sect2=Gv_GetVar(*insptr++,g_i,g_p), rvar=*insptr++; - if ((sect1<0 || sect1>=numsectors || sect2<0 || sect2>=numsectors) && checkCON) + if ((sect1<0 || sect1>=numsectors || sect2<0 || sect2>=numsectors) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "Invalid sector\n",line_num,keyw[g_tw]); - SetGameVarID(rvar, 0, g_i, g_p); + OSD_Printf(CON_ERROR "Invalid sector\n",g_errorLineNum,keyw[g_tw]); + Gv_SetVar(rvar, 0, g_i, g_p); } - SetGameVarID(rvar, cansee(x1,y1,z1,sect1,x2,y2,z2,sect2), g_i, g_p); + Gv_SetVar(rvar, cansee(x1,y1,z1,sect1,x2,y2,z2,sect2), g_i, g_p); break; } case CON_ROTATEPOINT: insptr++; { - int xpivot=GetGameVarID(*insptr++,g_i,g_p), ypivot=GetGameVarID(*insptr++,g_i,g_p); - int x=GetGameVarID(*insptr++,g_i,g_p), y=GetGameVarID(*insptr++,g_i,g_p), daang=GetGameVarID(*insptr++,g_i,g_p); + int xpivot=Gv_GetVar(*insptr++,g_i,g_p), ypivot=Gv_GetVar(*insptr++,g_i,g_p); + int x=Gv_GetVar(*insptr++,g_i,g_p), y=Gv_GetVar(*insptr++,g_i,g_p), daang=Gv_GetVar(*insptr++,g_i,g_p); int x2var=*insptr++, y2var=*insptr++; int x2, y2; rotatepoint(xpivot,ypivot,x,y,daang,&x2,&y2); - SetGameVarID(x2var, x2, g_i, g_p); - SetGameVarID(y2var, y2, g_i, g_p); + Gv_SetVar(x2var, x2, g_i, g_p); + Gv_SetVar(y2var, y2, g_i, g_p); break; } @@ -2331,22 +2329,22 @@ static int parse(void) // int neartagrange, //Choose maximum distance to scan (scale: 1024=largest grid size) // char tagsearch) //1-lotag only, 2-hitag only, 3-lotag&hitag - int x=GetGameVarID(*insptr++,g_i,g_p), y=GetGameVarID(*insptr++,g_i,g_p), z=GetGameVarID(*insptr++,g_i,g_p); - int sectnum=GetGameVarID(*insptr++,g_i,g_p), ang=GetGameVarID(*insptr++,g_i,g_p); + int x=Gv_GetVar(*insptr++,g_i,g_p), y=Gv_GetVar(*insptr++,g_i,g_p), z=Gv_GetVar(*insptr++,g_i,g_p); + int sectnum=Gv_GetVar(*insptr++,g_i,g_p), ang=Gv_GetVar(*insptr++,g_i,g_p); int neartagsectorvar=*insptr++, neartagwallvar=*insptr++, neartagspritevar=*insptr++, neartaghitdistvar=*insptr++; - int neartagrange=GetGameVarID(*insptr++,g_i,g_p), tagsearch=GetGameVarID(*insptr++,g_i,g_p); + int neartagrange=Gv_GetVar(*insptr++,g_i,g_p), tagsearch=Gv_GetVar(*insptr++,g_i,g_p); - if ((sectnum<0 || sectnum>=numsectors) && checkCON) + if ((sectnum<0 || sectnum>=numsectors) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "Invalid sector %d\n",line_num,keyw[g_tw],sectnum); + OSD_Printf(CON_ERROR "Invalid sector %d\n",g_errorLineNum,keyw[g_tw],sectnum); break; } neartag(x, y, z, sectnum, ang, &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, neartagrange, tagsearch); - SetGameVarID(neartagsectorvar, neartagsector, g_i, g_p); - SetGameVarID(neartagwallvar, neartagwall, g_i, g_p); - SetGameVarID(neartagspritevar, neartagsprite, g_i, g_p); - SetGameVarID(neartaghitdistvar, neartaghitdist, g_i, g_p); + Gv_SetVar(neartagsectorvar, neartagsector, g_i, g_p); + Gv_SetVar(neartagwallvar, neartagwall, g_i, g_p); + Gv_SetVar(neartagspritevar, neartagsprite, g_i, g_p); + Gv_SetVar(neartaghitdistvar, neartaghitdist, g_i, g_p); break; } @@ -2361,14 +2359,14 @@ static int parse(void) ti=localtime(&rawtime); // initprintf("Time&date: %s\n",asctime (ti)); - SetGameVarID(v1, ti->tm_sec, g_i, g_p); - SetGameVarID(v2, ti->tm_min, g_i, g_p); - SetGameVarID(v3, ti->tm_hour, g_i, g_p); - SetGameVarID(v4, ti->tm_mday, g_i, g_p); - SetGameVarID(v5, ti->tm_mon, g_i, g_p); - SetGameVarID(v6, ti->tm_year+1900, g_i, g_p); - SetGameVarID(v7, ti->tm_wday, g_i, g_p); - SetGameVarID(v8, ti->tm_yday, g_i, g_p); + Gv_SetVar(v1, ti->tm_sec, g_i, g_p); + Gv_SetVar(v2, ti->tm_min, g_i, g_p); + Gv_SetVar(v3, ti->tm_hour, g_i, g_p); + Gv_SetVar(v4, ti->tm_mday, g_i, g_p); + Gv_SetVar(v5, ti->tm_mon, g_i, g_p); + Gv_SetVar(v6, ti->tm_year+1900, g_i, g_p); + Gv_SetVar(v7, ti->tm_wday, g_i, g_p); + Gv_SetVar(v8, ti->tm_yday, g_i, g_p); break; } @@ -2376,14 +2374,14 @@ static int parse(void) case CON_SETSPRITE: insptr++; { - int spritenum = GetGameVarID(*insptr++,g_i,g_p); - int x = GetGameVarID(*insptr++,g_i,g_p), y = GetGameVarID(*insptr++,g_i,g_p), z = GetGameVarID(*insptr++,g_i,g_p); + int spritenum = Gv_GetVar(*insptr++,g_i,g_p); + int x = Gv_GetVar(*insptr++,g_i,g_p), y = Gv_GetVar(*insptr++,g_i,g_p), z = Gv_GetVar(*insptr++,g_i,g_p); if (tw == CON_SETSPRITE) { - if ((spritenum < 0 || spritenum >= MAXSPRITES) && checkCON) + if ((spritenum < 0 || spritenum >= MAXSPRITES) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "invalid sprite ID %d\n",line_num,keyw[g_tw],spritenum); + OSD_Printf(CON_ERROR "invalid sprite ID %d\n",g_errorLineNum,keyw[g_tw],spritenum); break; } setsprite(spritenum, x, y, z); @@ -2391,15 +2389,15 @@ static int parse(void) } { - int cliptype = GetGameVarID(*insptr++,g_i,g_p); + int cliptype = Gv_GetVar(*insptr++,g_i,g_p); - if ((spritenum < 0 && spritenum >= MAXSPRITES) && checkCON) + if ((spritenum < 0 && spritenum >= MAXSPRITES) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "invalid sprite ID %d\n",line_num,keyw[g_tw],spritenum); + OSD_Printf(CON_ERROR "invalid sprite ID %d\n",g_errorLineNum,keyw[g_tw],spritenum); insptr++; break; } - SetGameVarID(*insptr++, movesprite(spritenum, x, y, z, cliptype), g_i, g_p); + Gv_SetVar(*insptr++, A_MoveSprite(spritenum, x, y, z, cliptype), g_i, g_p); break; } } @@ -2408,20 +2406,20 @@ static int parse(void) case CON_GETCEILZOFSLOPE: insptr++; { - int sectnum = GetGameVarID(*insptr++,g_i,g_p), x = GetGameVarID(*insptr++,g_i,g_p), y = GetGameVarID(*insptr++,g_i,g_p); - if ((sectnum<0 || sectnum>=numsectors) && checkCON) + int sectnum = Gv_GetVar(*insptr++,g_i,g_p), x = Gv_GetVar(*insptr++,g_i,g_p), y = Gv_GetVar(*insptr++,g_i,g_p); + if ((sectnum<0 || sectnum>=numsectors) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "Invalid sector %d\n",line_num,keyw[g_tw],sectnum); + OSD_Printf(CON_ERROR "Invalid sector %d\n",g_errorLineNum,keyw[g_tw],sectnum); insptr++; break; } if (tw == CON_GETFLORZOFSLOPE) { - SetGameVarID(*insptr++, getflorzofslope(sectnum,x,y), g_i, g_p); + Gv_SetVar(*insptr++, getflorzofslope(sectnum,x,y), g_i, g_p); break; } - SetGameVarID(*insptr++, getceilzofslope(sectnum,x,y), g_i, g_p); + Gv_SetVar(*insptr++, getceilzofslope(sectnum,x,y), g_i, g_p); break; } @@ -2429,43 +2427,43 @@ static int parse(void) case CON_UPDATESECTORZ: insptr++; { - int x=GetGameVarID(*insptr++,g_i,g_p), y=GetGameVarID(*insptr++,g_i,g_p); - int z=(tw==CON_UPDATESECTORZ)?GetGameVarID(*insptr++,g_i,g_p):0; + int x=Gv_GetVar(*insptr++,g_i,g_p), y=Gv_GetVar(*insptr++,g_i,g_p); + int z=(tw==CON_UPDATESECTORZ)?Gv_GetVar(*insptr++,g_i,g_p):0; int var=*insptr++; short w=sprite[g_i].sectnum; if (tw==CON_UPDATESECTOR) updatesector(x,y,&w); else updatesectorz(x,y,z,&w); - SetGameVarID(var, w, g_i, g_p); + Gv_SetVar(var, w, g_i, g_p); break; } case CON_SPAWN: insptr++; if (g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS) - spawn(g_i,*insptr); + A_Spawn(g_i,*insptr); insptr++; break; case CON_IFWASWEAPON: insptr++; - parseifelse(hittype[g_i].picnum == *insptr); + X_DoConditional(ActorExtra[g_i].picnum == *insptr); break; case CON_IFAI: insptr++; - parseifelse(g_t[5] == *insptr); + X_DoConditional(g_t[5] == *insptr); break; case CON_IFACTION: insptr++; - parseifelse(g_t[4] == *insptr); + X_DoConditional(g_t[4] == *insptr); break; case CON_IFACTIONCOUNT: insptr++; - parseifelse(g_t[2] >= *insptr); + X_DoConditional(g_t[2] >= *insptr); break; case CON_RESETACTIONCOUNT: @@ -2483,15 +2481,15 @@ static int parse(void) { if (g_sp->picnum == BLIMP && dnum == SCRAP1) s = 0; - else s = (TRAND%3); + else s = (krand()%3); - l = EGS(g_sp->sectnum, - g_sp->x+(TRAND&255)-128,g_sp->y+(TRAND&255)-128,g_sp->z-(8<<8)-(TRAND&8191), - dnum+s,g_sp->shade,32+(TRAND&15),32+(TRAND&15), - TRAND&2047,(TRAND&127)+32, - -(TRAND&2047),g_i,5); + l = A_InsertSprite(g_sp->sectnum, + g_sp->x+(krand()&255)-128,g_sp->y+(krand()&255)-128,g_sp->z-(8<<8)-(krand()&8191), + dnum+s,g_sp->shade,32+(krand()&15),32+(krand()&15), + krand()&2047,(krand()&127)+32, + -(krand()&2047),g_i,5); if (g_sp->picnum == BLIMP && dnum == SCRAP1) - sprite[l].yvel = weaponsandammosprites[j%14]; + sprite[l].yvel = BlimpSpawnSprites[j%14]; else sprite[l].yvel = -1; sprite[l].pal = g_sp->pal; } @@ -2524,45 +2522,45 @@ static int parse(void) { time_t curtime; - lastsavedpos = *insptr++; + g_lastSaveSlot = *insptr++; - if ((movesperpacket == 4 && connecthead != myconnectindex) || lastsavedpos > 9) + if ((g_movesPerPacket == 4 && connecthead != myconnectindex) || g_lastSaveSlot > 9) break; - if ((tw == CON_SAVE) || !(ud.savegame[lastsavedpos][0])) + if ((tw == CON_SAVE) || !(ud.savegame[g_lastSaveSlot][0])) { curtime = time(NULL); Bstrcpy(tempbuf,asctime(localtime(&curtime))); - clearbuf(ud.savegame[lastsavedpos],sizeof(ud.savegame[lastsavedpos]),0); - Bsprintf(ud.savegame[lastsavedpos],"Auto"); + clearbuf(ud.savegame[g_lastSaveSlot],sizeof(ud.savegame[g_lastSaveSlot]),0); + Bsprintf(ud.savegame[g_lastSaveSlot],"Auto"); // for (j=0;j<13;j++) -// Bmemcpy(&ud.savegame[lastsavedpos][j+4],&tempbuf[j+3],sizeof(tempbuf[j+3])); -// ud.savegame[lastsavedpos][j+4] = '\0'; - Bmemcpy(&ud.savegame[lastsavedpos][4],&tempbuf[3],sizeof(tempbuf[0])*13); - ud.savegame[lastsavedpos][17] = '\0'; +// Bmemcpy(&ud.savegame[g_lastSaveSlot][j+4],&tempbuf[j+3],sizeof(tempbuf[j+3])); +// ud.savegame[g_lastSaveSlot][j+4] = '\0'; + Bmemcpy(&ud.savegame[g_lastSaveSlot][4],&tempbuf[3],sizeof(tempbuf[0])*13); + ud.savegame[g_lastSaveSlot][17] = '\0'; } - OSD_Printf("Saving to slot %d\n",lastsavedpos); + OSD_Printf("Saving to slot %d\n",g_lastSaveSlot); KB_FlushKeyboardQueue(); - screencapt = 1; - displayrooms(myconnectindex,65536); - screencapt = 0; + g_screenCapture = 1; + G_DrawRooms(myconnectindex,65536); + g_screenCapture = 0; if (ud.multimode > 1) - saveplayer(-1-(lastsavedpos)); - else saveplayer(lastsavedpos); + G_SavePlayer(-1-(g_lastSaveSlot)); + else G_SavePlayer(g_lastSaveSlot); break; } case CON_QUAKE: insptr++; - earthquaketime = (char)GetGameVarID(*insptr++,g_i,g_p); - spritesound(EARTHQUAKE,g_player[screenpeek].ps->i); + g_earthquakeTime = (char)Gv_GetVar(*insptr++,g_i,g_p); + A_PlaySound(EARTHQUAKE,g_player[screenpeek].ps->i); break; case CON_IFMOVE: insptr++; - parseifelse(g_t[1] == *insptr); + X_DoConditional(g_t[1] == *insptr); break; case CON_RESETPLAYER: @@ -2572,21 +2570,21 @@ static int parse(void) //AddLog("resetplayer"); if (ud.multimode < 2) { - if (lastsavedpos >= 0 && ud.recstat != 2) + if (g_lastSaveSlot >= 0 && ud.recstat != 2) { g_player[g_p].ps->gm = MODE_MENU; KB_ClearKeyDown(sc_Space); - cmenu(15000); + ChangeToMenu(15000); } else g_player[g_p].ps->gm = MODE_RESTART; - killit_flag = 2; + g_killitFlag = 2; } else { - pickrandomspot(g_p); - g_sp->x = hittype[g_i].bposx = g_player[g_p].ps->bobposx = g_player[g_p].ps->oposx = g_player[g_p].ps->posx; - g_sp->y = hittype[g_i].bposy = g_player[g_p].ps->bobposy = g_player[g_p].ps->oposy =g_player[g_p].ps->posy; - g_sp->z = hittype[g_i].bposy = g_player[g_p].ps->oposz =g_player[g_p].ps->posz; + P_RandomSpawnPoint(g_p); + g_sp->x = ActorExtra[g_i].bposx = g_player[g_p].ps->bobposx = g_player[g_p].ps->oposx = g_player[g_p].ps->posx; + g_sp->y = ActorExtra[g_i].bposy = g_player[g_p].ps->bobposy = g_player[g_p].ps->oposy =g_player[g_p].ps->posy; + g_sp->z = ActorExtra[g_i].bposy = g_player[g_p].ps->oposz =g_player[g_p].ps->posz; updatesector(g_player[g_p].ps->posx,g_player[g_p].ps->posy,&g_player[g_p].ps->cursectnum); setsprite(g_player[g_p].ps->i,g_player[g_p].ps->posx,g_player[g_p].ps->posy,g_player[g_p].ps->posz+PHEIGHT); g_sp->cstat = 257; @@ -2607,7 +2605,7 @@ static int parse(void) g_player[g_p].ps->horizoff = 0; g_player[g_p].ps->opyoff = 0; g_player[g_p].ps->wackedbyactor = -1; - g_player[g_p].ps->shield_amount = start_armour_amount; + g_player[g_p].ps->shield_amount = g_startArmorAmount; g_player[g_p].ps->dead_flag = 0; g_player[g_p].ps->pals_time = 0; g_player[g_p].ps->footprintcount = 0; @@ -2616,51 +2614,51 @@ static int parse(void) g_player[g_p].ps->ftq = 0; g_player[g_p].ps->posxv = g_player[g_p].ps->posyv = 0; g_player[g_p].ps->rotscrnang = 0; - g_player[g_p].ps->runspeed = dukefriction; + g_player[g_p].ps->runspeed = g_playerFriction; g_player[g_p].ps->falling_counter = 0; - hittype[g_i].extra = -1; - hittype[g_i].owner = g_i; + ActorExtra[g_i].extra = -1; + ActorExtra[g_i].owner = g_i; - hittype[g_i].cgg = 0; - hittype[g_i].movflag = 0; - hittype[g_i].tempang = 0; - hittype[g_i].actorstayput = -1; - hittype[g_i].dispicnum = 0; - hittype[g_i].owner = g_player[g_p].ps->i; + ActorExtra[g_i].cgg = 0; + ActorExtra[g_i].movflag = 0; + ActorExtra[g_i].tempang = 0; + ActorExtra[g_i].actorstayput = -1; + ActorExtra[g_i].dispicnum = 0; + ActorExtra[g_i].owner = g_player[g_p].ps->i; - resetinventory(g_p); - resetweapons(g_p); + P_ResetInventory(g_p); + P_ResetWeapons(g_p); g_player[g_p].ps->reloading = 0; g_player[g_p].ps->movement_lock = 0; - OnEvent(EVENT_RESETPLAYER, g_player[g_p].ps->i, g_p, -1); - cameradist = 0; - cameraclock = totalclock; + X_OnEvent(EVENT_RESETPLAYER, g_player[g_p].ps->i, g_p, -1); + g_cameraDistance = 0; + g_cameraClock = totalclock; } - setpal(g_player[g_p].ps); + P_UpdateScreenPal(g_player[g_p].ps); //AddLog("EOF: resetplayer"); } break; case CON_IFONWATER: - parseifelse(klabs(g_sp->z-sector[g_sp->sectnum].floorz) < (32<<8) && sector[g_sp->sectnum].lotag == 1); + X_DoConditional(klabs(g_sp->z-sector[g_sp->sectnum].floorz) < (32<<8) && sector[g_sp->sectnum].lotag == 1); break; case CON_IFINWATER: - parseifelse(sector[g_sp->sectnum].lotag == 2); + X_DoConditional(sector[g_sp->sectnum].lotag == 2); break; case CON_IFCOUNT: insptr++; - parseifelse(g_t[0] >= *insptr); + X_DoConditional(g_t[0] >= *insptr); break; case CON_IFACTOR: insptr++; - parseifelse(g_sp->picnum == *insptr); + X_DoConditional(g_sp->picnum == *insptr); break; case CON_RESETCOUNT: @@ -2728,7 +2726,7 @@ static int parse(void) g_player[g_p].ps->boot_amount = *insptr; break; default: - OSD_Printf(CON_ERROR "Invalid inventory ID %d\n",line_num,keyw[g_tw],*(insptr-1)); + OSD_Printf(CON_ERROR "Invalid inventory ID %d\n",g_errorLineNum,keyw[g_tw],*(insptr-1)); break; } insptr++; @@ -2737,14 +2735,14 @@ static int parse(void) case CON_HITRADIUSVAR: insptr++; { - int v1=GetGameVarID(*insptr++,g_i,g_p),v2=GetGameVarID(*insptr++,g_i,g_p),v3=GetGameVarID(*insptr++,g_i,g_p); - int v4=GetGameVarID(*insptr++,g_i,g_p),v5=GetGameVarID(*insptr++,g_i,g_p); - hitradius(g_i,v1,v2,v3,v4,v5); + int v1=Gv_GetVar(*insptr++,g_i,g_p),v2=Gv_GetVar(*insptr++,g_i,g_p),v3=Gv_GetVar(*insptr++,g_i,g_p); + int v4=Gv_GetVar(*insptr++,g_i,g_p),v5=Gv_GetVar(*insptr++,g_i,g_p); + A_RadiusDamage(g_i,v1,v2,v3,v4,v5); } break; case CON_HITRADIUS: - hitradius(g_i,*(insptr+1),*(insptr+2),*(insptr+3),*(insptr+4),*(insptr+5)); + A_RadiusDamage(g_i,*(insptr+1),*(insptr+2),*(insptr+3),*(insptr+4),*(insptr+5)); insptr+=6; break; @@ -2757,7 +2755,7 @@ static int parse(void) s = sprite[g_player[g_p].ps->i].xvel; - if ((l&8) && g_player[g_p].ps->on_ground && (g_player[g_p].sync->bits&2)) + if ((l&8) && g_player[g_p].ps->on_ground && TEST_SYNC_KEY(g_player[g_p].sync->bits, SK_CROUCH)) j = 1; else if ((l&16) && g_player[g_p].ps->jumping_counter == 0 && !g_player[g_p].ps->on_ground && g_player[g_p].ps->poszv > 2048) @@ -2766,15 +2764,15 @@ static int parse(void) j = 1; else if ((l&1) && s >= 0 && s < 8) j = 1; - else if ((l&2) && s >= 8 && !(g_player[g_p].sync->bits&(1<<5))) + else if ((l&2) && s >= 8 && !TEST_SYNC_KEY(g_player[g_p].sync->bits, SK_RUN)) j = 1; - else if ((l&4) && s >= 8 && g_player[g_p].sync->bits&(1<<5)) + else if ((l&4) && s >= 8 && TEST_SYNC_KEY(g_player[g_p].sync->bits, SK_RUN)) j = 1; else if ((l&64) && g_player[g_p].ps->posz < (g_sp->z-(48<<8))) j = 1; - else if ((l&128) && s <= -8 && !(g_player[g_p].sync->bits&(1<<5))) + else if ((l&128) && s <= -8 && !TEST_SYNC_KEY(g_player[g_p].sync->bits, SK_RUN)) j = 1; - else if ((l&256) && s <= -8 && (g_player[g_p].sync->bits&(1<<5))) + else if ((l&256) && s <= -8 && TEST_SYNC_KEY(g_player[g_p].sync->bits, SK_RUN)) j = 1; else if ((l&512) && (g_player[g_p].ps->quick_kick > 0 || (g_player[g_p].ps->curr_weapon == KNEE_WEAPON && g_player[g_p].ps->kickback_pic > 0))) j = 1; @@ -2793,38 +2791,38 @@ static int parse(void) else if ((l&65536L)) { if (g_sp->picnum == APLAYER && ud.multimode > 1) - j = getincangle(g_player[otherp].ps->ang,getangle(g_player[g_p].ps->posx-g_player[otherp].ps->posx,g_player[g_p].ps->posy-g_player[otherp].ps->posy)); + j = G_GetAngleDelta(g_player[otherp].ps->ang,getangle(g_player[g_p].ps->posx-g_player[otherp].ps->posx,g_player[g_p].ps->posy-g_player[otherp].ps->posy)); else - j = getincangle(g_player[g_p].ps->ang,getangle(g_sp->x-g_player[g_p].ps->posx,g_sp->y-g_player[g_p].ps->posy)); + j = G_GetAngleDelta(g_player[g_p].ps->ang,getangle(g_sp->x-g_player[g_p].ps->posx,g_sp->y-g_player[g_p].ps->posy)); if (j > -128 && j < 128) j = 1; else j = 0; } - parseifelse((intptr_t) j); + X_DoConditional((intptr_t) j); } break; case CON_IFSTRENGTH: insptr++; - parseifelse(g_sp->extra <= *insptr); + X_DoConditional(g_sp->extra <= *insptr); break; case CON_GUTS: insptr += 2; - guts(g_i,*(insptr-1),*insptr); + A_DoGuts(g_i,*(insptr-1),*insptr); insptr++; break; case CON_IFSPAWNEDBY: insptr++; - parseifelse(hittype[g_i].picnum == *insptr); + X_DoConditional(ActorExtra[g_i].picnum == *insptr); break; case CON_WACKPLAYER: insptr++; - forceplayerangle(g_player[g_p].ps); + P_ForceAngle(g_player[g_p].ps); return 0; case CON_FLASH: @@ -2835,28 +2833,28 @@ static int parse(void) return 0; case CON_SAVEMAPSTATE: - if (map[ud.volume_number*MAXLEVELS+ud.level_number].savedstate == NULL) - map[ud.volume_number*MAXLEVELS+ud.level_number].savedstate = Bcalloc(1,sizeof(mapstate_t)); - savemapstate(map[ud.volume_number*MAXLEVELS+ud.level_number].savedstate); + if (MapInfo[ud.volume_number*MAXLEVELS+ud.level_number].savedstate == NULL) + MapInfo[ud.volume_number*MAXLEVELS+ud.level_number].savedstate = Bcalloc(1,sizeof(mapstate_t)); + G_SaveMapState(MapInfo[ud.volume_number*MAXLEVELS+ud.level_number].savedstate); insptr++; return 0; case CON_LOADMAPSTATE: - if (map[ud.volume_number*MAXLEVELS+ud.level_number].savedstate) - restoremapstate(map[ud.volume_number*MAXLEVELS+ud.level_number].savedstate); + if (MapInfo[ud.volume_number*MAXLEVELS+ud.level_number].savedstate) + G_RestoreMapState(MapInfo[ud.volume_number*MAXLEVELS+ud.level_number].savedstate); insptr++; return 0; case CON_CLEARMAPSTATE: insptr++; - j = GetGameVarID(*insptr++,g_i,g_p); - if ((j < 0 || j >= MAXVOLUMES*MAXLEVELS) && checkCON) + j = Gv_GetVar(*insptr++,g_i,g_p); + if ((j < 0 || j >= MAXVOLUMES*MAXLEVELS) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "Invalid map number: %d\n",line_num,keyw[g_tw],j); + OSD_Printf(CON_ERROR "Invalid map number: %d\n",g_errorLineNum,keyw[g_tw],j); return 0; } - if (map[j].savedstate) - FreeMapState(j); + if (MapInfo[j].savedstate) + G_FreeMapState(j); return 0; case CON_STOPALLSOUNDS: @@ -2867,19 +2865,19 @@ static int parse(void) case CON_IFGAPZL: insptr++; - parseifelse(((hittype[g_i].floorz - hittype[g_i].ceilingz) >> 8) < *insptr); + X_DoConditional(((ActorExtra[g_i].floorz - ActorExtra[g_i].ceilingz) >> 8) < *insptr); break; case CON_IFHITSPACE: - parseifelse(g_player[g_p].sync->bits&(1<<29)); + X_DoConditional(TEST_SYNC_KEY(g_player[g_p].sync->bits, SK_OPEN)); break; case CON_IFOUTSIDE: - parseifelse(sector[g_sp->sectnum].ceilingstat&1); + X_DoConditional(sector[g_sp->sectnum].ceilingstat&1); break; case CON_IFMULTIPLAYER: - parseifelse(ud.multimode > 1); + X_DoConditional(ud.multimode > 1); break; case CON_OPERATE: @@ -2900,19 +2898,19 @@ static int parse(void) j = nextspritesect[j]; } if (j == -1) - operatesectors(neartagsector,g_i); + G_OperateSectors(neartagsector,g_i); } } break; case CON_IFINSPACE: - parseifelse(ceilingspace(g_sp->sectnum)); + X_DoConditional(G_CheckForSpaceCeiling(g_sp->sectnum)); break; case CON_SPRITEPAL: insptr++; if (g_sp->picnum != APLAYER) - hittype[g_i].tempang = g_sp->pal; + ActorExtra[g_i].tempang = g_sp->pal; g_sp->pal = *insptr++; break; @@ -2922,26 +2920,26 @@ static int parse(void) break; case CON_IFBULLETNEAR: - parseifelse(dodge(g_sp) == 1); + X_DoConditional(A_Dodge(g_sp) == 1); break; case CON_IFRESPAWN: - if (badguy(g_sp)) - parseifelse(ud.respawn_monsters); - else if (inventory(g_sp)) - parseifelse(ud.respawn_inventory); + if (A_CheckEnemySprite(g_sp)) + X_DoConditional(ud.respawn_monsters); + else if (A_CheckInventorySprite(g_sp)) + X_DoConditional(ud.respawn_inventory); else - parseifelse(ud.respawn_items); + X_DoConditional(ud.respawn_items); break; case CON_IFFLOORDISTL: insptr++; - parseifelse((hittype[g_i].floorz - g_sp->z) <= ((*insptr)<<8)); + X_DoConditional((ActorExtra[g_i].floorz - g_sp->z) <= ((*insptr)<<8)); break; case CON_IFCEILINGDISTL: insptr++; - parseifelse((g_sp->z - hittype[g_i].ceilingz) <= ((*insptr)<<8)); + X_DoConditional((g_sp->z - ActorExtra[g_i].ceilingz) <= ((*insptr)<<8)); break; case CON_PALFROM: @@ -2955,18 +2953,18 @@ static int parse(void) insptr++; { int dq = *insptr++, sq = *insptr++; - if ((fta_quotes[sq] == NULL || fta_quotes[dq] == NULL) && checkCON) + if ((ScriptQuotes[sq] == NULL || ScriptQuotes[dq] == NULL) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "null quote %d\n",line_num,keyw[g_tw],fta_quotes[sq] ? dq : sq); + OSD_Printf(CON_ERROR "null quote %d\n",g_errorLineNum,keyw[g_tw],ScriptQuotes[sq] ? dq : sq); insptr += 4; break; } { - int var1 = GetGameVarID(*insptr++, g_i, g_p), var2 = GetGameVarID(*insptr++, g_i, g_p); - int var3 = GetGameVarID(*insptr++, g_i, g_p), var4 = GetGameVarID(*insptr++, g_i, g_p); - Bstrcpy(tempbuf,fta_quotes[sq]); - Bsprintf(fta_quotes[dq],tempbuf,var1,var2,var3,var4); + int var1 = Gv_GetVar(*insptr++, g_i, g_p), var2 = Gv_GetVar(*insptr++, g_i, g_p); + int var3 = Gv_GetVar(*insptr++, g_i, g_p), var4 = Gv_GetVar(*insptr++, g_i, g_p); + Bstrcpy(tempbuf,ScriptQuotes[sq]); + Bsprintf(ScriptQuotes[dq],tempbuf,var1,var2,var3,var4); break; } } @@ -2975,7 +2973,7 @@ static int parse(void) { insptr++; - OSD_Printf(OSDTEXT_GREEN "CONLOG: L=%d\n",line_num); + OSD_Printf(OSDTEXT_GREEN "CONLOG: L=%d\n",g_errorLineNum); break; } @@ -2986,11 +2984,11 @@ static int parse(void) char szBuf[256]; int lVarID = *insptr; - if ((lVarID >= iGameVarCount) || lVarID < 0) + if ((lVarID >= g_gameVarCount) || lVarID < 0) { if (*insptr==MAXGAMEVARS) // addlogvar for a constant? Har. insptr++; -// else if (*insptr > iGameVarCount && (*insptr < (MAXGAMEVARS<<1)+MAXGAMEVARS+1+MAXGAMEARRAYS)) +// else if (*insptr > g_gameVarCount && (*insptr < (MAXGAMEVARS<<1)+MAXGAMEVARS+1+MAXGAMEARRAYS)) else if (*insptr&(MAXGAMEVARS<<2)) { int index; @@ -3005,16 +3003,16 @@ static int parse(void) insptr++; - index=GetGameVarID(*insptr++,g_i,g_p); + index=Gv_GetVar(*insptr++,g_i,g_p); if ((index < aGameArrays[lVarID].size)&&(index>=0)) { - OSD_Printf(OSDTEXT_GREEN "%s: L=%d %s[%d] =%d\n",line_num,keyw[g_tw], + OSD_Printf(OSDTEXT_GREEN "%s: L=%d %s[%d] =%d\n",g_errorLineNum,keyw[g_tw], aGameArrays[lVarID].szLabel,index,m*aGameArrays[lVarID].plValues[index]); break; } else { - OSD_Printf(CON_ERROR "invalid array index\n",line_num,keyw[g_tw]); + OSD_Printf(CON_ERROR "invalid array index\n",g_errorLineNum,keyw[g_tw]); break; } } @@ -3027,23 +3025,23 @@ static int parse(void) { // invalid varID insptr++; - OSD_Printf(CON_ERROR "invalid variable\n",line_num,keyw[g_tw]); + OSD_Printf(CON_ERROR "invalid variable\n",g_errorLineNum,keyw[g_tw]); break; // out of switch } } - Bsprintf(szBuf,"CONLOGVAR: L=%d %s ",line_num, aGameVars[lVarID].szLabel); + Bsprintf(szBuf,"CONLOGVAR: L=%d %s ",g_errorLineNum, aGameVars[lVarID].szLabel); strcpy(g_szBuf,szBuf); - if (aGameVars[lVarID].dwFlags & GAMEVAR_FLAG_READONLY) + if (aGameVars[lVarID].dwFlags & GAMEVAR_READONLY) { Bsprintf(szBuf," (read-only)"); strcat(g_szBuf,szBuf); } - if (aGameVars[lVarID].dwFlags & GAMEVAR_FLAG_PERPLAYER) + if (aGameVars[lVarID].dwFlags & GAMEVAR_PERPLAYER) { Bsprintf(szBuf," (Per Player. Player=%d)",g_p); } - else if (aGameVars[lVarID].dwFlags & GAMEVAR_FLAG_PERACTOR) + else if (aGameVars[lVarID].dwFlags & GAMEVAR_PERACTOR) { Bsprintf(szBuf," (Per Actor. Actor=%d)",g_i); } @@ -3052,7 +3050,7 @@ static int parse(void) Bsprintf(szBuf," (Global)"); } Bstrcat(g_szBuf,szBuf); - Bsprintf(szBuf," =%d\n", GetGameVarID(lVarID, g_i, g_p)*m); + Bsprintf(szBuf," =%d\n", Gv_GetVar(lVarID, g_i, g_p)*m); Bstrcat(g_szBuf,szBuf); OSD_Printf(OSDTEXT_GREEN "%s",g_szBuf); insptr++; @@ -3067,7 +3065,7 @@ static int parse(void) // int lVar1=*insptr++, lLabelID=*insptr++, lVar2=*insptr++; - DoSector(tw==CON_SETSECTOR, lVar1, lLabelID, lVar2); + X_AccessSector(tw==CON_SETSECTOR, lVar1, lLabelID, lVar2); break; } @@ -3077,7 +3075,7 @@ static int parse(void) // syntax sqrt int lInVarID=*insptr++, lOutVarID=*insptr++; - SetGameVarID(lOutVarID, ksqrt(GetGameVarID(lInVarID, g_i, g_p)), g_i, g_p); + Gv_SetVar(lOutVarID, ksqrt(Gv_GetVar(lInVarID, g_i, g_p)), g_i, g_p); break; } @@ -3130,7 +3128,7 @@ static int parse(void) break; } while (k--); - SetGameVarID(lVarID, lFound, g_i, g_p); + Gv_SetVar(lVarID, lFound, g_i, g_p); break; } @@ -3145,7 +3143,7 @@ static int parse(void) // that is of into // -1 for none found // - int lType=*insptr++, lMaxDist=GetGameVarID(*insptr++, g_i, g_p), lVarID=*insptr++; + int lType=*insptr++, lMaxDist=Gv_GetVar(*insptr++, g_i, g_p), lVarID=*insptr++; int lFound=-1, j, k = MAXSTATUS-1; if (tw == CON_FINDNEARACTORVAR || tw == CON_FINDNEARACTOR3DVAR) @@ -3184,7 +3182,7 @@ static int parse(void) break; } while (k--); - SetGameVarID(lVarID, lFound, g_i, g_p); + Gv_SetVar(lVarID, lFound, g_i, g_p); break; } @@ -3197,7 +3195,7 @@ static int parse(void) // that is of into // -1 for none found // - int lType=*insptr++, lMaxDist=GetGameVarID(*insptr++, g_i, g_p), lMaxZDist=GetGameVarID(*insptr++, g_i, g_p); + int lType=*insptr++, lMaxDist=Gv_GetVar(*insptr++, g_i, g_p), lMaxZDist=Gv_GetVar(*insptr++, g_i, g_p); int lVarID=*insptr++, lFound=-1, lTemp, lTemp2, j, k; k=MAXSTATUS-1; @@ -3228,7 +3226,7 @@ static int parse(void) break; } while (k--); - SetGameVarID(lVarID, lFound, g_i, g_p); + Gv_SetVar(lVarID, lFound, g_i, g_p); break; } @@ -3273,7 +3271,7 @@ static int parse(void) break; } while (k--); - SetGameVarID(lVarID, lFound, g_i, g_p); + Gv_SetVar(lVarID, lFound, g_i, g_p); break; } @@ -3288,11 +3286,11 @@ static int parse(void) // int var1 = *insptr++, d; - if (tw == CON_FINDPLAYER) j=findplayer(&sprite[g_i],&d); - else j=findotherplayer(g_i,&d); + if (tw == CON_FINDPLAYER) j=A_FindPlayer(&sprite[g_i],&d); + else j=P_FindOtherPlayer(g_i,&d); - SetGameVarID(g_iReturnVarID, j, g_i, g_p); - SetGameVarID(var1, d, g_i, g_p); + Gv_SetVar(g_iReturnVarID, j, g_i, g_p); + Gv_SetVar(var1, d, g_i, g_p); break; } @@ -3306,11 +3304,11 @@ static int parse(void) int lVar1=*insptr++, lLabelID=*insptr++, lParm2 = 0, lVar2; // HACK: need to have access to labels structure at run-time... - if (playerlabels[lLabelID].flags & LABEL_HASPARM2) - lParm2=GetGameVarID(*insptr++, g_i, g_p); + if (PlayerLabels[lLabelID].flags & LABEL_HASPARM2) + lParm2=Gv_GetVar(*insptr++, g_i, g_p); lVar2=*insptr++; - DoPlayer(tw==CON_SETPLAYER, lVar1, lLabelID, lVar2, lParm2); + X_AccessPlayer(tw==CON_SETPLAYER, lVar1, lLabelID, lVar2, lParm2); break; } @@ -3322,7 +3320,7 @@ static int parse(void) // int lVar1=*insptr++, lLabelID=*insptr++, lVar2=*insptr++; - DoInput(tw==CON_SETINPUT, lVar1, lLabelID, lVar2); + X_AccessPlayerInput(tw==CON_SETINPUT, lVar1, lLabelID, lVar2); break; } @@ -3334,7 +3332,7 @@ static int parse(void) // int lLabelID=*insptr++, lVar2=*insptr++; - DoUserDef(tw==CON_SETUSERDEF, lLabelID, lVar2); + X_AccessUserdef(tw==CON_SETUSERDEF, lLabelID, lVar2); break; } @@ -3344,9 +3342,9 @@ static int parse(void) { // syntax [gs]etplayer[].x // - int lVar1=GetGameVarID(*insptr++, g_i, g_p), lLabelID=*insptr++, lVar2=*insptr++; + int lVar1=Gv_GetVar(*insptr++, g_i, g_p), lLabelID=*insptr++, lVar2=*insptr++; - DoProjectile(tw==CON_SETPROJECTILE,lVar1,lLabelID,lVar2); + X_AccessProjectile(tw==CON_SETPROJECTILE,lVar1,lLabelID,lVar2); break; } @@ -3358,7 +3356,7 @@ static int parse(void) // int lVar1=*insptr++, lLabelID=*insptr++, lVar2=*insptr++; - DoWall(tw==CON_SETWALL, lVar1, lLabelID, lVar2); + X_AccessWall(tw==CON_SETWALL, lVar1, lLabelID, lVar2); break; } @@ -3369,12 +3367,12 @@ static int parse(void) // syntax [gs]etactorvar[]. // gets the value of the per-actor variable varx into VAR // - int lSprite=GetGameVarID(*insptr++, g_i, g_p), lVar1=*insptr++; + int lSprite=Gv_GetVar(*insptr++, g_i, g_p), lVar1=*insptr++; j=*insptr++; - if ((lSprite < 0 || lSprite >= MAXSPRITES) && checkCON) + if ((lSprite < 0 || lSprite >= MAXSPRITES) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "invalid sprite ID %d\n",line_num,keyw[g_tw],lSprite); + OSD_Printf(CON_ERROR "invalid sprite ID %d\n",g_errorLineNum,keyw[g_tw],lSprite); if (lVar1 == MAXGAMEVARS) insptr++; if (j == MAXGAMEVARS) insptr++; break; @@ -3382,10 +3380,10 @@ static int parse(void) if (tw == CON_SETACTORVAR) { - SetGameVarID(lVar1, GetGameVarID(j, g_i, g_p), lSprite, g_p); + Gv_SetVar(lVar1, Gv_GetVar(j, g_i, g_p), lSprite, g_p); break; } - SetGameVarID(j, GetGameVarID(lVar1, lSprite, g_p), g_i, g_p); + Gv_SetVar(j, Gv_GetVar(lVar1, lSprite, g_p), g_i, g_p); break; } @@ -3396,25 +3394,25 @@ static int parse(void) int iPlayer; if (*insptr != g_iThisActorID) - iPlayer=GetGameVarID(*insptr, g_i, g_p); + iPlayer=Gv_GetVar(*insptr, g_i, g_p); else iPlayer = g_p; insptr++; { int lVar1=*insptr++, lVar2=*insptr++; - if ((iPlayer < 0 || iPlayer >= ud.multimode) && checkCON) + if ((iPlayer < 0 || iPlayer >= ud.multimode) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "invalid player ID %d\n",line_num,keyw[g_tw],iPlayer); + OSD_Printf(CON_ERROR "invalid player ID %d\n",g_errorLineNum,keyw[g_tw],iPlayer); break; } if (tw == CON_SETPLAYERVAR) { - SetGameVarID(lVar1, GetGameVarID(lVar2, g_i, g_p), g_i, iPlayer); + Gv_SetVar(lVar1, Gv_GetVar(lVar2, g_i, g_p), g_i, iPlayer); break; } - SetGameVarID(lVar2, GetGameVarID(lVar1, g_i, iPlayer), g_i, g_p); + Gv_SetVar(lVar2, Gv_GetVar(lVar1, g_i, iPlayer), g_i, g_p); break; } } @@ -3428,11 +3426,11 @@ static int parse(void) int lVar1=*insptr++, lLabelID=*insptr++, lParm2 = 0, lVar2; - if (actorlabels[lLabelID].flags & LABEL_HASPARM2) - lParm2=GetGameVarID(*insptr++, g_i, g_p); + if (ActorLabels[lLabelID].flags & LABEL_HASPARM2) + lParm2=Gv_GetVar(*insptr++, g_i, g_p); lVar2=*insptr++; - DoActor(tw==CON_SETACTOR, lVar1, lLabelID, lVar2, lParm2); + X_AccessSprite(tw==CON_SETACTOR, lVar1, lLabelID, lVar2, lParm2); break; } @@ -3445,24 +3443,24 @@ static int parse(void) int lVar1=*insptr++, lLabelID=*insptr++, lVar2=*insptr++; - DoTsprite(tw==CON_SETTSPR, lVar1, lLabelID, lVar2); + X_AccessTsprite(tw==CON_SETTSPR, lVar1, lLabelID, lVar2); break; } case CON_GETANGLETOTARGET: insptr++; - // hittype[g_i].lastvx and lastvy are last known location of target. - SetGameVarID(*insptr++, getangle(hittype[g_i].lastvx-g_sp->x,hittype[g_i].lastvy-g_sp->y), g_i, g_p); + // ActorExtra[g_i].lastvx and lastvy are last known location of target. + Gv_SetVar(*insptr++, getangle(ActorExtra[g_i].lastvx-g_sp->x,ActorExtra[g_i].lastvy-g_sp->y), g_i, g_p); break; case CON_ANGOFFVAR: insptr++; - spriteext[g_i].angoff=GetGameVarID(*insptr++, g_i, g_p); + spriteext[g_i].angoff=Gv_GetVar(*insptr++, g_i, g_p); break; case CON_LOCKPLAYER: insptr++; - g_player[g_p].ps->transporter_hold=GetGameVarID(*insptr++, g_i, g_p); + g_player[g_p].ps->transporter_hold=Gv_GetVar(*insptr++, g_i, g_p); break; case CON_CHECKAVAILWEAPON: @@ -3471,47 +3469,47 @@ static int parse(void) j = g_p; if (*insptr != g_iThisActorID) - j=GetGameVarID(*insptr, g_i, g_p); + j=Gv_GetVar(*insptr, g_i, g_p); insptr++; - if ((j < 0 || j >= ud.multimode) && checkCON) + if ((j < 0 || j >= ud.multimode) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "Invalid player ID %d\n",line_num,keyw[g_tw],j); + OSD_Printf(CON_ERROR "Invalid player ID %d\n",g_errorLineNum,keyw[g_tw],j); break; } if (tw == CON_CHECKAVAILWEAPON) - checkavailweapon(g_player[j].ps); - else checkavailinven(g_player[j].ps); + P_CheckWeapon(g_player[j].ps); + else P_SelectNextInventoryItem(g_player[j].ps); break; case CON_GETPLAYERANGLE: insptr++; - SetGameVarID(*insptr++, g_player[g_p].ps->ang, g_i, g_p); + Gv_SetVar(*insptr++, g_player[g_p].ps->ang, g_i, g_p); break; case CON_SETPLAYERANGLE: insptr++; - g_player[g_p].ps->ang=GetGameVarID(*insptr++, g_i, g_p); + g_player[g_p].ps->ang=Gv_GetVar(*insptr++, g_i, g_p); g_player[g_p].ps->ang &= 2047; break; case CON_GETACTORANGLE: insptr++; - SetGameVarID(*insptr++, g_sp->ang, g_i, g_p); + Gv_SetVar(*insptr++, g_sp->ang, g_i, g_p); break; case CON_SETACTORANGLE: insptr++; - g_sp->ang=GetGameVarID(*insptr++, g_i, g_p); + g_sp->ang=Gv_GetVar(*insptr++, g_i, g_p); g_sp->ang &= 2047; break; case CON_SETVAR: insptr++; - SetGameVarID(*insptr, *(insptr+1), g_i, g_p); + Gv_SetVar(*insptr, *(insptr+1), g_i, g_p); insptr += 2; break; @@ -3519,13 +3517,13 @@ static int parse(void) insptr++; j=*insptr++; { - int index = GetGameVarID(*insptr++, g_i, g_p); - int value = GetGameVarID(*insptr++, g_i, g_p); + int index = Gv_GetVar(*insptr++, g_i, g_p); + int value = Gv_GetVar(*insptr++, g_i, g_p); // SetGameArrayID(j,index,value); - if (j<0 || j >= iGameArrayCount || index >= aGameArrays[j].size || index < 0) + if (j<0 || j >= g_gameArrayCount || index >= aGameArrays[j].size || index < 0) { - OSD_Printf(OSD_ERROR "SetGameVarID(): tried to set invalid array ID (%d) or index out of bounds from sprite %d (%d), player %d\n",j,g_i,sprite[g_i].picnum,g_p); + OSD_Printf(OSD_ERROR "Gv_SetVar(): tried to set invalid array ID (%d) or index out of bounds from sprite %d (%d), player %d\n",j,g_i,sprite[g_i].picnum,g_p); return 0; } aGameArrays[j].plValues[index]=value; @@ -3534,14 +3532,14 @@ static int parse(void) case CON_GETARRAYSIZE: insptr++; j=*insptr++; - SetGameVarID(*insptr++,aGameArrays[j].size, g_i, g_p); + Gv_SetVar(*insptr++,aGameArrays[j].size, g_i, g_p); break; case CON_RESIZEARRAY: insptr++; j=*insptr++; { - int asize = GetGameVarID(*insptr++, g_i, g_p); + int asize = Gv_GetVar(*insptr++, g_i, g_p); if (asize > 0) { OSD_Printf(OSDTEXT_GREEN "CON_RESIZEARRAY: resizing array %s from %d to %d\n", aGameArrays[j].szLabel, aGameArrays[j].size, asize); @@ -3553,19 +3551,19 @@ static int parse(void) case CON_RANDVAR: insptr++; - SetGameVarID(*insptr, mulscale(krand(), *(insptr+1)+1, 16), g_i, g_p); + Gv_SetVar(*insptr, mulscale(krand(), *(insptr+1)+1, 16), g_i, g_p); insptr += 2; break; case CON_DISPLAYRANDVAR: insptr++; - SetGameVarID(*insptr, mulscale(rand(), *(insptr+1)+1, 15), g_i, g_p); + Gv_SetVar(*insptr, mulscale(rand(), *(insptr+1)+1, 15), g_i, g_p); insptr += 2; break; case CON_MULVAR: insptr++; - SetGameVarID(*insptr, GetGameVarID(*insptr, g_i, g_p) * *(insptr+1), g_i, g_p); + Gv_SetVar(*insptr, Gv_GetVar(*insptr, g_i, g_p) * *(insptr+1), g_i, g_p); insptr += 2; break; @@ -3573,11 +3571,11 @@ static int parse(void) insptr++; if (*(insptr+1) == 0) { - OSD_Printf(CON_ERROR "Divide by zero.\n",line_num,keyw[g_tw]); + OSD_Printf(CON_ERROR "Divide by zero.\n",g_errorLineNum,keyw[g_tw]); insptr += 2; break; } - SetGameVarID(*insptr, GetGameVarID(*insptr, g_i, g_p) / *(insptr+1), g_i, g_p); + Gv_SetVar(*insptr, Gv_GetVar(*insptr, g_i, g_p) / *(insptr+1), g_i, g_p); insptr += 2; break; @@ -3585,92 +3583,92 @@ static int parse(void) insptr++; if (*(insptr+1) == 0) { - OSD_Printf(CON_ERROR "Mod by zero.\n",line_num,keyw[g_tw]); + OSD_Printf(CON_ERROR "Mod by zero.\n",g_errorLineNum,keyw[g_tw]); insptr += 2; break; } - SetGameVarID(*insptr,GetGameVarID(*insptr, g_i, g_p)%*(insptr+1), g_i, g_p); + Gv_SetVar(*insptr,Gv_GetVar(*insptr, g_i, g_p)%*(insptr+1), g_i, g_p); insptr += 2; break; case CON_ANDVAR: insptr++; - SetGameVarID(*insptr,GetGameVarID(*insptr, g_i, g_p) & *(insptr+1), g_i, g_p); + Gv_SetVar(*insptr,Gv_GetVar(*insptr, g_i, g_p) & *(insptr+1), g_i, g_p); insptr += 2; break; case CON_ORVAR: insptr++; - SetGameVarID(*insptr,GetGameVarID(*insptr, g_i, g_p) | *(insptr+1), g_i, g_p); + Gv_SetVar(*insptr,Gv_GetVar(*insptr, g_i, g_p) | *(insptr+1), g_i, g_p); insptr += 2; break; case CON_XORVAR: insptr++; - SetGameVarID(*insptr,GetGameVarID(*insptr, g_i, g_p) ^ *(insptr+1), g_i, g_p); + Gv_SetVar(*insptr,Gv_GetVar(*insptr, g_i, g_p) ^ *(insptr+1), g_i, g_p); insptr += 2; break; case CON_SETVARVAR: insptr++; j=*insptr++; - SetGameVarID(j, GetGameVarID(*insptr++, g_i, g_p), g_i, g_p); + Gv_SetVar(j, Gv_GetVar(*insptr++, g_i, g_p), g_i, g_p); break; case CON_RANDVARVAR: insptr++; j=*insptr++; - SetGameVarID(j,mulscale(krand(), GetGameVarID(*insptr++, g_i, g_p)+1, 16), g_i, g_p); + Gv_SetVar(j,mulscale(krand(), Gv_GetVar(*insptr++, g_i, g_p)+1, 16), g_i, g_p); break; case CON_DISPLAYRANDVARVAR: insptr++; j=*insptr++; - SetGameVarID(j,mulscale(rand(), GetGameVarID(*insptr++, g_i, g_p)+1, 15), g_i, g_p); + Gv_SetVar(j,mulscale(rand(), Gv_GetVar(*insptr++, g_i, g_p)+1, 15), g_i, g_p); break; case CON_GMAXAMMO: insptr++; - j=GetGameVarID(*insptr++, g_i, g_p); - if ((j<0 || j>=MAX_WEAPONS) && checkCON) + j=Gv_GetVar(*insptr++, g_i, g_p); + if ((j<0 || j>=MAX_WEAPONS) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "Invalid weapon ID %d\n",line_num,keyw[g_tw],j); + OSD_Printf(CON_ERROR "Invalid weapon ID %d\n",g_errorLineNum,keyw[g_tw],j); insptr++; break; } - SetGameVarID(*insptr++, g_player[g_p].ps->max_ammo_amount[j], g_i, g_p); + Gv_SetVar(*insptr++, g_player[g_p].ps->max_ammo_amount[j], g_i, g_p); break; case CON_SMAXAMMO: insptr++; - j=GetGameVarID(*insptr++, g_i, g_p); - if ((j<0 || j>=MAX_WEAPONS) && checkCON) + j=Gv_GetVar(*insptr++, g_i, g_p); + if ((j<0 || j>=MAX_WEAPONS) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "Invalid weapon ID %d\n",line_num,keyw[g_tw],j); + OSD_Printf(CON_ERROR "Invalid weapon ID %d\n",g_errorLineNum,keyw[g_tw],j); insptr++; break; } - g_player[g_p].ps->max_ammo_amount[j]=GetGameVarID(*insptr++, g_i, g_p); + g_player[g_p].ps->max_ammo_amount[j]=Gv_GetVar(*insptr++, g_i, g_p); break; case CON_MULVARVAR: insptr++; j=*insptr++; - SetGameVarID(j, GetGameVarID(j, g_i, g_p)*GetGameVarID(*insptr++, g_i, g_p), g_i, g_p); + Gv_SetVar(j, Gv_GetVar(j, g_i, g_p)*Gv_GetVar(*insptr++, g_i, g_p), g_i, g_p); break; case CON_DIVVARVAR: insptr++; j=*insptr++; { - int l2=GetGameVarID(*insptr++, g_i, g_p); + int l2=Gv_GetVar(*insptr++, g_i, g_p); if (l2==0) { - OSD_Printf(CON_ERROR "Divide by zero.\n",line_num,keyw[g_tw]); + OSD_Printf(CON_ERROR "Divide by zero.\n",g_errorLineNum,keyw[g_tw]); break; } - SetGameVarID(j, GetGameVarID(j, g_i, g_p)/l2 , g_i, g_p); + Gv_SetVar(j, Gv_GetVar(j, g_i, g_p)/l2 , g_i, g_p); break; } @@ -3678,129 +3676,129 @@ static int parse(void) insptr++; j=*insptr++; { - int l2=GetGameVarID(*insptr++, g_i, g_p); + int l2=Gv_GetVar(*insptr++, g_i, g_p); if (l2==0) { - OSD_Printf(CON_ERROR "Mod by zero.\n",line_num,keyw[g_tw]); + OSD_Printf(CON_ERROR "Mod by zero.\n",g_errorLineNum,keyw[g_tw]); break; } - SetGameVarID(j, GetGameVarID(j, g_i, g_p) % l2, g_i, g_p); + Gv_SetVar(j, Gv_GetVar(j, g_i, g_p) % l2, g_i, g_p); break; } case CON_ANDVARVAR: insptr++; j=*insptr++; - SetGameVarID(j, GetGameVarID(j, g_i, g_p) & GetGameVarID(*insptr++, g_i, g_p), g_i, g_p); + Gv_SetVar(j, Gv_GetVar(j, g_i, g_p) & Gv_GetVar(*insptr++, g_i, g_p), g_i, g_p); break; case CON_XORVARVAR: insptr++; j=*insptr++; - SetGameVarID(j, GetGameVarID(j, g_i, g_p) ^ GetGameVarID(*insptr++, g_i, g_p) , g_i, g_p); + Gv_SetVar(j, Gv_GetVar(j, g_i, g_p) ^ Gv_GetVar(*insptr++, g_i, g_p) , g_i, g_p); break; case CON_ORVARVAR: insptr++; j=*insptr++; - SetGameVarID(j, GetGameVarID(j, g_i, g_p) | GetGameVarID(*insptr++, g_i, g_p) , g_i, g_p); + Gv_SetVar(j, Gv_GetVar(j, g_i, g_p) | Gv_GetVar(*insptr++, g_i, g_p) , g_i, g_p); break; case CON_SUBVAR: insptr++; - SetGameVarID(*insptr, GetGameVarID(*insptr, g_i, g_p) - *(insptr+1), g_i, g_p); + Gv_SetVar(*insptr, Gv_GetVar(*insptr, g_i, g_p) - *(insptr+1), g_i, g_p); insptr += 2; break; case CON_SUBVARVAR: insptr++; j=*insptr++; - SetGameVarID(j, GetGameVarID(j, g_i, g_p) - GetGameVarID(*insptr++, g_i, g_p), g_i, g_p); + Gv_SetVar(j, Gv_GetVar(j, g_i, g_p) - Gv_GetVar(*insptr++, g_i, g_p), g_i, g_p); break; case CON_ADDVAR: insptr++; - SetGameVarID(*insptr, GetGameVarID(*insptr, g_i, g_p) + *(insptr+1), g_i, g_p); + Gv_SetVar(*insptr, Gv_GetVar(*insptr, g_i, g_p) + *(insptr+1), g_i, g_p); insptr += 2; break; case CON_SHIFTVARL: insptr++; - SetGameVarID(*insptr, GetGameVarID(*insptr, g_i, g_p) << *(insptr+1), g_i, g_p); + Gv_SetVar(*insptr, Gv_GetVar(*insptr, g_i, g_p) << *(insptr+1), g_i, g_p); insptr += 2; break; case CON_SHIFTVARR: insptr++; - SetGameVarID(*insptr, GetGameVarID(*insptr, g_i, g_p) >> *(insptr+1), g_i, g_p); + Gv_SetVar(*insptr, Gv_GetVar(*insptr, g_i, g_p) >> *(insptr+1), g_i, g_p); insptr += 2; break; case CON_SIN: insptr++; - SetGameVarID(*insptr, sintable[GetGameVarID(*(insptr+1), g_i, g_p)&2047], g_i, g_p); + Gv_SetVar(*insptr, sintable[Gv_GetVar(*(insptr+1), g_i, g_p)&2047], g_i, g_p); insptr += 2; break; case CON_COS: insptr++; - SetGameVarID(*insptr, sintable[(GetGameVarID(*(insptr+1), g_i, g_p)+512)&2047], g_i, g_p); + Gv_SetVar(*insptr, sintable[(Gv_GetVar(*(insptr+1), g_i, g_p)+512)&2047], g_i, g_p); insptr += 2; break; case CON_ADDVARVAR: insptr++; j=*insptr++; - SetGameVarID(j, GetGameVarID(j, g_i, g_p) + GetGameVarID(*insptr++, g_i, g_p), g_i, g_p); + Gv_SetVar(j, Gv_GetVar(j, g_i, g_p) + Gv_GetVar(*insptr++, g_i, g_p), g_i, g_p); break; case CON_SPGETLOTAG: insptr++; - SetGameVarID(g_iLoTagID, g_sp->lotag, g_i, g_p); + Gv_SetVar(g_iLoTagID, g_sp->lotag, g_i, g_p); break; case CON_SPGETHITAG: insptr++; - SetGameVarID(g_iHiTagID, g_sp->hitag, g_i, g_p); + Gv_SetVar(g_iHiTagID, g_sp->hitag, g_i, g_p); break; case CON_SECTGETLOTAG: insptr++; - SetGameVarID(g_iLoTagID, sector[g_sp->sectnum].lotag, g_i, g_p); + Gv_SetVar(g_iLoTagID, sector[g_sp->sectnum].lotag, g_i, g_p); break; case CON_SECTGETHITAG: insptr++; - SetGameVarID(g_iHiTagID, sector[g_sp->sectnum].hitag, g_i, g_p); + Gv_SetVar(g_iHiTagID, sector[g_sp->sectnum].hitag, g_i, g_p); break; case CON_GETTEXTUREFLOOR: insptr++; - SetGameVarID(g_iTextureID, sector[g_sp->sectnum].floorpicnum, g_i, g_p); + Gv_SetVar(g_iTextureID, sector[g_sp->sectnum].floorpicnum, g_i, g_p); break; case CON_STARTTRACK: case CON_STARTTRACKVAR: insptr++; - if (tw == CON_STARTTRACK) music_select=(ud.volume_number*MAXLEVELS)+(*(insptr++)); - else music_select=(ud.volume_number*MAXLEVELS)+(GetGameVarID(*(insptr++), g_i, g_p)); - if (map[(unsigned char)music_select].musicfn == NULL) + if (tw == CON_STARTTRACK) g_musicIndex=(ud.volume_number*MAXLEVELS)+(*(insptr++)); + else g_musicIndex=(ud.volume_number*MAXLEVELS)+(Gv_GetVar(*(insptr++), g_i, g_p)); + if (MapInfo[(unsigned char)g_musicIndex].musicfn == NULL) { - OSD_Printf(CON_ERROR "null music for map %d\n",line_num,keyw[g_tw],music_select); + OSD_Printf(CON_ERROR "null music for map %d\n",g_errorLineNum,keyw[g_tw],g_musicIndex); insptr++; break; } - playmusic(&map[(unsigned char)music_select].musicfn[0],music_select); + S_PlayMusic(&MapInfo[(unsigned char)g_musicIndex].musicfn[0],g_musicIndex); break; case CON_ACTIVATECHEAT: insptr++; - j=GetGameVarID(*(insptr++), g_i, g_p); + j=Gv_GetVar(*(insptr++), g_i, g_p); if (numplayers != 1 || !(g_player[myconnectindex].ps->gm & MODE_GAME)) { - OSD_Printf(CON_ERROR "not in a single-player game.\n",line_num,keyw[g_tw]); + OSD_Printf(CON_ERROR "not in a single-player game.\n",g_errorLineNum,keyw[g_tw]); break; } osdcmd_cheatsinfo_stat.cheatnum = j; @@ -3808,83 +3806,83 @@ static int parse(void) case CON_SETGAMEPALETTE: insptr++; - j=GetGameVarID(*(insptr++), g_i, g_p); + j=Gv_GetVar(*(insptr++), g_i, g_p); switch (j) { default: - case 0:setgamepalette(g_player[g_p].ps,palette ,0);break; - case 1:setgamepalette(g_player[g_p].ps,waterpal ,0);break; - case 2:setgamepalette(g_player[g_p].ps,slimepal ,0);break; - case 3:setgamepalette(g_player[g_p].ps,drealms ,0);break; - case 4:setgamepalette(g_player[g_p].ps,titlepal ,0);break; - case 5:setgamepalette(g_player[g_p].ps,endingpal,0);break; - case 6:setgamepalette(g_player[g_p].ps,animpal ,0);break; + case 0:SetGamePalette(g_player[g_p].ps,palette ,0);break; + case 1:SetGamePalette(g_player[g_p].ps,waterpal ,0);break; + case 2:SetGamePalette(g_player[g_p].ps,slimepal ,0);break; + case 3:SetGamePalette(g_player[g_p].ps,drealms ,0);break; + case 4:SetGamePalette(g_player[g_p].ps,titlepal ,0);break; + case 5:SetGamePalette(g_player[g_p].ps,endingpal,0);break; + case 6:SetGamePalette(g_player[g_p].ps,animpal ,0);break; } break; case CON_GETTEXTURECEILING: insptr++; - SetGameVarID(g_iTextureID, sector[g_sp->sectnum].ceilingpicnum, g_i, g_p); + Gv_SetVar(g_iTextureID, sector[g_sp->sectnum].ceilingpicnum, g_i, g_p); break; case CON_IFVARVARAND: insptr++; j=*insptr++; - parseifelse(GetGameVarID(j, g_i, g_p) & GetGameVarID(*(insptr), g_i, g_p)); + X_DoConditional(Gv_GetVar(j, g_i, g_p) & Gv_GetVar(*(insptr), g_i, g_p)); break; case CON_IFVARVAROR: insptr++; j=*insptr++; - parseifelse(GetGameVarID(j, g_i, g_p) | GetGameVarID(*(insptr), g_i, g_p)); + X_DoConditional(Gv_GetVar(j, g_i, g_p) | Gv_GetVar(*(insptr), g_i, g_p)); break; case CON_IFVARVARXOR: insptr++; j=*insptr++; - parseifelse(GetGameVarID(j, g_i, g_p) ^ GetGameVarID(*(insptr), g_i, g_p)); + X_DoConditional(Gv_GetVar(j, g_i, g_p) ^ Gv_GetVar(*(insptr), g_i, g_p)); break; case CON_IFVARVAREITHER: insptr++; j=*insptr++; - parseifelse(GetGameVarID(j, g_i, g_p) || GetGameVarID(*(insptr), g_i, g_p)); + X_DoConditional(Gv_GetVar(j, g_i, g_p) || Gv_GetVar(*(insptr), g_i, g_p)); break; case CON_IFVARVARN: insptr++; j=*insptr++; - parseifelse(GetGameVarID(j, g_i, g_p) != GetGameVarID(*(insptr), g_i, g_p)); + X_DoConditional(Gv_GetVar(j, g_i, g_p) != Gv_GetVar(*(insptr), g_i, g_p)); break; case CON_IFVARVARE: insptr++; j=*insptr++; - parseifelse(GetGameVarID(j, g_i, g_p) == GetGameVarID(*(insptr), g_i, g_p)); + X_DoConditional(Gv_GetVar(j, g_i, g_p) == Gv_GetVar(*(insptr), g_i, g_p)); break; case CON_IFVARVARG: insptr++; j=*insptr++; - parseifelse(GetGameVarID(j, g_i, g_p) > GetGameVarID(*(insptr), g_i, g_p)); + X_DoConditional(Gv_GetVar(j, g_i, g_p) > Gv_GetVar(*(insptr), g_i, g_p)); break; case CON_IFVARVARL: insptr++; j=*insptr++; - parseifelse(GetGameVarID(j, g_i, g_p) < GetGameVarID(*(insptr), g_i, g_p)); + X_DoConditional(Gv_GetVar(j, g_i, g_p) < Gv_GetVar(*(insptr), g_i, g_p)); break; case CON_IFVARE: insptr++; j=*insptr++; - parseifelse(GetGameVarID(j, g_i, g_p) == *insptr); + X_DoConditional(Gv_GetVar(j, g_i, g_p) == *insptr); break; case CON_IFVARN: insptr++; j=*insptr++; - parseifelse(GetGameVarID(j, g_i, g_p) != *insptr); + X_DoConditional(Gv_GetVar(j, g_i, g_p) != *insptr); break; case CON_WHILEVARN: @@ -3894,9 +3892,9 @@ static int parse(void) do { insptr=savedinsptr; - if (GetGameVarID(*(insptr-1), g_i, g_p) == *insptr) + if (Gv_GetVar(*(insptr-1), g_i, g_p) == *insptr) j=0; - parseifelse(j); + X_DoConditional(j); } while (j); break; @@ -3910,11 +3908,11 @@ static int parse(void) do { insptr=savedinsptr; - i = GetGameVarID(*(insptr-1), g_i, g_p); + i = Gv_GetVar(*(insptr-1), g_i, g_p); k=*(insptr); - if (i == GetGameVarID(k, g_i, g_p)) + if (i == Gv_GetVar(k, g_i, g_p)) j=0; - parseifelse(j); + X_DoConditional(j); } while (j); break; @@ -3923,42 +3921,42 @@ static int parse(void) case CON_IFVARAND: insptr++; j=*insptr++; - parseifelse(GetGameVarID(j, g_i, g_p) & *insptr); + X_DoConditional(Gv_GetVar(j, g_i, g_p) & *insptr); break; case CON_IFVAROR: insptr++; j=*insptr++; - parseifelse(GetGameVarID(j, g_i, g_p) | *insptr); + X_DoConditional(Gv_GetVar(j, g_i, g_p) | *insptr); break; case CON_IFVARXOR: insptr++; j=*insptr++; - parseifelse(GetGameVarID(j, g_i, g_p) ^ *insptr); + X_DoConditional(Gv_GetVar(j, g_i, g_p) ^ *insptr); break; case CON_IFVAREITHER: insptr++; j=*insptr++; - parseifelse(GetGameVarID(j, g_i, g_p) || *insptr); + X_DoConditional(Gv_GetVar(j, g_i, g_p) || *insptr); break; case CON_IFVARG: insptr++; j=*insptr++; - parseifelse(GetGameVarID(j, g_i, g_p) > *insptr); + X_DoConditional(Gv_GetVar(j, g_i, g_p) > *insptr); break; case CON_IFVARL: insptr++; j=*insptr++; - parseifelse(GetGameVarID(j, g_i, g_p) < *insptr); + X_DoConditional(Gv_GetVar(j, g_i, g_p) < *insptr); break; case CON_IFPHEALTHL: insptr++; - parseifelse(sprite[g_player[g_p].ps->i].extra < *insptr); + X_DoConditional(sprite[g_player[g_p].ps->i].extra < *insptr); break; case CON_IFPINVENTORY: @@ -4008,10 +4006,10 @@ static int parse(void) if (g_player[g_p].ps->boot_amount != *insptr) j = 1; break; default: - OSD_Printf(CON_ERROR "invalid inventory ID: %d\n",line_num,keyw[g_tw],*(insptr-1)); + OSD_Printf(CON_ERROR "invalid inventory ID: %d\n",g_errorLineNum,keyw[g_tw],*(insptr-1)); } - parseifelse(j); + X_DoConditional(j); break; } @@ -4056,55 +4054,55 @@ static int parse(void) } } } - parseifelse(j); + X_DoConditional(j); } break; case CON_QUOTE: insptr++; - if ((fta_quotes[*insptr] == NULL) && checkCON) + if ((ScriptQuotes[*insptr] == NULL) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "null quote %d\n",line_num,keyw[g_tw],*insptr); + OSD_Printf(CON_ERROR "null quote %d\n",g_errorLineNum,keyw[g_tw],*insptr); insptr++; break; } - if ((g_p < 0 || g_p >= MAXPLAYERS) && checkCON) + if ((g_p < 0 || g_p >= MAXPLAYERS) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "bad player for quote %d: (%d)\n",line_num,keyw[g_tw],*insptr,g_p); + OSD_Printf(CON_ERROR "bad player for quote %d: (%d)\n",g_errorLineNum,keyw[g_tw],*insptr,g_p); insptr++; break; } - FTA(*(insptr++)|MAXQUOTES,g_player[g_p].ps); + P_DoQuote(*(insptr++)|MAXQUOTES,g_player[g_p].ps); break; case CON_USERQUOTE: insptr++; { - int i=GetGameVarID(*insptr++, g_i, g_p); + int i=Gv_GetVar(*insptr++, g_i, g_p); - if ((fta_quotes[i] == NULL) && checkCON) + if ((ScriptQuotes[i] == NULL) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "null quote %d\n",line_num,keyw[g_tw],i); + OSD_Printf(CON_ERROR "null quote %d\n",g_errorLineNum,keyw[g_tw],i); break; } - adduserquote(fta_quotes[i]); + G_AddUserQuote(ScriptQuotes[i]); } break; case CON_IFINOUTERSPACE: - parseifelse(floorspace(g_sp->sectnum)); + X_DoConditional(G_CheckForSpaceFloor(g_sp->sectnum)); break; case CON_IFNOTMOVING: - parseifelse((hittype[g_i].movflag&49152) > 16384); + X_DoConditional((ActorExtra[g_i].movflag&49152) > 16384); break; case CON_RESPAWNHITAG: insptr++; - switch (dynamictostatic[g_sp->picnum]) + switch (DynamicTileMap[g_sp->picnum]) { case FEM1__STATIC: case FEM2__STATIC: @@ -4119,23 +4117,23 @@ static int parse(void) case PODFEM1__STATIC: case NAKED1__STATIC: case STATUE__STATIC: - if (g_sp->yvel) operaterespawns(g_sp->yvel); + if (g_sp->yvel) G_OperateRespawns(g_sp->yvel); break; default: - if (g_sp->hitag >= 0) operaterespawns(g_sp->hitag); + if (g_sp->hitag >= 0) G_OperateRespawns(g_sp->hitag); break; } break; case CON_IFSPRITEPAL: insptr++; - parseifelse(g_sp->pal == *insptr); + X_DoConditional(g_sp->pal == *insptr); break; case CON_IFANGDIFFL: insptr++; - j = klabs(getincangle(g_player[g_p].ps->ang,g_sp->ang)); - parseifelse(j <= *insptr); + j = klabs(G_GetAngleDelta(g_player[g_p].ps->ang,g_sp->ang)); + X_DoConditional(j <= *insptr); break; case CON_IFNOSOUNDS: @@ -4143,29 +4141,29 @@ static int parse(void) if (g_sounds[j].SoundOwner[0].i == g_i) break; - parseifelse(j < 0); + X_DoConditional(j < 0); break; case CON_SPRITEFLAGS: insptr++; - hittype[g_i].flags = GetGameVarID(*insptr++, g_i, g_p); + ActorExtra[g_i].flags = Gv_GetVar(*insptr++, g_i, g_p); break; case CON_GETTICKS: insptr++; j=*insptr++; - SetGameVarID(j, getticks(), g_i, g_p); + Gv_SetVar(j, getticks(), g_i, g_p); break; case CON_GETCURRADDRESS: insptr++; j=*insptr++; - SetGameVarID(j, (intptr_t)(insptr-script), g_i, g_p); + Gv_SetVar(j, (intptr_t)(insptr-script), g_i, g_p); break; case CON_JUMP: insptr++; - j = GetGameVarID(*insptr++, g_i, g_p); + j = Gv_GetVar(*insptr++, g_i, g_p); insptr = (intptr_t *)(j+script); break; @@ -4174,49 +4172,49 @@ static int parse(void) "current opcode: %d, next five values: %d, %d, %d, %d, %d\ncurrent actor: %d (%d)\n", *(insptr-5),*(insptr-4),*(insptr-3),*(insptr-2),*(insptr-1),*insptr,*(insptr+1), *(insptr+2),*(insptr+3),*(insptr+4),*(insptr+5),g_i,g_sp->picnum); - OSD_Printf("line_num: %d, g_tw: %d\n",line_num,g_tw);*/ - scriptinfo(); + OSD_Printf("g_errorLineNum: %d, g_tw: %d\n",g_errorLineNum,g_tw);*/ + X_ScriptInfo(); - gameexit("An error has occurred in the EDuke32 CON executor.\n\n" - "If you are an end user, please e-mail the file eduke32.log\n" - "along with links to any mods you're using to terminx@gmail.com.\n\n" - "If you are a mod developer, please attach all of your CON files\n" - "along with instructions on how to reproduce this error.\n\n" - "Thank you!"); + G_GameExit("An error has occurred in the EDuke32 CON executor.\n\n" + "If you are an end user, please e-mail the file eduke32.log\n" + "along with links to any mods you're using to terminx@gmail.com.\n\n" + "If you are a mod developer, please attach all of your CON files\n" + "along with instructions on how to reproduce this error.\n\n" + "Thank you!"); break; } return 0; } -void LoadActor(int iActor) +void A_LoadActor(int iActor) { g_i = iActor; // Sprite ID g_p = -1; // iPlayer; // Player ID g_x = -1; // lDist; // ?? g_sp = &sprite[g_i]; // Pointer to sprite structure - g_t = &hittype[g_i].temp_data[0]; // Sprite's 'extra' data + g_t = &ActorExtra[g_i].temp_data[0]; // Sprite's 'extra' data if (actorLoadEventScrptr[g_sp->picnum] == 0) return; insptr = actorLoadEventScrptr[g_sp->picnum]; - killit_flag = 0; + g_killitFlag = 0; if (g_sp->sectnum < 0 || g_sp->sectnum >= MAXSECTORS) { - // if(badguy(g_sp)) + // if(A_CheckEnemySprite(g_sp)) // g_player[g_p].ps->actors_killed++; deletesprite(g_i); return; } - while (1) if (parse()) break; + while (1) if (X_DoExecute()) break; - if (killit_flag == 1) + if (g_killitFlag == 1) deletesprite(g_i); } -void execute(int iActor,int iPlayer,int lDist) +void A_Execute(int iActor,int iPlayer,int lDist) { int temp, temp2; @@ -4226,15 +4224,15 @@ void execute(int iActor,int iPlayer,int lDist) g_p = iPlayer; // Player ID g_x = lDist; // ?? g_sp = &sprite[g_i]; // Pointer to sprite structure - g_t = &hittype[g_i].temp_data[0]; // Sprite's 'extra' data + g_t = &ActorExtra[g_i].temp_data[0]; // Sprite's 'extra' data insptr = 4 + (actorscrptr[g_sp->picnum]); - killit_flag = 0; + g_killitFlag = 0; if (g_sp->sectnum < 0 || g_sp->sectnum >= MAXSECTORS) { - if (badguy(g_sp)) + if (A_CheckEnemySprite(g_sp)) g_player[g_p].ps->actors_killed++; deletesprite(g_i); return; @@ -4258,9 +4256,9 @@ void execute(int iActor,int iPlayer,int lDist) g_t[3] = 0; } - while (1) if (parse()) break; + while (1) if (X_DoExecute()) break; - if (killit_flag == 1) + if (g_killitFlag == 1) { // if player was set to squish, first stop that... if (g_player[g_p].ps->actorsqu == g_i) @@ -4269,7 +4267,7 @@ void execute(int iActor,int iPlayer,int lDist) return; } - move(); + X_Move(); if (ud.angleinterpolation) { @@ -4287,7 +4285,7 @@ void execute(int iActor,int iPlayer,int lDist) } if (g_sp->statnum == 6) - switch (dynamictostatic[g_sp->picnum]) + switch (DynamicTileMap[g_sp->picnum]) { case RUBBERCAN__STATIC: case EXPLODINGBARREL__STATIC: @@ -4300,9 +4298,9 @@ void execute(int iActor,int iPlayer,int lDist) case NUKEBARRELLEAKED__STATIC: case TRIPBOMB__STATIC: case EGG__STATIC: - if (hittype[g_i].timetosleep > 1) - hittype[g_i].timetosleep--; - else if (hittype[g_i].timetosleep == 1) + if (ActorExtra[g_i].timetosleep > 1) + ActorExtra[g_i].timetosleep--; + else if (ActorExtra[g_i].timetosleep == 1) changespritestat(g_i,2); default: return; @@ -4311,20 +4309,20 @@ void execute(int iActor,int iPlayer,int lDist) if (g_sp->statnum != 1) return; - if (badguy(g_sp)) + if (A_CheckEnemySprite(g_sp)) { if (g_sp->xrepeat > 60) return; if (ud.respawn_monsters == 1 && g_sp->extra <= 0) return; } else if (ud.respawn_items == 1 && (g_sp->cstat&32768)) return; - if (hittype[g_i].timetosleep > 1) - hittype[g_i].timetosleep--; - else if (hittype[g_i].timetosleep == 1) + if (ActorExtra[g_i].timetosleep > 1) + ActorExtra[g_i].timetosleep--; + else if (ActorExtra[g_i].timetosleep == 1) changespritestat(g_i,2); } -void savemapstate(mapstate_t *save) +void G_SaveMapState(mapstate_t *save) { if (save != NULL) { @@ -4340,9 +4338,9 @@ void savemapstate(mapstate_t *save) Bmemcpy(&save->headspritesect[0],&headspritesect[0],sizeof(headspritesect)); Bmemcpy(&save->prevspritesect[0],&prevspritesect[0],sizeof(prevspritesect)); Bmemcpy(&save->nextspritesect[0],&nextspritesect[0],sizeof(nextspritesect)); - Bmemcpy(&save->headspritestat[0],&headspritestat[0],sizeof(headspritestat)); - Bmemcpy(&save->prevspritestat[0],&prevspritestat[0],sizeof(prevspritestat)); - Bmemcpy(&save->nextspritestat[0],&nextspritestat[0],sizeof(nextspritestat)); + Bmemcpy(&save->headspritestat[STAT_DEFAULT],&headspritestat[STAT_DEFAULT],sizeof(headspritestat)); + Bmemcpy(&save->prevspritestat[STAT_DEFAULT],&prevspritestat[STAT_DEFAULT],sizeof(prevspritestat)); + Bmemcpy(&save->nextspritestat[STAT_DEFAULT],&nextspritestat[STAT_DEFAULT],sizeof(nextspritestat)); for (i=MAXSPRITES-1;i>=0;i--) { @@ -4352,24 +4350,24 @@ void savemapstate(mapstate_t *save) j = (intptr_t)&script[0]; - if (T2 >= j && T2 < (intptr_t)(&script[g_ScriptSize])) + if (T2 >= j && T2 < (intptr_t)(&script[g_scriptSize])) { save->scriptptrs[i] |= 1; T2 -= j; } - if (T5 >= j && T5 < (intptr_t)(&script[g_ScriptSize])) + if (T5 >= j && T5 < (intptr_t)(&script[g_scriptSize])) { save->scriptptrs[i] |= 2; T5 -= j; } - if (T6 >= j && T6 < (intptr_t)(&script[g_ScriptSize])) + if (T6 >= j && T6 < (intptr_t)(&script[g_scriptSize])) { save->scriptptrs[i] |= 4; T6 -= j; } } - Bmemcpy(&save->hittype[0],&hittype[0],sizeof(actordata_t)*MAXSPRITES); + Bmemcpy(&save->ActorExtra[0],&ActorExtra[0],sizeof(actordata_t)*MAXSPRITES); for (i=MAXSPRITES-1;i>=0;i--) { @@ -4384,20 +4382,20 @@ void savemapstate(mapstate_t *save) T6 += j; } - Bmemcpy(&save->numcyclers,&numcyclers,sizeof(numcyclers)); + Bmemcpy(&save->g_numCyclers,&g_numCyclers,sizeof(g_numCyclers)); Bmemcpy(&save->cyclers[0][0],&cyclers[0][0],sizeof(cyclers)); - Bmemcpy(&save->g_PlayerSpawnPoints[0],&g_PlayerSpawnPoints[0],sizeof(g_PlayerSpawnPoints)); - Bmemcpy(&save->numanimwalls,&numanimwalls,sizeof(numanimwalls)); - Bmemcpy(&save->spriteq[0],&spriteq[0],sizeof(spriteq)); - Bmemcpy(&save->spriteqloc,&spriteqloc,sizeof(spriteqloc)); + Bmemcpy(&save->g_playerSpawnPoints[0],&g_playerSpawnPoints[0],sizeof(g_playerSpawnPoints)); + Bmemcpy(&save->g_numAnimWalls,&g_numAnimWalls,sizeof(g_numAnimWalls)); + Bmemcpy(&save->SpriteDeletionQueue[0],&SpriteDeletionQueue[0],sizeof(SpriteDeletionQueue)); + Bmemcpy(&save->g_spriteDeleteQueuePos,&g_spriteDeleteQueuePos,sizeof(g_spriteDeleteQueuePos)); Bmemcpy(&save->animwall[0],&animwall[0],sizeof(animwall)); Bmemcpy(&save->msx[0],&msx[0],sizeof(msx)); Bmemcpy(&save->msy[0],&msy[0],sizeof(msy)); - Bmemcpy(&save->mirrorwall[0],&mirrorwall[0],sizeof(mirrorwall)); - Bmemcpy(&save->mirrorsector[0],&mirrorsector[0],sizeof(mirrorsector)); - Bmemcpy(&save->mirrorcnt,&mirrorcnt,sizeof(mirrorcnt)); + Bmemcpy(&save->g_mirrorWall[0],&g_mirrorWall[0],sizeof(g_mirrorWall)); + Bmemcpy(&save->g_mirrorSector[0],&g_mirrorSector[0],sizeof(g_mirrorSector)); + Bmemcpy(&save->g_mirrorCount,&g_mirrorCount,sizeof(g_mirrorCount)); Bmemcpy(&save->show2dsector[0],&show2dsector[0],sizeof(show2dsector)); - Bmemcpy(&save->numclouds,&numclouds,sizeof(numclouds)); + Bmemcpy(&save->g_numClouds,&g_numClouds,sizeof(g_numClouds)); Bmemcpy(&save->clouds[0],&clouds[0],sizeof(clouds)); Bmemcpy(&save->cloudx[0],&cloudx[0],sizeof(cloudx)); Bmemcpy(&save->cloudy[0],&cloudy[0],sizeof(cloudy)); @@ -4405,27 +4403,27 @@ void savemapstate(mapstate_t *save) Bmemcpy(&save->pskybits,&pskybits,sizeof(pskybits)); Bmemcpy(&save->animategoal[0],&animategoal[0],sizeof(animategoal)); Bmemcpy(&save->animatevel[0],&animatevel[0],sizeof(animatevel)); - Bmemcpy(&save->animatecnt,&animatecnt,sizeof(animatecnt)); + Bmemcpy(&save->g_animateCount,&g_animateCount,sizeof(g_animateCount)); Bmemcpy(&save->animatesect[0],&animatesect[0],sizeof(animatesect)); - for (i = animatecnt-1;i>=0;i--) animateptr[i] = (int *)((intptr_t)animateptr[i]-(intptr_t)(§or[0])); + for (i = g_animateCount-1;i>=0;i--) animateptr[i] = (int *)((intptr_t)animateptr[i]-(intptr_t)(§or[0])); Bmemcpy(&save->animateptr[0],&animateptr[0],sizeof(animateptr)); - for (i = animatecnt-1;i>=0;i--) animateptr[i] = (int *)((intptr_t)animateptr[i]+(intptr_t)(§or[0])); - Bmemcpy(&save->numplayersprites,&numplayersprites,sizeof(numplayersprites)); - Bmemcpy(&save->earthquaketime,&earthquaketime,sizeof(earthquaketime)); + for (i = g_animateCount-1;i>=0;i--) animateptr[i] = (int *)((intptr_t)animateptr[i]+(intptr_t)(§or[0])); + Bmemcpy(&save->g_numPlayerSprites,&g_numPlayerSprites,sizeof(g_numPlayerSprites)); + Bmemcpy(&save->g_earthquakeTime,&g_earthquakeTime,sizeof(g_earthquakeTime)); Bmemcpy(&save->lockclock,&lockclock,sizeof(lockclock)); Bmemcpy(&save->randomseed,&randomseed,sizeof(randomseed)); - Bmemcpy(&save->global_random,&global_random,sizeof(global_random)); + Bmemcpy(&save->g_globalRandom,&g_globalRandom,sizeof(g_globalRandom)); - for (i=iGameVarCount-1; i>=0;i--) + for (i=g_gameVarCount-1; i>=0;i--) { - if (aGameVars[i].dwFlags & GAMEVAR_FLAG_NORESET) continue; - if (aGameVars[i].dwFlags & GAMEVAR_FLAG_PERPLAYER) + if (aGameVars[i].dwFlags & GAMEVAR_NORESET) continue; + if (aGameVars[i].dwFlags & GAMEVAR_PERPLAYER) { if (!save->vars[i]) save->vars[i] = Bcalloc(MAXPLAYERS,sizeof(intptr_t)); Bmemcpy(&save->vars[i][0],&aGameVars[i].plValues[0],sizeof(intptr_t) * MAXPLAYERS); } - else if (aGameVars[i].dwFlags & GAMEVAR_FLAG_PERACTOR) + else if (aGameVars[i].dwFlags & GAMEVAR_PERACTOR) { if (!save->vars[i]) save->vars[i] = Bcalloc(MAXSPRITES,sizeof(intptr_t)); @@ -4438,9 +4436,9 @@ void savemapstate(mapstate_t *save) } } -extern void ResetPointerVars(void); +extern void Gv_RefreshPointers(void); -void restoremapstate(mapstate_t *save) +void G_RestoreMapState(mapstate_t *save) { if (save != NULL) { @@ -4453,7 +4451,7 @@ void restoremapstate(mapstate_t *save) pub = NUMPAGES; pus = NUMPAGES; - vscrn(); + G_UpdateScreenArea(); Bmemcpy(&numwalls,&save->numwalls,sizeof(numwalls)); Bmemcpy(&wall[0],&save->wall[0],sizeof(walltype)*MAXWALLS); @@ -4464,10 +4462,10 @@ void restoremapstate(mapstate_t *save) Bmemcpy(&headspritesect[0],&save->headspritesect[0],sizeof(headspritesect)); Bmemcpy(&prevspritesect[0],&save->prevspritesect[0],sizeof(prevspritesect)); Bmemcpy(&nextspritesect[0],&save->nextspritesect[0],sizeof(nextspritesect)); - Bmemcpy(&headspritestat[0],&save->headspritestat[0],sizeof(headspritestat)); - Bmemcpy(&prevspritestat[0],&save->prevspritestat[0],sizeof(prevspritestat)); - Bmemcpy(&nextspritestat[0],&save->nextspritestat[0],sizeof(nextspritestat)); - Bmemcpy(&hittype[0],&save->hittype[0],sizeof(actordata_t)*MAXSPRITES); + Bmemcpy(&headspritestat[STAT_DEFAULT],&save->headspritestat[STAT_DEFAULT],sizeof(headspritestat)); + Bmemcpy(&prevspritestat[STAT_DEFAULT],&save->prevspritestat[STAT_DEFAULT],sizeof(prevspritestat)); + Bmemcpy(&nextspritestat[STAT_DEFAULT],&save->nextspritestat[STAT_DEFAULT],sizeof(nextspritestat)); + Bmemcpy(&ActorExtra[0],&save->ActorExtra[0],sizeof(actordata_t)*MAXSPRITES); for (i=MAXSPRITES-1;i>=0;i--) { @@ -4477,20 +4475,20 @@ void restoremapstate(mapstate_t *save) if (save->scriptptrs[i]&4) T6 += j; } - Bmemcpy(&numcyclers,&save->numcyclers,sizeof(numcyclers)); + Bmemcpy(&g_numCyclers,&save->g_numCyclers,sizeof(g_numCyclers)); Bmemcpy(&cyclers[0][0],&save->cyclers[0][0],sizeof(cyclers)); - Bmemcpy(&g_PlayerSpawnPoints[0],&save->g_PlayerSpawnPoints[0],sizeof(g_PlayerSpawnPoints)); - Bmemcpy(&numanimwalls,&save->numanimwalls,sizeof(numanimwalls)); - Bmemcpy(&spriteq[0],&save->spriteq[0],sizeof(spriteq)); - Bmemcpy(&spriteqloc,&save->spriteqloc,sizeof(spriteqloc)); + Bmemcpy(&g_playerSpawnPoints[0],&save->g_playerSpawnPoints[0],sizeof(g_playerSpawnPoints)); + Bmemcpy(&g_numAnimWalls,&save->g_numAnimWalls,sizeof(g_numAnimWalls)); + Bmemcpy(&SpriteDeletionQueue[0],&save->SpriteDeletionQueue[0],sizeof(SpriteDeletionQueue)); + Bmemcpy(&g_spriteDeleteQueuePos,&save->g_spriteDeleteQueuePos,sizeof(g_spriteDeleteQueuePos)); Bmemcpy(&animwall[0],&save->animwall[0],sizeof(animwall)); Bmemcpy(&msx[0],&save->msx[0],sizeof(msx)); Bmemcpy(&msy[0],&save->msy[0],sizeof(msy)); - Bmemcpy(&mirrorwall[0],&save->mirrorwall[0],sizeof(mirrorwall)); - Bmemcpy(&mirrorsector[0],&save->mirrorsector[0],sizeof(mirrorsector)); - Bmemcpy(&mirrorcnt,&save->mirrorcnt,sizeof(mirrorcnt)); + Bmemcpy(&g_mirrorWall[0],&save->g_mirrorWall[0],sizeof(g_mirrorWall)); + Bmemcpy(&g_mirrorSector[0],&save->g_mirrorSector[0],sizeof(g_mirrorSector)); + Bmemcpy(&g_mirrorCount,&save->g_mirrorCount,sizeof(g_mirrorCount)); Bmemcpy(&show2dsector[0],&save->show2dsector[0],sizeof(show2dsector)); - Bmemcpy(&numclouds,&save->numclouds,sizeof(numclouds)); + Bmemcpy(&g_numClouds,&save->g_numClouds,sizeof(g_numClouds)); Bmemcpy(&clouds[0],&save->clouds[0],sizeof(clouds)); Bmemcpy(&cloudx[0],&save->cloudx[0],sizeof(cloudx)); Bmemcpy(&cloudy[0],&save->cloudy[0],sizeof(cloudy)); @@ -4498,35 +4496,35 @@ void restoremapstate(mapstate_t *save) Bmemcpy(&pskybits,&save->pskybits,sizeof(pskybits)); Bmemcpy(&animategoal[0],&save->animategoal[0],sizeof(animategoal)); Bmemcpy(&animatevel[0],&save->animatevel[0],sizeof(animatevel)); - Bmemcpy(&animatecnt,&save->animatecnt,sizeof(animatecnt)); + Bmemcpy(&g_animateCount,&save->g_animateCount,sizeof(g_animateCount)); Bmemcpy(&animatesect[0],&save->animatesect[0],sizeof(animatesect)); Bmemcpy(&animateptr[0],&save->animateptr[0],sizeof(animateptr)); - for (i = animatecnt-1;i>=0;i--) animateptr[i] = (int *)((intptr_t)animateptr[i]+(intptr_t)(§or[0])); - Bmemcpy(&numplayersprites,&save->numplayersprites,sizeof(numplayersprites)); - Bmemcpy(&earthquaketime,&save->earthquaketime,sizeof(earthquaketime)); + for (i = g_animateCount-1;i>=0;i--) animateptr[i] = (int *)((intptr_t)animateptr[i]+(intptr_t)(§or[0])); + Bmemcpy(&g_numPlayerSprites,&save->g_numPlayerSprites,sizeof(g_numPlayerSprites)); + Bmemcpy(&g_earthquakeTime,&save->g_earthquakeTime,sizeof(g_earthquakeTime)); Bmemcpy(&lockclock,&save->lockclock,sizeof(lockclock)); Bmemcpy(&randomseed,&save->randomseed,sizeof(randomseed)); - Bmemcpy(&global_random,&save->global_random,sizeof(global_random)); + Bmemcpy(&g_globalRandom,&save->g_globalRandom,sizeof(g_globalRandom)); - for (i=iGameVarCount-1;i>=0;i--) + for (i=g_gameVarCount-1;i>=0;i--) { - if (aGameVars[i].dwFlags & GAMEVAR_FLAG_NORESET) continue; - if (aGameVars[i].dwFlags & GAMEVAR_FLAG_PERPLAYER) + if (aGameVars[i].dwFlags & GAMEVAR_NORESET) continue; + if (aGameVars[i].dwFlags & GAMEVAR_PERPLAYER) Bmemcpy(&aGameVars[i].plValues[0],&save->vars[i][0],sizeof(intptr_t) * MAXPLAYERS); - else if (aGameVars[i].dwFlags & GAMEVAR_FLAG_PERACTOR) + else if (aGameVars[i].dwFlags & GAMEVAR_PERACTOR) Bmemcpy(&aGameVars[i].plValues[0],&save->vars[i][0],sizeof(intptr_t) * MAXSPRITES); else aGameVars[i].lValue = (intptr_t)save->vars[i]; } - ResetPointerVars(); + Gv_RefreshPointers(); for (i=0;ii].extra = phealth[i]; if (g_player[myconnectindex].ps->over_shoulder_on != 0) { - cameradist = 0; - cameraclock = 0; + g_cameraDistance = 0; + g_cameraClock = 0; g_player[myconnectindex].ps->over_shoulder_on = 1; } @@ -4534,14 +4532,14 @@ void restoremapstate(mapstate_t *save) if (ud.lockout == 0) { - for (x=numanimwalls-1;x>=0;x--) + for (x=g_numAnimWalls-1;x>=0;x--) if (wall[animwall[x].wallnum].extra >= 0) wall[animwall[x].wallnum].picnum = wall[animwall[x].wallnum].extra; } else { - for (x=numanimwalls-1;x>=0;x--) - switch (dynamictostatic[wall[animwall[x].wallnum].picnum]) + for (x=g_numAnimWalls-1;x>=0;x--) + switch (DynamicTileMap[wall[animwall[x].wallnum].picnum]) { case FEMPIC1__STATIC: wall[animwall[x].wallnum].picnum = BLANKSCREEN; @@ -4553,27 +4551,27 @@ void restoremapstate(mapstate_t *save) } } - numinterpolations = 0; + g_numInterpolations = 0; startofdynamicinterpolations = 0; - k = headspritestat[3]; + k = headspritestat[STAT_EFFECTOR]; while (k >= 0) { switch (sprite[k].lotag) { case 31: - setinterpolation(§or[sprite[k].sectnum].floorz); + G_SetInterpolation(§or[sprite[k].sectnum].floorz); break; case 32: - setinterpolation(§or[sprite[k].sectnum].ceilingz); + G_SetInterpolation(§or[sprite[k].sectnum].ceilingz); break; case 25: - setinterpolation(§or[sprite[k].sectnum].floorz); - setinterpolation(§or[sprite[k].sectnum].ceilingz); + G_SetInterpolation(§or[sprite[k].sectnum].floorz); + G_SetInterpolation(§or[sprite[k].sectnum].ceilingz); break; case 17: - setinterpolation(§or[sprite[k].sectnum].floorz); - setinterpolation(§or[sprite[k].sectnum].ceilingz); + G_SetInterpolation(§or[sprite[k].sectnum].floorz); + G_SetInterpolation(§or[sprite[k].sectnum].ceilingz); break; case 0: case 5: @@ -4584,22 +4582,22 @@ void restoremapstate(mapstate_t *save) case 16: case 26: case 30: - setsectinterpolate(k); + Sect_SetInterpolation(k); break; } k = nextspritestat[k]; } - for (i=numinterpolations-1;i>=0;i--) bakipos[i] = *curipos[i]; - for (i = animatecnt-1;i>=0;i--) - setinterpolation(animateptr[i]); + for (i=g_numInterpolations-1;i>=0;i--) bakipos[i] = *curipos[i]; + for (i = g_animateCount-1;i>=0;i--) + G_SetInterpolation(animateptr[i]); - resetmys(); + Net_ResetPrediction(); + waitforeverybody(); flushpackets(); clearfifo(); - waitforeverybody(); - resettimevars(); + G_ResetTimers(); } } diff --git a/polymer/eduke32/source/gamestructures.c b/polymer/eduke32/source/gamestructures.c index 476b1a937..e54722ae5 100644 --- a/polymer/eduke32/source/gamestructures.c +++ b/polymer/eduke32/source/gamestructures.c @@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // this is all the crap for accessing the game's structs through the CON VM -void DoUserDef(int iSet, int lLabelID, int lVar2) +void X_AccessUserdef(int iSet, int lLabelID, int lVar2) { int lValue=0; @@ -41,7 +41,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) } if (iSet) - lValue=GetGameVarID(lVar2, g_i, g_p); + lValue=Gv_GetVar(lVar2, g_i, g_p); switch (lLabelID) { @@ -51,7 +51,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.god = lValue; return; } - SetGameVarID(lVar2, ud.god, g_i, g_p); + Gv_SetVar(lVar2, ud.god, g_i, g_p); return; case USERDEFS_WARP_ON: @@ -60,7 +60,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.warp_on = lValue; return; } - SetGameVarID(lVar2, ud.warp_on, g_i, g_p); + Gv_SetVar(lVar2, ud.warp_on, g_i, g_p); return; case USERDEFS_CASHMAN: @@ -69,7 +69,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.cashman = lValue; return; } - SetGameVarID(lVar2, ud.cashman, g_i, g_p); + Gv_SetVar(lVar2, ud.cashman, g_i, g_p); return; case USERDEFS_EOG: @@ -78,7 +78,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.eog = lValue; return; } - SetGameVarID(lVar2, ud.eog, g_i, g_p); + Gv_SetVar(lVar2, ud.eog, g_i, g_p); return; case USERDEFS_SHOWALLMAP: @@ -87,7 +87,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.showallmap = lValue; return; } - SetGameVarID(lVar2, ud.showallmap, g_i, g_p); + Gv_SetVar(lVar2, ud.showallmap, g_i, g_p); return; case USERDEFS_SHOW_HELP: @@ -96,7 +96,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.show_help = lValue; return; } - SetGameVarID(lVar2, ud.show_help, g_i, g_p); + Gv_SetVar(lVar2, ud.show_help, g_i, g_p); return; case USERDEFS_SCROLLMODE: @@ -105,7 +105,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.scrollmode = lValue; return; } - SetGameVarID(lVar2, ud.scrollmode, g_i, g_p); + Gv_SetVar(lVar2, ud.scrollmode, g_i, g_p); return; case USERDEFS_CLIPPING: @@ -114,7 +114,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.clipping = lValue; return; } - SetGameVarID(lVar2, ud.clipping, g_i, g_p); + Gv_SetVar(lVar2, ud.clipping, g_i, g_p); return; // case USERDEFS_USER_NAME: @@ -123,7 +123,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) // ud.user_name[MAXPLAYERS][32] = lValue; // return; // } - // SetGameVarID(lVar2, ud.user_name[MAXPLAYERS][32], g_i, g_p); + // Gv_SetVar(lVar2, ud.user_name[MAXPLAYERS][32], g_i, g_p); // return; // case USERDEFS_RIDECULE: @@ -132,7 +132,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) // ud.ridecule = lValue; // return; // } - // SetGameVarID(lVar2, ud.ridecule, g_i, g_p); + // Gv_SetVar(lVar2, ud.ridecule, g_i, g_p); // return; // case USERDEFS_SAVEGAME: @@ -141,7 +141,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) // ud.savegame = lValue; // return; // } - // SetGameVarID(lVar2, ud.savegame, g_i, g_p); + // Gv_SetVar(lVar2, ud.savegame, g_i, g_p); // return; // case USERDEFS_PWLOCKOUT: @@ -150,7 +150,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) // ud.pwlockout = lValue; // return; // } - // SetGameVarID(lVar2, ud.pwlockout, g_i, g_p); + // Gv_SetVar(lVar2, ud.pwlockout, g_i, g_p); // return; // case USERDEFS_RTSNAME: @@ -159,7 +159,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) // ud.rtsname = lValue; // return; // } - // SetGameVarID(lVar2, ud.rtsname, g_i, g_p); + // Gv_SetVar(lVar2, ud.rtsname, g_i, g_p); // return; case USERDEFS_OVERHEAD_ON: @@ -168,7 +168,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.overhead_on = lValue; return; } - SetGameVarID(lVar2, ud.overhead_on, g_i, g_p); + Gv_SetVar(lVar2, ud.overhead_on, g_i, g_p); return; case USERDEFS_LAST_OVERHEAD: @@ -177,7 +177,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.last_overhead = lValue; return; } - SetGameVarID(lVar2, ud.last_overhead, g_i, g_p); + Gv_SetVar(lVar2, ud.last_overhead, g_i, g_p); return; case USERDEFS_SHOWWEAPONS: @@ -186,7 +186,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.showweapons = lValue; return; } - SetGameVarID(lVar2, ud.showweapons, g_i, g_p); + Gv_SetVar(lVar2, ud.showweapons, g_i, g_p); return; case USERDEFS_PAUSE_ON: @@ -195,7 +195,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.pause_on = lValue; return; } - SetGameVarID(lVar2, ud.pause_on, g_i, g_p); + Gv_SetVar(lVar2, ud.pause_on, g_i, g_p); return; case USERDEFS_FROM_BONUS: @@ -204,7 +204,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.from_bonus = lValue; return; } - SetGameVarID(lVar2, ud.from_bonus, g_i, g_p); + Gv_SetVar(lVar2, ud.from_bonus, g_i, g_p); return; case USERDEFS_CAMERASPRITE: @@ -213,7 +213,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.camerasprite = lValue; return; } - SetGameVarID(lVar2, ud.camerasprite, g_i, g_p); + Gv_SetVar(lVar2, ud.camerasprite, g_i, g_p); return; case USERDEFS_LAST_CAMSPRITE: @@ -222,7 +222,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.last_camsprite = lValue; return; } - SetGameVarID(lVar2, ud.last_camsprite, g_i, g_p); + Gv_SetVar(lVar2, ud.last_camsprite, g_i, g_p); return; case USERDEFS_LAST_LEVEL: @@ -231,7 +231,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.last_level = lValue; return; } - SetGameVarID(lVar2, ud.last_level, g_i, g_p); + Gv_SetVar(lVar2, ud.last_level, g_i, g_p); return; case USERDEFS_SECRETLEVEL: @@ -240,7 +240,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.secretlevel = lValue; return; } - SetGameVarID(lVar2, ud.secretlevel, g_i, g_p); + Gv_SetVar(lVar2, ud.secretlevel, g_i, g_p); return; case USERDEFS_CONST_VISIBILITY: @@ -249,7 +249,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.const_visibility = lValue; return; } - SetGameVarID(lVar2, ud.const_visibility, g_i, g_p); + Gv_SetVar(lVar2, ud.const_visibility, g_i, g_p); return; case USERDEFS_UW_FRAMERATE: @@ -258,7 +258,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.uw_framerate = lValue; return; } - SetGameVarID(lVar2, ud.uw_framerate, g_i, g_p); + Gv_SetVar(lVar2, ud.uw_framerate, g_i, g_p); return; case USERDEFS_CAMERA_TIME: @@ -267,7 +267,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.camera_time = lValue; return; } - SetGameVarID(lVar2, ud.camera_time, g_i, g_p); + Gv_SetVar(lVar2, ud.camera_time, g_i, g_p); return; case USERDEFS_FOLFVEL: @@ -276,7 +276,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.folfvel = lValue; return; } - SetGameVarID(lVar2, ud.folfvel, g_i, g_p); + Gv_SetVar(lVar2, ud.folfvel, g_i, g_p); return; case USERDEFS_FOLAVEL: @@ -285,7 +285,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.folavel = lValue; return; } - SetGameVarID(lVar2, ud.folavel, g_i, g_p); + Gv_SetVar(lVar2, ud.folavel, g_i, g_p); return; case USERDEFS_FOLX: @@ -294,7 +294,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.folx = lValue; return; } - SetGameVarID(lVar2, ud.folx, g_i, g_p); + Gv_SetVar(lVar2, ud.folx, g_i, g_p); return; case USERDEFS_FOLY: @@ -303,7 +303,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.foly = lValue; return; } - SetGameVarID(lVar2, ud.foly, g_i, g_p); + Gv_SetVar(lVar2, ud.foly, g_i, g_p); return; case USERDEFS_FOLA: @@ -312,7 +312,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.fola = lValue; return; } - SetGameVarID(lVar2, ud.fola, g_i, g_p); + Gv_SetVar(lVar2, ud.fola, g_i, g_p); return; case USERDEFS_RECCNT: @@ -321,7 +321,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.reccnt = lValue; return; } - SetGameVarID(lVar2, ud.reccnt, g_i, g_p); + Gv_SetVar(lVar2, ud.reccnt, g_i, g_p); return; case USERDEFS_ENTERED_NAME: @@ -330,7 +330,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.entered_name = lValue; return; } - SetGameVarID(lVar2, ud.entered_name, g_i, g_p); + Gv_SetVar(lVar2, ud.entered_name, g_i, g_p); return; case USERDEFS_SCREEN_TILTING: @@ -339,7 +339,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.screen_tilting = lValue; return; } - SetGameVarID(lVar2, ud.screen_tilting, g_i, g_p); + Gv_SetVar(lVar2, ud.screen_tilting, g_i, g_p); return; case USERDEFS_SHADOWS: @@ -348,7 +348,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.shadows = lValue; return; } - SetGameVarID(lVar2, ud.shadows, g_i, g_p); + Gv_SetVar(lVar2, ud.shadows, g_i, g_p); return; case USERDEFS_FTA_ON: @@ -357,7 +357,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.fta_on = lValue; return; } - SetGameVarID(lVar2, ud.fta_on, g_i, g_p); + Gv_SetVar(lVar2, ud.fta_on, g_i, g_p); return; case USERDEFS_EXECUTIONS: @@ -366,7 +366,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.executions = lValue; return; } - SetGameVarID(lVar2, ud.executions, g_i, g_p); + Gv_SetVar(lVar2, ud.executions, g_i, g_p); return; case USERDEFS_AUTO_RUN: @@ -375,7 +375,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.auto_run = lValue; return; } - SetGameVarID(lVar2, ud.auto_run, g_i, g_p); + Gv_SetVar(lVar2, ud.auto_run, g_i, g_p); return; case USERDEFS_COORDS: @@ -384,7 +384,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.coords = lValue; return; } - SetGameVarID(lVar2, ud.coords, g_i, g_p); + Gv_SetVar(lVar2, ud.coords, g_i, g_p); return; case USERDEFS_TICKRATE: @@ -393,7 +393,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.tickrate = lValue; return; } - SetGameVarID(lVar2, ud.tickrate, g_i, g_p); + Gv_SetVar(lVar2, ud.tickrate, g_i, g_p); return; case USERDEFS_M_COOP: @@ -402,7 +402,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.m_coop = lValue; return; } - SetGameVarID(lVar2, ud.m_coop, g_i, g_p); + Gv_SetVar(lVar2, ud.m_coop, g_i, g_p); return; case USERDEFS_COOP: @@ -411,7 +411,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.coop = lValue; return; } - SetGameVarID(lVar2, ud.coop, g_i, g_p); + Gv_SetVar(lVar2, ud.coop, g_i, g_p); return; case USERDEFS_SCREEN_SIZE: @@ -420,11 +420,11 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) if (ud.screen_size != lValue) { ud.screen_size = lValue; - vscrn(); + G_UpdateScreenArea(); } return; } - SetGameVarID(lVar2, ud.screen_size, g_i, g_p); + Gv_SetVar(lVar2, ud.screen_size, g_i, g_p); return; case USERDEFS_LOCKOUT: @@ -433,7 +433,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.lockout = lValue; return; } - SetGameVarID(lVar2, ud.lockout, g_i, g_p); + Gv_SetVar(lVar2, ud.lockout, g_i, g_p); return; case USERDEFS_CROSSHAIR: @@ -442,7 +442,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.crosshair = lValue; return; } - SetGameVarID(lVar2, ud.crosshair, g_i, g_p); + Gv_SetVar(lVar2, ud.crosshair, g_i, g_p); return; // case USERDEFS_WCHOICE: @@ -451,7 +451,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) // ud.wchoice = lValue; // return; // } - // SetGameVarID(lVar2, ud.wchoice, g_i, g_p); + // Gv_SetVar(lVar2, ud.wchoice, g_i, g_p); // return; case USERDEFS_PLAYERAI: @@ -460,7 +460,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.playerai = lValue; return; } - SetGameVarID(lVar2, ud.playerai, g_i, g_p); + Gv_SetVar(lVar2, ud.playerai, g_i, g_p); return; case USERDEFS_RESPAWN_MONSTERS: @@ -469,7 +469,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.respawn_monsters = lValue; return; } - SetGameVarID(lVar2, ud.respawn_monsters, g_i, g_p); + Gv_SetVar(lVar2, ud.respawn_monsters, g_i, g_p); return; case USERDEFS_RESPAWN_ITEMS: @@ -478,7 +478,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.respawn_items = lValue; return; } - SetGameVarID(lVar2, ud.respawn_items, g_i, g_p); + Gv_SetVar(lVar2, ud.respawn_items, g_i, g_p); return; case USERDEFS_RESPAWN_INVENTORY: @@ -487,7 +487,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.respawn_inventory = lValue; return; } - SetGameVarID(lVar2, ud.respawn_inventory, g_i, g_p); + Gv_SetVar(lVar2, ud.respawn_inventory, g_i, g_p); return; case USERDEFS_RECSTAT: @@ -496,7 +496,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.recstat = lValue; return; } - SetGameVarID(lVar2, ud.recstat, g_i, g_p); + Gv_SetVar(lVar2, ud.recstat, g_i, g_p); return; case USERDEFS_MONSTERS_OFF: @@ -505,7 +505,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.monsters_off = lValue; return; } - SetGameVarID(lVar2, ud.monsters_off, g_i, g_p); + Gv_SetVar(lVar2, ud.monsters_off, g_i, g_p); return; case USERDEFS_BRIGHTNESS: @@ -514,7 +514,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.brightness = lValue; return; } - SetGameVarID(lVar2, ud.brightness, g_i, g_p); + Gv_SetVar(lVar2, ud.brightness, g_i, g_p); return; case USERDEFS_M_RESPAWN_ITEMS: @@ -523,7 +523,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.m_respawn_items = lValue; return; } - SetGameVarID(lVar2, ud.m_respawn_items, g_i, g_p); + Gv_SetVar(lVar2, ud.m_respawn_items, g_i, g_p); return; case USERDEFS_M_RESPAWN_MONSTERS: @@ -532,7 +532,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.m_respawn_monsters = lValue; return; } - SetGameVarID(lVar2, ud.m_respawn_monsters, g_i, g_p); + Gv_SetVar(lVar2, ud.m_respawn_monsters, g_i, g_p); return; case USERDEFS_M_RESPAWN_INVENTORY: @@ -541,7 +541,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.m_respawn_inventory = lValue; return; } - SetGameVarID(lVar2, ud.m_respawn_inventory, g_i, g_p); + Gv_SetVar(lVar2, ud.m_respawn_inventory, g_i, g_p); return; case USERDEFS_M_RECSTAT: @@ -550,7 +550,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.m_recstat = lValue; return; } - SetGameVarID(lVar2, ud.m_recstat, g_i, g_p); + Gv_SetVar(lVar2, ud.m_recstat, g_i, g_p); return; case USERDEFS_M_MONSTERS_OFF: @@ -559,7 +559,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.m_monsters_off = lValue; return; } - SetGameVarID(lVar2, ud.m_monsters_off, g_i, g_p); + Gv_SetVar(lVar2, ud.m_monsters_off, g_i, g_p); return; case USERDEFS_DETAIL: @@ -568,7 +568,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.detail = lValue; return; } - SetGameVarID(lVar2, ud.detail, g_i, g_p); + Gv_SetVar(lVar2, ud.detail, g_i, g_p); return; case USERDEFS_M_FFIRE: @@ -577,7 +577,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.m_ffire = lValue; return; } - SetGameVarID(lVar2, ud.m_ffire, g_i, g_p); + Gv_SetVar(lVar2, ud.m_ffire, g_i, g_p); return; case USERDEFS_FFIRE: @@ -586,7 +586,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.ffire = lValue; return; } - SetGameVarID(lVar2, ud.ffire, g_i, g_p); + Gv_SetVar(lVar2, ud.ffire, g_i, g_p); return; case USERDEFS_M_PLAYER_SKILL: @@ -595,7 +595,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.m_player_skill = lValue; return; } - SetGameVarID(lVar2, ud.m_player_skill, g_i, g_p); + Gv_SetVar(lVar2, ud.m_player_skill, g_i, g_p); return; case USERDEFS_M_LEVEL_NUMBER: @@ -604,7 +604,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.m_level_number = lValue; return; } - SetGameVarID(lVar2, ud.m_level_number, g_i, g_p); + Gv_SetVar(lVar2, ud.m_level_number, g_i, g_p); return; case USERDEFS_M_VOLUME_NUMBER: @@ -613,7 +613,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.m_volume_number = lValue; return; } - SetGameVarID(lVar2, ud.m_volume_number, g_i, g_p); + Gv_SetVar(lVar2, ud.m_volume_number, g_i, g_p); return; case USERDEFS_MULTIMODE: @@ -622,7 +622,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.multimode = lValue; return; } - SetGameVarID(lVar2, ud.multimode, g_i, g_p); + Gv_SetVar(lVar2, ud.multimode, g_i, g_p); return; case USERDEFS_PLAYER_SKILL: @@ -631,7 +631,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.player_skill = lValue; return; } - SetGameVarID(lVar2, ud.player_skill, g_i, g_p); + Gv_SetVar(lVar2, ud.player_skill, g_i, g_p); return; case USERDEFS_LEVEL_NUMBER: @@ -640,7 +640,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.level_number = lValue; return; } - SetGameVarID(lVar2, ud.level_number, g_i, g_p); + Gv_SetVar(lVar2, ud.level_number, g_i, g_p); return; case USERDEFS_VOLUME_NUMBER: @@ -649,7 +649,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.volume_number = lValue; return; } - SetGameVarID(lVar2, ud.volume_number, g_i, g_p); + Gv_SetVar(lVar2, ud.volume_number, g_i, g_p); return; case USERDEFS_M_MARKER: @@ -658,7 +658,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.m_marker = lValue; return; } - SetGameVarID(lVar2, ud.m_marker, g_i, g_p); + Gv_SetVar(lVar2, ud.m_marker, g_i, g_p); return; case USERDEFS_MARKER: @@ -667,7 +667,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.marker = lValue; return; } - SetGameVarID(lVar2, ud.marker, g_i, g_p); + Gv_SetVar(lVar2, ud.marker, g_i, g_p); return; case USERDEFS_MOUSEFLIP: @@ -676,7 +676,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.mouseflip = lValue; return; } - SetGameVarID(lVar2, ud.mouseflip, g_i, g_p); + Gv_SetVar(lVar2, ud.mouseflip, g_i, g_p); return; case USERDEFS_STATUSBARSCALE: @@ -685,7 +685,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.statusbarscale = lValue; return; } - SetGameVarID(lVar2, ud.statusbarscale, g_i, g_p); + Gv_SetVar(lVar2, ud.statusbarscale, g_i, g_p); return; case USERDEFS_DRAWWEAPON: @@ -694,7 +694,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.drawweapon = lValue; return; } - SetGameVarID(lVar2, ud.drawweapon, g_i, g_p); + Gv_SetVar(lVar2, ud.drawweapon, g_i, g_p); return; case USERDEFS_MOUSEAIMING: @@ -703,7 +703,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.mouseaiming = lValue; return; } - SetGameVarID(lVar2, ud.mouseaiming, g_i, g_p); + Gv_SetVar(lVar2, ud.mouseaiming, g_i, g_p); return; case USERDEFS_WEAPONSWITCH: @@ -712,7 +712,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.weaponswitch = lValue; return; } - SetGameVarID(lVar2, ud.weaponswitch, g_i, g_p); + Gv_SetVar(lVar2, ud.weaponswitch, g_i, g_p); return; case USERDEFS_DEMOCAMS: @@ -721,7 +721,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.democams = lValue; return; } - SetGameVarID(lVar2, ud.democams, g_i, g_p); + Gv_SetVar(lVar2, ud.democams, g_i, g_p); return; case USERDEFS_COLOR: @@ -730,7 +730,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.color = lValue; return; } - SetGameVarID(lVar2, ud.color, g_i, g_p); + Gv_SetVar(lVar2, ud.color, g_i, g_p); return; case USERDEFS_MSGDISPTIME: @@ -739,7 +739,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.msgdisptime = lValue; return; } - SetGameVarID(lVar2, ud.msgdisptime, g_i, g_p); + Gv_SetVar(lVar2, ud.msgdisptime, g_i, g_p); return; case USERDEFS_STATUSBARMODE: @@ -748,7 +748,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.statusbarmode = lValue; return; } - SetGameVarID(lVar2, ud.statusbarmode, g_i, g_p); + Gv_SetVar(lVar2, ud.statusbarmode, g_i, g_p); return; case USERDEFS_M_NOEXITS: @@ -757,7 +757,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.m_noexits = lValue; return; } - SetGameVarID(lVar2, ud.m_noexits, g_i, g_p); + Gv_SetVar(lVar2, ud.m_noexits, g_i, g_p); return; case USERDEFS_NOEXITS: @@ -766,7 +766,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.noexits = lValue; return; } - SetGameVarID(lVar2, ud.noexits, g_i, g_p); + Gv_SetVar(lVar2, ud.noexits, g_i, g_p); return; case USERDEFS_AUTOVOTE: @@ -775,7 +775,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.autovote = lValue; return; } - SetGameVarID(lVar2, ud.autovote, g_i, g_p); + Gv_SetVar(lVar2, ud.autovote, g_i, g_p); return; case USERDEFS_AUTOMSG: @@ -784,7 +784,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.automsg = lValue; return; } - SetGameVarID(lVar2, ud.automsg, g_i, g_p); + Gv_SetVar(lVar2, ud.automsg, g_i, g_p); return; case USERDEFS_IDPLAYERS: @@ -793,7 +793,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.idplayers = lValue; return; } - SetGameVarID(lVar2, ud.idplayers, g_i, g_p); + Gv_SetVar(lVar2, ud.idplayers, g_i, g_p); return; case USERDEFS_TEAM: @@ -802,7 +802,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.team = lValue; return; } - SetGameVarID(lVar2, ud.team, g_i, g_p); + Gv_SetVar(lVar2, ud.team, g_i, g_p); return; case USERDEFS_VIEWBOB: @@ -811,7 +811,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.viewbob = lValue; return; } - SetGameVarID(lVar2, ud.viewbob, g_i, g_p); + Gv_SetVar(lVar2, ud.viewbob, g_i, g_p); return; case USERDEFS_WEAPONSWAY: @@ -820,7 +820,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.weaponsway = lValue; return; } - SetGameVarID(lVar2, ud.weaponsway, g_i, g_p); + Gv_SetVar(lVar2, ud.weaponsway, g_i, g_p); return; case USERDEFS_ANGLEINTERPOLATION: @@ -829,7 +829,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.angleinterpolation = lValue; return; } - SetGameVarID(lVar2, ud.angleinterpolation, g_i, g_p); + Gv_SetVar(lVar2, ud.angleinterpolation, g_i, g_p); return; case USERDEFS_OBITUARIES: @@ -838,7 +838,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.obituaries = lValue; return; } - SetGameVarID(lVar2, ud.obituaries, g_i, g_p); + Gv_SetVar(lVar2, ud.obituaries, g_i, g_p); return; case USERDEFS_LEVELSTATS: @@ -847,7 +847,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.levelstats = lValue; return; } - SetGameVarID(lVar2, ud.levelstats, g_i, g_p); + Gv_SetVar(lVar2, ud.levelstats, g_i, g_p); return; case USERDEFS_CROSSHAIRSCALE: @@ -856,7 +856,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.crosshairscale = lValue; return; } - SetGameVarID(lVar2, ud.crosshairscale, g_i, g_p); + Gv_SetVar(lVar2, ud.crosshairscale, g_i, g_p); return; case USERDEFS_ALTHUD: @@ -865,7 +865,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.althud = lValue; return; } - SetGameVarID(lVar2, ud.althud, g_i, g_p); + Gv_SetVar(lVar2, ud.althud, g_i, g_p); return; case USERDEFS_DISPLAY_BONUS_SCREEN: @@ -874,7 +874,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.display_bonus_screen = lValue; return; } - SetGameVarID(lVar2, ud.display_bonus_screen, g_i, g_p); + Gv_SetVar(lVar2, ud.display_bonus_screen, g_i, g_p); return; case USERDEFS_SHOW_LEVEL_TEXT: @@ -883,7 +883,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.show_level_text = lValue; return; } - SetGameVarID(lVar2, ud.show_level_text, g_i, g_p); + Gv_SetVar(lVar2, ud.show_level_text, g_i, g_p); return; case USERDEFS_WEAPONSCALE: @@ -892,7 +892,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.weaponscale = lValue; return; } - SetGameVarID(lVar2, ud.weaponscale, g_i, g_p); + Gv_SetVar(lVar2, ud.weaponscale, g_i, g_p); return; case USERDEFS_TEXTSCALE: @@ -901,7 +901,7 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) ud.textscale = lValue; return; } - SetGameVarID(lVar2, ud.textscale, g_i, g_p); + Gv_SetVar(lVar2, ud.textscale, g_i, g_p); return; default: @@ -909,278 +909,278 @@ void DoUserDef(int iSet, int lLabelID, int lVar2) } } -void DoThisProjectile(int iSet, int lVar1, int lLabelID, int lVar2) +void X_AccessActiveProjectile(int iSet, int lVar1, int lLabelID, int lVar2) { int lValue=0,proj=g_i; if (lVar1 != g_iThisActorID) - proj=GetGameVarID(lVar1, g_i, g_p); + proj=Gv_GetVar(lVar1, g_i, g_p); - if ((proj < 0 || proj >= MAXSPRITES) && checkCON) + if ((proj < 0 || proj >= MAXSPRITES) && g_scriptSanityChecks) { -// OSD_Printf("DoThisProjectile(): invalid projectile (%d)\n",proj); - OSD_Printf(CON_ERROR "tried to %s %s on invalid target projectile (%d) %d %d from %s\n",line_num,keyw[g_tw], - iSet?"set":"get",projectilelabels[lLabelID].name,proj,g_i,g_sp->picnum, +// OSD_Printf("X_AccessActiveProjectile(): invalid projectile (%d)\n",proj); + OSD_Printf(CON_ERROR "tried to %s %s on invalid target projectile (%d) %d %d from %s\n",g_errorLineNum,keyw[g_tw], + iSet?"set":"get",ProjectileLabels[lLabelID].name,proj,g_i,g_sp->picnum, (lVar1= ud.multimode) && checkCON) + if ((iPlayer<0 || iPlayer >= ud.multimode) && g_scriptSanityChecks) { -// OSD_Printf("DoPlayer(): invalid target player (%d) %d\n",iPlayer,g_i); - OSD_Printf(CON_ERROR "tried to %s %s on invalid target player (%d) from spr %d gv %s\n",line_num,keyw[g_tw], - iSet?"set":"get",playerlabels[lLabelID].name,iPlayer,g_i, +// OSD_Printf("X_AccessPlayer(): invalid target player (%d) %d\n",iPlayer,g_i); + OSD_Printf(CON_ERROR "tried to %s %s on invalid target player (%d) from spr %d gv %s\n",g_errorLineNum,keyw[g_tw], + iSet?"set":"get",PlayerLabels[lLabelID].name,iPlayer,g_i, (lVar1= playerlabels[lLabelID].maxParm2)) && checkCON) + if ((PlayerLabels[lLabelID].flags & LABEL_HASPARM2 && (lParm2 < 0 || lParm2 >= PlayerLabels[lLabelID].maxParm2)) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "tried to %s invalid %s position %d on player (%d) from spr %d\n",line_num,keyw[g_tw], - iSet?"set":"get",playerlabels[lLabelID].name,lParm2,iPlayer,g_i); + OSD_Printf(CON_ERROR "tried to %s invalid %s position %d on player (%d) from spr %d\n",g_errorLineNum,keyw[g_tw], + iSet?"set":"get",PlayerLabels[lLabelID].name,lParm2,iPlayer,g_i); insptr += (lVar2 == MAXGAMEVARS); return; } if (iSet) - lValue=GetGameVarID(lVar2, g_i, g_p); + lValue=Gv_GetVar(lVar2, g_i, g_p); switch (lLabelID) { @@ -1225,7 +1225,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->zoom=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->zoom, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->zoom, g_i, g_p); return; case PLAYER_EXITX: @@ -1234,7 +1234,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->exitx=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->exitx, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->exitx, g_i, g_p); return; case PLAYER_EXITY: @@ -1243,7 +1243,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->exity=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->exity, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->exity, g_i, g_p); return; case PLAYER_LOOGIEX: @@ -1252,7 +1252,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->loogiex[lParm2]=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->loogiex[lParm2], g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->loogiex[lParm2], g_i, g_p); return; case PLAYER_LOOGIEY: @@ -1261,7 +1261,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->loogiey[lParm2]=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->loogiey[lParm2], g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->loogiey[lParm2], g_i, g_p); return; case PLAYER_NUMLOOGS: @@ -1270,7 +1270,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->numloogs=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->numloogs, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->numloogs, g_i, g_p); return; case PLAYER_LOOGCNT: @@ -1279,7 +1279,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->loogcnt=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->loogcnt, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->loogcnt, g_i, g_p); return; case PLAYER_POSX: @@ -1288,7 +1288,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->posx=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->posx, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->posx, g_i, g_p); return; case PLAYER_POSY: @@ -1297,7 +1297,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->posy=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->posy, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->posy, g_i, g_p); return; case PLAYER_POSZ: @@ -1306,7 +1306,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->posz=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->posz, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->posz, g_i, g_p); return; case PLAYER_HORIZ: @@ -1315,7 +1315,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->horiz=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->horiz, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->horiz, g_i, g_p); return; case PLAYER_OHORIZ: @@ -1324,7 +1324,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->ohoriz=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->ohoriz, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->ohoriz, g_i, g_p); return; case PLAYER_OHORIZOFF: @@ -1333,7 +1333,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->ohorizoff=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->ohorizoff, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->ohorizoff, g_i, g_p); return; case PLAYER_INVDISPTIME: @@ -1342,7 +1342,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->invdisptime=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->invdisptime, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->invdisptime, g_i, g_p); return; case PLAYER_BOBPOSX: @@ -1351,7 +1351,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->bobposx=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->bobposx, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->bobposx, g_i, g_p); return; case PLAYER_BOBPOSY: @@ -1360,7 +1360,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->bobposy=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->bobposy, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->bobposy, g_i, g_p); return; case PLAYER_OPOSX: @@ -1369,7 +1369,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->oposx=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->oposx, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->oposx, g_i, g_p); return; case PLAYER_OPOSY: @@ -1378,7 +1378,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->oposy=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->oposy, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->oposy, g_i, g_p); return; case PLAYER_OPOSZ: @@ -1387,7 +1387,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->oposz=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->oposz, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->oposz, g_i, g_p); return; case PLAYER_PYOFF: @@ -1396,7 +1396,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->pyoff=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->pyoff, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->pyoff, g_i, g_p); return; case PLAYER_OPYOFF: @@ -1405,7 +1405,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->opyoff=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->opyoff, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->opyoff, g_i, g_p); return; case PLAYER_POSXV: @@ -1414,7 +1414,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->posxv=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->posxv, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->posxv, g_i, g_p); return; case PLAYER_POSYV: @@ -1423,7 +1423,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->posyv=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->posyv, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->posyv, g_i, g_p); return; case PLAYER_POSZV: @@ -1432,7 +1432,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->poszv=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->poszv, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->poszv, g_i, g_p); return; case PLAYER_LAST_PISSED_TIME: @@ -1441,7 +1441,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->last_pissed_time=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->last_pissed_time, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->last_pissed_time, g_i, g_p); return; case PLAYER_TRUEFZ: @@ -1450,7 +1450,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->truefz=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->truefz, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->truefz, g_i, g_p); return; case PLAYER_TRUECZ: @@ -1459,7 +1459,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->truecz=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->truecz, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->truecz, g_i, g_p); return; case PLAYER_PLAYER_PAR: @@ -1468,7 +1468,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->player_par=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->player_par, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->player_par, g_i, g_p); return; case PLAYER_VISIBILITY: @@ -1477,7 +1477,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->visibility=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->visibility, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->visibility, g_i, g_p); return; case PLAYER_BOBCOUNTER: @@ -1486,7 +1486,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->bobcounter=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->bobcounter, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->bobcounter, g_i, g_p); return; case PLAYER_WEAPON_SWAY: @@ -1495,7 +1495,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->weapon_sway=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->weapon_sway, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->weapon_sway, g_i, g_p); return; case PLAYER_PALS_TIME: @@ -1504,7 +1504,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->pals_time=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->pals_time, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->pals_time, g_i, g_p); return; case PLAYER_RANDOMFLAMEX: @@ -1513,7 +1513,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->randomflamex=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->randomflamex, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->randomflamex, g_i, g_p); return; case PLAYER_CRACK_TIME: @@ -1522,7 +1522,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->crack_time=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->crack_time, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->crack_time, g_i, g_p); return; case PLAYER_AIM_MODE: @@ -1531,7 +1531,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->aim_mode=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->aim_mode, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->aim_mode, g_i, g_p); return; case PLAYER_ANG: @@ -1540,7 +1540,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->ang=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->ang, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->ang, g_i, g_p); return; case PLAYER_OANG: @@ -1549,7 +1549,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->oang=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->oang, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->oang, g_i, g_p); return; case PLAYER_ANGVEL: @@ -1558,7 +1558,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->angvel=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->angvel, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->angvel, g_i, g_p); return; case PLAYER_CURSECTNUM: @@ -1567,7 +1567,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->cursectnum=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->cursectnum, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->cursectnum, g_i, g_p); return; case PLAYER_LOOK_ANG: @@ -1576,7 +1576,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->look_ang=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->look_ang, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->look_ang, g_i, g_p); return; case PLAYER_LAST_EXTRA: @@ -1585,7 +1585,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->last_extra=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->last_extra, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->last_extra, g_i, g_p); return; case PLAYER_SUBWEAPON: @@ -1594,7 +1594,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->subweapon=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->subweapon, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->subweapon, g_i, g_p); return; case PLAYER_AMMO_AMOUNT: @@ -1603,7 +1603,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->ammo_amount[lParm2]=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->ammo_amount[lParm2], g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->ammo_amount[lParm2], g_i, g_p); return; case PLAYER_WACKEDBYACTOR: @@ -1612,7 +1612,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->wackedbyactor=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->wackedbyactor, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->wackedbyactor, g_i, g_p); return; case PLAYER_FRAG: @@ -1621,7 +1621,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->frag=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->frag, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->frag, g_i, g_p); return; case PLAYER_FRAGGEDSELF: @@ -1630,7 +1630,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->fraggedself=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->fraggedself, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->fraggedself, g_i, g_p); return; case PLAYER_CURR_WEAPON: @@ -1639,7 +1639,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->curr_weapon=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->curr_weapon, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->curr_weapon, g_i, g_p); return; case PLAYER_LAST_WEAPON: @@ -1648,7 +1648,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->last_weapon=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->last_weapon, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->last_weapon, g_i, g_p); return; case PLAYER_TIPINCS: @@ -1657,7 +1657,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->tipincs=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->tipincs, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->tipincs, g_i, g_p); return; case PLAYER_HORIZOFF: @@ -1666,7 +1666,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->horizoff=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->horizoff, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->horizoff, g_i, g_p); return; case PLAYER_WANTWEAPONFIRE: @@ -1675,7 +1675,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->wantweaponfire=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->wantweaponfire, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->wantweaponfire, g_i, g_p); return; case PLAYER_HOLODUKE_AMOUNT: @@ -1684,7 +1684,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->holoduke_amount=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->holoduke_amount, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->holoduke_amount, g_i, g_p); return; case PLAYER_NEWOWNER: @@ -1693,7 +1693,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->newowner=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->newowner, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->newowner, g_i, g_p); return; case PLAYER_HURT_DELAY: @@ -1702,7 +1702,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->hurt_delay=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->hurt_delay, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->hurt_delay, g_i, g_p); return; case PLAYER_HBOMB_HOLD_DELAY: @@ -1711,7 +1711,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->hbomb_hold_delay=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->hbomb_hold_delay, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->hbomb_hold_delay, g_i, g_p); return; case PLAYER_JUMPING_COUNTER: @@ -1720,7 +1720,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->jumping_counter=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->jumping_counter, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->jumping_counter, g_i, g_p); return; case PLAYER_AIRLEFT: @@ -1729,7 +1729,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->airleft=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->airleft, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->airleft, g_i, g_p); return; case PLAYER_KNEE_INCS: @@ -1738,7 +1738,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->knee_incs=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->knee_incs, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->knee_incs, g_i, g_p); return; case PLAYER_ACCESS_INCS: @@ -1747,7 +1747,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->access_incs=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->access_incs, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->access_incs, g_i, g_p); return; case PLAYER_FTA: @@ -1756,7 +1756,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->fta=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->fta, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->fta, g_i, g_p); return; case PLAYER_FTQ: @@ -1765,7 +1765,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->ftq=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->ftq, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->ftq, g_i, g_p); return; case PLAYER_ACCESS_WALLNUM: @@ -1774,7 +1774,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->access_wallnum=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->access_wallnum, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->access_wallnum, g_i, g_p); return; case PLAYER_ACCESS_SPRITENUM: @@ -1783,7 +1783,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->access_spritenum=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->access_spritenum, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->access_spritenum, g_i, g_p); return; case PLAYER_KICKBACK_PIC: @@ -1792,7 +1792,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->kickback_pic=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->kickback_pic, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->kickback_pic, g_i, g_p); return; case PLAYER_GOT_ACCESS: @@ -1801,7 +1801,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->got_access=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->got_access, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->got_access, g_i, g_p); return; case PLAYER_WEAPON_ANG: @@ -1810,7 +1810,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->weapon_ang=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->weapon_ang, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->weapon_ang, g_i, g_p); return; case PLAYER_FIRSTAID_AMOUNT: @@ -1819,7 +1819,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->firstaid_amount=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->firstaid_amount, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->firstaid_amount, g_i, g_p); return; case PLAYER_SOMETHINGONPLAYER: @@ -1828,7 +1828,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->somethingonplayer=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->somethingonplayer, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->somethingonplayer, g_i, g_p); return; case PLAYER_ON_CRANE: @@ -1837,7 +1837,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->on_crane=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->on_crane, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->on_crane, g_i, g_p); return; case PLAYER_I: @@ -1846,7 +1846,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->i=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->i, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->i, g_i, g_p); return; case PLAYER_ONE_PARALLAX_SECTNUM: @@ -1855,7 +1855,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->one_parallax_sectnum=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->one_parallax_sectnum, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->one_parallax_sectnum, g_i, g_p); return; case PLAYER_OVER_SHOULDER_ON: @@ -1864,7 +1864,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->over_shoulder_on=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->over_shoulder_on, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->over_shoulder_on, g_i, g_p); return; case PLAYER_RANDOM_CLUB_FRAME: @@ -1873,7 +1873,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->random_club_frame=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->random_club_frame, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->random_club_frame, g_i, g_p); return; case PLAYER_FIST_INCS: @@ -1882,7 +1882,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->fist_incs=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->fist_incs, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->fist_incs, g_i, g_p); return; case PLAYER_ONE_EIGHTY_COUNT: @@ -1891,7 +1891,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->one_eighty_count=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->one_eighty_count, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->one_eighty_count, g_i, g_p); return; case PLAYER_CHEAT_PHASE: @@ -1900,7 +1900,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->cheat_phase=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->cheat_phase, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->cheat_phase, g_i, g_p); return; case PLAYER_DUMMYPLAYERSPRITE: @@ -1909,7 +1909,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->dummyplayersprite=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->dummyplayersprite, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->dummyplayersprite, g_i, g_p); return; case PLAYER_EXTRA_EXTRA8: @@ -1918,7 +1918,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->extra_extra8=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->extra_extra8, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->extra_extra8, g_i, g_p); return; case PLAYER_QUICK_KICK: @@ -1927,7 +1927,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->quick_kick=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->quick_kick, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->quick_kick, g_i, g_p); return; case PLAYER_HEAT_AMOUNT: @@ -1936,7 +1936,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->heat_amount=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->heat_amount, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->heat_amount, g_i, g_p); return; case PLAYER_ACTORSQU: @@ -1945,7 +1945,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->actorsqu=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->actorsqu, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->actorsqu, g_i, g_p); return; case PLAYER_TIMEBEFOREEXIT: @@ -1954,7 +1954,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->timebeforeexit=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->timebeforeexit, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->timebeforeexit, g_i, g_p); return; case PLAYER_CUSTOMEXITSOUND: @@ -1963,7 +1963,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->customexitsound=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->customexitsound, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->customexitsound, g_i, g_p); return; case PLAYER_WEAPRECS: @@ -1972,7 +1972,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->weaprecs[15]=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->weaprecs[15], g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->weaprecs[15], g_i, g_p); return; case PLAYER_WEAPRECCNT: @@ -1981,7 +1981,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->weapreccnt=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->weapreccnt, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->weapreccnt, g_i, g_p); return; case PLAYER_INTERFACE_TOGGLE_FLAG: @@ -1990,7 +1990,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->interface_toggle_flag=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->interface_toggle_flag, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->interface_toggle_flag, g_i, g_p); return; case PLAYER_ROTSCRNANG: @@ -1999,7 +1999,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->rotscrnang=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->rotscrnang, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->rotscrnang, g_i, g_p); return; case PLAYER_DEAD_FLAG: @@ -2008,7 +2008,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->dead_flag=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->dead_flag, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->dead_flag, g_i, g_p); return; case PLAYER_SHOW_EMPTY_WEAPON: @@ -2017,7 +2017,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->show_empty_weapon=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->show_empty_weapon, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->show_empty_weapon, g_i, g_p); return; case PLAYER_SCUBA_AMOUNT: @@ -2026,7 +2026,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->scuba_amount=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->scuba_amount, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->scuba_amount, g_i, g_p); return; case PLAYER_JETPACK_AMOUNT: @@ -2035,7 +2035,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->jetpack_amount=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->jetpack_amount, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->jetpack_amount, g_i, g_p); return; case PLAYER_STEROIDS_AMOUNT: @@ -2044,7 +2044,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->steroids_amount=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->steroids_amount, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->steroids_amount, g_i, g_p); return; case PLAYER_SHIELD_AMOUNT: @@ -2053,7 +2053,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->shield_amount=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->shield_amount, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->shield_amount, g_i, g_p); return; case PLAYER_HOLODUKE_ON: @@ -2062,7 +2062,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->holoduke_on=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->holoduke_on, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->holoduke_on, g_i, g_p); return; case PLAYER_PYCOUNT: @@ -2071,7 +2071,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->pycount=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->pycount, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->pycount, g_i, g_p); return; case PLAYER_WEAPON_POS: @@ -2080,7 +2080,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->weapon_pos=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->weapon_pos, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->weapon_pos, g_i, g_p); return; case PLAYER_FRAG_PS: @@ -2089,7 +2089,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->frag_ps=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->frag_ps, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->frag_ps, g_i, g_p); return; case PLAYER_TRANSPORTER_HOLD: @@ -2098,7 +2098,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->transporter_hold=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->transporter_hold, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->transporter_hold, g_i, g_p); return; case PLAYER_LAST_FULL_WEAPON: @@ -2107,7 +2107,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->last_full_weapon=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->last_full_weapon, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->last_full_weapon, g_i, g_p); return; case PLAYER_FOOTPRINTSHADE: @@ -2116,7 +2116,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->footprintshade=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->footprintshade, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->footprintshade, g_i, g_p); return; case PLAYER_BOOT_AMOUNT: @@ -2125,7 +2125,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->boot_amount=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->boot_amount, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->boot_amount, g_i, g_p); return; case PLAYER_SCREAM_VOICE: @@ -2134,7 +2134,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->scream_voice=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->scream_voice, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->scream_voice, g_i, g_p); return; case PLAYER_GM: @@ -2143,7 +2143,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->gm=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->gm, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->gm, g_i, g_p); return; case PLAYER_ON_WARPING_SECTOR: @@ -2152,7 +2152,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->on_warping_sector=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->on_warping_sector, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->on_warping_sector, g_i, g_p); return; case PLAYER_FOOTPRINTCOUNT: @@ -2161,7 +2161,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->footprintcount=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->footprintcount, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->footprintcount, g_i, g_p); return; case PLAYER_HBOMB_ON: @@ -2170,7 +2170,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->hbomb_on=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->hbomb_on, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->hbomb_on, g_i, g_p); return; case PLAYER_JUMPING_TOGGLE: @@ -2179,7 +2179,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->jumping_toggle=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->jumping_toggle, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->jumping_toggle, g_i, g_p); return; case PLAYER_RAPID_FIRE_HOLD: @@ -2188,7 +2188,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->rapid_fire_hold=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->rapid_fire_hold, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->rapid_fire_hold, g_i, g_p); return; case PLAYER_ON_GROUND: @@ -2197,7 +2197,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->on_ground=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->on_ground, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->on_ground, g_i, g_p); return; /* case PLAYER_NAME: @@ -2206,7 +2206,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->name[32]=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->name[32], g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->name[32], g_i, g_p); return;*/ case PLAYER_INVEN_ICON: @@ -2215,7 +2215,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->inven_icon=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->inven_icon, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->inven_icon, g_i, g_p); return; case PLAYER_BUTTONPALETTE: @@ -2224,7 +2224,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->buttonpalette=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->buttonpalette, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->buttonpalette, g_i, g_p); return; case PLAYER_JETPACK_ON: @@ -2233,7 +2233,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->jetpack_on=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->jetpack_on, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->jetpack_on, g_i, g_p); return; case PLAYER_SPRITEBRIDGE: @@ -2242,7 +2242,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->spritebridge=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->spritebridge, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->spritebridge, g_i, g_p); return; case PLAYER_LASTRANDOMSPOT: @@ -2251,7 +2251,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->lastrandomspot=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->lastrandomspot, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->lastrandomspot, g_i, g_p); return; case PLAYER_SCUBA_ON: @@ -2260,7 +2260,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->scuba_on=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->scuba_on, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->scuba_on, g_i, g_p); return; case PLAYER_FOOTPRINTPAL: @@ -2269,7 +2269,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->footprintpal=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->footprintpal, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->footprintpal, g_i, g_p); return; case PLAYER_HEAT_ON: @@ -2279,12 +2279,12 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) if (g_player[iPlayer].ps->heat_on != lValue) { g_player[iPlayer].ps->heat_on=lValue; - setpal(g_player[iPlayer].ps); + P_UpdateScreenPal(g_player[iPlayer].ps); } } return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->heat_on, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->heat_on, g_i, g_p); return; case PLAYER_HOLSTER_WEAPON: @@ -2293,7 +2293,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->holster_weapon=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->holster_weapon, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->holster_weapon, g_i, g_p); return; case PLAYER_FALLING_COUNTER: @@ -2302,7 +2302,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->falling_counter=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->falling_counter, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->falling_counter, g_i, g_p); return; case PLAYER_GOTWEAPON: @@ -2311,7 +2311,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->gotweapon[lParm2]=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->gotweapon[lParm2], g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->gotweapon[lParm2], g_i, g_p); return; case PLAYER_REFRESH_INVENTORY: @@ -2320,7 +2320,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->refresh_inventory=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->refresh_inventory, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->refresh_inventory, g_i, g_p); return; // case PLAYER_PALETTE: @@ -2330,7 +2330,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) // } // return; } // { - // SetGameVarID(lVar2, g_player[iPlayer].ps->palette, g_i, g_p); + // Gv_SetVar(lVar2, g_player[iPlayer].ps->palette, g_i, g_p); // } // return; @@ -2340,7 +2340,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->toggle_key_flag=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->toggle_key_flag, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->toggle_key_flag, g_i, g_p); return; case PLAYER_KNUCKLE_INCS: @@ -2349,7 +2349,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->knuckle_incs=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->knuckle_incs, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->knuckle_incs, g_i, g_p); return; case PLAYER_WALKING_SND_TOGGLE: @@ -2358,7 +2358,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->walking_snd_toggle=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->walking_snd_toggle, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->walking_snd_toggle, g_i, g_p); return; case PLAYER_PALOOKUP: @@ -2367,7 +2367,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->palookup=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->palookup, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->palookup, g_i, g_p); return; case PLAYER_HARD_LANDING: @@ -2376,7 +2376,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->hard_landing=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->hard_landing, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->hard_landing, g_i, g_p); return; case PLAYER_MAX_SECRET_ROOMS: @@ -2385,7 +2385,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->max_secret_rooms=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->max_secret_rooms, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->max_secret_rooms, g_i, g_p); return; case PLAYER_SECRET_ROOMS: @@ -2394,7 +2394,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->secret_rooms=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->secret_rooms, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->secret_rooms, g_i, g_p); return; case PLAYER_PALS: @@ -2403,7 +2403,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->pals[lParm2]=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->pals[lParm2], g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->pals[lParm2], g_i, g_p); return; case PLAYER_MAX_ACTORS_KILLED: @@ -2412,7 +2412,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->max_actors_killed=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->max_actors_killed, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->max_actors_killed, g_i, g_p); return; case PLAYER_ACTORS_KILLED: @@ -2421,7 +2421,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->actors_killed=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->actors_killed, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->actors_killed, g_i, g_p); return; case PLAYER_RETURN_TO_CENTER: @@ -2430,7 +2430,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->return_to_center=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->return_to_center, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->return_to_center, g_i, g_p); return; case PLAYER_RUNSPEED: @@ -2439,7 +2439,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->runspeed=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->runspeed, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->runspeed, g_i, g_p); return; case PLAYER_SBS: @@ -2448,7 +2448,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->sbs=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->sbs, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->sbs, g_i, g_p); return; case PLAYER_RELOADING: @@ -2457,7 +2457,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->reloading=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->reloading, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->reloading, g_i, g_p); return; case PLAYER_AUTO_AIM: @@ -2466,7 +2466,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->auto_aim=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->auto_aim, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->auto_aim, g_i, g_p); return; case PLAYER_MOVEMENT_LOCK: @@ -2475,7 +2475,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->movement_lock=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->movement_lock, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->movement_lock, g_i, g_p); return; case PLAYER_SOUND_PITCH: @@ -2484,7 +2484,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->sound_pitch=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->sound_pitch, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->sound_pitch, g_i, g_p); return; case PLAYER_WEAPONSWITCH: @@ -2493,7 +2493,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->weaponswitch=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->weaponswitch, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->weaponswitch, g_i, g_p); return; case PLAYER_TEAM: @@ -2502,7 +2502,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->team=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->team, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->team, g_i, g_p); return; case PLAYER_MAX_PLAYER_HEALTH: @@ -2511,7 +2511,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->max_player_health = lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->max_player_health, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->max_player_health, g_i, g_p); return; case PLAYER_MAX_SHIELD_AMOUNT: @@ -2520,7 +2520,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->max_shield_amount = lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->max_shield_amount, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->max_shield_amount, g_i, g_p); return; case PLAYER_MAX_AMMO_AMOUNT: @@ -2529,7 +2529,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->max_ammo_amount[lParm2]=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->max_ammo_amount[lParm2], g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->max_ammo_amount[lParm2], g_i, g_p); return; case PLAYER_LAST_QUICK_KICK: @@ -2538,7 +2538,7 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) g_player[iPlayer].ps->last_quick_kick=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].ps->last_quick_kick, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].ps->last_quick_kick, g_i, g_p); return; default: @@ -2546,23 +2546,23 @@ void DoPlayer(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) } } -void DoInput(int iSet, int lVar1, int lLabelID, int lVar2) +void X_AccessPlayerInput(int iSet, int lVar1, int lLabelID, int lVar2) { int lValue=0; int iPlayer=g_p; if (lVar1 != g_iThisActorID) - iPlayer=GetGameVarID(lVar1, g_i, g_p); + iPlayer=Gv_GetVar(lVar1, g_i, g_p); - if ((iPlayer<0 || iPlayer >= ud.multimode) && checkCON) + if ((iPlayer<0 || iPlayer >= ud.multimode) && g_scriptSanityChecks) { insptr += (lVar2 == MAXGAMEVARS); - OSD_Printf(CON_ERROR "invalid target player (%d) %d\n",line_num,keyw[g_tw],iPlayer,g_i); + OSD_Printf(CON_ERROR "invalid target player (%d) %d\n",g_errorLineNum,keyw[g_tw],iPlayer,g_i); return; } if (iSet) - lValue=GetGameVarID(lVar2, g_i, g_p); + lValue=Gv_GetVar(lVar2, g_i, g_p); switch (lLabelID) { @@ -2572,7 +2572,7 @@ void DoInput(int iSet, int lVar1, int lLabelID, int lVar2) g_player[iPlayer].sync->avel=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].sync->avel, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].sync->avel, g_i, g_p); return; case INPUT_HORZ: @@ -2581,7 +2581,7 @@ void DoInput(int iSet, int lVar1, int lLabelID, int lVar2) g_player[iPlayer].sync->horz=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].sync->horz, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].sync->horz, g_i, g_p); return; case INPUT_FVEL: @@ -2590,7 +2590,7 @@ void DoInput(int iSet, int lVar1, int lLabelID, int lVar2) g_player[iPlayer].sync->fvel=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].sync->fvel, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].sync->fvel, g_i, g_p); return; case INPUT_SVEL: @@ -2599,7 +2599,7 @@ void DoInput(int iSet, int lVar1, int lLabelID, int lVar2) g_player[iPlayer].sync->svel=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].sync->svel, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].sync->svel, g_i, g_p); return; case INPUT_BITS: @@ -2608,7 +2608,7 @@ void DoInput(int iSet, int lVar1, int lLabelID, int lVar2) g_player[iPlayer].sync->bits=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].sync->bits, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].sync->bits, g_i, g_p); return; case INPUT_EXTBITS: @@ -2617,27 +2617,27 @@ void DoInput(int iSet, int lVar1, int lLabelID, int lVar2) g_player[iPlayer].sync->extbits=lValue; return; } - SetGameVarID(lVar2, g_player[iPlayer].sync->extbits, g_i, g_p); + Gv_SetVar(lVar2, g_player[iPlayer].sync->extbits, g_i, g_p); return; default: return; } } -void DoWall(int iSet, int lVar1, int lLabelID, int lVar2) +void X_AccessWall(int iSet, int lVar1, int lLabelID, int lVar2) { int lValue=0; - int iWall = GetGameVarID(lVar1, g_i, g_p); + int iWall = Gv_GetVar(lVar1, g_i, g_p); - if ((iWall<0 || iWall >= numwalls) && checkCON) + if ((iWall<0 || iWall >= numwalls) && g_scriptSanityChecks) { insptr += (lVar2 == MAXGAMEVARS); - OSD_Printf(CON_ERROR "Invalid wall %d\n",line_num,keyw[g_tw],iWall); + OSD_Printf(CON_ERROR "Invalid wall %d\n",g_errorLineNum,keyw[g_tw],iWall); return; } if (iSet) - lValue=GetGameVarID(lVar2, g_i, g_p); + lValue=Gv_GetVar(lVar2, g_i, g_p); switch (lLabelID) { @@ -2647,7 +2647,7 @@ void DoWall(int iSet, int lVar1, int lLabelID, int lVar2) wall[iWall].x=lValue; return; } - SetGameVarID(lVar2, wall[iWall].x, g_i, g_p); + Gv_SetVar(lVar2, wall[iWall].x, g_i, g_p); return; case WALL_Y: @@ -2656,7 +2656,7 @@ void DoWall(int iSet, int lVar1, int lLabelID, int lVar2) wall[iWall].y=lValue; return; } - SetGameVarID(lVar2, wall[iWall].y, g_i, g_p); + Gv_SetVar(lVar2, wall[iWall].y, g_i, g_p); return; case WALL_POINT2: @@ -2665,7 +2665,7 @@ void DoWall(int iSet, int lVar1, int lLabelID, int lVar2) wall[iWall].point2=lValue; return; } - SetGameVarID(lVar2, wall[iWall].point2, g_i, g_p); + Gv_SetVar(lVar2, wall[iWall].point2, g_i, g_p); return; case WALL_NEXTWALL: @@ -2674,7 +2674,7 @@ void DoWall(int iSet, int lVar1, int lLabelID, int lVar2) wall[iWall].nextwall=lValue; return; } - SetGameVarID(lVar2, wall[iWall].nextwall, g_i, g_p); + Gv_SetVar(lVar2, wall[iWall].nextwall, g_i, g_p); return; case WALL_NEXTSECTOR: @@ -2683,7 +2683,7 @@ void DoWall(int iSet, int lVar1, int lLabelID, int lVar2) wall[iWall].nextsector=lValue; return; } - SetGameVarID(lVar2, wall[iWall].nextsector, g_i, g_p); + Gv_SetVar(lVar2, wall[iWall].nextsector, g_i, g_p); return; case WALL_CSTAT: @@ -2692,7 +2692,7 @@ void DoWall(int iSet, int lVar1, int lLabelID, int lVar2) wall[iWall].cstat=lValue; return; } - SetGameVarID(lVar2, wall[iWall].cstat, g_i, g_p); + Gv_SetVar(lVar2, wall[iWall].cstat, g_i, g_p); return; case WALL_PICNUM: @@ -2701,7 +2701,7 @@ void DoWall(int iSet, int lVar1, int lLabelID, int lVar2) wall[iWall].picnum=lValue; return; } - SetGameVarID(lVar2, wall[iWall].picnum, g_i, g_p); + Gv_SetVar(lVar2, wall[iWall].picnum, g_i, g_p); return; case WALL_OVERPICNUM: @@ -2710,7 +2710,7 @@ void DoWall(int iSet, int lVar1, int lLabelID, int lVar2) wall[iWall].overpicnum=lValue; return; } - SetGameVarID(lVar2, wall[iWall].overpicnum, g_i, g_p); + Gv_SetVar(lVar2, wall[iWall].overpicnum, g_i, g_p); return; case WALL_SHADE: @@ -2719,7 +2719,7 @@ void DoWall(int iSet, int lVar1, int lLabelID, int lVar2) wall[iWall].shade=lValue; return; } - SetGameVarID(lVar2, wall[iWall].shade, g_i, g_p); + Gv_SetVar(lVar2, wall[iWall].shade, g_i, g_p); return; case WALL_PAL: @@ -2728,7 +2728,7 @@ void DoWall(int iSet, int lVar1, int lLabelID, int lVar2) wall[iWall].pal=lValue; return; } - SetGameVarID(lVar2, wall[iWall].pal, g_i, g_p); + Gv_SetVar(lVar2, wall[iWall].pal, g_i, g_p); return; case WALL_XREPEAT: @@ -2737,7 +2737,7 @@ void DoWall(int iSet, int lVar1, int lLabelID, int lVar2) wall[iWall].xrepeat=lValue; return; } - SetGameVarID(lVar2, wall[iWall].xrepeat, g_i, g_p); + Gv_SetVar(lVar2, wall[iWall].xrepeat, g_i, g_p); return; case WALL_YREPEAT: @@ -2746,7 +2746,7 @@ void DoWall(int iSet, int lVar1, int lLabelID, int lVar2) wall[iWall].yrepeat=lValue; return; } - SetGameVarID(lVar2, wall[iWall].yrepeat, g_i, g_p); + Gv_SetVar(lVar2, wall[iWall].yrepeat, g_i, g_p); return; case WALL_XPANNING: @@ -2755,7 +2755,7 @@ void DoWall(int iSet, int lVar1, int lLabelID, int lVar2) wall[iWall].xpanning=lValue; return; } - SetGameVarID(lVar2, wall[iWall].xpanning, g_i, g_p); + Gv_SetVar(lVar2, wall[iWall].xpanning, g_i, g_p); return; case WALL_YPANNING: @@ -2764,7 +2764,7 @@ void DoWall(int iSet, int lVar1, int lLabelID, int lVar2) wall[iWall].ypanning=lValue; return; } - SetGameVarID(lVar2, wall[iWall].ypanning, g_i, g_p); + Gv_SetVar(lVar2, wall[iWall].ypanning, g_i, g_p); return; case WALL_LOTAG: @@ -2773,7 +2773,7 @@ void DoWall(int iSet, int lVar1, int lLabelID, int lVar2) wall[iWall].lotag=lValue; return; } - SetGameVarID(lVar2, wall[iWall].lotag, g_i, g_p); + Gv_SetVar(lVar2, wall[iWall].lotag, g_i, g_p); return; case WALL_HITAG: @@ -2782,7 +2782,7 @@ void DoWall(int iSet, int lVar1, int lLabelID, int lVar2) wall[iWall].hitag=lValue; return; } - SetGameVarID(lVar2, wall[iWall].hitag, g_i, g_p); + Gv_SetVar(lVar2, wall[iWall].hitag, g_i, g_p); return; case WALL_EXTRA: @@ -2791,30 +2791,30 @@ void DoWall(int iSet, int lVar1, int lLabelID, int lVar2) wall[iWall].extra=lValue; return; } - SetGameVarID(lVar2, wall[iWall].extra, g_i, g_p); + Gv_SetVar(lVar2, wall[iWall].extra, g_i, g_p); return; default: return; } } -void DoSector(int iSet, int lVar1, int lLabelID, int lVar2) +void X_AccessSector(int iSet, int lVar1, int lLabelID, int lVar2) { int lValue=0; int iSector=sprite[g_i].sectnum; if (lVar1 != g_iThisActorID) - iSector=GetGameVarID(lVar1, g_i, g_p); + iSector=Gv_GetVar(lVar1, g_i, g_p); - if ((iSector<0 || iSector >= numsectors) && checkCON) + if ((iSector<0 || iSector >= numsectors) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "Invalid sector %d\n",line_num,keyw[g_tw],iSector); + OSD_Printf(CON_ERROR "Invalid sector %d\n",g_errorLineNum,keyw[g_tw],iSector); insptr += (lVar2 == MAXGAMEVARS); return; } if (iSet) - lValue=GetGameVarID(lVar2, g_i, g_p); + lValue=Gv_GetVar(lVar2, g_i, g_p); switch (lLabelID) { @@ -2824,7 +2824,7 @@ void DoSector(int iSet, int lVar1, int lLabelID, int lVar2) sector[iSector].wallptr=lValue; return; } - SetGameVarID(lVar2, sector[iSector].wallptr,g_i,g_p); + Gv_SetVar(lVar2, sector[iSector].wallptr,g_i,g_p); return; case SECTOR_WALLNUM: @@ -2833,7 +2833,7 @@ void DoSector(int iSet, int lVar1, int lLabelID, int lVar2) sector[iSector].wallnum=lValue; return; } - SetGameVarID(lVar2, sector[iSector].wallnum,g_i,g_p); + Gv_SetVar(lVar2, sector[iSector].wallnum,g_i,g_p); return; case SECTOR_CEILINGZ: @@ -2842,7 +2842,7 @@ void DoSector(int iSet, int lVar1, int lLabelID, int lVar2) sector[iSector].ceilingz=lValue; return; } - SetGameVarID(lVar2, sector[iSector].ceilingz,g_i,g_p); + Gv_SetVar(lVar2, sector[iSector].ceilingz,g_i,g_p); return; case SECTOR_FLOORZ: @@ -2851,7 +2851,7 @@ void DoSector(int iSet, int lVar1, int lLabelID, int lVar2) sector[iSector].floorz=lValue; return; } - SetGameVarID(lVar2, sector[iSector].floorz,g_i,g_p); + Gv_SetVar(lVar2, sector[iSector].floorz,g_i,g_p); return; case SECTOR_CEILINGSTAT: @@ -2860,7 +2860,7 @@ void DoSector(int iSet, int lVar1, int lLabelID, int lVar2) sector[iSector].ceilingstat=lValue; return; } - SetGameVarID(lVar2, sector[iSector].ceilingstat,g_i,g_p); + Gv_SetVar(lVar2, sector[iSector].ceilingstat,g_i,g_p); return; case SECTOR_FLOORSTAT: @@ -2869,7 +2869,7 @@ void DoSector(int iSet, int lVar1, int lLabelID, int lVar2) sector[iSector].floorstat=lValue; return; } - SetGameVarID(lVar2, sector[iSector].floorstat,g_i,g_p); + Gv_SetVar(lVar2, sector[iSector].floorstat,g_i,g_p); return; case SECTOR_CEILINGPICNUM: @@ -2878,7 +2878,7 @@ void DoSector(int iSet, int lVar1, int lLabelID, int lVar2) sector[iSector].ceilingpicnum=lValue; return; } - SetGameVarID(lVar2, sector[iSector].ceilingpicnum,g_i,g_p); + Gv_SetVar(lVar2, sector[iSector].ceilingpicnum,g_i,g_p); return; case SECTOR_CEILINGSLOPE: @@ -2887,7 +2887,7 @@ void DoSector(int iSet, int lVar1, int lLabelID, int lVar2) sector[iSector].ceilingheinum=lValue; return; } - SetGameVarID(lVar2, sector[iSector].ceilingheinum,g_i,g_p); + Gv_SetVar(lVar2, sector[iSector].ceilingheinum,g_i,g_p); return; case SECTOR_CEILINGSHADE: @@ -2896,7 +2896,7 @@ void DoSector(int iSet, int lVar1, int lLabelID, int lVar2) sector[iSector].ceilingshade=lValue; return; } - SetGameVarID(lVar2, sector[iSector].ceilingshade,g_i,g_p); + Gv_SetVar(lVar2, sector[iSector].ceilingshade,g_i,g_p); return; case SECTOR_CEILINGPAL: @@ -2905,7 +2905,7 @@ void DoSector(int iSet, int lVar1, int lLabelID, int lVar2) sector[iSector].ceilingpal=lValue; return; } - SetGameVarID(lVar2, sector[iSector].ceilingpal,g_i,g_p); + Gv_SetVar(lVar2, sector[iSector].ceilingpal,g_i,g_p); return; case SECTOR_CEILINGXPANNING: @@ -2914,7 +2914,7 @@ void DoSector(int iSet, int lVar1, int lLabelID, int lVar2) sector[iSector].ceilingxpanning=lValue; return; } - SetGameVarID(lVar2, sector[iSector].ceilingxpanning,g_i,g_p); + Gv_SetVar(lVar2, sector[iSector].ceilingxpanning,g_i,g_p); return; case SECTOR_CEILINGYPANNING: @@ -2923,7 +2923,7 @@ void DoSector(int iSet, int lVar1, int lLabelID, int lVar2) sector[iSector].ceilingypanning=lValue; return; } - SetGameVarID(lVar2, sector[iSector].ceilingypanning,g_i,g_p); + Gv_SetVar(lVar2, sector[iSector].ceilingypanning,g_i,g_p); return; case SECTOR_FLOORPICNUM: @@ -2932,7 +2932,7 @@ void DoSector(int iSet, int lVar1, int lLabelID, int lVar2) sector[iSector].floorpicnum=lValue; return; } - SetGameVarID(lVar2, sector[iSector].floorpicnum,g_i,g_p); + Gv_SetVar(lVar2, sector[iSector].floorpicnum,g_i,g_p); return; case SECTOR_FLOORSLOPE: @@ -2941,7 +2941,7 @@ void DoSector(int iSet, int lVar1, int lLabelID, int lVar2) sector[iSector].floorheinum=lValue; return; } - SetGameVarID(lVar2, sector[iSector].floorheinum,g_i,g_p); + Gv_SetVar(lVar2, sector[iSector].floorheinum,g_i,g_p); return; case SECTOR_FLOORSHADE: @@ -2950,7 +2950,7 @@ void DoSector(int iSet, int lVar1, int lLabelID, int lVar2) sector[iSector].floorshade=lValue; return; } - SetGameVarID(lVar2, sector[iSector].floorshade,g_i,g_p); + Gv_SetVar(lVar2, sector[iSector].floorshade,g_i,g_p); return; case SECTOR_FLOORPAL: @@ -2959,7 +2959,7 @@ void DoSector(int iSet, int lVar1, int lLabelID, int lVar2) sector[iSector].floorpal=lValue; return; } - SetGameVarID(lVar2, sector[iSector].floorpal,g_i,g_p); + Gv_SetVar(lVar2, sector[iSector].floorpal,g_i,g_p); return; case SECTOR_FLOORXPANNING: @@ -2968,7 +2968,7 @@ void DoSector(int iSet, int lVar1, int lLabelID, int lVar2) sector[iSector].floorxpanning=lValue; return; } - SetGameVarID(lVar2, sector[iSector].floorxpanning,g_i,g_p); + Gv_SetVar(lVar2, sector[iSector].floorxpanning,g_i,g_p); return; case SECTOR_FLOORYPANNING: @@ -2977,7 +2977,7 @@ void DoSector(int iSet, int lVar1, int lLabelID, int lVar2) sector[iSector].floorypanning=lValue; return; } - SetGameVarID(lVar2, sector[iSector].floorypanning,g_i,g_p); + Gv_SetVar(lVar2, sector[iSector].floorypanning,g_i,g_p); return; case SECTOR_VISIBILITY: @@ -2986,7 +2986,7 @@ void DoSector(int iSet, int lVar1, int lLabelID, int lVar2) sector[iSector].visibility=lValue; return; } - SetGameVarID(lVar2, sector[iSector].visibility,g_i,g_p); + Gv_SetVar(lVar2, sector[iSector].visibility,g_i,g_p); return; case SECTOR_ALIGNTO: @@ -2995,7 +2995,7 @@ void DoSector(int iSet, int lVar1, int lLabelID, int lVar2) sector[iSector].filler=lValue; return; } - SetGameVarID(lVar2, sector[iSector].filler,g_i,g_p); + Gv_SetVar(lVar2, sector[iSector].filler,g_i,g_p); return; case SECTOR_LOTAG: @@ -3004,7 +3004,7 @@ void DoSector(int iSet, int lVar1, int lLabelID, int lVar2) sector[iSector].lotag=lValue; return; } - SetGameVarID(lVar2, sector[iSector].lotag,g_i,g_p); + Gv_SetVar(lVar2, sector[iSector].lotag,g_i,g_p); return; case SECTOR_HITAG: @@ -3013,7 +3013,7 @@ void DoSector(int iSet, int lVar1, int lLabelID, int lVar2) sector[iSector].hitag=lValue; return; } - SetGameVarID(lVar2, sector[iSector].hitag,g_i,g_p); + Gv_SetVar(lVar2, sector[iSector].hitag,g_i,g_p); return; case SECTOR_EXTRA: @@ -3022,7 +3022,7 @@ void DoSector(int iSet, int lVar1, int lLabelID, int lVar2) sector[iSector].extra=lValue; return; } - SetGameVarID(lVar2, sector[iSector].extra,g_i,g_p); + Gv_SetVar(lVar2, sector[iSector].extra,g_i,g_p); return; default: @@ -3030,33 +3030,33 @@ void DoSector(int iSet, int lVar1, int lLabelID, int lVar2) } } -void DoActor(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) +void X_AccessSprite(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) { int lValue=0; int iActor=g_i; if (lVar1 != g_iThisActorID) - iActor=GetGameVarID(lVar1, g_i, g_p); + iActor=Gv_GetVar(lVar1, g_i, g_p); - if ((iActor < 0 || iActor >= MAXSPRITES) && checkCON) + if ((iActor < 0 || iActor >= MAXSPRITES) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "tried to %s %s on invalid target sprite (%d) from spr %d pic %d gv %s\n",line_num,keyw[g_tw], - iSet?"set":"get",actorlabels[lLabelID].name,iActor,g_i,g_sp->picnum, + OSD_Printf(CON_ERROR "tried to %s %s on invalid target sprite (%d) from spr %d pic %d gv %s\n",g_errorLineNum,keyw[g_tw], + iSet?"set":"get",ActorLabels[lLabelID].name,iActor,g_i,g_sp->picnum, (lVar1= actorlabels[lLabelID].maxParm2)) && checkCON) + if ((ActorLabels[lLabelID].flags & LABEL_HASPARM2 && (lParm2 < 0 || lParm2 >= ActorLabels[lLabelID].maxParm2)) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "tried to %s invalid %s position %d on sprite (%d) from spr %d\n",line_num,keyw[g_tw], - iSet?"set":"get",actorlabels[lLabelID].name,lParm2,iActor,g_i); + OSD_Printf(CON_ERROR "tried to %s invalid %s position %d on sprite (%d) from spr %d\n",g_errorLineNum,keyw[g_tw], + iSet?"set":"get",ActorLabels[lLabelID].name,lParm2,iActor,g_i); insptr += (lVar2 == MAXGAMEVARS); return; } if (iSet) - lValue=GetGameVarID(lVar2, g_i, g_p); + lValue=Gv_GetVar(lVar2, g_i, g_p); switch (lLabelID) { @@ -3066,7 +3066,7 @@ void DoActor(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) sprite[iActor].x=lValue; return; } - SetGameVarID(lVar2, sprite[iActor].x,g_i,g_p); + Gv_SetVar(lVar2, sprite[iActor].x,g_i,g_p); return; case ACTOR_Y: @@ -3075,7 +3075,7 @@ void DoActor(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) sprite[iActor].y=lValue; return; } - SetGameVarID(lVar2, sprite[iActor].y,g_i,g_p); + Gv_SetVar(lVar2, sprite[iActor].y,g_i,g_p); return; case ACTOR_Z: @@ -3084,7 +3084,7 @@ void DoActor(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) sprite[iActor].z=lValue; return; } - SetGameVarID(lVar2, sprite[iActor].z,g_i,g_p); + Gv_SetVar(lVar2, sprite[iActor].z,g_i,g_p); return; case ACTOR_CSTAT: @@ -3093,7 +3093,7 @@ void DoActor(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) sprite[iActor].cstat=lValue; return; } - SetGameVarID(lVar2, sprite[iActor].cstat,g_i,g_p); + Gv_SetVar(lVar2, sprite[iActor].cstat,g_i,g_p); return; case ACTOR_PICNUM: @@ -3102,7 +3102,7 @@ void DoActor(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) sprite[iActor].picnum=lValue; return; } - SetGameVarID(lVar2, sprite[iActor].picnum,g_i,g_p); + Gv_SetVar(lVar2, sprite[iActor].picnum,g_i,g_p); return; case ACTOR_SHADE: @@ -3111,7 +3111,7 @@ void DoActor(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) sprite[iActor].shade=lValue; return; } - SetGameVarID(lVar2, sprite[iActor].shade,g_i,g_p); + Gv_SetVar(lVar2, sprite[iActor].shade,g_i,g_p); return; case ACTOR_PAL: @@ -3120,7 +3120,7 @@ void DoActor(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) sprite[iActor].pal=lValue; return; } - SetGameVarID(lVar2, sprite[iActor].pal,g_i,g_p); + Gv_SetVar(lVar2, sprite[iActor].pal,g_i,g_p); return; case ACTOR_CLIPDIST: @@ -3129,7 +3129,7 @@ void DoActor(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) sprite[iActor].clipdist=lValue; return; } - SetGameVarID(lVar2, sprite[iActor].clipdist,g_i,g_p); + Gv_SetVar(lVar2, sprite[iActor].clipdist,g_i,g_p); return; case ACTOR_DETAIL: @@ -3138,7 +3138,7 @@ void DoActor(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) sprite[iActor].filler=lValue; return; } - SetGameVarID(lVar2, sprite[iActor].filler,g_i,g_p); + Gv_SetVar(lVar2, sprite[iActor].filler,g_i,g_p); return; case ACTOR_XREPEAT: @@ -3147,7 +3147,7 @@ void DoActor(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) sprite[iActor].xrepeat=lValue; return; } - SetGameVarID(lVar2, sprite[iActor].xrepeat,g_i,g_p); + Gv_SetVar(lVar2, sprite[iActor].xrepeat,g_i,g_p); return; case ACTOR_YREPEAT: @@ -3156,7 +3156,7 @@ void DoActor(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) sprite[iActor].yrepeat=lValue; return; } - SetGameVarID(lVar2, sprite[iActor].yrepeat,g_i,g_p); + Gv_SetVar(lVar2, sprite[iActor].yrepeat,g_i,g_p); return; case ACTOR_XOFFSET: @@ -3165,7 +3165,7 @@ void DoActor(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) sprite[iActor].xoffset=lValue; return; } - SetGameVarID(lVar2, sprite[iActor].xoffset,g_i,g_p); + Gv_SetVar(lVar2, sprite[iActor].xoffset,g_i,g_p); return; case ACTOR_YOFFSET: @@ -3174,7 +3174,7 @@ void DoActor(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) sprite[iActor].yoffset=lValue; return; } - SetGameVarID(lVar2, sprite[iActor].yoffset,g_i,g_p); + Gv_SetVar(lVar2, sprite[iActor].yoffset,g_i,g_p); return; case ACTOR_SECTNUM: @@ -3183,7 +3183,7 @@ void DoActor(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) changespritesect(iActor,lValue); return; } - SetGameVarID(lVar2, sprite[iActor].sectnum,g_i,g_p); + Gv_SetVar(lVar2, sprite[iActor].sectnum,g_i,g_p); return; case ACTOR_STATNUM: @@ -3192,7 +3192,7 @@ void DoActor(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) changespritestat(iActor,lValue); return; } - SetGameVarID(lVar2, sprite[iActor].statnum,g_i,g_p); + Gv_SetVar(lVar2, sprite[iActor].statnum,g_i,g_p); return; case ACTOR_ANG: @@ -3201,7 +3201,7 @@ void DoActor(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) sprite[iActor].ang=lValue; return; } - SetGameVarID(lVar2, sprite[iActor].ang,g_i,g_p); + Gv_SetVar(lVar2, sprite[iActor].ang,g_i,g_p); return; case ACTOR_OWNER: @@ -3210,7 +3210,7 @@ void DoActor(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) sprite[iActor].owner=lValue; return; } - SetGameVarID(lVar2, sprite[iActor].owner,g_i,g_p); + Gv_SetVar(lVar2, sprite[iActor].owner,g_i,g_p); return; case ACTOR_XVEL: @@ -3219,7 +3219,7 @@ void DoActor(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) sprite[iActor].xvel=lValue; return; } - SetGameVarID(lVar2, sprite[iActor].xvel,g_i,g_p); + Gv_SetVar(lVar2, sprite[iActor].xvel,g_i,g_p); return; case ACTOR_YVEL: @@ -3228,7 +3228,7 @@ void DoActor(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) sprite[iActor].yvel=lValue; return; } - SetGameVarID(lVar2, sprite[iActor].yvel,g_i,g_p); + Gv_SetVar(lVar2, sprite[iActor].yvel,g_i,g_p); return; case ACTOR_ZVEL: @@ -3237,7 +3237,7 @@ void DoActor(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) sprite[iActor].zvel=lValue; return; } - SetGameVarID(lVar2, sprite[iActor].zvel,g_i,g_p); + Gv_SetVar(lVar2, sprite[iActor].zvel,g_i,g_p); return; case ACTOR_LOTAG: @@ -3246,7 +3246,7 @@ void DoActor(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) sprite[iActor].lotag=lValue; return; } - SetGameVarID(lVar2, sprite[iActor].lotag,g_i,g_p); + Gv_SetVar(lVar2, sprite[iActor].lotag,g_i,g_p); return; case ACTOR_HITAG: @@ -3255,7 +3255,7 @@ void DoActor(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) sprite[iActor].hitag=lValue; return; } - SetGameVarID(lVar2, sprite[iActor].hitag,g_i,g_p); + Gv_SetVar(lVar2, sprite[iActor].hitag,g_i,g_p); return; case ACTOR_EXTRA: @@ -3264,169 +3264,169 @@ void DoActor(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) sprite[iActor].extra=lValue; return; } - SetGameVarID(lVar2, sprite[iActor].extra,g_i,g_p); + Gv_SetVar(lVar2, sprite[iActor].extra,g_i,g_p); return; case ACTOR_HTCGG: if (iSet) { - hittype[iActor].cgg=lValue; + ActorExtra[iActor].cgg=lValue; return; } - SetGameVarID(lVar2, hittype[iActor].cgg, g_i, g_p); + Gv_SetVar(lVar2, ActorExtra[iActor].cgg, g_i, g_p); return; case ACTOR_HTPICNUM : if (iSet) { - hittype[iActor].picnum=lValue; + ActorExtra[iActor].picnum=lValue; return; } - SetGameVarID(lVar2, hittype[iActor].picnum, g_i, g_p); + Gv_SetVar(lVar2, ActorExtra[iActor].picnum, g_i, g_p); return; case ACTOR_HTANG: if (iSet) { - hittype[iActor].ang=lValue; + ActorExtra[iActor].ang=lValue; return; } - SetGameVarID(lVar2, hittype[iActor].ang, g_i, g_p); + Gv_SetVar(lVar2, ActorExtra[iActor].ang, g_i, g_p); return; case ACTOR_HTEXTRA: if (iSet) { - hittype[iActor].extra=lValue; + ActorExtra[iActor].extra=lValue; return; } - SetGameVarID(lVar2,hittype[iActor].extra, g_i, g_p); + Gv_SetVar(lVar2,ActorExtra[iActor].extra, g_i, g_p); return; case ACTOR_HTOWNER: if (iSet) { - hittype[iActor].owner=lValue; + ActorExtra[iActor].owner=lValue; return; } - SetGameVarID(lVar2,hittype[iActor].owner, g_i, g_p); + Gv_SetVar(lVar2,ActorExtra[iActor].owner, g_i, g_p); return; case ACTOR_HTMOVFLAG: if (iSet) { - hittype[iActor].movflag=lValue; + ActorExtra[iActor].movflag=lValue; return; } - SetGameVarID(lVar2,hittype[iActor].movflag, g_i, g_p); + Gv_SetVar(lVar2,ActorExtra[iActor].movflag, g_i, g_p); return; case ACTOR_HTTEMPANG: if (iSet) { - hittype[iActor].tempang=lValue; + ActorExtra[iActor].tempang=lValue; return; } - SetGameVarID(lVar2,hittype[iActor].tempang, g_i, g_p); + Gv_SetVar(lVar2,ActorExtra[iActor].tempang, g_i, g_p); return; case ACTOR_HTACTORSTAYPUT: if (iSet) { - hittype[iActor].actorstayput=lValue; + ActorExtra[iActor].actorstayput=lValue; return; } - SetGameVarID(lVar2,hittype[iActor].actorstayput, g_i, g_p); + Gv_SetVar(lVar2,ActorExtra[iActor].actorstayput, g_i, g_p); return; case ACTOR_HTDISPICNUM: if (iSet) { - hittype[iActor].dispicnum=lValue; + ActorExtra[iActor].dispicnum=lValue; return; } - SetGameVarID(lVar2,hittype[iActor].dispicnum, g_i, g_p); + Gv_SetVar(lVar2,ActorExtra[iActor].dispicnum, g_i, g_p); return; case ACTOR_HTTIMETOSLEEP: if (iSet) { - hittype[iActor].timetosleep=lValue; + ActorExtra[iActor].timetosleep=lValue; return; } - SetGameVarID(lVar2,hittype[iActor].timetosleep, g_i, g_p); + Gv_SetVar(lVar2,ActorExtra[iActor].timetosleep, g_i, g_p); return; case ACTOR_HTFLOORZ: if (iSet) { - hittype[iActor].floorz=lValue; + ActorExtra[iActor].floorz=lValue; return; } - SetGameVarID(lVar2,hittype[iActor].floorz, g_i, g_p); + Gv_SetVar(lVar2,ActorExtra[iActor].floorz, g_i, g_p); return; case ACTOR_HTCEILINGZ: if (iSet) { - hittype[iActor].ceilingz=lValue; + ActorExtra[iActor].ceilingz=lValue; return; } - SetGameVarID(lVar2,hittype[iActor].ceilingz, g_i, g_p); + Gv_SetVar(lVar2,ActorExtra[iActor].ceilingz, g_i, g_p); return; case ACTOR_HTLASTVX: if (iSet) { - hittype[iActor].lastvx=lValue; + ActorExtra[iActor].lastvx=lValue; return; } - SetGameVarID(lVar2,hittype[iActor].lastvx, g_i, g_p); + Gv_SetVar(lVar2,ActorExtra[iActor].lastvx, g_i, g_p); return; case ACTOR_HTLASTVY: if (iSet) { - hittype[iActor].lastvy=lValue; + ActorExtra[iActor].lastvy=lValue; return; } - SetGameVarID(lVar2,hittype[iActor].lastvy, g_i, g_p); + Gv_SetVar(lVar2,ActorExtra[iActor].lastvy, g_i, g_p); return; case ACTOR_HTBPOSX: if (iSet) { - hittype[iActor].bposx=lValue; + ActorExtra[iActor].bposx=lValue; return; } - SetGameVarID(lVar2,hittype[iActor].bposx, g_i, g_p); + Gv_SetVar(lVar2,ActorExtra[iActor].bposx, g_i, g_p); return; case ACTOR_HTBPOSY: if (iSet) { - hittype[iActor].bposy=lValue; + ActorExtra[iActor].bposy=lValue; return; } - SetGameVarID(lVar2,hittype[iActor].bposy, g_i, g_p); + Gv_SetVar(lVar2,ActorExtra[iActor].bposy, g_i, g_p); return; case ACTOR_HTBPOSZ: if (iSet) { - hittype[iActor].bposz=lValue; + ActorExtra[iActor].bposz=lValue; return; } - SetGameVarID(lVar2,hittype[iActor].bposz, g_i, g_p); + Gv_SetVar(lVar2,ActorExtra[iActor].bposz, g_i, g_p); return; case ACTOR_HTG_T: if (iSet) { - hittype[iActor].temp_data[lParm2]=lValue; + ActorExtra[iActor].temp_data[lParm2]=lValue; return; } - SetGameVarID(lVar2, hittype[iActor].temp_data[lParm2], g_i, g_p); + Gv_SetVar(lVar2, ActorExtra[iActor].temp_data[lParm2], g_i, g_p); return; case ACTOR_ANGOFF: @@ -3435,7 +3435,7 @@ void DoActor(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) spriteext[iActor].angoff=lValue; return; } - SetGameVarID(lVar2,spriteext[iActor].angoff, g_i, g_p); + Gv_SetVar(lVar2,spriteext[iActor].angoff, g_i, g_p); return; case ACTOR_PITCH: @@ -3444,7 +3444,7 @@ void DoActor(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) spriteext[iActor].pitch=lValue; return; } - SetGameVarID(lVar2,spriteext[iActor].pitch, g_i, g_p); + Gv_SetVar(lVar2,spriteext[iActor].pitch, g_i, g_p); return; case ACTOR_ROLL: @@ -3453,7 +3453,7 @@ void DoActor(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) spriteext[iActor].roll=lValue; return; } - SetGameVarID(lVar2,spriteext[iActor].roll, g_i, g_p); + Gv_SetVar(lVar2,spriteext[iActor].roll, g_i, g_p); return; case ACTOR_MDXOFF: @@ -3462,7 +3462,7 @@ void DoActor(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) spriteext[iActor].xoff=lValue; return; } - SetGameVarID(lVar2,spriteext[iActor].xoff, g_i, g_p); + Gv_SetVar(lVar2,spriteext[iActor].xoff, g_i, g_p); return; case ACTOR_MDYOFF: @@ -3471,7 +3471,7 @@ void DoActor(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) spriteext[iActor].yoff=lValue; return; } - SetGameVarID(lVar2,spriteext[iActor].yoff, g_i, g_p); + Gv_SetVar(lVar2,spriteext[iActor].yoff, g_i, g_p); return; case ACTOR_MDZOFF: @@ -3480,7 +3480,7 @@ void DoActor(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) spriteext[iActor].zoff=lValue; return; } - SetGameVarID(lVar2,spriteext[iActor].zoff, g_i, g_p); + Gv_SetVar(lVar2,spriteext[iActor].zoff, g_i, g_p); return; case ACTOR_MDFLAGS: @@ -3489,7 +3489,7 @@ void DoActor(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) spriteext[iActor].flags=lValue; return; } - SetGameVarID(lVar2,spriteext[iActor].flags, g_i, g_p); + Gv_SetVar(lVar2,spriteext[iActor].flags, g_i, g_p); return; case ACTOR_XPANNING: @@ -3498,7 +3498,7 @@ void DoActor(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) spriteext[iActor].xpanning=lValue; return; } - SetGameVarID(lVar2, spriteext[iActor].xpanning,g_i,g_p); + Gv_SetVar(lVar2, spriteext[iActor].xpanning,g_i,g_p); return; case ACTOR_YPANNING: @@ -3507,16 +3507,16 @@ void DoActor(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) spriteext[iActor].ypanning=lValue; return; } - SetGameVarID(lVar2, spriteext[iActor].ypanning,g_i,g_p); + Gv_SetVar(lVar2, spriteext[iActor].ypanning,g_i,g_p); return; case ACTOR_HTFLAGS: if (iSet) { - hittype[iActor].flags=lValue; + ActorExtra[iActor].flags=lValue; return; } - SetGameVarID(lVar2,hittype[iActor].flags, g_i, g_p); + Gv_SetVar(lVar2,ActorExtra[iActor].flags, g_i, g_p); return; default: @@ -3524,27 +3524,27 @@ void DoActor(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) } } -void DoTsprite(int iSet, int lVar1, int lLabelID, int lVar2) +void X_AccessTsprite(int iSet, int lVar1, int lLabelID, int lVar2) { int lValue=0; int iActor=g_i; if (lVar1 != g_iThisActorID) - iActor=GetGameVarID(lVar1, g_i, g_p); + iActor=Gv_GetVar(lVar1, g_i, g_p); - if ((iActor < 0 || iActor >= MAXSPRITES) && checkCON) + if ((iActor < 0 || iActor >= MAXSPRITES) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "invalid target sprite (%d) %d %d\n",line_num,keyw[g_tw],iActor,g_i,g_sp->picnum); + OSD_Printf(CON_ERROR "invalid target sprite (%d) %d %d\n",g_errorLineNum,keyw[g_tw],iActor,g_i,g_sp->picnum); insptr += (lVar2 == MAXGAMEVARS); return; } if (iSet) - lValue=GetGameVarID(lVar2, g_i, g_p); + lValue=Gv_GetVar(lVar2, g_i, g_p); - if ((!spriteext[iActor].tspr) && checkCON) + if ((!spriteext[iActor].tspr) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "Internal bug, tsprite is unavailable\n",line_num,keyw[g_tw]); + OSD_Printf(CON_ERROR "Internal bug, tsprite is unavailable\n",g_errorLineNum,keyw[g_tw]); return; } @@ -3556,7 +3556,7 @@ void DoTsprite(int iSet, int lVar1, int lLabelID, int lVar2) spriteext[iActor].tspr->x=lValue; return; } - SetGameVarID(lVar2, spriteext[iActor].tspr->x,g_i,g_p); + Gv_SetVar(lVar2, spriteext[iActor].tspr->x,g_i,g_p); return; case ACTOR_Y: @@ -3565,7 +3565,7 @@ void DoTsprite(int iSet, int lVar1, int lLabelID, int lVar2) spriteext[iActor].tspr->y=lValue; return; } - SetGameVarID(lVar2, spriteext[iActor].tspr->y,g_i,g_p); + Gv_SetVar(lVar2, spriteext[iActor].tspr->y,g_i,g_p); return; case ACTOR_Z: @@ -3574,7 +3574,7 @@ void DoTsprite(int iSet, int lVar1, int lLabelID, int lVar2) spriteext[iActor].tspr->z=lValue; return; } - SetGameVarID(lVar2, spriteext[iActor].tspr->z,g_i,g_p); + Gv_SetVar(lVar2, spriteext[iActor].tspr->z,g_i,g_p); return; case ACTOR_CSTAT: @@ -3583,7 +3583,7 @@ void DoTsprite(int iSet, int lVar1, int lLabelID, int lVar2) spriteext[iActor].tspr->cstat=lValue; return; } - SetGameVarID(lVar2, spriteext[iActor].tspr->cstat,g_i,g_p); + Gv_SetVar(lVar2, spriteext[iActor].tspr->cstat,g_i,g_p); return; case ACTOR_PICNUM: @@ -3592,7 +3592,7 @@ void DoTsprite(int iSet, int lVar1, int lLabelID, int lVar2) spriteext[iActor].tspr->picnum=lValue; return; } - SetGameVarID(lVar2, spriteext[iActor].tspr->picnum,g_i,g_p); + Gv_SetVar(lVar2, spriteext[iActor].tspr->picnum,g_i,g_p); return; case ACTOR_SHADE: @@ -3601,7 +3601,7 @@ void DoTsprite(int iSet, int lVar1, int lLabelID, int lVar2) spriteext[iActor].tspr->shade=lValue; return; } - SetGameVarID(lVar2, spriteext[iActor].tspr->shade,g_i,g_p); + Gv_SetVar(lVar2, spriteext[iActor].tspr->shade,g_i,g_p); return; case ACTOR_PAL: @@ -3610,7 +3610,7 @@ void DoTsprite(int iSet, int lVar1, int lLabelID, int lVar2) spriteext[iActor].tspr->pal=lValue; return; } - SetGameVarID(lVar2, spriteext[iActor].tspr->pal,g_i,g_p); + Gv_SetVar(lVar2, spriteext[iActor].tspr->pal,g_i,g_p); return; case ACTOR_CLIPDIST: @@ -3619,7 +3619,7 @@ void DoTsprite(int iSet, int lVar1, int lLabelID, int lVar2) spriteext[iActor].tspr->clipdist=lValue; return; } - SetGameVarID(lVar2, spriteext[iActor].tspr->clipdist,g_i,g_p); + Gv_SetVar(lVar2, spriteext[iActor].tspr->clipdist,g_i,g_p); return; case ACTOR_DETAIL: @@ -3628,7 +3628,7 @@ void DoTsprite(int iSet, int lVar1, int lLabelID, int lVar2) spriteext[iActor].tspr->filler=lValue; return; } - SetGameVarID(lVar2, spriteext[iActor].tspr->filler,g_i,g_p); + Gv_SetVar(lVar2, spriteext[iActor].tspr->filler,g_i,g_p); return; case ACTOR_XREPEAT: @@ -3637,7 +3637,7 @@ void DoTsprite(int iSet, int lVar1, int lLabelID, int lVar2) spriteext[iActor].tspr->xrepeat=lValue; return; } - SetGameVarID(lVar2, spriteext[iActor].tspr->xrepeat,g_i,g_p); + Gv_SetVar(lVar2, spriteext[iActor].tspr->xrepeat,g_i,g_p); return; case ACTOR_YREPEAT: @@ -3646,7 +3646,7 @@ void DoTsprite(int iSet, int lVar1, int lLabelID, int lVar2) spriteext[iActor].tspr->yrepeat=lValue; return; } - SetGameVarID(lVar2, spriteext[iActor].tspr->yrepeat,g_i,g_p); + Gv_SetVar(lVar2, spriteext[iActor].tspr->yrepeat,g_i,g_p); return; case ACTOR_XOFFSET: @@ -3655,7 +3655,7 @@ void DoTsprite(int iSet, int lVar1, int lLabelID, int lVar2) spriteext[iActor].tspr->xoffset=lValue; return; } - SetGameVarID(lVar2, spriteext[iActor].tspr->xoffset,g_i,g_p); + Gv_SetVar(lVar2, spriteext[iActor].tspr->xoffset,g_i,g_p); return; case ACTOR_YOFFSET: @@ -3664,7 +3664,7 @@ void DoTsprite(int iSet, int lVar1, int lLabelID, int lVar2) spriteext[iActor].tspr->yoffset=lValue; return; } - SetGameVarID(lVar2, spriteext[iActor].tspr->yoffset,g_i,g_p); + Gv_SetVar(lVar2, spriteext[iActor].tspr->yoffset,g_i,g_p); return; case ACTOR_SECTNUM: @@ -3673,7 +3673,7 @@ void DoTsprite(int iSet, int lVar1, int lLabelID, int lVar2) spriteext[iActor].tspr->sectnum=lValue; return; } - SetGameVarID(lVar2, spriteext[iActor].tspr->sectnum,g_i,g_p); + Gv_SetVar(lVar2, spriteext[iActor].tspr->sectnum,g_i,g_p); return; case ACTOR_STATNUM: @@ -3682,7 +3682,7 @@ void DoTsprite(int iSet, int lVar1, int lLabelID, int lVar2) spriteext[iActor].tspr->statnum=lValue; return; } - SetGameVarID(lVar2, spriteext[iActor].tspr->statnum,g_i,g_p); + Gv_SetVar(lVar2, spriteext[iActor].tspr->statnum,g_i,g_p); return; case ACTOR_ANG: @@ -3691,7 +3691,7 @@ void DoTsprite(int iSet, int lVar1, int lLabelID, int lVar2) spriteext[iActor].tspr->ang=lValue; return; } - SetGameVarID(lVar2, spriteext[iActor].tspr->ang,g_i,g_p); + Gv_SetVar(lVar2, spriteext[iActor].tspr->ang,g_i,g_p); return; case ACTOR_OWNER: @@ -3700,7 +3700,7 @@ void DoTsprite(int iSet, int lVar1, int lLabelID, int lVar2) spriteext[iActor].tspr->owner=lValue; return; } - SetGameVarID(lVar2, spriteext[iActor].tspr->owner,g_i,g_p); + Gv_SetVar(lVar2, spriteext[iActor].tspr->owner,g_i,g_p); return; #if 1 @@ -3710,7 +3710,7 @@ void DoTsprite(int iSet, int lVar1, int lLabelID, int lVar2) spriteext[iActor].tspr->xvel=lValue; return; } - SetGameVarID(lVar2, spriteext[iActor].tspr->xvel,g_i,g_p); + Gv_SetVar(lVar2, spriteext[iActor].tspr->xvel,g_i,g_p); return; case ACTOR_YVEL: @@ -3719,7 +3719,7 @@ void DoTsprite(int iSet, int lVar1, int lLabelID, int lVar2) spriteext[iActor].tspr->yvel=lValue; return; } - SetGameVarID(lVar2, spriteext[iActor].tspr->yvel,g_i,g_p); + Gv_SetVar(lVar2, spriteext[iActor].tspr->yvel,g_i,g_p); return; case ACTOR_ZVEL: @@ -3728,7 +3728,7 @@ void DoTsprite(int iSet, int lVar1, int lLabelID, int lVar2) spriteext[iActor].tspr->zvel=lValue; return; } - SetGameVarID(lVar2, spriteext[iActor].tspr->zvel,g_i,g_p); + Gv_SetVar(lVar2, spriteext[iActor].tspr->zvel,g_i,g_p); return; case ACTOR_LOTAG: @@ -3737,7 +3737,7 @@ void DoTsprite(int iSet, int lVar1, int lLabelID, int lVar2) spriteext[iActor].tspr->lotag=lValue; return; } - SetGameVarID(lVar2, spriteext[iActor].tspr->lotag,g_i,g_p); + Gv_SetVar(lVar2, spriteext[iActor].tspr->lotag,g_i,g_p); return; case ACTOR_HITAG: @@ -3746,7 +3746,7 @@ void DoTsprite(int iSet, int lVar1, int lLabelID, int lVar2) spriteext[iActor].tspr->hitag=lValue; return; } - SetGameVarID(lVar2, spriteext[iActor].tspr->hitag,g_i,g_p); + Gv_SetVar(lVar2, spriteext[iActor].tspr->hitag,g_i,g_p); return; case ACTOR_EXTRA: @@ -3755,7 +3755,7 @@ void DoTsprite(int iSet, int lVar1, int lLabelID, int lVar2) spriteext[iActor].tspr->extra=lValue; return; } - SetGameVarID(lVar2, spriteext[iActor].tspr->extra,g_i,g_p); + Gv_SetVar(lVar2, spriteext[iActor].tspr->extra,g_i,g_p); return; #endif @@ -3764,272 +3764,272 @@ void DoTsprite(int iSet, int lVar1, int lLabelID, int lVar2) } } -void DoProjectile(int iSet, int lVar1, int lLabelID, int lVar2) +void X_AccessProjectile(int iSet, int lVar1, int lLabelID, int lVar2) { int lValue=0; - if ((lVar1 < 0 || lVar1 >= MAXTILES) && checkCON) + if ((lVar1 < 0 || lVar1 >= MAXTILES) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "invalid tile (%d)\n",line_num,keyw[g_tw],lVar1); + OSD_Printf(CON_ERROR "invalid tile (%d)\n",g_errorLineNum,keyw[g_tw],lVar1); insptr += (lVar2 == MAXGAMEVARS); return; } if (iSet) - lValue=GetGameVarID(lVar2, g_i, g_p); + lValue=Gv_GetVar(lVar2, g_i, g_p); switch (lLabelID) { case PROJ_WORKSLIKE: if (iSet) { - projectile[lVar1].workslike=lValue; + ProjectileData[lVar1].workslike=lValue; return; } - SetGameVarID(lVar2, projectile[lVar1].workslike, g_i, g_p); + Gv_SetVar(lVar2, ProjectileData[lVar1].workslike, g_i, g_p); return; case PROJ_SPAWNS: if (iSet) { - projectile[lVar1].spawns=lValue; + ProjectileData[lVar1].spawns=lValue; return; } - SetGameVarID(lVar2, projectile[lVar1].spawns, g_i, g_p); + Gv_SetVar(lVar2, ProjectileData[lVar1].spawns, g_i, g_p); return; case PROJ_SXREPEAT: if (iSet) { - projectile[lVar1].sxrepeat=lValue; + ProjectileData[lVar1].sxrepeat=lValue; return; } - SetGameVarID(lVar2, projectile[lVar1].sxrepeat, g_i, g_p); + Gv_SetVar(lVar2, ProjectileData[lVar1].sxrepeat, g_i, g_p); return; case PROJ_SYREPEAT: if (iSet) { - projectile[lVar1].syrepeat=lValue; + ProjectileData[lVar1].syrepeat=lValue; return; } - SetGameVarID(lVar2, projectile[lVar1].syrepeat, g_i, g_p); + Gv_SetVar(lVar2, ProjectileData[lVar1].syrepeat, g_i, g_p); return; case PROJ_SOUND: if (iSet) { - projectile[lVar1].sound=lValue; + ProjectileData[lVar1].sound=lValue; return; } - SetGameVarID(lVar2, projectile[lVar1].sound, g_i, g_p); + Gv_SetVar(lVar2, ProjectileData[lVar1].sound, g_i, g_p); return; case PROJ_ISOUND: if (iSet) { - projectile[lVar1].isound=lValue; + ProjectileData[lVar1].isound=lValue; return; } - SetGameVarID(lVar2, projectile[lVar1].isound, g_i, g_p); + Gv_SetVar(lVar2, ProjectileData[lVar1].isound, g_i, g_p); return; case PROJ_VEL: if (iSet) { - projectile[lVar1].vel=lValue; + ProjectileData[lVar1].vel=lValue; return; } - SetGameVarID(lVar2, projectile[lVar1].vel, g_i, g_p); + Gv_SetVar(lVar2, ProjectileData[lVar1].vel, g_i, g_p); return; case PROJ_EXTRA: if (iSet) { - projectile[lVar1].extra=lValue; + ProjectileData[lVar1].extra=lValue; return; } - SetGameVarID(lVar2, projectile[lVar1].extra, g_i, g_p); + Gv_SetVar(lVar2, ProjectileData[lVar1].extra, g_i, g_p); return; case PROJ_DECAL: if (iSet) { - projectile[lVar1].decal=lValue; + ProjectileData[lVar1].decal=lValue; return; } - SetGameVarID(lVar2, projectile[lVar1].decal, g_i, g_p); + Gv_SetVar(lVar2, ProjectileData[lVar1].decal, g_i, g_p); return; case PROJ_TRAIL: if (iSet) { - projectile[lVar1].trail=lValue; + ProjectileData[lVar1].trail=lValue; return; } - SetGameVarID(lVar2, projectile[lVar1].trail, g_i, g_p); + Gv_SetVar(lVar2, ProjectileData[lVar1].trail, g_i, g_p); return; case PROJ_TXREPEAT: if (iSet) { - projectile[lVar1].txrepeat=lValue; + ProjectileData[lVar1].txrepeat=lValue; return; } - SetGameVarID(lVar2, projectile[lVar1].txrepeat, g_i, g_p); + Gv_SetVar(lVar2, ProjectileData[lVar1].txrepeat, g_i, g_p); return; case PROJ_TYREPEAT: if (iSet) { - projectile[lVar1].tyrepeat=lValue; + ProjectileData[lVar1].tyrepeat=lValue; return; } - SetGameVarID(lVar2, projectile[lVar1].tyrepeat, g_i, g_p); + Gv_SetVar(lVar2, ProjectileData[lVar1].tyrepeat, g_i, g_p); return; case PROJ_TOFFSET: if (iSet) { - projectile[lVar1].toffset=lValue; + ProjectileData[lVar1].toffset=lValue; return; } - SetGameVarID(lVar2, projectile[lVar1].toffset, g_i, g_p); + Gv_SetVar(lVar2, ProjectileData[lVar1].toffset, g_i, g_p); return; case PROJ_TNUM: if (iSet) { - projectile[lVar1].tnum=lValue; + ProjectileData[lVar1].tnum=lValue; return; } - SetGameVarID(lVar2, projectile[lVar1].tnum, g_i, g_p); + Gv_SetVar(lVar2, ProjectileData[lVar1].tnum, g_i, g_p); return; case PROJ_DROP: if (iSet) { - projectile[lVar1].drop=lValue; + ProjectileData[lVar1].drop=lValue; return; } - SetGameVarID(lVar2, projectile[lVar1].drop, g_i, g_p); + Gv_SetVar(lVar2, ProjectileData[lVar1].drop, g_i, g_p); return; case PROJ_CSTAT: if (iSet) { - projectile[lVar1].cstat=lValue; + ProjectileData[lVar1].cstat=lValue; return; } - SetGameVarID(lVar2, projectile[lVar1].cstat, g_i, g_p); + Gv_SetVar(lVar2, ProjectileData[lVar1].cstat, g_i, g_p); return; case PROJ_CLIPDIST: if (iSet) { - projectile[lVar1].clipdist=lValue; + ProjectileData[lVar1].clipdist=lValue; return; } - SetGameVarID(lVar2, projectile[lVar1].clipdist, g_i, g_p); + Gv_SetVar(lVar2, ProjectileData[lVar1].clipdist, g_i, g_p); return; case PROJ_SHADE: if (iSet) { - projectile[lVar1].shade=lValue; + ProjectileData[lVar1].shade=lValue; return; } - SetGameVarID(lVar2, projectile[lVar1].shade, g_i, g_p); + Gv_SetVar(lVar2, ProjectileData[lVar1].shade, g_i, g_p); return; case PROJ_XREPEAT: if (iSet) { - projectile[lVar1].xrepeat=lValue; + ProjectileData[lVar1].xrepeat=lValue; return; } - SetGameVarID(lVar2, projectile[lVar1].xrepeat, g_i, g_p); + Gv_SetVar(lVar2, ProjectileData[lVar1].xrepeat, g_i, g_p); return; case PROJ_YREPEAT: if (iSet) { - projectile[lVar1].yrepeat=lValue; + ProjectileData[lVar1].yrepeat=lValue; return; } - SetGameVarID(lVar2, projectile[lVar1].yrepeat, g_i, g_p); + Gv_SetVar(lVar2, ProjectileData[lVar1].yrepeat, g_i, g_p); return; case PROJ_PAL: if (iSet) { - projectile[lVar1].pal=lValue; + ProjectileData[lVar1].pal=lValue; return; } - SetGameVarID(lVar2, projectile[lVar1].pal, g_i, g_p); + Gv_SetVar(lVar2, ProjectileData[lVar1].pal, g_i, g_p); return; case PROJ_EXTRA_RAND: if (iSet) { - projectile[lVar1].extra_rand=lValue; + ProjectileData[lVar1].extra_rand=lValue; return; } - SetGameVarID(lVar2, projectile[lVar1].extra_rand, g_i, g_p); + Gv_SetVar(lVar2, ProjectileData[lVar1].extra_rand, g_i, g_p); return; case PROJ_HITRADIUS: if (iSet) { - projectile[lVar1].hitradius=lValue; + ProjectileData[lVar1].hitradius=lValue; return; } - SetGameVarID(lVar2, projectile[lVar1].hitradius, g_i, g_p); + Gv_SetVar(lVar2, ProjectileData[lVar1].hitradius, g_i, g_p); return; case PROJ_VEL_MULT: if (iSet) { - projectile[lVar1].velmult=lValue; + ProjectileData[lVar1].velmult=lValue; return; } - SetGameVarID(lVar2, projectile[lVar1].velmult, g_i, g_p); + Gv_SetVar(lVar2, ProjectileData[lVar1].velmult, g_i, g_p); return; case PROJ_OFFSET: if (iSet) { - projectile[lVar1].offset=lValue; + ProjectileData[lVar1].offset=lValue; return; } - SetGameVarID(lVar2, projectile[lVar1].offset, g_i, g_p); + Gv_SetVar(lVar2, ProjectileData[lVar1].offset, g_i, g_p); return; case PROJ_BOUNCES: if (iSet) { - projectile[lVar1].bounces=lValue; + ProjectileData[lVar1].bounces=lValue; return; } - SetGameVarID(lVar2, projectile[lVar1].bounces, g_i, g_p); + Gv_SetVar(lVar2, ProjectileData[lVar1].bounces, g_i, g_p); return; case PROJ_BSOUND: if (iSet) { - projectile[lVar1].bsound=lValue; + ProjectileData[lVar1].bsound=lValue; return; } - SetGameVarID(lVar2, projectile[lVar1].bsound, g_i, g_p); + Gv_SetVar(lVar2, ProjectileData[lVar1].bsound, g_i, g_p); return; case PROJ_RANGE: if (iSet) { - projectile[lVar1].range=lValue; + ProjectileData[lVar1].range=lValue; return; } - SetGameVarID(lVar2, projectile[lVar1].range, g_i, g_p); + Gv_SetVar(lVar2, ProjectileData[lVar1].range, g_i, g_p); return; default: diff --git a/polymer/eduke32/source/gamevars.c b/polymer/eduke32/source/gamevars.c index 410528347..a221e8204 100644 --- a/polymer/eduke32/source/gamevars.c +++ b/polymer/eduke32/source/gamevars.c @@ -29,13 +29,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern int g_i,g_p; extern int OSD_errors; -void ResetPointerVars(void); -extern void FreeMapState(int mapnum); -static void FreeGameVars(void) /* called from ReadGameVars() and ResetGameVars() */ +void Gv_RefreshPointers(void); +extern void G_FreeMapState(int mapnum); +static void Gv_Free(void) /* called from Gv_ReadSave() and Gv_ResetVarsToDefault() */ { // call this function as many times as needed. int i=(MAXGAMEVARS-1); - // AddLog("FreeGameVars"); + // AddLog("Gv_Free"); for (;i>=0;i--) { if (aGameVars[i].plValues) @@ -49,18 +49,18 @@ static void FreeGameVars(void) /* called from ReadGameVars() and ResetGameVars() aGameArrays[i].plValues=NULL; aGameArrays[i].bReset=1; } - iGameVarCount=iGameArrayCount=0; + g_gameVarCount=g_gameArrayCount=0; HASH_init(&gamevarH); HASH_init(&arrayH); return; } -static void ClearGameVars(void) +static void Gv_Clear(void) { // only call this function ONCE... int i=(MAXGAMEVARS-1); - //AddLog("ClearGameVars"); + //AddLog("Gv_Clear"); for (;i>=0;i--) { @@ -85,13 +85,13 @@ static void ClearGameVars(void) aGameArrays[i].plValues=NULL; aGameArrays[i].bReset=1; } - iGameVarCount=iGameArrayCount=0; + g_gameVarCount=g_gameArrayCount=0; HASH_init(&gamevarH); HASH_init(&arrayH); return; } -int ReadGameVars(int fil) +int Gv_ReadSave(int fil) { int i, j; intptr_t l; @@ -101,12 +101,12 @@ int ReadGameVars(int fil) // AddLog("Reading gamevars from savegame"); - FreeGameVars(); // nuke 'em from orbit, it's the only way to be sure... + Gv_Free(); // nuke 'em from orbit, it's the only way to be sure... // Bsprintf(g_szBuf,"CP:%s %d",__FILE__,__LINE__); // AddLog(g_szBuf); - if (kdfread(&iGameVarCount,sizeof(iGameVarCount),1,fil) != 1) goto corrupt; - for (i=0;ivars[j]) - map[i].savedstate->vars[j] = Bcalloc(MAXPLAYERS,sizeof(intptr_t)); - if (kdfread(&map[i].savedstate->vars[j][0],sizeof(intptr_t) * MAXPLAYERS, 1, fil) != 1) goto corrupt; + if (!MapInfo[i].savedstate->vars[j]) + MapInfo[i].savedstate->vars[j] = Bcalloc(MAXPLAYERS,sizeof(intptr_t)); + if (kdfread(&MapInfo[i].savedstate->vars[j][0],sizeof(intptr_t) * MAXPLAYERS, 1, fil) != 1) goto corrupt; } - else if (aGameVars[j].dwFlags & GAMEVAR_FLAG_PERACTOR) + else if (aGameVars[j].dwFlags & GAMEVAR_PERACTOR) { - if (!map[i].savedstate->vars[j]) - map[i].savedstate->vars[j] = Bcalloc(MAXSPRITES,sizeof(intptr_t)); - if (kdfread(&map[i].savedstate->vars[j][0],sizeof(intptr_t), MAXSPRITES, fil) != MAXSPRITES) goto corrupt; + if (!MapInfo[i].savedstate->vars[j]) + MapInfo[i].savedstate->vars[j] = Bcalloc(MAXSPRITES,sizeof(intptr_t)); + if (kdfread(&MapInfo[i].savedstate->vars[j][0],sizeof(intptr_t), MAXSPRITES, fil) != MAXSPRITES) goto corrupt; } } } - else if (map[i].savedstate) + else if (MapInfo[i].savedstate) { - FreeMapState(i); + G_FreeMapState(i); } } @@ -232,7 +232,7 @@ int ReadGameVars(int fil) fp=fopen("xxx.txt","w"); if (fp) { - DumpGameVars(fp); + Gv_DumpValues(fp); fclose(fp); } AddLog("Done Dumping..."); @@ -243,7 +243,7 @@ corrupt: return(1); } -void SaveGameVars(FILE *fil) +void Gv_WriteSave(FILE *fil) { int i, j; intptr_t l; @@ -252,9 +252,9 @@ void SaveGameVars(FILE *fil) Bmemset(&savedstate,0,sizeof(savedstate)); // AddLog("Saving Game Vars to File"); - dfwrite(&iGameVarCount,sizeof(iGameVarCount),1,fil); + dfwrite(&g_gameVarCount,sizeof(g_gameVarCount),1,fil); - for (i=0;ivars[j][0],sizeof(intptr_t) * MAXPLAYERS, 1, fil); + dfwrite(&MapInfo[i].savedstate->vars[j][0],sizeof(intptr_t) * MAXPLAYERS, 1, fil); } - else if (aGameVars[j].dwFlags & GAMEVAR_FLAG_PERACTOR) + else if (aGameVars[j].dwFlags & GAMEVAR_PERACTOR) { - dfwrite(&map[i].savedstate->vars[j][0],sizeof(intptr_t) * MAXSPRITES, 1, fil); + dfwrite(&MapInfo[i].savedstate->vars[j][0],sizeof(intptr_t) * MAXSPRITES, 1, fil); } } } @@ -338,7 +338,7 @@ void SaveGameVars(FILE *fil) dfwrite(g_szBuf,l,1,fil); } -void DumpGameVars(FILE *fp) +void Gv_DumpValues(FILE *fp) { int i; if (!fp) @@ -346,9 +346,9 @@ void DumpGameVars(FILE *fp) return; } fprintf(fp,"// Current Game Definitions\n\n"); - for (i=0;i (MAXARRAYLABEL-1)) { - error++; - ReportError(-1); - initprintf("%s:%d: error: array name `%s' exceeds limit of %d characters.\n",compilefile,line_number,pszLabel, MAXARRAYLABEL); + g_numCompilerErrors++; + C_ReportError(-1); + initprintf("%s:%d: error: array name `%s' exceeds limit of %d characters.\n",g_szScriptFileName,g_lineNumber,pszLabel, MAXARRAYLABEL); return 0; } i = HASH_find(&arrayH,pszLabel); if (i >=0 && !aGameArrays[i].bReset) { // found it it's a duplicate in error - warning++; - ReportError(WARNING_DUPLICATEDEFINITION); + g_numCompilerWarnings++; + C_ReportError(WARNING_DUPLICATEDEFINITION); return 0; } - i = iGameArrayCount; + i = g_gameArrayCount; if (i < MAXGAMEARRAYS) { if (aGameArrays[i].szLabel == NULL) @@ -441,25 +441,25 @@ int AddGameArray(const char *pszLabel, int asize) aGameArrays[i].plValues=Bcalloc(asize,sizeof(intptr_t)); aGameArrays[i].size=asize; aGameVars[i].bReset=0; - iGameArrayCount++; + g_gameArrayCount++; HASH_add(&arrayH,aGameArrays[i].szLabel,i); return 1; } return 0; } -int AddGameVar(const char *pszLabel, int lValue, unsigned int dwFlags) +int Gv_SetupVar(const char *pszLabel, int lValue, unsigned int dwFlags) { int i, j; - //Bsprintf(g_szBuf,"AddGameVar(%s, %d, %X)",pszLabel, lValue, dwFlags); + //Bsprintf(g_szBuf,"Gv_SetupVar(%s, %d, %X)",pszLabel, lValue, dwFlags); //AddLog(g_szBuf); if (Bstrlen(pszLabel) > (MAXVARLABEL-1)) { - error++; - ReportError(-1); - initprintf("%s:%d: error: variable name `%s' exceeds limit of %d characters.\n",compilefile,line_number,pszLabel, MAXVARLABEL); + g_numCompilerErrors++; + C_ReportError(-1); + initprintf("%s:%d: error: variable name `%s' exceeds limit of %d characters.\n",g_szScriptFileName,g_lineNumber,pszLabel, MAXVARLABEL); return 0; } i = HASH_find(&gamevarH,pszLabel); @@ -467,35 +467,35 @@ int AddGameVar(const char *pszLabel, int lValue, unsigned int dwFlags) if (i >= 0 && !aGameVars[i].bReset) { // found it... - if (aGameVars[i].dwFlags & (GAMEVAR_FLAG_INTPTR|GAMEVAR_FLAG_SHORTPTR|GAMEVAR_FLAG_CHARPTR)) + if (aGameVars[i].dwFlags & (GAMEVAR_INTPTR|GAMEVAR_SHORTPTR|GAMEVAR_CHARPTR)) { // warning++; - // initprintf("%s:%d: warning: Internal gamevar '%s' cannot be redefined.\n",compilefile,line_number,label+(labelcnt<<6)); - ReportError(-1); - initprintf("%s:%d: warning: cannot redefine internal gamevar `%s'.\n",compilefile,line_number,label+(labelcnt<<6)); + // initprintf("%s:%d: warning: Internal gamevar '%s' cannot be redefined.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); + C_ReportError(-1); + initprintf("%s:%d: warning: cannot redefine internal gamevar `%s'.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); return 0; } - else if (!(aGameVars[i].dwFlags & GAMEVAR_FLAG_DEFAULT) && !(aGameVars[i].dwFlags & GAMEVAR_FLAG_SYSTEM)) + else if (!(aGameVars[i].dwFlags & GAMEVAR_DEFAULT) && !(aGameVars[i].dwFlags & GAMEVAR_SYSTEM)) { // it's a duplicate in error - warning++; - ReportError(WARNING_DUPLICATEDEFINITION); + g_numCompilerWarnings++; + C_ReportError(WARNING_DUPLICATEDEFINITION); return 0; } } if (i == -1) - i = iGameVarCount; + i = g_gameVarCount; if (i >= MAXGAMEVARS) { - error++; - ReportError(-1); - initprintf("%s:%d: error: too many gamevars!\n",compilefile,line_number); + g_numCompilerErrors++; + C_ReportError(-1); + initprintf("%s:%d: error: too many gamevars!\n",g_szScriptFileName,g_lineNumber); return 0; } // Set values - if ((aGameVars[i].dwFlags & GAMEVAR_FLAG_SYSTEM) == 0) + if ((aGameVars[i].dwFlags & GAMEVAR_SYSTEM) == 0) { if (aGameVars[i].szLabel == NULL) aGameVars[i].szLabel=Bcalloc(MAXVARLABEL,sizeof(char)); @@ -516,21 +516,21 @@ int AddGameVar(const char *pszLabel, int lValue, unsigned int dwFlags) aGameVars[i].lDefault=lValue; aGameVars[i].bReset=0; - if (i==iGameVarCount) + if (i==g_gameVarCount) { // we're adding a new one. HASH_replace(&gamevarH,aGameVars[i].szLabel,i); - iGameVarCount++; + g_gameVarCount++; } - if (aGameVars[i].dwFlags & GAMEVAR_FLAG_PERPLAYER) + if (aGameVars[i].dwFlags & GAMEVAR_PERPLAYER) { if (!aGameVars[i].plValues) aGameVars[i].plValues=Bcalloc(MAXPLAYERS,sizeof(intptr_t)); for (j=MAXPLAYERS-1;j>=0;j--) aGameVars[i].plValues[j]=lValue; } - else if (aGameVars[i].dwFlags & GAMEVAR_FLAG_PERACTOR) + else if (aGameVars[i].dwFlags & GAMEVAR_PERACTOR) { if (!aGameVars[i].plValues) aGameVars[i].plValues=Bcalloc(MAXSPRITES,sizeof(intptr_t)); @@ -540,24 +540,24 @@ int AddGameVar(const char *pszLabel, int lValue, unsigned int dwFlags) return 1; } -void ResetActorGameVars(int iActor) +void A_ResetGameVars(int iActor) { int i=(MAXGAMEVARS-1); // OSD_Printf("resetting vars for actor %d\n",iActor); for (;i>=0;i--) - if ((aGameVars[i].dwFlags & GAMEVAR_FLAG_PERACTOR) && !(aGameVars[i].dwFlags & GAMEVAR_FLAG_NODEFAULT)) + if ((aGameVars[i].dwFlags & GAMEVAR_PERACTOR) && !(aGameVars[i].dwFlags & GAMEVAR_NODEFAULT)) { // OSD_Printf("reset %s (%d) to %s (%d)\n",aGameVars[i].szLabel,aGameVars[i].plValues[iActor],aDefaultGameVars[i].szLabel,aDefaultGameVars[i].lValue); aGameVars[i].plValues[iActor]=aGameVars[i].lDefault; } } -inline static int GetGameID(const char *szGameLabel) +inline static int Gv_GetVarIndex(const char *szGameLabel) { return HASH_find(&gamevarH,szGameLabel); } -int GetGameVarID(int id, int iActor, int iPlayer) +int Gv_GetVar(int id, int iActor, int iPlayer) { if (id == MAXGAMEVARS) return(*insptr++); @@ -566,100 +566,104 @@ int GetGameVarID(int id, int iActor, int iPlayer) return iActor; { - int m = 1; + int neg = 0; - if (id >= iGameVarCount || id<0) + if (id >= g_gameVarCount || id<0) { if (id&(MAXGAMEVARS<<2)) { - int index=GetGameVarID(*insptr++,iActor,iPlayer); + int index=Gv_GetVar(*insptr++,iActor,iPlayer); id &= ~(MAXGAMEVARS<<2); if (id&(MAXGAMEVARS<<1)) // negative array access { - m = -m; + neg = 1; id &= ~(MAXGAMEVARS<<1); } - // OSD_Printf("GetGameVarID(): reading from array\n"); + // OSD_Printf("Gv_GetVar(): reading from array\n"); if (index >= aGameArrays[id].size || index < 0) { - OSD_Printf(CON_ERROR "GetGameVarID(): invalid array index (%s[%d])\n",line_num,keyw[g_tw],aGameArrays[id].szLabel,index); + OSD_Printf(CON_ERROR "Gv_GetVar(): invalid array index (%s[%d])\n",g_errorLineNum,keyw[g_tw],aGameArrays[id].szLabel,index); return -1; } - return(m * aGameArrays[id].plValues[index]); + return(neg?-aGameArrays[id].plValues[index]:aGameArrays[id].plValues[index]); } if ((id&(MAXGAMEVARS<<1)) == 0) { - OSD_Printf(CON_ERROR "GetGameVarID(): invalid gamevar ID (%d)\n",line_num,keyw[g_tw],id); + OSD_Printf(CON_ERROR "Gv_GetVar(): invalid gamevar ID (%d)\n",g_errorLineNum,keyw[g_tw],id); return -1; } - m = -m; + neg = 1; id &= ~(MAXGAMEVARS<<1); } - if (aGameVars[id].dwFlags & GAMEVAR_FLAG_PERPLAYER) + if (aGameVars[id].dwFlags & GAMEVAR_PERPLAYER) { // for the current player if (iPlayer < 0 || iPlayer >= MAXPLAYERS) { - OSD_Printf(CON_ERROR "GetGameVarID(): invalid player ID (%d)\n",line_num,keyw[g_tw],iPlayer); + OSD_Printf(CON_ERROR "Gv_GetVar(): invalid player ID (%d)\n",g_errorLineNum,keyw[g_tw],iPlayer); return -1; } - return(m * aGameVars[id].plValues[iPlayer]); + return(neg?-aGameVars[id].plValues[iPlayer]:aGameVars[id].plValues[iPlayer]); } - if (aGameVars[id].dwFlags & GAMEVAR_FLAG_PERACTOR) + if (aGameVars[id].dwFlags & GAMEVAR_PERACTOR) { // for the current actor if (iActor < 0 || iActor >= MAXSPRITES) { - OSD_Printf(CON_ERROR "GetGameVarID(): invalid sprite ID (%d)\n",line_num,keyw[g_tw],iActor); + OSD_Printf(CON_ERROR "Gv_GetVar(): invalid sprite ID (%d)\n",g_errorLineNum,keyw[g_tw],iActor); return -1; } - return(m * aGameVars[id].plValues[iActor]); + return(neg?-aGameVars[id].plValues[iActor]:aGameVars[id].plValues[iActor]); } - if (aGameVars[id].dwFlags & GAMEVAR_FLAG_INTPTR) - return(m * (*((int*)aGameVars[id].lValue))); + if (!(aGameVars[id].dwFlags & (GAMEVAR_INTPTR|GAMEVAR_SHORTPTR|GAMEVAR_CHARPTR))) + return(neg?-aGameVars[id].lValue:aGameVars[id].lValue); - if (aGameVars[id].dwFlags & GAMEVAR_FLAG_SHORTPTR) - return(m * (*((short*)aGameVars[id].lValue))); + if (aGameVars[id].dwFlags & GAMEVAR_INTPTR) + return(neg?-(*((int*)aGameVars[id].lValue)):(*((int*)aGameVars[id].lValue))); - if (aGameVars[id].dwFlags & GAMEVAR_FLAG_CHARPTR) - return(m * (*((char*)aGameVars[id].lValue))); + if (aGameVars[id].dwFlags & GAMEVAR_SHORTPTR) + return(neg?-(*((short*)aGameVars[id].lValue)):(*((short*)aGameVars[id].lValue))); - return(m * aGameVars[id].lValue); + if (aGameVars[id].dwFlags & GAMEVAR_CHARPTR) + return(neg?-(*((char*)aGameVars[id].lValue)):(*((char*)aGameVars[id].lValue))); + + OSD_Printf(CON_ERROR "Gv_GetVar(): unknown variable type (%d)\n",g_errorLineNum,keyw[g_tw],aGameVars[id].dwFlags); + return -1; } } /* void SetGameArrayID(int id,int index, int lValue) { - if (id<0 || id >= iGameArrayCount || !((index < aGameArrays[id].size)&&(index>=0))) + if (id<0 || id >= g_gameArrayCount || !((index < aGameArrays[id].size)&&(index>=0))) { - OSD_Printf(CON_ERROR "SetGameVarID(): tried to set invalid array ID (%d) or index out of bounds from sprite %d (%d), player %d\n",line_num,keyw[g_tw],id,g_i,sprite[g_i].picnum,g_p); + OSD_Printf(CON_ERROR "Gv_SetVar(): tried to set invalid array ID (%d) or index out of bounds from sprite %d (%d), player %d\n",g_errorLineNum,keyw[g_tw],id,g_i,sprite[g_i].picnum,g_p); return; } aGameArrays[id].plValues[index]=lValue; } */ -void SetGameVarID(int id, int lValue, int iActor, int iPlayer) +void Gv_SetVar(int id, int lValue, int iActor, int iPlayer) { - if (id<0 || id >= iGameVarCount) + if (id<0 || id >= g_gameVarCount) { - OSD_Printf(CON_ERROR "SetGameVarID(): tried to set invalid gamevar ID (%d) from sprite %d (%d), player %d\n",line_num,keyw[g_tw],id,g_i,sprite[g_i].picnum,g_p); + OSD_Printf(CON_ERROR "Gv_SetVar(): tried to set invalid gamevar ID (%d) from sprite %d (%d), player %d\n",g_errorLineNum,keyw[g_tw],id,g_i,sprite[g_i].picnum,g_p); return; } //Bsprintf(g_szBuf,"SGVI: %d ('%s') to %d for %d %d",id,aGameVars[id].szLabel,lValue,iActor,iPlayer); //AddLog(g_szBuf); - if (aGameVars[id].dwFlags & GAMEVAR_FLAG_PERPLAYER) + if (aGameVars[id].dwFlags & GAMEVAR_PERPLAYER) { if (iPlayer < 0 || iPlayer > MAXPLAYERS-1) { - OSD_Printf(CON_ERROR "SetGameVarID(): invalid player (%d) for per-player gamevar %s from sprite %d, player %d\n",line_num,keyw[g_tw],iPlayer,aGameVars[id].szLabel,g_i,g_p); + OSD_Printf(CON_ERROR "Gv_SetVar(): invalid player (%d) for per-player gamevar %s from sprite %d, player %d\n",g_errorLineNum,keyw[g_tw],iPlayer,aGameVars[id].szLabel,g_i,g_p); return; } // for the current player @@ -667,11 +671,11 @@ void SetGameVarID(int id, int lValue, int iActor, int iPlayer) return; } - if (aGameVars[id].dwFlags & GAMEVAR_FLAG_PERACTOR) + if (aGameVars[id].dwFlags & GAMEVAR_PERACTOR) { if (iActor < 0 || iActor > MAXSPRITES-1) { - OSD_Printf(CON_ERROR "SetGameVarID(): invalid sprite (%d) for per-actor gamevar %s from sprite %d (%d), player %d\n",line_num,keyw[g_tw],iActor,aGameVars[id].szLabel,g_i,sprite[g_i].picnum,g_p); + OSD_Printf(CON_ERROR "Gv_SetVar(): invalid sprite (%d) for per-actor gamevar %s from sprite %d (%d), player %d\n",g_errorLineNum,keyw[g_tw],iActor,aGameVars[id].szLabel,g_i,sprite[g_i].picnum,g_p); return; } // for the current actor @@ -679,57 +683,61 @@ void SetGameVarID(int id, int lValue, int iActor, int iPlayer) return; } - if (aGameVars[id].dwFlags & GAMEVAR_FLAG_INTPTR) + if (!(aGameVars[id].dwFlags & (GAMEVAR_INTPTR|GAMEVAR_SHORTPTR|GAMEVAR_CHARPTR))) + { + aGameVars[id].lValue=lValue; + return; + } + + if (aGameVars[id].dwFlags & GAMEVAR_INTPTR) { // set the value at pointer *((int*)aGameVars[id].lValue)=(int)lValue; return; } - if (aGameVars[id].dwFlags & GAMEVAR_FLAG_SHORTPTR) + if (aGameVars[id].dwFlags & GAMEVAR_SHORTPTR) { // set the value at pointer *((short*)aGameVars[id].lValue)=(short)lValue; return; } - if (aGameVars[id].dwFlags & GAMEVAR_FLAG_CHARPTR) + if (aGameVars[id].dwFlags & GAMEVAR_CHARPTR) { // set the value at pointer *((char*)aGameVars[id].lValue)=(char)lValue; return; } - - aGameVars[id].lValue=lValue; } -int GetGameVar(const char *szGameLabel, int lDefault, int iActor, int iPlayer) +int Gv_GetVarByLabel(const char *szGameLabel, int lDefault, int iActor, int iPlayer) { int i=0; i = HASH_find(&gamevarH,szGameLabel); if (i<0)return lDefault; - return GetGameVarID(i, iActor, iPlayer); + return Gv_GetVar(i, iActor, iPlayer); } -static intptr_t *GetGameValuePtr(const char *szGameLabel) +static intptr_t *Gv_GetVarDataPtr(const char *szGameLabel) { int i=0; i = HASH_find(&gamevarH,szGameLabel); if (i<0)return NULL; - if (aGameVars[i].dwFlags & (GAMEVAR_FLAG_PERACTOR | GAMEVAR_FLAG_PERPLAYER)) + if (aGameVars[i].dwFlags & (GAMEVAR_PERACTOR | GAMEVAR_PERPLAYER)) { if (!aGameVars[i].plValues) { - OSD_Printf(CON_ERROR "GetGameValuePtr(): INTERNAL ERROR: NULL array !!!\n",line_num,keyw[g_tw]); + OSD_Printf(CON_ERROR "Gv_GetVarDataPtr(): INTERNAL ERROR: NULL array !!!\n",g_errorLineNum,keyw[g_tw]); } return aGameVars[i].plValues; } return &(aGameVars[i].lValue); } -void ResetSystemDefaults(void) +void Gv_ResetSystemDefaults(void) { // call many times... @@ -743,739 +751,770 @@ void ResetSystemDefaults(void) for (i=MAX_WEAPONS-1;i>=0;i--) { Bsprintf(aszBuf,"WEAPON%d_CLIP",i); - aplWeaponClip[i][j]=GetGameVar(aszBuf,0, -1, j); + aplWeaponClip[i][j]=Gv_GetVarByLabel(aszBuf,0, -1, j); Bsprintf(aszBuf,"WEAPON%d_RELOAD",i); - aplWeaponReload[i][j]=GetGameVar(aszBuf,0, -1, j); + aplWeaponReload[i][j]=Gv_GetVarByLabel(aszBuf,0, -1, j); Bsprintf(aszBuf,"WEAPON%d_FIREDELAY",i); - aplWeaponFireDelay[i][j]=GetGameVar(aszBuf,0, -1, j); + aplWeaponFireDelay[i][j]=Gv_GetVarByLabel(aszBuf,0, -1, j); Bsprintf(aszBuf,"WEAPON%d_TOTALTIME",i); - aplWeaponTotalTime[i][j]=GetGameVar(aszBuf,0, -1, j); + aplWeaponTotalTime[i][j]=Gv_GetVarByLabel(aszBuf,0, -1, j); Bsprintf(aszBuf,"WEAPON%d_HOLDDELAY",i); - aplWeaponHoldDelay[i][j]=GetGameVar(aszBuf,0, -1, j); + aplWeaponHoldDelay[i][j]=Gv_GetVarByLabel(aszBuf,0, -1, j); Bsprintf(aszBuf,"WEAPON%d_FLAGS",i); - aplWeaponFlags[i][j]=GetGameVar(aszBuf,0, -1, j); + aplWeaponFlags[i][j]=Gv_GetVarByLabel(aszBuf,0, -1, j); Bsprintf(aszBuf,"WEAPON%d_SHOOTS",i); - aplWeaponShoots[i][j]=GetGameVar(aszBuf,0, -1, j); + aplWeaponShoots[i][j]=Gv_GetVarByLabel(aszBuf,0, -1, j); Bsprintf(aszBuf,"WEAPON%d_SPAWNTIME",i); - aplWeaponSpawnTime[i][j]=GetGameVar(aszBuf,0, -1, j); + aplWeaponSpawnTime[i][j]=Gv_GetVarByLabel(aszBuf,0, -1, j); Bsprintf(aszBuf,"WEAPON%d_SPAWN",i); - aplWeaponSpawn[i][j]=GetGameVar(aszBuf,0, -1, j); + aplWeaponSpawn[i][j]=Gv_GetVarByLabel(aszBuf,0, -1, j); Bsprintf(aszBuf,"WEAPON%d_SHOTSPERBURST",i); - aplWeaponShotsPerBurst[i][j]=GetGameVar(aszBuf,0, -1, j); + aplWeaponShotsPerBurst[i][j]=Gv_GetVarByLabel(aszBuf,0, -1, j); Bsprintf(aszBuf,"WEAPON%d_WORKSLIKE",i); - aplWeaponWorksLike[i][j]=GetGameVar(aszBuf,0, -1, j); + aplWeaponWorksLike[i][j]=Gv_GetVarByLabel(aszBuf,0, -1, j); Bsprintf(aszBuf,"WEAPON%d_INITIALSOUND",i); - aplWeaponInitialSound[i][j]=GetGameVar(aszBuf,0, -1, j); + aplWeaponInitialSound[i][j]=Gv_GetVarByLabel(aszBuf,0, -1, j); Bsprintf(aszBuf,"WEAPON%d_FIRESOUND",i); - aplWeaponFireSound[i][j]=GetGameVar(aszBuf,0, -1, j); + aplWeaponFireSound[i][j]=Gv_GetVarByLabel(aszBuf,0, -1, j); Bsprintf(aszBuf,"WEAPON%d_SOUND2TIME",i); - aplWeaponSound2Time[i][j]=GetGameVar(aszBuf,0, -1, j); + aplWeaponSound2Time[i][j]=Gv_GetVarByLabel(aszBuf,0, -1, j); Bsprintf(aszBuf,"WEAPON%d_SOUND2SOUND",i); - aplWeaponSound2Sound[i][j]=GetGameVar(aszBuf,0, -1, j); + aplWeaponSound2Sound[i][j]=Gv_GetVarByLabel(aszBuf,0, -1, j); Bsprintf(aszBuf,"WEAPON%d_RELOADSOUND1",i); - aplWeaponReloadSound1[i][j]=GetGameVar(aszBuf,0, -1, j); + aplWeaponReloadSound1[i][j]=Gv_GetVarByLabel(aszBuf,0, -1, j); Bsprintf(aszBuf,"WEAPON%d_RELOADSOUND2",i); - aplWeaponReloadSound2[i][j]=GetGameVar(aszBuf,0, -1, j); + aplWeaponReloadSound2[i][j]=Gv_GetVarByLabel(aszBuf,0, -1, j); + Bsprintf(aszBuf,"WEAPON%d_SELECTSOUND",i); + aplWeaponSelectSound[i][j]=Gv_GetVarByLabel(aszBuf,0, -1, j); } } - g_iReturnVarID=GetGameID("RETURN"); - g_iWeaponVarID=GetGameID("WEAPON"); - g_iWorksLikeVarID=GetGameID("WORKSLIKE"); - g_iZRangeVarID=GetGameID("ZRANGE"); - g_iAngRangeVarID=GetGameID("ANGRANGE"); - g_iAimAngleVarID=GetGameID("AUTOAIMANGLE"); - g_iLoTagID=GetGameID("LOTAG"); - g_iHiTagID=GetGameID("HITAG"); - g_iTextureID=GetGameID("TEXTURE"); - g_iThisActorID=GetGameID("THISACTOR"); + g_iReturnVarID=Gv_GetVarIndex("RETURN"); + g_iWeaponVarID=Gv_GetVarIndex("WEAPON"); + g_iWorksLikeVarID=Gv_GetVarIndex("WORKSLIKE"); + g_iZRangeVarID=Gv_GetVarIndex("ZRANGE"); + g_iAngRangeVarID=Gv_GetVarIndex("ANGRANGE"); + g_iAimAngleVarID=Gv_GetVarIndex("AUTOAIMANGLE"); + g_iLoTagID=Gv_GetVarIndex("LOTAG"); + g_iHiTagID=Gv_GetVarIndex("HITAG"); + g_iTextureID=Gv_GetVarIndex("TEXTURE"); + g_iThisActorID=Gv_GetVarIndex("THISACTOR"); - Bmemcpy(&projectile,&defaultprojectile,sizeof(projectile)); + Bmemcpy(&ProjectileData,&DefaultProjectileData,sizeof(ProjectileData)); //AddLog("EOF:ResetWeaponDefaults"); } -static void AddSystemVars() +static void Gv_AddSystemVars(void) { // only call ONCE char aszBuf[64]; - //AddLog("AddSystemVars"); + //AddLog("Gv_AddSystemVars"); Bsprintf(aszBuf,"WEAPON%d_WORKSLIKE",KNEE_WEAPON); - AddGameVar(aszBuf, KNEE_WEAPON, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, KNEE_WEAPON, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_CLIP",KNEE_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_RELOAD",KNEE_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_FIREDELAY",KNEE_WEAPON); - AddGameVar(aszBuf, 7, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 7, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_TOTALTIME",KNEE_WEAPON); - AddGameVar(aszBuf, 14, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 14, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_HOLDDELAY",KNEE_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_FLAGS",KNEE_WEAPON); - AddGameVar(aszBuf, WEAPON_FLAG_NOVISIBLE | WEAPON_FLAG_RANDOMRESTART | WEAPON_FLAG_AUTOMATIC, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, WEAPON_NOVISIBLE | WEAPON_RANDOMRESTART | WEAPON_AUTOMATIC, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SHOOTS",KNEE_WEAPON); - AddGameVar(aszBuf, KNEE, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, KNEE, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SPAWNTIME",KNEE_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SPAWN",KNEE_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SHOTSPERBURST",KNEE_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_INITIALSOUND",KNEE_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_FIRESOUND",KNEE_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SOUND2TIME",KNEE_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SOUND2SOUND",KNEE_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_RELOADSOUND1",KNEE_WEAPON); - AddGameVar(aszBuf, EJECT_CLIP, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, EJECT_CLIP, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_RELOADSOUND2",KNEE_WEAPON); - AddGameVar(aszBuf, INSERT_CLIP, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, INSERT_CLIP, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); + Bsprintf(aszBuf,"WEAPON%d_SELECTSOUND",KNEE_WEAPON); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); ///////////////////////////// Bsprintf(aszBuf,"WEAPON%d_WORKSLIKE",PISTOL_WEAPON); - AddGameVar(aszBuf, PISTOL_WEAPON, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, PISTOL_WEAPON, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_CLIP",PISTOL_WEAPON); - AddGameVar(aszBuf, NAM?20:12, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, NAM?20:12, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_RELOAD",PISTOL_WEAPON); - AddGameVar(aszBuf, NAM?50:27, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, NAM?50:27, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_FIREDELAY",PISTOL_WEAPON); - AddGameVar(aszBuf, 2, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 2, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_TOTALTIME",PISTOL_WEAPON); - AddGameVar(aszBuf, 5, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 5, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_HOLDDELAY",PISTOL_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_FLAGS",PISTOL_WEAPON); - AddGameVar(aszBuf, NAM?WEAPON_FLAG_HOLSTER_CLEARS_CLIP:0 | WEAPON_FLAG_RELOAD_TIMING, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, NAM?WEAPON_HOLSTER_CLEARS_CLIP:0 | WEAPON_RELOAD_TIMING, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SHOOTS",PISTOL_WEAPON); - AddGameVar(aszBuf, SHOTSPARK1, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, SHOTSPARK1, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SPAWNTIME",PISTOL_WEAPON); - AddGameVar(aszBuf, 2, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 2, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SPAWN",PISTOL_WEAPON); - AddGameVar(aszBuf, SHELL, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, SHELL, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SHOTSPERBURST",PISTOL_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_INITIALSOUND",PISTOL_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_FIRESOUND",PISTOL_WEAPON); - AddGameVar(aszBuf, PISTOL_FIRE, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, PISTOL_FIRE, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SOUND2TIME",PISTOL_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SOUND2SOUND",PISTOL_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_RELOADSOUND1",PISTOL_WEAPON); - AddGameVar(aszBuf, EJECT_CLIP, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, EJECT_CLIP, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_RELOADSOUND2",PISTOL_WEAPON); - AddGameVar(aszBuf, INSERT_CLIP, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, INSERT_CLIP, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); + Bsprintf(aszBuf,"WEAPON%d_SELECTSOUND",PISTOL_WEAPON); + Gv_SetupVar(aszBuf, INSERT_CLIP, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); ///////////////////////////// Bsprintf(aszBuf,"WEAPON%d_WORKSLIKE",SHOTGUN_WEAPON); - AddGameVar(aszBuf, SHOTGUN_WEAPON, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, SHOTGUN_WEAPON, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_CLIP",SHOTGUN_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_RELOAD",SHOTGUN_WEAPON); - AddGameVar(aszBuf, 13, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 13, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_FIREDELAY",SHOTGUN_WEAPON); - AddGameVar(aszBuf, 4, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 4, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_TOTALTIME",SHOTGUN_WEAPON); - AddGameVar(aszBuf, 30, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 30, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_HOLDDELAY",SHOTGUN_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_FLAGS",SHOTGUN_WEAPON); - AddGameVar(aszBuf, WEAPON_FLAG_CHECKATRELOAD, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, WEAPON_CHECKATRELOAD, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SHOOTS",SHOTGUN_WEAPON); - AddGameVar(aszBuf, SHOTGUN, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, SHOTGUN, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SPAWNTIME",SHOTGUN_WEAPON); - AddGameVar(aszBuf, 24, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 24, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SPAWN",SHOTGUN_WEAPON); - AddGameVar(aszBuf, SHOTGUNSHELL, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, SHOTGUNSHELL, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SHOTSPERBURST",SHOTGUN_WEAPON); - AddGameVar(aszBuf, 7, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 7, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_INITIALSOUND",SHOTGUN_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_FIRESOUND",SHOTGUN_WEAPON); - AddGameVar(aszBuf, SHOTGUN_FIRE, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, SHOTGUN_FIRE, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SOUND2TIME",SHOTGUN_WEAPON); - AddGameVar(aszBuf, 15, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 15, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SOUND2SOUND",SHOTGUN_WEAPON); - AddGameVar(aszBuf, SHOTGUN_COCK, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, SHOTGUN_COCK, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_RELOADSOUND1",SHOTGUN_WEAPON); - AddGameVar(aszBuf, EJECT_CLIP, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, EJECT_CLIP, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_RELOADSOUND2",SHOTGUN_WEAPON); - AddGameVar(aszBuf, INSERT_CLIP, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, INSERT_CLIP, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); + Bsprintf(aszBuf,"WEAPON%d_SELECTSOUND",SHOTGUN_WEAPON); + Gv_SetupVar(aszBuf, SHOTGUN_COCK, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); ///////////////////////////// Bsprintf(aszBuf,"WEAPON%d_WORKSLIKE",CHAINGUN_WEAPON); - AddGameVar(aszBuf, CHAINGUN_WEAPON, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, CHAINGUN_WEAPON, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_CLIP",CHAINGUN_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_RELOAD",CHAINGUN_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_FIREDELAY",CHAINGUN_WEAPON); - AddGameVar(aszBuf, 3, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 3, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_TOTALTIME",CHAINGUN_WEAPON); - AddGameVar(aszBuf, 12, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 12, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_HOLDDELAY",CHAINGUN_WEAPON); - AddGameVar(aszBuf, 3, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 3, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_FLAGS",CHAINGUN_WEAPON); - AddGameVar(aszBuf, WEAPON_FLAG_AUTOMATIC | WEAPON_FLAG_FIREEVERYTHIRD | WEAPON_FLAG_AMMOPERSHOT | WEAPON_FLAG_SPAWNTYPE3 | WEAPON_FLAG_RESET, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, WEAPON_AUTOMATIC | WEAPON_FIREEVERYTHIRD | WEAPON_AMMOPERSHOT | WEAPON_SPAWNTYPE3 | WEAPON_RESET, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SHOOTS",CHAINGUN_WEAPON); - AddGameVar(aszBuf, CHAINGUN, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, CHAINGUN, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SPAWNTIME",CHAINGUN_WEAPON); - AddGameVar(aszBuf, 1, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 1, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SPAWN",CHAINGUN_WEAPON); - AddGameVar(aszBuf, SHELL, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, SHELL, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SHOTSPERBURST",CHAINGUN_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_INITIALSOUND",CHAINGUN_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_FIRESOUND",CHAINGUN_WEAPON); - AddGameVar(aszBuf, CHAINGUN_FIRE, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, CHAINGUN_FIRE, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SOUND2TIME",CHAINGUN_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SOUND2SOUND",CHAINGUN_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_RELOADSOUND1",CHAINGUN_WEAPON); - AddGameVar(aszBuf, EJECT_CLIP, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, EJECT_CLIP, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_RELOADSOUND2",CHAINGUN_WEAPON); - AddGameVar(aszBuf, INSERT_CLIP, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, INSERT_CLIP, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); + Bsprintf(aszBuf,"WEAPON%d_SELECTSOUND",CHAINGUN_WEAPON); + Gv_SetupVar(aszBuf, SELECT_WEAPON, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); ///////////////////////////// Bsprintf(aszBuf,"WEAPON%d_WORKSLIKE",RPG_WEAPON); - AddGameVar(aszBuf, RPG_WEAPON, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, RPG_WEAPON, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_CLIP",RPG_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_RELOAD",RPG_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_FIREDELAY",RPG_WEAPON); - AddGameVar(aszBuf, 4, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 4, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_TOTALTIME",RPG_WEAPON); - AddGameVar(aszBuf, 20, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 20, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_HOLDDELAY",RPG_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_FLAGS",RPG_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SHOOTS",RPG_WEAPON); - AddGameVar(aszBuf, RPG, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, RPG, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SPAWNTIME",RPG_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SPAWN",RPG_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SHOTSPERBURST",RPG_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_INITIALSOUND",RPG_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_FIRESOUND",RPG_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SOUND2TIME",RPG_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SOUND2SOUND",RPG_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_RELOADSOUND1",RPG_WEAPON); - AddGameVar(aszBuf, EJECT_CLIP, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, EJECT_CLIP, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_RELOADSOUND2",RPG_WEAPON); - AddGameVar(aszBuf, INSERT_CLIP, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, INSERT_CLIP, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); + Bsprintf(aszBuf,"WEAPON%d_SELECTSOUND",RPG_WEAPON); + Gv_SetupVar(aszBuf, SELECT_WEAPON, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); ///////////////////////////// Bsprintf(aszBuf,"WEAPON%d_WORKSLIKE",HANDBOMB_WEAPON); - AddGameVar(aszBuf, HANDBOMB_WEAPON, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, HANDBOMB_WEAPON, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_CLIP",HANDBOMB_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_RELOAD",HANDBOMB_WEAPON); - AddGameVar(aszBuf, 30, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 30, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_FIREDELAY",HANDBOMB_WEAPON); - AddGameVar(aszBuf, 6, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 6, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_TOTALTIME",HANDBOMB_WEAPON); - AddGameVar(aszBuf, 19, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 19, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_HOLDDELAY",HANDBOMB_WEAPON); - AddGameVar(aszBuf, 12, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 12, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_FLAGS",HANDBOMB_WEAPON); - AddGameVar(aszBuf, WEAPON_FLAG_THROWIT, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, WEAPON_THROWIT, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SHOOTS",HANDBOMB_WEAPON); - AddGameVar(aszBuf, HEAVYHBOMB, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, HEAVYHBOMB, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SPAWNTIME",HANDBOMB_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SPAWN",HANDBOMB_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SHOTSPERBURST",HANDBOMB_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_INITIALSOUND",HANDBOMB_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_FIRESOUND",HANDBOMB_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SOUND2TIME",HANDBOMB_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SOUND2SOUND",HANDBOMB_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_RELOADSOUND1",HANDBOMB_WEAPON); - AddGameVar(aszBuf, EJECT_CLIP, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, EJECT_CLIP, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_RELOADSOUND2",HANDBOMB_WEAPON); - AddGameVar(aszBuf, INSERT_CLIP, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, INSERT_CLIP, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); + Bsprintf(aszBuf,"WEAPON%d_SELECTSOUND",HANDBOMB_WEAPON); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); ///////////////////////////// Bsprintf(aszBuf,"WEAPON%d_WORKSLIKE",SHRINKER_WEAPON); - AddGameVar(aszBuf, SHRINKER_WEAPON, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, SHRINKER_WEAPON, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_CLIP",SHRINKER_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_RELOAD",SHRINKER_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_FIREDELAY",SHRINKER_WEAPON); - AddGameVar(aszBuf, 10, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 10, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_TOTALTIME",SHRINKER_WEAPON); - AddGameVar(aszBuf, NAM?30:12, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, NAM?30:12, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_HOLDDELAY",SHRINKER_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_FLAGS",SHRINKER_WEAPON); - AddGameVar(aszBuf, WEAPON_FLAG_GLOWS, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, WEAPON_GLOWS, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SHOOTS",SHRINKER_WEAPON); - AddGameVar(aszBuf, SHRINKER, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, SHRINKER, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SPAWNTIME",SHRINKER_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SPAWN",SHRINKER_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SHOTSPERBURST",SHRINKER_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_INITIALSOUND",SHRINKER_WEAPON); - AddGameVar(aszBuf, SHRINKER_FIRE, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, SHRINKER_FIRE, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_FIRESOUND",SHRINKER_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SOUND2TIME",SHRINKER_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SOUND2SOUND",SHRINKER_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_RELOADSOUND1",SHRINKER_WEAPON); - AddGameVar(aszBuf, EJECT_CLIP, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, EJECT_CLIP, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_RELOADSOUND2",SHRINKER_WEAPON); - AddGameVar(aszBuf, INSERT_CLIP, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, INSERT_CLIP, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); + Bsprintf(aszBuf,"WEAPON%d_SELECTSOUND",SHRINKER_WEAPON); + Gv_SetupVar(aszBuf, SELECT_WEAPON, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); ///////////////////////////// Bsprintf(aszBuf,"WEAPON%d_WORKSLIKE",DEVISTATOR_WEAPON); - AddGameVar(aszBuf, DEVISTATOR_WEAPON, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, DEVISTATOR_WEAPON, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_CLIP",DEVISTATOR_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_RELOAD",DEVISTATOR_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_FIREDELAY",DEVISTATOR_WEAPON); - AddGameVar(aszBuf, 3, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 3, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_TOTALTIME",DEVISTATOR_WEAPON); - AddGameVar(aszBuf, 6, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 6, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_HOLDDELAY",DEVISTATOR_WEAPON); - AddGameVar(aszBuf, 5, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 5, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_FLAGS",DEVISTATOR_WEAPON); - AddGameVar(aszBuf, WEAPON_FLAG_FIREEVERYOTHER | WEAPON_FLAG_AMMOPERSHOT, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, WEAPON_FIREEVERYOTHER | WEAPON_AMMOPERSHOT, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SHOOTS",DEVISTATOR_WEAPON); - AddGameVar(aszBuf, RPG, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, RPG, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SPAWNTIME",DEVISTATOR_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SPAWN",DEVISTATOR_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SHOTSPERBURST",DEVISTATOR_WEAPON); - AddGameVar(aszBuf, 2, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 2, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_INITIALSOUND",DEVISTATOR_WEAPON); - AddGameVar(aszBuf, CAT_FIRE, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, CAT_FIRE, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_FIRESOUND",DEVISTATOR_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SOUND2TIME",DEVISTATOR_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SOUND2SOUND",DEVISTATOR_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_RELOADSOUND1",DEVISTATOR_WEAPON); - AddGameVar(aszBuf, EJECT_CLIP, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, EJECT_CLIP, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_RELOADSOUND2",DEVISTATOR_WEAPON); - AddGameVar(aszBuf, INSERT_CLIP, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, INSERT_CLIP, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); + Bsprintf(aszBuf,"WEAPON%d_SELECTSOUND",DEVISTATOR_WEAPON); + Gv_SetupVar(aszBuf, SELECT_WEAPON, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); ///////////////////////////// Bsprintf(aszBuf,"WEAPON%d_WORKSLIKE",TRIPBOMB_WEAPON); - AddGameVar(aszBuf, TRIPBOMB_WEAPON, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, TRIPBOMB_WEAPON, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_CLIP",TRIPBOMB_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_RELOAD",TRIPBOMB_WEAPON); - AddGameVar(aszBuf, 16, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 16, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_FIREDELAY",TRIPBOMB_WEAPON); - AddGameVar(aszBuf, 3, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 3, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_TOTALTIME",TRIPBOMB_WEAPON); - AddGameVar(aszBuf, 16, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 16, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_HOLDDELAY",TRIPBOMB_WEAPON); - AddGameVar(aszBuf, 7, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 7, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_FLAGS",TRIPBOMB_WEAPON); - AddGameVar(aszBuf, WEAPON_FLAG_STANDSTILL | WEAPON_FLAG_CHECKATRELOAD, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, WEAPON_STANDSTILL | WEAPON_CHECKATRELOAD, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SHOOTS",TRIPBOMB_WEAPON); - AddGameVar(aszBuf, HANDHOLDINGLASER, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, HANDHOLDINGLASER, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SPAWNTIME",TRIPBOMB_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SPAWN",TRIPBOMB_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SHOTSPERBURST",TRIPBOMB_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_INITIALSOUND",TRIPBOMB_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_FIRESOUND",TRIPBOMB_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SOUND2TIME",TRIPBOMB_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SOUND2SOUND",TRIPBOMB_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_RELOADSOUND1",TRIPBOMB_WEAPON); - AddGameVar(aszBuf, EJECT_CLIP, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, EJECT_CLIP, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_RELOADSOUND2",TRIPBOMB_WEAPON); - AddGameVar(aszBuf, INSERT_CLIP, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, INSERT_CLIP, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); + Bsprintf(aszBuf,"WEAPON%d_SELECTSOUND",TRIPBOMB_WEAPON); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); ///////////////////////////// Bsprintf(aszBuf,"WEAPON%d_WORKSLIKE",FREEZE_WEAPON); - AddGameVar(aszBuf, FREEZE_WEAPON, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, FREEZE_WEAPON, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_CLIP",FREEZE_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_RELOAD",FREEZE_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_FIREDELAY",FREEZE_WEAPON); - AddGameVar(aszBuf, 3, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 3, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_TOTALTIME",FREEZE_WEAPON); - AddGameVar(aszBuf, 5, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 5, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_HOLDDELAY",FREEZE_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_FLAGS",FREEZE_WEAPON); - AddGameVar(aszBuf, WEAPON_FLAG_RESET, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, WEAPON_RESET, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SHOOTS",FREEZE_WEAPON); - AddGameVar(aszBuf, FREEZEBLAST, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, FREEZEBLAST, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SPAWNTIME",FREEZE_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SPAWN",FREEZE_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SHOTSPERBURST",FREEZE_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_INITIALSOUND",FREEZE_WEAPON); - AddGameVar(aszBuf, CAT_FIRE, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, CAT_FIRE, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_FIRESOUND",FREEZE_WEAPON); - AddGameVar(aszBuf, CAT_FIRE, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, CAT_FIRE, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SOUND2TIME",FREEZE_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SOUND2SOUND",FREEZE_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_RELOADSOUND1",FREEZE_WEAPON); - AddGameVar(aszBuf, EJECT_CLIP, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, EJECT_CLIP, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_RELOADSOUND2",FREEZE_WEAPON); - AddGameVar(aszBuf, INSERT_CLIP, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, INSERT_CLIP, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); + Bsprintf(aszBuf,"WEAPON%d_SELECTSOUND",FREEZE_WEAPON); + Gv_SetupVar(aszBuf, SELECT_WEAPON, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); ///////////////////////////// Bsprintf(aszBuf,"WEAPON%d_WORKSLIKE",HANDREMOTE_WEAPON); - AddGameVar(aszBuf, HANDREMOTE_WEAPON, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, HANDREMOTE_WEAPON, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_CLIP",HANDREMOTE_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_RELOAD",HANDREMOTE_WEAPON); - AddGameVar(aszBuf, 10, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 10, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_FIREDELAY",HANDREMOTE_WEAPON); - AddGameVar(aszBuf, 2, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 2, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_TOTALTIME",HANDREMOTE_WEAPON); - AddGameVar(aszBuf, 10, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 10, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_HOLDDELAY",HANDREMOTE_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_FLAGS",HANDREMOTE_WEAPON); - AddGameVar(aszBuf, WEAPON_FLAG_BOMB_TRIGGER | WEAPON_FLAG_NOVISIBLE, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, WEAPON_BOMB_TRIGGER | WEAPON_NOVISIBLE, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SHOOTS",HANDREMOTE_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SPAWNTIME",HANDREMOTE_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SPAWN",HANDREMOTE_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SHOTSPERBURST",HANDREMOTE_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_INITIALSOUND",HANDREMOTE_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_FIRESOUND",HANDREMOTE_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SOUND2TIME",HANDREMOTE_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SOUND2SOUND",HANDREMOTE_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_RELOADSOUND1",HANDREMOTE_WEAPON); - AddGameVar(aszBuf, EJECT_CLIP, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, EJECT_CLIP, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_RELOADSOUND2",HANDREMOTE_WEAPON); - AddGameVar(aszBuf, INSERT_CLIP, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, INSERT_CLIP, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); + Bsprintf(aszBuf,"WEAPON%d_SELECTSOUND",HANDREMOTE_WEAPON); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); /////////////////////////////////////////////////////// Bsprintf(aszBuf,"WEAPON%d_WORKSLIKE",GROW_WEAPON); - AddGameVar(aszBuf, GROW_WEAPON, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, GROW_WEAPON, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_CLIP",GROW_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_RELOAD",GROW_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_FIREDELAY",GROW_WEAPON); - AddGameVar(aszBuf, 3, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 3, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_TOTALTIME",GROW_WEAPON); - AddGameVar(aszBuf, NAM?30:5, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, NAM?30:5, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_HOLDDELAY",GROW_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_FLAGS",GROW_WEAPON); - AddGameVar(aszBuf, WEAPON_FLAG_GLOWS, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, WEAPON_GLOWS, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SHOOTS",GROW_WEAPON); - AddGameVar(aszBuf, GROWSPARK, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, GROWSPARK, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SPAWNTIME",GROW_WEAPON); - AddGameVar(aszBuf, NAM?2:0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, NAM?2:0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SPAWN",GROW_WEAPON); - AddGameVar(aszBuf, NAM?SHELL:0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, NAM?SHELL:0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SHOTSPERBURST",GROW_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_INITIALSOUND",GROW_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_FIRESOUND",GROW_WEAPON); - AddGameVar(aszBuf, NAM?0:EXPANDERSHOOT, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, NAM?0:EXPANDERSHOOT, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SOUND2TIME",GROW_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_SOUND2SOUND",GROW_WEAPON); - AddGameVar(aszBuf, 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_RELOADSOUND1",GROW_WEAPON); - AddGameVar(aszBuf, EJECT_CLIP, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, EJECT_CLIP, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); Bsprintf(aszBuf,"WEAPON%d_RELOADSOUND2",GROW_WEAPON); - AddGameVar(aszBuf, INSERT_CLIP, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar(aszBuf, INSERT_CLIP, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); + Bsprintf(aszBuf,"WEAPON%d_SELECTSOUND",GROW_WEAPON); + Gv_SetupVar(aszBuf, SELECT_WEAPON, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); - AddGameVar("GRENADE_LIFETIME", NAM_GRENADE_LIFETIME, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); - AddGameVar("GRENADE_LIFETIME_VAR", NAM_GRENADE_LIFETIME_VAR, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar("GRENADE_LIFETIME", NAM_GRENADE_LIFETIME, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); + Gv_SetupVar("GRENADE_LIFETIME_VAR", NAM_GRENADE_LIFETIME_VAR, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); - AddGameVar("STICKYBOMB_LIFETIME", NAM_GRENADE_LIFETIME, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); - AddGameVar("STICKYBOMB_LIFETIME_VAR", NAM_GRENADE_LIFETIME_VAR, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar("STICKYBOMB_LIFETIME", NAM_GRENADE_LIFETIME, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); + Gv_SetupVar("STICKYBOMB_LIFETIME_VAR", NAM_GRENADE_LIFETIME_VAR, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); - AddGameVar("TRIPBOMB_CONTROL", TRIPBOMB_TRIPWIRE, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); - AddGameVar("PIPEBOMB_CONTROL", NAM?PIPEBOMB_TIMER:PIPEBOMB_REMOTE, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); + Gv_SetupVar("TRIPBOMB_CONTROL", TRIPBOMB_TRIPWIRE, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); + Gv_SetupVar("PIPEBOMB_CONTROL", NAM?PIPEBOMB_TIMER:PIPEBOMB_REMOTE, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); - AddGameVar("RESPAWN_MONSTERS", (intptr_t)&ud.respawn_monsters,GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_INTPTR); - AddGameVar("RESPAWN_ITEMS",(intptr_t)&ud.respawn_items, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_INTPTR); - AddGameVar("RESPAWN_INVENTORY",(intptr_t)&ud.respawn_inventory, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_INTPTR); - AddGameVar("MONSTERS_OFF",(intptr_t)&ud.monsters_off, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_INTPTR); - AddGameVar("MARKER",(intptr_t)&ud.marker, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_INTPTR); - AddGameVar("FFIRE",(intptr_t)&ud.ffire, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_INTPTR); - AddGameVar("LEVEL",(intptr_t)&ud.level_number, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_INTPTR | GAMEVAR_FLAG_READONLY); - AddGameVar("VOLUME",(intptr_t)&ud.volume_number, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_INTPTR | GAMEVAR_FLAG_READONLY); + Gv_SetupVar("RESPAWN_MONSTERS", (intptr_t)&ud.respawn_monsters,GAMEVAR_SYSTEM | GAMEVAR_INTPTR); + Gv_SetupVar("RESPAWN_ITEMS",(intptr_t)&ud.respawn_items, GAMEVAR_SYSTEM | GAMEVAR_INTPTR); + Gv_SetupVar("RESPAWN_INVENTORY",(intptr_t)&ud.respawn_inventory, GAMEVAR_SYSTEM | GAMEVAR_INTPTR); + Gv_SetupVar("MONSTERS_OFF",(intptr_t)&ud.monsters_off, GAMEVAR_SYSTEM | GAMEVAR_INTPTR); + Gv_SetupVar("MARKER",(intptr_t)&ud.marker, GAMEVAR_SYSTEM | GAMEVAR_INTPTR); + Gv_SetupVar("FFIRE",(intptr_t)&ud.ffire, GAMEVAR_SYSTEM | GAMEVAR_INTPTR); + Gv_SetupVar("LEVEL",(intptr_t)&ud.level_number, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_READONLY); + Gv_SetupVar("VOLUME",(intptr_t)&ud.volume_number, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_READONLY); - AddGameVar("COOP",(intptr_t)&ud.coop, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_INTPTR); - AddGameVar("MULTIMODE",(intptr_t)&ud.multimode, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_INTPTR); + Gv_SetupVar("COOP",(intptr_t)&ud.coop, GAMEVAR_SYSTEM | GAMEVAR_INTPTR); + Gv_SetupVar("MULTIMODE",(intptr_t)&ud.multimode, GAMEVAR_SYSTEM | GAMEVAR_INTPTR); - AddGameVar("WEAPON", 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_READONLY | GAMEVAR_FLAG_SYSTEM); - AddGameVar("WORKSLIKE", 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_READONLY | GAMEVAR_FLAG_SYSTEM); - AddGameVar("RETURN", 0, GAMEVAR_FLAG_SYSTEM); - AddGameVar("ZRANGE", 4, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); - AddGameVar("ANGRANGE", 18, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); - AddGameVar("AUTOAIMANGLE", 0, GAMEVAR_FLAG_PERPLAYER | GAMEVAR_FLAG_SYSTEM); - AddGameVar("LOTAG", 0, GAMEVAR_FLAG_SYSTEM); - AddGameVar("HITAG", 0, GAMEVAR_FLAG_SYSTEM); - AddGameVar("TEXTURE", 0, GAMEVAR_FLAG_SYSTEM); - AddGameVar("THISACTOR", 0, GAMEVAR_FLAG_READONLY | GAMEVAR_FLAG_SYSTEM); - AddGameVar("myconnectindex", (intptr_t)&myconnectindex, GAMEVAR_FLAG_READONLY | GAMEVAR_FLAG_INTPTR | GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("screenpeek", (intptr_t)&screenpeek, GAMEVAR_FLAG_READONLY | GAMEVAR_FLAG_INTPTR | GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("currentweapon",(intptr_t)&g_currentweapon, GAMEVAR_FLAG_INTPTR | GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("gs",(intptr_t)&g_gs, GAMEVAR_FLAG_INTPTR | GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("looking_arc",(intptr_t)&g_looking_arc, GAMEVAR_FLAG_INTPTR | GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("gun_pos",(intptr_t)&g_gun_pos, GAMEVAR_FLAG_INTPTR | GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("weapon_xoffset",(intptr_t)&g_weapon_xoffset, GAMEVAR_FLAG_INTPTR | GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("weaponcount",(intptr_t)&g_kb, GAMEVAR_FLAG_INTPTR | GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("looking_angSR1",(intptr_t)&g_looking_angSR1, GAMEVAR_FLAG_INTPTR | GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("xdim",(intptr_t)&xdim, GAMEVAR_FLAG_INTPTR | GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_READONLY | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("ydim",(intptr_t)&ydim, GAMEVAR_FLAG_INTPTR | GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_READONLY | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("windowx1",(intptr_t)&windowx1, GAMEVAR_FLAG_INTPTR | GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_READONLY | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("windowx2",(intptr_t)&windowx2, GAMEVAR_FLAG_INTPTR | GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_READONLY | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("windowy1",(intptr_t)&windowy1, GAMEVAR_FLAG_INTPTR | GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_READONLY | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("windowy2",(intptr_t)&windowy2, GAMEVAR_FLAG_INTPTR | GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_READONLY | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("totalclock",(intptr_t)&totalclock, GAMEVAR_FLAG_INTPTR | GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_READONLY | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("lastvisinc",(intptr_t)&lastvisinc, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_INTPTR | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("numsectors",(intptr_t)&numsectors, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_SHORTPTR | GAMEVAR_FLAG_READONLY); + Gv_SetupVar("WEAPON", 0, GAMEVAR_PERPLAYER | GAMEVAR_READONLY | GAMEVAR_SYSTEM); + Gv_SetupVar("WORKSLIKE", 0, GAMEVAR_PERPLAYER | GAMEVAR_READONLY | GAMEVAR_SYSTEM); + Gv_SetupVar("RETURN", 0, GAMEVAR_SYSTEM); + Gv_SetupVar("ZRANGE", 4, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); + Gv_SetupVar("ANGRANGE", 18, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); + Gv_SetupVar("AUTOAIMANGLE", 0, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); + Gv_SetupVar("LOTAG", 0, GAMEVAR_SYSTEM); + Gv_SetupVar("HITAG", 0, GAMEVAR_SYSTEM); + Gv_SetupVar("TEXTURE", 0, GAMEVAR_SYSTEM); + Gv_SetupVar("THISACTOR", 0, GAMEVAR_READONLY | GAMEVAR_SYSTEM); + Gv_SetupVar("myconnectindex", (intptr_t)&myconnectindex, GAMEVAR_READONLY | GAMEVAR_INTPTR | GAMEVAR_SYSTEM | GAMEVAR_SYNCCHECK); + Gv_SetupVar("screenpeek", (intptr_t)&screenpeek, GAMEVAR_READONLY | GAMEVAR_INTPTR | GAMEVAR_SYSTEM | GAMEVAR_SYNCCHECK); + Gv_SetupVar("currentweapon",(intptr_t)&g_currentweapon, GAMEVAR_INTPTR | GAMEVAR_SYSTEM | GAMEVAR_SYNCCHECK); + Gv_SetupVar("gs",(intptr_t)&g_gs, GAMEVAR_INTPTR | GAMEVAR_SYSTEM | GAMEVAR_SYNCCHECK); + Gv_SetupVar("looking_arc",(intptr_t)&g_looking_arc, GAMEVAR_INTPTR | GAMEVAR_SYSTEM | GAMEVAR_SYNCCHECK); + Gv_SetupVar("gun_pos",(intptr_t)&g_gun_pos, GAMEVAR_INTPTR | GAMEVAR_SYSTEM | GAMEVAR_SYNCCHECK); + Gv_SetupVar("weapon_xoffset",(intptr_t)&g_weapon_xoffset, GAMEVAR_INTPTR | GAMEVAR_SYSTEM | GAMEVAR_SYNCCHECK); + Gv_SetupVar("weaponcount",(intptr_t)&g_kb, GAMEVAR_INTPTR | GAMEVAR_SYSTEM | GAMEVAR_SYNCCHECK); + Gv_SetupVar("looking_angSR1",(intptr_t)&g_looking_angSR1, GAMEVAR_INTPTR | GAMEVAR_SYSTEM | GAMEVAR_SYNCCHECK); + Gv_SetupVar("xdim",(intptr_t)&xdim, GAMEVAR_INTPTR | GAMEVAR_SYSTEM | GAMEVAR_READONLY | GAMEVAR_SYNCCHECK); + Gv_SetupVar("ydim",(intptr_t)&ydim, GAMEVAR_INTPTR | GAMEVAR_SYSTEM | GAMEVAR_READONLY | GAMEVAR_SYNCCHECK); + Gv_SetupVar("windowx1",(intptr_t)&windowx1, GAMEVAR_INTPTR | GAMEVAR_SYSTEM | GAMEVAR_READONLY | GAMEVAR_SYNCCHECK); + Gv_SetupVar("windowx2",(intptr_t)&windowx2, GAMEVAR_INTPTR | GAMEVAR_SYSTEM | GAMEVAR_READONLY | GAMEVAR_SYNCCHECK); + Gv_SetupVar("windowy1",(intptr_t)&windowy1, GAMEVAR_INTPTR | GAMEVAR_SYSTEM | GAMEVAR_READONLY | GAMEVAR_SYNCCHECK); + Gv_SetupVar("windowy2",(intptr_t)&windowy2, GAMEVAR_INTPTR | GAMEVAR_SYSTEM | GAMEVAR_READONLY | GAMEVAR_SYNCCHECK); + Gv_SetupVar("totalclock",(intptr_t)&totalclock, GAMEVAR_INTPTR | GAMEVAR_SYSTEM | GAMEVAR_READONLY | GAMEVAR_SYNCCHECK); + Gv_SetupVar("lastvisinc",(intptr_t)&lastvisinc, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_SYNCCHECK); + Gv_SetupVar("numsectors",(intptr_t)&numsectors, GAMEVAR_SYSTEM | GAMEVAR_SHORTPTR | GAMEVAR_READONLY); - AddGameVar("current_menu",(intptr_t)¤t_menu, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_INTPTR | GAMEVAR_FLAG_READONLY); - AddGameVar("numplayers",(intptr_t)&numplayers, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_INTPTR | GAMEVAR_FLAG_READONLY); - AddGameVar("viewingrange",(intptr_t)&viewingrange, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_INTPTR | GAMEVAR_FLAG_READONLY | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("yxaspect",(intptr_t)&yxaspect, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_INTPTR | GAMEVAR_FLAG_READONLY | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("gravitationalconstant",(intptr_t)&gc, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_INTPTR); - AddGameVar("gametype_flags",(intptr_t)&gametype_flags[ud.coop], GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_INTPTR); - AddGameVar("framerate",(intptr_t)&framerate, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_INTPTR | GAMEVAR_FLAG_READONLY | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("CLIPMASK0", CLIPMASK0, GAMEVAR_FLAG_SYSTEM|GAMEVAR_FLAG_READONLY); - AddGameVar("CLIPMASK1", CLIPMASK1, GAMEVAR_FLAG_SYSTEM|GAMEVAR_FLAG_READONLY); + Gv_SetupVar("current_menu",(intptr_t)&g_currentMenu, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_READONLY); + Gv_SetupVar("numplayers",(intptr_t)&numplayers, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_READONLY); + Gv_SetupVar("viewingrange",(intptr_t)&viewingrange, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_READONLY | GAMEVAR_SYNCCHECK); + Gv_SetupVar("yxaspect",(intptr_t)&yxaspect, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_READONLY | GAMEVAR_SYNCCHECK); + Gv_SetupVar("gravitationalconstant",(intptr_t)&SpriteGravity, GAMEVAR_SYSTEM | GAMEVAR_INTPTR); + Gv_SetupVar("gametype_flags",(intptr_t)&GametypeFlags[ud.coop], GAMEVAR_SYSTEM | GAMEVAR_INTPTR); + Gv_SetupVar("framerate",(intptr_t)&g_currentFrameRate, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_READONLY | GAMEVAR_SYNCCHECK); + Gv_SetupVar("CLIPMASK0", CLIPMASK0, GAMEVAR_SYSTEM|GAMEVAR_READONLY); + Gv_SetupVar("CLIPMASK1", CLIPMASK1, GAMEVAR_SYSTEM|GAMEVAR_READONLY); - AddGameVar("camerax",(intptr_t)&ud.camerax, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_INTPTR | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("cameray",(intptr_t)&ud.cameray, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_INTPTR | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("cameraz",(intptr_t)&ud.cameraz, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_INTPTR | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("cameraang",(intptr_t)&ud.cameraang, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_SHORTPTR | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("camerahoriz",(intptr_t)&ud.camerahoriz, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_SHORTPTR | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("camerasect",(intptr_t)&ud.camerasect, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_SHORTPTR | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("cameradist",(intptr_t)&cameradist, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_INTPTR | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("cameraclock",(intptr_t)&cameraclock, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_INTPTR | GAMEVAR_FLAG_SYNCCHECK); + Gv_SetupVar("camerax",(intptr_t)&ud.camerax, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_SYNCCHECK); + Gv_SetupVar("cameray",(intptr_t)&ud.cameray, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_SYNCCHECK); + Gv_SetupVar("cameraz",(intptr_t)&ud.cameraz, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_SYNCCHECK); + Gv_SetupVar("cameraang",(intptr_t)&ud.cameraang, GAMEVAR_SYSTEM | GAMEVAR_SHORTPTR | GAMEVAR_SYNCCHECK); + Gv_SetupVar("camerahoriz",(intptr_t)&ud.camerahoriz, GAMEVAR_SYSTEM | GAMEVAR_SHORTPTR | GAMEVAR_SYNCCHECK); + Gv_SetupVar("camerasect",(intptr_t)&ud.camerasect, GAMEVAR_SYSTEM | GAMEVAR_SHORTPTR | GAMEVAR_SYNCCHECK); + Gv_SetupVar("cameradist",(intptr_t)&g_cameraDistance, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_SYNCCHECK); + Gv_SetupVar("cameraclock",(intptr_t)&g_cameraClock, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_SYNCCHECK); - AddGameVar("myx",(intptr_t)&myx, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_INTPTR | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("myy",(intptr_t)&myy, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_INTPTR | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("myz",(intptr_t)&myz, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_INTPTR | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("omyx",(intptr_t)&omyx, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_INTPTR | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("omyy",(intptr_t)&omyy, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_INTPTR | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("omyz",(intptr_t)&omyz, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_INTPTR | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("myxvel",(intptr_t)&myxvel, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_INTPTR | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("myyvel",(intptr_t)&myyvel, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_INTPTR | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("myzvel",(intptr_t)&myzvel, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_INTPTR | GAMEVAR_FLAG_SYNCCHECK); + Gv_SetupVar("myx",(intptr_t)&myx, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_SYNCCHECK); + Gv_SetupVar("myy",(intptr_t)&myy, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_SYNCCHECK); + Gv_SetupVar("myz",(intptr_t)&myz, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_SYNCCHECK); + Gv_SetupVar("omyx",(intptr_t)&omyx, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_SYNCCHECK); + Gv_SetupVar("omyy",(intptr_t)&omyy, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_SYNCCHECK); + Gv_SetupVar("omyz",(intptr_t)&omyz, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_SYNCCHECK); + Gv_SetupVar("myxvel",(intptr_t)&myxvel, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_SYNCCHECK); + Gv_SetupVar("myyvel",(intptr_t)&myyvel, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_SYNCCHECK); + Gv_SetupVar("myzvel",(intptr_t)&myzvel, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_SYNCCHECK); - AddGameVar("myhoriz",(intptr_t)&myhoriz, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_SHORTPTR | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("myhorizoff",(intptr_t)&myhorizoff, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_SHORTPTR | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("omyhoriz",(intptr_t)&omyhoriz, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_SHORTPTR | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("omyhorizoff",(intptr_t)&omyhorizoff, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_SHORTPTR | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("myang",(intptr_t)&myang, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_SHORTPTR | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("omyang",(intptr_t)&omyang, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_SHORTPTR | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("mycursectnum",(intptr_t)&mycursectnum, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_SHORTPTR | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("myjumpingcounter",(intptr_t)&myjumpingcounter, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_SHORTPTR | GAMEVAR_FLAG_SYNCCHECK); + Gv_SetupVar("myhoriz",(intptr_t)&myhoriz, GAMEVAR_SYSTEM | GAMEVAR_SHORTPTR | GAMEVAR_SYNCCHECK); + Gv_SetupVar("myhorizoff",(intptr_t)&myhorizoff, GAMEVAR_SYSTEM | GAMEVAR_SHORTPTR | GAMEVAR_SYNCCHECK); + Gv_SetupVar("omyhoriz",(intptr_t)&omyhoriz, GAMEVAR_SYSTEM | GAMEVAR_SHORTPTR | GAMEVAR_SYNCCHECK); + Gv_SetupVar("omyhorizoff",(intptr_t)&omyhorizoff, GAMEVAR_SYSTEM | GAMEVAR_SHORTPTR | GAMEVAR_SYNCCHECK); + Gv_SetupVar("myang",(intptr_t)&myang, GAMEVAR_SYSTEM | GAMEVAR_SHORTPTR | GAMEVAR_SYNCCHECK); + Gv_SetupVar("omyang",(intptr_t)&omyang, GAMEVAR_SYSTEM | GAMEVAR_SHORTPTR | GAMEVAR_SYNCCHECK); + Gv_SetupVar("mycursectnum",(intptr_t)&mycursectnum, GAMEVAR_SYSTEM | GAMEVAR_SHORTPTR | GAMEVAR_SYNCCHECK); + Gv_SetupVar("myjumpingcounter",(intptr_t)&myjumpingcounter, GAMEVAR_SYSTEM | GAMEVAR_SHORTPTR | GAMEVAR_SYNCCHECK); - AddGameVar("myjumpingtoggle",(intptr_t)&myjumpingtoggle, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_CHARPTR | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("myonground",(intptr_t)&myonground, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_CHARPTR | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("myhardlanding",(intptr_t)&myhardlanding, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_CHARPTR | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("myreturntocenter",(intptr_t)&myreturntocenter, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_CHARPTR | GAMEVAR_FLAG_SYNCCHECK); + Gv_SetupVar("myjumpingtoggle",(intptr_t)&myjumpingtoggle, GAMEVAR_SYSTEM | GAMEVAR_CHARPTR | GAMEVAR_SYNCCHECK); + Gv_SetupVar("myonground",(intptr_t)&myonground, GAMEVAR_SYSTEM | GAMEVAR_CHARPTR | GAMEVAR_SYNCCHECK); + Gv_SetupVar("myhardlanding",(intptr_t)&myhardlanding, GAMEVAR_SYSTEM | GAMEVAR_CHARPTR | GAMEVAR_SYNCCHECK); + Gv_SetupVar("myreturntocenter",(intptr_t)&myreturntocenter, GAMEVAR_SYSTEM | GAMEVAR_CHARPTR | GAMEVAR_SYNCCHECK); - AddGameVar("display_mirror",(intptr_t)&display_mirror, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_CHARPTR | GAMEVAR_FLAG_SYNCCHECK); - AddGameVar("randomseed",(intptr_t)&randomseed, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_INTPTR); + Gv_SetupVar("display_mirror",(intptr_t)&display_mirror, GAMEVAR_SYSTEM | GAMEVAR_CHARPTR | GAMEVAR_SYNCCHECK); + Gv_SetupVar("randomseed",(intptr_t)&randomseed, GAMEVAR_SYSTEM | GAMEVAR_INTPTR); - AddGameVar("NUMWALLS",(intptr_t)&numwalls, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_SHORTPTR | GAMEVAR_FLAG_READONLY); - AddGameVar("NUMSECTORS",(intptr_t)&numsectors, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_SHORTPTR | GAMEVAR_FLAG_READONLY); + Gv_SetupVar("NUMWALLS",(intptr_t)&numwalls, GAMEVAR_SYSTEM | GAMEVAR_SHORTPTR | GAMEVAR_READONLY); + Gv_SetupVar("NUMSECTORS",(intptr_t)&numsectors, GAMEVAR_SYSTEM | GAMEVAR_SHORTPTR | GAMEVAR_READONLY); - AddGameVar("lastsavedpos",(intptr_t)&lastsavedpos, GAMEVAR_FLAG_SYSTEM | GAMEVAR_FLAG_INTPTR); + Gv_SetupVar("lastsavepos",(intptr_t)&g_lastSaveSlot, GAMEVAR_SYSTEM | GAMEVAR_INTPTR); } -void InitGameVars(void) +void Gv_Init(void) { // only call ONCE // initprintf("Initializing game variables\n"); - //AddLog("InitGameVars"); + //AddLog("Gv_Init"); - ClearGameVars(); - AddSystemVars(); - InitGameVarPointers(); - ResetSystemDefaults(); + Gv_Clear(); + Gv_AddSystemVars(); + Gv_InitWeaponPointers(); + Gv_ResetSystemDefaults(); } -void InitGameVarPointers(void) +void Gv_InitWeaponPointers(void) { int i; char aszBuf[64]; // called from game Init AND when level is loaded... - //AddLog("InitGameVarPointers"); + //AddLog("Gv_InitWeaponPointers"); for (i=(MAX_WEAPONS-1);i>=0;i--) { Bsprintf(aszBuf,"WEAPON%d_CLIP",i); - aplWeaponClip[i]=GetGameValuePtr(aszBuf); + aplWeaponClip[i]=Gv_GetVarDataPtr(aszBuf); if (!aplWeaponClip[i]) { - initprintf("ERROR: NULL Weapon\n"); - exit(0); + initprintf("ERROR: NULL weapon! WTF?!\n"); + // exit(0); + G_Shutdown(); } Bsprintf(aszBuf,"WEAPON%d_RELOAD",i); - aplWeaponReload[i]=GetGameValuePtr(aszBuf); + aplWeaponReload[i]=Gv_GetVarDataPtr(aszBuf); Bsprintf(aszBuf,"WEAPON%d_FIREDELAY",i); - aplWeaponFireDelay[i]=GetGameValuePtr(aszBuf); + aplWeaponFireDelay[i]=Gv_GetVarDataPtr(aszBuf); Bsprintf(aszBuf,"WEAPON%d_TOTALTIME",i); - aplWeaponTotalTime[i]=GetGameValuePtr(aszBuf); + aplWeaponTotalTime[i]=Gv_GetVarDataPtr(aszBuf); Bsprintf(aszBuf,"WEAPON%d_HOLDDELAY",i); - aplWeaponHoldDelay[i]=GetGameValuePtr(aszBuf); + aplWeaponHoldDelay[i]=Gv_GetVarDataPtr(aszBuf); Bsprintf(aszBuf,"WEAPON%d_FLAGS",i); - aplWeaponFlags[i]=GetGameValuePtr(aszBuf); + aplWeaponFlags[i]=Gv_GetVarDataPtr(aszBuf); Bsprintf(aszBuf,"WEAPON%d_SHOOTS",i); - aplWeaponShoots[i]=GetGameValuePtr(aszBuf); + aplWeaponShoots[i]=Gv_GetVarDataPtr(aszBuf); Bsprintf(aszBuf,"WEAPON%d_SPAWNTIME",i); - aplWeaponSpawnTime[i]=GetGameValuePtr(aszBuf); + aplWeaponSpawnTime[i]=Gv_GetVarDataPtr(aszBuf); Bsprintf(aszBuf,"WEAPON%d_SPAWN",i); - aplWeaponSpawn[i]=GetGameValuePtr(aszBuf); + aplWeaponSpawn[i]=Gv_GetVarDataPtr(aszBuf); Bsprintf(aszBuf,"WEAPON%d_SHOTSPERBURST",i); - aplWeaponShotsPerBurst[i]=GetGameValuePtr(aszBuf); + aplWeaponShotsPerBurst[i]=Gv_GetVarDataPtr(aszBuf); Bsprintf(aszBuf,"WEAPON%d_WORKSLIKE",i); - aplWeaponWorksLike[i]=GetGameValuePtr(aszBuf); + aplWeaponWorksLike[i]=Gv_GetVarDataPtr(aszBuf); Bsprintf(aszBuf,"WEAPON%d_INITIALSOUND",i); - aplWeaponInitialSound[i]=GetGameValuePtr(aszBuf); + aplWeaponInitialSound[i]=Gv_GetVarDataPtr(aszBuf); Bsprintf(aszBuf,"WEAPON%d_FIRESOUND",i); - aplWeaponFireSound[i]=GetGameValuePtr(aszBuf); + aplWeaponFireSound[i]=Gv_GetVarDataPtr(aszBuf); Bsprintf(aszBuf,"WEAPON%d_SOUND2TIME",i); - aplWeaponSound2Time[i]=GetGameValuePtr(aszBuf); + aplWeaponSound2Time[i]=Gv_GetVarDataPtr(aszBuf); Bsprintf(aszBuf,"WEAPON%d_SOUND2SOUND",i); - aplWeaponSound2Sound[i]=GetGameValuePtr(aszBuf); + aplWeaponSound2Sound[i]=Gv_GetVarDataPtr(aszBuf); Bsprintf(aszBuf,"WEAPON%d_RELOADSOUND1",i); - aplWeaponReloadSound1[i]=GetGameValuePtr(aszBuf); + aplWeaponReloadSound1[i]=Gv_GetVarDataPtr(aszBuf); Bsprintf(aszBuf,"WEAPON%d_RELOADSOUND2",i); - aplWeaponReloadSound2[i]=GetGameValuePtr(aszBuf); + aplWeaponReloadSound2[i]=Gv_GetVarDataPtr(aszBuf); + Bsprintf(aszBuf,"WEAPON%d_SELECTSOUND",i); + aplWeaponSelectSound[i]=Gv_GetVarDataPtr(aszBuf); } } -void ResetPointerVars(void) +void Gv_RefreshPointers(void) { - aGameVars[GetGameID("RESPAWN_MONSTERS")].lValue = (intptr_t)&ud.respawn_monsters; - aGameVars[GetGameID("RESPAWN_ITEMS")].lValue = (intptr_t)&ud.respawn_items; - aGameVars[GetGameID("RESPAWN_INVENTORY")].lValue = (intptr_t)&ud.respawn_inventory; - aGameVars[GetGameID("MONSTERS_OFF")].lValue = (intptr_t)&ud.monsters_off; - aGameVars[GetGameID("MARKER")].lValue = (intptr_t)&ud.marker; - aGameVars[GetGameID("FFIRE")].lValue = (intptr_t)&ud.ffire; - aGameVars[GetGameID("LEVEL")].lValue = (intptr_t)&ud.level_number; - aGameVars[GetGameID("VOLUME")].lValue = (intptr_t)&ud.volume_number; + aGameVars[Gv_GetVarIndex("RESPAWN_MONSTERS")].lValue = (intptr_t)&ud.respawn_monsters; + aGameVars[Gv_GetVarIndex("RESPAWN_ITEMS")].lValue = (intptr_t)&ud.respawn_items; + aGameVars[Gv_GetVarIndex("RESPAWN_INVENTORY")].lValue = (intptr_t)&ud.respawn_inventory; + aGameVars[Gv_GetVarIndex("MONSTERS_OFF")].lValue = (intptr_t)&ud.monsters_off; + aGameVars[Gv_GetVarIndex("MARKER")].lValue = (intptr_t)&ud.marker; + aGameVars[Gv_GetVarIndex("FFIRE")].lValue = (intptr_t)&ud.ffire; + aGameVars[Gv_GetVarIndex("LEVEL")].lValue = (intptr_t)&ud.level_number; + aGameVars[Gv_GetVarIndex("VOLUME")].lValue = (intptr_t)&ud.volume_number; - aGameVars[GetGameID("COOP")].lValue = (intptr_t)&ud.coop; - aGameVars[GetGameID("MULTIMODE")].lValue = (intptr_t)&ud.multimode; + aGameVars[Gv_GetVarIndex("COOP")].lValue = (intptr_t)&ud.coop; + aGameVars[Gv_GetVarIndex("MULTIMODE")].lValue = (intptr_t)&ud.multimode; - aGameVars[GetGameID("myconnectindex")].lValue = (intptr_t)&myconnectindex; - aGameVars[GetGameID("screenpeek")].lValue = (intptr_t)&screenpeek; - aGameVars[GetGameID("currentweapon")].lValue = (intptr_t)&g_currentweapon; - aGameVars[GetGameID("gs")].lValue = (intptr_t)&g_gs; - aGameVars[GetGameID("looking_arc")].lValue = (intptr_t)&g_looking_arc; - aGameVars[GetGameID("gun_pos")].lValue = (intptr_t)&g_gun_pos; - aGameVars[GetGameID("weapon_xoffset")].lValue = (intptr_t)&g_weapon_xoffset; - aGameVars[GetGameID("weaponcount")].lValue = (intptr_t)&g_kb; - aGameVars[GetGameID("looking_angSR1")].lValue = (intptr_t)&g_looking_angSR1; - aGameVars[GetGameID("xdim")].lValue = (intptr_t)&xdim; - aGameVars[GetGameID("ydim")].lValue = (intptr_t)&ydim; - aGameVars[GetGameID("windowx1")].lValue = (intptr_t)&windowx1; - aGameVars[GetGameID("windowx2")].lValue = (intptr_t)&windowx2; - aGameVars[GetGameID("windowy1")].lValue = (intptr_t)&windowy1; - aGameVars[GetGameID("windowy2")].lValue = (intptr_t)&windowy2; - aGameVars[GetGameID("totalclock")].lValue = (intptr_t)&totalclock; - aGameVars[GetGameID("lastvisinc")].lValue = (intptr_t)&lastvisinc; - aGameVars[GetGameID("numsectors")].lValue = (intptr_t)&numsectors; - aGameVars[GetGameID("numplayers")].lValue = (intptr_t)&numplayers; - aGameVars[GetGameID("current_menu")].lValue = (intptr_t)¤t_menu; - aGameVars[GetGameID("viewingrange")].lValue = (intptr_t)&viewingrange; - aGameVars[GetGameID("yxaspect")].lValue = (intptr_t)&yxaspect; - aGameVars[GetGameID("gravitationalconstant")].lValue = (intptr_t)&gc; - aGameVars[GetGameID("gametype_flags")].lValue = (intptr_t)&gametype_flags[ud.coop]; - aGameVars[GetGameID("framerate")].lValue = (intptr_t)&framerate; + aGameVars[Gv_GetVarIndex("myconnectindex")].lValue = (intptr_t)&myconnectindex; + aGameVars[Gv_GetVarIndex("screenpeek")].lValue = (intptr_t)&screenpeek; + aGameVars[Gv_GetVarIndex("currentweapon")].lValue = (intptr_t)&g_currentweapon; + aGameVars[Gv_GetVarIndex("gs")].lValue = (intptr_t)&g_gs; + aGameVars[Gv_GetVarIndex("looking_arc")].lValue = (intptr_t)&g_looking_arc; + aGameVars[Gv_GetVarIndex("gun_pos")].lValue = (intptr_t)&g_gun_pos; + aGameVars[Gv_GetVarIndex("weapon_xoffset")].lValue = (intptr_t)&g_weapon_xoffset; + aGameVars[Gv_GetVarIndex("weaponcount")].lValue = (intptr_t)&g_kb; + aGameVars[Gv_GetVarIndex("looking_angSR1")].lValue = (intptr_t)&g_looking_angSR1; + aGameVars[Gv_GetVarIndex("xdim")].lValue = (intptr_t)&xdim; + aGameVars[Gv_GetVarIndex("ydim")].lValue = (intptr_t)&ydim; + aGameVars[Gv_GetVarIndex("windowx1")].lValue = (intptr_t)&windowx1; + aGameVars[Gv_GetVarIndex("windowx2")].lValue = (intptr_t)&windowx2; + aGameVars[Gv_GetVarIndex("windowy1")].lValue = (intptr_t)&windowy1; + aGameVars[Gv_GetVarIndex("windowy2")].lValue = (intptr_t)&windowy2; + aGameVars[Gv_GetVarIndex("totalclock")].lValue = (intptr_t)&totalclock; + aGameVars[Gv_GetVarIndex("lastvisinc")].lValue = (intptr_t)&lastvisinc; + aGameVars[Gv_GetVarIndex("numsectors")].lValue = (intptr_t)&numsectors; + aGameVars[Gv_GetVarIndex("numplayers")].lValue = (intptr_t)&numplayers; + aGameVars[Gv_GetVarIndex("g_currentMenu")].lValue = (intptr_t)&g_currentMenu; + aGameVars[Gv_GetVarIndex("viewingrange")].lValue = (intptr_t)&viewingrange; + aGameVars[Gv_GetVarIndex("yxaspect")].lValue = (intptr_t)&yxaspect; + aGameVars[Gv_GetVarIndex("gravitationalconstant")].lValue = (intptr_t)&SpriteGravity; + aGameVars[Gv_GetVarIndex("GametypeFlags")].lValue = (intptr_t)&GametypeFlags[ud.coop]; + aGameVars[Gv_GetVarIndex("framerate")].lValue = (intptr_t)&g_currentFrameRate; - aGameVars[GetGameID("camerax")].lValue = (intptr_t)&ud.camerax; - aGameVars[GetGameID("cameray")].lValue = (intptr_t)&ud.cameray; - aGameVars[GetGameID("cameraz")].lValue = (intptr_t)&ud.cameraz; - aGameVars[GetGameID("cameraang")].lValue = (intptr_t)&ud.cameraang; - aGameVars[GetGameID("camerahoriz")].lValue = (intptr_t)&ud.camerahoriz; - aGameVars[GetGameID("camerasect")].lValue = (intptr_t)&ud.camerasect; - aGameVars[GetGameID("cameradist")].lValue = (intptr_t)&cameradist; - aGameVars[GetGameID("cameraclock")].lValue = (intptr_t)&cameraclock; + aGameVars[Gv_GetVarIndex("camerax")].lValue = (intptr_t)&ud.camerax; + aGameVars[Gv_GetVarIndex("cameray")].lValue = (intptr_t)&ud.cameray; + aGameVars[Gv_GetVarIndex("cameraz")].lValue = (intptr_t)&ud.cameraz; + aGameVars[Gv_GetVarIndex("cameraang")].lValue = (intptr_t)&ud.cameraang; + aGameVars[Gv_GetVarIndex("camerahoriz")].lValue = (intptr_t)&ud.camerahoriz; + aGameVars[Gv_GetVarIndex("camerasect")].lValue = (intptr_t)&ud.camerasect; + aGameVars[Gv_GetVarIndex("g_cameraDistance")].lValue = (intptr_t)&g_cameraDistance; + aGameVars[Gv_GetVarIndex("g_cameraClock")].lValue = (intptr_t)&g_cameraClock; - aGameVars[GetGameID("myx")].lValue = (intptr_t)&myx; - aGameVars[GetGameID("myy")].lValue = (intptr_t)&myy; - aGameVars[GetGameID("myz")].lValue = (intptr_t)&myz; - aGameVars[GetGameID("omyx")].lValue = (intptr_t)&omyx; - aGameVars[GetGameID("omyy")].lValue = (intptr_t)&omyy; - aGameVars[GetGameID("omyz")].lValue = (intptr_t)&omyz; - aGameVars[GetGameID("myxvel")].lValue = (intptr_t)&myxvel; - aGameVars[GetGameID("myyvel")].lValue = (intptr_t)&myyvel; - aGameVars[GetGameID("myzvel")].lValue = (intptr_t)&myzvel; + aGameVars[Gv_GetVarIndex("myx")].lValue = (intptr_t)&myx; + aGameVars[Gv_GetVarIndex("myy")].lValue = (intptr_t)&myy; + aGameVars[Gv_GetVarIndex("myz")].lValue = (intptr_t)&myz; + aGameVars[Gv_GetVarIndex("omyx")].lValue = (intptr_t)&omyx; + aGameVars[Gv_GetVarIndex("omyy")].lValue = (intptr_t)&omyy; + aGameVars[Gv_GetVarIndex("omyz")].lValue = (intptr_t)&omyz; + aGameVars[Gv_GetVarIndex("myxvel")].lValue = (intptr_t)&myxvel; + aGameVars[Gv_GetVarIndex("myyvel")].lValue = (intptr_t)&myyvel; + aGameVars[Gv_GetVarIndex("myzvel")].lValue = (intptr_t)&myzvel; - aGameVars[GetGameID("myhoriz")].lValue = (intptr_t)&myhoriz; - aGameVars[GetGameID("myhorizoff")].lValue = (intptr_t)&myhorizoff; - aGameVars[GetGameID("omyhoriz")].lValue = (intptr_t)&omyhoriz; - aGameVars[GetGameID("omyhorizoff")].lValue = (intptr_t)&omyhorizoff; - aGameVars[GetGameID("myang")].lValue = (intptr_t)&myang; - aGameVars[GetGameID("omyang")].lValue = (intptr_t)&omyang; - aGameVars[GetGameID("mycursectnum")].lValue = (intptr_t)&mycursectnum; - aGameVars[GetGameID("myjumpingcounter")].lValue = (intptr_t)&myjumpingcounter; + aGameVars[Gv_GetVarIndex("myhoriz")].lValue = (intptr_t)&myhoriz; + aGameVars[Gv_GetVarIndex("myhorizoff")].lValue = (intptr_t)&myhorizoff; + aGameVars[Gv_GetVarIndex("omyhoriz")].lValue = (intptr_t)&omyhoriz; + aGameVars[Gv_GetVarIndex("omyhorizoff")].lValue = (intptr_t)&omyhorizoff; + aGameVars[Gv_GetVarIndex("myang")].lValue = (intptr_t)&myang; + aGameVars[Gv_GetVarIndex("omyang")].lValue = (intptr_t)&omyang; + aGameVars[Gv_GetVarIndex("mycursectnum")].lValue = (intptr_t)&mycursectnum; + aGameVars[Gv_GetVarIndex("myjumpingcounter")].lValue = (intptr_t)&myjumpingcounter; - aGameVars[GetGameID("myjumpingtoggle")].lValue = (intptr_t)&myjumpingtoggle; - aGameVars[GetGameID("myonground")].lValue = (intptr_t)&myonground; - aGameVars[GetGameID("myhardlanding")].lValue = (intptr_t)&myhardlanding; - aGameVars[GetGameID("myreturntocenter")].lValue = (intptr_t)&myreturntocenter; + aGameVars[Gv_GetVarIndex("myjumpingtoggle")].lValue = (intptr_t)&myjumpingtoggle; + aGameVars[Gv_GetVarIndex("myonground")].lValue = (intptr_t)&myonground; + aGameVars[Gv_GetVarIndex("myhardlanding")].lValue = (intptr_t)&myhardlanding; + aGameVars[Gv_GetVarIndex("myreturntocenter")].lValue = (intptr_t)&myreturntocenter; - aGameVars[GetGameID("display_mirror")].lValue = (intptr_t)&display_mirror; - aGameVars[GetGameID("randomseed")].lValue = (intptr_t)&randomseed; + aGameVars[Gv_GetVarIndex("display_mirror")].lValue = (intptr_t)&display_mirror; + aGameVars[Gv_GetVarIndex("randomseed")].lValue = (intptr_t)&randomseed; - aGameVars[GetGameID("NUMWALLS")].lValue = (intptr_t)&numwalls; - aGameVars[GetGameID("NUMSECTORS")].lValue = (intptr_t)&numsectors; + aGameVars[Gv_GetVarIndex("NUMWALLS")].lValue = (intptr_t)&numwalls; + aGameVars[Gv_GetVarIndex("NUMSECTORS")].lValue = (intptr_t)&numsectors; + + aGameVars[Gv_GetVarIndex("lastsavepos")].lValue = (intptr_t)&g_lastSaveSlot; } diff --git a/polymer/eduke32/source/global.c b/polymer/eduke32/source/global.c index 50422c679..a3e17110f 100644 --- a/polymer/eduke32/source/global.c +++ b/polymer/eduke32/source/global.c @@ -27,63 +27,61 @@ char *s_builddate = "20081116"; char *MusicPtr = NULL; int Musicsize; -short global_random; +short g_globalRandom; short neartagsector, neartagwall, neartagsprite; -int neartaghitdist,lockclock,start_armour_amount; -// JBF: gc modified to default to Atomic ed. default when using 1.3d CONs -int gc=176; +int neartaghitdist,lockclock,g_startArmorAmount; +// JBF: SpriteGravity modified to default to Atomic ed. default when using 1.3d CONs +int SpriteGravity=176; // int temp_data[MAXSPRITES][6]; -actordata_t hittype[MAXSPRITES]; +actordata_t ActorExtra[MAXSPRITES]; -short spriteq[1024],spriteqloc,spriteqamount=64; +short SpriteDeletionQueue[1024],g_spriteDeleteQueuePos,g_spriteDeleteQueueSize=64; animwalltype animwall[MAXANIMWALLS]; -short numanimwalls; +short g_numAnimWalls; int *animateptr[MAXANIMATES]; -int animategoal[MAXANIMATES], animatevel[MAXANIMATES], animatecnt; +int animategoal[MAXANIMATES], animatevel[MAXANIMATES], g_animateCount; // int oanimateval[MAXANIMATES]; short animatesect[MAXANIMATES]; int msx[2048],msy[2048]; -short cyclers[MAXCYCLERS][6],numcyclers; +short cyclers[MAXCYCLERS][6],g_numCyclers; -char *fta_quotes[MAXQUOTES],*redefined_quotes[MAXQUOTES]; +char *ScriptQuotes[MAXQUOTES], *ScriptQuoteRedefinitions[MAXQUOTES]; char tempbuf[2048], packbuf[576], menutextbuf[128]; char buf[1024]; short camsprite; -short mirrorwall[64], mirrorsector[64], mirrorcnt; +short g_mirrorWall[64], g_mirrorSector[64], g_mirrorCount; -int current_menu; +int g_currentMenu; -map_t map[(MAXVOLUMES+1)*MAXLEVELS]; // +1 volume for "intro", "briefing" music +map_t MapInfo[(MAXVOLUMES+1)*MAXLEVELS]; // +1 volume for "intro", "briefing" music -char volume_names[MAXVOLUMES][33] = { "L.A. MELTDOWN", "LUNAR APOCALYPSE", "SHRAPNEL CITY" }; -char skill_names[5][33] = { "PIECE OF CAKE", "LET'S ROCK", "COME GET SOME", "DAMN I'M GOOD" }; +char EpisodeNames[MAXVOLUMES][33] = { "L.A. MELTDOWN", "LUNAR APOCALYPSE", "SHRAPNEL CITY" }; +char SkillNames[5][33] = { "PIECE OF CAKE", "LET'S ROCK", "COME GET SOME", "DAMN I'M GOOD" }; -char gametype_names[MAXGAMETYPES][33] = { "DUKEMATCH (SPAWN)","COOPERATIVE PLAY","DUKEMATCH (NO SPAWN)","TEAM DM (SPAWN)","TEAM DM (NO SPAWN)"}; -int gametype_flags[MAXGAMETYPES] = {4+8+16+1024+2048+16384,1+2+32+64+128+256+512+4096+8192+32768,2+4+8+16+16384,4+8+16+1024+2048+16384+65536+131072,2+4+8+16+16384+65536+131072}; -char num_gametypes = 5; +char GametypeNames[MAXGAMETYPES][33] = { "DUKEMATCH (SPAWN)","COOPERATIVE PLAY","DUKEMATCH (NO SPAWN)","TEAM DM (SPAWN)","TEAM DM (NO SPAWN)"}; +int GametypeFlags[MAXGAMETYPES] = {4+8+16+1024+2048+16384,1+2+32+64+128+256+512+4096+8192+32768,2+4+8+16+16384,4+8+16+1024+2048+16384+65536+131072,2+4+8+16+16384+65536+131072}; +char g_numGametypes = 5; -short title_zoom; +int g_currentFrameRate; -int framerate; +char g_numVolumes = 3; -char num_volumes = 3; - -short timer=120; +short g_timerTicsPerSecond=120; //fx_device device; sound_t g_sounds[ MAXSOUNDS ]; -char numplayersprites,loadfromgrouponly=0,earthquaketime; +char g_numPlayerSprites,g_loadFromGroupOnly=0,g_earthquakeTime; int fricxv,fricyv; playerdata_t g_player[MAXPLAYERS]; input_t inputfifo[MOVEFIFOSIZ][MAXPLAYERS]; -playerspawn_t g_PlayerSpawnPoints[MAXPLAYERS]; +PlayerSpawn_t g_playerSpawnPoints[MAXPLAYERS]; user_defs ud; char pus, pub; @@ -102,26 +100,25 @@ int screenpeek; //Game recording variables char ready2send; -int vel, svel, angvel, horiz, ototalclock, respawnactortime=768, respawnitemtime=768, groupfile; +int vel, svel, angvel, horiz, ototalclock, g_actorRespawnTime=768, g_itemRespawnTime=768, g_groupFileHandle; -intptr_t *scriptptr,*insptr,*labelcode,*labeltype; -int labelcnt,defaultlabelcnt; -intptr_t *actorscrptr[MAXTILES],*parsing_actor; +intptr_t *g_scriptPtr,*insptr,*labelcode,*labeltype; +int g_numLabels,g_numDefaultLabels; +intptr_t *actorscrptr[MAXTILES],*g_parsingActorPtr; char *label; -char *music_pointer; -char actortype[MAXTILES]; +char ActorType[MAXTILES]; intptr_t *script = NULL; -int g_ScriptSize = 16384; +int g_scriptSize = 16384; char typebuflen,typebuf[141]; -char *music_fn[MAXVOLUMES+1][MAXLEVELS],music_select; -char env_music_fn[MAXVOLUMES+1][BMAX_PATH]; -char rtsplaying; +char g_musicIndex; +char EnvMusicFilename[MAXVOLUMES+1][BMAX_PATH]; +char g_RTSPlaying; -short weaponsandammosprites[15] = +short BlimpSpawnSprites[15] = { RPGSPRITE__STATIC, CHAINGUNSPRITE__STATIC, @@ -140,8 +137,8 @@ short weaponsandammosprites[15] = FREEZEAMMO__STATIC }; -int impact_damage; -int g_ScriptDebug; +int g_impactDamage; +int g_scriptDebug; //GLOBAL.C - replace the end "my's" with this int myx, omyx, myxvel, myy, omyy, myyvel, myz, omyz, myzvel; @@ -151,35 +148,36 @@ short myang, omyang, mycursectnum, myjumpingcounter; char myjumpingtoggle, myonground, myhardlanding, myreturntocenter; signed char multiwho, multipos, multiwhat, multiflag; -int fakemovefifoplc,movefifoplc; +int predictfifoplc,movefifoplc; int myxbak[MOVEFIFOSIZ], myybak[MOVEFIFOSIZ], myzbak[MOVEFIFOSIZ]; -int myhorizbak[MOVEFIFOSIZ],dukefriction = 0xcc00, show_shareware; +int myhorizbak[MOVEFIFOSIZ],g_playerFriction = 0xcc00, g_showShareware; short myangbak[MOVEFIFOSIZ]; -char myname[32]; -int camerashitable,freezerhurtowner=0,lasermode=0; -int networkmode = 255, movesperpacket = 1,gamequit = 0,everyothertime; -int numfreezebounces=3,rpgblastradius,pipebombblastradius,tripbombblastradius,shrinkerblastradius,morterblastradius,bouncemineblastradius,seenineblastradius; +char szPlayerName[32]; +int g_damageCameras,g_freezerSelfDamage=0,g_tripbombLaserMode=0; +int g_networkBroadcastMode = 255, g_movesPerPacket = 1,g_gameQuit = 0,everyothertime; +int g_numFreezeBounces=3,g_rpgBlastRadius,g_pipebombBlastRadius,g_tripbombBlastRadius, + g_shrinkerBlastRadius,g_morterBlastRadius,g_bouncemineBlastRadius,g_seenineBlastRadius; STATUSBARTYPE sbar; int mymaxlag, otherminlag, bufferjitter = 1; -short numclouds,clouds[128],cloudx[128],cloudy[128]; +short g_numClouds,clouds[128],cloudx[128],cloudy[128]; int cloudtotalclock = 0,totalmemory = 0; -int numinterpolations = 0, startofdynamicinterpolations = 0; +int g_numInterpolations = 0, startofdynamicinterpolations = 0; int oldipos[MAXINTERPOLATIONS]; int bakipos[MAXINTERPOLATIONS]; int *curipos[MAXINTERPOLATIONS]; int nextvoxid = 0; -int spriteflags[MAXTILES]; +int SpriteFlags[MAXTILES]; -projectile_t projectile[MAXTILES], thisprojectile[MAXSPRITES], defaultprojectile[MAXTILES]; +projectile_t ProjectileData[MAXTILES], DefaultProjectileData[MAXTILES]; -char cheatkey[2] = { sc_D, sc_N }; +char CheatKeys[2] = { sc_D, sc_N }; char setupfilename[BMAX_PATH]= "duke3d.cfg"; // char datetimestring[] = ""__DATE__" "__TIME__""; -int doquicksave = 0; -unsigned int MoveThingsCount = 0; +int g_doQuickSave = 0; +unsigned int g_moveThingsCount = 0; diff --git a/polymer/eduke32/source/jaudiolib/audiolib_musicstub.c b/polymer/eduke32/source/jaudiolib/audiolib_musicstub.c index d0120ec7f..d2919d415 100644 --- a/polymer/eduke32/source/jaudiolib/audiolib_musicstub.c +++ b/polymer/eduke32/source/jaudiolib/audiolib_musicstub.c @@ -490,5 +490,5 @@ void MUSIC_RegisterTimbreBank void MUSIC_Update(void) {} -void PlayMusic(char *_filename, int loopflag) +void MUSIC_PlayMusic(char *_filename, int loopflag) {} diff --git a/polymer/eduke32/source/jaudiolib/multivoc.c b/polymer/eduke32/source/jaudiolib/multivoc.c index 08d43e6c8..94262cc63 100644 --- a/polymer/eduke32/source/jaudiolib/multivoc.c +++ b/polymer/eduke32/source/jaudiolib/multivoc.c @@ -2977,7 +2977,7 @@ int MV_Shutdown(void) // Stop the sound playback engine MV_StopPlayback(); - // Shutdown the sound card + // G_Shutdown the sound card #if defined(_WIN32) DSOUND_Shutdown(); #else diff --git a/polymer/eduke32/source/jaudiolib/music.c b/polymer/eduke32/source/jaudiolib/music.c index e26d2ba2e..f011d1b0e 100644 --- a/polymer/eduke32/source/jaudiolib/music.c +++ b/polymer/eduke32/source/jaudiolib/music.c @@ -158,9 +158,9 @@ int MUSIC_Init // no AL support so shitcan the ogg definitions for (i=(MAXLEVELS*(MAXVOLUMES+1))-1;i>=0;i--) // +1 volume for "intro", "briefing" music { - if (map[i].musicfn1 != NULL) - Bfree(map[i].musicfn1); - map[i].musicfn1 = NULL; + if (MapInfo[i].musicfn1 != NULL) + Bfree(MapInfo[i].musicfn1); + MapInfo[i].musicfn1 = NULL; } } #endif diff --git a/polymer/eduke32/source/jaudiolib/sdlmusic.c b/polymer/eduke32/source/jaudiolib/sdlmusic.c index c00c80106..21a1ce3e2 100644 --- a/polymer/eduke32/source/jaudiolib/sdlmusic.c +++ b/polymer/eduke32/source/jaudiolib/sdlmusic.c @@ -304,7 +304,7 @@ int MUSIC_StopSong(void) } // MUSIC_StopSong // Duke3D-specific. --ryan. -void PlayMusic(char *_filename) +void MUSIC_PlayMusic(char *_filename) { int handle; int size; diff --git a/polymer/eduke32/source/jmact/scriplib.c b/polymer/eduke32/source/jmact/scriplib.c index b81cd2186..cc0d24daa 100644 --- a/polymer/eduke32/source/jmact/scriplib.c +++ b/polymer/eduke32/source/jmact/scriplib.c @@ -306,7 +306,7 @@ int32 SCRIPT_ParseBuffer(int32 scripthandle, char *data, int32 length) if (!(expect & ExpectingEntry)) { // Unexpected name start - printf("Unexpected entry label on line %d.\n", linenum); + printf("Unexpected entry LabelText on line %d.\n", linenum); SETRV(-1); EATLINE(sp); continue; diff --git a/polymer/eduke32/source/menus.c b/polymer/eduke32/source/menus.c index 2c7dabb0f..81b8c71a6 100644 --- a/polymer/eduke32/source/menus.c +++ b/polymer/eduke32/source/menus.c @@ -31,7 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern char inputloc; extern int recfilep; //extern char vgacompatible; -short globalskillsound=-1; +short g_skillSoundID=-1; int probey=0; static int lastsavehead=0,last_menu_pos=0,last_menu,sh,onbar,buttonstat; static int last_zero,last_fifty,last_onehundred,last_twoohtwo,last_threehundred = 0; @@ -58,9 +58,9 @@ extern int voting; #define mgametext(x,y,t,s,dabits) gametext_z(2,STARTALPHANUM, x,y,t,s,0,dabits,0, 0, xdim-1, ydim-1, 65536) #define mgametextpal(x,y,t,s,p) gametext_z(2,STARTALPHANUM, x,y,t,s,p,26,0, 0, xdim-1, ydim-1, 65536) -void cmenu(int cm) +void ChangeToMenu(int cm) { - current_menu = cm; + g_currentMenu = cm; if ((cm >= 1000 && cm <= 1009)) return; @@ -129,7 +129,7 @@ static int probe_(int type,int x,int y,int i,int n) KB_ClearKeyDown(sc_kpad_8); KB_ClearKeyDown(sc_PgUp); MOUSE_ClearButton(WHEELUP_MOUSE); - sound(KICK_HIT); + S_PlaySound(KICK_HIT); probey--; if (probey < 0) probey = n-1; @@ -141,7 +141,7 @@ static int probe_(int type,int x,int y,int i,int n) KB_ClearKeyDown(sc_kpad_2); KB_ClearKeyDown(sc_PgDn); MOUSE_ClearButton(WHEELDOWN_MOUSE); - sound(KICK_HIT); + S_PlaySound(KICK_HIT); probey++; } } @@ -162,8 +162,8 @@ static int probe_(int type,int x,int y,int i,int n) if (KB_KeyPressed(sc_Space) || KB_KeyPressed(sc_kpad_Enter) || KB_KeyPressed(sc_Enter) || (LMB && !onbar)) { - if (current_menu != 110) - sound(PISTOL_BODYHIT); + if (g_currentMenu != 110) + S_PlaySound(PISTOL_BODYHIT); KB_ClearKeyDown(sc_Enter); KB_ClearKeyDown(sc_Space); KB_ClearKeyDown(sc_kpad_Enter); @@ -174,7 +174,7 @@ static int probe_(int type,int x,int y,int i,int n) { onbar = 0; KB_ClearKeyDown(sc_Escape); - sound(EXITMENUSOUND); + S_PlaySound(EXITMENUSOUND); MOUSE_ClearButton(RIGHT_MOUSE); return(-1); } @@ -188,7 +188,7 @@ static int probe_(int type,int x,int y,int i,int n) return(-probey-2); } } -static inline int probe(int x,int y,int i,int n) +static inline int M_Probe(int x,int y,int i,int n) { return probe_(0,x,y,i,n); } @@ -349,7 +349,7 @@ static void _bar(int type, int x,int y,int *p,int dainc,int damodify,int s, int *p = min; if (*p > max) *p = max; - sound(KICK_HIT); + S_PlaySound(KICK_HIT); } if (*p <= max && *p >= min && (KB_KeyPressed(sc_RightArrow) || KB_KeyPressed(sc_kpad_6) || ((buttonstat&1) && (WHEELDOWN || mii > 256)))) //&& onbar) ) { @@ -364,7 +364,7 @@ static void _bar(int type, int x,int y,int *p,int dainc,int damodify,int s, int *p = max; if (*p < min) *p = min; - sound(KICK_HIT); + S_PlaySound(KICK_HIT); } } @@ -406,7 +406,7 @@ static void modval(int min, int max,int *p,int dainc,int damodify) if (damodify == 2) *p = min; } - sound(PISTOL_BODYHIT); + S_PlaySound(PISTOL_BODYHIT); } if (KB_KeyPressed(sc_RightArrow) || KB_KeyPressed(sc_kpad_6) || ((buttonstat&1) && minfo.dyaw > 256)) //&& onbar) ) { @@ -420,7 +420,7 @@ static void modval(int min, int max,int *p,int dainc,int damodify) if (damodify == 2) *p = max; } - sound(PISTOL_BODYHIT); + S_PlaySound(PISTOL_BODYHIT); } } else @@ -437,7 +437,7 @@ static void modval(int min, int max,int *p,int dainc,int damodify) if (damodify == 2) *p = min; } - sound(PISTOL_BODYHIT); + S_PlaySound(PISTOL_BODYHIT); } if (KB_KeyPressed(sc_LeftArrow) || KB_KeyPressed(sc_kpad_4) || ((buttonstat&1) && minfo.dyaw < -256)) // && onbar) ) { @@ -451,7 +451,7 @@ static void modval(int min, int max,int *p,int dainc,int damodify) if (damodify == 2) *p = max; } - sound(PISTOL_BODYHIT); + S_PlaySound(PISTOL_BODYHIT); } } } @@ -469,14 +469,14 @@ static void modval(int min, int max,int *p,int dainc,int damodify) #define MWIN(X) rotatesprite( 320<<15,200<<15,X,0,MENUSCREEN,-16,0,10+64,0,0,xdim-1,ydim-1) #define MWINXY(X,OX,OY) rotatesprite( ( 320+(OX) )<<15, ( 200+(OY) )<<15,X,0,MENUSCREEN,-16,0,10+64,0,0,xdim-1,ydim-1) -extern int loadpheader(char spot,struct savehead *saveh); +extern int G_LoadSaveHeader(char spot,struct savehead *saveh); static struct savehead savehead; //static int32 volnum,levnum,plrskl,numplr; //static char brdfn[BMAX_PATH]; -int lastsavedpos = -1; +int g_lastSaveSlot = -1; -static void dispnames(void) +static void M_DisplaySaveGameList(void) { int x, c = 160; @@ -519,9 +519,9 @@ static int getfilenames(const char *path, char kind[]) return(0); } -int quittimer = 0; +extern int quittimer; -void check_valid_color(int *color, int prev_color) +void G_CheckPlayerColor(int *color, int prev_color) { int i, disallowed[] = { 1, 2, 3, 4, 5, 6, 7, 8, 17, 18, 19, 20, 22 }; @@ -537,38 +537,7 @@ void check_valid_color(int *color, int prev_color) } } -void sendquit(void) -{ - if (gamequit == 0 && (numplayers > 1)) - { - if (g_player[myconnectindex].ps->gm&MODE_GAME) - { - gamequit = 1; - quittimer = totalclock+120; - } - else - { - int i; - - tempbuf[0] = 254; - tempbuf[1] = myconnectindex; - - for (i=connecthead;i >= 0;i=connectpoint2[i]) - { - if (i != myconnectindex) sendpacket(i,tempbuf,2); - if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master - } - gameexit(" "); - } - } - else if (numplayers < 2) - gameexit(" "); - - if ((totalclock > quittimer) && (gamequit == 1)) - gameexit("Timed out."); -} - -void menus(void) +void M_DisplayMenus(void) { CACHE1D_FIND_REC *dir; int c,x,i; @@ -593,7 +562,7 @@ void menus(void) walock[TILE_LOADSHOT] = 1; return; } - OnEvent(EVENT_DISPLAYMENU, g_player[screenpeek].ps->i, screenpeek, -1); + X_OnEvent(EVENT_DISPLAYMENU, g_player[screenpeek].ps->i, screenpeek, -1); g_player[myconnectindex].ps->gm &= (0xff-MODE_TYPE); g_player[myconnectindex].ps->fta = 0; @@ -610,12 +579,12 @@ void menus(void) rotatesprite(x<<16,y<<16,65536L,0,MENUSCREEN,80,0,1+8+16,0,0,xdim-1,ydim-1); } - if (!(current_menu >= 1000 && current_menu <= 2999 && current_menu >= 300 && current_menu <= 369)) - vscrn(); + if (!(g_currentMenu >= 1000 && g_currentMenu <= 2999 && g_currentMenu >= 300 && g_currentMenu <= 369)) + G_UpdateScreenArea(); if (KB_KeyPressed(sc_Q)) { - switch (current_menu) + switch (g_currentMenu) { case 102: case 210: @@ -638,23 +607,23 @@ void menus(void) case 20005: break; default: - if (current_menu >= 0) + if (g_currentMenu >= 0) { - last_menu = current_menu; + last_menu = g_currentMenu; last_menu_pos = probey; - cmenu(502); + ChangeToMenu(502); } break; } } - switch (current_menu) + switch (g_currentMenu) { case 25000: mgametext(160,90,"SELECT A SAVE SPOT BEFORE",0,2+8+16); mgametext(160,90+9,"YOU QUICK RESTORE.",0,2+8+16); - x = probe(186,124,0,1); + x = M_Probe(186,124,0,1); if (x >= -1) { if (ud.multimode < 2 && ud.recstat != 2) @@ -667,7 +636,7 @@ void menus(void) break; case 20000: - x = probe(326,190,0,1); + x = M_Probe(326,190,0,1); mgametext(160,41-8,"YOU ARE PLAYING THE SHAREWARE",0,2+8+16); mgametext(160,50-8,"VERSION OF DUKE NUKEM 3D. WHILE",0,2+8+16); mgametext(160,59-8,"THIS VERSION IS REALLY COOL, YOU",0,2+8+16); @@ -684,19 +653,19 @@ void menus(void) mgametext(160,139+8,"VERSION OF DUKE NUKEM 3D.",0,2+8+16); mgametext(160,148+16,"PRESS ANY KEY...",0,2+8+16); - if (x >= -1) cmenu(100); + if (x >= -1) ChangeToMenu(100); break; case 20001: rotatesprite(160<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); menutext(160,24,0,0,"NETWORK GAME"); - x = probe(160,100-18,18,3); + x = M_Probe(160,100-18,18,3); - if (x == -1) cmenu(0); - else if (x == 2) cmenu(20010); - else if (x == 1) cmenu(20020); - else if (x == 0) cmenu(20002); + if (x == -1) ChangeToMenu(0); + else if (x == 2) ChangeToMenu(20010); + else if (x == 1) ChangeToMenu(20020); + else if (x == 0) ChangeToMenu(20002); menutext(160,100-18,MENUHIGHLIGHT(0),0,"PLAYER SETUP"); menutext(160,100,MENUHIGHLIGHT(1),0,"JOIN GAME"); @@ -737,7 +706,7 @@ void menus(void) x = ud.color; if (probey == 2) - x = getteampal(ud.team); + x = G_GetTeamPalette(ud.team); rotatesprite((260)<<16,(24+(tilesizy[APLAYER]>>1))<<16,49152L,0,1441-((((4-(totalclock>>4)))&3)*5),0,x,10,0,0,xdim-1,ydim-1); @@ -753,13 +722,13 @@ void menus(void) } - if (current_menu == 20002) + if (g_currentMenu == 20002) { x = probesm(c,yy+5,0,io); if (x == -1) { - cmenu(202); + ChangeToMenu(202); probey = 3; break; } @@ -774,9 +743,9 @@ void menus(void) case 0: if (x == io) { - strcpy(buf, myname); + strcpy(buf, szPlayerName); inputloc = strlen(buf); - current_menu = 20003; + g_currentMenu = 20003; KB_ClearKeyDown(sc_Enter); KB_ClearKeyDown(sc_kpad_Enter); @@ -791,12 +760,12 @@ void menus(void) ud.color++; if (ud.color > 23) ud.color = 0; - check_valid_color((int *)&ud.color,-1); + G_CheckPlayerColor((int *)&ud.color,-1); } modval(0,23,(int *)&ud.color,1,probey==1); - check_valid_color((int *)&ud.color,i); + G_CheckPlayerColor((int *)&ud.color,i); if (ud.color != i) - updateplayer(); + G_UpdatePlayerFromMenu(); break; case 2: @@ -809,7 +778,7 @@ void menus(void) } modval(0,3,(int *)&ud.team,1,probey==2); if (ud.team != i) - updateplayer(); + G_UpdatePlayerFromMenu(); break; case 3: @@ -818,7 +787,7 @@ void menus(void) ud.config.AutoAim = (ud.config.AutoAim == 2) ? 0 : ud.config.AutoAim+1; modval(0,2,(int *)&ud.config.AutoAim,1,probey==3); if (ud.config.AutoAim != i) - updateplayer(); + G_UpdatePlayerFromMenu(); break; case 4: @@ -827,7 +796,7 @@ void menus(void) ud.mouseaiming = !ud.mouseaiming; modval(0,1,(int *)&ud.mouseaiming,1,probey==4); if (ud.mouseaiming != i) - updateplayer(); + G_UpdatePlayerFromMenu(); break; case 5: @@ -840,7 +809,7 @@ void menus(void) if ((ud.weaponswitch & 1 && !i) || (!(ud.weaponswitch & 1) && i)) { ud.weaponswitch ^= 1; - updateplayer(); + G_UpdatePlayerFromMenu(); } break; case 6: @@ -853,7 +822,7 @@ void menus(void) if ((ud.weaponswitch & 2 && !i) || (!(ud.weaponswitch & 2) && i)) { ud.weaponswitch ^= 2; - updateplayer(); + G_UpdatePlayerFromMenu(); } break; #ifndef RANCID_NETWORKING @@ -866,7 +835,7 @@ void menus(void) case 8: if (x == io) { - cmenu(20004); + ChangeToMenu(20004); } break; @@ -878,9 +847,9 @@ void menus(void) } else { - // because stripcolorcodes needs a valid target and tempbuf is used in strget() + // because stripcolorcodes needs a valid target and tempbuf is used in G_EnterText() char dummybuf[64]; - x = strget(d-50,37,buf,30,0); + x = G_EnterText(d-50,37,buf,30,0); while (Bstrlen(stripcolorcodes(dummybuf,buf)) > 10) { @@ -892,10 +861,10 @@ void menus(void) { if (x == 1) { - if (buf[0] && Bstrcmp(myname,buf)) + if (buf[0] && Bstrcmp(szPlayerName,buf)) { - Bstrcpy(myname,buf); - updateplayer(); + Bstrcpy(szPlayerName,buf); + Net_SendPlayerName(); } // send name update } @@ -903,7 +872,7 @@ void menus(void) KB_ClearKeyDown(sc_kpad_Enter); KB_FlushKeyboardQueue(); - current_menu = 20002; + g_currentMenu = 20002; } } @@ -920,9 +889,9 @@ void menus(void) switch (io) { case 0: - if (current_menu == 20002) + if (g_currentMenu == 20002) { - mgametext(d-50,yy,myname,MENUHIGHLIGHT(io),2+8+16); + mgametext(d-50,yy,szPlayerName,MENUHIGHLIGHT(io),2+8+16); } break; @@ -987,12 +956,12 @@ void menus(void) rotatesprite(160<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); menutext(160,24,0,0,"MULTIPLAYER MACROS"); - if (current_menu == 20004) + if (g_currentMenu == 20004) { x = probesm(24,45,8,10); if (x == -1) { - cmenu(20002); + ChangeToMenu(20002); probey = 8; } else if (x >= 0 && x <= 9) @@ -1000,7 +969,7 @@ void menus(void) strcpy(buf, ud.ridecule[x]); inputloc = strlen(buf); last_menu_pos = probey; - current_menu = 20005; + g_currentMenu = 20005; KB_ClearKeyDown(sc_Enter); KB_ClearKeyDown(sc_kpad_Enter); KB_FlushKeyboardQueue(); @@ -1008,7 +977,7 @@ void menus(void) } else { - x = strget(26,40+(8*probey),buf,34,0); + x = G_EnterText(26,40+(8*probey),buf,34,0); if (x) { if (x == 1) @@ -1018,12 +987,12 @@ void menus(void) KB_ClearKeyDown(sc_Enter); KB_ClearKeyDown(sc_kpad_Enter); KB_FlushKeyboardQueue(); - current_menu = 20004; + g_currentMenu = 20004; } } for (i=0;i<10;i++) { - if (current_menu == 20005 && i == last_menu_pos) continue; + if (g_currentMenu == 20005 && i == last_menu_pos) continue; mgametextpal(26,40+(i<<3),ud.ridecule[i],MENUHIGHLIGHT(i),0); } @@ -1036,14 +1005,14 @@ void menus(void) rotatesprite(160<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); menutext(160,24,0,0,"HOST NETWORK GAME"); - x = probe(46,50,80,2); + x = M_Probe(46,50,80,2); if (x == -1) { - cmenu(20001); + ChangeToMenu(20001); probey = 2; } - else if (x == 0) cmenu(20011); + else if (x == 0) ChangeToMenu(20011); menutext(40,50,0,0, "GAME OPTIONS"); minitext(90,60, "GAME TYPE" ,2,26); @@ -1056,12 +1025,12 @@ void menus(void) minitext(90,60+8+8+8+8, "FRIENDLY FIRE",2,26); minitext(90,60+8+8+8+8+8, "USER MAP" ,2,26); - mgametext(90+60,60,gametype_names[ud.m_coop],0,26); + mgametext(90+60,60,GametypeNames[ud.m_coop],0,26); - minitext(90+60,60+8, volume_names[ud.m_volume_number],0,26); + minitext(90+60,60+8, EpisodeNames[ud.m_volume_number],0,26); minitext(90+60,60+8+8, level_names[MAXLEVELS*ud.m_volume_number+ud.m_level_number],0,26); if (ud.m_monsters_off == 0 || ud.m_player_skill > 0) - minitext(90+60,60+8+8+8, skill_names[ud.m_player_skill],0,26); + minitext(90+60,60+8+8+8, SkillNames[ud.m_player_skill],0,26); else minitext(90+60,60+8+8+8, "NONE",0,28); if (ud.m_coop == 0) { @@ -1082,12 +1051,12 @@ void menus(void) rotatesprite(160<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); menutext(160,24,0,0,"NET GAME OPTIONS"); - x = probe(c,57-8,16,8); + x = M_Probe(c,57-8,16,8); switch (x) { case -1: - cmenu(20010); + ChangeToMenu(20010); break; case 0: ud.m_coop++; @@ -1097,7 +1066,7 @@ void menus(void) if (!VOLUMEONE) { ud.m_volume_number++; - if (ud.m_volume_number == num_volumes) ud.m_volume_number = 0; + if (ud.m_volume_number == g_numVolumes) ud.m_volume_number = 0; if (ud.m_volume_number == 0 && ud.m_level_number > 6) ud.m_level_number = 0; if (ud.m_level_number > 10) ud.m_level_number = 0; @@ -1149,7 +1118,7 @@ void menus(void) break; case 7: - cmenu(20010); + ChangeToMenu(20010); break; } @@ -1158,14 +1127,14 @@ void menus(void) // if(ud.m_coop==1) mgametext(c+70,57-7-9,"COOPERATIVE PLAY",0,2+8+16); // else if(ud.m_coop==2) mgametext(c+70,57-7-9,"DUKEMATCH (NO SPAWN)",0,2+8+16); // else mgametext(c+70,57-7-9,"DUKEMATCH (SPAWN)",0,2+8+16); - mgametext(c+70,57-7-9,gametype_names[ud.m_coop],0,26); + mgametext(c+70,57-7-9,GametypeNames[ud.m_coop],0,26); - mgametext(c+70,57+16-7-9,volume_names[ud.m_volume_number],0,2+8+16); + mgametext(c+70,57+16-7-9,EpisodeNames[ud.m_volume_number],0,2+8+16); mgametext(c+70,57+16+16-7-9,&level_names[MAXLEVELS*ud.m_volume_number+ud.m_level_number][0],0,2+8+16); if (ud.m_monsters_off == 0 || ud.m_player_skill > 0) - mgametext(c+70,57+16+16+16-7-9,skill_names[ud.m_player_skill],0,2+8+16); + mgametext(c+70,57+16+16+16-7-9,SkillNames[ud.m_player_skill],0,2+8+16); else mgametext(c+70,57+16+16+16-7-9,"NONE",0,2+8+16); if (ud.m_coop == 0) @@ -1223,26 +1192,26 @@ void menus(void) rotatesprite(160<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); menutext(160,24,0,0,"JOIN NETWORK GAME"); - if (current_menu == 20020) + if (g_currentMenu == 20020) { - x = probe(46,50,20,3); + x = M_Probe(46,50,20,3); if (x == -1) { - cmenu(20001); + ChangeToMenu(20001); probey = 1; } else if (x == 0) { strcpy(buf, "localhost"); inputloc = strlen(buf); - current_menu = 20021; + g_currentMenu = 20021; } else if (x == 1) { strcpy(buf, "19014"); inputloc = strlen(buf); - current_menu = 20022; + g_currentMenu = 20022; } else if (x == 2) {} @@ -1250,46 +1219,46 @@ void menus(void) KB_ClearKeyDown(sc_kpad_Enter); KB_FlushKeyboardQueue(); } - else if (current_menu == 20021) + else if (g_currentMenu == 20021) { - x = strget(40+100,50-9,buf,31,0); + x = G_EnterText(40+100,50-9,buf,31,0); if (x) { if (x == 1) { - //strcpy(myname,buf); + //strcpy(szPlayerName,buf); } KB_ClearKeyDown(sc_Enter); KB_ClearKeyDown(sc_kpad_Enter); KB_FlushKeyboardQueue(); - current_menu = 20020; + g_currentMenu = 20020; } } - else if (current_menu == 20022) + else if (g_currentMenu == 20022) { - x = strget(40+100,50+20-9,buf,5,997); + x = G_EnterText(40+100,50+20-9,buf,5,997); if (x) { if (x == 1) { - //strcpy(myname,buf); + //strcpy(szPlayerName,buf); } KB_ClearKeyDown(sc_Enter); KB_ClearKeyDown(sc_kpad_Enter); KB_FlushKeyboardQueue(); - current_menu = 20020; + g_currentMenu = 20020; } } menutext(40,50,0,0,"SERVER"); - if (current_menu != 20021) mgametext(40+100,50-9,"server",0,2+8+16); + if (g_currentMenu != 20021) mgametext(40+100,50-9,"server",0,2+8+16); menutext(40,50+20,0,0,"PORT"); - if (current_menu != 20022) + if (g_currentMenu != 20022) { sprintf(tempbuf,"%d",19014); mgametext(40+100,50+20-9,tempbuf,0,2+8+16); @@ -1308,7 +1277,7 @@ void menus(void) mgametext(160,90,"LOAD last game:",0,2+8+16); - sprintf(tempbuf,"\"%s\"",ud.savegame[lastsavedpos]); + sprintf(tempbuf,"\"%s\"",ud.savegame[g_lastSaveSlot]); mgametext(160,99,tempbuf,0,2+8+16); mgametext(160,99+9,"(Y/N)",0,2+8+16); @@ -1317,7 +1286,7 @@ void menus(void) { if (sprite[g_player[myconnectindex].ps->i].extra <= 0) { - if (enterlevel(MODE_GAME)) backtomenu(); + if (G_EnterLevel(MODE_GAME)) G_BackToMenu(); return; } @@ -1340,18 +1309,18 @@ void menus(void) if (ud.multimode > 1) { - loadplayer(-1-lastsavedpos); + G_LoadPlayer(-1-g_lastSaveSlot); g_player[myconnectindex].ps->gm = MODE_GAME; } else { - c = loadplayer(lastsavedpos); + c = G_LoadPlayer(g_lastSaveSlot); if (c == 0) g_player[myconnectindex].ps->gm = MODE_GAME; } } - probe(186,124+9,0,0); + M_Probe(186,124+9,0,0); break; @@ -1362,10 +1331,10 @@ void menus(void) rotatesprite(160<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); menutext(160,24,0,0,"ADULT MODE"); - x = probe(60,50+16,16,2); + x = M_Probe(60,50+16,16,2); if (x == -1) { - cmenu(201); + ChangeToMenu(201); probey = 0; break; } @@ -1375,10 +1344,10 @@ void menus(void) menutext(c+160+40,50+16,MENUHIGHLIGHT(0),0,ud.lockout?"OFF":"ON"); - if (current_menu == 10001) + if (g_currentMenu == 10001) { mgametext(160,50+16+16+16+16-12,"ENTER PASSWORD",0,2+8+16); - x = strget((320>>1),50+16+16+16+16,buf,19, 998); + x = G_EnterText((320>>1),50+16+16+16+16,buf,19, 998); if (x) { @@ -1389,7 +1358,7 @@ void menus(void) ud.lockout = 0; buf[0] = 0; - for (x=0;x>1,512,TILE_LOADSHOT,-32,0,4+10+64,0,0,xdim-1,ydim-1); - dispnames(); + M_DisplaySaveGameList(); sprintf(tempbuf,"PLAYERS: %-2d ",savehead.numplr); mgametext(160,156,tempbuf,0,2+8+16); @@ -1483,13 +1452,13 @@ void menus(void) mgametext(160,180,savehead.boardfn,0,2+8+16); mgametext(160,90,"LOAD game:",0,2+8+16); - sprintf(tempbuf,"\"%s\"",ud.savegame[current_menu-1000]); + sprintf(tempbuf,"\"%s\"",ud.savegame[g_currentMenu-1000]); mgametext(160,99,tempbuf,0,2+8+16); mgametext(160,99+9,"(Y/N)",0,2+8+16); if (KB_KeyPressed(sc_Space) || KB_KeyPressed(sc_Enter) || KB_KeyPressed(sc_kpad_Enter) || KB_KeyPressed(sc_Y) || LMB) { - lastsavedpos = current_menu-1000; + g_lastSaveSlot = g_currentMenu-1000; KB_FlushKeyboardQueue(); KB_ClearKeysDown(); @@ -1503,29 +1472,29 @@ void menus(void) { if (g_player[myconnectindex].ps->gm&MODE_GAME) { - loadplayer(-1-lastsavedpos); + G_LoadPlayer(-1-g_lastSaveSlot); g_player[myconnectindex].ps->gm = MODE_GAME; } else { - tempbuf[0] = 126; - tempbuf[1] = lastsavedpos; + tempbuf[0] = PACKET_TYPE_LOAD_GAME; + tempbuf[1] = g_lastSaveSlot; tempbuf[2] = myconnectindex; - for (x=connecthead;x>=0;x=connectpoint2[x]) + TRAVERSE_CONNECT(x) { if (x != myconnectindex) sendpacket(x,tempbuf,3); - if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master + if ((!g_networkBroadcastMode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master } getpackets(); - loadplayer(lastsavedpos); + G_LoadPlayer(g_lastSaveSlot); multiflag = 0; } } else { - c = loadplayer(lastsavedpos); + c = G_LoadPlayer(g_lastSaveSlot); if (c == 0) g_player[myconnectindex].ps->gm = MODE_GAME; } @@ -1533,13 +1502,13 @@ void menus(void) break; } - probe(186,124+9,0,0); + M_Probe(186,124+9,0,0); if (KB_KeyPressed(sc_N) || KB_KeyPressed(sc_Escape) || RMB) { KB_ClearKeyDown(sc_N); KB_ClearKeyDown(sc_Escape); - sound(EXITMENUSOUND); + S_PlaySound(EXITMENUSOUND); if (g_player[myconnectindex].ps->gm&MODE_GAME) { g_player[myconnectindex].ps->gm &= ~MODE_MENU; @@ -1551,7 +1520,7 @@ void menus(void) } else { - cmenu(300); + ChangeToMenu(300); probey = last_threehundred; } } @@ -1563,7 +1532,7 @@ void menus(void) if (KB_KeyPressed(sc_Space) || KB_KeyPressed(sc_Enter) || KB_KeyPressed(sc_kpad_Enter) || KB_KeyPressed(sc_Y) || LMB) { KB_FlushKeyboardQueue(); - cmenu(100); + ChangeToMenu(100); } if (KB_KeyPressed(sc_N) || KB_KeyPressed(sc_Escape) || RMB) { @@ -1575,10 +1544,10 @@ void menus(void) totalclock = ototalclock; } g_player[myconnectindex].ps->gm &= ~MODE_MENU; - sound(EXITMENUSOUND); + S_PlaySound(EXITMENUSOUND); break; } - probe(186,124,0,0); + M_Probe(186,124,0,0); mgametext(160,90,"ABORT this game?",0,2+8+16); mgametext(160,90+9,"(Y/N)",0,2+8+16); @@ -1609,16 +1578,16 @@ void menus(void) if (ud.volume_number == 0 && ud.level_number == 7) mgametext(160,180,boardfilename,0,2+8+16); - dispnames(); + M_DisplaySaveGameList(); mgametext(160,90,"OVERWRITE previous SAVED game?",0,2+8+16); mgametext(160,90+9,"(Y/N)",0,2+8+16); if (KB_KeyPressed(sc_Space) || KB_KeyPressed(sc_Enter) || KB_KeyPressed(sc_kpad_Enter) || KB_KeyPressed(sc_Y) || LMB) { - inputloc = strlen(&ud.savegame[current_menu-2000][0]); + inputloc = strlen(&ud.savegame[g_currentMenu-2000][0]); - cmenu(current_menu-2000+360); + ChangeToMenu(g_currentMenu-2000+360); KB_FlushKeyboardQueue(); break; @@ -1627,11 +1596,11 @@ void menus(void) { KB_ClearKeyDown(sc_N); KB_ClearKeyDown(sc_Escape); - cmenu(351); - sound(EXITMENUSOUND); + ChangeToMenu(351); + S_PlaySound(EXITMENUSOUND); } - probe(186,124,0,0); + M_Probe(186,124,0,0); break; @@ -1649,7 +1618,7 @@ void menus(void) { //rotatesprite(c<<16,200<<15,65536L,0,MENUSCREEN,16,0,10+64,0,0,xdim-1,ydim-1); rotatesprite(c<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); - menutext(c,24,0,0,current_menu == 998 ? "ABOUT EDUKE32" : "CREDITS"); + menutext(c,24,0,0,g_currentMenu == 998 ? "ABOUT EDUKE32" : "CREDITS"); l = 8; } @@ -1671,9 +1640,9 @@ void menus(void) KB_ClearKeyDown(sc_PgUp); KB_ClearKeyDown(sc_kpad_8); - sound(KICK_HIT); - current_menu--; - if (current_menu < 990) current_menu = 990+l; + S_PlaySound(KICK_HIT); + g_currentMenu--; + if (g_currentMenu < 990) g_currentMenu = 990+l; } else if ( KB_KeyPressed(sc_PgDn) || @@ -1696,22 +1665,22 @@ void menus(void) KB_ClearKeyDown(sc_kpad_2); KB_ClearKeyDown(sc_DownArrow); KB_ClearKeyDown(sc_Space); - sound(KICK_HIT); - current_menu++; - if (current_menu > 990+l) current_menu = 990; + S_PlaySound(KICK_HIT); + g_currentMenu++; + if (g_currentMenu > 990+l) g_currentMenu = 990; } - x = probe(0,0,0,1); + x = M_Probe(0,0,0,1); if (x == -1) { - cmenu(0); + ChangeToMenu(0); break; } if (!VOLUMEALL || !PLUTOPAK) { - switch (current_menu) + switch (g_currentMenu) { case 990: mgametext(c,40, "ORIGINAL CONCEPT",0,2+8+16); @@ -1826,12 +1795,12 @@ void menus(void) } // Plutonium pak menus - switch (current_menu) + switch (g_currentMenu) { case 990: case 991: case 992: - rotatesprite(160<<16,200<<15,65536L,0,2504+current_menu-990,0,0,10+64,0,0,xdim-1,ydim-1); + rotatesprite(160<<16,200<<15,65536L,0,2504+g_currentMenu-990,0,0,10+64,0,0,xdim-1,ydim-1); break; case 993: // JBF 20031220 rotatesprite(160<<16,200<<15,65536L,0,MENUSCREEN,0,0,10+64,0,0,xdim-1,ydim-1); @@ -1839,7 +1808,7 @@ void menus(void) menutext(160,24,0,0,"ABOUT EDUKE32"); cheat_for_port_credits: - if (g_ScriptVersion == 13) l = (-2); + if (g_scriptVersion == 13) l = (-2); mgametext(160,38-l,"GAME PROGRAMMING",0,2+8+16); p = "Richard \"TerminX\" Gobeille"; minitext(161-(Bstrlen(p)<<1), 39+10-l, p, 4, 10+16+128); @@ -1924,16 +1893,16 @@ cheat_for_port_credits: rotatesprite(c<<16,28<<16,65536L,0,INGAMEDUKETHREEDEE,0,0,10,0,0,xdim-1,ydim-1); if (PLUTOPAK) // JBF 20030804 rotatesprite((c+100)<<16,36<<16,65536L,0,PLUTOPAKSPRITE+2,(sintable[(totalclock<<4)&2047]>>11),0,2+8,0,0,xdim-1,ydim-1); - x = probe(c,67,16,6); + x = M_Probe(c,67,16,6); if (x >= 0) { if (ud.multimode > 1 && x == 0 && ud.recstat != 2) { - if (movesperpacket == 4 && myconnectindex != connecthead) + if (g_movesPerPacket == 4 && myconnectindex != connecthead) break; last_zero = 0; - cmenu(600); + ChangeToMenu(600); } else { @@ -1941,32 +1910,32 @@ cheat_for_port_credits: switch (x) { case 0: - cmenu(100); + ChangeToMenu(100); break; - //case 1: break;//cmenu(20001);break; // JBF 20031128: I'm taking over the TEN menu option + //case 1: break;//ChangeToMenu(20001);break; // JBF 20031128: I'm taking over the TEN menu option case 1: - cmenu(202); + ChangeToMenu(202); break; // JBF 20031205: was 200 case 2: - if (movesperpacket == 4 && connecthead != myconnectindex) + if (g_movesPerPacket == 4 && connecthead != myconnectindex) break; - cmenu(300); + ChangeToMenu(300); break; case 3: KB_FlushKeyboardQueue(); - cmenu(400); + ChangeToMenu(400); break; case 4: - cmenu(990); + ChangeToMenu(990); break; case 5: - cmenu(500); + ChangeToMenu(500); break; } } } - if (KB_KeyPressed(sc_Q)) cmenu(500); + if (KB_KeyPressed(sc_Q)) ChangeToMenu(500); if (x == -1 && (g_player[myconnectindex].ps->gm&MODE_GAME || ud.recstat == 2)) { @@ -1978,7 +1947,7 @@ cheat_for_port_credits: } } - if (movesperpacket == 4) + if (g_movesPerPacket == 4) { if (myconnectindex == connecthead) menutext(c,67,MENUHIGHLIGHT(0),PHX(-2),"NEW GAME"); @@ -1992,7 +1961,7 @@ cheat_for_port_credits: menutext(c,67+16/*+16*/,MENUHIGHLIGHT(1),PHX(-3),"OPTIONS"); - if (movesperpacket == 4 && connecthead != myconnectindex) + if (g_movesPerPacket == 4 && connecthead != myconnectindex) menutext(c,67+16+16/*+16*/,MENUHIGHLIGHT(2),1,"LOAD GAME"); else menutext(c,67+16+16/*+16*/,MENUHIGHLIGHT(2),PHX(-4),"LOAD GAME"); @@ -2018,55 +1987,55 @@ cheat_for_port_credits: rotatesprite(c<<16,32<<16,65536L,0,INGAMEDUKETHREEDEE,0,0,10,0,0,xdim-1,ydim-1); if (PLUTOPAK) // JBF 20030804 rotatesprite((c+100)<<16,36<<16,65536L,0,PLUTOPAKSPRITE+2,(sintable[(totalclock<<4)&2047]>>11),0,2+8,0,0,xdim-1,ydim-1); - x = probe(c,67,16,7); + x = M_Probe(c,67,16,7); switch (x) { case 0: - if (movesperpacket == 4 && myconnectindex != connecthead) + if (g_movesPerPacket == 4 && myconnectindex != connecthead) break; if (ud.multimode < 2 || ud.recstat == 2) - cmenu(1500); + ChangeToMenu(1500); else { - cmenu(600); + ChangeToMenu(600); last_fifty = 0; } break; case 1: - if (movesperpacket == 4 && connecthead != myconnectindex) + if (g_movesPerPacket == 4 && connecthead != myconnectindex) break; if (ud.recstat != 2) { last_fifty = 1; - cmenu(350); + ChangeToMenu(350); setview(0,0,xdim-1,ydim-1); } break; case 2: - if (movesperpacket == 4 && connecthead != myconnectindex) + if (g_movesPerPacket == 4 && connecthead != myconnectindex) break; last_fifty = 2; - cmenu(300); + ChangeToMenu(300); break; case 3: last_fifty = 3; - cmenu(202); // JBF 20031205: was 200 + ChangeToMenu(202); // JBF 20031205: was 200 break; case 4: last_fifty = 4; KB_FlushKeyboardQueue(); - cmenu(400); + ChangeToMenu(400); break; case 5: if (numplayers < 2) { last_fifty = 5; - cmenu(501); + ChangeToMenu(501); } break; case 6: last_fifty = 6; - cmenu(500); + ChangeToMenu(500); break; case -1: g_player[myconnectindex].ps->gm &= ~MODE_MENU; @@ -2079,9 +2048,9 @@ cheat_for_port_credits: } if (KB_KeyPressed(sc_Q)) - cmenu(500); + ChangeToMenu(500); - if (movesperpacket == 4 && connecthead != myconnectindex) + if (g_movesPerPacket == 4 && connecthead != myconnectindex) { menutext(c,67 ,MENUHIGHLIGHT(0),1,"NEW GAME"); menutext(c,67+16 ,MENUHIGHLIGHT(1),1,"SAVE GAME"); @@ -2112,62 +2081,62 @@ cheat_for_port_credits: case 100: rotatesprite(160<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); menutext(160,24,0,0,"SELECT AN EPISODE"); - x = probe(160,VOLUMEONE?60:60-(num_volumes*2),20,VOLUMEONE?3:num_volumes+1); + x = M_Probe(160,VOLUMEONE?60:60-(g_numVolumes*2),20,VOLUMEONE?3:g_numVolumes+1); if (x >= 0) { if (VOLUMEONE) { if (x > 0) - cmenu(20000); + ChangeToMenu(20000); else { ud.m_volume_number = x; ud.m_level_number = 0; last_onehundred = x; - cmenu(110); + ChangeToMenu(110); } } if (!VOLUMEONE) { - if (x == num_volumes /*&& boardfilename[0]*/) + if (x == g_numVolumes /*&& boardfilename[0]*/) { //ud.m_volume_number = 0; //ud.m_level_number = 7; currentlist = 1; last_onehundred = x; - cmenu(101); + ChangeToMenu(101); } else { ud.m_volume_number = x; ud.m_level_number = 0; last_onehundred = x; - cmenu(110); + ChangeToMenu(110); } } } else if (x == -1) { - if (g_player[myconnectindex].ps->gm&MODE_GAME) cmenu(50); - else cmenu(0); + if (g_player[myconnectindex].ps->gm&MODE_GAME) ChangeToMenu(50); + else ChangeToMenu(0); } c = 80; if (VOLUMEONE) { - menutext(160,60,MENUHIGHLIGHT(0),PHX(-2),volume_names[0]); - menutext(160,60+20,MENUHIGHLIGHT(1),1,volume_names[1]); - menutext(160,60+20+20,MENUHIGHLIGHT(2),1,volume_names[2]); + menutext(160,60,MENUHIGHLIGHT(0),PHX(-2),EpisodeNames[0]); + menutext(160,60+20,MENUHIGHLIGHT(1),1,EpisodeNames[1]); + menutext(160,60+20+20,MENUHIGHLIGHT(2),1,EpisodeNames[2]); if (PLUTOPAK) - menutext(160,60+20+20,MENUHIGHLIGHT(3),1,volume_names[3]); + menutext(160,60+20+20,MENUHIGHLIGHT(3),1,EpisodeNames[3]); } else { - for (i=0;i 0) @@ -2217,7 +2186,7 @@ cheat_for_port_credits: { if (currentlist) findfileshigh = seeker; else finddirshigh = seeker; - sound(KICK_HIT); + S_PlaySound(KICK_HIT); } } else @@ -2238,7 +2207,7 @@ cheat_for_port_credits: { if (currentlist) findfileshigh = seeker; else finddirshigh = seeker; - sound(KICK_HIT); + S_PlaySound(KICK_HIT); } } } @@ -2307,7 +2276,7 @@ cheat_for_port_credits: KB_ClearKeyDown(sc_kpad_6); KB_ClearKeyDown(sc_Tab); currentlist = 1-currentlist; - sound(KICK_HIT); + S_PlaySound(KICK_HIT); } onbar = 0; @@ -2348,11 +2317,11 @@ cheat_for_port_credits: boardfilename[0] = 0; if (ud.multimode > 1) { - sendboardname(); - cmenu(600); + Net_SendUserMapName(); + ChangeToMenu(600); probey = last_menu_pos; } - else cmenu(100); + else ChangeToMenu(100); } else if (x >= 0) { @@ -2362,7 +2331,7 @@ cheat_for_port_credits: strcat(boardfilename, finddirshigh->name); strcat(boardfilename, "/"); Bcorrectfilename(boardfilename, 1); - cmenu(101); + ChangeToMenu(101); KB_FlushKeyboardQueue(); } else @@ -2373,11 +2342,11 @@ cheat_for_port_credits: ud.m_level_number = 7; if (ud.multimode > 1) { - sendboardname(); - cmenu(600); + Net_SendUserMapName(); + ChangeToMenu(600); probey = last_menu_pos; } - else cmenu(110); + else ChangeToMenu(110); } clearfilenames(); } @@ -2387,26 +2356,26 @@ cheat_for_port_credits: c = (320>>1); rotatesprite(c<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); menutext(c,24,0,0,"SELECT SKILL"); - x = probe(c,70,19,4); + x = M_Probe(c,70,19,4); if (x >= 0) { switch (x) { case 0: - globalskillsound = JIBBED_ACTOR6; + g_skillSoundID = JIBBED_ACTOR6; break; case 1: - globalskillsound = BONUS_SPEECH1; + g_skillSoundID = BONUS_SPEECH1; break; case 2: - globalskillsound = DUKE_GETWEAPON2; + g_skillSoundID = DUKE_GETWEAPON2; break; case 3: - globalskillsound = JIBBED_ACTOR5; + g_skillSoundID = JIBBED_ACTOR5; break; } - sound(globalskillsound); + S_PlaySound(g_skillSoundID); ud.m_player_skill = x+1; if (x == 3) ud.m_respawn_monsters = 1; @@ -2427,19 +2396,19 @@ cheat_for_port_credits: nextpage(); } - newgame(ud.m_volume_number,ud.m_level_number,ud.m_player_skill); - if (enterlevel(MODE_GAME)) backtomenu(); + G_NewGame(ud.m_volume_number,ud.m_level_number,ud.m_player_skill); + if (G_EnterLevel(MODE_GAME)) G_BackToMenu(); } else if (x == -1) { - cmenu(100); + ChangeToMenu(100); KB_FlushKeyboardQueue(); } - menutext(c,70,MENUHIGHLIGHT(0),PHX(-2),skill_names[0]); - menutext(c,70+19,MENUHIGHLIGHT(1),PHX(-3),skill_names[1]); - menutext(c,70+19+19,MENUHIGHLIGHT(2),PHX(-4),skill_names[2]); - menutext(c,70+19+19+19,MENUHIGHLIGHT(3),PHX(-5),skill_names[3]); + menutext(c,70,MENUHIGHLIGHT(0),PHX(-2),SkillNames[0]); + menutext(c,70+19,MENUHIGHLIGHT(1),PHX(-3),SkillNames[1]); + menutext(c,70+19+19,MENUHIGHLIGHT(2),PHX(-4),SkillNames[2]); + menutext(c,70+19+19+19,MENUHIGHLIGHT(3),PHX(-5),SkillNames[3]); break; case 230: #if defined(POLYMOST) && defined(USE_OPENGL) @@ -2489,7 +2458,7 @@ cheat_for_port_credits: if (x == -1) { - cmenu(203); + ChangeToMenu(203); probey = 6; break; } @@ -2642,11 +2611,11 @@ cheat_for_port_credits: x = 4; onbar = (probey != 3); - x = probe(c,probey==3?106:98,16,x); + x = M_Probe(c,probey==3?106:98,16,x); if (x == -1) { - if (g_player[myconnectindex].ps->gm&MODE_GAME && current_menu == 232) + if (g_player[myconnectindex].ps->gm&MODE_GAME && g_currentMenu == 232) { g_player[myconnectindex].ps->gm &= ~MODE_MENU; if (ud.multimode < 2 && ud.recstat != 2) @@ -2657,7 +2626,7 @@ cheat_for_port_credits: } else { - cmenu(203); + ChangeToMenu(203); probey = 4; } break; @@ -2769,7 +2738,7 @@ cheat_for_port_credits: if (x == -1) { - cmenu(202); + ChangeToMenu(202); break; } @@ -2832,7 +2801,7 @@ cheat_for_port_credits: if (x == io && sbs != sbsl) { sbs += 37; - setstatusbarscale(sbs); + G_SetStatusBarScale(sbs); } } break; @@ -2873,7 +2842,7 @@ cheat_for_port_credits: if (x==io) { enabled = !((g_player[myconnectindex].ps->gm&MODE_GAME) && ud.m_recstat != 1); - if ((g_player[myconnectindex].ps->gm&MODE_GAME)) closedemowrite(); + if ((g_player[myconnectindex].ps->gm&MODE_GAME)) G_CloseDemoWrite(); else ud.m_recstat = !ud.m_recstat; } if ((g_player[myconnectindex].ps->gm&MODE_GAME) && ud.m_recstat != 1) @@ -2881,7 +2850,7 @@ cheat_for_port_credits: mgametextpal(d,yy,ud.m_recstat?((ud.m_recstat && enabled && g_player[myconnectindex].ps->gm&MODE_GAME)?"Running":"On"):"Off",enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE,enabled?0:1); break; case 12: - if (x==io) cmenu(201); + if (x==io) ChangeToMenu(201); break; default: break; @@ -2946,7 +2915,7 @@ cheat_for_port_credits: if (x == -1) { - cmenu(200); + ChangeToMenu(200); probey = 12; break; } @@ -2965,7 +2934,7 @@ cheat_for_port_credits: case 0: if (!NAM) { - if (x==io) cmenu(10000); + if (x==io) ChangeToMenu(10000); } else enabled = 0; break; @@ -3051,7 +3020,7 @@ cheat_for_port_credits: #else case 11: #endif - if (x==io) cmenu(200); + if (x==io) ChangeToMenu(200); break; default: break; @@ -3071,24 +3040,24 @@ cheat_for_port_credits: c = 50; onbar = 0; - x = probe(160,c,18,7); + x = M_Probe(160,c,18,7); last_twoohtwo = probey; switch (x) { case -1: - if (g_player[myconnectindex].ps->gm&MODE_GAME) cmenu(50); - else cmenu(0); + if (g_player[myconnectindex].ps->gm&MODE_GAME) ChangeToMenu(50); + else ChangeToMenu(0); break; case 0: - cmenu(200); + ChangeToMenu(200); break; case 1: changesmade = 0; - cmenu(700); + ChangeToMenu(700); break; case 2: @@ -3120,19 +3089,19 @@ cheat_for_port_credits: if (dax < (int)(sizeof(vidsets)/sizeof(vidsets[1]))) newvidset = dax; curvidset = newvidset; - cmenu(203); + ChangeToMenu(203); } break; case 3: if (ud.recstat != 1) - cmenu(20002); + ChangeToMenu(20002); break; case 4: currentlist = 0; case 5: case 6: if (x==6 && !CONTROL_JoyPresent) break; - cmenu(204+x-4); + ChangeToMenu(204+x-4); break; } @@ -3159,22 +3128,22 @@ cheat_for_port_credits: #endif onbar = (!getrendermode() && probey == 6); // (probey == 4); if (probey == 0 || probey == 1 || probey == 2) - x = probe(c,50,16,x); + x = M_Probe(c,50,16,x); else if (probey == 3) - x = probe(c,50+16+16+22,0,x); + x = M_Probe(c,50+16+16+22,0,x); else - x = probe(c,50+62-16-16-16,16,x); + x = M_Probe(c,50+62-16-16-16,16,x); if ((probey==0 || probey==1 || probey==2) && (KB_KeyPressed(sc_LeftArrow) || KB_KeyPressed(sc_RightArrow))) { - sound(PISTOL_BODYHIT); + S_PlaySound(PISTOL_BODYHIT); x=probey; } switch (x) { case -1: - cmenu(202); + ChangeToMenu(202); probey = 2; break; @@ -3362,14 +3331,14 @@ cheat_for_port_credits: if (setgamemode(pfs, pxdim, pydim, pbpp) < 0) { setrendermode(prend); - gameexit("Failed restoring old video mode."); + G_GameExit("Failed restoring old video mode."); } else onvideomodechange(pbpp > 8); } else onvideomodechange(nbpp > 8); - restorepalette = 1; - vscrn(); + g_restorePalette = 1; + G_UpdateScreenArea(); setrendermode(nrend); curvidmode = newvidmode; @@ -3384,7 +3353,7 @@ cheat_for_port_credits: break; case 4: - cmenu(231); + ChangeToMenu(231); break; case 5: @@ -3416,7 +3385,7 @@ cheat_for_port_credits: break; case 6: if (!getrendermode()) break; - cmenu(230); + ChangeToMenu(230); break; #endif } @@ -3519,7 +3488,7 @@ cheat_for_port_credits: if (x==-1) { - cmenu(202); + ChangeToMenu(202); probey = 4; } else if (x == NUMGAMEFUNCTIONS) @@ -3536,7 +3505,7 @@ cheat_for_port_credits: { function = probey; whichkey = currentlist; - cmenu(210); + ChangeToMenu(210); KB_FlushKeyboardQueue(); KB_ClearLastScanCode(); break; @@ -3558,7 +3527,7 @@ cheat_for_port_credits: KB_ClearKeyDown(sc_kpad_4); KB_ClearKeyDown(sc_kpad_6); KB_ClearKeyDown(sc_Tab); - sound(KICK_HIT); + S_PlaySound(KICK_HIT); } else if (KB_KeyPressed(sc_Delete)) { @@ -3567,7 +3536,7 @@ cheat_for_port_credits: key[1] = ud.config.KeyboardKeys[probey][1]; ud.config.KeyboardKeys[probey][currentlist] = 0xff; CONFIG_MapKey(probey, ud.config.KeyboardKeys[probey][0], key[0], ud.config.KeyboardKeys[probey][1], key[1]); - sound(KICK_HIT); + S_PlaySound(KICK_HIT); KB_ClearKeyDown(sc_Delete); } @@ -3617,7 +3586,7 @@ cheat_for_port_credits: { if (sc == sc_Escape || RMB) { - sound(EXITMENUSOUND); + S_PlaySound(EXITMENUSOUND); } else { @@ -3625,7 +3594,7 @@ cheat_for_port_credits: key[0] = ud.config.KeyboardKeys[function][0]; key[1] = ud.config.KeyboardKeys[function][1]; - sound(PISTOL_BODYHIT); + S_PlaySound(PISTOL_BODYHIT); ud.config.KeyboardKeys[function][whichkey] = KB_GetLastScanCode(); if (function == gamefunc_Show_Console) @@ -3634,7 +3603,7 @@ cheat_for_port_credits: CONFIG_MapKey(function, ud.config.KeyboardKeys[function][0], key[0], ud.config.KeyboardKeys[function][1], key[1]); } - cmenu(204); + ChangeToMenu(204); currentlist = whichkey; probey = function; @@ -3658,7 +3627,7 @@ cheat_for_port_credits: if (x==-1) { - cmenu(202); + ChangeToMenu(202); probey = 5; break; } @@ -3669,7 +3638,7 @@ cheat_for_port_credits: else if (x == (MAXMOUSEBUTTONS-2)*2+2+1) { // mouse aiming toggle - if (!ud.mouseaiming) myaimmode = 1-myaimmode; + if (!ud.mouseaiming) g_myAimMode = 1-g_myAimMode; } else if (x == (MAXMOUSEBUTTONS-2)*2+2+2) { @@ -3685,13 +3654,13 @@ cheat_for_port_credits: else if (x == (MAXMOUSEBUTTONS-2)*2+2+2+2) { //advanced - cmenu(212); + ChangeToMenu(212); break; } else if (x >= 0) { //set an option - cmenu(211); + ChangeToMenu(211); function = 0; whichkey = x; if (x < (MAXMOUSEBUTTONS-2)*2) @@ -3747,7 +3716,7 @@ cheat_for_port_credits: CONTROL_SetMouseSensitivity(sense+1); } - if (!ud.mouseaiming) modval(0,1,(int *)&myaimmode,1,probey == (MAXMOUSEBUTTONS-2)*2+2+1); + if (!ud.mouseaiming) modval(0,1,(int *)&g_myAimMode,1,probey == (MAXMOUSEBUTTONS-2)*2+2+1); else if (probey == (MAXMOUSEBUTTONS-2)*2+2+1) { mgametext(160,140+9+9+9,"SET MOUSE AIM TYPE TO TOGGLE ON/OFF",0,2+8+16); @@ -3762,7 +3731,7 @@ cheat_for_port_credits: control_smoothmouse = ud.config.SmoothInput; } - mgametextpal(240,118+9, myaimmode && !ud.mouseaiming ? "Yes" : "No", !ud.mouseaiming?MENUHIGHLIGHT((MAXMOUSEBUTTONS-2)*2+2+1):DISABLEDMENUSHADE, 0); + mgametextpal(240,118+9, g_myAimMode && !ud.mouseaiming ? "Yes" : "No", !ud.mouseaiming?MENUHIGHLIGHT((MAXMOUSEBUTTONS-2)*2+2+1):DISABLEDMENUSHADE, 0); mgametextpal(240,118+9+9, !ud.mouseflip ? "Yes" : "No", MENUHIGHLIGHT((MAXMOUSEBUTTONS-2)*2+2+2), 0); mgametextpal(240,118+9+9+9, ud.config.SmoothInput ? "Yes" : "No", MENUHIGHLIGHT((MAXMOUSEBUTTONS-2)*2+2+2+1), 0); @@ -3780,32 +3749,32 @@ cheat_for_port_credits: else if (function == 2) menutext(320>>1,24,0,0,"JOYSTICK BUTTONS"); else if (function == 3) menutext(320>>1,24,0,0,"JOYSTICK AXES"); - x = probe(0,0,0,NUMGAMEFUNCTIONS); + x = M_Probe(0,0,0,NUMGAMEFUNCTIONS); if (x==-1) { if (function == 0) { // mouse button - cmenu(205); + ChangeToMenu(205); probey = whichkey; } else if (function == 1) { // mouse digital axis - cmenu(212); + ChangeToMenu(212); probey = 3+(whichkey^2); } else if (function == 2) { // joystick button/hat - cmenu(207); + ChangeToMenu(207); probey = whichkey; } else if (function == 3) { // joystick digital axis - cmenu((whichkey>>2)+208); + ChangeToMenu((whichkey>>2)+208); probey = 1+((whichkey>>1)&1)*4+(whichkey&1); } break; @@ -3828,14 +3797,14 @@ cheat_for_port_credits: CONTROL_MapButton(x, whichkey-(MAXMOUSEBUTTONS-2), 0, controldevice_mouse); mousebind[whichkey-(MAXMOUSEBUTTONS-2)].cmd[0] = 0; } - cmenu(205); + ChangeToMenu(205); probey = whichkey; } else if (function == 1) { ud.config.MouseDigitalFunctions[whichkey>>1][whichkey&1] = x; CONTROL_MapDigitalAxis(whichkey>>1, x, whichkey&1, controldevice_mouse); - cmenu(212); + ChangeToMenu(212); probey = 3+(whichkey^2); } else if (function == 2) @@ -3850,14 +3819,14 @@ cheat_for_port_credits: ud.config.JoystickFunctions[joynumbuttons + (whichkey-2*joynumbuttons)][0] = x; CONTROL_MapButton(x, joynumbuttons + (whichkey-2*joynumbuttons), 0, controldevice_joystick); } - cmenu(207); + ChangeToMenu(207); probey = whichkey; } else if (function == 3) { ud.config.JoystickDigitalFunctions[whichkey>>1][whichkey&1] = x; CONTROL_MapDigitalAxis(whichkey>>1, x, whichkey&1, controldevice_joystick); - cmenu((whichkey>>2)+208); + ChangeToMenu((whichkey>>2)+208); probey = 1+((whichkey>>1)&1)*4+(whichkey&1); } break; @@ -3912,13 +3881,13 @@ cheat_for_port_credits: { KB_ClearKeyDown(sc_End); probey = NUMGAMEFUNCTIONS-1; - sound(KICK_HIT); + S_PlaySound(KICK_HIT); } else if (KB_KeyPressed(sc_Home)) { KB_ClearKeyDown(sc_Home); probey = 0; - sound(KICK_HIT); + S_PlaySound(KICK_HIT); } m = probey - 6; @@ -3948,7 +3917,7 @@ cheat_for_port_credits: onbar = (probey == 0 || probey == 1 || probey == 2); if (probey < 3) - x = probe(c,46,16,7); + x = M_Probe(c,46,16,7); else if (probey < 7) { m=50; @@ -3956,13 +3925,13 @@ cheat_for_port_credits: } else { - x = probe(c,146+16-(16+16+16+16+16+16),16,7); + x = M_Probe(c,146+16-(16+16+16+16+16+16),16,7); } switch (x) { case -1: - cmenu(205); + ChangeToMenu(205); probey = (MAXMOUSEBUTTONS-2)*2+2+2+2; break; @@ -3984,7 +3953,7 @@ cheat_for_port_credits: // digital right function = 1; whichkey = (x-3)^2; // flip the actual axis number - cmenu(211); + ChangeToMenu(211); probey = ud.config.MouseDigitalFunctions[whichkey>>1][whichkey&1]; if (probey < 0) probey = NUMGAMEFUNCTIONS-1; break; @@ -4086,20 +4055,20 @@ cheat_for_port_credits: rotatesprite(320<<15,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); menutext(320>>1,24,0,0,"JOYSTICK SETUP"); - x = probe(160,100-18,18,3); + x = M_Probe(160,100-18,18,3); switch (x) { case -1: - cmenu(202); + ChangeToMenu(202); probey = 6; break; case 0: case 1: - cmenu(207+x); + ChangeToMenu(207+x); break; case 2: - cmenu(213); + ChangeToMenu(213); break; } @@ -4115,11 +4084,11 @@ cheat_for_port_credits: c = 2*joynumbuttons + 4*(joynumhats>0); - x = probe(0,0,0,c); + x = M_Probe(0,0,0,c); if (x == -1) { - cmenu(206); + ChangeToMenu(206); probey = 0; break; } @@ -4127,7 +4096,7 @@ cheat_for_port_credits: { function = 2; whichkey = x; - cmenu(211); + ChangeToMenu(211); if (x < 2*joynumbuttons) { probey = ud.config.JoystickFunctions[x>>1][x&1]; @@ -4194,7 +4163,7 @@ cheat_for_port_credits: rotatesprite(320<<15,10<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); menutext(320>>1,15,0,0,"JOYSTICK AXES"); - thispage = (current_menu < 217) ? (current_menu-208) : (current_menu-217)+2; + thispage = (g_currentMenu < 217) ? (g_currentMenu-208) : (g_currentMenu-217)+2; twothispage = (thispage*2+1 < joynumaxes); onbar = 0; @@ -4203,44 +4172,44 @@ cheat_for_port_credits: case 0: case 4: onbar = 1; - x = probe(88,45+(probey==4)*64,0,1+(4< 2) { - if (thispage == ((joynumaxes+1)/2)-1) cmenu(208); + if (thispage == ((joynumaxes+1)/2)-1) ChangeToMenu(208); else { - if (current_menu == 209) cmenu(217); - else cmenu(current_menu+1); + if (g_currentMenu == 209) ChangeToMenu(217); + else ChangeToMenu(g_currentMenu+1); } } break; case 4: // bar if (!twothispage && joynumaxes > 2) - cmenu(208); + ChangeToMenu(208); case 0: break; @@ -4250,7 +4219,7 @@ cheat_for_port_credits: case 6: function = 3; whichkey = ((thispage*2+(x==5||x==6)) << 1) + (x==2||x==6); - cmenu(211); + ChangeToMenu(211); probey = ud.config.JoystickDigitalFunctions[whichkey>>1][whichkey&1]; if (probey < 0) probey = NUMGAMEFUNCTIONS-1; break; @@ -4381,21 +4350,21 @@ cheat_for_port_credits: rotatesprite(320<<15,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); menutext(320>>1,24,0,0,"JOY DEAD ZONES"); - first = 4*(current_menu-213); - last = min(4*(current_menu-213)+4,joynumaxes); + first = 4*(g_currentMenu-213); + last = min(4*(g_currentMenu-213)+4,joynumaxes); onbar = 1; - x = probe(320,48,15,2*(last-first)+(joynumaxes>4)); + x = M_Probe(320,48,15,2*(last-first)+(joynumaxes>4)); if (x==-1) { - cmenu(206); + ChangeToMenu(206); probey = 2; break; } else if (x==2*(last-first) && joynumaxes>4) { - cmenu((current_menu-213) == (joynumaxes/4) ? 213 : (current_menu+1)); + ChangeToMenu((g_currentMenu-213) == (joynumaxes/4) ? 213 : (g_currentMenu+1)); probey = 0; break; } @@ -4429,7 +4398,7 @@ cheat_for_port_credits: if (joynumaxes>4) { menutext(32,48+30*(last-first),0,0,"NEXT..."); - sprintf(tempbuf,"Page %d of %d", 1+(current_menu-213), (joynumaxes+3)/4); + sprintf(tempbuf,"Page %d of %d", 1+(g_currentMenu-213), (joynumaxes+3)/4); mgametext(320-100,158,tempbuf,0,2+8+16); } break; @@ -4493,7 +4462,7 @@ cheat_for_port_credits: ud.config.NumVoices = soundvoices; ud.config.NumBits = soundbits; - if (g_player[myconnectindex].ps->gm&MODE_GAME && current_menu == 701) + if (g_player[myconnectindex].ps->gm&MODE_GAME && g_currentMenu == 701) { g_player[myconnectindex].ps->gm &= ~MODE_MENU; if (ud.multimode < 2 && ud.recstat != 2) @@ -4503,7 +4472,7 @@ cheat_for_port_credits: } } - else cmenu(202); + else ChangeToMenu(202); probey = 1; } @@ -4531,7 +4500,7 @@ cheat_for_port_credits: if (ud.config.SoundToggle == 0) { FX_StopAllSounds(); - clearsoundlocks(); + S_ClearSoundLocks(); } } } @@ -4562,10 +4531,10 @@ cheat_for_port_credits: { if (ud.recstat != 2 && g_player[myconnectindex].ps->gm&MODE_GAME) { - if (map[(unsigned char)music_select].musicfn != NULL) - playmusic(&map[(unsigned char)music_select].musicfn[0],music_select); + if (MapInfo[(unsigned char)g_musicIndex].musicfn != NULL) + S_PlayMusic(&MapInfo[(unsigned char)g_musicIndex].musicfn[0],g_musicIndex); } - else playmusic(&env_music_fn[0][0],MAXVOLUMES*MAXLEVELS); + else S_PlayMusic(&EnvMusicFilename[0][0],MAXVOLUMES*MAXLEVELS); MUSIC_Continue(); } @@ -4648,25 +4617,25 @@ cheat_for_port_credits: if (!enabled) break; if (x == io) { - SoundShutdown(); - MusicShutdown(); + S_SoundShutdown(); + S_MusicShutdown(); initprintf("Initializing music...\n"); - MusicStartup(); + S_MusicStartup(); initprintf("Initializing sound...\n"); - SoundStartup(); + S_SoundStartup(); FX_StopAllSounds(); - clearsoundlocks(); + S_ClearSoundLocks(); if (ud.config.MusicToggle == 1) { if (ud.recstat != 2 && g_player[myconnectindex].ps->gm&MODE_GAME) { - if (map[(unsigned char)music_select].musicfn != NULL) - playmusic(&map[(unsigned char)music_select].musicfn[0],music_select); + if (MapInfo[(unsigned char)g_musicIndex].musicfn != NULL) + S_PlayMusic(&MapInfo[(unsigned char)g_musicIndex].musicfn[0],g_musicIndex); } - else playmusic(&env_music_fn[0][0],MAXVOLUMES*MAXLEVELS); + else S_PlayMusic(&EnvMusicFilename[0][0],MAXVOLUMES*MAXLEVELS); } changesmade &= ~8; } @@ -4714,11 +4683,11 @@ cheat_for_port_credits: break; case 350: - cmenu(351); - screencapt = 1; - displayrooms(myconnectindex,65536); + ChangeToMenu(351); + g_screenCapture = 1; + G_DrawRooms(myconnectindex,65536); //savetemp("duke3d.tmp",waloff[TILE_SAVESHOT],160*100); - screencapt = 0; + g_screenCapture = 0; break; case 360: @@ -4738,10 +4707,10 @@ cheat_for_port_credits: rotatesprite(c<<16,200<<15,65536L,0,MENUSCREEN,16,0,10+64,0,0,xdim-1,ydim-1); rotatesprite(c<<16,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); - if (current_menu == 300) menutext(c,24,0,0,"LOAD GAME"); + if (g_currentMenu == 300) menutext(c,24,0,0,"LOAD GAME"); else menutext(c,24,0,0,"SAVE GAME"); - if (current_menu >= 360 && current_menu <= 369) + if (g_currentMenu >= 360 && g_currentMenu <= 369) { sprintf(tempbuf,"PLAYERS: %-2d ",ud.multimode); mgametext(160,156,tempbuf,0,2+8+16); @@ -4750,11 +4719,11 @@ cheat_for_port_credits: if (ud.volume_number == 0 && ud.level_number == 7) mgametext(160,180,currentboardfilename,0,2+8+16); - x = strget((320>>1),184,&ud.savegame[current_menu-360][0],19, 999); + x = G_EnterText((320>>1),184,&ud.savegame[g_currentMenu-360][0],19, 999); if (x == -1) { - // readsavenames(); + // ReadSaveGameHeaders(); g_player[myconnectindex].ps->gm = MODE_GAME; if (ud.multimode < 2 && ud.recstat != 2) { @@ -4766,17 +4735,17 @@ cheat_for_port_credits: if (x == 1) { - if (ud.savegame[current_menu-360][0] == 0) + if (ud.savegame[g_currentMenu-360][0] == 0) { KB_FlushKeyboardQueue(); - cmenu(351); + ChangeToMenu(351); } else { if (ud.multimode > 1) - saveplayer(-1-(current_menu-360)); - else saveplayer(current_menu-360); - lastsavedpos = current_menu-360; + G_SavePlayer(-1-(g_currentMenu-360)); + else G_SavePlayer(g_currentMenu-360); + g_lastSaveSlot = g_currentMenu-360; g_player[myconnectindex].ps->gm = MODE_GAME; if (ud.multimode < 2 && ud.recstat != 2) @@ -4785,27 +4754,27 @@ cheat_for_port_credits: totalclock = ototalclock; } KB_ClearKeyDown(sc_Escape); - sound(EXITMENUSOUND); + S_PlaySound(EXITMENUSOUND); } } rotatesprite(101<<16,97<<16,65536>>1,512,TILE_SAVESHOT,-32,0,2+4+8+64,0,0,xdim-1,ydim-1); - dispnames(); - rotatesprite((c+67+strlen(&ud.savegame[current_menu-360][0])*4)<<16,(50+12*probey)<<16,32768L-10240,0,SPINNINGNUKEICON+(((totalclock)>>3)%7),0,0,10,0,0,xdim-1,ydim-1); + M_DisplaySaveGameList(); + rotatesprite((c+67+strlen(&ud.savegame[g_currentMenu-360][0])*4)<<16,(50+12*probey)<<16,32768L-10240,0,SPINNINGNUKEICON+(((totalclock)>>3)%7),0,0,10,0,0,xdim-1,ydim-1); break; } last_threehundred = probey; - x = probe(c+68,54,12,10); + x = M_Probe(c+68,54,12,10); - if (current_menu == 300) + if (g_currentMenu == 300) { if (ud.savegame[probey][0]) { if (lastsavehead != probey) { - loadpheader(probey,&savehead); + G_LoadSaveHeader(probey,&savehead); lastsavehead = probey; } @@ -4824,7 +4793,7 @@ cheat_for_port_credits: if (ud.savegame[probey][0]) { if (lastsavehead != probey) - loadpheader(probey,&savehead); + G_LoadSaveHeader(probey,&savehead); lastsavehead = probey; rotatesprite(101<<16,97<<16,65536L>>1,512,TILE_LOADSHOT,-32,0,4+10+64,0,0,xdim-1,ydim-1); } @@ -4840,11 +4809,11 @@ cheat_for_port_credits: switch (x) { case -1: - if (current_menu == 300) + if (g_currentMenu == 300) { if ((g_player[myconnectindex].ps->gm&MODE_GAME) != MODE_GAME) { - cmenu(0); + ChangeToMenu(0); break; } else @@ -4870,19 +4839,19 @@ cheat_for_port_credits: case 7: case 8: case 9: - if (current_menu == 300) + if (g_currentMenu == 300) { if (ud.savegame[x][0]) - current_menu = (1000+x); + g_currentMenu = (1000+x); } else { if (ud.savegame[x][0] != 0) - current_menu = 2000+x; + g_currentMenu = 2000+x; else { KB_FlushKeyboardQueue(); - current_menu = (360+x); + g_currentMenu = (360+x); ud.savegame[x][0] = 0; inputloc = 0; } @@ -4891,7 +4860,7 @@ cheat_for_port_credits: } DISPLAYNAMES: - dispnames(); + M_DisplaySaveGameList(); break; case 400: @@ -4914,9 +4883,9 @@ DISPLAYNAMES: KB_ClearKeyDown(sc_PgUp); KB_ClearKeyDown(sc_kpad_8); - sound(KICK_HIT); - current_menu--; - if (current_menu < 400) current_menu = 403; + S_PlaySound(KICK_HIT); + g_currentMenu--; + if (g_currentMenu < 400) g_currentMenu = 403; } else if ( KB_KeyPressed(sc_PgDn) || @@ -4938,21 +4907,21 @@ DISPLAYNAMES: KB_ClearKeyDown(sc_kpad_2); KB_ClearKeyDown(sc_DownArrow); KB_ClearKeyDown(sc_Space); - sound(KICK_HIT); - current_menu++; - if (current_menu > 403) current_menu = 400; + S_PlaySound(KICK_HIT); + g_currentMenu++; + if (g_currentMenu > 403) g_currentMenu = 400; } if (KB_KeyPressed(sc_Escape)) { if (g_player[myconnectindex].ps->gm&MODE_GAME) - cmenu(50); - else cmenu(0); + ChangeToMenu(50); + else ChangeToMenu(0); return; } flushperms(); - rotatesprite(0,0,65536L,0,ORDERING+current_menu-400,0,0,10+16+64,0,0,xdim-1,ydim-1); + rotatesprite(0,0,65536L,0,ORDERING+g_currentMenu-400,0,0,10+16+64,0,0,xdim-1,ydim-1); break; VOLUME_ALL_40x: @@ -4971,9 +4940,9 @@ VOLUME_ALL_40x: KB_ClearKeyDown(sc_UpArrow); KB_ClearKeyDown(sc_PgUp); KB_ClearKeyDown(sc_kpad_8); - sound(KICK_HIT); - current_menu--; - if (current_menu < 400) current_menu = 401; + S_PlaySound(KICK_HIT); + g_currentMenu--; + if (g_currentMenu < 400) g_currentMenu = 401; } else if ( KB_KeyPressed(sc_PgDn) || @@ -4996,23 +4965,23 @@ VOLUME_ALL_40x: KB_ClearKeyDown(sc_kpad_2); KB_ClearKeyDown(sc_DownArrow); KB_ClearKeyDown(sc_Space); - sound(KICK_HIT); - current_menu++; - if (current_menu > 401) current_menu = 400; + S_PlaySound(KICK_HIT); + g_currentMenu++; + if (g_currentMenu > 401) g_currentMenu = 400; } - x = probe(0,0,0,1); + x = M_Probe(0,0,0,1); if (x == -1) { if (g_player[myconnectindex].ps->gm&MODE_GAME) - cmenu(50); - else cmenu(0); + ChangeToMenu(50); + else ChangeToMenu(0); return; } flushperms(); - switch (current_menu) + switch (g_currentMenu) { case 400: rotatesprite(0,0,65536L,0,TEXTSTORY,0,0,10+16+64, 0,0,xdim-1,ydim-1); @@ -5035,10 +5004,10 @@ VOLUME_ALL_40x: { KB_FlushKeyboardQueue(); - sendquit(); + Net_SendQuit(); } - x = probe(186,124,0,1); + x = M_Probe(186,124,0,1); if (x == -1 || KB_KeyPressed(sc_N) || RMB) { KB_ClearKeyDown(sc_N); @@ -5047,13 +5016,13 @@ VOLUME_ALL_40x: g_player[myconnectindex].ps->gm = MODE_DEMO; else { - if (current_menu == 502) + if (g_currentMenu == 502) { - cmenu(last_menu); + ChangeToMenu(last_menu); probey = last_menu_pos; } else if (!(g_player[myconnectindex].ps->gm & MODE_GAME || ud.recstat == 2)) - cmenu(0); + ChangeToMenu(0); else g_player[myconnectindex].ps->gm &= ~MODE_MENU; if (ud.multimode < 2 && ud.recstat != 2) { @@ -5074,11 +5043,11 @@ VOLUME_ALL_40x: KB_FlushKeyboardQueue(); g_player[myconnectindex].ps->gm = MODE_DEMO; if (ud.recstat == 1) - closedemowrite(); - cmenu(0); + G_CloseDemoWrite(); + ChangeToMenu(0); } - x = probe(186,124,0,0); + x = M_Probe(186,124,0,0); if (x == -1 || KB_KeyPressed(sc_N) || RMB) { @@ -5093,7 +5062,7 @@ VOLUME_ALL_40x: break; case 601: - displayfragbar(); + G_DrawFrags(); rotatesprite(160<<16,29<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); menutext(320>>1,34,0,0,&g_player[myconnectindex].user_name[0]); @@ -5104,8 +5073,8 @@ VOLUME_ALL_40x: if (KB_KeyPressed(sc_Escape)) { KB_ClearKeyDown(sc_Escape); - sound(EXITMENUSOUND); - cmenu(0); + S_PlaySound(EXITMENUSOUND); + ChangeToMenu(0); } break; @@ -5115,14 +5084,14 @@ VOLUME_ALL_40x: // getfilenames("SUBD"); getfilenames(".","*.MAP"); if (menunamecnt == 0) - cmenu(600); + ChangeToMenu(600); } case 603: { int plrvotes = 0, j = 0; - x = probe(186,124,0,0); + x = M_Probe(186,124,0,0); if (voting != myconnectindex) g_player[myconnectindex].ps->gm &= ~MODE_MENU; @@ -5137,18 +5106,17 @@ VOLUME_ALL_40x: g_player[i].gotvote = 0; } - tempbuf[0] = 18; - tempbuf[1] = 2; - tempbuf[2] = myconnectindex; + tempbuf[0] = PACKET_TYPE_MAP_VOTE_CANCEL; + tempbuf[1] = myconnectindex; - for (c=connecthead;c>=0;c=connectpoint2[c]) + TRAVERSE_CONNECT(c) { - if (c != myconnectindex) sendpacket(c,tempbuf,3); - if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master + if (c != myconnectindex) sendpacket(c,tempbuf,2); + if ((!g_networkBroadcastMode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master } voting = -1; } - cmenu(0); + ChangeToMenu(0); } for (i=0;ii || (plrvotes > (numplayers>>1)) || (!networkmode && myconnectindex == connecthead)) + if (j == numplayers || !g_player[myconnectindex].ps->i || (plrvotes > (numplayers>>1)) || (!g_networkBroadcastMode && myconnectindex == connecthead)) { - if (plrvotes > (numplayers>>1) || !g_player[myconnectindex].ps->i || (!networkmode && myconnectindex == connecthead)) + if (plrvotes > (numplayers>>1) || !g_player[myconnectindex].ps->i || (!g_networkBroadcastMode && myconnectindex == connecthead)) { if (ud.m_player_skill == 3) ud.m_respawn_monsters = 1; else ud.m_respawn_monsters = 0; - if ((gametype_flags[ud.m_coop] & GAMETYPE_FLAG_ITEMRESPAWN)) ud.m_respawn_items = 1; + if ((GametypeFlags[ud.m_coop] & GAMETYPE_ITEMRESPAWN)) ud.m_respawn_items = 1; else ud.m_respawn_items = 0; ud.m_respawn_inventory = 1; - for (c=connecthead;c>=0;c=connectpoint2[c]) + TRAVERSE_CONNECT(c) { - resetweapons(c); - resetinventory(c); + P_ResetWeapons(c); + P_ResetInventory(c); } - mpchangemap(ud.m_volume_number,ud.m_level_number); + Net_NewGame(ud.m_volume_number,ud.m_level_number); - if (voting == myconnectindex) - adduserquote("VOTE SUCCEEDED"); + if (voting == myconnectindex && !(!g_networkBroadcastMode && myconnectindex == connecthead)) + G_AddUserQuote("VOTE SUCCEEDED"); - newgame(ud.m_volume_number,ud.m_level_number,ud.m_player_skill+1); - if (enterlevel(MODE_GAME)) backtomenu(); + G_NewGame(ud.m_volume_number,ud.m_level_number,ud.m_player_skill+1); + if (G_EnterLevel(MODE_GAME)) G_BackToMenu(); return; } @@ -5195,19 +5163,18 @@ VOLUME_ALL_40x: voting = -1; - tempbuf[0] = 18; - tempbuf[1] = 2; - tempbuf[2] = myconnectindex; - tempbuf[3] = 1; + tempbuf[0] = PACKET_TYPE_MAP_VOTE_CANCEL; + tempbuf[1] = myconnectindex; + tempbuf[2] = 1; - for (c=connecthead;c>=0;c=connectpoint2[c]) + TRAVERSE_CONNECT(c) { - if (c != myconnectindex) sendpacket(c,tempbuf,4); - if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master + if (c != myconnectindex) sendpacket(c,tempbuf,3); + if ((!g_networkBroadcastMode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master } - Bsprintf(fta_quotes[116],"VOTE FAILED"); - FTA(116,g_player[myconnectindex].ps); + Bsprintf(ScriptQuotes[116],"VOTE FAILED"); + P_DoQuote(116,g_player[myconnectindex].ps); g_player[myconnectindex].ps->gm &= ~MODE_MENU; } } @@ -5220,23 +5187,23 @@ VOLUME_ALL_40x: case 600: c = (320>>1) - 120; if ((g_player[myconnectindex].ps->gm&MODE_GAME) != MODE_GAME) - displayfragbar(); + G_DrawFrags(); rotatesprite(160<<16,26<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); menutext(160,31,0,0,&g_player[myconnectindex].user_name[0]); - x = probe(c,57-8,16,8); + x = M_Probe(c,57-8,16,8); - modval(0,num_gametypes-1,(int *)&ud.m_coop,1,probey==0); + modval(0,g_numGametypes-1,(int *)&ud.m_coop,1,probey==0); if (!VOLUMEONE) - modval(0,num_volumes-1,(int *)&ud.m_volume_number,1,probey==1); + modval(0,g_numVolumes-1,(int *)&ud.m_volume_number,1,probey==1); i = ud.m_level_number; modval(0,ud.m_volume_number == 0?6+(boardfilename[0]!=0):MAXLEVELS-1,(int *)&ud.m_level_number,1,probey==2); - if ((gametype_flags[ud.m_coop] & GAMETYPE_FLAG_MARKEROPTION)) + if ((GametypeFlags[ud.m_coop] & GAMETYPE_MARKEROPTION)) modval(0,1,(int *)&ud.m_marker,1,probey==4); - if ((gametype_flags[ud.m_coop] & (GAMETYPE_FLAG_PLAYERSFRIENDLY|GAMETYPE_FLAG_TDM))) + if ((GametypeFlags[ud.m_coop] & (GAMETYPE_PLAYERSFRIENDLY|GAMETYPE_TDM))) modval(0,1,(int *)&ud.m_ffire,1,probey==5); else modval(0,1,(int *)&ud.m_noexits,1,probey==5); @@ -5244,7 +5211,7 @@ VOLUME_ALL_40x: if (ud.m_volume_number == 0 && ud.m_level_number > 6+(boardfilename[0]!=0)) ud.m_level_number = 0; - while (map[(ud.m_volume_number*MAXLEVELS)+ud.m_level_number].name == NULL) + while (MapInfo[(ud.m_volume_number*MAXLEVELS)+ud.m_level_number].name == NULL) { if (ud.m_level_number < i || i == 0) ud.m_level_number--; @@ -5261,18 +5228,18 @@ VOLUME_ALL_40x: { case -1: ud.m_recstat = 0; - if (g_player[myconnectindex].ps->gm&MODE_GAME) cmenu(50); - else cmenu(0); + if (g_player[myconnectindex].ps->gm&MODE_GAME) ChangeToMenu(50); + else ChangeToMenu(0); break; case 0: ud.m_coop++; - if (ud.m_coop == num_gametypes) ud.m_coop = 0; + if (ud.m_coop == g_numGametypes) ud.m_coop = 0; break; case 1: if (!VOLUMEONE) { ud.m_volume_number++; - if (ud.m_volume_number == num_volumes) ud.m_volume_number = 0; + if (ud.m_volume_number == g_numVolumes) ud.m_volume_number = 0; if (ud.m_volume_number == 0 && ud.m_level_number > 6+(boardfilename[0]!=0)) ud.m_level_number = 0; if (ud.m_level_number > MAXLEVELS-1) ud.m_level_number = 0; @@ -5310,12 +5277,12 @@ VOLUME_ALL_40x: break; case 4: - if ((gametype_flags[ud.m_coop] & GAMETYPE_FLAG_MARKEROPTION)) + if ((GametypeFlags[ud.m_coop] & GAMETYPE_MARKEROPTION)) ud.m_marker = !ud.m_marker; break; case 5: - if ((gametype_flags[ud.m_coop] & (GAMETYPE_FLAG_PLAYERSFRIENDLY|GAMETYPE_FLAG_TDM))) + if ((GametypeFlags[ud.m_coop] & (GAMETYPE_PLAYERSFRIENDLY|GAMETYPE_TDM))) ud.m_ffire = !ud.m_ffire; else ud.m_noexits = !ud.m_noexits; break; @@ -5325,10 +5292,16 @@ VOLUME_ALL_40x: { currentlist = 1; last_menu_pos = probey; - cmenu(101); + ChangeToMenu(101); } break; case 7: + // master does whatever it wants + if (!g_networkBroadcastMode && myconnectindex == connecthead) + { + ChangeToMenu(603); + break; + } if (voting == -1) { if (g_player[myconnectindex].ps->i) @@ -5341,22 +5314,21 @@ VOLUME_ALL_40x: g_player[myconnectindex].vote = g_player[myconnectindex].gotvote = 1; voting = myconnectindex; - tempbuf[0] = 18; - tempbuf[1] = 1; - tempbuf[2] = myconnectindex; - tempbuf[3] = ud.m_volume_number; - tempbuf[4] = ud.m_level_number; + tempbuf[0] = PACKET_TYPE_MAP_VOTE_INITIATE; + tempbuf[1] = myconnectindex; + tempbuf[2] = ud.m_volume_number; + tempbuf[3] = ud.m_level_number; - for (c=connecthead;c>=0;c=connectpoint2[c]) + TRAVERSE_CONNECT(c) { - if (c != myconnectindex) sendpacket(c,tempbuf,5); - if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master + if (c != myconnectindex) sendpacket(c,tempbuf,4); + if ((!g_networkBroadcastMode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master } } - if ((gametype_flags[ud.m_coop] & GAMETYPE_FLAG_PLAYERSFRIENDLY) && !(gametype_flags[ud.m_coop] & GAMETYPE_FLAG_TDM)) + if ((GametypeFlags[ud.m_coop] & GAMETYPE_PLAYERSFRIENDLY) && !(GametypeFlags[ud.m_coop] & GAMETYPE_TDM)) ud.m_noexits = 0; - cmenu(603); + ChangeToMenu(603); } break; } @@ -5366,24 +5338,24 @@ VOLUME_ALL_40x: //if(ud.m_coop==1) mgametext(c+70,57-7-9,"COOPERATIVE PLAY",0,2+8+16); //else if(ud.m_coop==2) mgametext(c+70,57-7-9,"DUKEMATCH (NO SPAWN)",0,2+8+16); //else mgametext(c+70,57-7-9,"DUKEMATCH (SPAWN)",0,2+8+16); - mgametext(c+70,57-7-9,gametype_names[ud.m_coop],MENUHIGHLIGHT(0),2+8+16); + mgametext(c+70,57-7-9,GametypeNames[ud.m_coop],MENUHIGHLIGHT(0),2+8+16); if (VOLUMEONE) { - mgametext(c+70,57+16-7-9,volume_names[ud.m_volume_number],MENUHIGHLIGHT(1),2+8+16); + mgametext(c+70,57+16-7-9,EpisodeNames[ud.m_volume_number],MENUHIGHLIGHT(1),2+8+16); } else { - mgametext(c+70,57+16-7-9,volume_names[ud.m_volume_number],MENUHIGHLIGHT(1),2+8+16); + mgametext(c+70,57+16-7-9,EpisodeNames[ud.m_volume_number],MENUHIGHLIGHT(1),2+8+16); } - mgametext(c+70,57+16+16-7-9,&map[MAXLEVELS*ud.m_volume_number+ud.m_level_number].name[0],MENUHIGHLIGHT(2),2+8+16); + mgametext(c+70,57+16+16-7-9,&MapInfo[MAXLEVELS*ud.m_volume_number+ud.m_level_number].name[0],MENUHIGHLIGHT(2),2+8+16); - mgametext(c+70,57+16+16+16-7-9,ud.m_monsters_off == 0 || ud.m_player_skill > 0?skill_names[ud.m_player_skill]:"NONE",MENUHIGHLIGHT(3),2+8+16); + mgametext(c+70,57+16+16+16-7-9,ud.m_monsters_off == 0 || ud.m_player_skill > 0?SkillNames[ud.m_player_skill]:"NONE",MENUHIGHLIGHT(3),2+8+16); - if (gametype_flags[ud.m_coop] & GAMETYPE_FLAG_MARKEROPTION) + if (GametypeFlags[ud.m_coop] & GAMETYPE_MARKEROPTION) mgametext(c+70,57+16+16+16+16-7-9,ud.m_marker?"ON":"OFF",MENUHIGHLIGHT(4),2+8+16); - if (gametype_flags[ud.m_coop] & (GAMETYPE_FLAG_PLAYERSFRIENDLY|GAMETYPE_FLAG_TDM)) + if (GametypeFlags[ud.m_coop] & (GAMETYPE_PLAYERSFRIENDLY|GAMETYPE_TDM)) mgametext(c+70,57+16+16+16+16+16-7-9,ud.m_ffire?"ON":"OFF",MENUHIGHLIGHT(5),2+8+16); else mgametext(c+70,57+16+16+16+16+16-7-9,ud.m_noexits?"OFF":"ON",MENUHIGHLIGHT(5),2+8+16); @@ -5407,12 +5379,12 @@ VOLUME_ALL_40x: menutext(c,57+16+16+16-9,MENUHIGHLIGHT(3),PHX(-5),"MONSTERS"); - if (gametype_flags[ud.m_coop] & GAMETYPE_FLAG_MARKEROPTION) + if (GametypeFlags[ud.m_coop] & GAMETYPE_MARKEROPTION) menutext(c,57+16+16+16+16-9,MENUHIGHLIGHT(4),PHX(-6),"MARKERS"); else menutext(c,57+16+16+16+16-9,MENUHIGHLIGHT(4),1,"MARKERS"); - if (gametype_flags[ud.m_coop] & (GAMETYPE_FLAG_PLAYERSFRIENDLY|GAMETYPE_FLAG_TDM)) + if (GametypeFlags[ud.m_coop] & (GAMETYPE_PLAYERSFRIENDLY|GAMETYPE_TDM)) menutext(c,57+16+16+16+16+16-9,MENUHIGHLIGHT(5),0,"FR. FIRE"); else menutext(c,57+16+16+16+16+16-9,MENUHIGHLIGHT(5),0,"MAP EXITS"); @@ -5431,12 +5403,12 @@ VOLUME_ALL_40x: break; } - OnEvent(EVENT_DISPLAYMENUREST, g_player[myconnectindex].ps->i, myconnectindex, -1); + X_OnEvent(EVENT_DISPLAYMENUREST, g_player[myconnectindex].ps->i, myconnectindex, -1); if ((g_player[myconnectindex].ps->gm&MODE_MENU) != MODE_MENU) { - vscrn(); - cameraclock = totalclock; - cameradist = 65536L; + G_UpdateScreenArea(); + g_cameraClock = totalclock; + g_cameraDistance = 65536L; } } diff --git a/polymer/eduke32/source/namesdyn.c b/polymer/eduke32/source/namesdyn.c index 48b01c122..9c3cb20ec 100644 --- a/polymer/eduke32/source/namesdyn.c +++ b/polymer/eduke32/source/namesdyn.c @@ -1517,9 +1517,9 @@ int RESERVEDSLOT10 = 6141; int RESERVEDSLOT11 = 6142; int RESERVEDSLOT12 = 6143; -short dynamictostatic[MAXTILES]; +short DynamicTileMap[MAXTILES]; -void processnames(const char *szLabel, int lValue) +void G_ProcessDynamicTileMapping(const char *szLabel, int lValue) { int i; if (lValue >= MAXTILES || !szLabel) @@ -1542,42 +1542,42 @@ void freehashnames() HASH_free(&dynnamesH); } -void setupdynamictostatic(void) +void G_InitDynamicTiles(void) { int i = 0; - clearbufbyte(dynamictostatic,MAXTILES,0); + clearbufbyte(DynamicTileMap,MAXTILES,0); while (list[i].val) { - dynamictostatic[list[i].val]=list[i].vstat; + DynamicTileMap[list[i].val]=list[i].vstat; i++; } - weaponsandammosprites[0] = RPGSPRITE; - weaponsandammosprites[1] = CHAINGUNSPRITE; - weaponsandammosprites[2] = DEVISTATORAMMO; - weaponsandammosprites[3] = RPGAMMO; - weaponsandammosprites[4] = RPGAMMO; - weaponsandammosprites[5] = JETPACK; - weaponsandammosprites[6] = SHIELD; - weaponsandammosprites[7] = FIRSTAID; - weaponsandammosprites[8] = STEROIDS; - weaponsandammosprites[9] = RPGAMMO; - weaponsandammosprites[10] = RPGAMMO; - weaponsandammosprites[11] = RPGSPRITE; - weaponsandammosprites[12] = RPGAMMO; - weaponsandammosprites[13] = FREEZESPRITE; - weaponsandammosprites[14] = FREEZEAMMO; + BlimpSpawnSprites[0] = RPGSPRITE; + BlimpSpawnSprites[1] = CHAINGUNSPRITE; + BlimpSpawnSprites[2] = DEVISTATORAMMO; + BlimpSpawnSprites[3] = RPGAMMO; + BlimpSpawnSprites[4] = RPGAMMO; + BlimpSpawnSprites[5] = JETPACK; + BlimpSpawnSprites[6] = SHIELD; + BlimpSpawnSprites[7] = FIRSTAID; + BlimpSpawnSprites[8] = STEROIDS; + BlimpSpawnSprites[9] = RPGAMMO; + BlimpSpawnSprites[10] = RPGAMMO; + BlimpSpawnSprites[11] = RPGSPRITE; + BlimpSpawnSprites[12] = RPGAMMO; + BlimpSpawnSprites[13] = FREEZESPRITE; + BlimpSpawnSprites[14] = FREEZEAMMO; - weapon_sprites[0] = KNEE; - weapon_sprites[1] = FIRSTGUNSPRITE; - weapon_sprites[2] = SHOTGUNSPRITE; - weapon_sprites[3] = CHAINGUNSPRITE; - weapon_sprites[4] = RPGSPRITE; - weapon_sprites[5] = HEAVYHBOMB; - weapon_sprites[6] = SHRINKERSPRITE; - weapon_sprites[7] = DEVISTATORSPRITE; - weapon_sprites[8] = TRIPBOMBSPRITE; - weapon_sprites[9] = FREEZESPRITE; - weapon_sprites[10] = HEAVYHBOMB; - weapon_sprites[11] = SHRINKERSPRITE; + WeaponPickupSprites[0] = KNEE; + WeaponPickupSprites[1] = FIRSTGUNSPRITE; + WeaponPickupSprites[2] = SHOTGUNSPRITE; + WeaponPickupSprites[3] = CHAINGUNSPRITE; + WeaponPickupSprites[4] = RPGSPRITE; + WeaponPickupSprites[5] = HEAVYHBOMB; + WeaponPickupSprites[6] = SHRINKERSPRITE; + WeaponPickupSprites[7] = DEVISTATORSPRITE; + WeaponPickupSprites[8] = TRIPBOMBSPRITE; + WeaponPickupSprites[9] = FREEZESPRITE; + WeaponPickupSprites[10] = HEAVYHBOMB; + WeaponPickupSprites[11] = SHRINKERSPRITE; } diff --git a/polymer/eduke32/source/namesdyn.h b/polymer/eduke32/source/namesdyn.h index bb36d0966..9e311db1c 100644 --- a/polymer/eduke32/source/namesdyn.h +++ b/polymer/eduke32/source/namesdyn.h @@ -1496,4 +1496,4 @@ extern int RESERVEDSLOT11; #define RESERVEDSLOT11__STATIC 6142 extern int RESERVEDSLOT12; #define RESERVEDSLOT12__STATIC 6143 -extern short dynamictostatic[MAXTILES]; +extern short DynamicTileMap[MAXTILES]; diff --git a/polymer/eduke32/source/osdcmds.c b/polymer/eduke32/source/osdcmds.c index 0e56e0495..816497457 100644 --- a/polymer/eduke32/source/osdcmds.c +++ b/polymer/eduke32/source/osdcmds.c @@ -32,7 +32,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include -extern int voting, doquicksave; +extern int voting, g_doQuickSave; struct osdcmd_cheatsinfo osdcmd_cheatsinfo_stat; float r_ambientlight = 1.0, r_ambientlightrecip = 1.0; extern int althud_numbertile, althud_numberpal, althud_shadows, althud_flashing, hud_glowingquotes; @@ -42,7 +42,7 @@ extern int r_maxfps; static inline int osdcmd_quit(const osdfuncparm_t *parm) { UNREFERENCED_PARAMETER(parm); - sendquit(); + Net_SendQuit(); return OSDCMD_OK; } @@ -86,14 +86,14 @@ static int osdcmd_changelevel(const osdfuncparm_t *parm) if (!VOLUMEONE) { - if (volume > num_volumes) + if (volume > g_numVolumes) { - OSD_Printf("changelevel: invalid volume number (range 1-%d)\n",num_volumes); + OSD_Printf("changelevel: invalid volume number (range 1-%d)\n",g_numVolumes); return OSDCMD_OK; } } - if (level > MAXLEVELS || map[volume*MAXLEVELS+level].filename == NULL) + if (level > MAXLEVELS || MapInfo[volume*MAXLEVELS+level].filename == NULL) { OSD_Printf("changelevel: invalid level number\n"); return OSDCMD_SHOWHELP; @@ -101,8 +101,8 @@ static int osdcmd_changelevel(const osdfuncparm_t *parm) if (numplayers > 1) { - if (myconnectindex == connecthead && networkmode == 0) - mpchangemap(volume,level); + if (myconnectindex == connecthead && g_networkBroadcastMode == 0) + Net_NewGame(volume,level); else if (voting == -1) { ud.m_volume_number = volume; @@ -122,23 +122,22 @@ static int osdcmd_changelevel(const osdfuncparm_t *parm) voting = myconnectindex; - tempbuf[0] = 18; - tempbuf[1] = 1; - tempbuf[2] = myconnectindex; - tempbuf[3] = ud.m_volume_number; - tempbuf[4] = ud.m_level_number; + tempbuf[0] = PACKET_TYPE_MAP_VOTE_INITIATE; + tempbuf[1] = myconnectindex; + tempbuf[2] = ud.m_volume_number; + tempbuf[3] = ud.m_level_number; - for (i=connecthead;i>=0;i=connectpoint2[i]) + TRAVERSE_CONNECT(i) { - if (i != myconnectindex) sendpacket(i,tempbuf,5); - if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master + if (i != myconnectindex) sendpacket(i,tempbuf,4); + if ((!g_networkBroadcastMode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master } } - if ((gametype_flags[ud.m_coop] & GAMETYPE_FLAG_PLAYERSFRIENDLY) && !(gametype_flags[ud.m_coop] & GAMETYPE_FLAG_TDM)) + if ((GametypeFlags[ud.m_coop] & GAMETYPE_PLAYERSFRIENDLY) && !(GametypeFlags[ud.m_coop] & GAMETYPE_TDM)) ud.m_noexits = 0; g_player[myconnectindex].ps->gm |= MODE_MENU; - cmenu(603); + ChangeToMenu(603); } return OSDCMD_OK; } @@ -164,8 +163,8 @@ static int osdcmd_changelevel(const osdfuncparm_t *parm) ud.multimode = 1; - newgame(ud.m_volume_number,ud.m_level_number,ud.m_player_skill); - if (enterlevel(MODE_GAME)) backtomenu(); + G_NewGame(ud.m_volume_number,ud.m_level_number,ud.m_player_skill); + if (G_EnterLevel(MODE_GAME)) G_BackToMenu(); } return OSDCMD_OK; @@ -254,14 +253,16 @@ static int osdcmd_map(const osdfuncparm_t *parm) if (numplayers > 1) { - if (myconnectindex == connecthead && networkmode == 0) + if (myconnectindex == connecthead && g_networkBroadcastMode == 0) { - sendboardname(); - mpchangemap(0,7); + Net_SendUserMapName(); + ud.m_volume_number = 0; + ud.m_level_number = 7; + Net_NewGame(ud.m_volume_number, ud.m_level_number); } else if (voting == -1) { - sendboardname(); + Net_SendUserMapName(); ud.m_volume_number = 0; ud.m_level_number = 7; @@ -279,23 +280,22 @@ static int osdcmd_map(const osdfuncparm_t *parm) g_player[myconnectindex].vote = g_player[myconnectindex].gotvote = 1; voting = myconnectindex; - tempbuf[0] = 18; - tempbuf[1] = 1; - tempbuf[2] = myconnectindex; - tempbuf[3] = ud.m_volume_number; - tempbuf[4] = ud.m_level_number; + tempbuf[0] = PACKET_TYPE_MAP_VOTE_INITIATE; + tempbuf[1] = myconnectindex; + tempbuf[2] = ud.m_volume_number; + tempbuf[3] = ud.m_level_number; - for (i=connecthead;i>=0;i=connectpoint2[i]) + TRAVERSE_CONNECT(i) { - if (i != myconnectindex) sendpacket(i,tempbuf,5); - if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master + if (i != myconnectindex) sendpacket(i,tempbuf,4); + if ((!g_networkBroadcastMode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master } } - if ((gametype_flags[ud.m_coop] & GAMETYPE_FLAG_PLAYERSFRIENDLY) && !(gametype_flags[ud.m_coop] & GAMETYPE_FLAG_TDM)) + if ((GametypeFlags[ud.m_coop] & GAMETYPE_PLAYERSFRIENDLY) && !(GametypeFlags[ud.m_coop] & GAMETYPE_TDM)) ud.m_noexits = 0; g_player[myconnectindex].ps->gm |= MODE_MENU; - cmenu(603); + ChangeToMenu(603); } return OSDCMD_OK; } @@ -311,8 +311,8 @@ static int osdcmd_map(const osdfuncparm_t *parm) ud.multimode = 1; - newgame(ud.m_volume_number,ud.m_level_number,ud.m_player_skill); - if (enterlevel(MODE_GAME)) backtomenu(); + G_NewGame(ud.m_volume_number,ud.m_level_number,ud.m_player_skill); + if (G_EnterLevel(MODE_GAME)) G_BackToMenu(); return OSDCMD_OK; } @@ -410,25 +410,25 @@ static int osdcmd_rate(const osdfuncparm_t *parm) static int osdcmd_restartsound(const osdfuncparm_t *parm) { UNREFERENCED_PARAMETER(parm); - SoundShutdown(); - MusicShutdown(); + S_SoundShutdown(); + S_MusicShutdown(); initprintf("Initializing music...\n"); - MusicStartup(); + S_MusicStartup(); initprintf("Initializing sound...\n"); - SoundStartup(); + S_SoundStartup(); FX_StopAllSounds(); - clearsoundlocks(); + S_ClearSoundLocks(); if (ud.config.MusicToggle == 1) { if (ud.recstat != 2 && g_player[myconnectindex].ps->gm&MODE_GAME) { - if (map[(unsigned char)music_select].musicfn != NULL) - playmusic(&map[(unsigned char)music_select].musicfn[0],music_select); + if (MapInfo[(unsigned char)g_musicIndex].musicfn != NULL) + S_PlayMusic(&MapInfo[(unsigned char)g_musicIndex].musicfn[0],g_musicIndex); } - else playmusic(&env_music_fn[0][0],MAXVOLUMES*MAXLEVELS); + else S_PlayMusic(&EnvMusicFilename[0][0],MAXVOLUMES*MAXLEVELS); } return OSDCMD_OK; @@ -439,9 +439,9 @@ static int osdcmd_restartvid(const osdfuncparm_t *parm) UNREFERENCED_PARAMETER(parm); resetvideomode(); if (setgamemode(ud.config.ScreenMode,ud.config.ScreenWidth,ud.config.ScreenHeight,ud.config.ScreenBPP)) - gameexit("restartvid: Reset failed...\n"); + G_GameExit("restartvid: Reset failed...\n"); onvideomodechange(ud.config.ScreenBPP>8); - vscrn(); + G_UpdateScreenArea(); return OSDCMD_OK; } @@ -475,14 +475,14 @@ static int osdcmd_vidmode(const osdfuncparm_t *parm) { initprintf("vidmode: Mode change failed!\n"); if (setgamemode(ud.config.ScreenMode, ud.config.ScreenWidth, ud.config.ScreenHeight, ud.config.ScreenBPP)) - gameexit("vidmode: Reset failed!\n"); + G_GameExit("vidmode: Reset failed!\n"); } ud.config.ScreenBPP = newbpp; ud.config.ScreenWidth = newwidth; ud.config.ScreenHeight = newheight; ud.config.ScreenMode = newfs; onvideomodechange(ud.config.ScreenBPP>8); - vscrn(); + G_UpdateScreenArea(); return OSDCMD_OK; } @@ -495,7 +495,7 @@ static int osdcmd_setstatusbarscale(const osdfuncparm_t *parm) } else if (parm->numparms != 1) return OSDCMD_SHOWHELP; - setstatusbarscale(Batol(parm->parms[0])); + G_SetStatusBarScale(Batol(parm->parms[0])); OSD_Printf("hud_scale %d\n", ud.statusbarscale); return OSDCMD_OK; } @@ -553,7 +553,7 @@ static int osdcmd_spawn(const osdfuncparm_t *parm) int i,j; for (j=0; j<2; j++) { - for (i=0; iparms[0])) || @@ -564,9 +564,9 @@ static int osdcmd_spawn(const osdfuncparm_t *parm) break; } } - if (ii, (short)picnum); + idx = A_Spawn(g_player[myconnectindex].ps->i, (short)picnum); if (set & 1) sprite[idx].pal = (char)pal; if (set & 2) sprite[idx].cstat = (short)cstat; if (set & 4) sprite[idx].ang = ang; @@ -616,12 +616,12 @@ static int osdcmd_setvar(const osdfuncparm_t *parm) varval = Batol(varname); i = HASH_find(&gamevarH,varname); if (i >= 0) - varval=GetGameVarID(i, g_player[myconnectindex].ps->i, myconnectindex); + varval=Gv_GetVar(i, g_player[myconnectindex].ps->i, myconnectindex); strcpy(varname,parm->parms[0]); i = HASH_find(&gamevarH,varname); if (i >= 0) - SetGameVarID(i, varval, g_player[myconnectindex].ps->i, myconnectindex); + Gv_SetVar(i, varval, g_player[myconnectindex].ps->i, myconnectindex); return OSDCMD_OK; } @@ -641,7 +641,7 @@ static int osdcmd_addlogvar(const osdfuncparm_t *parm) strcpy(varname,parm->parms[0]); i = HASH_find(&gamevarH,varname); if (i >= 0) - OSD_Printf("%s = %d\n", varname, GetGameVarID(i, g_player[myconnectindex].ps->i, myconnectindex)); + OSD_Printf("%s = %d\n", varname, Gv_GetVar(i, g_player[myconnectindex].ps->i, myconnectindex)); return OSDCMD_OK; } @@ -670,12 +670,12 @@ static int osdcmd_setactorvar(const osdfuncparm_t *parm) varval = Batol(varname); i = HASH_find(&gamevarH,varname); if (i >= 0) - varval=GetGameVarID(i, g_player[myconnectindex].ps->i, myconnectindex); + varval=Gv_GetVar(i, g_player[myconnectindex].ps->i, myconnectindex); strcpy(varname,parm->parms[1]); i = HASH_find(&gamevarH,varname); if (i >= 0) - SetGameVarID(i, varval, ID, -1); + Gv_SetVar(i, varval, ID, -1); return OSDCMD_OK; } @@ -711,7 +711,7 @@ static int osdcmd_cmenu(const osdfuncparm_t *parm) } else { - cmenu(Batol(parm->parms[0])); + ChangeToMenu(Batol(parm->parms[0])); } return OSDCMD_OK; @@ -844,7 +844,7 @@ static int osdcmd_cvar_set(const osdfuncparm_t *parm) break; } if (cvar[i].type&CVAR_MULTI) - updateplayer(); + G_UpdatePlayerFromMenu(); } } OSD_Printf("\n"); @@ -909,7 +909,7 @@ static int osdcmd_give(const osdfuncparm_t *parm) else if (!Bstrcasecmp(parm->parms[0], "ammo")) { for (i=MAX_WEAPONS-(VOLUMEONE?6:1)-1;i>=PISTOL_WEAPON;i--) - addammo(i,g_player[myconnectindex].ps,g_player[myconnectindex].ps->max_ammo_amount[i]); + P_AddAmmo(i,g_player[myconnectindex].ps,g_player[myconnectindex].ps->max_ammo_amount[i]); return OSDCMD_OK; } else if (!Bstrcasecmp(parm->parms[0], "armor")) @@ -954,7 +954,7 @@ void onvideomodechange(int newmode) } setbrightness(ud.brightness>>2, pal, 0); - restorepalette = 1; + g_restorePalette = 1; crosshair_sum = 0; } @@ -996,7 +996,7 @@ static int osdcmd_name(const osdfuncparm_t *parm) if (parm->numparms != 1) { - OSD_Printf("\"name\" is \"%s\"\n",myname); + OSD_Printf("\"name\" is \"%s\"\n",szPlayerName); return OSDCMD_SHOWHELP; } @@ -1005,12 +1005,12 @@ static int osdcmd_name(const osdfuncparm_t *parm) while (Bstrlen(stripcolorcodes(namebuf,tempbuf)) > 10) tempbuf[Bstrlen(tempbuf)-1] = '\0'; - Bstrncpy(myname,tempbuf,sizeof(myname)-1); - myname[sizeof(myname)-1] = '\0'; + Bstrncpy(szPlayerName,tempbuf,sizeof(szPlayerName)-1); + szPlayerName[sizeof(szPlayerName)-1] = '\0'; - OSD_Printf("name %s\n",myname); + OSD_Printf("name %s\n",szPlayerName); - updateplayer(); + Net_SendPlayerName(); return OSDCMD_OK; } @@ -1285,7 +1285,7 @@ static int osdcmd_quicksave(const osdfuncparm_t *parm) UNREFERENCED_PARAMETER(parm); if (!(g_player[myconnectindex].ps->gm & MODE_GAME)) OSD_Printf("quicksave: not in a game.\n"); - else doquicksave = 1; + else g_doQuickSave = 1; return OSDCMD_OK; } @@ -1294,7 +1294,7 @@ static int osdcmd_quickload(const osdfuncparm_t *parm) UNREFERENCED_PARAMETER(parm); if (!(g_player[myconnectindex].ps->gm & MODE_GAME)) OSD_Printf("quickload: not in a game.\n"); - else doquicksave = 2; + else g_doQuickSave = 2; return OSDCMD_OK; } @@ -1306,24 +1306,24 @@ static int osdcmd_screenshot(const osdfuncparm_t *parm) return OSDCMD_OK; } -extern void savemapstate(mapstate_t *save); -extern void restoremapstate(mapstate_t *save); +extern void G_SaveMapState(mapstate_t *save); +extern void G_RestoreMapState(mapstate_t *save); /* static int osdcmd_savestate(const osdfuncparm_t *parm) { UNREFERENCED_PARAMETER(parm); - if (map[ud.volume_number*MAXLEVELS+ud.level_number].savedstate == NULL) - map[ud.volume_number*MAXLEVELS+ud.level_number].savedstate = Bcalloc(1,sizeof(mapstate_t)); - savemapstate(map[ud.volume_number*MAXLEVELS+ud.level_number].savedstate); + if (MapInfo[ud.volume_number*MAXLEVELS+ud.level_number].savedstate == NULL) + MapInfo[ud.volume_number*MAXLEVELS+ud.level_number].savedstate = Bcalloc(1,sizeof(mapstate_t)); + G_SaveMapState(MapInfo[ud.volume_number*MAXLEVELS+ud.level_number].savedstate); return OSDCMD_OK; } static int osdcmd_restorestate(const osdfuncparm_t *parm) { UNREFERENCED_PARAMETER(parm); - if (map[ud.volume_number*MAXLEVELS+ud.level_number].savedstate) - restoremapstate(map[ud.volume_number*MAXLEVELS+ud.level_number].savedstate); + if (MapInfo[ud.volume_number*MAXLEVELS+ud.level_number].savedstate) + G_RestoreMapState(MapInfo[ud.volume_number*MAXLEVELS+ud.level_number].savedstate); return OSDCMD_OK; } */ @@ -1383,8 +1383,8 @@ static int osdcmd_setcrosshairscale(const osdfuncparm_t *parm) return OSDCMD_OK; } -extern void SetCrosshairColor(int r, int g, int b); -extern palette_t crosshair_colors; +extern void G_SetCrosshairColor(int r, int g, int b); +extern palette_t CrosshairColors; static int osdcmd_crosshaircolor(const osdfuncparm_t *parm) { @@ -1392,13 +1392,13 @@ static int osdcmd_crosshaircolor(const osdfuncparm_t *parm) if (parm->numparms != 3) { - OSD_Printf("crosshaircolor: r:%d g:%d b:%d\n",crosshair_colors.r,crosshair_colors.g,crosshair_colors.b); + OSD_Printf("crosshaircolor: r:%d g:%d b:%d\n",CrosshairColors.r,CrosshairColors.g,CrosshairColors.b); return OSDCMD_SHOWHELP; } r = atol(parm->parms[0]); g = atol(parm->parms[1]); b = atol(parm->parms[2]); - SetCrosshairColor(r,g,b); + G_SetCrosshairColor(r,g,b); OSD_Printf("%s\n", parm->raw); return OSDCMD_OK; } @@ -1421,7 +1421,7 @@ static int osdcmd_visibility(const osdfuncparm_t *parm) static int osdcmd_maxfps(const osdfuncparm_t *parm) { - extern int g_FrameDelay; + extern int g_frameDelay; if (parm->numparms != 1) { @@ -1429,8 +1429,8 @@ static int osdcmd_maxfps(const osdfuncparm_t *parm) return OSDCMD_SHOWHELP; } r_maxfps = max(0,min(1000,atol(parm->parms[0]))); - if (r_maxfps) g_FrameDelay = (1000/r_maxfps); - else g_FrameDelay = 0; + if (r_maxfps) g_frameDelay = (1000/r_maxfps); + else g_frameDelay = 0; OSD_Printf("%s\n",parm->raw); return OSDCMD_OK; } @@ -1441,16 +1441,16 @@ static int osdcmd_inittimer(const osdfuncparm_t *parm) if (parm->numparms != 1) { - OSD_Printf("%dHz timer\n",timer); + OSD_Printf("%dHz timer\n",g_timerTicsPerSecond); return OSDCMD_SHOWHELP; } j = atol(parm->parms[0]); - if (timer == j) + if (g_timerTicsPerSecond == j) return OSDCMD_OK; uninittimer(); inittimer(j); - timer = j; + g_timerTicsPerSecond = j; OSD_Printf("%s\n",parm->raw); return OSDCMD_OK; @@ -1490,11 +1490,13 @@ int registerosdcommands(void) OSD_RegisterFunction("fileinfo","fileinfo : gets a file's information", osdcmd_fileinfo); - for (i=0;i=0;j--) diff --git a/polymer/eduke32/source/osdcmds.h b/polymer/eduke32/source/osdcmds.h index 7ce2b1422..3184b8a72 100644 --- a/polymer/eduke32/source/osdcmds.h +++ b/polymer/eduke32/source/osdcmds.h @@ -2,7 +2,7 @@ #define __osdcmds_h__ struct osdcmd_cheatsinfo { - int cheatnum; // -1 = none, else = see cheats() + int cheatnum; // -1 = none, else = see DoCheats() int volume,level; }; diff --git a/polymer/eduke32/source/osdfuncs.c b/polymer/eduke32/source/osdfuncs.c index d3adb778b..03d6a64e8 100644 --- a/polymer/eduke32/source/osdfuncs.c +++ b/polymer/eduke32/source/osdfuncs.c @@ -132,7 +132,7 @@ void GAME_onshowosd(int shown) picsiz[BGTILE] += ((char)(j<<4)); } - vscrn(); + G_UpdateScreenArea(); if (numplayers == 1) if ((shown && !ud.pause_on) || (!shown && ud.pause_on)) KB_KeyDown[sc_Pause] = 1; diff --git a/polymer/eduke32/source/player.c b/polymer/eduke32/source/player.c index 0b7ca85f0..e548abd52 100644 --- a/polymer/eduke32/source/player.c +++ b/polymer/eduke32/source/player.c @@ -40,9 +40,9 @@ int g_weapon_xoffset; int32 turnheldtime; //MED int32 lastcontroltime; //MED -extern int leveltexttime; +extern int g_levelTextTime; -void setpal(player_struct *p) +void P_UpdateScreenPal(DukePlayer_t *p) { if (p->heat_on) p->palette = slimepal; else if (p->cursectnum < 0) p->palette = palette; @@ -55,17 +55,17 @@ void setpal(player_struct *p) if (sector[p->cursectnum].lotag == 2) p->palette = waterpal; else p->palette = palette; } - restorepalette = 1; + g_restorePalette = 1; } -static void incur_damage(player_struct *p) +static void P_IncurDamage(DukePlayer_t *p) { int damage = 0L, shield_damage = 0L; - SetGameVarID(g_iReturnVarID,0,p->i,sprite[p->i].yvel); - OnEvent(EVENT_INCURDAMAGE, p->i, sprite[p->i].yvel, -1); + Gv_SetVar(g_iReturnVarID,0,p->i,sprite[p->i].yvel); + X_OnEvent(EVENT_INCURDAMAGE, p->i, sprite[p->i].yvel, -1); - if (GetGameVarID(g_iReturnVarID,p->i,sprite[p->i].yvel) == 0) + if (Gv_GetVar(g_iReturnVarID,p->i,sprite[p->i].yvel) == 0) { sprite[p->i].extra -= p->extra_extra8>>8; @@ -78,7 +78,7 @@ static void incur_damage(player_struct *p) if (p->shield_amount > 0) { - shield_damage = damage * (20 + (TRAND%30)) / 100; + shield_damage = damage * (20 + (krand()%30)) / 100; damage -= shield_damage; p->shield_amount += shield_damage; @@ -97,7 +97,7 @@ static void incur_damage(player_struct *p) } -void quickkill(player_struct *p) +void P_QuickKill(DukePlayer_t *p) { p->pals[0] = 48; p->pals[1] = 48; @@ -106,11 +106,11 @@ void quickkill(player_struct *p) sprite[p->i].extra = 0; sprite[p->i].cstat |= 32768; - if (ud.god == 0) guts(p->i,JIBS6,8); + if (ud.god == 0) A_DoGuts(p->i,JIBS6,8); return; } -static void tracers(int x1,int y1,int z1,int x2,int y2,int z2,int n) +static void A_DoWaterTracers(int x1,int y1,int z1,int x2,int y2,int z2,int n) { int i, xv, yv, zv; short sect = -1; @@ -132,21 +132,21 @@ static void tracers(int x1,int y1,int z1,int x2,int y2,int z2,int n) if (sect >= 0) { if (sector[sect].lotag == 2) - EGS(sect,x1,y1,z1,WATERBUBBLE,-32,4+(TRAND&3),4+(TRAND&3),TRAND&2047,0,0,g_player[0].ps->i,5); + A_InsertSprite(sect,x1,y1,z1,WATERBUBBLE,-32,4+(krand()&3),4+(krand()&3),krand()&2047,0,0,g_player[0].ps->i,5); else - EGS(sect,x1,y1,z1,SMALLSMOKE,-32,14,14,0,0,0,g_player[0].ps->i,5); + A_InsertSprite(sect,x1,y1,z1,SMALLSMOKE,-32,14,14,0,0,0,g_player[0].ps->i,5); } } } -static void hitscantrail(int x1, int y1, int z1, int x2, int y2, int z2, int ang, int atwith) +static void A_HitscanProjTrail(int x1, int y1, int z1, int x2, int y2, int z2, int ang, int atwith) { int n, j, i; short sect = -1; - x1 += (sintable[(348+ang+512)&2047]/projectile[atwith].offset); - y1 += (sintable[(ang+348)&2047]/projectile[atwith].offset); - z1 += 1024+(projectile[atwith].toffset<<8); + x1 += (sintable[(348+ang+512)&2047]/ProjectileData[atwith].offset); + y1 += (sintable[(ang+348)&2047]/ProjectileData[atwith].offset); + z1 += 1024+(ProjectileData[atwith].toffset<<8); n = ((FindDistance2D(x1-x2,y1-y2))>>8)+1; @@ -158,7 +158,7 @@ static void hitscantrail(int x1, int y1, int z1, int x2, int y2, int z2, int ang y1 += y2>>2; z1 += (z2>>2); - for (i=projectile[atwith].tnum;i>0;i--) + for (i=ProjectileData[atwith].tnum;i>0;i--) { x1 += x2; y1 += y2; @@ -167,12 +167,12 @@ static void hitscantrail(int x1, int y1, int z1, int x2, int y2, int z2, int ang getzsofslope(sect,x1,y1,&n,&j); if (sect < 0 || z1 > j || z1 < n) break; - j = EGS(sect,x1,y1,z1,projectile[atwith].trail,-32,projectile[atwith].txrepeat,projectile[atwith].tyrepeat,ang,0,0,g_player[0].ps->i,0); + j = A_InsertSprite(sect,x1,y1,z1,ProjectileData[atwith].trail,-32,ProjectileData[atwith].txrepeat,ProjectileData[atwith].tyrepeat,ang,0,0,g_player[0].ps->i,0); changespritestat(j,1); } } -int hits(int i) +int A_GetHitscanRange(int i) { int sx,sy,sz; short sect,hw,hs; @@ -188,7 +188,7 @@ int hits(int i) return (FindDistance2D(sx-SX,sy-SY)); } -static int aim(spritetype *s,int aang,int atwith) +static int A_FindTargetSprite(spritetype *s,int aang,int atwith) { int gotshrinker,gotfreezer; int i, j, a, k, cans; @@ -202,9 +202,9 @@ static int aim(spritetype *s,int aang,int atwith) return -1; if (g_player[s->yvel].ps->auto_aim == 2) { - if (checkspriteflagsp(atwith,SPRITE_FLAG_PROJECTILE) && (projectile[atwith].workslike & PROJECTILE_FLAG_RPG)) + if (A_CheckSpriteTileFlags(atwith,SPRITE_PROJECTILE) && (ProjectileData[atwith].workslike & PROJECTILE_RPG)) return -1; - else switch (dynamictostatic[atwith]) + else switch (DynamicTileMap[atwith]) { case TONGUE__STATIC: case FREEZEBLAST__STATIC: @@ -244,13 +244,13 @@ static int aim(spritetype *s,int aang,int atwith) break; for (i=headspritestat[aimstats[k]];i >= 0;i=nextspritestat[i]) if (sprite[i].xrepeat > 0 && sprite[i].extra >= 0 && (sprite[i].cstat&(257+32768)) == 257) - if (badguy(&sprite[i]) || k < 2) + if (A_CheckEnemySprite(&sprite[i]) || k < 2) { - if (badguy(&sprite[i]) || PN == APLAYER || PN == SHARK) + if (A_CheckEnemySprite(&sprite[i]) || PN == APLAYER || PN == SHARK) { if (PN == APLAYER && // ud.ffire == 0 && - (GTFLAGS(GAMETYPE_FLAG_PLAYERSFRIENDLY) || (GTFLAGS(GAMETYPE_FLAG_TDM) && g_player[sprite[i].yvel].ps->team == g_player[s->yvel].ps->team)) && + (GTFLAGS(GAMETYPE_PLAYERSFRIENDLY) || (GTFLAGS(GAMETYPE_TDM) && g_player[sprite[i].yvel].ps->team == g_player[s->yvel].ps->team)) && s->picnum == APLAYER && s != &sprite[i]) continue; @@ -298,7 +298,7 @@ static int aim(spritetype *s,int aang,int atwith) return j; } -int shoot(int i,int atwith) +int A_Shoot(int i,int atwith) { short hitsect, hitspr, hitwall, l, sa, p, j, k=-1, wh, scount; int sx, sy, sz, vel, zvel = 0, hitx, hity, hitz, x, oldzvel, dal; @@ -327,7 +327,7 @@ int shoot(int i,int atwith) if (s->picnum != ROTATEGUN) { sz -= (7<<8); - if (badguy(s) && PN != COMMANDER) + if (A_CheckEnemySprite(s) && PN != COMMANDER) { sx += (sintable[(sa+1024+96)&2047]>>7); sy += (sintable[(sa+512+96)&2047]>>7); @@ -335,25 +335,25 @@ int shoot(int i,int atwith) } } - if (checkspriteflagsp(atwith,SPRITE_FLAG_PROJECTILE)) + if (A_CheckSpriteTileFlags(atwith,SPRITE_PROJECTILE)) { /* Custom projectiles. This is a big hack. */ - if (projectile[atwith].offset == 0) projectile[atwith].offset = 1; + if (ProjectileData[atwith].offset == 0) ProjectileData[atwith].offset = 1; // writestring(sx,sy,sz,sect,sintable[(sa+512)&2047],sintable[sa&2047],zvel<<6); - if (projectile[atwith].workslike & PROJECTILE_FLAG_BLOOD || projectile[atwith].workslike & PROJECTILE_FLAG_KNEE) + if (ProjectileData[atwith].workslike & PROJECTILE_BLOOD || ProjectileData[atwith].workslike & PROJECTILE_KNEE) { - if (projectile[atwith].workslike & PROJECTILE_FLAG_BLOOD) + if (ProjectileData[atwith].workslike & PROJECTILE_BLOOD) { if (p >= 0) - sa += 64 - (TRAND&127); - else sa += 1024 + 64 - (TRAND&127); - zvel = 1024-(TRAND&2047); + sa += 64 - (krand()&127); + else sa += 1024 + 64 - (krand()&127); + zvel = 1024-(krand()&2047); } - if (projectile[atwith].workslike & PROJECTILE_FLAG_KNEE) + if (ProjectileData[atwith].workslike & PROJECTILE_KNEE) { if (p >= 0) { @@ -361,33 +361,33 @@ int shoot(int i,int atwith) sz += (6<<8); sa += 15; } - else if (!(projectile[atwith].workslike & PROJECTILE_FLAG_NOAIM)) + else if (!(ProjectileData[atwith].workslike & PROJECTILE_NOAIM)) { - j = g_player[findplayer(s,&x)].ps->i; + j = g_player[A_FindPlayer(s,&x)].ps->i; zvel = ((sprite[j].z-sz)<<8) / (x+1); sa = getangle(sprite[j].x-sx,sprite[j].y-sy); } } - if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9]; + if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; hitscan(sx,sy,sz,sect, sintable[(sa+512)&2047], sintable[sa&2047],zvel<<6, &hitsect,&hitwall,&hitspr,&hitx,&hity,&hitz,CLIPMASK1); - if (projectile[atwith].workslike & PROJECTILE_FLAG_BLOOD) + if (ProjectileData[atwith].workslike & PROJECTILE_BLOOD) { - if (projectile[atwith].range == 0) - projectile[atwith].range = 1024; + if (ProjectileData[atwith].range == 0) + ProjectileData[atwith].range = 1024; - if (FindDistance2D(sx-hitx,sy-hity) < projectile[atwith].range) - if (FindDistance2D(wall[hitwall].x-wall[wall[hitwall].point2].x,wall[hitwall].y-wall[wall[hitwall].point2].y) > (mulscale(projectile[atwith].xrepeat+8,tilesizx[projectile[atwith].decal],3))) + if (FindDistance2D(sx-hitx,sy-hity) < ProjectileData[atwith].range) + if (FindDistance2D(wall[hitwall].x-wall[wall[hitwall].point2].x,wall[hitwall].y-wall[wall[hitwall].point2].y) > (mulscale(ProjectileData[atwith].xrepeat+8,tilesizx[ProjectileData[atwith].decal],3))) if (hitwall >= 0 && wall[hitwall].overpicnum != BIGFORCE) if ((wall[hitwall].nextsector >= 0 && hitsect >= 0 && sector[wall[hitwall].nextsector].lotag == 0 && sector[hitsect].lotag == 0 && sector[wall[hitwall].nextsector].lotag == 0 && - (sector[hitsect].floorz-sector[wall[hitwall].nextsector].floorz) > (mulscale(projectile[atwith].yrepeat,tilesizy[projectile[atwith].decal],3)<<8)) || + (sector[hitsect].floorz-sector[wall[hitwall].nextsector].floorz) > (mulscale(ProjectileData[atwith].yrepeat,tilesizy[ProjectileData[atwith].decal],3)<<8)) || (wall[hitwall].nextsector == -1 && sector[hitsect].lotag == 0)) if ((wall[hitwall].cstat&16) == 0) { @@ -408,9 +408,9 @@ int shoot(int i,int atwith) if (wall[hitwall].hitag == 0) { - if (projectile[atwith].decal >= 0) + if (ProjectileData[atwith].decal >= 0) { - k = spawn(i,projectile[atwith].decal); + k = A_Spawn(i,ProjectileData[atwith].decal); /* sprite[k].xvel = -12; sprite[k].ang = getangle(wall[hitwall].x-wall[wall[hitwall].point2].x, @@ -418,47 +418,47 @@ int shoot(int i,int atwith) sprite[k].x = hitx; sprite[k].y = hity; sprite[k].z = hitz; - sprite[k].cstat |= (TRAND&4); - sprite[k].xrepeat = projectile[atwith].xrepeat; - sprite[k].yrepeat = projectile[atwith].yrepeat; + sprite[k].cstat |= (krand()&4); + sprite[k].xrepeat = ProjectileData[atwith].xrepeat; + sprite[k].yrepeat = ProjectileData[atwith].yrepeat; sprite[k].cstat = 16+(krand()&12); - ssp(k,CLIPMASK0); + A_SetSprite(k,CLIPMASK0); setsprite(k,sprite[k].x,sprite[k].y,sprite[k].z); - insertspriteq(k); + A_AddToDeleteQueue(k); */ - if (!spriteflags[projectile[atwith].decal] & SPRITE_FLAG_DECAL) - spriteflags[projectile[atwith].decal] |= SPRITE_FLAG_DECAL; + if (!SpriteFlags[ProjectileData[atwith].decal] & SPRITE_DECAL) + SpriteFlags[ProjectileData[atwith].decal] |= SPRITE_DECAL; - k = spawn(i,projectile[atwith].decal); + k = A_Spawn(i,ProjectileData[atwith].decal); sprite[k].xvel = -1; sprite[k].ang = getangle(wall[hitwall].x-wall[wall[hitwall].point2].x, wall[hitwall].y-wall[wall[hitwall].point2].y)+512; sprite[k].x = hitx; sprite[k].y = hity; sprite[k].z = hitz; - if (projectile[atwith].workslike & PROJECTILE_FLAG_RANDDECALSIZE) + if (ProjectileData[atwith].workslike & PROJECTILE_RANDDECALSIZE) { - wh = (TRAND&projectile[atwith].xrepeat); - if (wh < projectile[atwith].yrepeat) - wh = projectile[atwith].yrepeat; + wh = (krand()&ProjectileData[atwith].xrepeat); + if (wh < ProjectileData[atwith].yrepeat) + wh = ProjectileData[atwith].yrepeat; sprite[k].xrepeat = wh; sprite[k].yrepeat = wh; } else { - sprite[k].xrepeat = projectile[atwith].xrepeat; - sprite[k].yrepeat = projectile[atwith].yrepeat; + sprite[k].xrepeat = ProjectileData[atwith].xrepeat; + sprite[k].yrepeat = ProjectileData[atwith].yrepeat; } sprite[k].z += sprite[k].yrepeat<<8; // sprite[k].cstat = 16+(krand()&12); sprite[k].cstat = 16; - wh = (TRAND&1); + wh = (krand()&1); if (wh == 1) sprite[k].cstat |= 4; - wh = (TRAND&1); + wh = (krand()&1); if (wh == 1) sprite[k].cstat |= 8; @@ -467,8 +467,8 @@ int shoot(int i,int atwith) sprite[k].x -= mulscale13(1,sintable[(sprite[k].ang+2560)&2047]); sprite[k].y -= mulscale13(1,sintable[(sprite[k].ang+2048)&2047]); - ssp(k,CLIPMASK0); - insertspriteq(k); + A_SetSprite(k,CLIPMASK0); + A_AddToDeleteQueue(k); changespritestat(k,5); } @@ -481,31 +481,31 @@ int shoot(int i,int atwith) if (hitsect < 0) return -1; - if ((projectile[atwith].range == 0) && (projectile[atwith].workslike & PROJECTILE_FLAG_KNEE)) - projectile[atwith].range = 1024; + if ((ProjectileData[atwith].range == 0) && (ProjectileData[atwith].workslike & PROJECTILE_KNEE)) + ProjectileData[atwith].range = 1024; - if ((projectile[atwith].range > 0) && ((klabs(sx-hitx)+klabs(sy-hity)) > projectile[atwith].range)) + if ((ProjectileData[atwith].range > 0) && ((klabs(sx-hitx)+klabs(sy-hity)) > ProjectileData[atwith].range)) return -1; else { if (hitwall >= 0 || hitspr >= 0) { - j = EGS(hitsect,hitx,hity,hitz,atwith,-15,0,0,sa,32,0,i,4); - hittype[j].projectile.workslike = projectile[sprite[j].picnum].workslike; - sprite[j].extra = projectile[atwith].extra; - if (projectile[atwith].extra_rand > 0) - sprite[j].extra += (TRAND&projectile[atwith].extra_rand); + j = A_InsertSprite(hitsect,hitx,hity,hitz,atwith,-15,0,0,sa,32,0,i,4); + ActorExtra[j].projectile.workslike = ProjectileData[sprite[j].picnum].workslike; + sprite[j].extra = ProjectileData[atwith].extra; + if (ProjectileData[atwith].extra_rand > 0) + sprite[j].extra += (krand()&ProjectileData[atwith].extra_rand); if (p >= 0) { - if (projectile[atwith].spawns >= 0) + if (ProjectileData[atwith].spawns >= 0) { - k = spawn(j,projectile[atwith].spawns); + k = A_Spawn(j,ProjectileData[atwith].spawns); sprite[k].z -= (8<<8); - hittype[k].temp_data[6] = hitwall; - hittype[k].temp_data[7] = hitsect; - hittype[k].temp_data[8] = hitspr; + ActorExtra[k].temp_data[6] = hitwall; + ActorExtra[k].temp_data[7] = hitsect; + ActorExtra[k].temp_data[8] = hitspr; } - if (projectile[atwith].sound >= 0) spritesound(projectile[atwith].sound,j); + if (ProjectileData[atwith].sound >= 0) A_PlaySound(ProjectileData[atwith].sound,j); } if (p >= 0 && g_player[p].ps->steroids_amount > 0 && g_player[p].ps->steroids_amount < 400) @@ -513,8 +513,8 @@ int shoot(int i,int atwith) if (hitspr >= 0 && sprite[hitspr].picnum != ACCESSSWITCH && sprite[hitspr].picnum != ACCESSSWITCH2) { - checkhitsprite(hitspr,j); - if (p >= 0) checkhitswitch(p,hitspr,1); + A_DamageObject(hitspr,j); + if (p >= 0) P_ActivateSwitch(p,hitspr,1); } else if (hitwall >= 0) @@ -526,19 +526,19 @@ int shoot(int i,int atwith) if (hitwall >= 0 && wall[hitwall].picnum != ACCESSSWITCH && wall[hitwall].picnum != ACCESSSWITCH2) { - checkhitwall(j,hitwall,hitx,hity,hitz,atwith); - if (p >= 0) checkhitswitch(p,hitwall,0); + A_DamageWall(j,hitwall,hitx,hity,hitz,atwith); + if (p >= 0) P_ActivateSwitch(p,hitwall,0); } } } else if (p >= 0 && zvel > 0 && sector[hitsect].lotag == 1) { - j = spawn(g_player[p].ps->i,WATERSPLASH2); + j = A_Spawn(g_player[p].ps->i,WATERSPLASH2); sprite[j].x = hitx; sprite[j].y = hity; sprite[j].ang = g_player[p].ps->ang; // Total tweek sprite[j].xvel = 32; - ssp(i,CLIPMASK0); + A_SetSprite(i,CLIPMASK0); sprite[j].xvel = 0; } @@ -546,21 +546,21 @@ int shoot(int i,int atwith) return -1; } - if (projectile[atwith].workslike & PROJECTILE_FLAG_HITSCAN) + if (ProjectileData[atwith].workslike & PROJECTILE_HITSCAN) { - if (s->extra >= 0) s->shade = projectile[atwith].shade; + if (s->extra >= 0) s->shade = ProjectileData[atwith].shade; if (p >= 0) { int angRange=32; int zRange=256; - SetGameVarID(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); - OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); + Gv_SetVar(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); + X_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); j=-1; - if (GetGameVarID(g_iAimAngleVarID,i,p) > 0) + if (Gv_GetVar(g_iAimAngleVarID,i,p) > 0) { - j = aim(s, GetGameVarID(g_iAimAngleVarID,i,p),atwith); + j = A_FindTargetSprite(s, Gv_GetVar(g_iAimAngleVarID,i,p),atwith); } if (j >= 0) { @@ -576,18 +576,18 @@ int shoot(int i,int atwith) sa = getangle(sprite[j].x-sx,sprite[j].y-sy); } - SetGameVarID(g_iAngRangeVarID,angRange, i,p); - SetGameVarID(g_iZRangeVarID,zRange,i,p); - OnEvent(EVENT_GETSHOTRANGE, i,p, -1); - angRange=GetGameVarID(g_iAngRangeVarID,i,p); - zRange=GetGameVarID(g_iZRangeVarID,i,p); + Gv_SetVar(g_iAngRangeVarID,angRange, i,p); + Gv_SetVar(g_iZRangeVarID,zRange,i,p); + X_OnEvent(EVENT_GETSHOTRANGE, i,p, -1); + angRange=Gv_GetVar(g_iAngRangeVarID,i,p); + zRange=Gv_GetVar(g_iZRangeVarID,i,p); - if (projectile[atwith].workslike & PROJECTILE_FLAG_ACCURATE_AUTOAIM) + if (ProjectileData[atwith].workslike & PROJECTILE_ACCURATE_AUTOAIM) { if (!g_player[p].ps->auto_aim) { zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)<<5; - if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9]; + if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; hitscan(sx,sy,sz,sect,sintable[(sa+512)&2047],sintable[sa&2047], zvel<<6,&hitsect,&hitwall,&hitspr,&hitx,&hity,&hitz,CLIPMASK1); if (hitspr != -1) @@ -599,26 +599,26 @@ int shoot(int i,int atwith) if (j == -1) { - sa += (angRange/2)-(TRAND&(angRange-1)); + sa += (angRange/2)-(krand()&(angRange-1)); zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)<<5; - zvel += (zRange/2)-(TRAND&(zRange-1)); + zvel += (zRange/2)-(krand()&(zRange-1)); } } else { - sa += (angRange/2)-(TRAND&(angRange-1)); + sa += (angRange/2)-(krand()&(angRange-1)); if (j == -1) { // no target zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)<<5; } - zvel += (zRange/2)-(TRAND&(zRange-1)); + zvel += (zRange/2)-(krand()&(zRange-1)); } sz -= (2<<8); } else { - j = findplayer(s,&x); + j = A_FindPlayer(s,&x); sz -= (4<<8); hitx = ldist(&sprite[g_player[j].ps->i], s); if (hitx == 0) @@ -626,52 +626,52 @@ int shoot(int i,int atwith) zvel = ((g_player[j].ps->posz-sz) <<8) / hitx; if (s->picnum != BOSS1) { - zvel += 128-(TRAND&255); - sa += 32-(TRAND&63); + zvel += 128-(krand()&255); + sa += 32-(krand()&63); } else { - zvel += 128-(TRAND&255); - sa = getangle(g_player[j].ps->posx-sx,g_player[j].ps->posy-sy)+64-(TRAND&127); + zvel += 128-(krand()&255); + sa = getangle(g_player[j].ps->posx-sx,g_player[j].ps->posy-sy)+64-(krand()&127); } } - if (projectile[atwith].cstat >= 0) s->cstat &= ~projectile[atwith].cstat; + if (ProjectileData[atwith].cstat >= 0) s->cstat &= ~ProjectileData[atwith].cstat; else s->cstat &= ~257; - if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9]; + if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; hitscan(sx,sy,sz,sect, sintable[(sa+512)&2047], sintable[sa&2047], zvel<<6,&hitsect,&hitwall,&hitspr,&hitx,&hity,&hitz,CLIPMASK1); - if (projectile[atwith].cstat >= 0) s->cstat |= projectile[atwith].cstat; + if (ProjectileData[atwith].cstat >= 0) s->cstat |= ProjectileData[atwith].cstat; else s->cstat |= 257; if (hitsect < 0) return -1; - if ((projectile[atwith].range > 0) && ((klabs(sx-hitx)+klabs(sy-hity)) > projectile[atwith].range)) return -1; + if ((ProjectileData[atwith].range > 0) && ((klabs(sx-hitx)+klabs(sy-hity)) > ProjectileData[atwith].range)) return -1; - if (projectile[atwith].trail >= 0) - hitscantrail(sx,sy,sz,hitx,hity,hitz,sa,atwith); + if (ProjectileData[atwith].trail >= 0) + A_HitscanProjTrail(sx,sy,sz,hitx,hity,hitz,sa,atwith); - if (projectile[atwith].workslike & PROJECTILE_FLAG_WATERBUBBLES) + if (ProjectileData[atwith].workslike & PROJECTILE_WATERBUBBLES) { - if ((TRAND&15) == 0 && sector[hitsect].lotag == 2) - tracers(hitx,hity,hitz,sx,sy,sz,8-(ud.multimode>>1)); + if ((krand()&15) == 0 && sector[hitsect].lotag == 2) + A_DoWaterTracers(hitx,hity,hitz,sx,sy,sz,8-(ud.multimode>>1)); } if (p >= 0) { - k = EGS(hitsect,hitx,hity,hitz,SHOTSPARK1,-15,10,10,sa,0,0,i,4); - sprite[k].extra = projectile[atwith].extra; - if (projectile[atwith].extra_rand > 0) - sprite[k].extra += (TRAND%projectile[atwith].extra_rand); + k = A_InsertSprite(hitsect,hitx,hity,hitz,SHOTSPARK1,-15,10,10,sa,0,0,i,4); + sprite[k].extra = ProjectileData[atwith].extra; + if (ProjectileData[atwith].extra_rand > 0) + sprite[k].extra += (krand()%ProjectileData[atwith].extra_rand); sprite[k].yvel = atwith; // this is a hack to allow you to detect which weapon spawned a SHOTSPARK1 - hittype[k].temp_data[6] = hitwall; - hittype[k].temp_data[7] = hitsect; - hittype[k].temp_data[8] = hitspr; + ActorExtra[k].temp_data[6] = hitwall; + ActorExtra[k].temp_data[7] = hitsect; + ActorExtra[k].temp_data[8] = hitspr; if (hitwall == -1 && hitspr == -1) { @@ -684,41 +684,41 @@ int shoot(int i,int atwith) return -1; } else - checkhitceiling(hitsect); + Sect_DamageCeiling(hitsect); } - if (projectile[atwith].spawns >= 0) + if (ProjectileData[atwith].spawns >= 0) { - wh=spawn(k,projectile[atwith].spawns); - if (projectile[atwith].sxrepeat > 4) sprite[wh].xrepeat=projectile[atwith].sxrepeat; - if (projectile[atwith].syrepeat > 4) sprite[wh].yrepeat=projectile[atwith].syrepeat; - hittype[wh].temp_data[6] = hitwall; - hittype[wh].temp_data[7] = hitsect; - hittype[wh].temp_data[8] = hitspr; + wh=A_Spawn(k,ProjectileData[atwith].spawns); + if (ProjectileData[atwith].sxrepeat > 4) sprite[wh].xrepeat=ProjectileData[atwith].sxrepeat; + if (ProjectileData[atwith].syrepeat > 4) sprite[wh].yrepeat=ProjectileData[atwith].syrepeat; + ActorExtra[wh].temp_data[6] = hitwall; + ActorExtra[wh].temp_data[7] = hitsect; + ActorExtra[wh].temp_data[8] = hitspr; } } if (hitspr >= 0) { - checkhitsprite(hitspr,k); - if (sprite[hitspr].picnum == APLAYER && (ud.ffire == 1 || (!GTFLAGS(GAMETYPE_FLAG_PLAYERSFRIENDLY) && GTFLAGS(GAMETYPE_FLAG_TDM) && g_player[sprite[hitspr].yvel].ps->team != g_player[sprite[i].yvel].ps->team))) + A_DamageObject(hitspr,k); + if (sprite[hitspr].picnum == APLAYER && (ud.ffire == 1 || (!GTFLAGS(GAMETYPE_PLAYERSFRIENDLY) && GTFLAGS(GAMETYPE_TDM) && g_player[sprite[hitspr].yvel].ps->team != g_player[sprite[i].yvel].ps->team))) { - l = spawn(k,JIBS6); + l = A_Spawn(k,JIBS6); sprite[k].xrepeat = sprite[k].yrepeat = 0; sprite[l].z += (4<<8); sprite[l].xvel = 16; sprite[l].xrepeat = sprite[l].yrepeat = 24; - sprite[l].ang += 64-(TRAND&127); + sprite[l].ang += 64-(krand()&127); } else { - if (projectile[atwith].spawns >= 0) + if (ProjectileData[atwith].spawns >= 0) { - wh=spawn(k,projectile[atwith].spawns); - if (projectile[atwith].sxrepeat > 4) sprite[wh].xrepeat=projectile[atwith].sxrepeat; - if (projectile[atwith].syrepeat > 4) sprite[wh].yrepeat=projectile[atwith].syrepeat; - hittype[wh].temp_data[6] = hitwall; - hittype[wh].temp_data[7] = hitsect; - hittype[wh].temp_data[8] = hitspr; + wh=A_Spawn(k,ProjectileData[atwith].spawns); + if (ProjectileData[atwith].sxrepeat > 4) sprite[wh].xrepeat=ProjectileData[atwith].sxrepeat; + if (ProjectileData[atwith].syrepeat > 4) sprite[wh].yrepeat=ProjectileData[atwith].syrepeat; + ActorExtra[wh].temp_data[6] = hitwall; + ActorExtra[wh].temp_data[7] = hitsect; + ActorExtra[wh].temp_data[8] = hitspr; } } if (p >= 0 && ( @@ -731,22 +731,22 @@ int shoot(int i,int atwith) sprite[hitspr].picnum == HANDSWITCH || sprite[hitspr].picnum == HANDSWITCH+1)) { - checkhitswitch(p,hitspr,1); + P_ActivateSwitch(p,hitspr,1); return -1; } } else if (hitwall >= 0) { - if (projectile[atwith].spawns >= 0) + if (ProjectileData[atwith].spawns >= 0) { - wh=spawn(k,projectile[atwith].spawns); - if (projectile[atwith].sxrepeat > 4) sprite[wh].xrepeat=projectile[atwith].sxrepeat; - if (projectile[atwith].syrepeat > 4) sprite[wh].yrepeat=projectile[atwith].syrepeat; - hittype[wh].temp_data[6] = hitwall; - hittype[wh].temp_data[7] = hitsect; - hittype[wh].temp_data[8] = hitspr; + wh=A_Spawn(k,ProjectileData[atwith].spawns); + if (ProjectileData[atwith].sxrepeat > 4) sprite[wh].xrepeat=ProjectileData[atwith].sxrepeat; + if (ProjectileData[atwith].syrepeat > 4) sprite[wh].yrepeat=ProjectileData[atwith].syrepeat; + ActorExtra[wh].temp_data[6] = hitwall; + ActorExtra[wh].temp_data[7] = hitsect; + ActorExtra[wh].temp_data[8] = hitspr; } - if (isadoorwall(wall[hitwall].picnum) == 1) + if (CheckDoorTile(wall[hitwall].picnum) == 1) goto DOSKIPBULLETHOLE; if (p >= 0 && ( wall[hitwall].picnum == DIPSWITCH || @@ -758,7 +758,7 @@ int shoot(int i,int atwith) wall[hitwall].picnum == HANDSWITCH || wall[hitwall].picnum == HANDSWITCH+1)) { - checkhitswitch(p,hitwall,0); + P_ActivateSwitch(p,hitwall,0); return -1; } @@ -782,39 +782,39 @@ int shoot(int i,int atwith) } } - l = headspritestat[5]; + l = headspritestat[STAT_MISC]; while (l >= 0) { - if (sprite[l].picnum == projectile[atwith].decal) - if (dist(&sprite[l],&sprite[k]) < (12+(TRAND&7))) + if (sprite[l].picnum == ProjectileData[atwith].decal) + if (dist(&sprite[l],&sprite[k]) < (12+(krand()&7))) goto DOSKIPBULLETHOLE; l = nextspritestat[l]; } - if (projectile[atwith].decal >= 0) + if (ProjectileData[atwith].decal >= 0) { - l = spawn(k,projectile[atwith].decal); + l = A_Spawn(k,ProjectileData[atwith].decal); sprite[l].xvel = -1; sprite[l].ang = getangle(wall[hitwall].x-wall[wall[hitwall].point2].x, wall[hitwall].y-wall[wall[hitwall].point2].y)+512; - if (projectile[atwith].workslike & PROJECTILE_FLAG_RANDDECALSIZE) + if (ProjectileData[atwith].workslike & PROJECTILE_RANDDECALSIZE) { - wh = (TRAND&projectile[atwith].xrepeat); - if (wh < projectile[atwith].yrepeat) - wh = projectile[atwith].yrepeat; + wh = (krand()&ProjectileData[atwith].xrepeat); + if (wh < ProjectileData[atwith].yrepeat) + wh = ProjectileData[atwith].yrepeat; sprite[l].xrepeat = wh; sprite[l].yrepeat = wh; } else { - sprite[l].xrepeat = projectile[atwith].xrepeat; - sprite[l].yrepeat = projectile[atwith].yrepeat; + sprite[l].xrepeat = ProjectileData[atwith].xrepeat; + sprite[l].yrepeat = ProjectileData[atwith].yrepeat; } sprite[l].cstat = 16+(krand()&12); sprite[l].x -= mulscale13(1,sintable[(sprite[l].ang+2560)&2047]); sprite[l].y -= mulscale13(1,sintable[(sprite[l].ang+2048)&2047]); - ssp(l,CLIPMASK0); - insertspriteq(l); + A_SetSprite(l,CLIPMASK0); + A_AddToDeleteQueue(l); } } @@ -825,89 +825,95 @@ DOSKIPBULLETHOLE: if (hitz >= (sector[wall[hitwall].nextsector].floorz)) hitwall = wall[hitwall].nextwall; - checkhitwall(k,hitwall,hitx,hity,hitz,atwith); + A_DamageWall(k,hitwall,hitx,hity,hitz,atwith); } } else { - k = EGS(hitsect,hitx,hity,hitz,SHOTSPARK1,-15,24,24,sa,0,0,i,4); - sprite[k].extra = projectile[atwith].extra; - if (projectile[atwith].extra_rand > 0) - sprite[k].extra += (TRAND%projectile[atwith].extra_rand); + k = A_InsertSprite(hitsect,hitx,hity,hitz,SHOTSPARK1,-15,24,24,sa,0,0,i,4); + sprite[k].extra = ProjectileData[atwith].extra; + if (ProjectileData[atwith].extra_rand > 0) + sprite[k].extra += (krand()%ProjectileData[atwith].extra_rand); sprite[k].yvel = atwith; // this is a hack to allow you to detect which weapon spawned a SHOTSPARK1 - hittype[k].temp_data[6] = hitwall; - hittype[k].temp_data[7] = hitsect; - hittype[k].temp_data[8] = hitspr; + ActorExtra[k].temp_data[6] = hitwall; + ActorExtra[k].temp_data[7] = hitsect; + ActorExtra[k].temp_data[8] = hitspr; if (hitspr >= 0) { - checkhitsprite(hitspr,k); + A_DamageObject(hitspr,k); if (sprite[hitspr].picnum != APLAYER) { - if (projectile[atwith].spawns >= 0) + if (ProjectileData[atwith].spawns >= 0) { - wh=spawn(k,projectile[atwith].spawns); - if (projectile[atwith].sxrepeat > 4) sprite[wh].xrepeat=projectile[atwith].sxrepeat; - if (projectile[atwith].syrepeat > 4) sprite[wh].yrepeat=projectile[atwith].syrepeat; - hittype[wh].temp_data[6] = hitwall; - hittype[wh].temp_data[7] = hitsect; - hittype[wh].temp_data[8] = hitspr; + wh=A_Spawn(k,ProjectileData[atwith].spawns); + if (ProjectileData[atwith].sxrepeat > 4) sprite[wh].xrepeat=ProjectileData[atwith].sxrepeat; + if (ProjectileData[atwith].syrepeat > 4) sprite[wh].yrepeat=ProjectileData[atwith].syrepeat; + ActorExtra[wh].temp_data[6] = hitwall; + ActorExtra[wh].temp_data[7] = hitsect; + ActorExtra[wh].temp_data[8] = hitspr; } } else sprite[k].xrepeat = sprite[k].yrepeat = 0; } else if (hitwall >= 0) - checkhitwall(k,hitwall,hitx,hity,hitz,atwith); + A_DamageWall(k,hitwall,hitx,hity,hitz,atwith); } - if ((TRAND&255) < 4) - if (projectile[atwith].isound >= 0) - xyzsound(projectile[atwith].isound,k,hitx,hity,hitz); + if ((krand()&255) < 4) + if (ProjectileData[atwith].isound >= 0) + S_PlaySoundXYZ(ProjectileData[atwith].isound,k,hitx,hity,hitz); return -1; } - if (projectile[atwith].workslike & PROJECTILE_FLAG_RPG) + if (ProjectileData[atwith].workslike & PROJECTILE_RPG) { - /* if(projectile[atwith].workslike & PROJECTILE_FLAG_FREEZEBLAST) + /* if(ProjectileData[atwith].workslike & PROJECTILE_FREEZEBLAST) sz += (3<<8);*/ - if (s->extra >= 0) s->shade = projectile[atwith].shade; + if (s->extra >= 0) s->shade = ProjectileData[atwith].shade; scount = 1; - vel = projectile[atwith].vel; + vel = ProjectileData[atwith].vel; j = -1; if (p >= 0) { - // j = aim( s, AUTO_AIM_ANGLE ); // 48 - SetGameVarID(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); - OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); + // j = A_FindTargetSprite( s, AUTO_AIM_ANGLE ); // 48 + Gv_SetVar(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); + X_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); j=-1; - if (GetGameVarID(g_iAimAngleVarID,i,p) > 0) + if (Gv_GetVar(g_iAimAngleVarID,i,p) > 0) { - j = aim(s, GetGameVarID(g_iAimAngleVarID,i,p),atwith); + j = A_FindTargetSprite(s, Gv_GetVar(g_iAimAngleVarID,i,p),atwith); } if (j >= 0) { dal = ((sprite[j].yrepeat*tilesizy[sprite[j].picnum])<<1)+(8<<8); hitx = ldist(&sprite[g_player[p].ps->i], &sprite[j]); - if (hitx == 0) hitx++; + + if (hitx == 0) + hitx++; + zvel = ((sprite[j].z-sz-dal)*vel) / hitx; + if (sprite[j].picnum != RECON) sa = getangle(sprite[j].x-sx,sprite[j].y-sy); } // else zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)*81; - else zvel = ((100-g_player[p].ps->horiz-g_player[p].ps->horizoff)*(projectile[atwith].vel/8)); - if (projectile[atwith].sound >= 0) spritesound(projectile[atwith].sound,i); + else zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)*(ProjectileData[atwith].vel/8); + + if (ProjectileData[atwith].sound >= 0) + A_PlaySound(ProjectileData[atwith].sound,i); } else { - if (!(projectile[atwith].workslike & PROJECTILE_FLAG_NOAIM)) + if (!(ProjectileData[atwith].workslike & PROJECTILE_NOAIM)) { - j = findplayer(s,&x); + j = A_FindPlayer(s,&x); sa = getangle(g_player[j].ps->oposx-sx,g_player[j].ps->oposy-sy); l = ldist(&sprite[g_player[j].ps->i],s); @@ -915,8 +921,8 @@ DOSKIPBULLETHOLE: l++; zvel = ((g_player[j].ps->oposz-sz)*vel) / l; - if (badguy(s) && (s->hitag&face_player_smart)) - sa = s->ang+(TRAND&31)-16; + if (A_CheckEnemySprite(s) && (s->hitag&face_player_smart)) + sa = s->ang+(krand()&31)-16; } } @@ -926,28 +932,28 @@ DOSKIPBULLETHOLE: l = j; else l = -1; - /* j = EGS(sect, + /* j = A_InsertSprite(sect, sx+(sintable[(348+sa+512)&2047]/448), sy+(sintable[(sa+348)&2047]/448), sz-(1<<8),atwith,0,14,14,sa,vel,zvel,i,4);*/ - if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9]; - j = EGS(sect, - sx+(sintable[(348+sa+512)&2047]/projectile[atwith].offset), - sy+(sintable[(sa+348)&2047]/projectile[atwith].offset), - sz-(1<<8),atwith,0,14,14,sa,vel,zvel,i,4); + if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; + j = A_InsertSprite(sect, + sx+(sintable[(348+sa+512)&2047]/ProjectileData[atwith].offset), + sy+(sintable[(sa+348)&2047]/ProjectileData[atwith].offset), + sz-(1<<8),atwith,0,14,14,sa,vel,zvel,i,4); - sprite[j].xrepeat=projectile[atwith].xrepeat; - sprite[j].yrepeat=projectile[atwith].yrepeat; + sprite[j].xrepeat=ProjectileData[atwith].xrepeat; + sprite[j].yrepeat=ProjectileData[atwith].yrepeat; - if (projectile[atwith].extra_rand > 0) - sprite[j].extra += (TRAND&projectile[atwith].extra_rand); - if (!(projectile[atwith].workslike & PROJECTILE_FLAG_BOUNCESOFFWALLS)) + if (ProjectileData[atwith].extra_rand > 0) + sprite[j].extra += (krand()&ProjectileData[atwith].extra_rand); + if (!(ProjectileData[atwith].workslike & PROJECTILE_BOUNCESOFFWALLS)) sprite[j].yvel = l; else { - if (projectile[atwith].bounces >= 1) sprite[j].yvel = projectile[atwith].bounces; - else sprite[j].yvel = numfreezebounces; + if (ProjectileData[atwith].bounces >= 1) sprite[j].yvel = ProjectileData[atwith].bounces; + else sprite[j].yvel = g_numFreezeBounces; // sprite[j].xrepeat >>= 1; // sprite[j].yrepeat >>= 1; sprite[j].zvel -= (2<<4); @@ -955,33 +961,31 @@ DOSKIPBULLETHOLE: /* if(p == -1) { - if(!(projectile[atwith].workslike & PROJECTILE_FLAG_BOUNCESOFFWALLS)) + if(!(ProjectileData[atwith].workslike & PROJECTILE_BOUNCESOFFWALLS)) { - sprite[j].xrepeat = projectile[atwith].xrepeat; // 30 - sprite[j].yrepeat = projectile[atwith].yrepeat; + sprite[j].xrepeat = ProjectileData[atwith].xrepeat; // 30 + sprite[j].yrepeat = ProjectileData[atwith].yrepeat; sprite[j].extra >>= 2; } } */ - if (projectile[atwith].cstat >= 0) sprite[j].cstat = projectile[atwith].cstat; + if (ProjectileData[atwith].cstat >= 0) sprite[j].cstat = ProjectileData[atwith].cstat; else sprite[j].cstat = 128; - if (projectile[atwith].clipdist >= 0) sprite[j].clipdist = projectile[atwith].clipdist; + if (ProjectileData[atwith].clipdist >= 0) sprite[j].clipdist = ProjectileData[atwith].clipdist; else sprite[j].clipdist = 40; - Bmemcpy(&hittype[j].projectile, &projectile[sprite[j].picnum], sizeof(projectile[sprite[j].picnum])); + Bmemcpy(&ActorExtra[j].projectile, &ProjectileData[sprite[j].picnum], sizeof(ProjectileData[sprite[j].picnum])); - // sa = s->ang+32-(TRAND&63); - // zvel = oldzvel+512-(TRAND&1023); + // sa = s->ang+32-(krand()&63); + // zvel = oldzvel+512-(krand()&1023); return j; } } - else - { - switch (dynamictostatic[atwith]) + switch (DynamicTileMap[atwith]) { case BLOODSPLAT1__STATIC: case BLOODSPLAT2__STATIC: @@ -989,9 +993,9 @@ DOSKIPBULLETHOLE: case BLOODSPLAT4__STATIC: if (p >= 0) - sa += 64 - (TRAND&127); - else sa += 1024 + 64 - (TRAND&127); - zvel = 1024-(TRAND&2047); + sa += 64 - (krand()&127); + else sa += 1024 + 64 - (krand()&127); + zvel = 1024-(krand()&2047); case KNEE__STATIC: if (atwith == KNEE) { @@ -1003,14 +1007,14 @@ DOSKIPBULLETHOLE: } else { - j = g_player[findplayer(s,&x)].ps->i; + j = g_player[A_FindPlayer(s,&x)].ps->i; zvel = ((sprite[j].z-sz)<<8) / (x+1); sa = getangle(sprite[j].x-sx,sprite[j].y-sy); } } // writestring(sx,sy,sz,sect,sintable[(sa+512)&2047],sintable[sa&2047],zvel<<6); - if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9]; + if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; hitscan(sx,sy,sz,sect, sintable[(sa+512)&2047], sintable[sa&2047],zvel<<6, @@ -1045,15 +1049,15 @@ DOSKIPBULLETHOLE: if (wall[hitwall].hitag == 0) { - k = spawn(i,atwith); + k = A_Spawn(i,atwith); sprite[k].xvel = -12; sprite[k].ang = getangle(wall[hitwall].x-wall[wall[hitwall].point2].x, wall[hitwall].y-wall[wall[hitwall].point2].y)+512; sprite[k].x = hitx; sprite[k].y = hity; sprite[k].z = hitz; - sprite[k].cstat |= (TRAND&4); - ssp(k,CLIPMASK0); + sprite[k].cstat |= (krand()&4); + A_SetSprite(k,CLIPMASK0); setsprite(k,sprite[k].x,sprite[k].y,sprite[k].z); if (PN == OOZFILTER || PN == NEWBEAST) sprite[k].pal = 6; @@ -1068,16 +1072,16 @@ DOSKIPBULLETHOLE: { if (hitwall >= 0 || hitspr >= 0) { - j = EGS(hitsect,hitx,hity,hitz,KNEE,-15,0,0,sa,32,0,i,4); - sprite[j].extra += (TRAND&7); + j = A_InsertSprite(hitsect,hitx,hity,hitz,KNEE,-15,0,0,sa,32,0,i,4); + sprite[j].extra += (krand()&7); if (p >= 0) { - k = spawn(j,SMALLSMOKE); + k = A_Spawn(j,SMALLSMOKE); sprite[k].z -= (8<<8); - spritesound(KICK_HIT,j); - hittype[k].temp_data[6] = hitwall; - hittype[k].temp_data[7] = hitsect; - hittype[k].temp_data[8] = hitspr; + A_PlaySound(KICK_HIT,j); + ActorExtra[k].temp_data[6] = hitwall; + ActorExtra[k].temp_data[7] = hitsect; + ActorExtra[k].temp_data[8] = hitspr; } if (p >= 0 && g_player[p].ps->steroids_amount > 0 && g_player[p].ps->steroids_amount < 400) @@ -1085,8 +1089,8 @@ DOSKIPBULLETHOLE: if (hitspr >= 0 && sprite[hitspr].picnum != ACCESSSWITCH && sprite[hitspr].picnum != ACCESSSWITCH2) { - checkhitsprite(hitspr,j); - if (p >= 0) checkhitswitch(p,hitspr,1); + A_DamageObject(hitspr,j); + if (p >= 0) P_ActivateSwitch(p,hitspr,1); } else if (hitwall >= 0) @@ -1098,19 +1102,19 @@ DOSKIPBULLETHOLE: if (hitwall >= 0 && wall[hitwall].picnum != ACCESSSWITCH && wall[hitwall].picnum != ACCESSSWITCH2) { - checkhitwall(j,hitwall,hitx,hity,hitz,atwith); - if (p >= 0) checkhitswitch(p,hitwall,0); + A_DamageWall(j,hitwall,hitx,hity,hitz,atwith); + if (p >= 0) P_ActivateSwitch(p,hitwall,0); } } } else if (p >= 0 && zvel > 0 && sector[hitsect].lotag == 1) { - j = spawn(g_player[p].ps->i,WATERSPLASH2); + j = A_Spawn(g_player[p].ps->i,WATERSPLASH2); sprite[j].x = hitx; sprite[j].y = hity; sprite[j].ang = g_player[p].ps->ang; // Total tweek sprite[j].xvel = 32; - ssp(i,CLIPMASK0); + A_SetSprite(i,CLIPMASK0); sprite[j].xvel = 0; } @@ -1129,12 +1133,12 @@ DOSKIPBULLETHOLE: int angRange=32; int zRange=256; - SetGameVarID(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); - OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); + Gv_SetVar(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); + X_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); j=-1; - if (GetGameVarID(g_iAimAngleVarID,i,p) > 0) + if (Gv_GetVar(g_iAimAngleVarID,i,p) > 0) { - j = aim(s, GetGameVarID(g_iAimAngleVarID,i,p),atwith); + j = A_FindTargetSprite(s, Gv_GetVar(g_iAimAngleVarID,i,p),atwith); } if (j >= 0) { @@ -1151,20 +1155,20 @@ DOSKIPBULLETHOLE: sa = getangle(sprite[j].x-sx,sprite[j].y-sy); } - SetGameVarID(g_iAngRangeVarID,angRange, i,p); - SetGameVarID(g_iZRangeVarID,zRange,i,p); + Gv_SetVar(g_iAngRangeVarID,angRange, i,p); + Gv_SetVar(g_iZRangeVarID,zRange,i,p); - OnEvent(EVENT_GETSHOTRANGE, i,p, -1); + X_OnEvent(EVENT_GETSHOTRANGE, i,p, -1); - angRange=GetGameVarID(g_iAngRangeVarID,i,p); - zRange=GetGameVarID(g_iZRangeVarID,i,p); + angRange=Gv_GetVar(g_iAngRangeVarID,i,p); + zRange=Gv_GetVar(g_iZRangeVarID,i,p); if (atwith == SHOTSPARK1__STATIC && !WW2GI && !NAM) { if (!g_player[p].ps->auto_aim) { zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)<<5; - if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9]; + if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; hitscan(sx,sy,sz,sect,sintable[(sa+512)&2047],sintable[sa&2047], zvel<<6,&hitsect,&hitwall,&hitspr,&hitx,&hity,&hitz,CLIPMASK1); if (hitspr != -1) @@ -1176,27 +1180,27 @@ DOSKIPBULLETHOLE: if (j == -1) { - sa += (angRange/2)-(TRAND&(angRange-1)); + sa += (angRange/2)-(krand()&(angRange-1)); zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)<<5; - zvel += (zRange/2)-(TRAND&(zRange-1)); + zvel += (zRange/2)-(krand()&(zRange-1)); } } else { - sa += (angRange/2)-(TRAND&(angRange-1)); + sa += (angRange/2)-(krand()&(angRange-1)); if (j == -1) { // no target zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)<<5; } - zvel += (zRange/2)-(TRAND&(zRange-1)); + zvel += (zRange/2)-(krand()&(zRange-1)); } sz -= (2<<8); } else { - j = findplayer(s,&x); + j = A_FindPlayer(s,&x); sz -= (4<<8); hitx = ldist(&sprite[g_player[j].ps->i], s); if (hitx == 0) @@ -1204,18 +1208,18 @@ DOSKIPBULLETHOLE: zvel = ((g_player[j].ps->posz-sz) <<8) / hitx; if (s->picnum != BOSS1) { - zvel += 128-(TRAND&255); - sa += 32-(TRAND&63); + zvel += 128-(krand()&255); + sa += 32-(krand()&63); } else { - zvel += 128-(TRAND&255); - sa = getangle(g_player[j].ps->posx-sx,g_player[j].ps->posy-sy)+64-(TRAND&127); + zvel += 128-(krand()&255); + sa = getangle(g_player[j].ps->posx-sx,g_player[j].ps->posy-sy)+64-(krand()&127); } } s->cstat &= ~257; - if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9]; + if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; hitscan(sx,sy,sz,sect, sintable[(sa+512)&2047], sintable[sa&2047], @@ -1224,18 +1228,18 @@ DOSKIPBULLETHOLE: if (hitsect < 0) return -1; - if ((TRAND&15) == 0 && sector[hitsect].lotag == 2) - tracers(hitx,hity,hitz,sx,sy,sz,8-(ud.multimode>>1)); + if ((krand()&15) == 0 && sector[hitsect].lotag == 2) + A_DoWaterTracers(hitx,hity,hitz,sx,sy,sz,8-(ud.multimode>>1)); if (p >= 0) { - k = EGS(hitsect,hitx,hity,hitz,SHOTSPARK1,-15,10,10,sa,0,0,i,4); + k = A_InsertSprite(hitsect,hitx,hity,hitz,SHOTSPARK1,-15,10,10,sa,0,0,i,4); sprite[k].extra = *actorscrptr[atwith]; - sprite[k].extra += (TRAND%6); + sprite[k].extra += (krand()%6); sprite[k].yvel = atwith; // this is a hack to allow you to detect which weapon spawned a SHOTSPARK1 - hittype[k].temp_data[6] = hitwall; - hittype[k].temp_data[7] = hitsect; - hittype[k].temp_data[8] = hitspr; + ActorExtra[k].temp_data[6] = hitwall; + ActorExtra[k].temp_data[7] = hitsect; + ActorExtra[k].temp_data[8] = hitspr; if (hitwall == -1 && hitspr == -1) @@ -1249,32 +1253,32 @@ DOSKIPBULLETHOLE: return -1; } else - checkhitceiling(hitsect); + Sect_DamageCeiling(hitsect); } - l = spawn(k,SMALLSMOKE); - hittype[l].temp_data[6] = hitwall; - hittype[l].temp_data[7] = hitsect; - hittype[l].temp_data[8] = hitspr; + l = A_Spawn(k,SMALLSMOKE); + ActorExtra[l].temp_data[6] = hitwall; + ActorExtra[l].temp_data[7] = hitsect; + ActorExtra[l].temp_data[8] = hitspr; } if (hitspr >= 0) { - checkhitsprite(hitspr,k); - if (sprite[hitspr].picnum == APLAYER && (ud.ffire == 1 || (!GTFLAGS(GAMETYPE_FLAG_PLAYERSFRIENDLY) && GTFLAGS(GAMETYPE_FLAG_TDM) && g_player[sprite[hitspr].yvel].ps->team != g_player[sprite[i].yvel].ps->team))) + A_DamageObject(hitspr,k); + if (sprite[hitspr].picnum == APLAYER && (ud.ffire == 1 || (!GTFLAGS(GAMETYPE_PLAYERSFRIENDLY) && GTFLAGS(GAMETYPE_TDM) && g_player[sprite[hitspr].yvel].ps->team != g_player[sprite[i].yvel].ps->team))) { - l = spawn(k,JIBS6); + l = A_Spawn(k,JIBS6); sprite[k].xrepeat = sprite[k].yrepeat = 0; sprite[l].z += (4<<8); sprite[l].xvel = 16; sprite[l].xrepeat = sprite[l].yrepeat = 24; - sprite[l].ang += 64-(TRAND&127); + sprite[l].ang += 64-(krand()&127); } else { - l = spawn(k,SMALLSMOKE); - hittype[l].temp_data[6] = hitwall; - hittype[l].temp_data[7] = hitsect; - hittype[l].temp_data[8] = hitspr; + l = A_Spawn(k,SMALLSMOKE); + ActorExtra[l].temp_data[6] = hitwall; + ActorExtra[l].temp_data[7] = hitsect; + ActorExtra[l].temp_data[8] = hitspr; } if (p >= 0 && ( @@ -1287,18 +1291,18 @@ DOSKIPBULLETHOLE: sprite[hitspr].picnum == HANDSWITCH || sprite[hitspr].picnum == HANDSWITCH+1)) { - checkhitswitch(p,hitspr,1); + P_ActivateSwitch(p,hitspr,1); return -1; } } else if (hitwall >= 0) { - l = spawn(k,SMALLSMOKE); - hittype[l].temp_data[6] = hitwall; - hittype[l].temp_data[7] = hitsect; - hittype[l].temp_data[8] = hitspr; + l = A_Spawn(k,SMALLSMOKE); + ActorExtra[l].temp_data[6] = hitwall; + ActorExtra[l].temp_data[7] = hitsect; + ActorExtra[l].temp_data[8] = hitspr; - if (isadoorwall(wall[hitwall].picnum) == 1) + if (CheckDoorTile(wall[hitwall].picnum) == 1) goto SKIPBULLETHOLE; if (p >= 0 && ( wall[hitwall].picnum == DIPSWITCH || @@ -1310,7 +1314,7 @@ DOSKIPBULLETHOLE: wall[hitwall].picnum == HANDSWITCH || wall[hitwall].picnum == HANDSWITCH+1)) { - checkhitswitch(p,hitwall,0); + P_ActivateSwitch(p,hitwall,0); return -1; } @@ -1334,15 +1338,15 @@ DOSKIPBULLETHOLE: } } - l = headspritestat[5]; + l = headspritestat[STAT_MISC]; while (l >= 0) { if (sprite[l].picnum == BULLETHOLE) - if (dist(&sprite[l],&sprite[k]) < (12+(TRAND&7))) + if (dist(&sprite[l],&sprite[k]) < (12+(krand()&7))) goto SKIPBULLETHOLE; l = nextspritestat[l]; } - l = spawn(k,BULLETHOLE); + l = A_Spawn(k,BULLETHOLE); sprite[l].xvel = -1; sprite[l].x = hitx; sprite[l].y = hity; @@ -1353,7 +1357,7 @@ DOSKIPBULLETHOLE: sprite[l].x -= mulscale13(1,sintable[(sprite[l].ang+2560)&2047]); sprite[l].y -= mulscale13(1,sintable[(sprite[l].ang+2048)&2047]); - ssp(l,CLIPMASK0); + A_SetSprite(l,CLIPMASK0); } SKIPBULLETHOLE: @@ -1363,36 +1367,36 @@ SKIPBULLETHOLE: if (hitz >= (sector[wall[hitwall].nextsector].floorz)) hitwall = wall[hitwall].nextwall; - checkhitwall(k,hitwall,hitx,hity,hitz,SHOTSPARK1); + A_DamageWall(k,hitwall,hitx,hity,hitz,SHOTSPARK1); } } else { - k = EGS(hitsect,hitx,hity,hitz,SHOTSPARK1,-15,24,24,sa,0,0,i,4); + k = A_InsertSprite(hitsect,hitx,hity,hitz,SHOTSPARK1,-15,24,24,sa,0,0,i,4); sprite[k].extra = *actorscrptr[atwith]; sprite[k].yvel = atwith; // this is a hack to allow you to detect which weapon spawned a SHOTSPARK1 - hittype[k].temp_data[6] = hitwall; - hittype[k].temp_data[7] = hitsect; - hittype[k].temp_data[8] = hitspr; + ActorExtra[k].temp_data[6] = hitwall; + ActorExtra[k].temp_data[7] = hitsect; + ActorExtra[k].temp_data[8] = hitspr; if (hitspr >= 0) { - checkhitsprite(hitspr,k); + A_DamageObject(hitspr,k); if (sprite[hitspr].picnum != APLAYER) { - l = spawn(k,SMALLSMOKE); - hittype[l].temp_data[6] = hitwall; - hittype[l].temp_data[7] = hitsect; - hittype[l].temp_data[8] = hitspr; + l = A_Spawn(k,SMALLSMOKE); + ActorExtra[l].temp_data[6] = hitwall; + ActorExtra[l].temp_data[7] = hitsect; + ActorExtra[l].temp_data[8] = hitspr; } else sprite[k].xrepeat = sprite[k].yrepeat = 0; } else if (hitwall >= 0) - checkhitwall(k,hitwall,hitx,hity,hitz,SHOTSPARK1); + A_DamageWall(k,hitwall,hitx,hity,hitz,SHOTSPARK1); } - if ((TRAND&255) < 4) - xyzsound(PISTOL_RICOCHET,k,hitx,hity,hitz); + if ((krand()&255) < 4) + S_PlaySoundXYZ(PISTOL_RICOCHET,k,hitx,hity,hitz); return -1; @@ -1421,13 +1425,13 @@ SKIPBULLETHOLE: if (p >= 0) { - // j = aim( s, AUTO_AIM_ANGLE ); - SetGameVarID(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); - OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); + // j = A_FindTargetSprite( s, AUTO_AIM_ANGLE ); + Gv_SetVar(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); + X_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); j=-1; - if (GetGameVarID(g_iAimAngleVarID,i,p) > 0) + if (Gv_GetVar(g_iAimAngleVarID,i,p) > 0) { - j = aim(s, GetGameVarID(g_iAimAngleVarID,i,p),atwith); + j = A_FindTargetSprite(s, Gv_GetVar(g_iAimAngleVarID,i,p),atwith); } if (j >= 0) @@ -1443,14 +1447,14 @@ SKIPBULLETHOLE: } else { - j = findplayer(s,&x); + j = A_FindPlayer(s,&x); // sa = getangle(g_player[j].ps->oposx-sx,g_player[j].ps->oposy-sy); - sa += 16-(TRAND&31); + sa += 16-(krand()&31); hitx = ldist(&sprite[g_player[j].ps->i],s); if (hitx == 0) hitx++; zvel = ((g_player[j].ps->oposz - sz + (3<<8))*vel) / hitx; } - if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9]; + if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; oldzvel = zvel; if (atwith == SPIT) @@ -1485,8 +1489,8 @@ SKIPBULLETHOLE: while (scount > 0) { - j = EGS(sect,sx,sy,sz,atwith,-127,sizx,sizy,sa,vel,zvel,i,4); - sprite[j].extra += (TRAND&7); + j = A_InsertSprite(sect,sx,sy,sz,atwith,-127,sizx,sizy,sa,vel,zvel,i,4); + sprite[j].extra += (krand()&7); if (atwith == COOLEXPLOSION1) { @@ -1495,17 +1499,17 @@ SKIPBULLETHOLE: { l = sprite[j].xvel; sprite[j].xvel = 1024; - ssp(j,CLIPMASK0); + A_SetSprite(j,CLIPMASK0); sprite[j].xvel = l; - sprite[j].ang += 128-(TRAND&255); + sprite[j].ang += 128-(krand()&255); } } sprite[j].cstat = 128; sprite[j].clipdist = 4; - sa = s->ang+32-(TRAND&63); - zvel = oldzvel+512-(TRAND&1023); + sa = s->ang+32-(krand()&63); + zvel = oldzvel+512-(krand()&1023); scount--; } @@ -1525,13 +1529,13 @@ SKIPBULLETHOLE: if (p >= 0) { - // j = aim( s, AUTO_AIM_ANGLE ); // 48 - SetGameVarID(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); - OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); + // j = A_FindTargetSprite( s, AUTO_AIM_ANGLE ); // 48 + Gv_SetVar(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); + X_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); j=-1; - if (GetGameVarID(g_iAimAngleVarID,i,p) > 0) + if (Gv_GetVar(g_iAimAngleVarID,i,p) > 0) { - j = aim(s, GetGameVarID(g_iAimAngleVarID,i,p),atwith); + j = A_FindTargetSprite(s, Gv_GetVar(g_iAimAngleVarID,i,p),atwith); } if (j >= 0) @@ -1545,11 +1549,11 @@ SKIPBULLETHOLE: } else zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)*81; if (atwith == RPG) - spritesound(RPG_SHOOT,i); + A_PlaySound(RPG_SHOOT,i); } else { - j = findplayer(s,&x); + j = A_FindPlayer(s,&x); sa = getangle(g_player[j].ps->oposx-sx,g_player[j].ps->oposy-sy); if (PN == BOSS3) sz -= (32<<8); @@ -1564,25 +1568,25 @@ SKIPBULLETHOLE: l++; zvel = ((g_player[j].ps->oposz-sz)*vel) / l; - if (badguy(s) && (s->hitag&face_player_smart)) - sa = s->ang+(TRAND&31)-16; + if (A_CheckEnemySprite(s) && (s->hitag&face_player_smart)) + sa = s->ang+(krand()&31)-16; } if (p >= 0 && j >= 0) l = j; else l = -1; - if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9]; - j = EGS(sect, - sx+(sintable[(348+sa+512)&2047]/448), - sy+(sintable[(sa+348)&2047]/448), - sz-(1<<8),atwith,0,14,14,sa,vel,zvel,i,4); + if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; + j = A_InsertSprite(sect, + sx+(sintable[(348+sa+512)&2047]/448), + sy+(sintable[(sa+348)&2047]/448), + sz-(1<<8),atwith,0,14,14,sa,vel,zvel,i,4); - sprite[j].extra += (TRAND&7); + sprite[j].extra += (krand()&7); if (atwith != FREEZEBLAST) sprite[j].yvel = l; else { - sprite[j].yvel = numfreezebounces; + sprite[j].yvel = g_numFreezeBounces; sprite[j].xrepeat >>= 1; sprite[j].yrepeat >>= 1; sprite[j].zvel -= (2<<4); @@ -1592,7 +1596,7 @@ SKIPBULLETHOLE: { if (PN == BOSS3) { - if (TRAND&1) + if (krand()&1) { sprite[j].x -= sintable[sa&2047]>>6; sprite[j].y -= sintable[(sa+1024+512)&2047]>>6; @@ -1611,7 +1615,7 @@ SKIPBULLETHOLE: { sprite[j].x -= sintable[sa&2047]/56; sprite[j].y -= sintable[(sa+1024+512)&2047]/56; - sprite[j].ang -= 8+(TRAND&255)-128; + sprite[j].ang -= 8+(krand()&255)-128; sprite[j].xrepeat = 24; sprite[j].yrepeat = 24; } @@ -1626,8 +1630,8 @@ SKIPBULLETHOLE: else if (*aplWeaponWorksLike[g_player[p].ps->curr_weapon] == DEVISTATOR_WEAPON) { sprite[j].extra >>= 2; - sprite[j].ang += 16-(TRAND&31); - sprite[j].zvel += 256-(TRAND&511); + sprite[j].ang += 16-(krand()&31); + sprite[j].zvel += 256-(krand()&511); if (g_player[p].ps->hbomb_hold_delay) { @@ -1656,7 +1660,7 @@ SKIPBULLETHOLE: if (p >= 0) zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)*32; else zvel = 0; - if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9]; + if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; hitscan(sx,sy,sz-g_player[p].ps->pyoff,sect, sintable[(sa+512)&2047], sintable[sa&2047], @@ -1679,26 +1683,26 @@ SKIPBULLETHOLE: if (j == 1) { - int lTripBombControl=GetGameVar("TRIPBOMB_CONTROL", TRIPBOMB_TRIPWIRE, g_player[p].ps->i, p); - k = EGS(hitsect,hitx,hity,hitz,TRIPBOMB,-16,4,5,sa,0,0,i,6); + int lTripBombControl=Gv_GetVarByLabel("TRIPBOMB_CONTROL", TRIPBOMB_TRIPWIRE, g_player[p].ps->i, p); + k = A_InsertSprite(hitsect,hitx,hity,hitz,TRIPBOMB,-16,4,5,sa,0,0,i,6); if (lTripBombControl & TRIPBOMB_TIMER) { - int lLifetime=GetGameVar("STICKYBOMB_LIFETIME", NAM_GRENADE_LIFETIME, g_player[p].ps->i, p); - int lLifetimeVar=GetGameVar("STICKYBOMB_LIFETIME_VAR", NAM_GRENADE_LIFETIME_VAR, g_player[p].ps->i, p); + int lLifetime=Gv_GetVarByLabel("STICKYBOMB_LIFETIME", NAM_GRENADE_LIFETIME, g_player[p].ps->i, p); + int lLifetimeVar=Gv_GetVarByLabel("STICKYBOMB_LIFETIME_VAR", NAM_GRENADE_LIFETIME_VAR, g_player[p].ps->i, p); // set timer. blows up when at zero.... - hittype[k].temp_data[7]=lLifetime - + mulscale(krand(),lLifetimeVar, 14) - - lLifetimeVar; - hittype[k].temp_data[6]=1; + ActorExtra[k].temp_data[7]=lLifetime + + mulscale(krand(),lLifetimeVar, 14) + - lLifetimeVar; + ActorExtra[k].temp_data[6]=1; } else sprite[k].hitag = k; - spritesound(LASERTRIP_ONWALL,k); + A_PlaySound(LASERTRIP_ONWALL,k); sprite[k].xvel = -20; - ssp(k,CLIPMASK0); + A_SetSprite(k,CLIPMASK0); sprite[k].cstat = 16; - hittype[k].temp_data[5] = sprite[k].ang = getangle(wall[hitwall].x-wall[wall[hitwall].point2].x,wall[hitwall].y-wall[wall[hitwall].point2].y)-512; + ActorExtra[k].temp_data[5] = sprite[k].ang = getangle(wall[hitwall].x-wall[wall[hitwall].point2].x,wall[hitwall].y-wall[wall[hitwall].point2].y)-512; } @@ -1709,7 +1713,7 @@ SKIPBULLETHOLE: if (s->extra >= 0) s->shade = -96; - j = g_player[findplayer(s,&x)].ps->i; + j = g_player[A_FindPlayer(s,&x)].ps->i; x = ldist(&sprite[j],s); zvel = -x>>1; @@ -1717,24 +1721,24 @@ SKIPBULLETHOLE: if (zvel < -4096) zvel = -2048; vel = x>>4; - if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9]; - EGS(sect, - sx+(sintable[(512+sa+512)&2047]>>8), - sy+(sintable[(sa+512)&2047]>>8), - sz+(6<<8),atwith,-64,32,32,sa,vel,zvel,i,1); + if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; + A_InsertSprite(sect, + sx+(sintable[(512+sa+512)&2047]>>8), + sy+(sintable[(sa+512)&2047]>>8), + sz+(6<<8),atwith,-64,32,32,sa,vel,zvel,i,1); break; case GROWSPARK__STATIC: if (p >= 0) { - // j = aim( s, AUTO_AIM_ANGLE ); - SetGameVarID(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); - OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); + // j = A_FindTargetSprite( s, AUTO_AIM_ANGLE ); + Gv_SetVar(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); + X_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); j=-1; - if (GetGameVarID(g_iAimAngleVarID,i,p) > 0) + if (Gv_GetVar(g_iAimAngleVarID,i,p) > 0) { - j = aim(s, GetGameVarID(g_iAimAngleVarID,i,p),atwith); + j = A_FindTargetSprite(s, Gv_GetVar(g_iAimAngleVarID,i,p),atwith); } if (j >= 0) @@ -1753,23 +1757,23 @@ SKIPBULLETHOLE: } else { - sa += 16-(TRAND&31); + sa += 16-(krand()&31); zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)<<5; - zvel += 128-(TRAND&255); + zvel += 128-(krand()&255); } sz -= (2<<8); } else { - j = findplayer(s,&x); + j = A_FindPlayer(s,&x); sz -= (4<<8); hitx = ldist(&sprite[g_player[j].ps->i], s); if (hitx == 0) hitx++; zvel = ((g_player[j].ps->posz-sz) <<8) / hitx; - zvel += 128-(TRAND&255); - sa += 32-(TRAND&63); + zvel += 128-(krand()&255); + sa += 32-(krand()&63); } k = 0; @@ -1778,7 +1782,7 @@ SKIPBULLETHOLE: if (sect < 0) break; s->cstat &= ~257; - if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9]; + if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; hitscan(sx,sy,sz,sect, sintable[(sa+512)&2047], sintable[sa&2047], @@ -1786,7 +1790,7 @@ SKIPBULLETHOLE: s->cstat |= 257; - j = EGS(sect,hitx,hity,hitz,GROWSPARK,-16,28,28,sa,0,0,i,1); + j = A_InsertSprite(sect,hitx,hity,hitz,GROWSPARK,-16,28,28,sa,0,0,i,1); sprite[j].pal = 2; sprite[j].cstat |= 130; @@ -1795,9 +1799,9 @@ SKIPBULLETHOLE: if (hitwall == -1 && hitspr == -1 && hitsect >= 0) { if (zvel < 0 && (sector[hitsect].ceilingstat&1) == 0) - checkhitceiling(hitsect); + Sect_DamageCeiling(hitsect); } - else if (hitspr >= 0) checkhitsprite(hitspr,j); + else if (hitspr >= 0) A_DamageObject(hitspr,j); else if (hitwall >= 0 && wall[hitwall].picnum != ACCESSSWITCH && wall[hitwall].picnum != ACCESSSWITCH2) { /* if(wall[hitwall].overpicnum == MIRROR && k == 0) @@ -1818,7 +1822,7 @@ SKIPBULLETHOLE: goto RESHOOTGROW; } else */ - checkhitwall(j,hitwall,hitx,hity,hitz,atwith); + A_DamageWall(j,hitwall,hitx,hity,hitz,atwith); } break; @@ -1827,13 +1831,13 @@ SKIPBULLETHOLE: if (s->extra >= 0) s->shade = -96; if (p >= 0) { - // j = aim( s, AUTO_AIM_ANGLE ); - SetGameVarID(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); - OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); + // j = A_FindTargetSprite( s, AUTO_AIM_ANGLE ); + Gv_SetVar(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); + X_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); j=-1; - if (GetGameVarID(g_iAimAngleVarID,i,p) > 0) + if (Gv_GetVar(g_iAimAngleVarID,i,p) > 0) { - j = aim(s, GetGameVarID(g_iAimAngleVarID,i,p),atwith); + j = A_FindTargetSprite(s, Gv_GetVar(g_iAimAngleVarID,i,p),atwith); } if (j >= 0) @@ -1849,18 +1853,18 @@ SKIPBULLETHOLE: } else if (s->statnum != 3) { - j = findplayer(s,&x); + j = A_FindPlayer(s,&x); l = ldist(&sprite[g_player[j].ps->i],s); if (l == 0) l++; zvel = ((g_player[j].ps->oposz-sz)*512) / l ; } else zvel = 0; - if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9]; - j = EGS(sect, - sx+(sintable[(512+sa+512)&2047]>>12), - sy+(sintable[(sa+512)&2047]>>12), - sz+(2<<8),SHRINKSPARK,-16,28,28,sa,768,zvel,i,4); + if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; + j = A_InsertSprite(sect, + sx+(sintable[(512+sa+512)&2047]>>12), + sy+(sintable[(sa+512)&2047]>>12), + sz+(2<<8),SHRINKSPARK,-16,28,28,sa,768,zvel,i,4); sprite[j].cstat = 128; sprite[j].clipdist = 32; @@ -1976,7 +1980,7 @@ static void myospalw(int x, int y, int tilenum, int shade, int orientation, int case HANDREMOTE_WEAPON: case HANDBOMB_WEAPON: case SHOTGUN_WEAPON: - rotatesprite(160<<16,(180+(g_player[screenpeek].ps->weapon_pos*g_player[screenpeek].ps->weapon_pos))<<16,scale(65536,ud.statusbarscale,100),0,g_currentweapon==GROW_WEAPON?GROWSPRITEICON:weapon_sprites[g_currentweapon],0,0,2,windowx1,windowy1,windowx2,windowy2); + rotatesprite(160<<16,(180+(g_player[screenpeek].ps->weapon_pos*g_player[screenpeek].ps->weapon_pos))<<16,scale(65536,ud.statusbarscale,100),0,g_currentweapon==GROW_WEAPON?GROWSPRITEICON:WeaponPickupSprites[g_currentweapon],0,0,2,windowx1,windowy1,windowx2,windowy2); break; } } @@ -2030,14 +2034,14 @@ static int animateknuckles(int gs,int snum) int lastvisinc; -void DoFire(player_struct *p) +void DoFire(DukePlayer_t *p) { int i, snum = sprite[p->i].yvel; - SetGameVarID(g_iReturnVarID,0,p->i,snum); - OnEvent(EVENT_DOFIRE, p->i, snum, -1); + Gv_SetVar(g_iReturnVarID,0,p->i,snum); + X_OnEvent(EVENT_DOFIRE, p->i, snum, -1); - if (GetGameVarID(g_iReturnVarID,p->i,snum) == 0) + if (Gv_GetVar(g_iReturnVarID,p->i,snum) == 0) { if (p->weapon_pos != 0) return; @@ -2046,38 +2050,38 @@ void DoFire(player_struct *p) if (aplWeaponFireSound[p->curr_weapon][snum]) { - spritesound(aplWeaponFireSound[p->curr_weapon][snum],p->i); + A_PlaySound(aplWeaponFireSound[p->curr_weapon][snum],p->i); } - SetGameVarID(g_iWeaponVarID,p->curr_weapon,p->i,snum); - SetGameVarID(g_iWorksLikeVarID,aplWeaponWorksLike[p->curr_weapon][snum], p->i, snum); - shoot(p->i,aplWeaponShoots[p->curr_weapon][snum]); + Gv_SetVar(g_iWeaponVarID,p->curr_weapon,p->i,snum); + Gv_SetVar(g_iWorksLikeVarID,aplWeaponWorksLike[p->curr_weapon][snum], p->i, snum); + A_Shoot(p->i,aplWeaponShoots[p->curr_weapon][snum]); for (i=1;icurr_weapon][snum];i++) { - if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_FIREEVERYOTHER) + if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FIREEVERYOTHER) { // this makes the projectiles fire on a delay from player code - hittype[p->i].temp_data[7] = (aplWeaponShotsPerBurst[p->curr_weapon][snum])<<1; + ActorExtra[p->i].temp_data[7] = (aplWeaponShotsPerBurst[p->curr_weapon][snum])<<1; } else { - if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_AMMOPERSHOT) + if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_AMMOPERSHOT) { if (p->ammo_amount[p->curr_weapon] > 0) p->ammo_amount[p->curr_weapon]--; else break; } - shoot(p->i,aplWeaponShoots[p->curr_weapon][snum]); + A_Shoot(p->i,aplWeaponShoots[p->curr_weapon][snum]); } } - if (!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_NOVISIBLE)) + if (!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_NOVISIBLE)) { lastvisinc = totalclock+32; p->visibility = 0; } - /* if( //!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_CHECKATRELOAD) && + /* if( //!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_CHECKATRELOAD) && aplWeaponReload[p->curr_weapon][snum] > aplWeaponTotalTime[p->curr_weapon][snum] && p->ammo_amount[p->curr_weapon] > 0 && (aplWeaponClip[p->curr_weapon][snum]) @@ -2088,16 +2092,16 @@ void DoFire(player_struct *p) } } -void DoSpawn(player_struct *p) +void DoSpawn(DukePlayer_t *p) { int j, snum = sprite[p->i].yvel; if (!aplWeaponSpawn[p->curr_weapon][snum]) return; - j = spawn(p->i, aplWeaponSpawn[p->curr_weapon][snum]); + j = A_Spawn(p->i, aplWeaponSpawn[p->curr_weapon][snum]); - if ((aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_SPAWNTYPE3)) + if ((aplWeaponFlags[p->curr_weapon][snum] & WEAPON_SPAWNTYPE3)) { // like chaingun shells sprite[j].ang += 1024; @@ -2106,11 +2110,11 @@ void DoSpawn(player_struct *p) sprite[j].z += (3<<8); } - ssp(j,CLIPMASK0); + A_SetSprite(j,CLIPMASK0); } -void displaymasks(int snum) +void P_DisplayScubaMask(int snum) { int p; @@ -2127,7 +2131,7 @@ void displaymasks(int snum) } } -static int animatetip(int gs,int snum) +static int DisplayTipAnimation(int gs,int snum) { int p,looking_arc; static short tip_y[] = {0,-8,-16,-32,-64,-84,-108,-108,-108,-108,-108,-108,-108,-108,-108,-108,-96,-72,-64,-32,-16}; @@ -2153,7 +2157,7 @@ static int animatetip(int gs,int snum) return 1; } -static int animateaccess(int gs,int snum) +static int DisplayAccessAnimation(int gs,int snum) { static short access_y[] = {0,-8,-16,-32,-64,-84,-108,-108,-108,-108,-108,-108,-108,-108,-108,-108,-96,-72,-64,-32,-16}; int looking_arc; @@ -2181,12 +2185,12 @@ static int animateaccess(int gs,int snum) static int fistsign; -void displayweapon(int snum) +void P_DisplayWeapons(int snum) { int gun_pos, looking_arc, cw; int weapon_xoffset, i, j; int o = 0,pal = 0; - player_struct *p = g_player[snum].ps; + DukePlayer_t *p = g_player[snum].ps; short *kb = &p->kickback_pic; int gs; @@ -2195,7 +2199,7 @@ void displayweapon(int snum) gs = sprite[p->i].shade; if (gs > 24) gs = 24; - if (p->newowner >= 0 || ud.camerasprite >= 0 || p->over_shoulder_on > 0 || (sprite[p->i].pal != 1 && sprite[p->i].extra <= 0) || animatefist(gs,snum) || animateknuckles(gs,snum) || animatetip(gs,snum) || animateaccess(gs,snum)) + if (p->newowner >= 0 || ud.camerasprite >= 0 || p->over_shoulder_on > 0 || (sprite[p->i].pal != 1 && sprite[p->i].extra <= 0) || animatefist(gs,snum) || animateknuckles(gs,snum) || DisplayTipAnimation(gs,snum) || DisplayAccessAnimation(gs,snum)) return; animateknee(gs,snum); @@ -2230,10 +2234,10 @@ void displayweapon(int snum) g_kb=*kb; g_looking_angSR1=p->look_ang>>1; - SetGameVarID(g_iReturnVarID,0,p->i,snum); - OnEvent(EVENT_DISPLAYWEAPON, p->i, screenpeek, -1); + Gv_SetVar(g_iReturnVarID,0,p->i,snum); + X_OnEvent(EVENT_DISPLAYWEAPON, p->i, screenpeek, -1); - if (GetGameVarID(g_iReturnVarID,p->i,snum) == 0) + if (Gv_GetVar(g_iReturnVarID,p->i,snum) == 0) { j = 14-p->quick_kick; if (j != 14 || p->last_quick_kick) @@ -2266,12 +2270,12 @@ void displayweapon(int snum) } cw = weapon_xoffset; weapon_xoffset += sintable[(fistsign)&2047]>>10; - myos(weapon_xoffset+250-(p->look_ang>>1), + G_DrawTile(weapon_xoffset+250-(p->look_ang>>1), looking_arc+258-(klabs(sintable[(fistsign)&2047]>>8)), FIST,gs,o); weapon_xoffset = cw; weapon_xoffset -= sintable[(fistsign)&2047]>>10; - myos(weapon_xoffset+40-(p->look_ang>>1), + G_DrawTile(weapon_xoffset+40-(p->look_ang>>1), looking_arc+200+(klabs(sintable[(fistsign)&2047]>>8)), FIST,gs,o|4); } @@ -2281,9 +2285,9 @@ void displayweapon(int snum) case KNEE_WEAPON: - SetGameVarID(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); - OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - if (GetGameVarID(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) + Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); + X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) { if ((*kb) > 0) { @@ -2309,9 +2313,9 @@ void displayweapon(int snum) case TRIPBOMB_WEAPON: - SetGameVarID(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); - OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - if (GetGameVarID(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) + Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); + X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) { if (sprite[p->i].pal == 1) pal = 1; @@ -2339,9 +2343,9 @@ void displayweapon(int snum) case RPG_WEAPON: - SetGameVarID(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); - OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - if (GetGameVarID(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) + Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); + X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) { if (sprite[p->i].pal == 1) pal = 1; @@ -2368,9 +2372,9 @@ void displayweapon(int snum) case SHOTGUN_WEAPON: - SetGameVarID(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); - OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - if (GetGameVarID(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) + Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); + X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) { if (sprite[p->i].pal == 1) pal = 1; @@ -2454,9 +2458,9 @@ void displayweapon(int snum) case CHAINGUN_WEAPON: - SetGameVarID(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); - OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - if (GetGameVarID(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) + Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); + X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) { if (sprite[p->i].pal == 1) pal = 1; @@ -2505,9 +2509,9 @@ void displayweapon(int snum) case PISTOL_WEAPON: - SetGameVarID(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); - OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - if (GetGameVarID(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) + Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); + X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) { if (sprite[p->i].pal == 1) pal = 1; @@ -2560,9 +2564,9 @@ void displayweapon(int snum) break; case HANDBOMB_WEAPON: { - SetGameVarID(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); - OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - if (GetGameVarID(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) + Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); + X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) { if (sprite[p->i].pal == 1) pal = 1; @@ -2596,9 +2600,9 @@ void displayweapon(int snum) case HANDREMOTE_WEAPON: { - SetGameVarID(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); - OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - if (GetGameVarID(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) + Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); + X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) { static char remote_frames[] = {0,1,1,2,1,1,0,0,0,0,0}; if (sprite[p->i].pal == 1) @@ -2618,9 +2622,9 @@ void displayweapon(int snum) case DEVISTATOR_WEAPON: - SetGameVarID(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); - OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - if (GetGameVarID(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) + Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); + X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) { if (sprite[p->i].pal == 1) pal = 1; @@ -2655,9 +2659,9 @@ void displayweapon(int snum) case FREEZE_WEAPON: - SetGameVarID(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); - OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - if (GetGameVarID(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) + Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); + X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) { if (sprite[p->i].pal == 1) pal = 1; @@ -2684,9 +2688,9 @@ void displayweapon(int snum) case GROW_WEAPON: - SetGameVarID(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); - OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - if (GetGameVarID(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) + Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); + X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) { weapon_xoffset += 28; looking_arc += 18; @@ -2727,9 +2731,9 @@ void displayweapon(int snum) case SHRINKER_WEAPON: - SetGameVarID(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); - OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - if (GetGameVarID(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) + Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); + X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) { weapon_xoffset += 28; looking_arc += 18; @@ -2782,7 +2786,7 @@ void displayweapon(int snum) #define MAXANGVEL 127 #define MAXHORIZ 127 -int myaimmode = 0, myaimstat = 0, omyaimstat = 0; +int g_myAimMode = 0, g_myAimStat = 0, g_oldAimStat = 0; int32 mouseyaxismode = -1; int jump_input = 0; @@ -2795,9 +2799,10 @@ void getinput(int snum) int32 turnamount; int32 keymove; int32 momx = 0,momy = 0; - player_struct *p = g_player[snum].ps; + DukePlayer_t *p = g_player[snum].ps; - if ((p->gm&MODE_MENU) || (p->gm&MODE_TYPE) || (ud.pause_on && !KB_KeyPressed(sc_Pause)) || (numplayers > 1 && totalclock < 10)) // HACK: kill getinput() for the first 10 tics of a new map in multi + if ((p->gm&MODE_MENU) || (p->gm&MODE_TYPE) || (ud.pause_on && !KB_KeyPressed(sc_Pause)) || (numplayers > 1 && totalclock < 10)) + // HACK: kill getinput() for the first 10 tics of a new map in multi { if (!(p->gm&MODE_MENU)) CONTROL_GetInput(&info[0]); @@ -2806,28 +2811,28 @@ void getinput(int snum) loc.svel = svel = 0; loc.avel = angvel = 0; loc.horz = horiz = 0; - loc.bits = (((int)gamequit)<<26); + loc.bits = (((int)g_gameQuit)<team)<<6; loc.extbits |= (1<<7); return; } if (ud.mouseaiming) - myaimmode = BUTTON(gamefunc_Mouse_Aiming); + g_myAimMode = BUTTON(gamefunc_Mouse_Aiming); else { - omyaimstat = myaimstat; - myaimstat = BUTTON(gamefunc_Mouse_Aiming); - if (myaimstat > omyaimstat) + g_oldAimStat = g_myAimStat; + g_myAimStat = BUTTON(gamefunc_Mouse_Aiming); + if (g_myAimStat > g_oldAimStat) { - myaimmode ^= 1; - FTA(44+myaimmode,p); + g_myAimMode ^= 1; + P_DoQuote(44+g_myAimMode,p); } } { int32 i; - if (myaimmode) i = analog_lookingupanddown; + if (g_myAimMode) i = analog_lookingupanddown; else i = ud.config.MouseAnalogueAxes[1]; if (i != mouseyaxismode) @@ -2879,9 +2884,9 @@ void getinput(int snum) if (multiflag == 1) { - loc.bits = 1<<17; - loc.bits |= multiwhat<<18; - loc.bits |= multipos<<19; + loc.bits = 1<on_ground) jump_input = 4; - loc.bits = (jump_input > 0 || BUTTON(gamefunc_Jump)); //BUTTON(gamefunc_Jump); - loc.bits |= BUTTON(gamefunc_Crouch)<<1; - loc.bits |= BUTTON(gamefunc_Fire)<<2; - loc.bits |= BUTTON(gamefunc_Aim_Up)<<3; - loc.bits |= BUTTON(gamefunc_Aim_Down)<<4; - if (ud.runkey_mode) loc.bits |= (ud.auto_run | BUTTON(gamefunc_Run))<<5; - else loc.bits |= (BUTTON(gamefunc_Run) ^ ud.auto_run)<<5; - loc.bits |= BUTTON(gamefunc_Look_Left)<<6; - loc.bits |= BUTTON(gamefunc_Look_Right)<<7; + loc.bits = (jump_input > 0 || BUTTON(gamefunc_Jump))<curr_weapon][snum] & WEAPON_FLAG_SEMIAUTO && BUTTON(gamefunc_Fire)) + if (aplWeaponFlags[g_player[snum].ps->curr_weapon][snum] & WEAPON_SEMIAUTO && BUTTON(gamefunc_Fire)) CONTROL_ClearButton(gamefunc_Fire); if (jump_input > 0) @@ -2932,26 +2937,26 @@ void getinput(int snum) if (BUTTON(gamefunc_Next_Weapon)) j = 12; - loc.bits |= j<<8; - loc.bits |= BUTTON(gamefunc_Steroids)<<12; - loc.bits |= BUTTON(gamefunc_Look_Up)<<13; - loc.bits |= BUTTON(gamefunc_Look_Down)<<14; - loc.bits |= BUTTON(gamefunc_NightVision)<<15; - loc.bits |= BUTTON(gamefunc_MedKit)<<16; - loc.bits |= BUTTON(gamefunc_Center_View)<<18; - loc.bits |= BUTTON(gamefunc_Holster_Weapon)<<19; - loc.bits |= BUTTON(gamefunc_Inventory_Left)<<20; - loc.bits |= KB_KeyPressed(sc_Pause)<<21; - loc.bits |= BUTTON(gamefunc_Quick_Kick)<<22; - loc.bits |= myaimmode<<23; - loc.bits |= BUTTON(gamefunc_Holo_Duke)<<24; - loc.bits |= BUTTON(gamefunc_Jetpack)<<25; - loc.bits |= (((int)gamequit)<<26); - loc.bits |= BUTTON(gamefunc_Inventory_Right)<<27; - loc.bits |= BUTTON(gamefunc_TurnAround)<<28; - loc.bits |= BUTTON(gamefunc_Open)<<29; - loc.bits |= BUTTON(gamefunc_Inventory)<<30; - loc.bits |= KB_KeyPressed(sc_Escape)<<31; + loc.bits |= j<i].yvel; @@ -3106,9 +3111,9 @@ static int doincrements(player_struct *p) if (p->last_pissed_time == (26*219)) { - spritesound(FLUSH_TOILET,p->i); - if (snum == screenpeek || GTFLAGS(GAMETYPE_FLAG_COOPSOUND)) - spritesound(DUKE_PISSRELIEF,p->i); + A_PlaySound(FLUSH_TOILET,p->i); + if (snum == screenpeek || GTFLAGS(GAMETYPE_COOPSOUND)) + A_PlaySound(DUKE_PISSRELIEF,p->i); } if (p->last_pissed_time == (26*218)) @@ -3132,10 +3137,10 @@ static int doincrements(player_struct *p) { p->steroids_amount--; if (p->steroids_amount == 0) - checkavailinven(p); + P_SelectNextInventoryItem(p); if (!(p->steroids_amount&7)) - if (snum == screenpeek || GTFLAGS(GAMETYPE_FLAG_COOPSOUND)) - spritesound(DUKE_HARTBEAT,p->i); + if (snum == screenpeek || GTFLAGS(GAMETYPE_COOPSOUND)) + A_PlaySound(DUKE_HARTBEAT,p->i); } if (p->heat_on && p->heat_amount > 0) @@ -3144,9 +3149,9 @@ static int doincrements(player_struct *p) if (p->heat_amount == 0) { p->heat_on = 0; - checkavailinven(p); - spritesound(NITEVISION_ONOFF,p->i); - setpal(p); + P_SelectNextInventoryItem(p); + A_PlaySound(NITEVISION_ONOFF,p->i); + P_UpdateScreenPal(p); } } @@ -3155,9 +3160,9 @@ static int doincrements(player_struct *p) p->holoduke_amount--; if (p->holoduke_amount <= 0) { - spritesound(TELEPORTER,p->i); + A_PlaySound(TELEPORTER,p->i); p->holoduke_on = -1; - checkavailinven(p); + P_SelectNextInventoryItem(p); } } @@ -3167,10 +3172,10 @@ static int doincrements(player_struct *p) if (p->jetpack_amount <= 0) { p->jetpack_on = 0; - checkavailinven(p); - spritesound(DUKE_JETPACK_OFF,p->i); - stopspritesound(DUKE_JETPACK_IDLE,p->i); - stopspritesound(DUKE_JETPACK_ON,p->i); + P_SelectNextInventoryItem(p); + A_PlaySound(DUKE_JETPACK_OFF,p->i); + A_StopSound(DUKE_JETPACK_IDLE,p->i); + A_StopSound(DUKE_JETPACK_ON,p->i); } } @@ -3179,7 +3184,7 @@ static int doincrements(player_struct *p) p->last_quick_kick = p->quick_kick+1; p->quick_kick--; if (p->quick_kick == 8) - shoot(p->i,KNEE); + A_Shoot(p->i,KNEE); } else if (p->last_quick_kick > 0) p->last_quick_kick--; @@ -3192,7 +3197,7 @@ static int doincrements(player_struct *p) { if (p->access_spritenum >= 0) { - checkhitswitch(snum,p->access_spritenum,1); + P_ActivateSwitch(snum,p->access_spritenum,1); switch (sprite[p->access_spritenum].pal) { case 0: @@ -3209,7 +3214,7 @@ static int doincrements(player_struct *p) } else { - checkhitswitch(snum,p->access_wallnum,0); + P_ActivateSwitch(snum,p->access_wallnum,0); switch (wall[p->access_wallnum].pal) { case 0: @@ -3239,7 +3244,7 @@ static int doincrements(player_struct *p) { p->scuba_on = 1; p->inven_icon = 6; - FTA(76,p); + P_DoQuote(76,p); } else { @@ -3249,7 +3254,7 @@ static int doincrements(player_struct *p) { p->extra_extra8 += 32; if (p->last_extra < (p->max_player_health>>1) && (p->last_extra&3) == 0) - spritesound(DUKE_LONGTERM_PAIN,p->i); + A_PlaySound(DUKE_LONGTERM_PAIN,p->i); } } } @@ -3259,7 +3264,7 @@ static int doincrements(player_struct *p) if (p->scuba_amount == 0) { p->scuba_on = 0; - checkavailinven(p); + P_SelectNextInventoryItem(p); } } @@ -3269,19 +3274,19 @@ static int doincrements(player_struct *p) if (p->knuckle_incs==10) { if (totalclock > 1024) - if (snum == screenpeek || GTFLAGS(GAMETYPE_FLAG_COOPSOUND)) + if (snum == screenpeek || GTFLAGS(GAMETYPE_COOPSOUND)) { if (rand()&1) - spritesound(DUKE_CRACK,p->i); - else spritesound(DUKE_CRACK2,p->i); + A_PlaySound(DUKE_CRACK,p->i); + else A_PlaySound(DUKE_CRACK2,p->i); } - spritesound(DUKE_CRACK_FIRST,p->i); + A_PlaySound(DUKE_CRACK_FIRST,p->i); } - else if (p->knuckle_incs == 22 || (g_player[snum].sync->bits&(1<<2))) + else if (p->knuckle_incs == 22 || TEST_SYNC_KEY(g_player[snum].sync->bits, SK_FIRE)) p->knuckle_incs=0; return 1; @@ -3289,12 +3294,12 @@ static int doincrements(player_struct *p) return 0; } -short weapon_sprites[MAX_WEAPONS] = { KNEE__STATIC, FIRSTGUNSPRITE__STATIC, SHOTGUNSPRITE__STATIC, - CHAINGUNSPRITE__STATIC, RPGSPRITE__STATIC, HEAVYHBOMB__STATIC, SHRINKERSPRITE__STATIC, DEVISTATORSPRITE__STATIC, - TRIPBOMBSPRITE__STATIC, FREEZESPRITE__STATIC, HEAVYHBOMB__STATIC, SHRINKERSPRITE__STATIC - }; +short WeaponPickupSprites[MAX_WEAPONS] = { KNEE__STATIC, FIRSTGUNSPRITE__STATIC, SHOTGUNSPRITE__STATIC, + CHAINGUNSPRITE__STATIC, RPGSPRITE__STATIC, HEAVYHBOMB__STATIC, SHRINKERSPRITE__STATIC, DEVISTATORSPRITE__STATIC, + TRIPBOMBSPRITE__STATIC, FREEZESPRITE__STATIC, HEAVYHBOMB__STATIC, SHRINKERSPRITE__STATIC + }; -void checkweapons(player_struct *p) +void P_DropWeapon(DukePlayer_t *p) { int snum = sprite[p->i].yvel, cw = aplWeaponWorksLike[p->curr_weapon][snum]; @@ -3302,26 +3307,26 @@ void checkweapons(player_struct *p) if (cw) { - if (TRAND&1) - spawn(p->i,weapon_sprites[cw]); + if (krand()&1) + A_Spawn(p->i,WeaponPickupSprites[cw]); else switch (cw) { case RPG_WEAPON: case HANDBOMB_WEAPON: - spawn(p->i,EXPLOSION2); + A_Spawn(p->i,EXPLOSION2); break; } } } -int g_NumObituaries = 0; -int g_NumSelfObituaries = 0; +int g_numObituaries = 0; +int g_numSelfObituaries = 0; -void processinput(int snum) +void P_ProcessInput(int snum) { int j, i, k, doubvel, fz, cz, hz, lz, truefdist, x, y, shrunk; unsigned int sb_snum = g_player[snum].sync->bits; - player_struct *p = g_player[snum].ps; + DukePlayer_t *p = g_player[snum].ps; int pi = p->i; spritetype *s = &sprite[pi]; int psect = p->cursectnum, psectlotag; @@ -3330,24 +3335,25 @@ void processinput(int snum) p->player_par++; - OnEvent(EVENT_PROCESSINPUT, pi, snum, -1); + X_OnEvent(EVENT_PROCESSINPUT, pi, snum, -1); if (p->cheat_phase > 0) sb_snum = 0; - if ((sb_snum&(1<<2))) + if (TEST_SYNC_KEY(sb_snum, SK_FIRE)) +// if ((sb_snum&(1<<2))) { - SetGameVarID(g_iReturnVarID,0,pi,snum); - OnEvent(EVENT_PRESSEDFIRE, pi, snum, -1); - if (GetGameVarID(g_iReturnVarID,pi,snum) != 0) - sb_snum &= ~(1<<2); + Gv_SetVar(g_iReturnVarID,0,pi,snum); + X_OnEvent(EVENT_PRESSEDFIRE, pi, snum, -1); + if (Gv_GetVar(g_iReturnVarID,pi,snum) != 0) + sb_snum &= ~BIT(SK_FIRE); } if (psect == -1) { if (s->extra > 0 && ud.clipping == 0) { - quickkill(p); - spritesound(SQUISHED,pi); + P_QuickKill(p); + A_PlaySound(SQUISHED,pi); } psect = 0; } @@ -3368,8 +3374,8 @@ void processinput(int snum) if ((lz&49152) == 16384 && psectlotag == 1 && truefdist > PHEIGHT+(16<<8)) psectlotag = 0; - hittype[pi].floorz = fz; - hittype[pi].ceilingz = cz; + ActorExtra[pi].floorz = fz; + ActorExtra[pi].ceilingz = cz; p->ohoriz = p->horiz; p->ohorizoff = p->horizoff; @@ -3415,7 +3421,7 @@ void processinput(int snum) p->spritebridge = 1; p->sbs = j; } - else if (badguy(&sprite[j]) && sprite[j].xrepeat > 24 && klabs(s->z-sprite[j].z) < (84<<8)) + else if (A_CheckEnemySprite(&sprite[j]) && sprite[j].xrepeat > 24 && klabs(s->z-sprite[j].z) < (84<<8)) { j = getangle(sprite[j].x-p->posx,sprite[j].y-p->posy); p->posxv -= sintable[(j+512)&2047]<<4; @@ -3424,7 +3430,7 @@ void processinput(int snum) } - if (s->extra > 0) incur_damage(p); + if (s->extra > 0) P_IncurDamage(p); else { s->extra = 0; @@ -3442,8 +3448,8 @@ void processinput(int snum) p->fist_incs++; if (p->fist_incs == 28) { - if (ud.recstat == 1) closedemowrite(); - sound(PIPEBOMB_EXPLODE); + if (ud.recstat == 1) G_CloseDemoWrite(); + S_PlaySound(PIPEBOMB_EXPLODE); p->pals[0] = 64; p->pals[1] = 64; p->pals[2] = 64; @@ -3476,8 +3482,8 @@ void processinput(int snum) ud.m_level_number = ud.level_number; } } - for (i=connecthead;i>=0;i=connectpoint2[i]) - g_player[i].ps->gm = MODE_EOL; + TRAVERSE_CONNECT(i) + g_player[i].ps->gm = MODE_EOL; p->fist_incs = 0; return; @@ -3490,17 +3496,17 @@ void processinput(int snum) if (p->timebeforeexit == 26*5) { FX_StopAllSounds(); - clearsoundlocks(); + S_ClearSoundLocks(); if (p->customexitsound >= 0) { - sound(p->customexitsound); - FTA(102,p); + S_PlaySound(p->customexitsound); + P_DoQuote(102,p); } } else if (p->timebeforeexit == 1) { - for (i=connecthead;i>=0;i=connectpoint2[i]) - g_player[i].ps->gm = MODE_EOL; + TRAVERSE_CONNECT(i) + g_player[i].ps->gm = MODE_EOL; if (ud.from_bonus) { ud.level_number = ud.from_bonus; @@ -3525,12 +3531,12 @@ void processinput(int snum) if(g_player[snum].sync->fvel > 127) { p->select_dir = 0; - activatewarpelevators(pi,-1); + G_ActivateWarpElevators(pi,-1); } else if(g_player[snum].sync->fvel <= -127) { p->select_dir = 0; - activatewarpelevators(pi,1); + G_ActivateWarpElevators(pi,1); } return; } @@ -3551,8 +3557,8 @@ void processinput(int snum) } } - if (leveltexttime > 0) - leveltexttime--; + if (g_levelTextTime > 0) + g_levelTextTime--; if (s->extra <= 0) { @@ -3569,11 +3575,11 @@ void processinput(int snum) } if (ud.recstat == 1 && ud.multimode < 2) - closedemowrite(); + G_CloseDemoWrite(); if (s->pal != 1) { - p->dead_flag = (512-((TRAND&1)<<10)+(TRAND&255)-512)&2047; + p->dead_flag = (512-((krand()&1)<<10)+(krand()&255)-512)&2047; if (p->dead_flag == 0) p->dead_flag++; } @@ -3581,11 +3587,11 @@ void processinput(int snum) p->jetpack_on = 0; p->holoduke_on = -1; - stopspritesound(DUKE_JETPACK_IDLE,p->i); + A_StopSound(DUKE_JETPACK_IDLE,p->i); if (p->scream_voice > FX_Ok) { FX_StopSound(p->scream_voice); - testcallback(DUKE_SCREAM); + S_TestSoundCallback(DUKE_SCREAM); p->scream_voice = FX_Ok; } @@ -3595,7 +3601,7 @@ void processinput(int snum) { if (p->frag_ps != snum) { - if (GTFLAGS(GAMETYPE_FLAG_TDM) && g_player[p->frag_ps].ps->team == g_player[snum].ps->team) + if (GTFLAGS(GAMETYPE_TDM) && g_player[p->frag_ps].ps->team == g_player[snum].ps->team) g_player[p->frag_ps].ps->fraggedself++; else { @@ -3605,26 +3611,26 @@ void processinput(int snum) if (snum == screenpeek) { - Bsprintf(fta_quotes[115],"KILLED BY %s",&g_player[p->frag_ps].user_name[0]); - FTA(115,p); + Bsprintf(ScriptQuotes[115],"KILLED BY %s",&g_player[p->frag_ps].user_name[0]); + P_DoQuote(115,p); } else { - Bsprintf(fta_quotes[116],"KILLED %s",&g_player[snum].user_name[0]); - FTA(116,g_player[p->frag_ps].ps); + Bsprintf(ScriptQuotes[116],"KILLED %s",&g_player[snum].user_name[0]); + P_DoQuote(116,g_player[p->frag_ps].ps); } if (ud.obituaries) { /* - if (GTFLAGS(GAMETYPE_FLAG_PLAYERSFRIENDLY) || (GTFLAGS(GAMETYPE_FLAG_TDM) && g_player[snum].ps->team == g_player[p->frag_ps].ps->team)) + if (GTFLAGS(GAMETYPE_PLAYERSFRIENDLY) || (GTFLAGS(GAMETYPE_TDM) && g_player[snum].ps->team == g_player[p->frag_ps].ps->team)) i = 9; else { // temp_data[1] on a player's APLAYER actor means the player is frozen - if (hittype[p->i].temp_data[1] == 1) + if (ActorExtra[p->i].temp_data[1] == 1) i = 7; - else switch (dynamictostatic[hittype[p->i].picnum]) + else switch (DynamicTileMap[ActorExtra[p->i].picnum]) { case KNEE__STATIC: i = 0; @@ -3662,37 +3668,33 @@ void processinput(int snum) } } */ - Bsprintf(tempbuf,fta_quotes[PPDEATHSTRINGS+(krand()%g_NumObituaries)], + Bsprintf(tempbuf,ScriptQuotes[FIRST_OBITUARY_QUOTE+(krand()%g_numObituaries)], &g_player[p->frag_ps].user_name[0], &g_player[snum].user_name[0]); - if (ud.config.ScreenWidth >= 800) - adduserquote(tempbuf); - else OSD_Printf("%s\n",tempbuf); + G_AddUserQuote(tempbuf); } else krand(); } else { - if (hittype[p->i].picnum != APLAYERTOP) + if (ActorExtra[p->i].picnum != APLAYERTOP) { p->fraggedself++; - if (badguypic(sprite[p->wackedbyactor].picnum)) - Bsprintf(tempbuf,fta_quotes[PPDEATHSTRINGS+(krand()%g_NumObituaries)],"A monster",&g_player[snum].user_name[0]); - else if (hittype[p->i].picnum == NUKEBUTTON) + if (A_CheckEnemyTile(sprite[p->wackedbyactor].picnum)) + Bsprintf(tempbuf,ScriptQuotes[FIRST_OBITUARY_QUOTE+(krand()%g_numObituaries)],"A monster",&g_player[snum].user_name[0]); + else if (ActorExtra[p->i].picnum == NUKEBUTTON) Bsprintf(tempbuf,"^02%s^02 tried to leave",&g_player[snum].user_name[0]); else { // random suicide death string - Bsprintf(tempbuf,fta_quotes[PSDEATHSTRINGS+(krand()%g_NumSelfObituaries)],&g_player[snum].user_name[0]); + Bsprintf(tempbuf,ScriptQuotes[FIRST_SUICIDE_QUOTE+(krand()%g_numSelfObituaries)],&g_player[snum].user_name[0]); } } else Bsprintf(tempbuf,"^02%s^02 switched to team %d",&g_player[snum].user_name[0],p->team+1); if (ud.obituaries) { - if (ud.config.ScreenWidth >= 800) - adduserquote(tempbuf); - else OSD_Printf("%s\n",tempbuf); + G_AddUserQuote(tempbuf); } } @@ -3768,7 +3770,7 @@ void processinput(int snum) p->look_ang = 0; p->rotscrnang = 0; - doincrements(p); + P_DoCounters(p); if (*aplWeaponWorksLike[p->curr_weapon] == HANDREMOTE_WEAPON) goto SHOOTINCODE; @@ -3783,24 +3785,24 @@ void processinput(int snum) p->look_ang -= (p->look_ang>>2); - if (sb_snum&(1<<6)) + if (TEST_SYNC_KEY(sb_snum, SK_LOOK_LEFT)) { // look_left - SetGameVarID(g_iReturnVarID,0,pi,snum); - OnEvent(EVENT_LOOKLEFT,pi,snum, -1); - if (GetGameVarID(g_iReturnVarID,pi,snum) == 0) + Gv_SetVar(g_iReturnVarID,0,pi,snum); + X_OnEvent(EVENT_LOOKLEFT,pi,snum, -1); + if (Gv_GetVar(g_iReturnVarID,pi,snum) == 0) { p->look_ang -= 152; p->rotscrnang += 24; } } - if (sb_snum&(1<<7)) + if (TEST_SYNC_KEY(sb_snum, SK_LOOK_RIGHT)) { // look_right - SetGameVarID(g_iReturnVarID,0,pi,snum); - OnEvent(EVENT_LOOKRIGHT,pi,snum, -1); - if (GetGameVarID(g_iReturnVarID,pi,snum) == 0) + Gv_SetVar(g_iReturnVarID,0,pi,snum); + X_OnEvent(EVENT_LOOKRIGHT,pi,snum, -1); + if (Gv_GetVar(g_iReturnVarID,pi,snum) == 0) { p->look_ang += 152; p->rotscrnang -= 24; @@ -3872,14 +3874,14 @@ void processinput(int snum) p->pycount &= 2047; p->pyoff = sintable[p->pycount]>>7; - if (!isspritemakingsound(pi,DUKE_UNDERWATER)) - spritesound(DUKE_UNDERWATER,pi); + if (!A_CheckSoundPlaying(pi,DUKE_UNDERWATER)) + A_PlaySound(DUKE_UNDERWATER,pi); - if (sb_snum&1) + if (TEST_SYNC_KEY(sb_snum, SK_JUMP)) { - SetGameVarID(g_iReturnVarID,0,pi,snum); - OnEvent(EVENT_SWIMUP,pi,snum, -1); - if (GetGameVarID(g_iReturnVarID,pi,snum) == 0) + Gv_SetVar(g_iReturnVarID,0,pi,snum); + X_OnEvent(EVENT_SWIMUP,pi,snum, -1); + if (Gv_GetVar(g_iReturnVarID,pi,snum) == 0) { // jump if (p->poszv > 0) p->poszv = 0; @@ -3887,11 +3889,11 @@ void processinput(int snum) if (p->poszv < -(256*6)) p->poszv = -(256*6); } } - else if (sb_snum&(1<<1)) + else if (TEST_SYNC_KEY(sb_snum, SK_CROUCH)) { - SetGameVarID(g_iReturnVarID,0,pi,snum); - OnEvent(EVENT_SWIMDOWN,pi,snum, -1); - if (GetGameVarID(g_iReturnVarID,pi,snum) == 0) + Gv_SetVar(g_iReturnVarID,0,pi,snum); + X_OnEvent(EVENT_SWIMDOWN,pi,snum, -1); + if (Gv_GetVar(g_iReturnVarID,pi,snum) == 0) { // crouch if (p->poszv < 0) p->poszv = 0; @@ -3930,13 +3932,13 @@ void processinput(int snum) p->poszv = 0; } - if (p->scuba_on && (TRAND&255) < 8) + if (p->scuba_on && (krand()&255) < 8) { - j = spawn(pi,WATERBUBBLE); + j = A_Spawn(pi,WATERBUBBLE); sprite[j].x += - sintable[(p->ang+512+64-(global_random&128))&2047]>>6; + sintable[(p->ang+512+64-(g_globalRandom&128))&2047]>>6; sprite[j].y += - sintable[(p->ang+64-(global_random&128))&2047]>>6; + sintable[(p->ang+64-(g_globalRandom&128))&2047]>>6; sprite[j].xrepeat = 3; sprite[j].yrepeat = 2; sprite[j].z = p->posz+(8<<8); @@ -3959,30 +3961,30 @@ void processinput(int snum) p->jetpack_on++; p->posz -= (p->jetpack_on<<7); //Goin up } - else if (p->jetpack_on == 11 && !isspritemakingsound(pi,DUKE_JETPACK_IDLE)) - spritesound(DUKE_JETPACK_IDLE,pi); + else if (p->jetpack_on == 11 && !A_CheckSoundPlaying(pi,DUKE_JETPACK_IDLE)) + A_PlaySound(DUKE_JETPACK_IDLE,pi); if (shrunk) j = 512; else j = 2048; - if (sb_snum&1) //A (soar high) + if (TEST_SYNC_KEY(sb_snum, SK_JUMP)) //A (soar high) { // jump - SetGameVarID(g_iReturnVarID,0,pi,snum); - OnEvent(EVENT_SOARUP,pi,snum, -1); - if (GetGameVarID(g_iReturnVarID,pi,snum) == 0) + Gv_SetVar(g_iReturnVarID,0,pi,snum); + X_OnEvent(EVENT_SOARUP,pi,snum, -1); + if (Gv_GetVar(g_iReturnVarID,pi,snum) == 0) { p->posz -= j; p->crack_time = 777; } } - if (sb_snum&(1<<1)) //Z (soar low) + if (TEST_SYNC_KEY(sb_snum, SK_CROUCH)) //Z (soar low) { // crouch - SetGameVarID(g_iReturnVarID,0,pi,snum); - OnEvent(EVENT_SOARDOWN,pi,snum, -1); - if (GetGameVarID(g_iReturnVarID,pi,snum) == 0) + Gv_SetVar(g_iReturnVarID,0,pi,snum); + X_OnEvent(EVENT_SOARDOWN,pi,snum, -1); + if (Gv_GetVar(g_iReturnVarID,pi,snum) == 0) { p->posz += j; p->crack_time = 777; @@ -3997,8 +3999,8 @@ void processinput(int snum) if (p->posz > (fz-(k<<8))) p->posz += ((fz-(k<<8))-p->posz)>>1; - if (p->posz < (hittype[pi].ceilingz+(18<<8))) - p->posz = hittype[pi].ceilingz+(18<<8); + if (p->posz < (ActorExtra[pi].ceilingz+(18<<8))) + p->posz = ActorExtra[pi].ceilingz+(18<<8); } else if (psectlotag != 2) @@ -4026,7 +4028,7 @@ void processinput(int snum) { if (p->dummyplayersprite == -1) p->dummyplayersprite = - spawn(pi,PLAYERONWATER); + A_Spawn(pi,PLAYERONWATER); sprite[p->dummyplayersprite].pal = sprite[p->i].pal; p->footprintcount = 6; if (sector[p->cursectnum].floorpicnum == FLOORSLIME) @@ -4051,19 +4053,19 @@ void processinput(int snum) p->footprintcount--; if (p->cursectnum >= 0 && sector[p->cursectnum].lotag == 0 && sector[p->cursectnum].hitag == 0) { - switch (TRAND&3) + switch (krand()&3) { case 0: - j = spawn(pi,FOOTPRINTS); + j = A_Spawn(pi,FOOTPRINTS); break; case 1: - j = spawn(pi,FOOTPRINTS2); + j = A_Spawn(pi,FOOTPRINTS2); break; case 2: - j = spawn(pi,FOOTPRINTS3); + j = A_Spawn(pi,FOOTPRINTS3); break; default: - j = spawn(pi,FOOTPRINTS4); + j = A_Spawn(pi,FOOTPRINTS4); break; } sprite[j].pal = p->footprintpal; @@ -4077,32 +4079,33 @@ void processinput(int snum) { // not jumping or crouching - if ((sb_snum&3) == 0 && p->on_ground && (sector[psect].floorstat&2) && p->posz >= (fz-(i<<8)-(16<<8))) + + if (!TEST_SYNC_KEY(sb_snum, SK_JUMP|SK_CROUCH) && p->on_ground && (sector[psect].floorstat&2) && p->posz >= (fz-(i<<8)-(16<<8))) p->posz = fz-(i<<8); else { p->on_ground = 0; - p->poszv += (gc+80); // (TICSPERFRAME<<6); + p->poszv += (SpriteGravity+80); // (TICSPERFRAME<<6); if (p->poszv >= (4096+2048)) p->poszv = (4096+2048); if (p->poszv > 2400 && p->falling_counter < 255) { p->falling_counter++; if (p->falling_counter == 38) - p->scream_voice = spritesound(DUKE_SCREAM,pi); + p->scream_voice = A_PlaySound(DUKE_SCREAM,pi); } if ((p->posz+p->poszv) >= (fz-(i<<8)) && p->cursectnum >= 0) // hit the ground if (sector[p->cursectnum].lotag != 1) { - if (p->falling_counter > 62) quickkill(p); + if (p->falling_counter > 62) P_QuickKill(p); else if (p->falling_counter > 9) { j = p->falling_counter; - s->extra -= j-(TRAND&3); + s->extra -= j-(krand()&3); if (s->extra <= 0) { - spritesound(SQUISHED,pi); + A_PlaySound(SQUISHED,pi); p->pals[0] = 63; p->pals[1] = 0; p->pals[2] = 0; @@ -4110,8 +4113,8 @@ void processinput(int snum) } else { - spritesound(DUKE_LAND,pi); - spritesound(DUKE_LAND_HURT,pi); + A_PlaySound(DUKE_LAND,pi); + A_PlaySound(DUKE_LAND_HURT,pi); } p->pals[0] = 16; @@ -4119,7 +4122,7 @@ void processinput(int snum) p->pals[2] = 0; p->pals_time = 32; } - else if (p->poszv > 2048) spritesound(DUKE_LAND,pi); + else if (p->poszv > 2048) A_PlaySound(DUKE_LAND,pi); } } } @@ -4160,12 +4163,12 @@ void processinput(int snum) p->on_warping_sector = 0; - if ((sb_snum&2)) + if (TEST_SYNC_KEY(sb_snum, SK_CROUCH)) { // crouching - SetGameVarID(g_iReturnVarID,0,pi,snum); - OnEvent(EVENT_CROUCH,pi,snum, -1); - if (GetGameVarID(g_iReturnVarID,pi,snum) == 0) + Gv_SetVar(g_iReturnVarID,0,pi,snum); + X_OnEvent(EVENT_CROUCH,pi,snum, -1); + if (Gv_GetVar(g_iReturnVarID,pi,snum) == 0) { p->posz += (2048+768); p->crack_time = 777; @@ -4173,17 +4176,16 @@ void processinput(int snum) } // jumping - if ((sb_snum&1) == 0 && p->jumping_toggle == 1) + if (!TEST_SYNC_KEY(sb_snum, SK_JUMP) && p->jumping_toggle == 1) p->jumping_toggle = 0; - - else if ((sb_snum&1) && p->jumping_toggle == 0) + else if (TEST_SYNC_KEY(sb_snum, SK_JUMP) && p->jumping_toggle == 0) { if (p->jumping_counter == 0) if ((fz-cz) > (56<<8)) { - SetGameVarID(g_iReturnVarID,0,pi,snum); - OnEvent(EVENT_JUMP,pi,snum, -1); - if (GetGameVarID(g_iReturnVarID,pi,snum) == 0) + Gv_SetVar(g_iReturnVarID,0,pi,snum); + X_OnEvent(EVENT_JUMP,pi,snum, -1); + if (Gv_GetVar(g_iReturnVarID,pi,snum) == 0) { p->jumping_counter = 1; p->jumping_toggle = 1; @@ -4191,13 +4193,13 @@ void processinput(int snum) } } - if (p->jumping_counter && (sb_snum&1) == 0) + if (p->jumping_counter && !TEST_SYNC_KEY(sb_snum, SK_JUMP)) p->jumping_toggle = 0; } if (p->jumping_counter) { - if ((sb_snum&1) == 0 && p->jumping_toggle == 1) + if (!TEST_SYNC_KEY(sb_snum, SK_JUMP) && p->jumping_toggle == 1) p->jumping_toggle = 0; if (p->jumping_counter < (1024+256)) @@ -4272,12 +4274,12 @@ void processinput(int snum) p->boot_amount--; p->inven_icon = 7; if (p->boot_amount <= 0) - checkavailinven(p); + P_SelectNextInventoryItem(p); } else { - if (!isspritemakingsound(pi,DUKE_LONGTERM_PAIN)) - spritesound(DUKE_LONGTERM_PAIN,pi); + if (!A_CheckSoundPlaying(pi,DUKE_LONGTERM_PAIN)) + A_PlaySound(DUKE_LONGTERM_PAIN,pi); p->pals[0] = 0; p->pals[1] = 8; p->pals[2] = 0; @@ -4290,7 +4292,7 @@ void processinput(int snum) if (p->on_ground && truefdist <= PHEIGHT+(16<<8)) { - switch (dynamictostatic[j]) + switch (DynamicTileMap[j]) { case HURTRAIL__STATIC: if (rnd(32)) @@ -4299,15 +4301,15 @@ void processinput(int snum) k = 1; else { - if (!isspritemakingsound(pi,DUKE_LONGTERM_PAIN)) - spritesound(DUKE_LONGTERM_PAIN,pi); + if (!A_CheckSoundPlaying(pi,DUKE_LONGTERM_PAIN)) + A_PlaySound(DUKE_LONGTERM_PAIN,pi); p->pals[0] = 64; p->pals[1] = 64; p->pals[2] = 64; p->pals_time = 32; - s->extra -= 1+(TRAND&3); - if (!isspritemakingsound(pi,SHORT_CIRCUIT)) - spritesound(SHORT_CIRCUIT,pi); + s->extra -= 1+(krand()&3); + if (!A_CheckSoundPlaying(pi,SHORT_CIRCUIT)) + A_PlaySound(SHORT_CIRCUIT,pi); } } break; @@ -4318,13 +4320,13 @@ void processinput(int snum) k = 1; else { - if (!isspritemakingsound(pi,DUKE_LONGTERM_PAIN)) - spritesound(DUKE_LONGTERM_PAIN,pi); + if (!A_CheckSoundPlaying(pi,DUKE_LONGTERM_PAIN)) + A_PlaySound(DUKE_LONGTERM_PAIN,pi); p->pals[0] = 0; p->pals[1] = 8; p->pals[2] = 0; p->pals_time = 32; - s->extra -= 1+(TRAND&3); + s->extra -= 1+(krand()&3); } } break; @@ -4335,13 +4337,13 @@ void processinput(int snum) k = 1; else { - if (!isspritemakingsound(pi,DUKE_LONGTERM_PAIN)) - spritesound(DUKE_LONGTERM_PAIN,pi); + if (!A_CheckSoundPlaying(pi,DUKE_LONGTERM_PAIN)) + A_PlaySound(DUKE_LONGTERM_PAIN,pi); p->pals[0] = 8; p->pals[1] = 0; p->pals[2] = 0; p->pals_time = 32; - s->extra -= 1+(TRAND&3); + s->extra -= 1+(krand()&3); } } break; @@ -4350,30 +4352,30 @@ void processinput(int snum) if (k) { - FTA(75,p); + P_DoQuote(75,p); p->boot_amount -= 2; if (p->boot_amount <= 0) - checkavailinven(p); + P_SelectNextInventoryItem(p); } } if (g_player[snum].sync->extbits&(1)) - OnEvent(EVENT_MOVEFORWARD,pi,snum, -1); + X_OnEvent(EVENT_MOVEFORWARD,pi,snum, -1); if (g_player[snum].sync->extbits&(1<<1)) - OnEvent(EVENT_MOVEBACKWARD,pi,snum, -1); + X_OnEvent(EVENT_MOVEBACKWARD,pi,snum, -1); if (g_player[snum].sync->extbits&(1<<2)) - OnEvent(EVENT_STRAFELEFT,pi,snum, -1); + X_OnEvent(EVENT_STRAFELEFT,pi,snum, -1); if (g_player[snum].sync->extbits&(1<<3)) - OnEvent(EVENT_STRAFERIGHT,pi,snum, -1); + X_OnEvent(EVENT_STRAFERIGHT,pi,snum, -1); if (g_player[snum].sync->extbits&(1<<4) || g_player[snum].sync->avel < 0) - OnEvent(EVENT_TURNLEFT,pi,snum, -1); + X_OnEvent(EVENT_TURNLEFT,pi,snum, -1); if (g_player[snum].sync->extbits&(1<<5) || g_player[snum].sync->avel > 0) - OnEvent(EVENT_TURNRIGHT,pi,snum, -1); + X_OnEvent(EVENT_TURNRIGHT,pi,snum, -1); if (p->posxv || p->posyv || g_player[snum].sync->fvel || g_player[snum].sync->svel) { @@ -4393,18 +4395,18 @@ void processinput(int snum) j = sprite[lz&(MAXSPRITES-1)].picnum; else j = sector[psect].floorpicnum; - switch (dynamictostatic[j]) + switch (DynamicTileMap[j]) { case PANNEL1__STATIC: case PANNEL2__STATIC: - spritesound(DUKE_WALKINDUCTS,pi); + A_PlaySound(DUKE_WALKINDUCTS,pi); p->walking_snd_toggle = 1; break; } break; case 1: - if ((TRAND&1) == 0) - spritesound(DUKE_ONWATER,pi); + if ((krand()&1) == 0) + A_PlaySound(DUKE_ONWATER,pi); p->walking_snd_toggle = 1; break; } @@ -4419,7 +4421,7 @@ void processinput(int snum) p->posxv += ((g_player[snum].sync->fvel*doubvel)<<6); p->posyv += ((g_player[snum].sync->svel*doubvel)<<6); - if ((aplWeaponWorksLike[p->curr_weapon][snum] == KNEE_WEAPON && *kb > 10 && p->on_ground) || (p->on_ground && (sb_snum&2))) + if ((aplWeaponWorksLike[p->curr_weapon][snum] == KNEE_WEAPON && *kb > 10 && p->on_ground) || (p->on_ground && TEST_SYNC_KEY(sb_snum, SK_CROUCH))) { p->posxv = mulscale(p->posxv,p->runspeed-0x2000,16); p->posyv = mulscale(p->posyv,p->runspeed-0x2000,16); @@ -4475,7 +4477,7 @@ HORIZONLY: p->posz += 32<<8; if (j) - checkplayerhurt(p,j); + P_CheckTouchDamage(p,j); if (p->jetpack_on == 0) { @@ -4501,35 +4503,35 @@ HORIZONLY: psect = s->sectnum; if (ud.clipping == 0 && sector[psect].lotag == 31) { - if (sprite[sector[psect].hitag].xvel && hittype[sector[psect].hitag].temp_data[0] == 0) + if (sprite[sector[psect].hitag].xvel && ActorExtra[sector[psect].hitag].temp_data[0] == 0) { - quickkill(p); + P_QuickKill(p); return; } } } if (p->cursectnum >= 0 && truefdist < PHEIGHT && p->on_ground && psectlotag != 1 && shrunk == 0 && sector[p->cursectnum].lotag == 1) - if (!isspritemakingsound(pi,DUKE_ONWATER)) - spritesound(DUKE_ONWATER,pi); + if (!A_CheckSoundPlaying(pi,DUKE_ONWATER)) + A_PlaySound(DUKE_ONWATER,pi); if (p->cursectnum != s->sectnum) changespritesect(pi,p->cursectnum); if (ud.clipping == 0) - j = (pushmove(&p->posx,&p->posy,&p->posz,&p->cursectnum,164L,(4L<<8),(4L<<8),CLIPMASK0) < 0 && furthestangle(pi,8) < 512); + j = (pushmove(&p->posx,&p->posy,&p->posz,&p->cursectnum,164L,(4L<<8),(4L<<8),CLIPMASK0) < 0 && A_GetFurthestAngle(pi,8) < 512); else j = 0; if (ud.clipping == 0) { - if (klabs(hittype[pi].floorz-hittype[pi].ceilingz) < (48<<8) || j) + if (klabs(ActorExtra[pi].floorz-ActorExtra[pi].ceilingz) < (48<<8) || j) { if (!(sector[s->sectnum].lotag&0x8000) && (isanunderoperator(sector[s->sectnum].lotag) || isanearoperator(sector[s->sectnum].lotag))) activatebysector(s->sectnum,pi); if (j) { - quickkill(p); + P_QuickKill(p); return; } } @@ -4539,73 +4541,73 @@ HORIZONLY: // center_view i = 0; - if (sb_snum&(1<<18) || p->hard_landing) + if (TEST_SYNC_KEY(sb_snum, SK_CENTER_VIEW) || p->hard_landing) { - SetGameVarID(g_iReturnVarID,0,pi,snum); - OnEvent(EVENT_RETURNTOCENTER,pi,snum, -1); - if (GetGameVarID(g_iReturnVarID,pi,snum) == 0) + Gv_SetVar(g_iReturnVarID,0,pi,snum); + X_OnEvent(EVENT_RETURNTOCENTER,pi,snum, -1); + if (Gv_GetVar(g_iReturnVarID,pi,snum) == 0) { p->return_to_center = 9; } } - if (sb_snum&(1<<13)) + if (TEST_SYNC_KEY(sb_snum, SK_LOOK_UP)) { // look_up - SetGameVarID(g_iReturnVarID,0,pi,snum); - OnEvent(EVENT_LOOKUP,pi,snum, -1); - if (GetGameVarID(g_iReturnVarID,pi,snum) == 0) + Gv_SetVar(g_iReturnVarID,0,pi,snum); + X_OnEvent(EVENT_LOOKUP,pi,snum, -1); + if (Gv_GetVar(g_iReturnVarID,pi,snum) == 0) { p->return_to_center = 9; - if (sb_snum&(1<<5)) p->horiz += 12; // running + if (TEST_SYNC_KEY(sb_snum, SK_RUN)) p->horiz += 12; // running p->horiz += 12; i++; } } - else if (sb_snum&(1<<14)) + else if (TEST_SYNC_KEY(sb_snum, SK_LOOK_DOWN)) { // look_down - SetGameVarID(g_iReturnVarID,0,pi,snum); - OnEvent(EVENT_LOOKDOWN,pi,snum, -1); - if (GetGameVarID(g_iReturnVarID,pi,snum) == 0) + Gv_SetVar(g_iReturnVarID,0,pi,snum); + X_OnEvent(EVENT_LOOKDOWN,pi,snum, -1); + if (Gv_GetVar(g_iReturnVarID,pi,snum) == 0) { p->return_to_center = 9; - if (sb_snum&(1<<5)) p->horiz -= 12; + if (TEST_SYNC_KEY(sb_snum, SK_RUN)) p->horiz -= 12; p->horiz -= 12; i++; } } - else if (sb_snum&(1<<3)) + else if (TEST_SYNC_KEY(sb_snum, SK_AIM_UP)) { // aim_up - SetGameVarID(g_iReturnVarID,0,pi,snum); - OnEvent(EVENT_AIMUP,pi,snum, -1); - if (GetGameVarID(g_iReturnVarID,pi,snum) == 0) + Gv_SetVar(g_iReturnVarID,0,pi,snum); + X_OnEvent(EVENT_AIMUP,pi,snum, -1); + if (Gv_GetVar(g_iReturnVarID,pi,snum) == 0) { // running - if (sb_snum&(1<<5)) p->horiz += 6; + if (TEST_SYNC_KEY(sb_snum, SK_RUN)) p->horiz += 6; p->horiz += 6; i++; } } - else if (sb_snum&(1<<4)) + else if (TEST_SYNC_KEY(sb_snum, SK_AIM_DOWN)) { // aim_down - SetGameVarID(g_iReturnVarID,0,pi,snum); - OnEvent(EVENT_AIMDOWN,pi,snum, -1); - if (GetGameVarID(g_iReturnVarID,pi,snum) == 0) + Gv_SetVar(g_iReturnVarID,0,pi,snum); + X_OnEvent(EVENT_AIMDOWN,pi,snum, -1); + if (Gv_GetVar(g_iReturnVarID,pi,snum) == 0) { // running - if (sb_snum&(1<<5)) p->horiz -= 6; + if (TEST_SYNC_KEY(sb_snum, SK_RUN)) p->horiz -= 6; p->horiz -= 6; i++; } } if (p->return_to_center > 0) - if ((sb_snum&(1<<13)) == 0 && (sb_snum&(1<<14)) == 0) + if (TEST_SYNC_KEY(sb_snum, SK_LOOK_UP) == 0 && TEST_SYNC_KEY(sb_snum, SK_LOOK_DOWN) == 0) { p->return_to_center--; p->horiz += 33-(p->horiz/3); @@ -4639,7 +4641,7 @@ HORIZONLY: p->subweapon |= (1<last_full_weapon == SHRINKER_WEAPON) p->subweapon &= ~(1<last_full_weapon); + P_AddWeapon(p, p->last_full_weapon); return; } } @@ -4657,10 +4659,10 @@ HORIZONLY: p->weapon_pos = -p->weapon_pos; if (p->actorsqu >= 0 && dist(&sprite[pi],&sprite[p->actorsqu]) < 1400 && sprite[p->actorsqu].statnum != MAXSTATUS) { - guts(p->actorsqu,JIBS6,7); - spawn(p->actorsqu,BLOODPOOL); - spritesound(SQUISHED,p->actorsqu); - switch (dynamictostatic[sprite[p->actorsqu].picnum]) + A_DoGuts(p->actorsqu,JIBS6,7); + A_Spawn(p->actorsqu,BLOODPOOL); + A_PlaySound(SQUISHED,p->actorsqu); + switch (DynamicTileMap[sprite[p->actorsqu].picnum]) { case FEM1__STATIC: case FEM2__STATIC: @@ -4676,16 +4678,16 @@ HORIZONLY: case NAKED1__STATIC: case STATUE__STATIC: if (sprite[p->actorsqu].yvel) - operaterespawns(sprite[p->actorsqu].yvel); + G_OperateRespawns(sprite[p->actorsqu].yvel); break; } if (sprite[p->actorsqu].picnum == APLAYER) { - quickkill(g_player[sprite[p->actorsqu].yvel].ps); + P_QuickKill(g_player[sprite[p->actorsqu].yvel].ps); g_player[sprite[p->actorsqu].yvel].ps->frag_ps = snum; } - else if (badguy(&sprite[p->actorsqu])) + else if (A_CheckEnemySprite(&sprite[p->actorsqu])) { deletesprite(p->actorsqu); p->actors_killed++; @@ -4695,10 +4697,10 @@ HORIZONLY: p->actorsqu = -1; } else if (p->actorsqu >= 0) - p->ang += getincangle(p->ang,getangle(sprite[p->actorsqu].x-p->posx,sprite[p->actorsqu].y-p->posy))>>2; + p->ang += G_GetAngleDelta(p->ang,getangle(sprite[p->actorsqu].x-p->posx,sprite[p->actorsqu].y-p->posy))>>2; } - if (doincrements(p)) return; + if (P_DoCounters(p)) return; if (p->weapon_pos != 0) { @@ -4719,15 +4721,15 @@ HORIZONLY: // HACKS SHOOTINCODE: - if (sb_snum & (1<<19)) // 'Holster Weapon + if (TEST_SYNC_KEY(sb_snum, SK_HOLSTER)) // 'Holster Weapon { - SetGameVarID(g_iReturnVarID,0,pi,snum); - SetGameVarID(g_iWeaponVarID,p->curr_weapon,pi,snum); - SetGameVarID(g_iWorksLikeVarID,aplWeaponWorksLike[p->curr_weapon][snum],pi,snum); - OnEvent(EVENT_HOLSTER, pi, snum, -1); - if (GetGameVarID(g_iReturnVarID,pi,snum) == 0) + Gv_SetVar(g_iReturnVarID,0,pi,snum); + Gv_SetVar(g_iWeaponVarID,p->curr_weapon,pi,snum); + Gv_SetVar(g_iWorksLikeVarID,aplWeaponWorksLike[p->curr_weapon][snum],pi,snum); + X_OnEvent(EVENT_HOLSTER, pi, snum, -1); + if (Gv_GetVar(g_iReturnVarID,pi,snum) == 0) { - if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_HOLSTER_CLEARS_CLIP) + if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_HOLSTER_CLEARS_CLIP) { if (p->ammo_amount[p->curr_weapon] > aplWeaponClip[p->curr_weapon][snum] && (p->ammo_amount[p->curr_weapon] % aplWeaponClip[p->curr_weapon][snum]) != 0) @@ -4735,46 +4737,46 @@ SHOOTINCODE: p->ammo_amount[p->curr_weapon]-= p->ammo_amount[p->curr_weapon] % aplWeaponClip[p->curr_weapon][snum] ; (*kb) = aplWeaponTotalTime[p->curr_weapon][snum]; - sb_snum &= ~(1<<2); // not firing... + sb_snum &= ~BIT(SK_FIRE); // not firing... } return; } } } - if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_GLOWS) + if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_GLOWS) p->random_club_frame += 64; // Glowing - // this is for WEAPON_FLAG_FIREEVERYOTHER - if (hittype[p->i].temp_data[7]) + // this is for WEAPON_FIREEVERYOTHER + if (ActorExtra[p->i].temp_data[7]) { - hittype[p->i].temp_data[7]--; - if (p->last_weapon == -1 && hittype[p->i].temp_data[7] != 0 && ((hittype[p->i].temp_data[7] & 1) == 0)) + ActorExtra[p->i].temp_data[7]--; + if (p->last_weapon == -1 && ActorExtra[p->i].temp_data[7] != 0 && ((ActorExtra[p->i].temp_data[7] & 1) == 0)) { - if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_AMMOPERSHOT) + if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_AMMOPERSHOT) { if (p->ammo_amount[p->curr_weapon] > 0) p->ammo_amount[p->curr_weapon]--; else { - hittype[p->i].temp_data[7] = 0; - checkavailweapon(p); + ActorExtra[p->i].temp_data[7] = 0; + P_CheckWeapon(p); } } - if (hittype[p->i].temp_data[7] != 0) + if (ActorExtra[p->i].temp_data[7] != 0) { - shoot(p->i,aplWeaponShoots[p->curr_weapon][snum]); + A_Shoot(p->i,aplWeaponShoots[p->curr_weapon][snum]); } } } if (p->rapid_fire_hold == 1) { - if (sb_snum&(1<<2)) return; + if (TEST_SYNC_KEY(sb_snum, SK_FIRE)) return; p->rapid_fire_hold = 0; } if (shrunk || p->tipincs || p->access_incs) - sb_snum &= ~(1<<2); + sb_snum &= ~BIT(SK_FIRE); else if (shrunk == 0 && (sb_snum&(1<<2)) && (*kb) == 0 && p->fist_incs == 0 && p->last_weapon == -1 && (p->weapon_pos == 0 || p->holster_weapon == 1)) { @@ -4786,21 +4788,21 @@ SHOOTINCODE: { p->holster_weapon = 0; p->weapon_pos = 10; - FTA(74,p); + P_DoQuote(74,p); } } else { - SetGameVarID(g_iReturnVarID,0,pi,snum); - SetGameVarID(g_iWeaponVarID,p->curr_weapon,pi,snum); - SetGameVarID(g_iWorksLikeVarID,aplWeaponWorksLike[p->curr_weapon][snum],pi,snum); - OnEvent(EVENT_FIRE, pi, snum, -1); - if (GetGameVarID(g_iReturnVarID,pi,snum) == 0) + Gv_SetVar(g_iReturnVarID,0,pi,snum); + Gv_SetVar(g_iWeaponVarID,p->curr_weapon,pi,snum); + Gv_SetVar(g_iWorksLikeVarID,aplWeaponWorksLike[p->curr_weapon][snum],pi,snum); + X_OnEvent(EVENT_FIRE, pi, snum, -1); + if (Gv_GetVar(g_iReturnVarID,pi,snum) == 0) { switch (aplWeaponWorksLike[p->curr_weapon][snum]) { case HANDBOMB_WEAPON: - OnEvent(EVENT_FIREWEAPON, p->i, snum, -1); + X_OnEvent(EVENT_FIREWEAPON, p->i, snum, -1); p->hbomb_hold_delay = 0; if (p->ammo_amount[p->curr_weapon] > 0) @@ -4808,29 +4810,29 @@ SHOOTINCODE: (*kb)=1; if (aplWeaponInitialSound[p->curr_weapon][snum]) { - spritesound(aplWeaponInitialSound[p->curr_weapon][snum], pi); + A_PlaySound(aplWeaponInitialSound[p->curr_weapon][snum], pi); } } break; case HANDREMOTE_WEAPON: - OnEvent(EVENT_FIREWEAPON, p->i, snum, -1); + X_OnEvent(EVENT_FIREWEAPON, p->i, snum, -1); p->hbomb_hold_delay = 0; (*kb) = 1; if (aplWeaponInitialSound[p->curr_weapon][snum]) { - spritesound(aplWeaponInitialSound[p->curr_weapon][snum], pi); + A_PlaySound(aplWeaponInitialSound[p->curr_weapon][snum], pi); } break; case SHOTGUN_WEAPON: - OnEvent(EVENT_FIREWEAPON, p->i, snum, -1); + X_OnEvent(EVENT_FIREWEAPON, p->i, snum, -1); if (p->ammo_amount[p->curr_weapon] > 0 && p->random_club_frame == 0) { (*kb)=1; if (aplWeaponInitialSound[p->curr_weapon][snum]) { - spritesound(aplWeaponInitialSound[p->curr_weapon][snum], pi); + A_PlaySound(aplWeaponInitialSound[p->curr_weapon][snum], pi); } } break; @@ -4874,7 +4876,7 @@ SHOOTINCODE: (*kb) = 1; if (aplWeaponInitialSound[p->curr_weapon][snum]) { - spritesound(aplWeaponInitialSound[p->curr_weapon][snum], pi); + A_PlaySound(aplWeaponInitialSound[p->curr_weapon][snum], pi); } } } @@ -4886,38 +4888,38 @@ SHOOTINCODE: case GROW_WEAPON: case FREEZE_WEAPON: case RPG_WEAPON: - OnEvent(EVENT_FIREWEAPON, p->i, snum, -1); + X_OnEvent(EVENT_FIREWEAPON, p->i, snum, -1); if (p->ammo_amount[p->curr_weapon] > 0) { (*kb) = 1; if (aplWeaponInitialSound[p->curr_weapon][snum]) { - spritesound(aplWeaponInitialSound[p->curr_weapon][snum], pi); + A_PlaySound(aplWeaponInitialSound[p->curr_weapon][snum], pi); } } break; case DEVISTATOR_WEAPON: - OnEvent(EVENT_FIREWEAPON, p->i, snum, -1); + X_OnEvent(EVENT_FIREWEAPON, p->i, snum, -1); if (p->ammo_amount[p->curr_weapon] > 0) { (*kb) = 1; p->hbomb_hold_delay = !p->hbomb_hold_delay; if (aplWeaponInitialSound[p->curr_weapon][snum]) { - spritesound(aplWeaponInitialSound[p->curr_weapon][snum], pi); + A_PlaySound(aplWeaponInitialSound[p->curr_weapon][snum], pi); } } break; case KNEE_WEAPON: - OnEvent(EVENT_FIREWEAPON, p->i, snum, -1); + X_OnEvent(EVENT_FIREWEAPON, p->i, snum, -1); if (p->quick_kick == 0) { (*kb) = 1; if (aplWeaponInitialSound[p->curr_weapon][snum]) { - spritesound(aplWeaponInitialSound[p->curr_weapon][snum], pi); + A_PlaySound(aplWeaponInitialSound[p->curr_weapon][snum], pi); } } break; @@ -4929,7 +4931,7 @@ SHOOTINCODE: { if (aplWeaponWorksLike[p->curr_weapon][snum] == HANDBOMB_WEAPON) { - if (aplWeaponHoldDelay[p->curr_weapon][snum] && ((*kb) == aplWeaponFireDelay[p->curr_weapon][snum]) && (sb_snum&(1<<2))) + if (aplWeaponHoldDelay[p->curr_weapon][snum] && ((*kb) == aplWeaponFireDelay[p->curr_weapon][snum]) && TEST_SYNC_KEY(sb_snum, SK_FIRE)) { p->rapid_fire_hold = 1; return; @@ -4941,7 +4943,7 @@ SHOOTINCODE: p->ammo_amount[p->curr_weapon]--; - if (p->on_ground && (sb_snum&2)) + if (p->on_ground && TEST_SYNC_KEY(sb_snum, SK_CROUCH)) { k = 15; i = ((p->horiz+p->horizoff-100)*20); @@ -4952,25 +4954,25 @@ SHOOTINCODE: i = -512-((p->horiz+p->horizoff-100)*20); } - j = EGS(p->cursectnum, - p->posx+(sintable[(p->ang+512)&2047]>>6), - p->posy+(sintable[p->ang&2047]>>6), - p->posz,aplWeaponShoots[p->curr_weapon][snum],-16,9,9, - p->ang,(k+(p->hbomb_hold_delay<<5)),i,pi,1); + j = A_InsertSprite(p->cursectnum, + p->posx+(sintable[(p->ang+512)&2047]>>6), + p->posy+(sintable[p->ang&2047]>>6), + p->posz,aplWeaponShoots[p->curr_weapon][snum],-16,9,9, + p->ang,(k+(p->hbomb_hold_delay<<5)),i,pi,1); - lPipeBombControl=GetGameVar("PIPEBOMB_CONTROL", PIPEBOMB_REMOTE, -1, snum); + lPipeBombControl=Gv_GetVarByLabel("PIPEBOMB_CONTROL", PIPEBOMB_REMOTE, -1, snum); if (lPipeBombControl & PIPEBOMB_TIMER) { - int lGrenadeLifetime=GetGameVar("GRENADE_LIFETIME", NAM_GRENADE_LIFETIME, -1, snum); - int lGrenadeLifetimeVar=GetGameVar("GRENADE_LIFETIME_VAR", NAM_GRENADE_LIFETIME_VAR, -1, snum); - hittype[j].temp_data[7]=lGrenadeLifetime - + mulscale(krand(),lGrenadeLifetimeVar, 14) - - lGrenadeLifetimeVar; - hittype[j].temp_data[6]=1; + int lGrenadeLifetime=Gv_GetVarByLabel("GRENADE_LIFETIME", NAM_GRENADE_LIFETIME, -1, snum); + int lGrenadeLifetimeVar=Gv_GetVarByLabel("GRENADE_LIFETIME_VAR", NAM_GRENADE_LIFETIME_VAR, -1, snum); + ActorExtra[j].temp_data[7]=lGrenadeLifetime + + mulscale(krand(),lGrenadeLifetimeVar, 14) + - lGrenadeLifetimeVar; + ActorExtra[j].temp_data[6]=1; } else - hittype[j].temp_data[6]=2; + ActorExtra[j].temp_data[6]=2; if (k == 15) { @@ -4978,7 +4980,7 @@ SHOOTINCODE: sprite[j].z += (8<<8); } - k = hits(pi); + k = A_GetHitscanRange(pi); if (k < 512) { sprite[j].ang += 1024; @@ -4987,13 +4989,13 @@ SHOOTINCODE: } p->hbomb_on = 1; } - else if ((*kb) < aplWeaponHoldDelay[p->curr_weapon][snum] && (sb_snum&(1<<2))) + else if ((*kb) < aplWeaponHoldDelay[p->curr_weapon][snum] && TEST_SYNC_KEY(sb_snum, SK_FIRE)) { p->hbomb_hold_delay++; } else if ((*kb) > aplWeaponTotalTime[p->curr_weapon][snum]) { - int lPipeBombControl=GetGameVar("PIPEBOMB_CONTROL", PIPEBOMB_REMOTE, -1, snum); + int lPipeBombControl=Gv_GetVarByLabel("PIPEBOMB_CONTROL", PIPEBOMB_REMOTE, -1, snum); (*kb) = 0; @@ -5006,7 +5008,7 @@ SHOOTINCODE: else { p->weapon_pos = 10; - checkavailweapon(p); + P_CheckWeapon(p); } } } @@ -5016,31 +5018,31 @@ SHOOTINCODE: if ((*kb) == aplWeaponFireDelay[p->curr_weapon][snum]) { - if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_BOMB_TRIGGER) + if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_BOMB_TRIGGER) { p->hbomb_on = 0; } if (aplWeaponShoots[p->curr_weapon][snum] != 0) { - if (!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_NOVISIBLE)) + if (!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_NOVISIBLE)) { lastvisinc = totalclock+32; p->visibility = 0; } - SetGameVarID(g_iWeaponVarID,p->curr_weapon,p->i,snum); - SetGameVarID(g_iWorksLikeVarID,aplWeaponWorksLike[p->curr_weapon][snum], p->i, snum); - shoot(pi, aplWeaponShoots[p->curr_weapon][snum]); + Gv_SetVar(g_iWeaponVarID,p->curr_weapon,p->i,snum); + Gv_SetVar(g_iWorksLikeVarID,aplWeaponWorksLike[p->curr_weapon][snum], p->i, snum); + A_Shoot(pi, aplWeaponShoots[p->curr_weapon][snum]); } } if ((*kb) >= aplWeaponTotalTime[p->curr_weapon][snum]) { - int lPipeBombControl=GetGameVar("PIPEBOMB_CONTROL", PIPEBOMB_REMOTE, -1, snum); + int lPipeBombControl=Gv_GetVarByLabel("PIPEBOMB_CONTROL", PIPEBOMB_REMOTE, -1, snum); (*kb) = 0; if ((p->ammo_amount[HANDBOMB_WEAPON] > 0) && lPipeBombControl == PIPEBOMB_REMOTE) - addweapon(p,HANDBOMB_WEAPON); + P_AddWeapon(p,HANDBOMB_WEAPON); else - checkavailweapon(p); + P_CheckWeapon(p); } } else @@ -5048,24 +5050,24 @@ SHOOTINCODE: // the basic weapon... (*kb)++; - if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_CHECKATRELOAD) + if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_CHECKATRELOAD) { if (aplWeaponWorksLike[p->curr_weapon][snum] == TRIPBOMB_WEAPON) { if ((*kb) >= aplWeaponTotalTime[p->curr_weapon][snum]) { (*kb) = 0; - checkavailweapon(p); + P_CheckWeapon(p); p->weapon_pos = -9; } } else if (*kb >= aplWeaponReload[p->curr_weapon][snum]) - checkavailweapon(p); + P_CheckWeapon(p); } else if (aplWeaponWorksLike[p->curr_weapon][snum]!=KNEE_WEAPON && *kb >= aplWeaponFireDelay[p->curr_weapon][snum]) - checkavailweapon(p); + P_CheckWeapon(p); - if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_STANDSTILL + if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_STANDSTILL && *kb < (aplWeaponFireDelay[p->curr_weapon][snum]+1)) { p->posz = p->oposz; @@ -5075,7 +5077,7 @@ SHOOTINCODE: { if (aplWeaponSound2Sound[p->curr_weapon][snum]) { - spritesound(aplWeaponSound2Sound[p->curr_weapon][snum],pi); + A_PlaySound(aplWeaponSound2Sound[p->curr_weapon][snum],pi); } } if (*kb == aplWeaponSpawnTime[p->curr_weapon][snum]) @@ -5083,7 +5085,7 @@ SHOOTINCODE: if ((*kb) >= aplWeaponTotalTime[p->curr_weapon][snum]) { - if (/*!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_CHECKATRELOAD) && */ p->reloading == 1 || + if (/*!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_CHECKATRELOAD) && */ p->reloading == 1 || (aplWeaponReload[p->curr_weapon][snum] > aplWeaponTotalTime[p->curr_weapon][snum] && p->ammo_amount[p->curr_weapon] > 0 && (aplWeaponClip[p->curr_weapon][snum]) && (((p->ammo_amount[p->curr_weapon]%(aplWeaponClip[p->curr_weapon][snum]))==0)))) { @@ -5096,13 +5098,13 @@ SHOOTINCODE: if ((*kb) == (aplWeaponTotalTime[p->curr_weapon][snum]+1)) { if (aplWeaponReloadSound1[p->curr_weapon][snum]) - spritesound(aplWeaponReloadSound1[p->curr_weapon][snum],pi); + A_PlaySound(aplWeaponReloadSound1[p->curr_weapon][snum],pi); } - else if (((*kb) == (aplWeaponReload[p->curr_weapon][snum] - (i/3)) && !(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_RELOAD_TIMING)) || - ((*kb) == (aplWeaponReload[p->curr_weapon][snum] - i+4) && (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_RELOAD_TIMING))) + else if (((*kb) == (aplWeaponReload[p->curr_weapon][snum] - (i/3)) && !(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_RELOAD_TIMING)) || + ((*kb) == (aplWeaponReload[p->curr_weapon][snum] - i+4) && (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_RELOAD_TIMING))) { if (aplWeaponReloadSound2[p->curr_weapon][snum]) - spritesound(aplWeaponReloadSound2[p->curr_weapon][snum],pi); + A_PlaySound(aplWeaponReloadSound2[p->curr_weapon][snum],pi); } else if ((*kb) >= (aplWeaponReload[p->curr_weapon][snum])) { @@ -5113,23 +5115,23 @@ SHOOTINCODE: } else { - if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_AUTOMATIC && + if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_AUTOMATIC && (aplWeaponWorksLike[p->curr_weapon][snum]==KNEE_WEAPON?1:p->ammo_amount[p->curr_weapon] > 0)) { - if (sb_snum&(1<<2)) + if (TEST_SYNC_KEY(sb_snum, SK_FIRE)) { - if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_RANDOMRESTART) - *kb = 1+(TRAND&3); + if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_RANDOMRESTART) + *kb = 1+(krand()&3); else *kb=1; } else *kb = 0; } else *kb = 0; - if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_RESET && + if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_RESET && ((aplWeaponWorksLike[p->curr_weapon][snum] == KNEE_WEAPON)?1:p->ammo_amount[p->curr_weapon] > 0)) { - if (sb_snum&(1<<2)) *kb = 1; + if (TEST_SYNC_KEY(sb_snum, SK_FIRE)) *kb = 1; else *kb = 0; } } @@ -5137,13 +5139,13 @@ SHOOTINCODE: else if (*kb >= aplWeaponFireDelay[p->curr_weapon][snum] && (*kb) < aplWeaponTotalTime[p->curr_weapon][snum] && ((aplWeaponWorksLike[p->curr_weapon][snum] == KNEE_WEAPON)?1:p->ammo_amount[p->curr_weapon] > 0)) { - if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_AUTOMATIC) + if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_AUTOMATIC) { - if (!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_SEMIAUTO)) + if (!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_SEMIAUTO)) { - if ((sb_snum&(1<<2)) == 0 && aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_RESET) + if (TEST_SYNC_KEY(sb_snum, SK_FIRE) == 0 && aplWeaponFlags[p->curr_weapon][snum] & WEAPON_RESET) *kb = 0; - if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_FIREEVERYTHIRD) + if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FIREEVERYTHIRD) { if (((*(kb))%3) == 0) { @@ -5151,7 +5153,7 @@ SHOOTINCODE: DoSpawn(p); } } - else if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_FIREEVERYOTHER) + else if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FIREEVERYOTHER) { DoFire(p); DoSpawn(p); @@ -5164,17 +5166,17 @@ SHOOTINCODE: // DoSpawn(p); } } - if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_RESET && + if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_RESET && (*kb) > aplWeaponTotalTime[p->curr_weapon][snum]-aplWeaponHoldDelay[p->curr_weapon][snum] && ((aplWeaponWorksLike[p->curr_weapon][snum] == KNEE_WEAPON)?1:p->ammo_amount[p->curr_weapon] > 0)) { - if (sb_snum&(1<<2)) *kb = 1; + if (TEST_SYNC_KEY(sb_snum, SK_FIRE)) *kb = 1; else *kb = 0; } } else { - if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_FIREEVERYOTHER) + if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FIREEVERYOTHER) { DoFire(p); DoSpawn(p); @@ -5199,7 +5201,7 @@ SHOOTINCODE: //UPDATE THIS FILE OVER THE OLD GETSPRITESCORE/COMPUTERGETINPUT FUNCTIONS int getspritescore(int snum, int dapicnum) { - switch (dynamictostatic[dapicnum]) + switch (DynamicTileMap[dapicnum]) { case FIRSTGUNSPRITE__STATIC: return(20); @@ -5314,7 +5316,7 @@ void computergetinput(int snum, input_t *syn) int dist, daang, zang, fightdist, damyang, damysect; int startsect, endsect, splc, send, startwall, endwall; short dasect, dawall, daspr; - player_struct *p = g_player[snum].ps; + DukePlayer_t *p = g_player[snum].ps; walltype *wal; syn->fvel = 0; @@ -5351,37 +5353,37 @@ void computergetinput(int snum, input_t *syn) if ((goalplayer[snum] == snum) || (g_player[goalplayer[snum]].ps->dead_flag != 0)) { j = 0x7fffffff; - for (i=connecthead;i>=0;i=connectpoint2[i]) - if (i != snum && !(GTFLAGS(GAMETYPE_FLAG_TDM) && g_player[snum].ps->team == g_player[i].ps->team)) + TRAVERSE_CONNECT(i) + if (i != snum && !(GTFLAGS(GAMETYPE_TDM) && g_player[snum].ps->team == g_player[i].ps->team)) + { + dist = ksqrt((sprite[g_player[i].ps->i].x-x1)*(sprite[g_player[i].ps->i].x-x1)+(sprite[g_player[i].ps->i].y-y1)*(sprite[g_player[i].ps->i].y-y1)); + + x2 = sprite[g_player[i].ps->i].x; + y2 = sprite[g_player[i].ps->i].y; + z2 = sprite[g_player[i].ps->i].z; + if (!cansee(x1,y1,z1-(48<<8),damysect,x2,y2,z2-(48<<8),sprite[g_player[i].ps->i].sectnum)) + dist <<= 1; + + if (dist < j) { - dist = ksqrt((sprite[g_player[i].ps->i].x-x1)*(sprite[g_player[i].ps->i].x-x1)+(sprite[g_player[i].ps->i].y-y1)*(sprite[g_player[i].ps->i].y-y1)); - - x2 = sprite[g_player[i].ps->i].x; - y2 = sprite[g_player[i].ps->i].y; - z2 = sprite[g_player[i].ps->i].z; - if (!cansee(x1,y1,z1-(48<<8),damysect,x2,y2,z2-(48<<8),sprite[g_player[i].ps->i].sectnum)) - dist <<= 1; - - if (dist < j) - { - j = dist; - goalplayer[snum] = i; - } - + j = dist; + goalplayer[snum] = i; } + + } } x2 = sprite[g_player[goalplayer[snum]].ps->i].x; y2 = sprite[g_player[goalplayer[snum]].ps->i].y; z2 = sprite[g_player[goalplayer[snum]].ps->i].z; - if (p->dead_flag) syn->bits |= (1<<29); + if (p->dead_flag) syn->bits |= BIT(SK_OPEN); if ((p->firstaid_amount > 0) && (p->last_extra < 100)) - syn->bits |= (1<<16); + syn->bits |= BIT(SK_MEDKIT); - for (j=headspritestat[4];j>=0;j=nextspritestat[j]) + for (j=headspritestat[STAT_PROJECTILE];j>=0;j=nextspritestat[j]) { - switch (dynamictostatic[sprite[j].picnum]) + switch (DynamicTileMap[sprite[j].picnum]) { case TONGUE__STATIC: k = 4; @@ -5438,19 +5440,19 @@ void computergetinput(int snum, input_t *syn) (cansee(x1,y1,z1-(24<<8),damysect,x2,y2,z2-(24<<8),sprite[g_player[goalplayer[snum]].ps->i].sectnum)) || (cansee(x1,y1,z1-(48<<8),damysect,x2,y2,z2-(48<<8),sprite[g_player[goalplayer[snum]].ps->i].sectnum)))) { - syn->bits |= (1<<2); + syn->bits |= BIT(SK_FIRE); if ((p->curr_weapon == HANDBOMB_WEAPON) && (!(rand()&7))) - syn->bits &= ~(1<<2); + syn->bits &= ~BIT(SK_FIRE); if (p->curr_weapon == TRIPBOMB_WEAPON) - syn->bits |= ((rand()%MAX_WEAPONS)<<8); + syn->bits |= ((rand()%MAX_WEAPONS)<curr_weapon == RPG_WEAPON) { hitscan(x1,y1,z1-PHEIGHT,damysect,sintable[(damyang+512)&2047],sintable[damyang&2047], (100-p->horiz-p->horizoff)*32,&dasect,&dawall,&daspr,&x3,&y3,&z3,CLIPMASK1); - if ((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1) < 2560*2560) syn->bits &= ~(1<<2); + if ((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1) < 2560*2560) syn->bits &= ~BIT(SK_FIRE); } @@ -5465,15 +5467,15 @@ void computergetinput(int snum, input_t *syn) if (sprite[g_player[goalplayer[snum]].ps->i].yrepeat < 32) { fightdist = 0; - syn->bits &= ~(1<<2); + syn->bits &= ~BIT(SK_FIRE); } if (sprite[g_player[goalplayer[snum]].ps->i].pal == 1) { fightdist = 0; - syn->bits &= ~(1<<2); + syn->bits &= ~BIT(SK_FIRE); } - if (dist < 256) syn->bits |= (1<<22); + if (dist < 256) syn->bits |= BIT(SK_QUICK_KICK); x3 = x2+((x1-x2)*fightdist/dist); y3 = y2+((y1-y2)*fightdist/dist); @@ -5498,7 +5500,7 @@ void computergetinput(int snum, input_t *syn) syn->avel = min(max((((daang+1024-damyang)&2047)-1024)>>1,-127),127); syn->horz = min(max((zang-p->horiz),-MAXHORIZ),MAXHORIZ); - syn->bits |= (1<<23); + syn->bits |= BIT(SK_AIMMODE); return; } @@ -5717,8 +5719,8 @@ void computergetinput(int snum, input_t *syn) if (getceilzofslope(wall[i&(MAXWALLS-1)].nextsector,p->posx,p->posy) >= p->posz-(24<<8)) j |= 2; } if ((i&0xc000) == 49152) j = 1; - if (j&1) if (clipmovecount[snum] == 4) syn->bits |= (1<<0); - if (j&2) syn->bits |= (1<<1); + if (j&1) if (clipmovecount[snum] == 4) syn->bits |= BIT(SK_JUMP); + if (j&2) syn->bits |= BIT(SK_CROUCH); //Strafe attack daang = getangle(x2-x1,y2-y1); @@ -5732,8 +5734,8 @@ void computergetinput(int snum, input_t *syn) syn->fvel += ((sintable[(daang+1024)&2047]*i)>>17); syn->svel += ((sintable[(daang+512)&2047]*i)>>17); - if ((clipmovecount[snum]&31) == 2) syn->bits |= (1<<29); - if ((clipmovecount[snum]&31) == 17) syn->bits |= (1<<22); + if ((clipmovecount[snum]&31) == 2) syn->bits |= BIT(SK_OPEN); + if ((clipmovecount[snum]&31) == 17) syn->bits |= BIT(SK_QUICK_KICK); if (clipmovecount[snum] > 32) { goalsect[snum] = -1; diff --git a/polymer/eduke32/source/premap.c b/polymer/eduke32/source/premap.c index 190770952..a3bac8aef 100644 --- a/polymer/eduke32/source/premap.c +++ b/polymer/eduke32/source/premap.c @@ -33,21 +33,21 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern char pow2char[]; extern int everyothertime; -static int which_palookup = 9; -int g_NumPalettes; -short spritecache[MAXTILES][3]; +static int g_whichPalForPlayer = 9; +int g_numPalettes; +short SpriteCacheList[MAXTILES][3]; static char precachehightile[2][MAXTILES>>3]; -static int precachecount; +static int g_precacheCount; extern char *duke3dgrpstring; -extern int leveltexttime; +extern int g_levelTextTime; static void tloadtile(int tilenume, int type) { if ((picanm[tilenume]&63) < 1) { - if (!(gotpic[tilenume>>3] & pow2char[tilenume&7])) precachecount++; + if (!(gotpic[tilenume>>3] & pow2char[tilenume&7])) g_precacheCount++; gotpic[tilenume>>3] |= pow2char[tilenume&7]; precachehightile[(unsigned char)type][tilenume>>3] |= pow2char[tilenume&7]; return; @@ -68,27 +68,27 @@ static void tloadtile(int tilenume, int type) } for (;i<=j;i++) { - if (!(gotpic[i>>3] & pow2char[i&7])) precachecount++; + if (!(gotpic[i>>3] & pow2char[i&7])) g_precacheCount++; gotpic[i>>3] |= pow2char[i&7]; precachehightile[(unsigned char)type][i>>3] |= pow2char[i&7]; } } } -static void cachespritenum(int i) +static void G_CacheSpriteNum(int i) { char maxc; int j; - if (ud.monsters_off && badguy(&sprite[i])) return; + if (ud.monsters_off && A_CheckEnemySprite(&sprite[i])) return; maxc = 1; - if (spritecache[PN][0] == PN) - for (j = PN; j <= spritecache[PN][1]; j++) + if (SpriteCacheList[PN][0] == PN) + for (j = PN; j <= SpriteCacheList[PN][1]; j++) tloadtile(j,1); - switch (dynamictostatic[PN]) + switch (DynamicTileMap[PN]) { case HYDRENT__STATIC: tloadtile(BROKEFIREHYDRENT,1); @@ -214,16 +214,16 @@ static void cachespritenum(int i) for (j = PN; j < (PN+maxc); j++) tloadtile(j,1); } -static void cachegoodsprites(void) +static void G_PrecacheSprites(void) { int i,j; for (i=0;i=0;i--) if (g_sounds[i].ptr == 0) { j++; @@ -325,11 +326,11 @@ static void precachenecessarysounds(void) handleevents(); getpackets(); } - getsound(i); + CacheSound(i); } } -static void dofrontscreens(char *statustext) +static void G_DoLoadScreen(char *statustext) { int i=0,j; @@ -338,17 +339,17 @@ static void dofrontscreens(char *statustext) if (!statustext) { //g_player[myconnectindex].ps->palette = palette; - setgamepalette(g_player[myconnectindex].ps, palette, 1); // JBF 20040308 + SetGamePalette(g_player[myconnectindex].ps, palette, 1); // JBF 20040308 fadepal(0,0,0, 0,64,7); i = ud.screen_size; ud.screen_size = 0; - vscrn(); + G_UpdateScreenArea(); clearview(0L); } - SetGameVarID(g_iReturnVarID,LOADSCREEN, -1, -1); - OnEvent(EVENT_GETLOADTILE, -1, myconnectindex, -1); - j = GetGameVarID(g_iReturnVarID, -1, -1); + Gv_SetVar(g_iReturnVarID,LOADSCREEN, -1, -1); + X_OnEvent(EVENT_GETLOADTILE, -1, myconnectindex, -1); + j = Gv_GetVar(g_iReturnVarID, -1, -1); rotatesprite(320<<15,200<<15,65536L,0,j > MAXTILES-1?j-MAXTILES:j,0,0,2+8+64,0,0,xdim-1,ydim-1); if (j > MAXTILES-1) { @@ -363,13 +364,13 @@ static void dofrontscreens(char *statustext) else { menutext(160,90,0,0,"LOADING"); - if (map[(ud.volume_number*MAXLEVELS) + ud.level_number].name != NULL) - menutext(160,90+16+8,0,0,map[(ud.volume_number*MAXLEVELS) + ud.level_number].name); + if (MapInfo[(ud.volume_number*MAXLEVELS) + ud.level_number].name != NULL) + menutext(160,90+16+8,0,0,MapInfo[(ud.volume_number*MAXLEVELS) + ud.level_number].name); } if (statustext) gametext(160,180,statustext,0,2+8+16); - OnEvent(EVENT_DISPLAYLOADINGSCREEN, g_player[screenpeek].ps->i, screenpeek, -1); + X_OnEvent(EVENT_DISPLAYLOADINGSCREEN, g_player[screenpeek].ps->i, screenpeek, -1); nextpage(); if (!statustext) @@ -386,12 +387,12 @@ static void dofrontscreens(char *statustext) { clearview(0L); //g_player[myconnectindex].ps->palette = palette; - //palto(0,0,0,0); - setgamepalette(g_player[myconnectindex].ps, palette, 0); // JBF 20040308 + //G_FadePalette(0,0,0,0); + SetGamePalette(g_player[myconnectindex].ps, palette, 0); // JBF 20040308 } - SetGameVarID(g_iReturnVarID,LOADSCREEN, -1, -1); - OnEvent(EVENT_GETLOADTILE, -1, myconnectindex, -1); - j = GetGameVarID(g_iReturnVarID, -1, -1); + Gv_SetVar(g_iReturnVarID,LOADSCREEN, -1, -1); + X_OnEvent(EVENT_GETLOADTILE, -1, myconnectindex, -1); + j = Gv_GetVar(g_iReturnVarID, -1, -1); rotatesprite(320<<15,200<<15,65536L,0,j > MAXTILES-1?j-MAXTILES:j,0,0,2+8+64,0,0,xdim-1,ydim-1); if (j > MAXTILES-1) { @@ -400,15 +401,15 @@ static void dofrontscreens(char *statustext) } menutext(160,105,0,0,"LOADING..."); if (statustext) gametext(160,180,statustext,0,2+8+16); - OnEvent(EVENT_DISPLAYLOADINGSCREEN, g_player[screenpeek].ps->i, screenpeek, -1); + X_OnEvent(EVENT_DISPLAYLOADINGSCREEN, g_player[screenpeek].ps->i, screenpeek, -1); nextpage(); } } -extern void SetCrosshairColor(int r, int g, int b); -extern palette_t crosshair_colors; +extern void G_SetCrosshairColor(int r, int g, int b); +extern palette_t CrosshairColors; -void cacheit(void) +void G_CacheMapData(void) { int i,j,pc=0; int tc; @@ -418,17 +419,17 @@ void cacheit(void) return; MUSIC_Pause(); - if (map[MAXVOLUMES*MAXLEVELS+2].musicfn1) + if (MapInfo[MAXVOLUMES*MAXLEVELS+2].musicfn1) { MUSIC_StopSong(); - playmusic(&env_music_fn[2][0],MAXVOLUMES*MAXLEVELS+2); // loadmus + S_PlayMusic(&EnvMusicFilename[2][0],MAXVOLUMES*MAXLEVELS+2); // loadmus } starttime = getticks(); - precachenecessarysounds(); + G_PrecacheSounds(); - cachegoodsprites(); + G_PrecacheSprites(); for (i=0;i= 0) { if (sprite[j].xrepeat != 0 && sprite[j].yrepeat != 0 && (sprite[j].cstat&32768) == 0) - cachespritenum(j); + G_CacheSpriteNum(j); j = nextspritesect[j]; } } @@ -500,8 +501,8 @@ void cacheit(void) } if (totalclock - tc > TICRATE/4) { - sprintf(tempbuf,"Loading resources... %d%%\n",min(100,100*pc/precachecount)); - dofrontscreens(tempbuf); + sprintf(tempbuf,"Loading resources... %d%%\n",min(100,100*pc/g_precacheCount)); + G_DoLoadScreen(tempbuf); tc = totalclock; } } @@ -519,7 +520,7 @@ void xyzmirror(int i,int wn) drawrooms(SX,SY,SZ,SA,100+sprite[i].shade,SECT); display_mirror = 1; - animatesprites(SX,SY,SA,65536L); + G_DoSpriteAnimations(SX,SY,SA,65536L); display_mirror = 0; drawmasks(); @@ -528,7 +529,7 @@ void xyzmirror(int i,int wn) invalidatetile(wn,-1,255); } -void vscrn(void) +void G_UpdateScreenArea(void) { int i, j, ss, x1, x2, y1, y2; @@ -543,11 +544,11 @@ void vscrn(void) y1 = ss; y2 = 200; - if (ud.screen_size > 0 && (gametype_flags[ud.coop]&GAMETYPE_FLAG_FRAGBAR) && ud.multimode > 1) + if (ud.screen_size > 0 && (GametypeFlags[ud.coop]&GAMETYPE_FRAGBAR) && ud.multimode > 1) { j = 0; - for (i=connecthead;i>=0;i=connectpoint2[i]) - if (i > j) j = i; + TRAVERSE_CONNECT(i) + if (i > j) j = i; if (j >= 1) y1 += 8; if (j >= 4) y1 += 8; @@ -563,31 +564,31 @@ void vscrn(void) setview(x1,y1,x2-1,y2-1); - GetCrosshairColor(); - SetCrosshairColor(crosshair_colors.r, crosshair_colors.g, crosshair_colors.b); + G_GetCrosshairColor(); + G_SetCrosshairColor(CrosshairColors.r, CrosshairColors.g, CrosshairColors.b); pub = NUMPAGES; pus = NUMPAGES; } -void pickrandomspot(int snum) +void P_RandomSpawnPoint(int snum) { - player_struct *p = g_player[snum].ps; + DukePlayer_t *p = g_player[snum].ps; int i=snum,j,k; unsigned int dist,pdist = -1; - if (ud.multimode > 1 && !(gametype_flags[ud.coop] & GAMETYPE_FLAG_FIXEDRESPAWN)) + if (ud.multimode > 1 && !(GametypeFlags[ud.coop] & GAMETYPE_FIXEDRESPAWN)) { - i = TRAND%numplayersprites; - if (gametype_flags[ud.coop] & GAMETYPE_FLAG_TDMSPAWN) + i = krand()%g_numPlayerSprites; + if (GametypeFlags[ud.coop] & GAMETYPE_TDMSPAWN) { for (j=0;jteam == p->team && sprite[g_player[j].ps->i].extra > 0) { - for (k=0;kposx-g_PlayerSpawnPoints[k].ox,g_player[j].ps->posy-g_PlayerSpawnPoints[k].oy); + dist = FindDistance2D(g_player[j].ps->posx-g_playerSpawnPoints[k].ox,g_player[j].ps->posy-g_playerSpawnPoints[k].oy); if (dist < pdist) i = k, pdist = dist; } @@ -597,16 +598,16 @@ void pickrandomspot(int snum) } } - p->bobposx = p->oposx = p->posx = g_PlayerSpawnPoints[i].ox; - p->bobposy = p->oposy = p->posy = g_PlayerSpawnPoints[i].oy; - p->oposz = p->posz = g_PlayerSpawnPoints[i].oz; - p->ang = g_PlayerSpawnPoints[i].oa; - p->cursectnum = g_PlayerSpawnPoints[i].os; + p->bobposx = p->oposx = p->posx = g_playerSpawnPoints[i].ox; + p->bobposy = p->oposy = p->posy = g_playerSpawnPoints[i].oy; + p->oposz = p->posz = g_playerSpawnPoints[i].oz; + p->ang = g_playerSpawnPoints[i].oa; + p->cursectnum = g_playerSpawnPoints[i].os; } -static void resetplayerstats(int snum) +static void P_ResetStatus(int snum) { - player_struct *p = g_player[snum].ps; + DukePlayer_t *p = g_player[snum].ps; ud.show_help = 0; ud.showallmap = 0; @@ -654,7 +655,7 @@ static void resetplayerstats(int snum) p->rapid_fire_hold = 0; p->toggle_key_flag = 0; p->access_spritenum = -1; - if (ud.multimode > 1 && (gametype_flags[ud.coop] & GAMETYPE_FLAG_ACCESSATSTART)) + if (ud.multimode > 1 && (GametypeFlags[ud.coop] & GAMETYPE_ACCESSATSTART)) p->got_access = 7; else p->got_access = 0; p->random_club_frame= 0; @@ -708,14 +709,14 @@ static void resetplayerstats(int snum) p->movement_lock = 0; - setpal(p); - OnEvent(EVENT_RESETPLAYER, p->i, snum, -1); + P_UpdateScreenPal(p); + X_OnEvent(EVENT_RESETPLAYER, p->i, snum, -1); } -void resetweapons(int snum) +void P_ResetWeapons(int snum) { int weapon; - player_struct *p = g_player[snum].ps; + DukePlayer_t *p = g_player[snum].ps; for (weapon = PISTOL_WEAPON; weapon < MAX_WEAPONS; weapon++) p->gotweapon[weapon] = 0; @@ -734,12 +735,12 @@ void resetweapons(int snum) p->show_empty_weapon= 0; p->last_pissed_time = 0; p->holster_weapon = 0; - OnEvent(EVENT_RESETWEAPONS, p->i, snum, -1); + X_OnEvent(EVENT_RESETWEAPONS, p->i, snum, -1); } -void resetinventory(int snum) +void P_ResetInventory(int snum) { - player_struct *p = g_player[snum].ps; + DukePlayer_t *p = g_player[snum].ps; p->inven_icon = 0; p->boot_amount = 0; @@ -749,22 +750,22 @@ void resetinventory(int snum) p->heat_on = 0; p->jetpack_on = 0; p->jetpack_amount = 0; - p->shield_amount = start_armour_amount; + p->shield_amount = g_startArmorAmount; p->holoduke_on = -1; p->holoduke_amount = 0; p->firstaid_amount = 0; p->steroids_amount = 0; p->inven_icon = 0; - OnEvent(EVENT_RESETINVENTORY, p->i, snum, -1); + X_OnEvent(EVENT_RESETINVENTORY, p->i, snum, -1); } static void resetprestat(int snum,int g) { - player_struct *p = g_player[snum].ps; + DukePlayer_t *p = g_player[snum].ps; int i; - spriteqloc = 0; - for (i=0;ihbomb_on = 0; p->cheat_phase = 0; @@ -788,25 +789,25 @@ static void resetprestat(int snum,int g) p->visibility = ud.const_visibility; screenpeek = myconnectindex; - numanimwalls = 0; - numcyclers = 0; - animatecnt = 0; + g_numAnimWalls = 0; + g_numCyclers = 0; + g_animateCount = 0; parallaxtype = 0; - randomseed = 17L; + randomseed = 1996; ud.pause_on = 0; ud.camerasprite =-1; ud.eog = 0; tempwallptr = 0; camsprite =-1; - earthquaketime = 0; + g_earthquakeTime = 0; - numinterpolations = 0; + g_numInterpolations = 0; startofdynamicinterpolations = 0; - if (((g&MODE_EOL) != MODE_EOL && numplayers < 2) || (!(gametype_flags[ud.coop]&GAMETYPE_FLAG_PRESERVEINVENTORYDEATH) && numplayers > 1)) + if (((g&MODE_EOL) != MODE_EOL && numplayers < 2) || (!(GametypeFlags[ud.coop]&GAMETYPE_PRESERVEINVENTORYDEATH) && numplayers > 1)) { - resetweapons(snum); - resetinventory(snum); + P_ResetWeapons(snum); + P_ResetInventory(snum); } else if (p->curr_weapon == HANDREMOTE_WEAPON) { @@ -828,7 +829,7 @@ static void setupbackdrop(short sky) if (parallaxyscale != 65536L) parallaxyscale = 32768; - switch (dynamictostatic[sky]) + switch (DynamicTileMap[sky]) { case CLOUDYOCEAN__STATIC: parallaxyscale = 65536L; @@ -873,7 +874,7 @@ static void prelevel(char g) clearbufbyte(show2dsprite,sizeof(show2dsprite),0L); resetprestat(0,g); - numclouds = 0; + g_numClouds = 0; for (i=0;ione_parallax_sectnum == -1) g_player[0].ps->one_parallax_sectnum = i; @@ -919,19 +920,19 @@ static void prelevel(char g) } } - i = headspritestat[0]; + i = headspritestat[STAT_DEFAULT]; while (i >= 0) { nexti = nextspritestat[i]; - ResetActorGameVars(i); - LoadActor(i); - OnEvent(EVENT_LOADACTOR, i, -1, -1); + A_ResetGameVars(i); + A_LoadActor(i); + X_OnEvent(EVENT_LOADACTOR, i, -1, -1); if (sprite[i].lotag == -1 && (sprite[i].cstat&16)) { g_player[0].ps->exitx = SX; g_player[0].ps->exity = SY; } - else switch (dynamictostatic[PN]) + else switch (DynamicTileMap[PN]) { case GPSPEED__STATIC: sector[SECT].extra = SLT; @@ -939,18 +940,18 @@ static void prelevel(char g) break; case CYCLER__STATIC: - if (numcyclers >= MAXCYCLERS) + if (g_numCyclers >= MAXCYCLERS) { Bsprintf(tempbuf,"\nToo many cycling sectors (%d max).",MAXCYCLERS); - gameexit(tempbuf); + G_GameExit(tempbuf); } - cyclers[numcyclers][0] = SECT; - cyclers[numcyclers][1] = SLT; - cyclers[numcyclers][2] = SS; - cyclers[numcyclers][3] = sector[SECT].floorshade; - cyclers[numcyclers][4] = SHT; - cyclers[numcyclers][5] = (SA == 1536); - numcyclers++; + cyclers[g_numCyclers][0] = SECT; + cyclers[g_numCyclers][1] = SLT; + cyclers[g_numCyclers][2] = SS; + cyclers[g_numCyclers][3] = sector[SECT].floorshade; + cyclers[g_numCyclers][4] = SHT; + cyclers[g_numCyclers][5] = (SA == 1536); + g_numCyclers++; deletesprite(i); break; @@ -974,7 +975,7 @@ static void prelevel(char g) { if (PN == SECTOREFFECTOR && SLT == 14) continue; - spawn(-1,i); + A_Spawn(-1,i); } } @@ -982,15 +983,15 @@ static void prelevel(char g) if (sprite[i].statnum < MAXSTATUS) { if (PN == SECTOREFFECTOR && SLT == 14) - spawn(-1,i); + A_Spawn(-1,i); } lotaglist = 0; - i = headspritestat[0]; + i = headspritestat[STAT_DEFAULT]; while (i >= 0) { - switch (dynamictostatic[PN-1]) + switch (DynamicTileMap[PN-1]) { case DIPSWITCH__STATIC: case DIPSWITCH2__STATIC: @@ -1014,13 +1015,13 @@ static void prelevel(char g) lotags[lotaglist] = SLT; lotaglist++; if (lotaglist > MAXSPRITES-1) - gameexit("\nToo many switches."); + G_GameExit("\nToo many switches."); - j = headspritestat[3]; + j = headspritestat[STAT_EFFECTOR]; while (j >= 0) { if (sprite[j].lotag == 12 && sprite[j].hitag == SLT) - hittype[j].temp_data[0] = 1; + ActorExtra[j].temp_data[0] = 1; j = nextspritestat[j]; } } @@ -1029,7 +1030,7 @@ static void prelevel(char g) i = nextspritestat[i]; } - mirrorcnt = 0; + g_mirrorCount = 0; for (i = 0; i < numwalls; i++) { @@ -1040,39 +1041,39 @@ static void prelevel(char g) { j = wal->nextsector; - if (mirrorcnt > 63) - gameexit("\nToo many mirrors (64 max.)"); + if (g_mirrorCount > 63) + G_GameExit("\nToo many mirrors (64 max.)"); if ((j >= 0) && sector[j].ceilingpicnum != MIRROR) { sector[j].ceilingpicnum = MIRROR; sector[j].floorpicnum = MIRROR; - mirrorwall[mirrorcnt] = i; - mirrorsector[mirrorcnt] = j; - mirrorcnt++; + g_mirrorWall[g_mirrorCount] = i; + g_mirrorSector[g_mirrorCount] = j; + g_mirrorCount++; continue; } } - if (numanimwalls >= MAXANIMWALLS) + if (g_numAnimWalls >= MAXANIMWALLS) { Bsprintf(tempbuf,"\nToo many 'anim' walls (%d max).",MAXANIMWALLS); - gameexit(tempbuf); + G_GameExit(tempbuf); } - animwall[numanimwalls].tag = 0; - animwall[numanimwalls].wallnum = 0; + animwall[g_numAnimWalls].tag = 0; + animwall[g_numAnimWalls].wallnum = 0; switchpicnum = wal->overpicnum; if ((wal->overpicnum > W_FORCEFIELD)&&(wal->overpicnum <= W_FORCEFIELD+2)) { switchpicnum = W_FORCEFIELD; } - switch (dynamictostatic[switchpicnum]) + switch (DynamicTileMap[switchpicnum]) { case FANSHADOW__STATIC: case FANSPRITE__STATIC: wall->cstat |= 65; - animwall[numanimwalls].wallnum = i; - numanimwalls++; + animwall[g_numAnimWalls].wallnum = i; + g_numAnimWalls++; break; case W_FORCEFIELD__STATIC: @@ -1090,15 +1091,15 @@ static void prelevel(char g) case BIGFORCE__STATIC: - animwall[numanimwalls].wallnum = i; - numanimwalls++; + animwall[g_numAnimWalls].wallnum = i; + g_numAnimWalls++; continue; } wal->extra = -1; - switch (dynamictostatic[wal->picnum]) + switch (DynamicTileMap[wal->picnum]) { case WATERTILE2__STATIC: for (j=0;j<3;j++) @@ -1113,18 +1114,18 @@ static void prelevel(char g) case W_TECHWALL2__STATIC: case W_TECHWALL3__STATIC: case W_TECHWALL4__STATIC: - animwall[numanimwalls].wallnum = i; - // animwall[numanimwalls].tag = -1; - numanimwalls++; + animwall[g_numAnimWalls].wallnum = i; + // animwall[g_numAnimWalls].tag = -1; + g_numAnimWalls++; break; case SCREENBREAK6__STATIC: case SCREENBREAK7__STATIC: case SCREENBREAK8__STATIC: for (j=SCREENBREAK6;jextra = wal->picnum; - animwall[numanimwalls].tag = -1; + animwall[g_numAnimWalls].tag = -1; if (ud.lockout) { if (wal->picnum == FEMPIC1) @@ -1140,9 +1141,9 @@ static void prelevel(char g) else wal->picnum = SCREENBREAK6; } - animwall[numanimwalls].wallnum = i; - animwall[numanimwalls].tag = wal->picnum; - numanimwalls++; + animwall[g_numAnimWalls].wallnum = i; + animwall[g_numAnimWalls].tag = wal->picnum; + g_numAnimWalls++; break; case SCREENBREAK1__STATIC: @@ -1163,75 +1164,75 @@ static void prelevel(char g) case SCREENBREAK18__STATIC: case SCREENBREAK19__STATIC: - animwall[numanimwalls].wallnum = i; - animwall[numanimwalls].tag = wal->picnum; - numanimwalls++; + animwall[g_numAnimWalls].wallnum = i; + animwall[g_numAnimWalls].tag = wal->picnum; + g_numAnimWalls++; break; } } //Invalidate textures in sector behind mirror - for (i=0;i= 0 && ud.config.FXDevice >= 0 && ud.config.SoundToggle) + if (g_skillSoundID >= 0 && ud.config.FXDevice >= 0 && ud.config.SoundToggle) { - while (issoundplaying(-1,globalskillsound)) + while (S_CheckSoundPlaying(-1,g_skillSoundID)) { handleevents(); getpackets(); } } - globalskillsound = -1; + g_skillSoundID = -1; waitforeverybody(); ready2send = 0; - if (ud.m_recstat != 2 && ud.last_level >= 0 && ud.multimode > 1 && (ud.coop&GAMETYPE_FLAG_SCORESHEET)) - dobonus(1); + if (ud.m_recstat != 2 && ud.last_level >= 0 && ud.multimode > 1 && (ud.coop&GAMETYPE_SCORESHEET)) + G_BonusScreen(1); if (ln == 0 && vn == 3 && ud.multimode < 2 && ud.lockout == 0) { - playmusic(&env_music_fn[1][0],MAXVOLUMES*MAXLEVELS+1); + S_PlayMusic(&EnvMusicFilename[1][0],MAXVOLUMES*MAXLEVELS+1); flushperms(); setview(0,0,xdim-1,ydim-1); clearview(0L); nextpage(); - playanm("vol41a.anm",6); + G_PlayAnim("vol41a.anm",6); clearview(0L); nextpage(); - playanm("vol42a.anm",7); - playanm("vol43a.anm",9); + G_PlayAnim("vol42a.anm",7); + G_PlayAnim("vol43a.anm",9); clearview(0L); nextpage(); FX_StopAllSounds(); } - show_shareware = 26*34; + g_showShareware = 26*34; ud.level_number = ln; ud.volume_number = vn; @@ -1241,22 +1242,22 @@ void newgame(int vn,int ln,int sk) parallaxyscale = 0; ud.last_level = -1; - lastsavedpos = -1; + g_lastSaveSlot = -1; p->zoom = 768; p->gm = 0; //AddLog("Newgame"); - ResetGameVars(); + Gv_ResetVarsToDefault(); - InitGameVarPointers(); + Gv_InitWeaponPointers(); - ResetSystemDefaults(); + Gv_ResetSystemDefaults(); for (i=0;i<(MAXVOLUMES*MAXLEVELS);i++) - if (map[i].savedstate) + if (MapInfo[i].savedstate) { - Bfree(map[i].savedstate); - map[i].savedstate = NULL; + Bfree(MapInfo[i].savedstate); + MapInfo[i].savedstate = NULL; } if (ud.m_coop != 1) @@ -1293,10 +1294,10 @@ void newgame(int vn,int ln,int sk) connecthead = 0; connectpoint2[0] = -1; } - OnEvent(EVENT_NEWGAME, g_player[screenpeek].ps->i, screenpeek, -1); + X_OnEvent(EVENT_NEWGAME, g_player[screenpeek].ps->i, screenpeek, -1); } -int getteampal(int team) +int G_GetTeamPalette(int team) { switch (team) { @@ -1320,15 +1321,15 @@ static void resetpspritevars(char g) char aimmode[MAXPLAYERS],autoaim[MAXPLAYERS],weaponswitch[MAXPLAYERS]; STATUSBARTYPE tsbar[MAXPLAYERS]; - EGS(g_player[0].ps->cursectnum,g_player[0].ps->posx,g_player[0].ps->posy,g_player[0].ps->posz, - APLAYER,0,0,0,g_player[0].ps->ang,0,0,0,10); + A_InsertSprite(g_player[0].ps->cursectnum,g_player[0].ps->posx,g_player[0].ps->posy,g_player[0].ps->posz, + APLAYER,0,0,0,g_player[0].ps->ang,0,0,0,10); if (ud.recstat != 2) for (i=0;iaim_mode; autoaim[i] = g_player[i].ps->auto_aim; weaponswitch[i] = g_player[i].ps->weaponswitch; - if (ud.multimode > 1 && (gametype_flags[ud.coop]&GAMETYPE_FLAG_PRESERVEINVENTORYDEATH) && ud.last_level >= 0) + if (ud.multimode > 1 && (GametypeFlags[ud.coop]&GAMETYPE_PRESERVEINVENTORYDEATH) && ud.last_level >= 0) { for (j=0;jaim_mode = aimmode[i]; g_player[i].ps->auto_aim = autoaim[i]; g_player[i].ps->weaponswitch = weaponswitch[i]; - if (ud.multimode > 1 && (gametype_flags[ud.coop]&GAMETYPE_FLAG_PRESERVEINVENTORYDEATH) && ud.last_level >= 0) + if (ud.multimode > 1 && (GametypeFlags[ud.coop]&GAMETYPE_PRESERVEINVENTORYDEATH) && ud.last_level >= 0) { for (j=0;j= 0) { nexti = nextspritestat[i]; s = &sprite[i]; - if (numplayersprites == MAXPLAYERS) - gameexit("\nToo many player sprites (max 16.)"); + if (g_numPlayerSprites == MAXPLAYERS) + G_GameExit("\nToo many player sprites (max 16.)"); - /* if (numplayersprites == 0) + /* if (g_numPlayerSprites == 0) { firstx = g_player[0].ps->posx; firsty = g_player[0].ps->posy; }*/ - g_PlayerSpawnPoints[(unsigned char)numplayersprites].ox = s->x; - g_PlayerSpawnPoints[(unsigned char)numplayersprites].oy = s->y; - g_PlayerSpawnPoints[(unsigned char)numplayersprites].oz = s->z; - g_PlayerSpawnPoints[(unsigned char)numplayersprites].oa = s->ang; - g_PlayerSpawnPoints[(unsigned char)numplayersprites].os = s->sectnum; + g_playerSpawnPoints[(unsigned char)g_numPlayerSprites].ox = s->x; + g_playerSpawnPoints[(unsigned char)g_numPlayerSprites].oy = s->y; + g_playerSpawnPoints[(unsigned char)g_numPlayerSprites].oz = s->z; + g_playerSpawnPoints[(unsigned char)g_numPlayerSprites].oa = s->ang; + g_playerSpawnPoints[(unsigned char)g_numPlayerSprites].os = s->sectnum; - numplayersprites++; + g_numPlayerSprites++; if (j >= 0) { s->owner = i; @@ -1423,13 +1424,13 @@ static void resetpspritevars(char g) { g_player[j].ps->last_extra = g_player[j].ps->max_player_health; s->extra = g_player[j].ps->max_player_health; - g_player[j].ps->runspeed = dukefriction; + g_player[j].ps->runspeed = g_playerFriction; } else s->extra = g_player[j].ps->last_extra; s->yvel = j; - if (!g_player[j].pcolor && ud.multimode > 1 && !(gametype_flags[ud.coop] & GAMETYPE_FLAG_TDM)) + if (!g_player[j].pcolor && ud.multimode > 1 && !(GametypeFlags[ud.coop] & GAMETYPE_TDM)) { if (s->pal == 0) { @@ -1437,17 +1438,17 @@ static void resetpspritevars(char g) for (;kpalookup) + if (g_whichPalForPlayer == g_player[k].ps->palookup) { - which_palookup++; - if (which_palookup >= 17) - which_palookup = 9; + g_whichPalForPlayer++; + if (g_whichPalForPlayer >= 17) + g_whichPalForPlayer = 9; k=0; } } - g_player[j].pcolor = s->pal = g_player[j].ps->palookup = which_palookup++; - if (which_palookup >= 17) - which_palookup = 9; + g_player[j].pcolor = s->pal = g_player[j].ps->palookup = g_whichPalForPlayer++; + if (g_whichPalForPlayer >= 17) + g_whichPalForPlayer = 9; } else g_player[j].pcolor = g_player[j].ps->palookup = s->pal; } @@ -1455,9 +1456,9 @@ static void resetpspritevars(char g) { int k = g_player[j].pcolor; - if (gametype_flags[ud.coop] & GAMETYPE_FLAG_TDM) + if (GametypeFlags[ud.coop] & GAMETYPE_TDM) { - k = getteampal(g_player[j].pteam); + k = G_GetTeamPalette(g_player[j].pteam); g_player[j].ps->team = g_player[j].pteam; } s->pal = g_player[j].ps->palookup = k; @@ -1465,11 +1466,11 @@ static void resetpspritevars(char g) g_player[j].ps->i = i; g_player[j].ps->frag_ps = j; - hittype[i].owner = i; + ActorExtra[i].owner = i; - hittype[i].bposx = g_player[j].ps->bobposx = g_player[j].ps->oposx = g_player[j].ps->posx = s->x; - hittype[i].bposy = g_player[j].ps->bobposy = g_player[j].ps->oposy = g_player[j].ps->posy = s->y; - hittype[i].bposz = g_player[j].ps->oposz = g_player[j].ps->posz = s->z; + ActorExtra[i].bposx = g_player[j].ps->bobposx = g_player[j].ps->oposx = g_player[j].ps->posx = s->x; + ActorExtra[i].bposy = g_player[j].ps->bobposy = g_player[j].ps->oposy = g_player[j].ps->posy = s->y; + ActorExtra[i].bposz = g_player[j].ps->oposz = g_player[j].ps->posz = s->z; g_player[j].ps->oang = g_player[j].ps->ang = s->ang; updatesector(s->x,s->y,&g_player[j].ps->cursectnum); @@ -1493,7 +1494,7 @@ static inline void clearfrags(void) } } -void resettimevars(void) +void G_ResetTimers(void) { vel = svel = angvel = horiz = 0; @@ -1502,8 +1503,8 @@ void resettimevars(void) ototalclock = 0L; lockclock = 0L; ready2send = 1; - leveltexttime = 85; - MoveThingsCount = 0; + g_levelTextTime = 85; + g_moveThingsCount = 0; } void waitforeverybody() @@ -1511,20 +1512,21 @@ void waitforeverybody() int i; if (numplayers < 2) return; - packbuf[0] = 250; + packbuf[0] = PACKET_TYPE_PLAYER_READY; g_player[myconnectindex].playerreadyflag++; - if ((networkmode == 1) || (!networkmode && (myconnectindex != connecthead))) - for (i=connecthead;i>=0;i=connectpoint2[i]) - { - if (i != myconnectindex) sendpacket(i,packbuf,1); - if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master - } + // if we're a peer or slave, not a master + if ((g_networkBroadcastMode == 1) || (!g_networkBroadcastMode && (myconnectindex != connecthead))) + TRAVERSE_CONNECT(i) + { + if (i != myconnectindex) sendpacket(i,packbuf,1); + if ((!g_networkBroadcastMode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master + } if (ud.multimode > 1) { - setgamepalette(g_player[myconnectindex].ps, titlepal, 11); + SetGamePalette(g_player[myconnectindex].ps, titlepal, 11); rotatesprite(0,0,65536L,0,BETASCREEN,0,0,2+8+16+64,0,0,xdim-1,ydim-1); rotatesprite(160<<16,(104)<<16,60<<10,0,DUKENUKEM,0,0,2+8,0,0,xdim-1,ydim-1); @@ -1538,42 +1540,39 @@ void waitforeverybody() while (1) { - idle(); - /* - sampletimer(); - handleevents(); - AudioUpdate(); - */ - - if (quitevent || keystatus[1]) gameexit(""); + if (quitevent || keystatus[1]) G_GameExit(""); getpackets(); - for (i=connecthead;i>=0;i=connectpoint2[i]) + TRAVERSE_CONNECT(i) { if (g_player[i].playerreadyflag < g_player[myconnectindex].playerreadyflag) break; - if ((!networkmode) && (myconnectindex != connecthead)) + if ((!g_networkBroadcastMode) && (myconnectindex != connecthead)) { + // we're a slave i = -1; break; } //slaves in M/S mode only wait for master } if (i < 0) { - if (!networkmode && myconnectindex == connecthead) - for (i=connecthead;i>=0;i=connectpoint2[i]) - { - packbuf[0] = 250; - if (i != myconnectindex) sendpacket(i,packbuf,1); - } + // master sends ready packet once it hears from all slaves + if (!g_networkBroadcastMode && myconnectindex == connecthead) + TRAVERSE_CONNECT(i) + { + packbuf[0] = PACKET_TYPE_PLAYER_READY; + if (i != myconnectindex) sendpacket(i,packbuf,1); + } - setgamepalette(g_player[myconnectindex].ps, palette, 11); + SetGamePalette(g_player[myconnectindex].ps, palette, 11); return; } } } extern int jump_input; +extern char sync_first[MAXSYNCBYTES][60]; +extern int sync_found; void clearfifo(void) { @@ -1582,16 +1581,19 @@ void clearfifo(void) syncvaltail = 0L; syncvaltottail = 0L; memset(&syncstat, 0, sizeof(syncstat)); + memset(&sync_first, 0, sizeof(sync_first)); + sync_found = 0; bufferjitter = 1; mymaxlag = otherminlag = 0; jump_input = 0; - movefifoplc = movefifosendplc = fakemovefifoplc = 0; + movefifoplc = movefifosendplc = predictfifoplc = 0; avgfvel = avgsvel = avgavel = avghorz = avgbits = avgextbits = 0; otherminlag = mymaxlag = 0; clearbufbyte(&loc,sizeof(input_t),0L); clearbufbyte(&inputfifo,sizeof(input_t)*MOVEFIFOSIZ*MAXPLAYERS,0L); + for (;iposx; myy = omyy = g_player[myconnectindex].ps->posy; @@ -1625,14 +1627,14 @@ void resetmys(void) extern int voting, vote_map, vote_episode; -void getlevelfromfilename(const char *fn, char *volume, char *level) +void G_FindLevelForFilename(const char *fn, char *volume, char *level) { for (*volume=0;*volumeposx, &g_player[0].ps->posy, &g_player[0].ps->posz, &g_player[0].ps->ang,&g_player[0].ps->cursectnum) == -1) { OSD_Printf(OSD_ERROR "Map '%s' not found!\n",boardfilename); - //gameexit(tempbuf); + //G_GameExit(tempbuf); return 1; } @@ -1765,16 +1763,16 @@ int enterlevel(int g) if (fil > -1) { kclose(fil); - if (map[ud.m_level_number].musicfn1 == NULL) - map[ud.m_level_number].musicfn1 = Bcalloc(Bstrlen(levname)+1,sizeof(char)); - else if ((Bstrlen(levname)+1) > sizeof(map[ud.m_level_number].musicfn1)) - map[ud.m_level_number].musicfn1 = Brealloc(map[ud.m_level_number].musicfn1,(Bstrlen(levname)+1)); - Bstrcpy(map[ud.m_level_number].musicfn1,levname); + if (MapInfo[ud.m_level_number].musicfn1 == NULL) + MapInfo[ud.m_level_number].musicfn1 = Bcalloc(Bstrlen(levname)+1,sizeof(char)); + else if ((Bstrlen(levname)+1) > sizeof(MapInfo[ud.m_level_number].musicfn1)) + MapInfo[ud.m_level_number].musicfn1 = Brealloc(MapInfo[ud.m_level_number].musicfn1,(Bstrlen(levname)+1)); + Bstrcpy(MapInfo[ud.m_level_number].musicfn1,levname); } - else if (map[ud.m_level_number].musicfn1 != NULL) + else if (MapInfo[ud.m_level_number].musicfn1 != NULL) { - Bfree(map[ud.m_level_number].musicfn1); - map[ud.m_level_number].musicfn1 = NULL; + Bfree(MapInfo[ud.m_level_number].musicfn1); + MapInfo[ud.m_level_number].musicfn1 = NULL; } p[1]='m'; @@ -1788,24 +1786,24 @@ int enterlevel(int g) Bsprintf(levname,"dethtoll.mid"); else kclose(fil); - if (map[ud.m_level_number].musicfn == NULL) - map[ud.m_level_number].musicfn = Bcalloc(Bstrlen(levname)+1,sizeof(char)); - else if ((Bstrlen(levname)+1) > sizeof(map[ud.m_level_number].musicfn)) - map[ud.m_level_number].musicfn = Brealloc(map[ud.m_level_number].musicfn,(Bstrlen(levname)+1)); - Bstrcpy(map[ud.m_level_number].musicfn,levname); + if (MapInfo[ud.m_level_number].musicfn == NULL) + MapInfo[ud.m_level_number].musicfn = Bcalloc(Bstrlen(levname)+1,sizeof(char)); + else if ((Bstrlen(levname)+1) > sizeof(MapInfo[ud.m_level_number].musicfn)) + MapInfo[ud.m_level_number].musicfn = Brealloc(MapInfo[ud.m_level_number].musicfn,(Bstrlen(levname)+1)); + Bstrcpy(MapInfo[ud.m_level_number].musicfn,levname); } } } - else if (loadboard(map[(ud.volume_number*MAXLEVELS)+ud.level_number].filename,0,&g_player[0].ps->posx, &g_player[0].ps->posy, &g_player[0].ps->posz, &g_player[0].ps->ang,&g_player[0].ps->cursectnum) == -1) + else if (loadboard(MapInfo[(ud.volume_number*MAXLEVELS)+ud.level_number].filename,0,&g_player[0].ps->posx, &g_player[0].ps->posy, &g_player[0].ps->posz, &g_player[0].ps->ang,&g_player[0].ps->cursectnum) == -1) { - OSD_Printf(OSD_ERROR "Map %s not found!\n",map[(ud.volume_number*MAXLEVELS)+ud.level_number].filename); - //gameexit(tempbuf); + OSD_Printf(OSD_ERROR "Map %s not found!\n",MapInfo[(ud.volume_number*MAXLEVELS)+ud.level_number].filename); + //G_GameExit(tempbuf); return 1; } else { char *p; - strcpy(levname, map[(ud.volume_number*MAXLEVELS)+ud.level_number].filename); + strcpy(levname, MapInfo[(ud.volume_number*MAXLEVELS)+ud.level_number].filename); p = Bstrrchr(levname,'.'); if (!p) strcat(levname,".mhk"); else @@ -1822,15 +1820,15 @@ int enterlevel(int g) else { - i = strlen(map[(ud.volume_number*MAXLEVELS)+ud.level_number].filename); - copybufbyte(map[(ud.volume_number*MAXLEVELS)+ud.level_number].filename,&levname[0],i); + i = strlen(MapInfo[(ud.volume_number*MAXLEVELS)+ud.level_number].filename); + copybufbyte(MapInfo[(ud.volume_number*MAXLEVELS)+ud.level_number].filename,&levname[0],i); levname[i] = 255; levname[i+1] = 0; if (loadboard(levname,1,&g_player[0].ps->posx, &g_player[0].ps->posy, &g_player[0].ps->posz, &g_player[0].ps->ang,&g_player[0].ps->cursectnum) == -1) { - OSD_Printf(OSD_ERROR "Map '%s' not found!\n",map[(ud.volume_number*MAXLEVELS)+ud.level_number].filename); - //gameexit(tempbuf); + OSD_Printf(OSD_ERROR "Map '%s' not found!\n",MapInfo[(ud.volume_number*MAXLEVELS)+ud.level_number].filename); + //G_GameExit(tempbuf); return 1; } else @@ -1849,10 +1847,10 @@ int enterlevel(int g) } } - precachecount = 0; + g_precacheCount = 0; clearbufbyte(gotpic,sizeof(gotpic),0L); clearbufbyte(precachehightile, sizeof(precachehightile), 0l); - //clearbufbyte(hittype,sizeof(hittype),0l); // JBF 20040531: yes? no? + //clearbufbyte(ActorExtra,sizeof(ActorExtra),0l); // JBF 20040531: yes? no? prelevel(g); @@ -1862,13 +1860,13 @@ int enterlevel(int g) cachedebug = 0; automapping = 0; - cacheit(); + G_CacheMapData(); if (ud.recstat != 2) { - music_select = (ud.volume_number*MAXLEVELS) + ud.level_number; - if (map[(unsigned char)music_select].musicfn != NULL) - playmusic(&map[(unsigned char)music_select].musicfn[0],music_select); + g_musicIndex = (ud.volume_number*MAXLEVELS) + ud.level_number; + if (MapInfo[(unsigned char)g_musicIndex].musicfn != NULL) + S_PlayMusic(&MapInfo[(unsigned char)g_musicIndex].musicfn[0],g_musicIndex); } if ((g&MODE_GAME) || (g&MODE_EOL)) @@ -1881,58 +1879,58 @@ int enterlevel(int g) } if ((ud.recstat == 1) && (g&MODE_RESTART) != MODE_RESTART) - opendemowrite(); + G_OpenDemoWrite(); if (VOLUMEONE) { - if (ud.level_number == 0 && ud.recstat != 2) FTA(40,g_player[myconnectindex].ps); + if (ud.level_number == 0 && ud.recstat != 2) P_DoQuote(40,g_player[myconnectindex].ps); } - for (i=connecthead;i>=0;i=connectpoint2[i]) - switch (dynamictostatic[sector[sprite[g_player[i].ps->i].sectnum].floorpicnum]) - { - case HURTRAIL__STATIC: - case FLOORSLIME__STATIC: - case FLOORPLASMA__STATIC: - resetweapons(i); - resetinventory(i); - g_player[i].ps->gotweapon[PISTOL_WEAPON] = 0; - g_player[i].ps->ammo_amount[PISTOL_WEAPON] = 0; - g_player[i].ps->curr_weapon = KNEE_WEAPON; - g_player[i].ps->kickback_pic = 0; - break; - } + TRAVERSE_CONNECT(i) + switch (DynamicTileMap[sector[sprite[g_player[i].ps->i].sectnum].floorpicnum]) + { + case HURTRAIL__STATIC: + case FLOORSLIME__STATIC: + case FLOORPLASMA__STATIC: + P_ResetWeapons(i); + P_ResetInventory(i); + g_player[i].ps->gotweapon[PISTOL_WEAPON] = 0; + g_player[i].ps->ammo_amount[PISTOL_WEAPON] = 0; + g_player[i].ps->curr_weapon = KNEE_WEAPON; + g_player[i].ps->kickback_pic = 0; + break; + } //PREMAP.C - replace near the my's at the end of the file - resetmys(); + Net_ResetPrediction(); //g_player[myconnectindex].ps->palette = palette; - //palto(0,0,0,0); - setgamepalette(g_player[myconnectindex].ps, palette, 0); // JBF 20040308 + //G_FadePalette(0,0,0,0); + SetGamePalette(g_player[myconnectindex].ps, palette, 0); // JBF 20040308 - setpal(g_player[myconnectindex].ps); + P_UpdateScreenPal(g_player[myconnectindex].ps); flushperms(); everyothertime = 0; - global_random = 0; + g_globalRandom = 0; ud.last_level = ud.level_number+1; clearfifo(); - for (i=numinterpolations-1;i>=0;i--) bakipos[i] = *curipos[i]; + for (i=g_numInterpolations-1;i>=0;i--) bakipos[i] = *curipos[i]; - restorepalette = 1; + g_restorePalette = 1; - flushpackets(); waitforeverybody(); + flushpackets(); - palto(0,0,0,0); - vscrn(); + G_FadePalette(0,0,0,0); + G_UpdateScreenArea(); clearview(0L); - drawbackground(); - displayrooms(myconnectindex,65536); + G_DrawBackground(); + G_DrawRooms(myconnectindex,65536); for (i=0;ivars[j]) - Bfree(map[mapnum].savedstate->vars[j]); + if (MapInfo[mapnum].savedstate->vars[j]) + Bfree(MapInfo[mapnum].savedstate->vars[j]); } - else if (aGameVars[j].dwFlags & GAMEVAR_FLAG_PERACTOR) + else if (aGameVars[j].dwFlags & GAMEVAR_PERACTOR) { - if (map[mapnum].savedstate->vars[j]) - Bfree(map[mapnum].savedstate->vars[j]); + if (MapInfo[mapnum].savedstate->vars[j]) + Bfree(MapInfo[mapnum].savedstate->vars[j]); } } - Bfree(map[mapnum].savedstate); - map[mapnum].savedstate = NULL; + Bfree(MapInfo[mapnum].savedstate); + MapInfo[mapnum].savedstate = NULL; } diff --git a/polymer/eduke32/source/savegame.c b/polymer/eduke32/source/savegame.c index 0dce3500a..f0a22baa2 100644 --- a/polymer/eduke32/source/savegame.c +++ b/polymer/eduke32/source/savegame.c @@ -28,7 +28,7 @@ extern char *bitptr; #define BITPTR_POINTER 1 -void readsavenames(void) +void ReadSaveGameHeaders(void) { int dummy,j; int i; @@ -74,7 +74,7 @@ void readsavenames(void) } } -int loadpheader(char spot,struct savehead *saveh) +int G_LoadSaveHeader(char spot,struct savehead *saveh) { char fn[13]; int fil; @@ -95,7 +95,7 @@ int loadpheader(char spot,struct savehead *saveh) if (kdfread(&bv,4,1,fil) != 1) goto corrupt; /* if (bv != BYTEVERSION) { - FTA(114,g_player[myconnectindex].ps); + P_DoQuote(114,g_player[myconnectindex].ps); kclose(fil); return 1; }*/ @@ -122,7 +122,7 @@ corrupt: return 1; } -int loadplayer(int spot) +int G_LoadPlayer(int spot) { int k; char fn[13]; @@ -173,7 +173,7 @@ int loadplayer(int spot) if (kdfread(&bv,4,1,fil) != 1) return -1; if (bv != BYTEVERSION) { - FTA(114,g_player[myconnectindex].ps); + P_DoQuote(114,g_player[myconnectindex].ps); kclose(fil); ototalclock = totalclock; ready2send = 1; @@ -186,7 +186,7 @@ int loadplayer(int spot) kclose(fil); ototalclock = totalclock; ready2send = 1; - FTA(124,g_player[myconnectindex].ps); + P_DoQuote(124,g_player[myconnectindex].ps); return 1; } else ud.multimode = nump; @@ -195,8 +195,8 @@ int loadplayer(int spot) { pub = NUMPAGES; pus = NUMPAGES; - vscrn(); - drawbackground(); + G_UpdateScreenArea(); + G_DrawBackground(); menutext(160,100,0,0,"LOADING..."); nextpage(); } @@ -204,7 +204,7 @@ int loadplayer(int spot) waitforeverybody(); FX_StopAllSounds(); - clearsoundlocks(); + S_ClearSoundLocks(); if (numplayers > 1) { @@ -248,43 +248,43 @@ int loadplayer(int spot) if (kdfread(&headspritesect[0],2,MAXSECTORS+1,fil) != MAXSECTORS+1) goto corrupt; if (kdfread(&prevspritesect[0],2,MAXSPRITES,fil) != MAXSPRITES) goto corrupt; if (kdfread(&nextspritesect[0],2,MAXSPRITES,fil) != MAXSPRITES) goto corrupt; - if (kdfread(&headspritestat[0],2,MAXSTATUS+1,fil) != MAXSTATUS+1) goto corrupt; - if (kdfread(&prevspritestat[0],2,MAXSPRITES,fil) != MAXSPRITES) goto corrupt; - if (kdfread(&nextspritestat[0],2,MAXSPRITES,fil) != MAXSPRITES) goto corrupt; - if (kdfread(&numcyclers,sizeof(numcyclers),1,fil) != 1) goto corrupt; + if (kdfread(&headspritestat[STAT_DEFAULT],2,MAXSTATUS+1,fil) != MAXSTATUS+1) goto corrupt; + if (kdfread(&prevspritestat[STAT_DEFAULT],2,MAXSPRITES,fil) != MAXSPRITES) goto corrupt; + if (kdfread(&nextspritestat[STAT_DEFAULT],2,MAXSPRITES,fil) != MAXSPRITES) goto corrupt; + if (kdfread(&g_numCyclers,sizeof(g_numCyclers),1,fil) != 1) goto corrupt; if (kdfread(&cyclers[0][0],12,MAXCYCLERS,fil) != MAXCYCLERS) goto corrupt; for (i=0;i>3,fil) != (MAXSECTORS>>3)) goto corrupt; - if (kdfread(&actortype[0],sizeof(char),MAXTILES,fil) != MAXTILES) goto corrupt; + if (kdfread(&ActorType[0],sizeof(char),MAXTILES,fil) != MAXTILES) goto corrupt; - if (kdfread(&numclouds,sizeof(numclouds),1,fil) != 1) goto corrupt; + if (kdfread(&g_numClouds,sizeof(g_numClouds),1,fil) != 1) goto corrupt; if (kdfread(&clouds[0],sizeof(short)<<7,1,fil) != 1) goto corrupt; if (kdfread(&cloudx[0],sizeof(short)<<7,1,fil) != 1) goto corrupt; if (kdfread(&cloudy[0],sizeof(short)<<7,1,fil) != 1) goto corrupt; - if (kdfread(&g_ScriptSize,sizeof(g_ScriptSize),1,fil) != 1) goto corrupt; - if (!g_ScriptSize) goto corrupt; - scriptptrs = Bcalloc(1,g_ScriptSize * sizeof(scriptptrs)); + if (kdfread(&g_scriptSize,sizeof(g_scriptSize),1,fil) != 1) goto corrupt; + if (!g_scriptSize) goto corrupt; + scriptptrs = Bcalloc(1,g_scriptSize * sizeof(scriptptrs)); Bfree(bitptr); - bitptr = Bcalloc(1,(((g_ScriptSize+7)>>3)+1) * sizeof(char)); - if (kdfread(&bitptr[0],sizeof(char),(g_ScriptSize+7)>>3,fil) != ((g_ScriptSize+7)>>3)) goto corrupt; + bitptr = Bcalloc(1,(((g_scriptSize+7)>>3)+1) * sizeof(char)); + if (kdfread(&bitptr[0],sizeof(char),(g_scriptSize+7)>>3,fil) != ((g_scriptSize+7)>>3)) goto corrupt; if (script != NULL) Bfree(script); - script = Bcalloc(1,g_ScriptSize * sizeof(intptr_t)); - if (kdfread(&script[0],sizeof(script),g_ScriptSize,fil) != g_ScriptSize) goto corrupt; - for (i=0;i>3]&(BITPTR_POINTER<<(i&7))) { j = (intptr_t)script[i]+(intptr_t)&script[0]; @@ -309,7 +309,7 @@ int loadplayer(int spot) scriptptrs = Brealloc(scriptptrs, MAXSPRITES * sizeof(scriptptrs)); if (kdfread(&scriptptrs[0],sizeof(scriptptrs),MAXSPRITES,fil) != MAXSPRITES) goto corrupt; - if (kdfread(&hittype[0],sizeof(actordata_t),MAXSPRITES,fil) != MAXSPRITES) goto corrupt; + if (kdfread(&ActorExtra[0],sizeof(actordata_t),MAXSPRITES,fil) != MAXSPRITES) goto corrupt; for (i=0;i=0;i--) animateptr[i] = (int *)((intptr_t)animateptr[i]+(intptr_t)(§or[0])); + for (i = g_animateCount-1;i>=0;i--) animateptr[i] = (int *)((intptr_t)animateptr[i]+(intptr_t)(§or[0])); if (kdfread(&animategoal[0],4,MAXANIMATES,fil) != MAXANIMATES) goto corrupt; if (kdfread(&animatevel[0],4,MAXANIMATES,fil) != MAXANIMATES) goto corrupt; - if (kdfread(&earthquaketime,sizeof(earthquaketime),1,fil) != 1) goto corrupt; + if (kdfread(&g_earthquakeTime,sizeof(g_earthquakeTime),1,fil) != 1) goto corrupt; if (kdfread(&ud.from_bonus,sizeof(ud.from_bonus),1,fil) != 1) goto corrupt; if (kdfread(&ud.secretlevel,sizeof(ud.secretlevel),1,fil) != 1) goto corrupt; if (kdfread(&ud.respawn_monsters,sizeof(ud.respawn_monsters),1,fil) != 1) goto corrupt; @@ -358,75 +358,75 @@ int loadplayer(int spot) if (kdfread(&camsprite,sizeof(camsprite),1,fil) != 1) goto corrupt; if (kdfread(&connecthead,sizeof(connecthead),1,fil) != 1) goto corrupt; if (kdfread(connectpoint2,sizeof(connectpoint2),1,fil) != 1) goto corrupt; - if (kdfread(&numplayersprites,sizeof(numplayersprites),1,fil) != 1) goto corrupt; + if (kdfread(&g_numPlayerSprites,sizeof(g_numPlayerSprites),1,fil) != 1) goto corrupt; for (i=0;iover_shoulder_on != 0) { - cameradist = 0; - cameraclock = 0; + g_cameraDistance = 0; + g_cameraClock = 0; g_player[myconnectindex].ps->over_shoulder_on = 1; } screenpeek = myconnectindex; clearbufbyte(gotpic,sizeof(gotpic),0L); - clearsoundlocks(); - cacheit(); + S_ClearSoundLocks(); + G_CacheMapData(); - i = music_select; - music_select = (ud.volume_number*MAXLEVELS) + ud.level_number; - if (map[(unsigned char)music_select].musicfn != NULL && (i != music_select || map[MAXVOLUMES*MAXLEVELS+2].musicfn1)) + i = g_musicIndex; + g_musicIndex = (ud.volume_number*MAXLEVELS) + ud.level_number; + if (MapInfo[(unsigned char)g_musicIndex].musicfn != NULL && (i != g_musicIndex || MapInfo[MAXVOLUMES*MAXLEVELS+2].musicfn1)) { MUSIC_StopSong(); - playmusic(&map[(unsigned char)music_select].musicfn[0],music_select); + S_PlayMusic(&MapInfo[(unsigned char)g_musicIndex].musicfn[0],g_musicIndex); } MUSIC_Continue(); @@ -434,24 +434,24 @@ int loadplayer(int spot) ud.recstat = 0; if (g_player[myconnectindex].ps->jetpack_on) - spritesound(DUKE_JETPACK_IDLE,g_player[myconnectindex].ps->i); + A_PlaySound(DUKE_JETPACK_IDLE,g_player[myconnectindex].ps->i); - restorepalette = 1; - setpal(g_player[myconnectindex].ps); - vscrn(); + g_restorePalette = 1; + P_UpdateScreenPal(g_player[myconnectindex].ps); + G_UpdateScreenArea(); FX_SetReverb(0); if (ud.lockout == 0) { - for (x=0;x= 0) wall[animwall[x].wallnum].picnum = wall[animwall[x].wallnum].extra; } else { - for (x=0;x= 0) { switch (sprite[k].lotag) { case 31: - setinterpolation(§or[sprite[k].sectnum].floorz); + G_SetInterpolation(§or[sprite[k].sectnum].floorz); break; case 32: - setinterpolation(§or[sprite[k].sectnum].ceilingz); + G_SetInterpolation(§or[sprite[k].sectnum].ceilingz); break; case 25: - setinterpolation(§or[sprite[k].sectnum].floorz); - setinterpolation(§or[sprite[k].sectnum].ceilingz); + G_SetInterpolation(§or[sprite[k].sectnum].floorz); + G_SetInterpolation(§or[sprite[k].sectnum].ceilingz); break; case 17: - setinterpolation(§or[sprite[k].sectnum].floorz); - setinterpolation(§or[sprite[k].sectnum].ceilingz); + G_SetInterpolation(§or[sprite[k].sectnum].floorz); + G_SetInterpolation(§or[sprite[k].sectnum].ceilingz); break; case 0: case 5: @@ -494,18 +494,18 @@ int loadplayer(int spot) case 16: case 26: case 30: - setsectinterpolate(k); + Sect_SetInterpolation(k); break; } k = nextspritestat[k]; } - for (i=numinterpolations-1;i>=0;i--) bakipos[i] = *curipos[i]; - for (i = animatecnt-1;i>=0;i--) - setinterpolation(animateptr[i]); + for (i=g_numInterpolations-1;i>=0;i--) bakipos[i] = *curipos[i]; + for (i = g_animateCount-1;i>=0;i--) + G_SetInterpolation(animateptr[i]); - show_shareware = 0; + g_showShareware = 0; everyothertime = 0; // clearbufbyte(playerquitflag,MAXPLAYERS,0x01010101); @@ -513,7 +513,7 @@ int loadplayer(int spot) for (i=0;i>3,fil); - dfwrite(&actortype[0],sizeof(char),MAXTILES,fil); + dfwrite(&ActorType[0],sizeof(char),MAXTILES,fil); - dfwrite(&numclouds,sizeof(numclouds),1,fil); + dfwrite(&g_numClouds,sizeof(g_numClouds),1,fil); dfwrite(&clouds[0],sizeof(short)<<7,1,fil); dfwrite(&cloudx[0],sizeof(short)<<7,1,fil); dfwrite(&cloudy[0],sizeof(short)<<7,1,fil); - dfwrite(&g_ScriptSize,sizeof(g_ScriptSize),1,fil); - scriptptrs = Bcalloc(1, g_ScriptSize * sizeof(scriptptrs)); - for (i=0;i>3]&(BITPTR_POINTER<<(i&7))) { @@ -663,11 +663,11 @@ int saveplayer(int spot) // else scriptptrs[i] = 0; } -// dfwrite(&scriptptrs[0],sizeof(scriptptrs),g_ScriptSize,fil); - dfwrite(&bitptr[0],sizeof(char),(g_ScriptSize+7)>>3,fil); - dfwrite(&script[0],sizeof(script),g_ScriptSize,fil); +// dfwrite(&scriptptrs[0],sizeof(scriptptrs),g_scriptSize,fil); + dfwrite(&bitptr[0],sizeof(char),(g_scriptSize+7)>>3,fil); + dfwrite(&script[0],sizeof(script),g_scriptSize,fil); - for (i=0;i>3]&(BITPTR_POINTER<<(i&7))) { j = script[i]+(intptr_t)&script[0]; @@ -713,17 +713,17 @@ int saveplayer(int spot) j = (intptr_t)&script[0]; - if (T2 >= j && T2 < (intptr_t)(&script[g_ScriptSize])) + if (T2 >= j && T2 < (intptr_t)(&script[g_scriptSize])) { scriptptrs[i] |= 1; T2 -= j; } - if (T5 >= j && T5 < (intptr_t)(&script[g_ScriptSize])) + if (T5 >= j && T5 < (intptr_t)(&script[g_scriptSize])) { scriptptrs[i] |= 2; T5 -= j; } - if (T6 >= j && T6 < (intptr_t)(&script[g_ScriptSize])) + if (T6 >= j && T6 < (intptr_t)(&script[g_scriptSize])) { scriptptrs[i] |= 4; T6 -= j; @@ -731,7 +731,7 @@ int saveplayer(int spot) } dfwrite(&scriptptrs[0],sizeof(scriptptrs),MAXSPRITES,fil); - dfwrite(&hittype[0],sizeof(actordata_t),MAXSPRITES,fil); + dfwrite(&ActorExtra[0],sizeof(actordata_t),MAXSPRITES,fil); for (i=0;i=0;i--) animateptr[i] = (int *)((intptr_t)animateptr[i]-(intptr_t)(§or[0])); + for (i = g_animateCount-1;i>=0;i--) animateptr[i] = (int *)((intptr_t)animateptr[i]-(intptr_t)(§or[0])); dfwrite(&animateptr[0],4,MAXANIMATES,fil); - for (i = animatecnt-1;i>=0;i--) animateptr[i] = (int *)((intptr_t)animateptr[i]+(intptr_t)(§or[0])); + for (i = g_animateCount-1;i>=0;i--) animateptr[i] = (int *)((intptr_t)animateptr[i]+(intptr_t)(§or[0])); dfwrite(&animategoal[0],4,MAXANIMATES,fil); dfwrite(&animatevel[0],4,MAXANIMATES,fil); - dfwrite(&earthquaketime,sizeof(earthquaketime),1,fil); + dfwrite(&g_earthquakeTime,sizeof(g_earthquakeTime),1,fil); dfwrite(&ud.from_bonus,sizeof(ud.from_bonus),1,fil); dfwrite(&ud.secretlevel,sizeof(ud.secretlevel),1,fil); dfwrite(&ud.respawn_monsters,sizeof(ud.respawn_monsters),1,fil); @@ -775,50 +775,50 @@ int saveplayer(int spot) dfwrite(&camsprite,sizeof(camsprite),1,fil); dfwrite(&connecthead,sizeof(connecthead),1,fil); dfwrite(connectpoint2,sizeof(connectpoint2),1,fil); - dfwrite(&numplayersprites,sizeof(numplayersprites),1,fil); + dfwrite(&g_numPlayerSprites,sizeof(g_numPlayerSprites),1,fil); for (i=0;i= 0) { if (sprite[i].lotag == lotag) { s = &sprite[i]; - for (j = animatecnt-1; j >= 0; j--) + for (j = g_animateCount-1; j >= 0; j--) if (s->sectnum == animatesect[j]) return(1); - j = headspritestat[3]; + j = headspritestat[STAT_EFFECTOR]; while (j >= 0) { if (s->sectnum == sprite[j].sectnum) @@ -99,14 +100,14 @@ int check_activator_motion(int lotag) { case 11: case 30: - if (hittype[j].temp_data[4]) + if (ActorExtra[j].temp_data[4]) return(1); break; case 20: case 31: case 32: case 18: - if (hittype[j].temp_data[0]) + if (ActorExtra[j].temp_data[0]) return(1); break; } @@ -119,9 +120,9 @@ int check_activator_motion(int lotag) return(0); } -int isadoorwall(int dapic) +int CheckDoorTile(int dapic) { - switch (dynamictostatic[dapic]) + switch (DynamicTileMap[dapic]) { case DOORTILE1__STATIC: case DOORTILE2__STATIC: @@ -188,7 +189,7 @@ int isanearoperator(int lotag) return 0; } -inline int checkcursectnums(int sect) +inline int CheckPlayerInSector(int sect) { int i = connecthead; for (;i>=0;i=connectpoint2[i]) @@ -224,7 +225,7 @@ int dist(spritetype *s1,spritetype *s2) } } -int findplayer(spritetype *s,int *d) +int A_FindPlayer(spritetype *s,int *d) { int j, closest_player = 0; int x, closest = 0x7fffffff; @@ -235,7 +236,7 @@ int findplayer(spritetype *s,int *d) return myconnectindex; } - for (j=connecthead;j>=0;j=connectpoint2[j]) + TRAVERSE_CONNECT(j) { x = klabs(g_player[j].ps->oposx-s->x) + klabs(g_player[j].ps->oposy-s->y) + ((klabs(g_player[j].ps->oposz-s->z+(28<<8)))>>4); if (x < closest && sprite[g_player[j].ps->i].extra > 0) @@ -249,32 +250,32 @@ int findplayer(spritetype *s,int *d) return closest_player; } -int findotherplayer(int p,int *d) +int P_FindOtherPlayer(int p,int *d) { int j, closest_player = p; int x, closest = 0x7fffffff; - for (j=connecthead;j>=0;j=connectpoint2[j]) - if (p != j && sprite[g_player[j].ps->i].extra > 0) - { - x = klabs(g_player[j].ps->oposx-g_player[p].ps->posx) + klabs(g_player[j].ps->oposy-g_player[p].ps->posy) + (klabs(g_player[j].ps->oposz-g_player[p].ps->posz)>>4); + TRAVERSE_CONNECT(j) + if (p != j && sprite[g_player[j].ps->i].extra > 0) + { + x = klabs(g_player[j].ps->oposx-g_player[p].ps->posx) + klabs(g_player[j].ps->oposy-g_player[p].ps->posy) + (klabs(g_player[j].ps->oposz-g_player[p].ps->posz)>>4); - if (x < closest) - { - closest_player = j; - closest = x; - } + if (x < closest) + { + closest_player = j; + closest = x; } + } *d = closest; return closest_player; } -void doanimations(void) +void G_DoSectorAnimations(void) { int i, j, a, p, v, dasect; - for (i=animatecnt-1;i>=0;i--) + for (i=g_animateCount-1;i>=0;i--) { a = *animateptr[i]; v = animatevel[i]*TICSPERFRAME; @@ -282,7 +283,7 @@ void doanimations(void) if (a == animategoal[i]) { - stopinterpolation(animateptr[i]); + G_StopInterpolation(animateptr[i]); // This fixes a bug where wall or floor sprites contained in // elevator sectors (ST 16-19) would jitter vertically after the @@ -290,19 +291,19 @@ void doanimations(void) if (animateptr[i] == §or[animatesect[i]].floorz) for (j=headspritesect[dasect];j>=0;j=nextspritesect[j]) if (sprite[j].statnum != 3) - hittype[j].bposz = sprite[j].z; + ActorExtra[j].bposz = sprite[j].z; - animatecnt--; - animateptr[i] = animateptr[animatecnt]; - animategoal[i] = animategoal[animatecnt]; - animatevel[i] = animatevel[animatecnt]; - animatesect[i] = animatesect[animatecnt]; + g_animateCount--; + animateptr[i] = animateptr[g_animateCount]; + animategoal[i] = animategoal[g_animateCount]; + animatevel[i] = animatevel[g_animateCount]; + animatesect[i] = animatesect[g_animateCount]; if (sector[animatesect[i]].lotag == 18 || sector[animatesect[i]].lotag == 19) if (animateptr[i] == §or[animatesect[i]].ceilingz) continue; if ((sector[dasect].lotag&0xff) != 22) - callsound(dasect,-1); + A_CallSound(dasect,-1); continue; } @@ -318,27 +319,27 @@ void doanimations(void) if (animateptr[i] == §or[animatesect[i]].floorz) { - for (p=connecthead;p>=0;p=connectpoint2[p]) - if (g_player[p].ps->cursectnum == dasect) - if ((sector[dasect].floorz-g_player[p].ps->posz) < (64<<8)) - if (sprite[g_player[p].ps->i].owner >= 0) + TRAVERSE_CONNECT(p) + if (g_player[p].ps->cursectnum == dasect) + if ((sector[dasect].floorz-g_player[p].ps->posz) < (64<<8)) + if (sprite[g_player[p].ps->i].owner >= 0) + { + g_player[p].ps->posz += v; + g_player[p].ps->poszv = 0; + if (p == myconnectindex) { - g_player[p].ps->posz += v; - g_player[p].ps->poszv = 0; - if (p == myconnectindex) - { - myz += v; - myzvel = 0; - myzbak[((movefifoplc-1)&(MOVEFIFOSIZ-1))] = g_player[p].ps->posz; - } + myz += v; + myzvel = 0; + myzbak[((movefifoplc-1)&(MOVEFIFOSIZ-1))] = g_player[p].ps->posz; } + } for (j=headspritesect[dasect];j>=0;j=nextspritesect[j]) if (sprite[j].statnum != 3) { - hittype[j].bposz = sprite[j].z; + ActorExtra[j].bposz = sprite[j].z; sprite[j].z += v; - hittype[j].floorz = sector[dasect].floorz+v; + ActorExtra[j].floorz = sector[dasect].floorz+v; } } @@ -346,9 +347,9 @@ void doanimations(void) } } -int getanimationgoal(int *animptr) +int GetAnimationGoal(int *animptr) { - int i = animatecnt-1, j = -1; + int i = g_animateCount-1, j = -1; for (;i>=0;i--) if (animptr == (int *)animateptr[i]) @@ -359,14 +360,14 @@ int getanimationgoal(int *animptr) return(j); } -int setanimation(int animsect,int *animptr, int thegoal, int thevel) +int SetAnimation(int animsect,int *animptr, int thegoal, int thevel) { - int i = 0, j = animatecnt; + int i = 0, j = g_animateCount; - if (animatecnt >= MAXANIMATES-1) + if (g_animateCount >= MAXANIMATES-1) return(-1); - for (;i=0;p--) - // for(p=numanimwalls-1;p>=0;p--) + // for(p=g_numAnimWalls-1;p>=0;p--) { i = animwall[p].wallnum; j = wall[i].picnum; - switch (dynamictostatic[j]) + switch (DynamicTileMap[j]) { case SCREENBREAK1__STATIC: case SCREENBREAK2__STATIC: @@ -441,7 +442,7 @@ void animatewalls(void) case SCREENBREAK18__STATIC: case SCREENBREAK19__STATIC: - if ((TRAND&255) < 16) + if ((krand()&255) < 16) { animwall[p].tag = wall[i].picnum; wall[i].picnum = SCREENBREAK6; @@ -492,8 +493,8 @@ void animatewalls(void) } else { - if ((TRAND&255) < 32) - animwall[p].tag = 128<<(TRAND&3); + if ((krand()&255) < 32) + animwall[p].tag = 128<<(krand()&3); else wall[i].overpicnum = W_FORCEFIELD+1; } } @@ -502,15 +503,15 @@ void animatewalls(void) } } -int activatewarpelevators(int s,int d) //Parm = sectoreffectornum +int G_ActivateWarpElevators(int s,int d) //Parm = sectoreffectornum { - int i = headspritestat[3], sn = sprite[s].sectnum; + int i = headspritestat[STAT_EFFECTOR], sn = sprite[s].sectnum; while (i >= 0) { if (SLT == 17) if (SHT == sprite[s].hitag) - if ((klabs(sector[sn].floorz-hittype[s].temp_data[2]) > SP) || + if ((klabs(sector[sn].floorz-ActorExtra[s].temp_data[2]) > SP) || (sector[SECT].hitag == (sector[sn].hitag-d))) break; i = nextspritestat[i]; @@ -524,12 +525,12 @@ int activatewarpelevators(int s,int d) //Parm = sectoreffectornum else { if (d == 0) - spritesound(ELEVATOR_OFF,s); - else spritesound(ELEVATOR_ON,s); + A_PlaySound(ELEVATOR_OFF,s); + else A_PlaySound(ELEVATOR_ON,s); } - i = headspritestat[3]; + i = headspritestat[STAT_EFFECTOR]; while (i >= 0) { if (SLT == 17) @@ -543,7 +544,7 @@ int activatewarpelevators(int s,int d) //Parm = sectoreffectornum return 0; } -void operatesectors(int sn,int ii) +void G_OperateSectors(int sn,int ii) { int j=0, l, q, startwall, endwall; int i; @@ -554,9 +555,9 @@ void operatesectors(int sn,int ii) case 30: j = sector[sn].hitag; - if (hittype[j].tempang == 0 || - hittype[j].tempang == 256) - callsound(sn,ii); + if (ActorExtra[j].tempang == 0 || + ActorExtra[j].tempang == 256) + A_CallSound(sn,ii); if (sprite[j].extra == 1) sprite[j].extra = 3; else sprite[j].extra = 1; @@ -565,23 +566,23 @@ void operatesectors(int sn,int ii) case 31: j = sector[sn].hitag; - if (hittype[j].temp_data[4] == 0) - hittype[j].temp_data[4] = 1; + if (ActorExtra[j].temp_data[4] == 0) + ActorExtra[j].temp_data[4] = 1; - callsound(sn,ii); + A_CallSound(sn,ii); break; case 26: //The split doors - i = getanimationgoal(&sptr->ceilingz); + i = GetAnimationGoal(&sptr->ceilingz); if (i == -1) //if the door has stopped { haltsoundhack = 1; sptr->lotag &= 0xff00; sptr->lotag |= 22; - operatesectors(sn,ii); + G_OperateSectors(sn,ii); sptr->lotag &= 0xff00; sptr->lotag |= 9; - operatesectors(sn,ii); + G_OperateSectors(sn,ii); sptr->lotag &= 0xff00; sptr->lotag |= 26; } @@ -633,19 +634,19 @@ void operatesectors(int sn,int ii) { dax2 = wall[wall[wall[wallfind[j]].point2].point2].x; dax2 -= wall[wall[wallfind[j]].point2].x; - setanimation(sn,&wall[wallfind[j]].x,wall[wallfind[j]].x+dax2,sp); - setanimation(sn,&wall[i].x,wall[i].x+dax2,sp); - setanimation(sn,&wall[wall[wallfind[j]].point2].x,wall[wall[wallfind[j]].point2].x+dax2,sp); - callsound(sn,ii); + SetAnimation(sn,&wall[wallfind[j]].x,wall[wallfind[j]].x+dax2,sp); + SetAnimation(sn,&wall[i].x,wall[i].x+dax2,sp); + SetAnimation(sn,&wall[wall[wallfind[j]].point2].x,wall[wall[wallfind[j]].point2].x+dax2,sp); + A_CallSound(sn,ii); } else if (day2 != 0) { day2 = wall[wall[wall[wallfind[j]].point2].point2].y; day2 -= wall[wall[wallfind[j]].point2].y; - setanimation(sn,&wall[wallfind[j]].y,wall[wallfind[j]].y+day2,sp); - setanimation(sn,&wall[i].y,wall[i].y+day2,sp); - setanimation(sn,&wall[wall[wallfind[j]].point2].y,wall[wall[wallfind[j]].point2].y+day2,sp); - callsound(sn,ii); + SetAnimation(sn,&wall[wallfind[j]].y,wall[wallfind[j]].y+day2,sp); + SetAnimation(sn,&wall[i].y,wall[i].y+day2,sp); + SetAnimation(sn,&wall[wall[wallfind[j]].point2].y,wall[wall[wallfind[j]].point2].y+day2,sp); + A_CallSound(sn,ii); } } else @@ -656,17 +657,17 @@ void operatesectors(int sn,int ii) day2 = ((wall[i].y+wall[wall[wallfind[j]].point2].y)>>1)-wall[wallfind[j]].y; if (dax2 != 0) { - setanimation(sn,&wall[wallfind[j]].x,dax,sp); - setanimation(sn,&wall[i].x,dax+dax2,sp); - setanimation(sn,&wall[wall[wallfind[j]].point2].x,dax+dax2,sp); - callsound(sn,ii); + SetAnimation(sn,&wall[wallfind[j]].x,dax,sp); + SetAnimation(sn,&wall[i].x,dax+dax2,sp); + SetAnimation(sn,&wall[wall[wallfind[j]].point2].x,dax+dax2,sp); + A_CallSound(sn,ii); } else if (day2 != 0) { - setanimation(sn,&wall[wallfind[j]].y,day,sp); - setanimation(sn,&wall[i].y,day+day2,sp); - setanimation(sn,&wall[wall[wallfind[j]].point2].y,day+day2,sp); - callsound(sn,ii); + SetAnimation(sn,&wall[wallfind[j]].y,day,sp); + SetAnimation(sn,&wall[i].y,day+day2,sp); + SetAnimation(sn,&wall[wall[wallfind[j]].point2].y,day+day2,sp); + A_CallSound(sn,ii); } } } @@ -688,18 +689,18 @@ void operatesectors(int sn,int ii) if (sprite[ii].sectnum == sn) { - if (activatewarpelevators(i,-1)) - activatewarpelevators(i,1); - else if (activatewarpelevators(i,1)) - activatewarpelevators(i,-1); + if (G_ActivateWarpElevators(i,-1)) + G_ActivateWarpElevators(i,1); + else if (G_ActivateWarpElevators(i,1)) + G_ActivateWarpElevators(i,-1); return; } else { if (sptr->floorz > SZ) - activatewarpelevators(i,-1); + G_ActivateWarpElevators(i,-1); else - activatewarpelevators(i,1); + G_ActivateWarpElevators(i,1); } return; @@ -707,7 +708,7 @@ void operatesectors(int sn,int ii) case 16: case 17: - i = getanimationgoal(&sptr->floorz); + i = GetAnimationGoal(&sptr->floorz); if (i == -1) { @@ -717,14 +718,14 @@ void operatesectors(int sn,int ii) i = nextsectorneighborz(sn,sptr->floorz,1,-1); if (i == -1) return; j = sector[i].floorz; - setanimation(sn,&sptr->floorz,j,sptr->extra); + SetAnimation(sn,&sptr->floorz,j,sptr->extra); } else { j = sector[i].floorz; - setanimation(sn,&sptr->floorz,j,sptr->extra); + SetAnimation(sn,&sptr->floorz,j,sptr->extra); } - callsound(sn,ii); + A_CallSound(sn,ii); } return; @@ -732,7 +733,7 @@ void operatesectors(int sn,int ii) case 18: case 19: - i = getanimationgoal(&sptr->floorz); + i = GetAnimationGoal(&sptr->floorz); if (i==-1) { @@ -742,9 +743,9 @@ void operatesectors(int sn,int ii) j = sector[i].floorz; q = sptr->extra; l = sptr->ceilingz-sptr->floorz; - setanimation(sn,&sptr->floorz,j,q); - setanimation(sn,&sptr->ceilingz,j+l,q); - callsound(sn,ii); + SetAnimation(sn,&sptr->floorz,j,q); + SetAnimation(sn,&sptr->ceilingz,j+l,q); + A_CallSound(sn,ii); } return; @@ -755,7 +756,7 @@ void operatesectors(int sn,int ii) else j = sector[nextsectorneighborz(sn,sptr->ceilingz,-1,-1)].ceilingz; - i = headspritestat[3]; //Effectors + i = headspritestat[STAT_EFFECTOR]; //Effectors while (i >= 0) { if ((SLT == 22) && @@ -771,9 +772,9 @@ void operatesectors(int sn,int ii) sptr->lotag ^= 0x8000; - setanimation(sn,&sptr->ceilingz,j,sptr->extra); + SetAnimation(sn,&sptr->ceilingz,j,sptr->extra); - callsound(sn,ii); + A_CallSound(sn,ii); return; @@ -810,13 +811,13 @@ REDODOOR: sptr->lotag ^= 0x8000; - setanimation(sn,&sptr->ceilingz,j,sptr->extra); - callsound(sn,ii); + SetAnimation(sn,&sptr->ceilingz,j,sptr->extra); + A_CallSound(sn,ii); return; case 21: - i = getanimationgoal(&sptr->floorz); + i = GetAnimationGoal(&sptr->floorz); if (i >= 0) { if (animategoal[sn] == sptr->ceilingz) @@ -832,8 +833,8 @@ REDODOOR: sptr->lotag ^= 0x8000; - if (setanimation(sn,&sptr->floorz,j,sptr->extra) >= 0) - callsound(sn,ii); + if (SetAnimation(sn,&sptr->floorz,j,sptr->extra) >= 0) + A_CallSound(sn,ii); } return; @@ -844,20 +845,20 @@ REDODOOR: if ((sptr->lotag&0x8000)) { q = (sptr->ceilingz+sptr->floorz)>>1; - j = setanimation(sn,&sptr->floorz,q,sptr->extra); - j = setanimation(sn,&sptr->ceilingz,q,sptr->extra); + j = SetAnimation(sn,&sptr->floorz,q,sptr->extra); + j = SetAnimation(sn,&sptr->ceilingz,q,sptr->extra); } else { q = sector[nextsectorneighborz(sn,sptr->floorz,1,1)].floorz; - j = setanimation(sn,&sptr->floorz,q,sptr->extra); + j = SetAnimation(sn,&sptr->floorz,q,sptr->extra); q = sector[nextsectorneighborz(sn,sptr->ceilingz,-1,-1)].ceilingz; - j = setanimation(sn,&sptr->ceilingz,q,sptr->extra); + j = SetAnimation(sn,&sptr->ceilingz,q,sptr->extra); } sptr->lotag ^= 0x8000; - callsound(sn,ii); + A_CallSound(sn,ii); return; @@ -866,7 +867,7 @@ REDODOOR: j = -1; q = 0; - i = headspritestat[3]; + i = headspritestat[STAT_EFFECTOR]; while (i >= 0) { if (SLT == 11 && SECT == sn && !T5) @@ -885,7 +886,7 @@ REDODOOR: if (j >= 0) { - i = headspritestat[3]; + i = headspritestat[STAT_EFFECTOR]; while (i >= 0) { if (l == (sector[SECT].lotag&0x8000) && SLT == 11 && sprite[j].hitag == SHT && !T5) @@ -896,7 +897,7 @@ REDODOOR: T4 = -T4; if (q == 0) { - callsound(sn,i); + A_CallSound(sn,i); q = 1; } } @@ -907,7 +908,7 @@ REDODOOR: case 25: //Subway type sliding doors - j = headspritestat[3]; + j = headspritestat[STAT_EFFECTOR]; while (j >= 0)//Find the sprite { if ((sprite[j].lotag) == 15 && sprite[j].sectnum == sn) @@ -918,7 +919,7 @@ REDODOOR: if (j < 0) return; - i = headspritestat[3]; + i = headspritestat[STAT_EFFECTOR]; while (i >= 0) { if (SHT==sprite[j].hitag) @@ -927,8 +928,8 @@ REDODOOR: { sector[SECT].lotag ^= 0x8000; // Toggle the open or close SA += 1024; - if (T5) callsound(SECT,i); - callsound(SECT,i); + if (T5) A_CallSound(SECT,i); + A_CallSound(SECT,i); if (sector[SECT].lotag&0x8000) T5 = 1; else T5 = 2; } @@ -939,7 +940,7 @@ REDODOOR: case 27: //Extended bridge - j = headspritestat[3]; + j = headspritestat[STAT_EFFECTOR]; while (j >= 0) { if ((sprite[j].lotag&0xff)==20 && sprite[j].sectnum == sn) //Bridge @@ -947,9 +948,9 @@ REDODOOR: sector[sn].lotag ^= 0x8000; if (sector[sn].lotag&0x8000) //OPENING - hittype[j].temp_data[0] = 1; - else hittype[j].temp_data[0] = 2; - callsound(sn,ii); + ActorExtra[j].temp_data[0] = 1; + else ActorExtra[j].temp_data[0] = 2; + A_CallSound(sn,ii); break; } j = nextspritestat[j]; @@ -970,32 +971,32 @@ REDODOOR: j = sprite[j].hitag; - l = headspritestat[3]; + l = headspritestat[STAT_EFFECTOR]; while (l >= 0) { - if ((sprite[l].lotag&0xff)==21 && !hittype[l].temp_data[0] && + if ((sprite[l].lotag&0xff)==21 && !ActorExtra[l].temp_data[0] && (sprite[l].hitag) == j) - hittype[l].temp_data[0] = 1; + ActorExtra[l].temp_data[0] = 1; l = nextspritestat[l]; } - callsound(sn,ii); + A_CallSound(sn,ii); return; } } -void operaterespawns(int low) +void G_OperateRespawns(int low) { - int j, nexti, i = headspritestat[11]; + int j, nexti, i = headspritestat[STAT_FX]; while (i >= 0) { nexti = nextspritestat[i]; if ((SLT == low) && (PN == RESPAWN)) { - if (badguypic(SHT) && ud.monsters_off) break; + if (A_CheckEnemyTile(SHT) && ud.monsters_off) break; - j = spawn(i,TRANSPORTERSTAR); + j = A_Spawn(i,TRANSPORTERSTAR); sprite[j].z -= (32<<8); sprite[i].extra = 66-12; // Just a way to killit @@ -1004,13 +1005,13 @@ void operaterespawns(int low) } } -void operateactivators(int low,int snum) +void G_OperateActivators(int low,int snum) { int i, j, k; short *p; walltype *wal; - for (i=numcyclers-1;i>=0;i--) + for (i=g_numCyclers-1;i>=0;i--) { p = &cyclers[i][0]; @@ -1025,7 +1026,7 @@ void operateactivators(int low,int snum) } } - i = headspritestat[8]; + i = headspritestat[STAT_ACTIVATOR]; k = -1; while (i >= 0) { @@ -1041,8 +1042,8 @@ void operateactivators(int low,int snum) if (snum >= 0 && snum < ud.multimode) { if (sector[SECT].lotag&16384) - FTA(4,g_player[snum].ps); - else FTA(8,g_player[snum].ps); + P_DoQuote(4,g_player[snum].ps); + else P_DoQuote(8,g_player[snum].ps); } } else @@ -1078,8 +1079,8 @@ void operateactivators(int low,int snum) case 31: case 32: case 18: - hittype[j].temp_data[0] = 1-hittype[j].temp_data[0]; - callsound(SECT,j); + ActorExtra[j].temp_data[0] = 1-ActorExtra[j].temp_data[0]; + A_CallSound(SECT,j); break; } j = nextspritesect[j]; @@ -1087,20 +1088,20 @@ void operateactivators(int low,int snum) } if (k == -1 && (sector[SECT].lotag&0xff) == 22) - k = callsound(SECT,i); + k = A_CallSound(SECT,i); - operatesectors(SECT,i); + G_OperateSectors(SECT,i); } } i = nextspritestat[i]; } - operaterespawns(low); + G_OperateRespawns(low); } -void operatemasterswitches(int low) +void G_OperateMasterSwitches(int low) { - int i = headspritestat[6]; + int i = headspritestat[STAT_STANDABLE]; while (i >= 0) { if (PN == MASTERSWITCH && SLT == low && SP == 0) @@ -1109,9 +1110,9 @@ void operatemasterswitches(int low) } } -void operateforcefields(int s, int low) +void G_OperateForceFields(int s, int low) { - int i, p=numanimwalls; + int i, p=g_numAnimWalls; for (;p>=0;p--) { @@ -1138,7 +1139,7 @@ void operateforcefields(int s, int low) } } -int checkhitswitch(int snum,int w,int switchtype) +int P_ActivateSwitch(int snum,int w,int switchtype) { int switchpal, switchpicnum; int i, x, lotag,hitag,picnum,correctdips = 1, numdips = 0; @@ -1166,7 +1167,7 @@ int checkhitswitch(int snum,int w,int switchtype) picnum = wall[w].picnum; switchpal = wall[w].pal; } - // initprintf("checkhitswitch called picnum=%i switchtype=%i\n",picnum,switchtype); + // initprintf("P_ActivateSwitch called picnum=%i switchtype=%i\n",picnum,switchtype); switchpicnum = picnum; if ((picnum==DIPSWITCH+1) || (picnum==TECHSWITCH+1) @@ -1194,7 +1195,7 @@ int checkhitswitch(int snum,int w,int switchtype) switchpicnum = MULTISWITCH; } - switch (dynamictostatic[switchpicnum]) + switch (DynamicTileMap[switchpicnum]) { case DIPSWITCH__STATIC: // case DIPSWITCH+1: @@ -1211,21 +1212,21 @@ int checkhitswitch(int snum,int w,int switchtype) { if ((g_player[snum].ps->got_access&1)) g_player[snum].ps->access_incs = 1; - else FTA(70,g_player[snum].ps); + else P_DoQuote(70,g_player[snum].ps); } else if (switchpal == 21) { if (g_player[snum].ps->got_access&2) g_player[snum].ps->access_incs = 1; - else FTA(71,g_player[snum].ps); + else P_DoQuote(71,g_player[snum].ps); } else if (switchpal == 23) { if (g_player[snum].ps->got_access&4) g_player[snum].ps->access_incs = 1; - else FTA(72,g_player[snum].ps); + else P_DoQuote(72,g_player[snum].ps); } if (g_player[snum].ps->access_incs == 1) @@ -1271,11 +1272,11 @@ int checkhitswitch(int snum,int w,int switchtype) if (check_activator_motion(lotag)) return 0; break; default: - if (isadoorwall(picnum) == 0) return 0; + if (CheckDoorTile(picnum) == 0) return 0; break; } - i = headspritestat[0]; + i = headspritestat[STAT_DEFAULT]; while (i >= 0) { @@ -1289,7 +1290,7 @@ int checkhitswitch(int snum,int w,int switchtype) sprite[i].picnum = MULTISWITCH; } - switch (dynamictostatic[switchpicnum]) + switch (DynamicTileMap[switchpicnum]) { case DIPSWITCH__STATIC: @@ -1317,7 +1318,7 @@ int checkhitswitch(int snum,int w,int switchtype) sprite[i].picnum++; break; default: - switch (dynamictostatic[switchpicnum-1]) + switch (DynamicTileMap[switchpicnum-1]) { case TECHSWITCH__STATIC: @@ -1361,7 +1362,7 @@ int checkhitswitch(int snum,int w,int switchtype) wall[x].picnum = MULTISWITCH; } - switch (dynamictostatic[wall[x].picnum]) + switch (DynamicTileMap[wall[x].picnum]) { case DIPSWITCH__STATIC: @@ -1389,7 +1390,7 @@ int checkhitswitch(int snum,int w,int switchtype) wall[x].picnum++; break; default: - switch (dynamictostatic[wall[x].picnum-1]) + switch (DynamicTileMap[wall[x].picnum-1]) { case TECHSWITCH__STATIC: @@ -1469,10 +1470,10 @@ int checkhitswitch(int snum,int w,int switchtype) switchpicnum = MULTISWITCH; } - switch (dynamictostatic[switchpicnum]) + switch (DynamicTileMap[switchpicnum]) { default: - if (isadoorwall(picnum) == 0) break; + if (CheckDoorTile(picnum) == 0) break; case DIPSWITCH__STATIC: //case DIPSWITCH+1: case TECHSWITCH__STATIC: @@ -1486,17 +1487,17 @@ int checkhitswitch(int snum,int w,int switchtype) if (picnum == ALIENSWITCH || picnum == ALIENSWITCH+1) { if (switchtype == 1) - xyzsound(ALIEN_SWITCH1,w,sx,sy,g_player[snum].ps->posz); - else xyzsound(ALIEN_SWITCH1,g_player[snum].ps->i,sx,sy,g_player[snum].ps->posz); + S_PlaySoundXYZ(ALIEN_SWITCH1,w,sx,sy,g_player[snum].ps->posz); + else S_PlaySoundXYZ(ALIEN_SWITCH1,g_player[snum].ps->i,sx,sy,g_player[snum].ps->posz); } else { if (switchtype == 1) - xyzsound(SWITCH_ON,w,sx,sy,g_player[snum].ps->posz); - else xyzsound(SWITCH_ON,g_player[snum].ps->i,sx,sy,g_player[snum].ps->posz); + S_PlaySoundXYZ(SWITCH_ON,w,sx,sy,g_player[snum].ps->posz); + else S_PlaySoundXYZ(SWITCH_ON,g_player[snum].ps->i,sx,sy,g_player[snum].ps->posz); } if (numdips != correctdips) break; - xyzsound(END_OF_LEVEL_WARN,g_player[snum].ps->i,sx,sy,g_player[snum].ps->posz); + S_PlaySoundXYZ(END_OF_LEVEL_WARN,g_player[snum].ps->i,sx,sy,g_player[snum].ps->posz); } case DIPSWITCH2__STATIC: //case DIPSWITCH2+1: @@ -1535,7 +1536,7 @@ int checkhitswitch(int snum,int w,int switchtype) picnum == (MULTISWITCH+2) || picnum == (MULTISWITCH+3)) lotag += picnum-MULTISWITCH; - x = headspritestat[3]; + x = headspritestat[STAT_EFFECTOR]; while (x >= 0) { if (((sprite[x].hitag) == lotag)) @@ -1544,46 +1545,46 @@ int checkhitswitch(int snum,int w,int switchtype) { case 12: sector[sprite[x].sectnum].floorpal = 0; - hittype[x].temp_data[0]++; - if (hittype[x].temp_data[0] == 2) - hittype[x].temp_data[0]++; + ActorExtra[x].temp_data[0]++; + if (ActorExtra[x].temp_data[0] == 2) + ActorExtra[x].temp_data[0]++; break; case 24: case 34: case 25: - hittype[x].temp_data[4] = !hittype[x].temp_data[4]; - if (hittype[x].temp_data[4]) - FTA(15,g_player[snum].ps); - else FTA(2,g_player[snum].ps); + ActorExtra[x].temp_data[4] = !ActorExtra[x].temp_data[4]; + if (ActorExtra[x].temp_data[4]) + P_DoQuote(15,g_player[snum].ps); + else P_DoQuote(2,g_player[snum].ps); break; case 21: - FTA(2,g_player[screenpeek].ps); + P_DoQuote(2,g_player[screenpeek].ps); break; } } x = nextspritestat[x]; } - operateactivators(lotag,snum); - operateforcefields(g_player[snum].ps->i,lotag); - operatemasterswitches(lotag); + G_OperateActivators(lotag,snum); + G_OperateForceFields(g_player[snum].ps->i,lotag); + G_OperateMasterSwitches(lotag); if (picnum == DIPSWITCH || picnum == DIPSWITCH+1 || picnum == ALIENSWITCH || picnum == ALIENSWITCH+1 || picnum == TECHSWITCH || picnum == TECHSWITCH+1) return 1; - if (hitag == 0 && isadoorwall(picnum) == 0) + if (hitag == 0 && CheckDoorTile(picnum) == 0) { if (switchtype == 1) - xyzsound(SWITCH_ON,w,sx,sy,g_player[snum].ps->posz); - else xyzsound(SWITCH_ON,g_player[snum].ps->i,sx,sy,g_player[snum].ps->posz); + S_PlaySoundXYZ(SWITCH_ON,w,sx,sy,g_player[snum].ps->posz); + else S_PlaySoundXYZ(SWITCH_ON,g_player[snum].ps->i,sx,sy,g_player[snum].ps->posz); } else if (hitag != 0) { if (switchtype == 1 && (g_sounds[hitag].m&4) == 0) - xyzsound(hitag,w,sx,sy,g_player[snum].ps->posz); - else spritesound(hitag,g_player[snum].ps->i); + S_PlaySoundXYZ(hitag,w,sx,sy,g_player[snum].ps->posz); + else A_PlaySound(hitag,g_player[snum].ps->i); } return 1; @@ -1601,7 +1602,7 @@ void activatebysector(int sect,int j) { if (PN == ACTIVATOR) { - operateactivators(SLT,-1); + G_OperateActivators(SLT,-1); didit = 1; // return; } @@ -1609,38 +1610,38 @@ void activatebysector(int sect,int j) } if (didit == 0) - operatesectors(sect,j); + G_OperateSectors(sect,j); } -static void breakwall(int newpn,int spr,int dawallnum) +static void BreakWall(int newpn,int spr,int dawallnum) { wall[dawallnum].picnum = newpn; - spritesound(VENT_BUST,spr); - spritesound(GLASS_HEAVYBREAK,spr); - lotsofglass(spr,dawallnum,10); + A_PlaySound(VENT_BUST,spr); + A_PlaySound(GLASS_HEAVYBREAK,spr); + A_SpawnWallGlass(spr,dawallnum,10); } -void checkhitwall(int spr,int dawallnum,int x,int y,int z,int atwith) +void A_DamageWall(int spr,int dawallnum,int x,int y,int z,int atwith) { short sn = -1; int j, i, darkestwall; walltype *wal = &wall[dawallnum]; - if (wal->overpicnum == MIRROR && wal->pal != 4 && checkspriteflagsp(atwith,SPRITE_FLAG_PROJECTILE) && (hittype[spr].projectile.workslike & PROJECTILE_FLAG_RPG)) + if (wal->overpicnum == MIRROR && wal->pal != 4 && A_CheckSpriteTileFlags(atwith,SPRITE_PROJECTILE) && (ActorExtra[spr].projectile.workslike & PROJECTILE_RPG)) { if (wal->nextwall == -1 || wall[wal->nextwall].pal != 4) { - lotsofglass(spr,dawallnum,70); + A_SpawnWallGlass(spr,dawallnum,70); wal->cstat &= ~16; wal->overpicnum = MIRRORBROKE; - spritesound(GLASS_HEAVYBREAK,spr); + A_PlaySound(GLASS_HEAVYBREAK,spr); return; } } if (wal->overpicnum == MIRROR && wal->pal != 4) { - switch (dynamictostatic[atwith]) + switch (DynamicTileMap[atwith]) { case HEAVYHBOMB__STATIC: case RADIUSEXPLOSION__STATIC: @@ -1651,10 +1652,10 @@ void checkhitwall(int spr,int dawallnum,int x,int y,int z,int atwith) case EXPLODINGBARREL__STATIC: if (wal->nextwall == -1 || wall[wal->nextwall].pal != 4) { - lotsofglass(spr,dawallnum,70); + A_SpawnWallGlass(spr,dawallnum,70); wal->cstat &= ~16; wal->overpicnum = MIRRORBROKE; - spritesound(GLASS_HEAVYBREAK,spr); + A_PlaySound(GLASS_HEAVYBREAK,spr); return; } } @@ -1667,7 +1668,7 @@ void checkhitwall(int spr,int dawallnum,int x,int y,int z,int atwith) int switchpicnum = wal->overpicnum; if ((switchpicnum > W_FORCEFIELD)&&(switchpicnum <= W_FORCEFIELD+2)) switchpicnum = W_FORCEFIELD; - switch (dynamictostatic[switchpicnum]) + switch (DynamicTileMap[switchpicnum]) { case W_FORCEFIELD__STATIC: //case W_FORCEFIELD+1: @@ -1678,19 +1679,19 @@ void checkhitwall(int spr,int dawallnum,int x,int y,int z,int atwith) if (sn < 0) return; if (atwith == -1) - i = EGS(sn,x,y,z,FORCERIPPLE,-127,8,8,0,0,0,spr,5); + i = A_InsertSprite(sn,x,y,z,FORCERIPPLE,-127,8,8,0,0,0,spr,5); else { if (atwith == CHAINGUN) - i = EGS(sn,x,y,z,FORCERIPPLE,-127,16+sprite[spr].xrepeat,16+sprite[spr].yrepeat,0,0,0,spr,5); - else i = EGS(sn,x,y,z,FORCERIPPLE,-127,32,32,0,0,0,spr,5); + i = A_InsertSprite(sn,x,y,z,FORCERIPPLE,-127,16+sprite[spr].xrepeat,16+sprite[spr].yrepeat,0,0,0,spr,5); + else i = A_InsertSprite(sn,x,y,z,FORCERIPPLE,-127,32,32,0,0,0,spr,5); } CS |= 18+128; SA = getangle(wal->x-wall[wal->point2].x, wal->y-wall[wal->point2].y)-512; - spritesound(SOMETHINGHITFORCE,i); + A_PlaySound(SOMETHINGHITFORCE,i); return; @@ -1702,45 +1703,45 @@ void checkhitwall(int spr,int dawallnum,int x,int y,int z,int atwith) wall[wal->nextwall].overpicnum = FANSPRITEBROKE; wall[wal->nextwall].cstat &= 65535-65; } - spritesound(VENT_BUST,spr); - spritesound(GLASS_BREAKING,spr); + A_PlaySound(VENT_BUST,spr); + A_PlaySound(GLASS_BREAKING,spr); return; case GLASS__STATIC: updatesector(x,y,&sn); if (sn < 0) return; wal->overpicnum=GLASS2; - lotsofglass(spr,dawallnum,10); + A_SpawnWallGlass(spr,dawallnum,10); wal->cstat = 0; if (wal->nextwall >= 0) wall[wal->nextwall].cstat = 0; - i = EGS(sn,x,y,z,SECTOREFFECTOR,0,0,0,g_player[0].ps->ang,0,0,spr,3); + i = A_InsertSprite(sn,x,y,z,SECTOREFFECTOR,0,0,0,g_player[0].ps->ang,0,0,spr,3); SLT = 128; T2 = 5; T3 = dawallnum; - spritesound(GLASS_BREAKING,i); + A_PlaySound(GLASS_BREAKING,i); return; case STAINGLASS1__STATIC: updatesector(x,y,&sn); if (sn < 0) return; - lotsofcolourglass(spr,dawallnum,80); + A_SpawnRandomGlass(spr,dawallnum,80); wal->cstat = 0; if (wal->nextwall >= 0) wall[wal->nextwall].cstat = 0; - spritesound(VENT_BUST,spr); - spritesound(GLASS_BREAKING,spr); + A_PlaySound(VENT_BUST,spr); + A_PlaySound(GLASS_BREAKING,spr); return; } } - switch (dynamictostatic[wal->picnum]) + switch (DynamicTileMap[wal->picnum]) { case COLAMACHINE__STATIC: case VENDMACHINE__STATIC: - breakwall(wal->picnum+2,spr,dawallnum); - spritesound(VENT_BUST,spr); + BreakWall(wal->picnum+2,spr,dawallnum); + A_PlaySound(VENT_BUST,spr); return; case OJ__STATIC: @@ -1770,9 +1771,9 @@ void checkhitwall(int spr,int dawallnum,int x,int y,int z,int atwith) case SCREENBREAK19__STATIC: case BORNTOBEWILDSCREEN__STATIC: - lotsofglass(spr,dawallnum,30); - wal->picnum=W_SCREENBREAK+(TRAND%3); - spritesound(GLASS_HEAVYBREAK,spr); + A_SpawnWallGlass(spr,dawallnum,30); + wal->picnum=W_SCREENBREAK+(krand()%3); + A_PlaySound(GLASS_HEAVYBREAK,spr); return; case W_TECHWALL5__STATIC: @@ -1780,14 +1781,14 @@ void checkhitwall(int spr,int dawallnum,int x,int y,int z,int atwith) case W_TECHWALL7__STATIC: case W_TECHWALL8__STATIC: case W_TECHWALL9__STATIC: - breakwall(wal->picnum+1,spr,dawallnum); + BreakWall(wal->picnum+1,spr,dawallnum); return; case W_MILKSHELF__STATIC: - breakwall(W_MILKSHELFBROKE,spr,dawallnum); + BreakWall(W_MILKSHELFBROKE,spr,dawallnum); return; case W_TECHWALL10__STATIC: - breakwall(W_HITTECHWALL10,spr,dawallnum); + BreakWall(W_HITTECHWALL10,spr,dawallnum); return; case W_TECHWALL1__STATIC: @@ -1795,33 +1796,33 @@ void checkhitwall(int spr,int dawallnum,int x,int y,int z,int atwith) case W_TECHWALL12__STATIC: case W_TECHWALL13__STATIC: case W_TECHWALL14__STATIC: - breakwall(W_HITTECHWALL1,spr,dawallnum); + BreakWall(W_HITTECHWALL1,spr,dawallnum); return; case W_TECHWALL15__STATIC: - breakwall(W_HITTECHWALL15,spr,dawallnum); + BreakWall(W_HITTECHWALL15,spr,dawallnum); return; case W_TECHWALL16__STATIC: - breakwall(W_HITTECHWALL16,spr,dawallnum); + BreakWall(W_HITTECHWALL16,spr,dawallnum); return; case W_TECHWALL2__STATIC: - breakwall(W_HITTECHWALL2,spr,dawallnum); + BreakWall(W_HITTECHWALL2,spr,dawallnum); return; case W_TECHWALL3__STATIC: - breakwall(W_HITTECHWALL3,spr,dawallnum); + BreakWall(W_HITTECHWALL3,spr,dawallnum); return; case W_TECHWALL4__STATIC: - breakwall(W_HITTECHWALL4,spr,dawallnum); + BreakWall(W_HITTECHWALL4,spr,dawallnum); return; case ATM__STATIC: wal->picnum = ATMBROKE; - lotsofmoneymailpaper(spr,1+(TRAND&7),MONEY); - spritesound(GLASS_HEAVYBREAK,spr); + A_SpawnMultiple(spr, MONEY, 1+(krand()&7)); + A_PlaySound(GLASS_HEAVYBREAK,spr); break; case WALLLIGHT1__STATIC: @@ -1832,9 +1833,9 @@ void checkhitwall(int spr,int dawallnum,int x,int y,int z,int atwith) case TECHLIGHT4__STATIC: if (rnd(128)) - spritesound(GLASS_HEAVYBREAK,spr); - else spritesound(GLASS_BREAKING,spr); - lotsofglass(spr,dawallnum,30); + A_PlaySound(GLASS_HEAVYBREAK,spr); + else A_PlaySound(GLASS_BREAKING,spr); + A_SpawnWallGlass(spr,dawallnum,30); if (wal->picnum == WALLLIGHT1) wal->picnum = WALLLIGHTBUST1; @@ -1865,8 +1866,8 @@ void checkhitwall(int spr,int dawallnum,int x,int y,int z,int atwith) if (wal->shade > darkestwall) darkestwall=wal->shade; - j = TRAND&1; - i= headspritestat[3]; + j = krand()&1; + i= headspritestat[STAT_EFFECTOR]; while (i >= 0) { if (SHT == wall[dawallnum].lotag && SLT == 3) @@ -1881,7 +1882,7 @@ void checkhitwall(int spr,int dawallnum,int x,int y,int z,int atwith) } } -void checkplayerhurt(player_struct *p,int j) +void P_CheckTouchDamage(DukePlayer_t *p,int j) { if ((j&49152) == 49152) { @@ -1899,7 +1900,7 @@ void checkplayerhurt(player_struct *p,int j) p->pals[0] = 32; p->pals[1] = 0; p->pals[2] = 0; - spritesound(DUKE_LONGTERM_PAIN,p->i); + A_PlaySound(DUKE_LONGTERM_PAIN,p->i); } } @@ -1916,7 +1917,7 @@ void checkplayerhurt(player_struct *p,int j) if ((switchpicnum>W_FORCEFIELD)&&(switchpicnum<=W_FORCEFIELD+2)) switchpicnum=W_FORCEFIELD; - switch (dynamictostatic[switchpicnum]) + switch (DynamicTileMap[switchpicnum]) { case W_FORCEFIELD__STATIC: // case W_FORCEFIELD+1: @@ -1931,9 +1932,9 @@ void checkplayerhurt(player_struct *p,int j) p->posxv = -(sintable[(p->ang+512)&2047]<<8); p->posyv = -(sintable[(p->ang)&2047]<<8); - spritesound(DUKE_LONGTERM_PAIN,p->i); + A_PlaySound(DUKE_LONGTERM_PAIN,p->i); - checkhitwall(p->i,j, + A_DamageWall(p->i,j, p->posx+(sintable[(p->ang+512)&2047]>>9), p->posy+(sintable[p->ang&2047]>>9), p->posz,-1); @@ -1942,7 +1943,7 @@ void checkplayerhurt(player_struct *p,int j) case BIGFORCE__STATIC: p->hurt_delay = 26; - checkhitwall(p->i,j, + A_DamageWall(p->i,j, p->posx+(sintable[(p->ang+512)&2047]>>9), p->posy+(sintable[p->ang&2047]>>9), p->posz,-1); @@ -1952,11 +1953,11 @@ void checkplayerhurt(player_struct *p,int j) } } -int checkhitceiling(int sn) +int Sect_DamageCeiling(int sn) { int i, j; - switch (dynamictostatic[sector[sn].ceilingpicnum]) + switch (DynamicTileMap[sector[sn].ceilingpicnum]) { case WALLLIGHT1__STATIC: case WALLLIGHT2__STATIC: @@ -1965,8 +1966,8 @@ int checkhitceiling(int sn) case TECHLIGHT2__STATIC: case TECHLIGHT4__STATIC: - ceilingglass(g_player[myconnectindex].ps->i,sn,10); - spritesound(GLASS_BREAKING,g_player[screenpeek].ps->i); + A_SpawnCeilingGlass(g_player[myconnectindex].ps->i,sn,10); + A_PlaySound(GLASS_BREAKING,g_player[screenpeek].ps->i); if (sector[sn].ceilingpicnum == WALLLIGHT1) sector[sn].ceilingpicnum = WALLLIGHTBUST1; @@ -1994,11 +1995,11 @@ int checkhitceiling(int sn) { if (PN == SECTOREFFECTOR && SLT == 12) { - j = headspritestat[3]; + j = headspritestat[STAT_EFFECTOR]; while (j >= 0) { if (sprite[j].hitag == SHT) - hittype[j].temp_data[3] = 1; + ActorExtra[j].temp_data[3] = 1; j = nextspritestat[j]; } break; @@ -2007,8 +2008,8 @@ int checkhitceiling(int sn) } } - i = headspritestat[3]; - j = TRAND&1; + i = headspritestat[STAT_EFFECTOR]; + j = krand()&1; while (i >= 0) { if (SHT == (sector[sn].hitag) && SLT == 3) @@ -2025,7 +2026,8 @@ int checkhitceiling(int sn) return 0; } -void checkhitsprite(int i,int sn) +// hard coded props... :( +void A_DamageObject(int i,int sn) { short j; int k, p, rpg=0; @@ -2034,22 +2036,22 @@ void checkhitsprite(int i,int sn) i &= (MAXSPRITES-1); - if (checkspriteflags(sn,SPRITE_FLAG_PROJECTILE)) - if (hittype[sn].projectile.workslike & PROJECTILE_FLAG_RPG) + if (A_CheckSpriteFlags(sn,SPRITE_PROJECTILE)) + if (ActorExtra[sn].projectile.workslike & PROJECTILE_RPG) rpg = 1; switchpicnum = PN; if ((PN > WATERFOUNTAIN)&&(PN < WATERFOUNTAIN+3)) { switchpicnum = WATERFOUNTAIN; } - switch (dynamictostatic[PN]) + switch (DynamicTileMap[PN]) { case OCEANSPRITE1__STATIC: case OCEANSPRITE2__STATIC: case OCEANSPRITE3__STATIC: case OCEANSPRITE4__STATIC: case OCEANSPRITE5__STATIC: - spawn(i,SMALLSMOKE); + A_Spawn(i,SMALLSMOKE); deletesprite(i); break; case QUEBALL__STATIC: @@ -2059,19 +2061,19 @@ void checkhitsprite(int i,int sn) sprite[sn].xvel = (sprite[i].xvel>>1)+(sprite[i].xvel>>2); sprite[sn].ang -= (SA<<1)+1024; SA = getangle(SX-sprite[sn].x,SY-sprite[sn].y)-512; - if (issoundplaying(i,POOLBALLHIT) < 2) - spritesound(POOLBALLHIT,i); + if (S_CheckSoundPlaying(i,POOLBALLHIT) < 2) + A_PlaySound(POOLBALLHIT,i); } else { - if (TRAND&3) + if (krand()&3) { sprite[i].xvel = 164; sprite[i].ang = sprite[sn].ang; } else { - lotsofglass(i,-1,3); + A_SpawnWallGlass(i,-1,3); deletesprite(i); } } @@ -2087,9 +2089,9 @@ void checkhitsprite(int i,int sn) { CS &= ~257; T1 = 1; - spawn(i,BURNING); + A_Spawn(i,BURNING); } - switch (dynamictostatic[sprite[sn].picnum]) + switch (DynamicTileMap[sprite[sn].picnum]) { case RADIUSEXPLOSION__STATIC: case RPG__STATIC: @@ -2100,7 +2102,7 @@ void checkhitsprite(int i,int sn) { CS &= ~257; T1 = 1; - spawn(i,BURNING); + A_Spawn(i,BURNING); } break; } @@ -2111,11 +2113,11 @@ void checkhitsprite(int i,int sn) if (rpg == 1) for (k=64;k>0;k--) { - j = EGS(SECT,SX,SY,SZ-(TRAND%(48<<8)),SCRAP3+(TRAND&3),-8,48,48,TRAND&2047,(TRAND&63)+64,-(TRAND&4095)-(sprite[i].zvel>>2),i,5); + j = A_InsertSprite(SECT,SX,SY,SZ-(krand()%(48<<8)),SCRAP3+(krand()&3),-8,48,48,krand()&2047,(krand()&63)+64,-(krand()&4095)-(sprite[i].zvel>>2),i,5); sprite[j].pal = 8; } // case CACTUSBROKE: - switch (dynamictostatic[sprite[sn].picnum]) + switch (DynamicTileMap[sprite[sn].picnum]) { case RADIUSEXPLOSION__STATIC: case RPG__STATIC: @@ -2124,7 +2126,7 @@ void checkhitsprite(int i,int sn) case HEAVYHBOMB__STATIC: for (k=64;k>0;k--) { - j = EGS(SECT,SX,SY,SZ-(TRAND%(48<<8)),SCRAP3+(TRAND&3),-8,48,48,TRAND&2047,(TRAND&63)+64,-(TRAND&4095)-(sprite[i].zvel>>2),i,5); + j = A_InsertSprite(SECT,SX,SY,SZ-(krand()%(48<<8)),SCRAP3+(krand()&3),-8,48,48,krand()&2047,(krand()&63)+64,-(krand()&4095)-(sprite[i].zvel>>2),i,5); sprite[j].pal = 8; } @@ -2139,8 +2141,8 @@ void checkhitsprite(int i,int sn) case HANGLIGHT__STATIC: case GENERICPOLE2__STATIC: for (k=6;k>0;k--) - EGS(SECT,SX,SY,SZ-(8<<8),SCRAP1+(TRAND&15),-8,48,48,TRAND&2047,(TRAND&63)+64,-(TRAND&4095)-(sprite[i].zvel>>2),i,5); - spritesound(GLASS_HEAVYBREAK,i); + A_InsertSprite(SECT,SX,SY,SZ-(8<<8),SCRAP1+(krand()&15),-8,48,48,krand()&2047,(krand()&63)+64,-(krand()&4095)-(sprite[i].zvel>>2),i,5); + A_PlaySound(GLASS_HEAVYBREAK,i); deletesprite(i); break; @@ -2151,7 +2153,7 @@ void checkhitsprite(int i,int sn) if (sector[SECT].floorpicnum == FANSHADOW) sector[SECT].floorpicnum = FANSHADOWBROKE; - spritesound(GLASS_HEAVYBREAK,i); + A_PlaySound(GLASS_HEAVYBREAK,i); s = &sprite[i]; for (j=16;j>0;j--) RANDOMSCRAP; @@ -2161,7 +2163,7 @@ void checkhitsprite(int i,int sn) // case WATERFOUNTAIN+2: // case __STATIC: PN = WATERFOUNTAINBROKE; - spawn(i,TOILETWATER); + A_Spawn(i,TOILETWATER); break; case SATELITE__STATIC: case FUELPOD__STATIC: @@ -2170,9 +2172,9 @@ void checkhitsprite(int i,int sn) if (sprite[sn].extra != *actorscrptr[SHOTSPARK1]) { for (j=15;j>0;j--) - EGS(SECT,SX,SY,sector[SECT].floorz-(12<<8)-(j<<9),SCRAP1+(TRAND&15),-8,64,64, - TRAND&2047,(TRAND&127)+64,-(TRAND&511)-256,i,5); - spawn(i,EXPLOSION2); + A_InsertSprite(SECT,SX,SY,sector[SECT].floorz-(12<<8)-(j<<9),SCRAP1+(krand()&15),-8,64,64, + krand()&2047,(krand()&127)+64,-(krand()&511)-256,i,5); + A_Spawn(i,EXPLOSION2); deletesprite(i); } break; @@ -2205,111 +2207,111 @@ void checkhitsprite(int i,int sn) case STATUEFLASH__STATIC: case STATUE__STATIC: if (PN == BOTTLE10) - lotsofmoneymailpaper(i,4+(TRAND&3),MONEY); + A_SpawnMultiple(i, MONEY, 4+(krand()&3)); else if (PN == STATUE || PN == STATUEFLASH) { - lotsofcolourglass(i,-1,40); - spritesound(GLASS_HEAVYBREAK,i); + A_SpawnRandomGlass(i,-1,40); + A_PlaySound(GLASS_HEAVYBREAK,i); } else if (PN == VASE) - lotsofglass(i,-1,40); + A_SpawnWallGlass(i,-1,40); - spritesound(GLASS_BREAKING,i); - SA = TRAND&2047; - lotsofglass(i,-1,8); + A_PlaySound(GLASS_BREAKING,i); + SA = krand()&2047; + A_SpawnWallGlass(i,-1,8); deletesprite(i); break; case FETUS__STATIC: PN = FETUSBROKE; - spritesound(GLASS_BREAKING,i); - lotsofglass(i,-1,10); + A_PlaySound(GLASS_BREAKING,i); + A_SpawnWallGlass(i,-1,10); break; case FETUSBROKE__STATIC: for (j=48;j>0;j--) { - shoot(i,BLOODSPLAT1); + A_Shoot(i,BLOODSPLAT1); SA += 333; } - spritesound(GLASS_HEAVYBREAK,i); - spritesound(SQUISHED,i); + A_PlaySound(GLASS_HEAVYBREAK,i); + A_PlaySound(SQUISHED,i); case BOTTLE7__STATIC: - spritesound(GLASS_BREAKING,i); - lotsofglass(i,-1,10); + A_PlaySound(GLASS_BREAKING,i); + A_SpawnWallGlass(i,-1,10); deletesprite(i); break; case HYDROPLANT__STATIC: PN = BROKEHYDROPLANT; - spritesound(GLASS_BREAKING,i); - lotsofglass(i,-1,10); + A_PlaySound(GLASS_BREAKING,i); + A_SpawnWallGlass(i,-1,10); break; case FORCESPHERE__STATIC: sprite[i].xrepeat = 0; - hittype[OW].temp_data[0] = 32; - hittype[OW].temp_data[1] = !hittype[OW].temp_data[1]; - hittype[OW].temp_data[2] ++; - spawn(i,EXPLOSION2); + ActorExtra[OW].temp_data[0] = 32; + ActorExtra[OW].temp_data[1] = !ActorExtra[OW].temp_data[1]; + ActorExtra[OW].temp_data[2] ++; + A_Spawn(i,EXPLOSION2); break; case BROKEHYDROPLANT__STATIC: if (CS&1) { - spritesound(GLASS_BREAKING,i); + A_PlaySound(GLASS_BREAKING,i); SZ += 16<<8; CS = 0; - lotsofglass(i,-1,5); + A_SpawnWallGlass(i,-1,5); } break; case TOILET__STATIC: PN = TOILETBROKE; - CS |= (TRAND&1)<<2; + CS |= (krand()&1)<<2; CS &= ~257; - spawn(i,TOILETWATER); - spritesound(GLASS_BREAKING,i); + A_Spawn(i,TOILETWATER); + A_PlaySound(GLASS_BREAKING,i); break; case STALL__STATIC: PN = STALLBROKE; - CS |= (TRAND&1)<<2; + CS |= (krand()&1)<<2; CS &= ~257; - spawn(i,TOILETWATER); - spritesound(GLASS_HEAVYBREAK,i); + A_Spawn(i,TOILETWATER); + A_PlaySound(GLASS_HEAVYBREAK,i); break; case HYDRENT__STATIC: PN = BROKEFIREHYDRENT; - spawn(i,TOILETWATER); + A_Spawn(i,TOILETWATER); // for(k=0;k<5;k++) // { - // j = EGS(SECT,SX,SY,SZ-(TRAND%(48<<8)),SCRAP3+(TRAND&3),-8,48,48,TRAND&2047,(TRAND&63)+64,-(TRAND&4095)-(sprite[i].zvel>>2),i,5); + // j = A_InsertSprite(SECT,SX,SY,SZ-(krand()%(48<<8)),SCRAP3+(krand()&3),-8,48,48,krand()&2047,(krand()&63)+64,-(krand()&4095)-(sprite[i].zvel>>2),i,5); // sprite[j].pal = 2; // } - spritesound(GLASS_HEAVYBREAK,i); + A_PlaySound(GLASS_HEAVYBREAK,i); break; case GRATE1__STATIC: PN = BGRATE1; CS &= (65535-256-1); - spritesound(VENT_BUST,i); + A_PlaySound(VENT_BUST,i); break; case CIRCLEPANNEL__STATIC: PN = CIRCLEPANNELBROKE; CS &= (65535-256-1); - spritesound(VENT_BUST,i); + A_PlaySound(VENT_BUST,i); break; case PANNEL1__STATIC: case PANNEL2__STATIC: PN = BPANNEL1; CS &= (65535-256-1); - spritesound(VENT_BUST,i); + A_PlaySound(VENT_BUST,i); break; case PANNEL3__STATIC: PN = BPANNEL3; CS &= (65535-256-1); - spritesound(VENT_BUST,i); + A_PlaySound(VENT_BUST,i); break; case PIPE1__STATIC: case PIPE2__STATIC: @@ -2317,7 +2319,7 @@ void checkhitsprite(int i,int sn) case PIPE4__STATIC: case PIPE5__STATIC: case PIPE6__STATIC: - switch (dynamictostatic[PN]) + switch (DynamicTileMap[PN]) { case PIPE1__STATIC: PN=PIPE1B; @@ -2339,7 +2341,7 @@ void checkhitsprite(int i,int sn) break; } - j = spawn(i,STEAM); + j = A_Spawn(i,STEAM); sprite[j].z = sector[SECT].floorz-(32<<8); break; @@ -2347,34 +2349,34 @@ void checkhitsprite(int i,int sn) case LUKE__STATIC: case INDY__STATIC: case JURYGUY__STATIC: - spritesound(SLT,i); - spawn(i,SHT); + A_PlaySound(SLT,i); + A_Spawn(i,SHT); case SPACEMARINE__STATIC: sprite[i].extra -= sprite[sn].extra; if (sprite[i].extra > 0) break; - SA = TRAND&2047; - shoot(i,BLOODSPLAT1); - SA = TRAND&2047; - shoot(i,BLOODSPLAT2); - SA = TRAND&2047; - shoot(i,BLOODSPLAT3); - SA = TRAND&2047; - shoot(i,BLOODSPLAT4); - SA = TRAND&2047; - shoot(i,BLOODSPLAT1); - SA = TRAND&2047; - shoot(i,BLOODSPLAT2); - SA = TRAND&2047; - shoot(i,BLOODSPLAT3); - SA = TRAND&2047; - shoot(i,BLOODSPLAT4); - guts(i,JIBS1,1); - guts(i,JIBS2,2); - guts(i,JIBS3,3); - guts(i,JIBS4,4); - guts(i,JIBS5,1); - guts(i,JIBS3,6); - sound(SQUISHED); + SA = krand()&2047; + A_Shoot(i,BLOODSPLAT1); + SA = krand()&2047; + A_Shoot(i,BLOODSPLAT2); + SA = krand()&2047; + A_Shoot(i,BLOODSPLAT3); + SA = krand()&2047; + A_Shoot(i,BLOODSPLAT4); + SA = krand()&2047; + A_Shoot(i,BLOODSPLAT1); + SA = krand()&2047; + A_Shoot(i,BLOODSPLAT2); + SA = krand()&2047; + A_Shoot(i,BLOODSPLAT3); + SA = krand()&2047; + A_Shoot(i,BLOODSPLAT4); + A_DoGuts(i,JIBS1,1); + A_DoGuts(i,JIBS2,2); + A_DoGuts(i,JIBS3,3); + A_DoGuts(i,JIBS4,4); + A_DoGuts(i,JIBS5,1); + A_DoGuts(i,JIBS3,6); + S_PlaySound(SQUISHED); deletesprite(i); break; case CHAIR1__STATIC: @@ -2392,7 +2394,7 @@ void checkhitsprite(int i,int sn) case POT2__STATIC: case POT3__STATIC: case TRIPODCAMERA__STATIC: - spritesound(GLASS_HEAVYBREAK,i); + A_PlaySound(GLASS_HEAVYBREAK,i); s = &sprite[i]; for (j=16;j>0;j--) RANDOMSCRAP; deletesprite(i); @@ -2405,21 +2407,21 @@ void checkhitsprite(int i,int sn) if ((sprite[sn].picnum == FREEZEBLAST || sprite[sn].owner != i) && sprite[i].statnum != 4) { - if (badguy(&sprite[i]) == 1) + if (A_CheckEnemySprite(&sprite[i]) == 1) { if (sprite[sn].picnum == RPG) sprite[sn].extra <<= 1; if ((PN != DRONE) && (PN != ROTATEGUN) && (PN != COMMANDER) && (PN < GREENSLIME || PN > GREENSLIME+7)) if (sprite[sn].picnum != FREEZEBLAST) - if (actortype[PN] == 0) + if (ActorType[PN] == 0) { - j = spawn(sn,JIBS6); + j = A_Spawn(sn,JIBS6); if (sprite[sn].pal == 6) sprite[j].pal = 6; sprite[j].z += (4<<8); sprite[j].xvel = 16; sprite[j].xrepeat = sprite[j].yrepeat = 24; - sprite[j].ang += 32-(TRAND&63); + sprite[j].ang += 32-(krand()&63); } j = sprite[sn].owner; @@ -2427,10 +2429,10 @@ void checkhitsprite(int i,int sn) if (j >= 0 && sprite[j].picnum == APLAYER && PN != ROTATEGUN && PN != DRONE) if (g_player[sprite[j].yvel].ps->curr_weapon == SHOTGUN_WEAPON) { - shoot(i,BLOODSPLAT3); - shoot(i,BLOODSPLAT1); - shoot(i,BLOODSPLAT2); - shoot(i,BLOODSPLAT4); + A_Shoot(i,BLOODSPLAT3); + A_Shoot(i,BLOODSPLAT1); + A_Shoot(i,BLOODSPLAT2); + A_Shoot(i,BLOODSPLAT4); } if (PN != TANK && PN != BOSS1 && PN != BOSS4 && PN != BOSS2 && PN != BOSS3 && PN != RECON && PN != ROTATEGUN) @@ -2447,20 +2449,20 @@ void checkhitsprite(int i,int sn) if (sprite[i].statnum == 2) { changespritestat(i,1); - hittype[i].timetosleep = SLEEPTIME; + ActorExtra[i].timetosleep = SLEEPTIME; } if ((RX < 24 || PN == SHARK) && sprite[sn].picnum == SHRINKSPARK) return; } if (sprite[i].statnum != 2) { - if (sprite[sn].picnum == FREEZEBLAST && ((PN == APLAYER && sprite[i].pal == 1) || (freezerhurtowner == 0 && sprite[sn].owner == i))) + if (sprite[sn].picnum == FREEZEBLAST && ((PN == APLAYER && sprite[i].pal == 1) || (g_freezerSelfDamage == 0 && sprite[sn].owner == i))) return; - hittype[i].picnum = sprite[sn].picnum; - hittype[i].extra += sprite[sn].extra; - hittype[i].ang = sprite[sn].ang; - hittype[i].owner = sprite[sn].owner; + ActorExtra[i].picnum = sprite[sn].picnum; + ActorExtra[i].extra += sprite[sn].extra; + ActorExtra[i].ang = sprite[sn].ang; + ActorExtra[i].owner = sprite[sn].owner; } if (sprite[i].statnum == 10) @@ -2475,9 +2477,9 @@ void checkhitsprite(int i,int sn) g_player[p].ps->ang = g_player[p].ps->oang; updatesector(g_player[p].ps->posx,g_player[p].ps->posy,&g_player[p].ps->cursectnum); - setpal(g_player[p].ps); + P_UpdateScreenPal(g_player[p].ps); - j = headspritestat[1]; + j = headspritestat[STAT_ACTOR]; while (j >= 0) { if (sprite[j].picnum==CAMERA1) sprite[j].yvel = 0; @@ -2488,7 +2490,7 @@ void checkhitsprite(int i,int sn) if (RX < 24 && sprite[sn].picnum == SHRINKSPARK) return; - if (sprite[hittype[i].owner].picnum != APLAYER) + if (sprite[ActorExtra[i].owner].picnum != APLAYER) if (ud.player_skill >= 3) sprite[sn].extra += (sprite[sn].extra>>1); } @@ -2500,13 +2502,13 @@ void checkhitsprite(int i,int sn) void allignwarpelevators(void) { - int j, i = headspritestat[3]; + int j, i = headspritestat[STAT_EFFECTOR]; while (i >= 0) { if (SLT == 17 && SS > 16) { - j = headspritestat[3]; + j = headspritestat[STAT_EFFECTOR]; while (j >= 0) { if ((sprite[j].lotag) == 17 && i != j && @@ -2525,11 +2527,11 @@ void allignwarpelevators(void) } } -void sharedkeys(int snum) +void G_HandleSharedKeys(int snum) { int i, k, dainv; unsigned int sb_snum = g_player[snum].sync->bits, j; - player_struct *p = g_player[snum].ps; + DukePlayer_t *p = g_player[snum].ps; if (p->cheat_phase == 1) return; @@ -2556,7 +2558,7 @@ void sharedkeys(int snum) // 1<<23 = aim mode // 1<<24 = !holoduke // 1<<25 = !jetpack - // 1<<26 = gamequit + // 1<<26 = g_gameQuit // 1<<27 = !inventory right // 1<<28 = !turn around // 1<<29 = !open @@ -2564,31 +2566,34 @@ void sharedkeys(int snum) // 1<<31 = !escape i = p->aim_mode; - p->aim_mode = (sb_snum>>23)&1; + p->aim_mode = (sb_snum>>SK_AIMMODE)&1; if (p->aim_mode < i) p->return_to_center = 9; - if ((sb_snum&(1<<22)) && p->quick_kick == 0) + if (TEST_SYNC_KEY(sb_snum, SK_QUICK_KICK) && p->quick_kick == 0) if (p->curr_weapon != KNEE_WEAPON || p->kickback_pic == 0) { - SetGameVarID(g_iReturnVarID,0,g_player[snum].ps->i,snum); - OnEvent(EVENT_QUICKKICK,g_player[snum].ps->i,snum, -1); - if (GetGameVarID(g_iReturnVarID,g_player[snum].ps->i,snum) == 0) + Gv_SetVar(g_iReturnVarID,0,g_player[snum].ps->i,snum); + X_OnEvent(EVENT_QUICKKICK,g_player[snum].ps->i,snum, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[snum].ps->i,snum) == 0) { p->quick_kick = 14; if (p->fta == 0 || p->ftq == 80) - FTA(80,p); + P_DoQuote(80,p); } } - j = sb_snum & ((15<<8)|(1<<12)|(1<<15)|(1<<16)|(1<<22)|(1<<19)|(1<<20)|(1<<21)|(1<<24)|(1<<25)|(1<<27)|(1<<28)|(1<<29)|(1<<30)|(1<<31)); + // j = sb_snum & ((15<<8)|(1<<12)|(1<<15)|(1<<16)|(1<<22)|(1<<19)|(1<<20)|(1<<21)|(1<<24)|(1<<25)|(1<<27)|(1<<28)|(1<<29)|(1<<30)|(1<<31)); + j = sb_snum & ((15<<8)|BIT(SK_STEROIDS)|BIT(SK_NIGHTVISION)|BIT(SK_MEDKIT)|BIT(SK_QUICK_KICK)| \ + BIT(SK_HOLSTER)|BIT(SK_INV_LEFT)|BIT(SK_PAUSE)|BIT(SK_HOLODUKE)|BIT(SK_JETPACK)|BIT(SK_INV_RIGHT)| \ + BIT(SK_TURNAROUND)|BIT(SK_OPEN)|BIT(SK_INVENTORY)|BIT(SK_ESCAPE)); sb_snum = j & ~p->interface_toggle_flag; p->interface_toggle_flag |= sb_snum | ((sb_snum&0xf00)?0xf00:0); p->interface_toggle_flag &= j | ((j&0xf00)?0xf00:0); - if (sb_snum && (sb_snum&(1<<17)) == 0) + if (sb_snum && TEST_SYNC_KEY(sb_snum, SK_MULTIFLAG) == 0) { - if (sb_snum&(1<<21)) + if (TEST_SYNC_KEY(sb_snum, SK_PAUSE)) { KB_ClearKeyDown(sc_Pause); if (ud.pause_on) @@ -2598,7 +2603,7 @@ void sharedkeys(int snum) { MUSIC_Pause(); FX_StopAllSounds(); - clearsoundlocks(); + S_ClearSoundLocks(); } else { @@ -2612,59 +2617,59 @@ void sharedkeys(int snum) if (sprite[p->i].extra <= 0) return; // if dead... - if (sb_snum&(1<<30) && p->newowner == -1) // inventory button generates event for selected item + if (TEST_SYNC_KEY(sb_snum, SK_INVENTORY) && p->newowner == -1) // inventory button generates event for selected item { - SetGameVarID(g_iReturnVarID,0,g_player[snum].ps->i,snum); - OnEvent(EVENT_INVENTORY,g_player[snum].ps->i,snum, -1); - if (GetGameVarID(g_iReturnVarID,g_player[snum].ps->i,snum) == 0) + Gv_SetVar(g_iReturnVarID,0,g_player[snum].ps->i,snum); + X_OnEvent(EVENT_INVENTORY,g_player[snum].ps->i,snum, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[snum].ps->i,snum) == 0) { switch (p->inven_icon) { case 4: - sb_snum |= (1<<25); + sb_snum |= BIT(SK_JETPACK); break; case 3: - sb_snum |= (1<<24); + sb_snum |= BIT(SK_HOLODUKE); break; case 5: - sb_snum |= (1<<15); + sb_snum |= BIT(SK_NIGHTVISION); break; case 1: - sb_snum |= (1<<16); + sb_snum |= BIT(SK_MEDKIT); break; case 2: - sb_snum |= (1<<12); + sb_snum |= BIT(SK_STEROIDS); break; } } } - if (sb_snum&(1<<15)) + if (TEST_SYNC_KEY(sb_snum, SK_NIGHTVISION)) { - SetGameVarID(g_iReturnVarID,0,g_player[snum].ps->i,snum); - OnEvent(EVENT_USENIGHTVISION,g_player[snum].ps->i,snum, -1); - if (GetGameVarID(g_iReturnVarID,g_player[snum].ps->i,snum) == 0 + Gv_SetVar(g_iReturnVarID,0,g_player[snum].ps->i,snum); + X_OnEvent(EVENT_USENIGHTVISION,g_player[snum].ps->i,snum, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[snum].ps->i,snum) == 0 && p->heat_amount > 0) { p->heat_on = !p->heat_on; - setpal(p); + P_UpdateScreenPal(p); p->inven_icon = 5; - spritesound(NITEVISION_ONOFF,p->i); - FTA(106+(!p->heat_on),p); + A_PlaySound(NITEVISION_ONOFF,p->i); + P_DoQuote(106+(!p->heat_on),p); } } - if ((sb_snum&(1<<12))) + if (TEST_SYNC_KEY(sb_snum, SK_STEROIDS)) { - SetGameVarID(g_iReturnVarID,0,g_player[snum].ps->i,snum); - OnEvent(EVENT_USESTEROIDS,g_player[snum].ps->i,snum, -1); - if (GetGameVarID(g_iReturnVarID,g_player[snum].ps->i,snum) == 0) + Gv_SetVar(g_iReturnVarID,0,g_player[snum].ps->i,snum); + X_OnEvent(EVENT_USESTEROIDS,g_player[snum].ps->i,snum, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[snum].ps->i,snum) == 0) { if (p->steroids_amount == 400) { p->steroids_amount--; - spritesound(DUKE_TAKEPILLS,p->i); - FTA(12,p); + A_PlaySound(DUKE_TAKEPILLS,p->i); + P_DoQuote(12,p); } if (p->steroids_amount > 0) p->inven_icon = 2; @@ -2673,14 +2678,14 @@ void sharedkeys(int snum) } if (p->refresh_inventory) { - sb_snum|=(1<<20); // emulate move left... + sb_snum |= BIT(SK_INV_LEFT); // emulate move left... } if (p->newowner == -1) - if (sb_snum&(1<<20) || sb_snum&(1<<27)) + if (TEST_SYNC_KEY(sb_snum, SK_INV_LEFT|SK_INV_RIGHT)) { p->invdisptime = 26*2; - if (sb_snum&(1<<27)) k = 1; + if (TEST_SYNC_KEY(sb_snum, SK_INV_RIGHT)) k = 1; else k = 0; if (p->refresh_inventory) p->refresh_inventory = 0; @@ -2742,17 +2747,17 @@ CHECKINV1: } else dainv = 0; - if (sb_snum&(1<<20)) // Inventory_Left + if (TEST_SYNC_KEY(sb_snum, SK_INV_LEFT)) // Inventory_Left { - SetGameVarID(g_iReturnVarID,dainv,g_player[snum].ps->i,snum); - OnEvent(EVENT_INVENTORYLEFT,g_player[snum].ps->i,snum, -1); - dainv=GetGameVarID(g_iReturnVarID,g_player[snum].ps->i,snum); + Gv_SetVar(g_iReturnVarID,dainv,g_player[snum].ps->i,snum); + X_OnEvent(EVENT_INVENTORYLEFT,g_player[snum].ps->i,snum, -1); + dainv=Gv_GetVar(g_iReturnVarID,g_player[snum].ps->i,snum); } - if (sb_snum&(1<<27)) // Inventory_Right + if (TEST_SYNC_KEY(sb_snum, SK_INV_RIGHT)) // Inventory_Right { - SetGameVarID(g_iReturnVarID,dainv,g_player[snum].ps->i,snum); - OnEvent(EVENT_INVENTORYRIGHT,g_player[snum].ps->i,snum, -1); - dainv=GetGameVarID(g_iReturnVarID,g_player[snum].ps->i,snum); + Gv_SetVar(g_iReturnVarID,dainv,g_player[snum].ps->i,snum); + X_OnEvent(EVENT_INVENTORYRIGHT,g_player[snum].ps->i,snum, -1); + dainv=Gv_GetVar(g_iReturnVarID,g_player[snum].ps->i,snum); } p->inven_icon = dainv; @@ -2760,75 +2765,75 @@ CHECKINV1: switch (dainv) { case 1: - FTA(3,p); + P_DoQuote(3,p); break; case 2: - FTA(90,p); + P_DoQuote(90,p); break; case 3: - FTA(91,p); + P_DoQuote(91,p); break; case 4: - FTA(88,p); + P_DoQuote(88,p); break; case 5: - FTA(101,p); + P_DoQuote(101,p); break; case 6: - FTA(89,p); + P_DoQuote(89,p); break; case 7: - FTA(6,p); + P_DoQuote(6,p); break; } } - j = ((sb_snum&(15<<8))>>8) - 1; + j = ((sb_snum&(15<>SK_WEAPON_BITS) - 1; - SetGameVarID(g_iReturnVarID,j,p->i,snum); + Gv_SetVar(g_iReturnVarID,j,p->i,snum); switch (j) { case 0: - OnEvent(EVENT_WEAPKEY1,p->i,snum, -1); + X_OnEvent(EVENT_WEAPKEY1,p->i,snum, -1); break; case 1: - OnEvent(EVENT_WEAPKEY2,p->i,snum, -1); + X_OnEvent(EVENT_WEAPKEY2,p->i,snum, -1); break; case 2: - OnEvent(EVENT_WEAPKEY3,p->i,snum, -1); + X_OnEvent(EVENT_WEAPKEY3,p->i,snum, -1); break; case 3: - OnEvent(EVENT_WEAPKEY4,p->i,snum, -1); + X_OnEvent(EVENT_WEAPKEY4,p->i,snum, -1); break; case 4: - OnEvent(EVENT_WEAPKEY5,p->i,snum, -1); + X_OnEvent(EVENT_WEAPKEY5,p->i,snum, -1); break; case 5: - OnEvent(EVENT_WEAPKEY6,p->i,snum, -1); + X_OnEvent(EVENT_WEAPKEY6,p->i,snum, -1); break; case 6: - OnEvent(EVENT_WEAPKEY7,p->i,snum, -1); + X_OnEvent(EVENT_WEAPKEY7,p->i,snum, -1); break; case 7: - OnEvent(EVENT_WEAPKEY8,p->i,snum, -1); + X_OnEvent(EVENT_WEAPKEY8,p->i,snum, -1); break; case 8: - OnEvent(EVENT_WEAPKEY9,p->i,snum, -1); + X_OnEvent(EVENT_WEAPKEY9,p->i,snum, -1); break; case 9: - OnEvent(EVENT_WEAPKEY10,p->i,snum, -1); + X_OnEvent(EVENT_WEAPKEY10,p->i,snum, -1); break; case 10: - OnEvent(EVENT_PREVIOUSWEAPON,p->i,snum, -1); + X_OnEvent(EVENT_PREVIOUSWEAPON,p->i,snum, -1); break; case 11: - OnEvent(EVENT_NEXTWEAPON,p->i,snum, -1); + X_OnEvent(EVENT_NEXTWEAPON,p->i,snum, -1); break; } - if ((unsigned int) GetGameVarID(g_iReturnVarID,p->i,snum) != j) - j = (unsigned int) GetGameVarID(g_iReturnVarID,p->i,snum); + if ((unsigned int) Gv_GetVar(g_iReturnVarID,p->i,snum) != j) + j = (unsigned int) Gv_GetVar(g_iReturnVarID,p->i,snum); if (p->reloading == 1) j = -1; @@ -2893,7 +2898,7 @@ CHECKINV1: i++; // absolutely no weapons, so use foot if (i == 10) { - addweapon(p, KNEE_WEAPON); + P_AddWeapon(p, KNEE_WEAPON); break; } } @@ -2901,14 +2906,14 @@ CHECKINV1: k = -1; - SetGameVarID(g_iWeaponVarID,j, p->i, snum); - SetGameVarID(g_iReturnVarID,0,p->i,snum); - OnEvent(EVENT_SELECTWEAPON,p->i,snum, -1); - if (GetGameVarID(g_iReturnVarID,p->i,snum) == 0) + Gv_SetVar(g_iWeaponVarID,j, p->i, snum); + Gv_SetVar(g_iReturnVarID,0,p->i,snum); + X_OnEvent(EVENT_SELECTWEAPON,p->i,snum, -1); + if (Gv_GetVar(g_iReturnVarID,p->i,snum) == 0) { if (j == HANDBOMB_WEAPON && p->ammo_amount[HANDBOMB_WEAPON] == 0) { - k = headspritestat[1]; + k = headspritestat[STAT_ACTOR]; while (k >= 0) { if (sprite[k].picnum == HEAVYHBOMB && sprite[k].owner == p->i) @@ -2951,14 +2956,14 @@ CHECKINV1: if (p->holster_weapon) { - sb_snum |= 1<<19; + sb_snum |= BIT(SK_HOLSTER); p->weapon_pos = -9; } else if ((int)j >= 0 && p->gotweapon[j] && (unsigned int)p->curr_weapon != j) switch (j) { case KNEE_WEAPON: - addweapon(p, KNEE_WEAPON); + P_AddWeapon(p, KNEE_WEAPON); break; case PISTOL_WEAPON: if (p->ammo_amount[PISTOL_WEAPON] == 0) @@ -2967,7 +2972,7 @@ CHECKINV1: p->last_full_weapon = p->curr_weapon; p->show_empty_weapon = 32; } - addweapon(p, PISTOL_WEAPON); + P_AddWeapon(p, PISTOL_WEAPON); break; case SHOTGUN_WEAPON: if (p->ammo_amount[SHOTGUN_WEAPON] == 0 && p->show_empty_weapon == 0) @@ -2975,7 +2980,7 @@ CHECKINV1: p->last_full_weapon = p->curr_weapon; p->show_empty_weapon = 32; } - addweapon(p, SHOTGUN_WEAPON); + P_AddWeapon(p, SHOTGUN_WEAPON); break; case CHAINGUN_WEAPON: if (p->ammo_amount[CHAINGUN_WEAPON] == 0 && p->show_empty_weapon == 0) @@ -2983,7 +2988,7 @@ CHECKINV1: p->last_full_weapon = p->curr_weapon; p->show_empty_weapon = 32; } - addweapon(p, CHAINGUN_WEAPON); + P_AddWeapon(p, CHAINGUN_WEAPON); break; case RPG_WEAPON: if (p->ammo_amount[RPG_WEAPON] == 0) @@ -2992,7 +2997,7 @@ CHECKINV1: p->last_full_weapon = p->curr_weapon; p->show_empty_weapon = 32; } - addweapon(p, RPG_WEAPON); + P_AddWeapon(p, RPG_WEAPON); break; case DEVISTATOR_WEAPON: if (p->ammo_amount[DEVISTATOR_WEAPON] == 0 && p->show_empty_weapon == 0) @@ -3000,7 +3005,7 @@ CHECKINV1: p->last_full_weapon = p->curr_weapon; p->show_empty_weapon = 32; } - addweapon(p, DEVISTATOR_WEAPON); + P_AddWeapon(p, DEVISTATOR_WEAPON); break; case FREEZE_WEAPON: if (p->ammo_amount[FREEZE_WEAPON] == 0 && p->show_empty_weapon == 0) @@ -3008,7 +3013,7 @@ CHECKINV1: p->last_full_weapon = p->curr_weapon; p->show_empty_weapon = 32; } - addweapon(p, FREEZE_WEAPON); + P_AddWeapon(p, FREEZE_WEAPON); break; case GROW_WEAPON: case SHRINKER_WEAPON: @@ -3019,7 +3024,7 @@ CHECKINV1: p->last_full_weapon = p->curr_weapon; } - addweapon(p, j); + P_AddWeapon(p, j); break; case HANDREMOTE_WEAPON: if (k >= 0) // Found in list of [1]'s @@ -3031,17 +3036,17 @@ CHECKINV1: break; case HANDBOMB_WEAPON: if (p->ammo_amount[HANDBOMB_WEAPON] > 0 && p->gotweapon[HANDBOMB_WEAPON]) - addweapon(p, HANDBOMB_WEAPON); + P_AddWeapon(p, HANDBOMB_WEAPON); break; case TRIPBOMB_WEAPON: if (p->ammo_amount[TRIPBOMB_WEAPON] > 0 && p->gotweapon[TRIPBOMB_WEAPON]) - addweapon(p, TRIPBOMB_WEAPON); + P_AddWeapon(p, TRIPBOMB_WEAPON); break; } } } - if (sb_snum&(1<<19)) + if (TEST_SYNC_KEY(sb_snum, SK_HOLSTER)) { if (p->curr_weapon > KNEE_WEAPON) { @@ -3049,26 +3054,26 @@ CHECKINV1: { p->holster_weapon = 1; p->weapon_pos = -1; - FTA(73,p); + P_DoQuote(73,p); } else if (p->holster_weapon == 1 && p->weapon_pos == -9) { p->holster_weapon = 0; p->weapon_pos = 10; - FTA(74,p); + P_DoQuote(74,p); } } } } - if (sb_snum&(1<<24) && p->newowner == -1) + if (TEST_SYNC_KEY(sb_snum, SK_HOLODUKE) && p->newowner == -1) { if (p->holoduke_on == -1) { - SetGameVarID(g_iReturnVarID,0,g_player[snum].ps->i,snum); - OnEvent(EVENT_HOLODUKEON,g_player[snum].ps->i,snum, -1); - if (GetGameVarID(g_iReturnVarID,g_player[snum].ps->i,snum) == 0) + Gv_SetVar(g_iReturnVarID,0,g_player[snum].ps->i,snum); + X_OnEvent(EVENT_HOLODUKEON,g_player[snum].ps->i,snum, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[snum].ps->i,snum) == 0) { if (p->holoduke_amount > 0) { @@ -3077,38 +3082,38 @@ CHECKINV1: if (p->cursectnum > -1) { p->holoduke_on = i = - EGS(p->cursectnum, - p->posx, - p->posy, - p->posz+(30<<8),APLAYER,-64,0,0,p->ang,0,0,-1,10); + A_InsertSprite(p->cursectnum, + p->posx, + p->posy, + p->posz+(30<<8),APLAYER,-64,0,0,p->ang,0,0,-1,10); T4 = T5 = 0; SP = snum; sprite[i].extra = 0; - FTA(47,p); - spritesound(TELEPORTER,p->holoduke_on); + P_DoQuote(47,p); + A_PlaySound(TELEPORTER,p->holoduke_on); } } - else FTA(49,p); + else P_DoQuote(49,p); } } else { - SetGameVarID(g_iReturnVarID,0,g_player[snum].ps->i,snum); - OnEvent(EVENT_HOLODUKEOFF,g_player[snum].ps->i,snum, -1); - if (GetGameVarID(g_iReturnVarID,g_player[snum].ps->i,snum) == 0) + Gv_SetVar(g_iReturnVarID,0,g_player[snum].ps->i,snum); + X_OnEvent(EVENT_HOLODUKEOFF,g_player[snum].ps->i,snum, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[snum].ps->i,snum) == 0) { - spritesound(TELEPORTER,p->holoduke_on); + A_PlaySound(TELEPORTER,p->holoduke_on); p->holoduke_on = -1; - FTA(48,p); + P_DoQuote(48,p); } } } - if (sb_snum&(1<<16)) + if (TEST_SYNC_KEY(sb_snum, SK_MEDKIT)) { - SetGameVarID(g_iReturnVarID,0,g_player[snum].ps->i,snum); - OnEvent(EVENT_USEMEDKIT,g_player[snum].ps->i,snum, -1); - if (GetGameVarID(g_iReturnVarID,g_player[snum].ps->i,snum) == 0) + Gv_SetVar(g_iReturnVarID,0,g_player[snum].ps->i,snum); + X_OnEvent(EVENT_USEMEDKIT,g_player[snum].ps->i,snum, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[snum].ps->i,snum) == 0) { if (p->firstaid_amount > 0 && sprite[p->i].extra < p->max_player_health) { @@ -3124,18 +3129,18 @@ CHECKINV1: { sprite[p->i].extra += p->firstaid_amount; p->firstaid_amount = 0; - checkavailinven(p); + P_SelectNextInventoryItem(p); } - spritesound(DUKE_USEMEDKIT,p->i); + A_PlaySound(DUKE_USEMEDKIT,p->i); } } } - if (sb_snum&(1<<25) && p->newowner == -1) + if (TEST_SYNC_KEY(sb_snum, SK_JETPACK) && p->newowner == -1) { - SetGameVarID(g_iReturnVarID,0,g_player[snum].ps->i,snum); - OnEvent(EVENT_USEJETPACK,g_player[snum].ps->i,snum, -1); - if (GetGameVarID(g_iReturnVarID,g_player[snum].ps->i,snum) == 0) + Gv_SetVar(g_iReturnVarID,0,g_player[snum].ps->i,snum); + X_OnEvent(EVENT_USEJETPACK,g_player[snum].ps->i,snum, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[snum].ps->i,snum) == 0) { if (p->jetpack_amount > 0) { @@ -3146,33 +3151,33 @@ CHECKINV1: if (p->scream_voice > FX_Ok) { FX_StopSound(p->scream_voice); - testcallback(DUKE_SCREAM); + S_TestSoundCallback(DUKE_SCREAM); p->scream_voice = FX_Ok; } - spritesound(DUKE_JETPACK_ON,p->i); + A_PlaySound(DUKE_JETPACK_ON,p->i); - FTA(52,p); + P_DoQuote(52,p); } else { p->hard_landing = 0; p->poszv = 0; - spritesound(DUKE_JETPACK_OFF,p->i); - stopspritesound(DUKE_JETPACK_IDLE,p->i); - stopspritesound(DUKE_JETPACK_ON,p->i); - FTA(53,p); + A_PlaySound(DUKE_JETPACK_OFF,p->i); + A_StopSound(DUKE_JETPACK_IDLE,p->i); + A_StopSound(DUKE_JETPACK_ON,p->i); + P_DoQuote(53,p); } } - else FTA(50,p); + else P_DoQuote(50,p); } } - if (sb_snum&(1<<28) && p->one_eighty_count == 0) + if (TEST_SYNC_KEY(sb_snum, SK_TURNAROUND) && p->one_eighty_count == 0) { - SetGameVarID(g_iReturnVarID,0,p->i,snum); - OnEvent(EVENT_TURNAROUND,p->i,snum, -1); - if (GetGameVarID(g_iReturnVarID,p->i,snum) == 0) + Gv_SetVar(g_iReturnVarID,0,p->i,snum); + X_OnEvent(EVENT_TURNAROUND,p->i,snum, -1); + if (Gv_GetVar(g_iReturnVarID,p->i,snum) == 0) { p->one_eighty_count = -1024; } @@ -3180,12 +3185,12 @@ CHECKINV1: } } -int hitasprite(int i,short *hitsp) +int A_CheckHitSprite(int i,short *hitsp) { int sx,sy,sz,zoff; short sect,hw; - if (badguy(&sprite[i])) + if (A_CheckEnemySprite(&sprite[i])) zoff = (42<<8); else if (PN == APLAYER) zoff = (39<<8); else zoff = 0; @@ -3195,13 +3200,13 @@ int hitasprite(int i,short *hitsp) sintable[SA&2047], 0,§,&hw,hitsp,&sx,&sy,&sz,CLIPMASK1); - if (hw >= 0 && (wall[hw].cstat&16) && badguy(&sprite[i])) + if (hw >= 0 && (wall[hw].cstat&16) && A_CheckEnemySprite(&sprite[i])) return((1<<30)); return (FindDistance2D(sx-SX,sy-SY)); } -static int hitawall(player_struct *p,short *hitw) +static int hitawall(DukePlayer_t *p,short *hitw) { int sx,sy,sz; short sect,hs; @@ -3218,7 +3223,7 @@ static int hitawall(player_struct *p,short *hitw) void checksectors(int snum) { int i = -1,oldz; - player_struct *p = g_player[snum].ps; + DukePlayer_t *p = g_player[snum].ps; short j,hitscanwall; if (p->cursectnum > -1) @@ -3227,12 +3232,12 @@ void checksectors(int snum) case 32767: sector[p->cursectnum].lotag = 0; - FTA(9,p); + P_DoQuote(9,p); p->secret_rooms++; return; case -1: - for (i=connecthead;i>=0;i=connectpoint2[i]) - g_player[i].ps->gm = MODE_EOL; + TRAVERSE_CONNECT(i) + g_player[i].ps->gm = MODE_EOL; sector[p->cursectnum].lotag = 0; if (ud.from_bonus) { @@ -3256,8 +3261,8 @@ void checksectors(int snum) default: if (sector[p->cursectnum].lotag >= 10000 && sector[p->cursectnum].lotag < 16383) { - if (snum == screenpeek || (gametype_flags[ud.coop]&GAMETYPE_FLAG_COOPSOUND)) - spritesound(sector[p->cursectnum].lotag-10000,p->i); + if (snum == screenpeek || (GametypeFlags[ud.coop]&GAMETYPE_COOPSOUND)) + A_PlaySound(sector[p->cursectnum].lotag-10000,p->i); sector[p->cursectnum].lotag = 0; } break; @@ -3268,16 +3273,16 @@ void checksectors(int snum) if (p->gm&MODE_TYPE || sprite[p->i].extra <= 0) return; - if ((g_player[snum].sync->bits&(1<<29))) + if (TEST_SYNC_KEY(g_player[snum].sync->bits, SK_OPEN)) { - SetGameVarID(g_iReturnVarID,0,p->i,snum); - OnEvent(EVENT_USE, p->i, snum, -1); - if (GetGameVarID(g_iReturnVarID,p->i,snum) != 0) - g_player[snum].sync->bits &= ~(1<<29); + Gv_SetVar(g_iReturnVarID,0,p->i,snum); + X_OnEvent(EVENT_USE, p->i, snum, -1); + if (Gv_GetVar(g_iReturnVarID,p->i,snum) != 0) + g_player[snum].sync->bits &= ~BIT(SK_OPEN); } - if (ud.cashman && g_player[snum].sync->bits&(1<<29)) - lotsofmoneymailpaper(p->i,2,MONEY); + if (ud.cashman && TEST_SYNC_KEY(g_player[snum].sync->bits, SK_OPEN)) + A_SpawnMultiple(p->i, MONEY, 2); if (p->newowner >= 0) { @@ -3288,13 +3293,13 @@ void checksectors(int snum) } } - if (!(g_player[snum].sync->bits&(1<<29)) && !(g_player[snum].sync->bits&(1<<31))) + if (!TEST_SYNC_KEY(g_player[snum].sync->bits, SK_OPEN) && !TEST_SYNC_KEY(g_player[snum].sync->bits, SK_ESCAPE)) p->toggle_key_flag = 0; else if (!p->toggle_key_flag) { - if ((g_player[snum].sync->bits&(1<<31))) + if (TEST_SYNC_KEY(g_player[snum].sync->bits, SK_ESCAPE)) { if (p->newowner >= 0) { @@ -3311,9 +3316,9 @@ void checksectors(int snum) i = hitawall(p,&hitscanwall); if (i < 1280 && hitscanwall >= 0 && wall[hitscanwall].overpicnum == MIRROR) - if (wall[hitscanwall].lotag > 0 && !isspritemakingsound(p->i,wall[hitscanwall].lotag) && snum == screenpeek) + if (wall[hitscanwall].lotag > 0 && !A_CheckSoundPlaying(p->i,wall[hitscanwall].lotag) && snum == screenpeek) { - spritesound(wall[hitscanwall].lotag,p->i); + A_PlaySound(wall[hitscanwall].lotag,p->i); return; } @@ -3339,7 +3344,7 @@ void checksectors(int snum) neartag(p->posx,p->posy,p->posz+(16<<8),sprite[p->i].sectnum,p->oang,&neartagsector,&neartagwall,&neartagsprite,&neartaghitdist,1280L,3); if (neartagsprite >= 0) { - switch (dynamictostatic[sprite[neartagsprite].picnum]) + switch (DynamicTileMap[sprite[neartagsprite].picnum]) { case FEM1__STATIC: case FEM2__STATIC: @@ -3375,21 +3380,21 @@ void checksectors(int snum) if (neartagsprite == -1 && neartagwall == -1) if (sector[p->cursectnum].lotag == 2) { - oldz = hitasprite(p->i,&neartagsprite); + oldz = A_CheckHitSprite(p->i,&neartagsprite); if (oldz > 1280) neartagsprite = -1; } if (neartagsprite >= 0) { - if (checkhitswitch(snum,neartagsprite,1)) return; + if (P_ActivateSwitch(snum,neartagsprite,1)) return; - switch (dynamictostatic[sprite[neartagsprite].picnum]) + switch (DynamicTileMap[sprite[neartagsprite].picnum]) { case TOILET__STATIC: case STALL__STATIC: if (p->last_pissed_time == 0) { - if (ud.lockout == 0) spritesound(DUKE_URINATE,p->i); + if (ud.lockout == 0) A_PlaySound(DUKE_URINATE,p->i); p->last_pissed_time = 26*220; p->transporter_hold = 29*2; @@ -3406,24 +3411,24 @@ void checksectors(int snum) else if (sprite[p->i].extra < p->max_player_health) sprite[p->i].extra = p->max_player_health; } - else if (!isspritemakingsound(neartagsprite,FLUSH_TOILET)) - spritesound(FLUSH_TOILET,neartagsprite); + else if (!A_CheckSoundPlaying(neartagsprite,FLUSH_TOILET)) + A_PlaySound(FLUSH_TOILET,neartagsprite); return; case NUKEBUTTON__STATIC: hitawall(p,&j); if (j >= 0 && wall[j].overpicnum == 0) - if (hittype[neartagsprite].temp_data[0] == 0) + if (ActorExtra[neartagsprite].temp_data[0] == 0) { if (ud.noexits && ud.multimode > 1) { - hittype[p->i].picnum = NUKEBUTTON; - hittype[p->i].extra = 250; + ActorExtra[p->i].picnum = NUKEBUTTON; + ActorExtra[p->i].extra = 250; } else { - hittype[neartagsprite].temp_data[0] = 1; + ActorExtra[neartagsprite].temp_data[0] = 1; sprite[neartagsprite].owner = p->i; p->buttonpalette = sprite[neartagsprite].pal; if (p->buttonpalette) @@ -3433,21 +3438,21 @@ void checksectors(int snum) } return; case WATERFOUNTAIN__STATIC: - if (hittype[neartagsprite].temp_data[0] != 1) + if (ActorExtra[neartagsprite].temp_data[0] != 1) { - hittype[neartagsprite].temp_data[0] = 1; + ActorExtra[neartagsprite].temp_data[0] = 1; sprite[neartagsprite].owner = p->i; if (sprite[p->i].extra < p->max_player_health) { sprite[p->i].extra++; - spritesound(DUKE_DRINKING,p->i); + A_PlaySound(DUKE_DRINKING,p->i); } } return; case PLUG__STATIC: - spritesound(SHORT_CIRCUIT,p->i); - sprite[p->i].extra -= 2+(TRAND&3); + A_PlaySound(SHORT_CIRCUIT,p->i); + sprite[p->i].extra -= 2+(krand()&3); p->pals[0] = 48; p->pals[1] = 48; p->pals[2] = 64; @@ -3456,14 +3461,14 @@ void checksectors(int snum) case VIEWSCREEN__STATIC: case VIEWSCREEN2__STATIC: { - i = headspritestat[1]; + i = headspritestat[STAT_ACTOR]; while (i >= 0) { if (PN == CAMERA1 && SP == 0 && sprite[neartagsprite].hitag == SLT) { SP = 1; //Using this camera - spritesound(MONITOR_ACTIVE,neartagsprite); + A_PlaySound(MONITOR_ACTIVE,neartagsprite); sprite[neartagsprite].owner = i; sprite[neartagsprite].yvel = 1; @@ -3471,7 +3476,7 @@ void checksectors(int snum) j = p->cursectnum; p->cursectnum = SECT; - setpal(p); + P_UpdateScreenPal(p); p->cursectnum = j; // parallaxtype = 2; @@ -3493,10 +3498,10 @@ CLEARCAMERAS: p->newowner = -1; updatesector(p->posx,p->posy,&p->cursectnum); - setpal(p); + P_UpdateScreenPal(p); - i = headspritestat[1]; + i = headspritestat[STAT_ACTOR]; while (i >= 0) { if (PN==CAMERA1) SP = 0; @@ -3513,7 +3518,7 @@ CLEARCAMERAS: } } - if ((g_player[snum].sync->bits&(1<<29)) == 0) return; + if (TEST_SYNC_KEY(g_player[snum].sync->bits, SK_OPEN) == 0) return; else if (p->newowner >= 0) { i = -1; @@ -3521,20 +3526,20 @@ CLEARCAMERAS: } if (neartagwall == -1 && neartagsector == -1 && neartagsprite == -1) - if (klabs(hits(p->i)) < 512) + if (klabs(A_GetHitscanRange(p->i)) < 512) { - if ((TRAND&255) < 16) - spritesound(DUKE_SEARCH2,p->i); - else spritesound(DUKE_SEARCH,p->i); + if ((krand()&255) < 16) + A_PlaySound(DUKE_SEARCH2,p->i); + else A_PlaySound(DUKE_SEARCH,p->i); return; } if (neartagwall >= 0) { - if (wall[neartagwall].lotag > 0 && isadoorwall(wall[neartagwall].picnum)) + if (wall[neartagwall].lotag > 0 && CheckDoorTile(wall[neartagwall].picnum)) { if (hitscanwall == neartagwall || hitscanwall == -1) - checkhitswitch(snum,neartagwall,0); + P_ActivateSwitch(snum,neartagwall,0); return; } else if (p->newowner >= 0) @@ -3553,7 +3558,7 @@ CLEARCAMERAS: return; i = nextspritesect[i]; } - operatesectors(neartagsector,p->i); + G_OperateSectors(neartagsector,p->i); } else if ((sector[sprite[p->i].sectnum].lotag&16384) == 0) { @@ -3565,9 +3570,9 @@ CLEARCAMERAS: if (PN == ACTIVATOR || PN == MASTERSWITCH) return; i = nextspritesect[i]; } - operatesectors(sprite[p->i].sectnum,p->i); + G_OperateSectors(sprite[p->i].sectnum,p->i); } - else checkhitswitch(snum,neartagwall,0); + else P_ActivateSwitch(snum,neartagwall,0); } } } diff --git a/polymer/eduke32/source/sounds.c b/polymer/eduke32/source/sounds.c index deee10491..4ca78bd57 100644 --- a/polymer/eduke32/source/sounds.c +++ b/polymer/eduke32/source/sounds.c @@ -40,7 +40,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define LOUDESTVOLUME 150 -int backflag,numenvsnds; +int backflag,g_numEnvSoundsPlaying; /* =================== @@ -50,7 +50,7 @@ int backflag,numenvsnds; =================== */ -void SoundStartup(void) +void S_SoundStartup(void) { int status; @@ -65,13 +65,13 @@ void SoundStartup(void) { FX_SetReverseStereo(!FX_GetReverseStereo()); } - status = FX_SetCallBack(testcallback); + status = FX_SetCallBack(S_TestSoundCallback); } if (status != FX_Ok) { sprintf(tempbuf, "Sound startup error: %s", FX_ErrorString(FX_Error)); - gameexit(tempbuf); + G_GameExit(tempbuf); } } @@ -83,7 +83,7 @@ void SoundStartup(void) =================== */ -void SoundShutdown(void) +void S_SoundShutdown(void) { int status; @@ -95,7 +95,7 @@ void SoundShutdown(void) if (status != FX_Ok) { sprintf(tempbuf, "Sound shutdown error: %s", FX_ErrorString(FX_Error)); - gameexit(tempbuf); + G_GameExit(tempbuf); } } @@ -107,7 +107,7 @@ void SoundShutdown(void) =================== */ -void MusicStartup(void) +void S_MusicStartup(void) { int status; @@ -125,7 +125,7 @@ void MusicStartup(void) { initprintf("Couldn't find selected sound card, or, error w/ sound card itself.\n"); - SoundShutdown(); + S_SoundShutdown(); uninittimer(); uninitengine(); CONTROL_Shutdown(); @@ -145,7 +145,7 @@ void MusicStartup(void) =================== */ -void MusicShutdown(void) +void S_MusicShutdown(void) { int status; @@ -165,11 +165,10 @@ void MusicUpdate(void) MUSIC_Update(); } -unsigned char menunum=0; - -void intomenusounds(void) +void S_MenuSound(void) { - short menusnds[] = + static int SoundNum=0; + static short menusnds[] = { LASERTRIP_EXPLODE, DUKE_GRUNT, @@ -189,8 +188,8 @@ void intomenusounds(void) RPG_SHOOT, SELECT_WEAPON }; - sound(menusnds[menunum++]); - menunum %= 17; + S_PlaySound(menusnds[SoundNum++]); + SoundNum %= 17; } void _playmusic(const char *fn) @@ -198,7 +197,7 @@ void _playmusic(const char *fn) #if defined(_WIN32) int fp, l; #else - extern void PlayMusic(char *_filename); + extern void MUSIC_PlayMusic(char *_filename); #endif if (fn == NULL) return; @@ -224,15 +223,15 @@ void _playmusic(const char *fn) #else // FIXME: I need this to get the music volume initialized (not sure why) -- Jim Bentler MUSIC_SetVolume(ud.config.MusicVolume); - PlayMusic((char *)fn); + MUSIC_PlayMusic((char *)fn); #endif } -int playmusic(const char *fn, const int sel) +int S_PlayMusic(const char *fn, const int sel) { Musicsize=0; - if (map[sel].musicfn1 != NULL) - _playmusic(map[sel].musicfn1); + if (MapInfo[sel].musicfn1 != NULL) + _playmusic(MapInfo[sel].musicfn1); if (!Musicsize) { _playmusic(fn); @@ -241,7 +240,7 @@ int playmusic(const char *fn, const int sel) return 1; } -int loadsound(unsigned int num) +int S_LoadSound(unsigned int num) { int fp = -1, l; @@ -254,13 +253,13 @@ int loadsound(unsigned int num) return 0; } - if (g_sounds[num].filename1)fp = kopen4loadfrommod(g_sounds[num].filename1,loadfromgrouponly); - if (fp == -1)fp = kopen4loadfrommod(g_sounds[num].filename,loadfromgrouponly); + if (g_sounds[num].filename1)fp = kopen4loadfrommod(g_sounds[num].filename1,g_loadFromGroupOnly); + if (fp == -1)fp = kopen4loadfrommod(g_sounds[num].filename,g_loadFromGroupOnly); if (fp == -1) { -// Bsprintf(fta_quotes[113],"g_sounds %s(#%d) not found.",sounds[num],num); -// FTA(113,g_player[myconnectindex].ps); - OSD_Printf(OSDTEXT_RED "Sound %s(#%d) not found.\n",g_sounds[num].filename,num); +// Bsprintf(ScriptQuotes[113],"g_sounds %s(#%d) not found.",sounds[num],num); +// P_DoQuote(113,g_player[myconnectindex].ps); + OSD_Printf(OSDTEXT_RED "Sound %s(#%d) not found!\n",g_sounds[num].filename,num); return 0; } @@ -275,7 +274,7 @@ int loadsound(unsigned int num) return 1; } -int xyzsound(int num,int i,int x,int y,int z) +int S_PlaySoundXYZ(int num,int i,int x,int y,int z) { int sndist, cx, cy, cz, j,k; int pitche,pitchs,cs; @@ -294,7 +293,7 @@ int xyzsound(int num,int i,int x,int y,int z) if (g_sounds[num].m&128) { - sound(num); + S_PlaySound(num); return 0; } @@ -363,9 +362,9 @@ int xyzsound(int num,int i,int x,int y,int z) if (g_sounds[num].num > 0 && PN != MUSICANDSFX) { - if (g_sounds[num].SoundOwner[0].i == i) stopsound(num); - else if (g_sounds[num].num > 1) stopsound(num); - else if (badguy(&sprite[i]) && sprite[i].extra <= 0) stopsound(num); + if (g_sounds[num].SoundOwner[0].i == i) S_StopSound(num); + else if (g_sounds[num].num > 1) S_StopSound(num); + else if (A_CheckEnemySprite(&sprite[i]) && sprite[i].extra <= 0) S_StopSound(num); } if (PN == APLAYER && sprite[i].yvel == screenpeek) @@ -381,7 +380,7 @@ int xyzsound(int num,int i,int x,int y,int z) if (g_sounds[num].ptr == 0) { - if (loadsound(num) == 0) return 0; + if (S_LoadSound(num) == 0) return 0; } else { @@ -435,7 +434,7 @@ int xyzsound(int num,int i,int x,int y,int z) return (voice); } -void sound(int num) +void S_PlaySound(int num) { int pitch,pitche,pitchs,cx; int voice; @@ -466,7 +465,7 @@ void sound(int num) if (g_sounds[num].ptr == 0) { - if (loadsound(num) == 0) return; + if (S_LoadSound(num) == 0) return; } else { @@ -512,34 +511,34 @@ void sound(int num) g_sounds[num].lock--; } -int spritesound(unsigned int num, int i) +int A_PlaySound(unsigned int num, int i) { if (num >= MAXSOUNDS) return -1; if (i < 0) { - sound(num); + S_PlaySound(num); return 0; } - return xyzsound(num,i,SX,SY,SZ); + return S_PlaySoundXYZ(num,i,SX,SY,SZ); } -void stopspritesound(int num, int i) +void A_StopSound(int num, int i) { UNREFERENCED_PARAMETER(i); - if (num >= 0 && num < MAXSOUNDS) stopsound(num); + if (num >= 0 && num < MAXSOUNDS) S_StopSound(num); } -void stopsound(int num) +void S_StopSound(int num) { if (num >= 0 && num < MAXSOUNDS) if (g_sounds[num].num > 0) { FX_StopSound(g_sounds[num].SoundOwner[g_sounds[num].num-1].voice); - testcallback(num); + S_TestSoundCallback(num); } } -void stopenvsound(int num,int i) +void S_StopEnvSound(int num,int i) { int j, k; @@ -561,7 +560,7 @@ void pan3dsound(void) int sndist, sx, sy, sz, cx, cy, cz; int sndang,ca,j,k,i,cs; - numenvsnds = 0; + g_numEnvSoundsPlaying = 0; if (ud.camerasprite == -1) { @@ -609,7 +608,7 @@ void pan3dsound(void) sndist += sndist>>5; if (PN == MUSICANDSFX && SLT < 999) - numenvsnds++; + g_numEnvSoundsPlaying++; switch (j) { @@ -621,12 +620,12 @@ void pan3dsound(void) default: if (sndist > 31444 && PN != MUSICANDSFX) { - stopsound(j); + S_StopSound(j); continue; } } - if (g_sounds[j].ptr == 0 && loadsound(j) == 0) continue; + if (g_sounds[j].ptr == 0 && S_LoadSound(j) == 0) continue; if (g_sounds[j].m&16) sndist = 0; if (sndist < ((255-LOUDESTVOLUME)<<6)) @@ -636,7 +635,7 @@ void pan3dsound(void) } } -void testcallback(unsigned int num) +void S_TestSoundCallback(unsigned int num) { int tempi,tempj,tempk; @@ -657,7 +656,7 @@ void testcallback(unsigned int num) tempi = g_sounds[num].SoundOwner[tempj].i; if (sprite[tempi].picnum == MUSICANDSFX && sector[sprite[tempi].sectnum].lotag < 3 && sprite[tempi].lotag < 999) { - hittype[tempi].temp_data[0] = 0; + ActorExtra[tempi].temp_data[0] = 0; if ((tempj + 1) < tempk) { g_sounds[num].SoundOwner[tempj].voice = g_sounds[num].SoundOwner[tempk-1].voice; @@ -674,7 +673,7 @@ void testcallback(unsigned int num) g_sounds[num].lock--; } -void clearsoundlocks(void) +void S_ClearSoundLocks(void) { int i; @@ -687,14 +686,14 @@ void clearsoundlocks(void) lumplockbyte[i] = 199; } -int isspritemakingsound(int i, int num) +int A_CheckSoundPlaying(int i, int num) { UNREFERENCED_PARAMETER(i); if (num < 0) num=0; // FIXME return (g_sounds[num].num > 0); } -int issoundplaying(int i, int num) +int S_CheckSoundPlaying(int i, int num) { if (i == -1) { diff --git a/polymer/eduke32/source/sounds.h b/polymer/eduke32/source/sounds.h index 1685dfad3..c6cbafb24 100644 --- a/polymer/eduke32/source/sounds.h +++ b/polymer/eduke32/source/sounds.h @@ -31,10 +31,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef _sounds_public_ #define _sounds_public_ -void SoundStartup( void ); -void SoundShutdown( void ); -void MusicStartup( void ); -void MusicShutdown( void ); +void S_SoundStartup( void ); +void S_SoundShutdown( void ); +void S_MusicStartup( void ); +void S_MusicShutdown( void ); void AudioUpdate(void); struct audioenumdev { diff --git a/polymer/eduke32/source/startgtk.game.c b/polymer/eduke32/source/startgtk.game.c index 1ca61866a..f13488267 100644 --- a/polymer/eduke32/source/startgtk.game.c +++ b/polymer/eduke32/source/startgtk.game.c @@ -351,7 +351,7 @@ static GtkWidget *create_window(void) GDK_F, GDK_MOD1_MASK, GTK_ACCEL_VISIBLE); - // 3D video mode label + // 3D video mode LabelText vmode3dlabel = gtk_label_new_with_mnemonic("_Video mode:"); gtk_widget_show(vmode3dlabel); gtk_fixed_put(GTK_FIXED(configlayout), vmode3dlabel, 0, 0); @@ -432,7 +432,7 @@ static GtkWidget *create_window(void) gtk_container_add(GTK_CONTAINER(tabs), gamevlayout); gtk_container_set_border_width(GTK_CONTAINER(gamevlayout), 4); - // Game data field label + // Game data field LabelText gamelabel = gtk_label_new_with_mnemonic("_Game or addon:"); gtk_widget_show(gamelabel); gtk_box_pack_start(GTK_BOX(gamevlayout), gamelabel, FALSE, FALSE, 0); @@ -759,7 +759,7 @@ int startwin_run(void) settings.forcesetup = ud.config.ForceSetup; settings.usemouse = ud.config.UseMouse; settings.usejoy = ud.config.UseJoystick; - settings.game = g_GameType; + settings.game = g_gameType; strncpy(settings.selectedgrp, duke3dgrp, BMAX_PATH); PopulateForm(-1); @@ -778,7 +778,7 @@ int startwin_run(void) ud.config.UseMouse = settings.usemouse; ud.config.UseJoystick = settings.usejoy; duke3dgrp = settings.selectedgrp; - g_GameType = settings.game; + g_gameType = settings.game; for (i = 0; i= 0; i = connectpoint2[i]) + TRAVERSE_CONNECT(i) { pp = g_player[i].ps; updatecrc(crc, pp->posx & 255); @@ -70,11 +70,13 @@ char PlayerSync(void) char PlayerSync2(void) { - short i; + int i; + int j, nextj; unsigned short crc = 0; - player_struct *pp; + DukePlayer_t *pp; + spritetype *spr; - for (i = connecthead; i >= 0; i = connectpoint2[i]) + TRAVERSE_CONNECT(i) { pp = g_player[i].ps; @@ -83,40 +85,7 @@ char PlayerSync2(void) updatecrc(crc, pp->bobcounter & 255); } - return ((char) crc & 255); -} -/* -char SOSync(void) -{ - unsigned short crc = 0; - SECTOR_OBJECTp sop; - - for (sop = SectorObject; sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++) - { - // if (sop->xmid == MAXLONG) - // continue; - - updatecrc(crc, (sop->xmid) & 255); - updatecrc(crc, (sop->ymid) & 255); - updatecrc(crc, (sop->zmid) & 255); - updatecrc(crc, (sop->vel) & 255); - updatecrc(crc, (sop->ang) & 255); - updatecrc(crc, (sop->ang_moving) & 255); - updatecrc(crc, (sop->spin_ang) & 255); - } - - return ((char) crc & 255); -} - - -char EnemySync(void) -{ - unsigned short crc = 0; - short j, nextj; - spritetype *spr; - extern char DemoTmpName[]; - - TRAVERSE_SPRITE_STAT(headspritestat[STAT_ENEMY], j, nextj) + TRAVERSE_SPRITE_STAT(headspritestat[STAT_PLAYER], j, nextj) { spr = &sprite[j]; updatecrc(crc, (spr->x) & 255); @@ -128,13 +97,44 @@ char EnemySync(void) return ((char) crc & 255); } -char MissileSync(void) +char ActorSync(void) { unsigned short crc = 0; - short j, nextj; + int j, nextj; spritetype *spr; - TRAVERSE_SPRITE_STAT(headspritestat[STAT_MISSILE], j, nextj) + TRAVERSE_SPRITE_STAT(headspritestat[STAT_ACTOR], j, nextj) + { + spr = &sprite[j]; + updatecrc(crc, (spr->x) & 255); + updatecrc(crc, (spr->y) & 255); + updatecrc(crc, (spr->z) & 255); + updatecrc(crc, (spr->lotag) & 255); + updatecrc(crc, (spr->hitag) & 255); + updatecrc(crc, (spr->ang) & 255); + } + + TRAVERSE_SPRITE_STAT(headspritestat[STAT_ZOMBIEACTOR], j, nextj) + { + spr = &sprite[j]; + updatecrc(crc, (spr->x) & 255); + updatecrc(crc, (spr->y) & 255); + updatecrc(crc, (spr->z) & 255); + updatecrc(crc, (spr->lotag) & 255); + updatecrc(crc, (spr->hitag) & 255); + updatecrc(crc, (spr->ang) & 255); + } + + return ((char) crc & 255); +} + +char WeaponSync(void) +{ + unsigned short crc = 0; + int j, nextj; + spritetype *spr; + + TRAVERSE_SPRITE_STAT(headspritestat[STAT_PROJECTILE], j, nextj) { spr = &sprite[j]; updatecrc(crc, (spr->x) & 255); @@ -146,107 +146,70 @@ char MissileSync(void) return ((char) crc & 255); } -char MissileSkip4Sync(void) +char MapSync(void) { unsigned short crc = 0; - short j, nextj; + int j, nextj; spritetype *spr; + walltype *wal; + sectortype *sect; - TRAVERSE_SPRITE_STAT(headspritestat[STAT_MISSILE_SKIP4], j, nextj) + TRAVERSE_SPRITE_STAT(headspritestat[STAT_EFFECTOR], j, nextj) { spr = &sprite[j]; updatecrc(crc, (spr->x) & 255); updatecrc(crc, (spr->y) & 255); updatecrc(crc, (spr->z) & 255); updatecrc(crc, (spr->ang) & 255); + updatecrc(crc, (spr->lotag) & 255); + updatecrc(crc, (spr->hitag) & 255); } - return ((char) crc & 255); -} - -char ShrapSync(void) -{ - unsigned short crc = 0; - short j, nextj; - spritetype *spr; - - TRAVERSE_SPRITE_STAT(headspritestat[STAT_SHRAP], j, nextj) + for (j=numwalls;j>=0;j--) { - spr = &sprite[j]; - updatecrc(crc, (spr->x) & 255); - updatecrc(crc, (spr->y) & 255); - updatecrc(crc, (spr->z) & 255); - updatecrc(crc, (spr->ang) & 255); + wal = &wall[j]; + updatecrc(crc, (wal->x) & 255); + updatecrc(crc, (wal->y) & 255); } - return ((char) crc & 255); -} - -char MiscSync(void) -{ - unsigned short crc = 0; - short j, nextj; - spritetype *spr; - - TRAVERSE_SPRITE_STAT(headspritestat[STAT_MISC], j, nextj) + for (j=numsectors;j>=0;j--) { - spr = &sprite[j]; - updatecrc(crc, (spr->x) & 255); - updatecrc(crc, (spr->y) & 255); - updatecrc(crc, (spr->z) & 255); - updatecrc(crc, (spr->ang) & 255); + sect = §or[j]; + updatecrc(crc, (sect->floorz) & 255); + updatecrc(crc, (sect->ceilingz) & 255); } return ((char) crc & 255); } -*/ + char RandomSync(void) { unsigned short crc = 0; updatecrc(crc, randomseed & 255); updatecrc(crc, (randomseed >> 8) & 255); + updatecrc(crc, g_globalRandom & 255); + updatecrc(crc, (g_globalRandom >> 8) & 255); if (NumSyncBytes == 1) { updatecrc(crc,PlayerSync() & 255); updatecrc(crc,PlayerSync2() & 255); -// updatecrc(crc,WeaponSync() & 255); + updatecrc(crc,WeaponSync() & 255); + updatecrc(crc,ActorSync() & 255); } return ((char) crc & 255); } -/* - movefta(); //ST 2 - moveweapons(); //ST 4 - movetransports(); //ST 9 - - moveplayers(); //ST 10 - movefallers(); //ST 12 - moveexplosions(); //ST 5 - - moveactors(); //ST 1 - moveeffectors(); //ST 3 - - movestandables(); //ST 6 - movefx(); //ST 11 -*/ - char *SyncNames[] = { - "RandomSync", - "PlayerSync", - "PlayerSync2", - /* "FTASync", - "WeaponSync", - "TransportSync", - "FallerSync", - "ExplosionSync", - "ActorSync", - "EffectorSync", - "StandableSync", - "FXSync", */ + "Net_CheckRandomSync", + "Net_CheckPlayerSync", + "Net_CheckPlayerSync2", + "Net_CheckWeaponSync", + "Net_CheckActorSync", + "Net_CheckMapSync", NULL }; @@ -255,15 +218,9 @@ static char(*SyncFunc[MAXSYNCBYTES + 1])(void) = RandomSync, PlayerSync, PlayerSync2, - /* FTASync, - WeaponSync, - TransportSync, - FallerSync, - ExplosionSync, - ActorSync, - EffectorSync, - StandableSync, - FXSync, */ + WeaponSync, + ActorSync, + MapSync, NULL }; @@ -299,7 +256,7 @@ void SyncStatMessage(void) { int i, j; static unsigned int MoveCount = 0; - extern unsigned int MoveThingsCount; + extern unsigned int g_moveThingsCount; // if (!SyncPrintMode) // return; @@ -314,8 +271,8 @@ void SyncStatMessage(void) { if (NumSyncBytes > 1) { - sprintf(tempbuf, "GAME OUT OF SYNC - %s", SyncNames[i]); - printext256(68L, 68L + (i * 8), 1, 31, tempbuf, 0); + sprintf(tempbuf, "Out Of Sync - %s", SyncNames[i]); + printext256(4L, 100L + (i * 8), 31, 1, tempbuf, 0); } if (!sync_found && sync_first[i][0] == '\0') @@ -324,13 +281,13 @@ void SyncStatMessage(void) sync_found = TRUE; // save off loop count - MoveCount = MoveThingsCount; + MoveCount = g_moveThingsCount; for (j = 0; j < NumSyncBytes; j++) { if (syncstat[j] != 0 && sync_first[j][0] == '\0') { - sprintf(tempbuf, "OUT OF SYNC - %s", SyncNames[j]); + sprintf(tempbuf, "Out Of Sync - %s", SyncNames[j]); strcpy(sync_first[j], tempbuf); } } @@ -346,24 +303,13 @@ void SyncStatMessage(void) if (NumSyncBytes > 1) { sprintf(tempbuf, "FIRST %s", sync_first[i]); - printext256(50L, 0L, 1, 31, tempbuf, 0); + printext256(4L, 44L + (i * 8), 31, 1, tempbuf, 0); sprintf(tempbuf, "MoveCount %d",MoveCount); - printext256(50L, 10L, 1, 31, tempbuf, 0); + printext256(4L, 52L + (i * 8), 31, 1, tempbuf, 0); } else { -// short w,h; - // production out of sync error - -// sprintf(tempbuf,"GAME OUT OF SYNC!"); -// MNU_MeasureString(tempbuf, &w, &h); - // MNU_DrawString(TEXT_TEST_COL(w), 20, tempbuf, 0, 19); - -// sprintf(tempbuf,"Restart the game."); - // MNU_MeasureString(tempbuf, &w, &h); - // MNU_DrawString(TEXT_TEST_COL(w), 30, tempbuf, 0, 19); - printext256(4L,130L,31,0,"Out Of Sync - Please restart game",0); - printext256(4L,138L,31,0,"RUN DN3DHELP.EXE for information.",0); + printext256(4L,100L,31,0,"Out Of Sync - Please restart game",0); } } } @@ -406,7 +352,7 @@ void GetSyncInfoFromPacket(char *packbuf, int packbufleng, int *j, int otherconn // Suspect that its trying to traverse the connect list // for a player that does not exist. This tries to take care of that - for (i=connecthead;i>=0;i=connectpoint2[i]) + TRAVERSE_CONNECT(i) { if (otherconnectindex == i) found = 1; @@ -428,7 +374,7 @@ void GetSyncInfoFromPacket(char *packbuf, int packbufleng, int *j, int otherconn // update syncstat // if any of the syncstat vars is non-0 then there is a problem - for (i=connecthead;i>=0;i=connectpoint2[i]) + TRAVERSE_CONNECT(i) { if (g_player[i].syncvalhead == syncvaltottail) return; @@ -452,7 +398,7 @@ void GetSyncInfoFromPacket(char *packbuf, int packbufleng, int *j, int otherconn syncvaltottail++; - for (i=connecthead;i>=0;i=connectpoint2[i]) + TRAVERSE_CONNECT(i) { if (g_player[i].syncvalhead == syncvaltottail) return; diff --git a/polymer/eduke32/source/winbits.c b/polymer/eduke32/source/winbits.c index 7670790a6..548320ad0 100644 --- a/polymer/eduke32/source/winbits.c +++ b/polymer/eduke32/source/winbits.c @@ -65,13 +65,13 @@ int Win_MsgBox(char *name, char *fmt, ...) // this replaces the Error() function in jmact/util_lib.c -extern void Shutdown(void); // game.c +extern void G_Shutdown(void); // game.c void Error(char *error, ...) { char buf[1000]; va_list va; - Shutdown(); + G_Shutdown(); if (error) {