From ae5f941ad0632246e8ec537a808717b44c48a012 Mon Sep 17 00:00:00 2001 From: terminx Date: Sat, 27 Aug 2016 01:40:06 +0000 Subject: [PATCH] You're just going to have to trust me that this is 10000 lines worth of formatting and variable name cleanup, and not 10000 lines of functional changes. git-svn-id: https://svn.eduke32.com/eduke32@5821 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/actors.c | 36 +- polymer/eduke32/source/actors.h | 251 ++-- polymer/eduke32/source/game.c | 20 +- polymer/eduke32/source/gamedef.c | 14 +- polymer/eduke32/source/gameexec.c | 2133 +++++++++++++++-------------- polymer/eduke32/source/gameexec.h | 36 +- polymer/eduke32/source/gamevars.c | 884 ++++++------ polymer/eduke32/source/gamevars.h | 189 ++- polymer/eduke32/source/player.c | 30 +- polymer/eduke32/source/premap.c | 6 +- polymer/eduke32/source/savegame.c | 16 +- polymer/eduke32/source/sector.c | 2005 +++++++++++++-------------- polymer/eduke32/source/sector.h | 8 +- 13 files changed, 2820 insertions(+), 2808 deletions(-) diff --git a/polymer/eduke32/source/actors.c b/polymer/eduke32/source/actors.c index b978652cb..ad1e8149e 100644 --- a/polymer/eduke32/source/actors.c +++ b/polymer/eduke32/source/actors.c @@ -186,7 +186,7 @@ void A_RadiusDamage(int32_t i, int32_t r, int32_t hp1, int32_t hp2, int32_t hp3, SKIPWALLCHECK: - q = -(16<<8) + (krand()&((32<<8)-1)); + q = -ZOFFSET2 + (krand()&((32<<8)-1)); for (stati=0; stati < ARRAY_SSIZE(statlist); stati++) { @@ -203,12 +203,12 @@ SKIPWALLCHECK: if (s->picnum != SHRINKSPARK || (sj->cstat&257)) if (dist(s, sj) < r) { - if (A_CheckEnemySprite((uspritetype *)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; A_DamageObject(j, i); } } - else if (sj->extra >= 0 && (uspritetype *)sj != s && (sj->picnum == TRIPBOMB || A_CheckEnemySprite((uspritetype *)sj) || sj->picnum == QUEBALL || sj->picnum == STRIPEBALL || (sj->cstat&257) || sj->picnum == DUKELYINGDEAD)) + else if (sj->extra >= 0 && (uspritetype *)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)) { @@ -397,7 +397,7 @@ static int32_t A_CheckNeedZUpdate(int32_t spritenum, int32_t changez, int32_t *d int32_t A_MoveSpriteClipdist(int32_t spritenum, vec3_t const * const change, uint32_t cliptype, int32_t clipdist) { spritetype * const spr = &sprite[spritenum]; - const int32_t badguy = A_CheckEnemySprite((uspritetype *)spr); + const int32_t badguy = A_CheckEnemySprite(spr); const int32_t oldx = spr->x, oldy = spr->y; if (spr->statnum == STAT_MISC || (badguy && spr->xrepeat < 4)) @@ -872,7 +872,7 @@ ACTOR_STATIC void G_MoveZombieActors(void) actor[i].timetosleep++; if (actor[i].timetosleep >= (x>>8)) { - if (A_CheckEnemySprite((uspritetype *)s)) + if (A_CheckEnemySprite(s)) { const int32_t px = g_player[p].ps->opos.x+64-(krand()&127); const int32_t py = g_player[p].ps->opos.y+64-(krand()&127); @@ -943,7 +943,7 @@ ACTOR_STATIC void G_MoveZombieActors(void) } } - if (A_CheckEnemySprite((uspritetype *)s) && A_CheckSpriteFlags(i,SFLAG_NOSHADE) == 0) + if (A_CheckEnemySprite(s) && A_CheckSpriteFlags(i,SFLAG_NOSHADE) == 0) { if (sector[s->sectnum].ceilingstat&1) s->shade = sector[s->sectnum].ceilingshade; @@ -1445,7 +1445,7 @@ ACTOR_STATIC void G_MoveFallers(void) int32_t j; const int32_t oextra = s->extra; - s->z -= (16<<8); + s->z -= ZOFFSET2; T2 = s->ang; if ((j = A_IncurDamage(i)) >= 0) { @@ -1474,7 +1474,7 @@ ACTOR_STATIC void G_MoveFallers(void) } } s->ang = T2; - s->z += (16<<8); + s->z += ZOFFSET2; } else if (T1 == 1) { @@ -1514,7 +1514,7 @@ ACTOR_STATIC void G_MoveFallers(void) s->zvel = 6144; s->z += s->zvel; } - if ((sector[sect].floorz-s->z) < (16<<8)) + if ((sector[sect].floorz-s->z) < ZOFFSET2) { int32_t j = 1+(krand()&7); for (x=0; xsectnum; s->zvel = -1; } - else if (s->z > actor[i].floorz + (16<<8)*(sector[s->sectnum].lotag == ST_1_ABOVE_WATER)) + else if (s->z > actor[i].floorz + ZOFFSET2*(sector[s->sectnum].lotag == ST_1_ABOVE_WATER)) { *j = 16384|s->sectnum; @@ -3054,7 +3054,7 @@ ACTOR_STATIC void G_MoveWeapons(void) j &= (MAXSPRITES-1); if (s->picnum == FREEZEBLAST && sprite[j].pal == 1) - if (A_CheckEnemySprite((uspritetype *)&sprite[j]) || sprite[j].picnum == APLAYER) + if (A_CheckEnemySprite(&sprite[j]) || sprite[j].picnum == APLAYER) { j = A_Spawn(i, TRANSPORTERSTAR); sprite[j].pal = 1; @@ -3969,7 +3969,7 @@ ACTOR_STATIC void G_MoveActors(void) A_Shoot(i,FIRELASER); s->ang = a; } - if (t[2] > (GAMETICSPERSEC*3) || !cansee(s->x,s->y,s->z-(16<<8),s->sectnum, ps->pos.x,ps->pos.y,ps->pos.z,ps->cursectnum)) + if (t[2] > (GAMETICSPERSEC*3) || !cansee(s->x,s->y,s->z-ZOFFSET2,s->sectnum, ps->pos.x,ps->pos.y,ps->pos.z,ps->cursectnum)) { t[0] = 0; t[2] = 0; @@ -3992,7 +3992,7 @@ ACTOR_STATIC void G_MoveActors(void) else { t[2]++; - if (t[2] > (GAMETICSPERSEC*3) || !cansee(s->x,s->y,s->z-(16<<8),s->sectnum, ps->pos.x,ps->pos.y,ps->pos.z,ps->cursectnum)) + if (t[2] > (GAMETICSPERSEC*3) || !cansee(s->x,s->y,s->z-ZOFFSET2,s->sectnum, ps->pos.x,ps->pos.y,ps->pos.z,ps->cursectnum)) { t[0] = 1; t[2] = 0; @@ -4887,7 +4887,7 @@ DETONATEB: goto BOLT; } - if (!g_netServer && ud.multimode < 2 && A_CheckEnemySprite((uspritetype *)s)) + if (!g_netServer && ud.multimode < 2 && A_CheckEnemySprite(s)) { if (g_noEnemies == 1) { @@ -5049,7 +5049,7 @@ ACTOR_STATIC void G_MoveMisc(void) // STATNUM 5 else { l = getflorzofslope(sect,s->x,s->y)-s->z; - if( l > (16<<8) ) KILLIT(i); + if( l > ZOFFSET2 ) KILLIT(i); } else */ @@ -5572,7 +5572,7 @@ static void MaybeTrainKillEnemies(int32_t i, int32_t numguts) { const int32_t nextj = nextspritesect[j]; - if (sprite[j].extra >= 0 && sprite[j].statnum == STAT_ACTOR && A_CheckEnemySprite((uspritetype *)&sprite[j])) + if (sprite[j].extra >= 0 && sprite[j].statnum == STAT_ACTOR && A_CheckEnemySprite(&sprite[j])) { int16_t k = sprite[j].sectnum; @@ -6533,7 +6533,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 { for (SPRITES_OF(STAT_ACTOR, k)) { - if (sprite[k].extra > 0 && A_CheckEnemySprite((uspritetype *)&sprite[k]) + if (sprite[k].extra > 0 && A_CheckEnemySprite(&sprite[k]) && clipinsidebox((vec2_t *)&sprite[k], j, 256) == 1) goto BOLT; } @@ -7239,7 +7239,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 if (!(sprite[j].picnum >= CRANE && sprite[j].picnum <= CRANE+3)) { - if (sprite[j].z > actor[j].floorz-(16<<8)) + if (sprite[j].z > actor[j].floorz-ZOFFSET2) { actor[j].bpos.x = sprite[j].x; actor[j].bpos.y = sprite[j].y; diff --git a/polymer/eduke32/source/actors.h b/polymer/eduke32/source/actors.h index bd1a40148..d1a064945 100644 --- a/polymer/eduke32/source/actors.h +++ b/polymer/eduke32/source/actors.h @@ -32,6 +32,7 @@ extern "C" { #define MAXSLEEPDIST 16384 #define SLEEPTIME 1536 #define ZOFFSET (1<<8) +#define ZOFFSET2 (16<<8) #define ACTOR_MAXFALLINGZVEL 6144 #define ACTOR_ONWATER_ADDZ (24<<8) @@ -56,24 +57,26 @@ extern "C" { // Defines the motion characteristics of an actor -enum amoveflags_t { - face_player = 1, - geth = 2, - getv = 4, - random_angle = 8, - face_player_slow = 16, - spin = 32, - face_player_smart = 64, - fleeenemy = 128, - jumptoplayer_only = 256, - jumptoplayer_bits = 257, // NOTE: two bits set! - seekplayer = 512, - furthestdir = 1024, - dodgebullet = 4096 +enum amoveflags_t +{ + face_player = 1, + geth = 2, + getv = 4, + random_angle = 8, + face_player_slow = 16, + spin = 32, + face_player_smart = 64, + fleeenemy = 128, + jumptoplayer_only = 256, + jumptoplayer_bits = 257, // NOTE: two bits set! + seekplayer = 512, + furthestdir = 1024, + dodgebullet = 4096 }; // Defines for 'useractor' keyword -enum uactortypes_t { +enum uactortypes_t +{ notenemy, enemy, enemystayput @@ -93,14 +96,16 @@ enum uactortypes_t { #define AC_AI_ID(t) ((t)[5]) /* the ID of the actor's current ai */ #ifdef LUNATIC -struct action { +struct action +{ // These members MUST be in this exact order because FFI cdata of this type // can be initialized by passing a table with numeric indices (con.action). int16_t startframe, numframes; int16_t viewtype, incval, delay; }; -struct move { +struct move +{ // These members MUST be in this exact order. int16_t hvel, vvel; }; @@ -124,27 +129,27 @@ typedef struct { int32_t id; struct action ac; } con_action_t; #endif // (+ 40 16 16 4 8 6 8 6 4 20) -typedef struct { +typedef struct +{ int32_t t_data[10]; // 40b sometimes used to hold offsets to con code #ifdef LUNATIC // total: 16b - struct move mv; + struct move mv; struct action ac; // Gets incremented by TICSPERFRAME on each A_Execute() call: uint16_t actiontics; #endif - int32_t flags; //4b - vec3_t bpos; //12b - int32_t floorz,ceilingz,lastvx,lastvy; //16b - int32_t lasttransport; //4b - - int16_t picnum,ang,extra,owner; //8b - int16_t movflag,tempang,timetosleep; //6b + int32_t flags; // 4b + vec3_t bpos; // 12b + int32_t floorz, ceilingz, lastvx, lastvy; // 16b + int32_t lasttransport; // 4b + int16_t picnum, ang, extra, owner; // 8b + int16_t movflag, tempang, timetosleep; // 6b // NOTE: 'dispicnum' is updated locally, not in sync with the game! - int16_t actorstayput, dispicnum; + int16_t actorstayput, dispicnum; #if !defined LUNATIC // NOTE: shootzvel is not used any more. int16_t shootzvel_; @@ -153,12 +158,11 @@ typedef struct { uint16_t movflags; #endif int16_t cgg; - - int16_t lightId, lightcount, lightmaxrange; //6b + int16_t lightId, lightcount, lightmaxrange; // 6b #ifdef POLYMER - _prlight *lightptr; //4b/8b + _prlight *lightptr; // 4b/8b #else - void *lightptr; + void * lightptr; #endif // pad struct to 128 bytes @@ -182,78 +186,75 @@ typedef struct { #endif } actor_t; -#pragma pack(push,1) +#pragma pack(push, 1) // this struct needs to match the beginning of actor_t above -typedef struct { +typedef struct +{ int32_t t_data[10]; // 40b sometimes used to hold offsets to con code #ifdef LUNATIC - struct move mv; + struct move mv; struct action ac; - uint16_t actiontics; + uint16_t actiontics; #endif - int32_t flags; //4b - vec3_t bpos; //12b - int32_t floorz,ceilingz,lastvx,lastvy; //16b - int32_t lasttransport; //4b + int32_t flags; // 4b + vec3_t bpos; // 12b + int32_t floorz, ceilingz, lastvx, lastvy; // 16b + int32_t lasttransport; // 4b + int16_t picnum, ang, extra, owner; // 8b + int16_t movflag, tempang, timetosleep; // 6b - int16_t picnum,ang,extra,owner; //8b - int16_t movflag,tempang,timetosleep; // 6b - - int16_t actorstayput, dispicnum; + int16_t actorstayput, dispicnum; #if !defined LUNATIC - int16_t shootzvel_; + int16_t shootzvel_; #else uint16_t movflags; #endif - int16_t cgg; - + int16_t cgg; spritetype sprite; - int16_t netIndex; - + int16_t netIndex; } netactor_t; #pragma pack(pop) -typedef struct { -#if !defined LUNATIC - intptr_t *execPtr; // pointer to CON script for this tile, formerly actorscrptr - intptr_t *loadPtr; // pointer to load time CON script, formerly actorLoadEventScrPtr or something +typedef struct +{ +#if !defined LUNATIC + intptr_t *execPtr; // pointer to CON script for this tile, formerly actorscrptr + intptr_t *loadPtr; // pointer to load time CON script, formerly actorLoadEventScrPtr or something #endif - uint32_t flags; // formerly SpriteFlags, ActorType - - int32_t cacherange; // formerly SpriteCache - - // todo: make this a pointer and allocate at runtime + uint32_t flags; // formerly SpriteFlags, ActorType + int32_t cacherange; // formerly SpriteCache projectile_t *proj; projectile_t *defproj; } tiledata_t; // KEEPINSYNC lunatic/con_lang.lua -enum sflags_t { - SFLAG_SHADOW = 0x00000001, - SFLAG_NVG = 0x00000002, - SFLAG_NOSHADE = 0x00000004, - SFLAG_PROJECTILE = 0x00000008, - SFLAG_DECAL = 0x00000010, - SFLAG_BADGUY = 0x00000020, - SFLAG_NOPAL = 0x00000040, - SFLAG_NOEVENTCODE = 0x00000080, - SFLAG_NOLIGHT = 0x00000100, - SFLAG_USEACTIVATOR = 0x00000200, - SFLAG_NULL = 0x00000400, // null sprite in multiplayer - SFLAG_NOCLIP = 0x00000800, // clipmove it with cliptype 0 - SFLAG_NOFLOORSHADOW = 0x00001000, // for temp. internal use, per-tile flag not checked - SFLAG_SMOOTHMOVE = 0x00002000, - SFLAG_NOTELEPORT = 0x00004000, - SFLAG_BADGUYSTAYPUT = 0x00008000, - SFLAG_CACHE = 0x00010000, +enum sflags_t +{ + SFLAG_SHADOW = 0x00000001, + SFLAG_NVG = 0x00000002, + SFLAG_NOSHADE = 0x00000004, + SFLAG_PROJECTILE = 0x00000008, + SFLAG_DECAL = 0x00000010, + SFLAG_BADGUY = 0x00000020, + SFLAG_NOPAL = 0x00000040, + SFLAG_NOEVENTCODE = 0x00000080, + SFLAG_NOLIGHT = 0x00000100, + SFLAG_USEACTIVATOR = 0x00000200, + SFLAG_NULL = 0x00000400, // null sprite in multiplayer + SFLAG_NOCLIP = 0x00000800, // clipmove it with cliptype 0 + SFLAG_NOFLOORSHADOW = 0x00001000, // for temp. internal use, per-tile flag not checked + SFLAG_SMOOTHMOVE = 0x00002000, + SFLAG_NOTELEPORT = 0x00004000, + SFLAG_BADGUYSTAYPUT = 0x00008000, + SFLAG_CACHE = 0x00010000, // rotation-fixed wrt a pivot point to prevent position diverging due to // roundoff error accumulation: SFLAG_ROTFIXED = 0x00020000, SFLAG_HARDCODED_BADGUY = 0x00040000, - SFLAG_DIDNOSE7WATER = 0x00080000, // used temporarily + SFLAG_DIDNOSE7WATER = 0x00080000, // used temporarily SFLAG_NODAMAGEPUSH = 0x00100000, SFLAG_NOWATERDIP = 0x00200000, SFLAG_HURTSPAWNBLOOD = 0x00400000, @@ -263,31 +264,32 @@ enum sflags_t { // Custom projectiles "workslike" flags. // XXX: Currently not predefined from CON. -enum pflags_t { - PROJECTILE_HITSCAN = 0x00000001, - PROJECTILE_RPG = 0x00000002, - PROJECTILE_BOUNCESOFFWALLS = 0x00000004, - PROJECTILE_BOUNCESOFFMIRRORS = 0x00000008, - PROJECTILE_KNEE = 0x00000010, - PROJECTILE_WATERBUBBLES = 0x00000020, - PROJECTILE_TIMED = 0x00000040, - PROJECTILE_BOUNCESOFFSPRITES = 0x00000080, - PROJECTILE_SPIT = 0x00000100, - PROJECTILE_COOLEXPLOSION1 = 0x00000200, - PROJECTILE_BLOOD = 0x00000400, - PROJECTILE_LOSESVELOCITY = 0x00000800, - PROJECTILE_NOAIM = 0x00001000, - PROJECTILE_RANDDECALSIZE = 0x00002000, - PROJECTILE_EXPLODEONTIMER = 0x00004000, - PROJECTILE_RPG_IMPACT = 0x00008000, - PROJECTILE_RADIUS_PICNUM = 0x00010000, - PROJECTILE_ACCURATE_AUTOAIM = 0x00020000, - PROJECTILE_FORCEIMPACT = 0x00040000, - PROJECTILE_REALCLIPDIST = 0x00080000, - PROJECTILE_ACCURATE = 0x00100000, - PROJECTILE_NOSETOWNERSHADE = 0x00200000, - PROJECTILE_MOVED = 0x80000000, // internal flag, do not document - PROJECTILE_TYPE_MASK = PROJECTILE_HITSCAN|PROJECTILE_RPG|PROJECTILE_KNEE|PROJECTILE_BLOOD, +enum pflags_t +{ + PROJECTILE_HITSCAN = 0x00000001, + PROJECTILE_RPG = 0x00000002, + PROJECTILE_BOUNCESOFFWALLS = 0x00000004, + PROJECTILE_BOUNCESOFFMIRRORS = 0x00000008, + PROJECTILE_KNEE = 0x00000010, + PROJECTILE_WATERBUBBLES = 0x00000020, + PROJECTILE_TIMED = 0x00000040, + PROJECTILE_BOUNCESOFFSPRITES = 0x00000080, + PROJECTILE_SPIT = 0x00000100, + PROJECTILE_COOLEXPLOSION1 = 0x00000200, + PROJECTILE_BLOOD = 0x00000400, + PROJECTILE_LOSESVELOCITY = 0x00000800, + PROJECTILE_NOAIM = 0x00001000, + PROJECTILE_RANDDECALSIZE = 0x00002000, + PROJECTILE_EXPLODEONTIMER = 0x00004000, + PROJECTILE_RPG_IMPACT = 0x00008000, + PROJECTILE_RADIUS_PICNUM = 0x00010000, + PROJECTILE_ACCURATE_AUTOAIM = 0x00020000, + PROJECTILE_FORCEIMPACT = 0x00040000, + PROJECTILE_REALCLIPDIST = 0x00080000, + PROJECTILE_ACCURATE = 0x00100000, + PROJECTILE_NOSETOWNERSHADE = 0x00200000, + PROJECTILE_MOVED = 0x80000000, // internal flag, do not document + PROJECTILE_TYPE_MASK = PROJECTILE_HITSCAN | PROJECTILE_RPG | PROJECTILE_KNEE | PROJECTILE_BLOOD, }; extern tiledata_t g_tile[MAXTILES]; @@ -299,28 +301,27 @@ extern int32_t ticrandomseed; extern projectile_t SpriteProjectile[MAXSPRITES]; +void A_AddToDeleteQueue(int32_t i); +int32_t A_CheckNoSE7Water(const spritetype *s, int32_t sectnum, int32_t slotag, int32_t *othersectptr); +int32_t A_CheckSwitchTile(int32_t i); +void A_DeleteSprite(int32_t s); +void A_DoGuts(int32_t sp, int32_t gtype, int32_t n); +void A_DoGutsDir(int32_t sp, int32_t gtype, int32_t n); +int32_t A_IncurDamage(int32_t sn); +void A_MoveCyclers(void); +void A_MoveDummyPlayers(void); +void A_MoveSector(int i); +void A_PlayAlertSound(int32_t i); +void A_RadiusDamage(int32_t i, int32_t r, int32_t hp1, int32_t hp2, int32_t hp3, int32_t hp4); +void A_SpawnMultiple(int32_t sp, int32_t pic, int32_t n); -void A_AddToDeleteQueue(int32_t i); -int32_t A_CheckNoSE7Water(const spritetype *s, int32_t sectnum, int32_t slotag, int32_t *othersectptr); -int32_t A_CheckSwitchTile(int32_t i); -void A_DeleteSprite(int32_t s); -void A_DoGuts(int32_t sp,int32_t gtype,int32_t n); -void A_DoGutsDir(int32_t sp,int32_t gtype,int32_t n); -int32_t A_IncurDamage(int32_t sn); -void A_MoveCyclers(void); -void A_MoveDummyPlayers(void); -void A_MoveSector(int i); -void A_PlayAlertSound(int32_t i); -void A_RadiusDamage(int32_t i,int32_t r,int32_t hp1,int32_t hp2,int32_t hp3,int32_t hp4); -void A_SpawnMultiple(int32_t sp,int32_t pic,int32_t n); - -void G_AddGameLight(int32_t radius,int32_t srcsprite,int32_t zoffset,int32_t range,int32_t color,int32_t priority); -void G_ClearCameraView(DukePlayer_t *ps); -void G_DoInterpolations(int32_t smoothratio); -void G_MoveWorld(void); -void G_RefreshLights(void); -int32_t G_SetInterpolation(int32_t * const posptr); -void G_StopInterpolation(int32_t * const posptr); +void G_AddGameLight(int32_t radius, int32_t srcsprite, int32_t zoffset, int32_t range, int32_t color, int32_t priority); +void G_ClearCameraView(DukePlayer_t *ps); +void G_DoInterpolations(int32_t smoothratio); +void G_MoveWorld(void); +void G_RefreshLights(void); +int32_t G_SetInterpolation(int32_t *const posptr); +void G_StopInterpolation(int32_t *const posptr); // PK 20110701: changed input argument: int32_t i (== sprite, whose sectnum...) --> sectnum directly void Sect_ToggleInterpolation(int sectnum, int doset); @@ -347,7 +348,7 @@ ACTOR_INLINE_HEADER int32_t A_MoveSprite(int32_t spritenum, vec3_t const * const EXTERN_INLINE_HEADER int32_t G_CheckForSpaceCeiling(int32_t sectnum); EXTERN_INLINE_HEADER int32_t G_CheckForSpaceFloor(int32_t sectnum); -EXTERN_INLINE_HEADER int32_t A_CheckEnemySprite(uspritetype const * const s); +EXTERN_INLINE_HEADER int A_CheckEnemySprite(void const * const s); #ifdef __cplusplus } @@ -392,9 +393,9 @@ EXTERN_INLINE int32_t G_CheckForSpaceFloor(int32_t sectnum) (sector[sectnum].floorpicnum==MOONSKY1 || sector[sectnum].floorpicnum==BIGORBIT1)); } -EXTERN_INLINE int32_t A_CheckEnemySprite(uspritetype const * const s) +EXTERN_INLINE int A_CheckEnemySprite(void const * const pSprite) { - return A_CheckEnemyTile(s->picnum); + return A_CheckEnemyTile(((uspritetype *) pSprite)->picnum); } #endif diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 8dfb354da..5a5288ff2 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -1007,9 +1007,11 @@ void G_DrawRooms(int32_t snum, int32_t smoothratio) if (dont_draw != 1) // event return values other than 0 and 1 are reserved { +/* if (EDUKE32_PREDICT_FALSE(dont_draw != 0)) OSD_Printf(OSD_ERROR "ERROR: EVENT_DISPLAYROOMS return value must be 0 or 1, " "other values are reserved.\n"); +*/ G_HandleMirror(CAMERA(pos.x), CAMERA(pos.y), CAMERA(pos.z), CAMERA(ang), CAMERA(horiz), smoothratio); #ifdef LEGACY_ROR @@ -1216,17 +1218,17 @@ void G_DumpDebugInfo(void) TrackerCast(sprite[j].x),TrackerCast(sprite[j].y),TrackerCast(sprite[j].z),TrackerCast(sprite[j].picnum)); for (i=0; ixrepeat = 48; sp->yrepeat = 64; - if (sprite[j].statnum == STAT_PLAYER || A_CheckEnemySprite((uspritetype *)&sprite[j])) + if (sprite[j].statnum == STAT_PLAYER || A_CheckEnemySprite(&sprite[j])) sp->z -= (32<<8); } } @@ -3576,7 +3578,7 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo continue; default: // NOTE: wall-aligned sprites will never take on ceiling/floor shade... - if ((t->cstat&16) || (A_CheckEnemySprite((uspritetype *)t) && + if ((t->cstat&16) || (A_CheckEnemySprite(t) && (unsigned)t->owner < MAXSPRITES && sprite[t->owner].extra > 0) || t->statnum == STAT_PLAYER) continue; } @@ -4126,14 +4128,14 @@ skip: // player has nightvision on. We should pass stuff like "from which player is this view // supposed to be" as parameters ("drawing context") instead of relying on globals. if (g_player[screenpeek].ps->inv_amount[GET_HEATS] > 0 && g_player[screenpeek].ps->heat_on && - (A_CheckEnemySprite((uspritetype *)s) || A_CheckSpriteFlags(t->owner,SFLAG_NVG) || s->picnum == APLAYER || s->statnum == STAT_DUMMYPLAYER)) + (A_CheckEnemySprite(s) || A_CheckSpriteFlags(t->owner,SFLAG_NVG) || s->picnum == APLAYER || s->statnum == STAT_DUMMYPLAYER)) { t->pal = 6; t->shade = 0; } // Fake floor shadow, implemented by inserting a new tsprite. - if (s->statnum == STAT_DUMMYPLAYER || A_CheckEnemySprite((uspritetype *)s) || A_CheckSpriteFlags(t->owner,SFLAG_SHADOW) || (s->picnum == APLAYER && s->owner >= 0)) + if (s->statnum == STAT_DUMMYPLAYER || A_CheckEnemySprite(s) || A_CheckSpriteFlags(t->owner,SFLAG_SHADOW) || (s->picnum == APLAYER && s->owner >= 0)) if (t->statnum != TSPR_TEMP && s->picnum != EXPLOSION2 && s->picnum != HANGLIGHT && s->picnum != DOMELITE && s->picnum != HOTMEAT) { if (actor[i].dispicnum < 0) diff --git a/polymer/eduke32/source/gamedef.c b/polymer/eduke32/source/gamedef.c index 15a9f4008..850e93fe0 100644 --- a/polymer/eduke32/source/gamedef.c +++ b/polymer/eduke32/source/gamedef.c @@ -1924,13 +1924,13 @@ static void C_GetNextVarType(int32_t type) return; } - if (EDUKE32_PREDICT_FALSE(type == GAMEVAR_READONLY && aGameVars[i].dwFlags & GAMEVAR_READONLY)) + if (EDUKE32_PREDICT_FALSE(type == GAMEVAR_READONLY && aGameVars[i].nFlags & GAMEVAR_READONLY)) { g_numCompilerErrors++; C_ReportError(ERROR_VARREADONLY); return; } - else if (EDUKE32_PREDICT_FALSE(aGameVars[i].dwFlags & type)) + else if (EDUKE32_PREDICT_FALSE(aGameVars[i].nFlags & type)) { g_numCompilerErrors++; C_ReportError(ERROR_VARTYPEMISMATCH); @@ -3894,7 +3894,7 @@ DO_DEFSTATE: C_ReportError(ERROR_NOTAGAMEVAR); continue; } - if (EDUKE32_PREDICT_FALSE(aGameVars[i].dwFlags & GAMEVAR_READONLY)) + if (EDUKE32_PREDICT_FALSE(aGameVars[i].nFlags & GAMEVAR_READONLY)) { g_numCompilerErrors++; C_ReportError(ERROR_VARREADONLY); @@ -3904,7 +3904,7 @@ DO_DEFSTATE: switch (tw) { case CON_SETACTORVAR: - if (EDUKE32_PREDICT_FALSE(!(aGameVars[i].dwFlags & GAMEVAR_PERACTOR))) + if (EDUKE32_PREDICT_FALSE(!(aGameVars[i].nFlags & GAMEVAR_PERACTOR))) { g_numCompilerErrors++; C_ReportError(-1); @@ -3913,7 +3913,7 @@ DO_DEFSTATE: } break; case CON_SETPLAYERVAR: - if (EDUKE32_PREDICT_FALSE(!(aGameVars[i].dwFlags & GAMEVAR_PERPLAYER))) + if (EDUKE32_PREDICT_FALSE(!(aGameVars[i].nFlags & GAMEVAR_PERPLAYER))) { g_numCompilerErrors++; C_ReportError(-1); @@ -4239,7 +4239,7 @@ DO_DEFSTATE: BITPTR_CLEAR(g_scriptPtr-script); *g_scriptPtr++=i; - if (EDUKE32_PREDICT_FALSE(aGameArrays[i].dwFlags & GAMEARRAY_READONLY)) + if (EDUKE32_PREDICT_FALSE(aGameArrays[i].nFlags & GAMEARRAY_READONLY)) { C_ReportError(ERROR_ARRAYREADONLY); g_numCompilerErrors++; @@ -4279,7 +4279,7 @@ DO_DEFSTATE: BITPTR_CLEAR(g_scriptPtr-script); *g_scriptPtr++ = i; - if (tw==CON_RESIZEARRAY && (aGameArrays[i].dwFlags & GAMEARRAY_TYPE_MASK)) + if (tw==CON_RESIZEARRAY && (aGameArrays[i].nFlags & GAMEARRAY_TYPE_MASK)) { C_ReportError(-1); initprintf("can't resize system array `%s'.", label+(g_numLabels<<6)); diff --git a/polymer/eduke32/source/gameexec.c b/polymer/eduke32/source/gameexec.c index be663ad16..b53cf0d40 100644 --- a/polymer/eduke32/source/gameexec.c +++ b/polymer/eduke32/source/gameexec.c @@ -59,19 +59,19 @@ int32_t g_currentEventExec = -1; intptr_t const *insptr; -int32_t g_iReturnVarID = -1; // var ID of "RETURN" -int32_t g_iWeaponVarID = -1; // var ID of "WEAPON" +int32_t g_iReturnVarID = -1; // var ID of "RETURN" +int32_t g_iWeaponVarID = -1; // var ID of "WEAPON" int32_t g_iWorksLikeVarID = -1; // var ID of "WORKSLIKE" -int32_t g_iZRangeVarID = -1; // var ID of "ZRANGE" -int32_t g_iAngRangeVarID = -1; // var ID of "ANGRANGE" -int32_t g_iAimAngleVarID = -1; // var ID of "AUTOAIMANGLE" -int32_t g_iLoTagID = -1; // var ID of "LOTAG" -int32_t g_iHiTagID = -1; // var ID of "HITAG" -int32_t g_iTextureID = -1; // var ID of "TEXTURE" -int32_t g_iThisActorID = -1; // var ID of "THISACTOR" -int32_t g_iStructVarIDs = -1; +int32_t g_iZRangeVarID = -1; // var ID of "ZRANGE" +int32_t g_iAngRangeVarID = -1; // var ID of "ANGRANGE" +int32_t g_iAimAngleVarID = -1; // var ID of "AUTOAIMANGLE" +int32_t g_iLoTagID = -1; // var ID of "LOTAG" +int32_t g_iHiTagID = -1; // var ID of "HITAG" +int32_t g_iTextureID = -1; // var ID of "TEXTURE" +int32_t g_iThisActorID = -1; // var ID of "THISACTOR" +int32_t g_iStructVarIDs = -1; -GAMEEXEC_STATIC void VM_Execute(int32_t loop); +GAMEEXEC_STATIC void VM_Execute(int loop); # include "gamestructures.c" #endif @@ -86,7 +86,7 @@ GAMEEXEC_STATIC void VM_Execute(int32_t loop); } #if !defined LUNATIC -void VM_ScriptInfo(intptr_t const *ptr, int32_t range) +void VM_ScriptInfo(intptr_t const *ptr, int range) { if (!script) return; @@ -118,61 +118,61 @@ void VM_ScriptInfo(intptr_t const *ptr, int32_t range) } #endif -static void VM_DeleteSprite(int32_t iActor, int32_t iPlayer) +static void VM_DeleteSprite(int nSprite, int nPlayer) { - if (EDUKE32_PREDICT_FALSE((unsigned) iActor >= MAXSPRITES)) + if (EDUKE32_PREDICT_FALSE((unsigned) nSprite >= MAXSPRITES)) return; // if player was set to squish, first stop that... - if (EDUKE32_PREDICT_FALSE(iPlayer >= 0 && g_player[iPlayer].ps->actorsqu == iActor)) - g_player[iPlayer].ps->actorsqu = -1; + if (EDUKE32_PREDICT_FALSE(nPlayer >= 0 && g_player[nPlayer].ps->actorsqu == nSprite)) + g_player[nPlayer].ps->actorsqu = -1; - A_DeleteSprite(iActor); + A_DeleteSprite(nSprite); } intptr_t apScriptGameEvent[MAXGAMEEVENTS]; // May recurse, e.g. through EVENT_XXX -> ... -> EVENT_KILLIT #ifdef LUNATIC -FORCE_INLINE int32_t VM_EventCommon_(int32_t iEventID, int32_t iActor, int32_t iPlayer, int32_t lDist, int32_t iReturn) +FORCE_INLINE int32_t VM_EventCommon_(int nEventID, int nSprite, int nPlayer, int nDist, int32_t nReturn) { const double t = gethiticks(); - int32_t ret = El_CallEvent(&g_ElState, iEventID, iActor, iPlayer, lDist, &iReturn); + int32_t ret = El_CallEvent(&g_ElState, nEventID, nSprite, nPlayer, nDist, &nReturn); // NOTE: the run times are those of the called event plus any events // called by it, *not* "self" time. - g_eventTotalMs[iEventID] += gethiticks()-t; - g_eventCalls[iEventID]++; + g_eventTotalMs[nEventID] += gethiticks()-t; + g_eventCalls[nEventID]++; if (ret == 1) - VM_DeleteSprite(iActor, iPlayer); + VM_DeleteSprite(nSprite, nPlayer); - return iReturn; + return nReturn; } #else -FORCE_INLINE int32_t VM_EventCommon_(const int32_t iEventID, const int32_t iActor, const int32_t iPlayer, - const int32_t lDist, int32_t iReturn) +FORCE_INLINE int32_t VM_EventCommon_(int const nEventID, int const nSprite, int const nPlayer, + int const nDist, int32_t nReturn) { // this is initialized first thing because iActor, iPlayer, lDist, etc are already right there on the stack // from the function call - const vmstate_t tempvm = { iActor, iPlayer, lDist, &actor[(unsigned)iActor].t_data[0], - &sprite[(unsigned)iActor], g_player[iPlayer].ps, 0 }; + const vmstate_t tempvm = { nSprite, nPlayer, nDist, &actor[(unsigned)nSprite].t_data[0], + &sprite[(unsigned)nSprite], g_player[nPlayer].ps, 0 }; // since we're targeting C99 and C++ now, we can interweave these to avoid // having to load addresses for things twice // for example, because we are loading backupReturnVar with the value of - // aGameVars[g_iReturnVarID].val.lValue, the compiler can avoid having to - // reload the address of aGameVars[g_iReturnVarID].val.lValue in order to + // aGameVars[g_iReturnVarID].lValue, the compiler can avoid having to + // reload the address of aGameVars[g_iReturnVarID].lValue in order to // set it to the value of iReturn (...which should still be on the stack!) - const int32_t backupReturnVar = aGameVars[g_iReturnVarID].val.lValue; - aGameVars[g_iReturnVarID].val.lValue = iReturn; + int const backupReturnVar = aGameVars[g_iReturnVarID].nValue; + aGameVars[g_iReturnVarID].nValue = nReturn; - const int32_t backupEventExec = g_currentEventExec; - g_currentEventExec = iEventID; + int const backupEventExec = g_currentEventExec; + g_currentEventExec = nEventID; intptr_t const *oinsptr = insptr; - insptr = script + apScriptGameEvent[iEventID]; + insptr = script + apScriptGameEvent[nEventID]; const vmstate_t vm_backup = vm; vm = tempvm; @@ -188,7 +188,7 @@ FORCE_INLINE int32_t VM_EventCommon_(const int32_t iEventID, const int32_t iActo vm.g_t = dummy_t; } - if ((unsigned)iPlayer >= (unsigned)playerswhenstarted) + if ((unsigned)nPlayer >= (unsigned)playerswhenstarted) vm.g_pp = g_player[0].ps; VM_Execute(1); @@ -198,13 +198,14 @@ FORCE_INLINE int32_t VM_EventCommon_(const int32_t iEventID, const int32_t iActo // this needs to happen after VM_DeleteSprite() because VM_DeleteSprite() // can trigger additional events - vm = vm_backup; - insptr = oinsptr; - g_currentEventExec = backupEventExec; - iReturn = aGameVars[g_iReturnVarID].val.lValue; - aGameVars[g_iReturnVarID].val.lValue = backupReturnVar; - return iReturn; + vm = vm_backup; + insptr = oinsptr; + g_currentEventExec = backupEventExec; + nReturn = aGameVars[g_iReturnVarID].nValue; + aGameVars[g_iReturnVarID].nValue = backupReturnVar; + + return nReturn; } #endif @@ -212,24 +213,24 @@ FORCE_INLINE int32_t VM_EventCommon_(const int32_t iEventID, const int32_t iActo // which are not only optimized further based on lDist or iReturn (or both) having values known at compile time, // but are called faster due to having less parameters -int32_t VM_OnEventWithBoth_(int32_t iEventID, int32_t iActor, int32_t iPlayer, int32_t lDist, int32_t iReturn) +int32_t VM_OnEventWithBoth_(int nEventID, int nSprite, int nPlayer, int nDist, int32_t nReturn) { - return VM_EventCommon_(iEventID, iActor, iPlayer, lDist, iReturn); + return VM_EventCommon_(nEventID, nSprite, nPlayer, nDist, nReturn); } -int32_t VM_OnEventWithReturn_(int32_t iEventID, int32_t iActor, int32_t iPlayer, int32_t iReturn) +int32_t VM_OnEventWithReturn_(int nEventID, int nSprite, int nPlayer, int32_t nReturn) { - return VM_EventCommon_(iEventID, iActor, iPlayer, -1, iReturn); + return VM_EventCommon_(nEventID, nSprite, nPlayer, -1, nReturn); } -int32_t VM_OnEventWithDist_(int32_t iEventID, int32_t iActor, int32_t iPlayer, int32_t lDist) +int32_t VM_OnEventWithDist_(int nEventID, int nSprite, int nPlayer, int nDist) { - return VM_EventCommon_(iEventID, iActor, iPlayer, lDist, 0); + return VM_EventCommon_(nEventID, nSprite, nPlayer, nDist, 0); } -int32_t VM_OnEvent_(int32_t iEventID, int32_t iActor, int32_t iPlayer) +int32_t VM_OnEvent_(int nEventID, int nSprite, int nPlayer) { - return VM_EventCommon_(iEventID, iActor, iPlayer, -1, 0); + return VM_EventCommon_(nEventID, nSprite, nPlayer, -1, 0); } static int32_t VM_CheckSquished(void) @@ -260,7 +261,7 @@ static int32_t VM_CheckSquished(void) P_DoQuote(QUOTE_SQUISHED, vm.g_pp); - if (A_CheckEnemySprite((uspritetype *)vm.g_sp)) + if (A_CheckEnemySprite(vm.g_sp)) vm.g_sp->xvel = 0; if (EDUKE32_PREDICT_FALSE(vm.g_sp->pal == 1)) // frozen @@ -276,38 +277,35 @@ static int32_t VM_CheckSquished(void) #if !defined LUNATIC GAMEEXEC_STATIC GAMEEXEC_INLINE void P_ForceAngle(DukePlayer_t *p) { - int32_t n = 128-(krand()&255); + int const nAngle = 128-(krand()&255); p->horiz += 64; p->return_to_center = 9; - p->look_ang = p->rotscrnang = n>>1; + p->look_ang = p->rotscrnang = nAngle>>1; } #endif -int32_t A_Dodge(spritetype *s) +int32_t A_Dodge(spritetype *pSprite) { - const int32_t mx = s->x, my = s->y; - const int32_t mxvect = sintable[(s->ang+512)&2047]; - const int32_t myvect = sintable[s->ang&2047]; + vec2_t const m = *(vec2_t *)pSprite; + vec2_t const msin = { sintable[(pSprite->ang + 512) & 2047], sintable[pSprite->ang & 2047] }; - if (A_CheckEnemySprite((uspritetype *)s) && s->extra <= 0) // hack + if (A_CheckEnemySprite(pSprite) && pSprite->extra <= 0) // hack return 0; - for (int32_t i=headspritestat[STAT_PROJECTILE]; i>=0; i=nextspritestat[i]) //weapons list + for (int nexti, SPRITES_OF_STAT_SAFE(STAT_PROJECTILE, i, nexti)) //weapons list { if (OW == i) continue; - int32_t bx = SX-mx; - int32_t by = SY-my; - int32_t bxvect = sintable[(SA+512)&2047]; - int32_t byvect = sintable[SA&2047]; + vec2_t const b = { SX - m.x, SY - m.y }; + vec2_t const v = { sintable[(SA + 512) & 2047], sintable[SA & 2047] }; - if (mxvect*bx + myvect*by >= 0 && bxvect*bx + byvect*by < 0) + if (((msin.x * b.x) + (msin.y * b.y) >= 0) && ((v.x * b.x) + (v.y * b.y) < 0)) { - if (klabs(bxvect*by - byvect*bx) < 65536<<6) + if (klabs((v.x * b.y) - (v.y * b.x)) < 65536 << 6) { - s->ang -= 512+(krand()&1024); + pSprite->ang -= 512+(krand()&1024); return 1; } } @@ -324,7 +322,7 @@ int32_t A_GetFurthestAngle(int32_t iActor, int32_t angs) return s->ang + 1024; int32_t furthest_angle = 0, greatestd = INT32_MIN; - const int32_t angincs = tabledivide32_noinline(2048, angs); + int const angincs = tabledivide32_noinline(2048, angs); hitdata_t hit; for (int32_t j=s->ang; j<(2048+s->ang); j+=angincs) @@ -336,7 +334,7 @@ int32_t A_GetFurthestAngle(int32_t iActor, int32_t angs) &hit, CLIPMASK1); s->z += (8<<8); - const int32_t d = klabs(hit.pos.x-s->x) + klabs(hit.pos.y-s->y); + int const d = klabs(hit.pos.x-s->x) + klabs(hit.pos.y-s->y); if (d > greatestd) { @@ -348,40 +346,40 @@ int32_t A_GetFurthestAngle(int32_t iActor, int32_t angs) return furthest_angle&2047; } -int32_t A_FurthestVisiblePoint(int32_t iActor, uspritetype * const ts, int32_t *dax, int32_t *day) +int32_t A_FurthestVisiblePoint(int32_t nSprite, uspritetype * const pSprite, int32_t *dax, int32_t *day) { - if (AC_COUNT(actor[iActor].t_data)&63) + if (AC_COUNT(actor[nSprite].t_data)&63) return -1; - const spritetype *const s = &sprite[iActor]; - - const int32_t angincs = - ((!g_netServer && ud.multimode < 2) && ud.player_skill < 3) ? 2048/2 : - tabledivide32_noinline(2048, 1+(krand()&1)); + const uspritetype *const pnSprite = (uspritetype *)&sprite[nSprite]; hitdata_t hit; + int const angincs = 128; +// ((!g_netServer && ud.multimode < 2) && ud.player_skill < 3) ? 2048 / 2 : tabledivide32_noinline(2048, 1 + (krand() & 1)); - for (int32_t j=ts->ang; j<(2048+ts->ang); j+=(angincs-(krand()&511))) + for (int j = pSprite->ang; j < (2048 + pSprite->ang); j += (angincs /*-(krand()&511)*/)) { - ts->z -= (16<<8); - hitscan((const vec3_t *)ts, ts->sectnum, - sintable[(j+512)&2047], - sintable[j&2047], 16384-(krand()&32767), - &hit, CLIPMASK1); + pSprite->z -= ZOFFSET2; + hitscan((const vec3_t *)pSprite, pSprite->sectnum, sintable[(j + 512) & 2047], sintable[j & 2047], + 16384 - (krand() & 32767), &hit, CLIPMASK1); + pSprite->z += ZOFFSET2; - ts->z += (16<<8); + if (hit.sect < 0) + continue; - const int32_t d = klabs(hit.pos.x-ts->x)+klabs(hit.pos.y-ts->y); - const int32_t da = klabs(hit.pos.x-s->x)+klabs(hit.pos.y-s->y); + int const d = FindDistance2D(hit.pos.x - pSprite->x, hit.pos.y - pSprite->y); + int const da = FindDistance2D(hit.pos.x - pnSprite->x, hit.pos.y - pnSprite->y); - if (d < da && hit.sect > -1) - if (cansee(hit.pos.x,hit.pos.y,hit.pos.z, - hit.sect,s->x,s->y,s->z-(16<<8),s->sectnum)) + if (d < da) + { + if (cansee(hit.pos.x, hit.pos.y, hit.pos.z, hit.sect, + pnSprite->x, pnSprite->y, pnSprite->z - ZOFFSET2, pnSprite->sectnum)) { *dax = hit.pos.x; *day = hit.pos.y; return hit.sect; } + } } return -1; @@ -390,7 +388,7 @@ int32_t A_FurthestVisiblePoint(int32_t iActor, uspritetype * const ts, int32_t * static void VM_GetZRange(int32_t iActor, int32_t *ceilhit, int32_t *florhit, int walldist) { spritetype *const s = &sprite[iActor]; - const int32_t ocstat = s->cstat; + int const ocstat = s->cstat; s->cstat = 0; s->z -= ZOFFSET; @@ -404,16 +402,13 @@ static void VM_GetZRange(int32_t iActor, int32_t *ceilhit, int32_t *florhit, int s->cstat = ocstat; } -void A_GetZLimits(int32_t iActor) +void A_GetZLimits(int32_t nSprite) { - spritetype *const s = &sprite[iActor]; + spritetype *const pSprite = &sprite[nSprite]; + int32_t ceilhit, florhit; - int32_t ceilhit, florhit; - const int walldist = (s->statnum == STAT_PROJECTILE) ? 4 : 127; - - VM_GetZRange(iActor, &ceilhit, &florhit, walldist); - - actor[iActor].flags &= ~SFLAG_NOFLOORSHADOW; + VM_GetZRange(nSprite, &ceilhit, &florhit, (pSprite->statnum == STAT_PROJECTILE) ? 4 : 127); + actor[nSprite].flags &= ~SFLAG_NOFLOORSHADOW; if ((florhit&49152) == 49152 && (sprite[florhit&(MAXSPRITES-1)].cstat&48) == 0) { @@ -422,70 +417,70 @@ void A_GetZLimits(int32_t iActor) florhit &= (MAXSPRITES-1); // If a non-projectile would fall onto non-frozen enemy OR an enemy onto a player... - if ((A_CheckEnemySprite(hitspr) && hitspr->pal != 1 && s->statnum != STAT_PROJECTILE) - || (hitspr->picnum == APLAYER && A_CheckEnemySprite((uspritetype *)s))) + if ((A_CheckEnemySprite(hitspr) && hitspr->pal != 1 && pSprite->statnum != STAT_PROJECTILE) + || (hitspr->picnum == APLAYER && A_CheckEnemySprite(pSprite))) { - actor[iActor].flags |= SFLAG_NOFLOORSHADOW; // No shadows on actors - s->xvel = -256; // SLIDE_ABOVE_ENEMY - A_SetSprite(iActor, CLIPMASK0); + actor[nSprite].flags |= SFLAG_NOFLOORSHADOW; // No shadows on actors + pSprite->xvel = -256; // SLIDE_ABOVE_ENEMY + A_SetSprite(nSprite, CLIPMASK0); } - else if (s->statnum == STAT_PROJECTILE && hitspr->picnum == APLAYER && s->owner==florhit) + else if (pSprite->statnum == STAT_PROJECTILE && hitspr->picnum == APLAYER && pSprite->owner==florhit) { - actor[iActor].ceilingz = sector[s->sectnum].ceilingz; - actor[iActor].floorz = sector[s->sectnum].floorz; + actor[nSprite].ceilingz = sector[pSprite->sectnum].ceilingz; + actor[nSprite].floorz = sector[pSprite->sectnum].floorz; } } } -void A_Fall(int32_t iActor) +void A_Fall(int nSprite) { - spritetype *const s = &sprite[iActor]; - int c = g_spriteGravity; + spritetype *const pSprite = &sprite[nSprite]; + int nGravity = g_spriteGravity; - if (EDUKE32_PREDICT_FALSE(G_CheckForSpaceFloor(s->sectnum))) - c = 0; - else if (sector[s->sectnum].lotag == ST_2_UNDERWATER || EDUKE32_PREDICT_FALSE(G_CheckForSpaceCeiling(s->sectnum))) - c = g_spriteGravity/6; + if (EDUKE32_PREDICT_FALSE(G_CheckForSpaceFloor(pSprite->sectnum))) + nGravity = 0; + else if (sector[pSprite->sectnum].lotag == ST_2_UNDERWATER || EDUKE32_PREDICT_FALSE(G_CheckForSpaceCeiling(pSprite->sectnum))) + nGravity = g_spriteGravity/6; - if (s->statnum == STAT_ACTOR || s->statnum == STAT_PLAYER || s->statnum == STAT_ZOMBIEACTOR || s->statnum == STAT_STANDABLE) + if (pSprite->statnum == STAT_ACTOR || pSprite->statnum == STAT_PLAYER || pSprite->statnum == STAT_ZOMBIEACTOR || pSprite->statnum == STAT_STANDABLE) { int32_t ceilhit, florhit; - VM_GetZRange(iActor, &ceilhit, &florhit, 127); + VM_GetZRange(nSprite, &ceilhit, &florhit, 127); } else { - actor[iActor].ceilingz = sector[s->sectnum].ceilingz; - actor[iActor].floorz = sector[s->sectnum].floorz; + actor[nSprite].ceilingz = sector[pSprite->sectnum].ceilingz; + actor[nSprite].floorz = sector[pSprite->sectnum].floorz; } #ifdef YAX_ENABLE - int16_t fbunch = (sector[s->sectnum].floorstat&512) ? -1 : yax_getbunch(s->sectnum, YAX_FLOOR); + int fbunch = (sector[pSprite->sectnum].floorstat&512) ? -1 : yax_getbunch(pSprite->sectnum, YAX_FLOOR); #endif - if (s->z < actor[iActor].floorz-ZOFFSET + if (pSprite->z < actor[nSprite].floorz-ZOFFSET #ifdef YAX_ENABLE || fbunch >= 0 #endif ) { - if (sector[s->sectnum].lotag == ST_2_UNDERWATER && s->zvel > 3122) - s->zvel = 3144; - s->z += s->zvel = min(6144, s->zvel+c); + if (sector[pSprite->sectnum].lotag == ST_2_UNDERWATER && pSprite->zvel > 3122) + pSprite->zvel = 3144; + pSprite->z += pSprite->zvel = min(6144, pSprite->zvel+nGravity); } #ifdef YAX_ENABLE if (fbunch >= 0) - setspritez(iActor, (vec3_t *)s); + setspritez(nSprite, (vec3_t *)pSprite); else #endif - if (s->z >= actor[iActor].floorz-ZOFFSET) + if (pSprite->z >= actor[nSprite].floorz-ZOFFSET) { - s->z = actor[iActor].floorz-ZOFFSET; - s->zvel = 0; + pSprite->z = actor[nSprite].floorz-ZOFFSET; + pSprite->zvel = 0; } } -int32_t G_GetAngleDelta(int32_t a,int32_t na) +int G_GetAngleDelta(int a, int na) { a &= 2047; na &= 2047; @@ -505,7 +500,7 @@ int32_t G_GetAngleDelta(int32_t a,int32_t na) GAMEEXEC_STATIC void VM_AlterAng(int32_t movflags) { - const int32_t ticselapsed = (AC_COUNT(vm.g_t))&31; + int const nElapsedTics = (AC_COUNT(vm.g_t))&31; #if !defined LUNATIC const intptr_t *moveptr; @@ -528,49 +523,51 @@ GAMEEXEC_STATIC void VM_AlterAng(int32_t movflags) vm.g_sp->zvel += ((actor[vm.g_i].mv.vvel<<4) - vm.g_sp->zvel)/5; #endif - if (A_CheckEnemySprite((uspritetype *)vm.g_sp) && vm.g_sp->extra <= 0) // hack + if (A_CheckEnemySprite(vm.g_sp) && vm.g_sp->extra <= 0) // hack return; if (movflags&seekplayer) { - int32_t aang = vm.g_sp->ang, angdif, goalang; - int32_t j = vm.g_pp->holoduke_on; + int nAngDiff; + int nGoalAng; + int const nAngle = vm.g_sp->ang; + int32_t nHoloDuke = vm.g_pp->holoduke_on; // NOTE: looks like 'owner' is set to target sprite ID... - if (j >= 0 && cansee(sprite[j].x,sprite[j].y,sprite[j].z,sprite[j].sectnum,vm.g_sp->x,vm.g_sp->y,vm.g_sp->z,vm.g_sp->sectnum)) - vm.g_sp->owner = j; + if (nHoloDuke >= 0 && cansee(sprite[nHoloDuke].x, sprite[nHoloDuke].y, sprite[nHoloDuke].z, sprite[nHoloDuke].sectnum, + vm.g_sp->x, vm.g_sp->y, vm.g_sp->z, vm.g_sp->sectnum)) + vm.g_sp->owner = nHoloDuke; else vm.g_sp->owner = vm.g_pp->i; - if (sprite[vm.g_sp->owner].picnum == APLAYER) - goalang = getangle(actor[vm.g_i].lastvx-vm.g_sp->x,actor[vm.g_i].lastvy-vm.g_sp->y); - else - goalang = getangle(sprite[vm.g_sp->owner].x-vm.g_sp->x,sprite[vm.g_sp->owner].y-vm.g_sp->y); + nGoalAng = (sprite[vm.g_sp->owner].picnum == APLAYER) + ? getangle(actor[vm.g_i].lastvx - vm.g_sp->x, actor[vm.g_i].lastvy - vm.g_sp->y) + : getangle(sprite[vm.g_sp->owner].x - vm.g_sp->x, sprite[vm.g_sp->owner].y - vm.g_sp->y); if (vm.g_sp->xvel && vm.g_sp->picnum != DRONE) { - angdif = G_GetAngleDelta(aang,goalang); + nAngDiff = G_GetAngleDelta(nAngle,nGoalAng); - if (ticselapsed < 2) + if (nElapsedTics < 2) { - if (klabs(angdif) < 256) + if (klabs(nAngDiff) < 256) { - j = 128-(krand()&256); + int const j = 128-(krand()&256); vm.g_sp->ang += j; if (A_GetHitscanRange(vm.g_i) < 844) vm.g_sp->ang -= j; } } - else if (ticselapsed > 18 && ticselapsed < GAMETICSPERSEC) // choose + else if (nElapsedTics > 18 && nElapsedTics < GAMETICSPERSEC) // choose { - if (klabs(angdif>>2) < 128) vm.g_sp->ang = goalang; - else vm.g_sp->ang += angdif>>2; + if (klabs(nAngDiff>>2) < 128) vm.g_sp->ang = nGoalAng; + else vm.g_sp->ang += nAngDiff>>2; } } - else vm.g_sp->ang = goalang; + else vm.g_sp->ang = nGoalAng; } - if (ticselapsed < 1) + if (nElapsedTics < 1) { if (movflags&furthestdir) { @@ -583,26 +580,20 @@ GAMEEXEC_STATIC void VM_AlterAng(int32_t movflags) } } -static inline void VM_AddAngle(int32_t shr, int32_t goalang) +static inline void VM_AddAngle(int nShift, int nGoalAng) { - int32_t angdif = G_GetAngleDelta(vm.g_sp->ang,goalang)>>shr; + int nAngDiff = G_GetAngleDelta(vm.g_sp->ang, nGoalAng) >> nShift; - if ((angdif > -8 && angdif < 0) || (angdif < 8 && angdif > 0)) - angdif *= 2; + if ((nAngDiff > -8 && nAngDiff < 0) || (nAngDiff < 8 && nAngDiff > 0)) + nAngDiff <<= 1; - vm.g_sp->ang += angdif; + vm.g_sp->ang += nAngDiff; } -static void VM_FacePlayer(int32_t shr) +static inline void VM_FacePlayer(int nShift) { - int32_t goalang; - - if (vm.g_pp->newowner >= 0) - goalang = getangle(vm.g_pp->opos.x-vm.g_sp->x, vm.g_pp->opos.y-vm.g_sp->y); - else - goalang = getangle(vm.g_pp->pos.x-vm.g_sp->x, vm.g_pp->pos.y-vm.g_sp->y); - - VM_AddAngle(shr, goalang); + VM_AddAngle(nShift, (vm.g_pp->newowner >= 0) ? getangle(vm.g_pp->opos.x - vm.g_sp->x, vm.g_pp->opos.y - vm.g_sp->y) + : getangle(vm.g_pp->pos.x - vm.g_sp->x, vm.g_pp->pos.y - vm.g_sp->y)); } ////////// TROR get*zofslope ////////// @@ -610,34 +601,34 @@ static void VM_FacePlayer(int32_t shr) static int32_t VM_GetCeilZOfSlope(void) { - const int dax = vm.g_sp->x, day = vm.g_sp->y; - const int sectnum = vm.g_sp->sectnum; + vec2_t const vect = *(vec2_t *)vm.g_sp; + int const sectnum = vm.g_sp->sectnum; #ifdef YAX_ENABLE if ((sector[sectnum].ceilingstat&512)==0) { - int32_t nsect = yax_getneighborsect(dax, day, sectnum, YAX_CEILING); + int const nsect = yax_getneighborsect(vect.x, vect.y, sectnum, YAX_CEILING); if (nsect >= 0) - return getceilzofslope(nsect, dax, day); + return getceilzofslope(nsect, vect.x, vect.y); } #endif - return getceilzofslope(sectnum, dax, day); + return getceilzofslope(sectnum, vect.x, vect.y); } static int32_t VM_GetFlorZOfSlope(void) { - const int dax = vm.g_sp->x, day = vm.g_sp->y; - const int sectnum = vm.g_sp->sectnum; + vec2_t const vect = *(vec2_t *)vm.g_sp; + int const sectnum = vm.g_sp->sectnum; #ifdef YAX_ENABLE if ((sector[sectnum].floorstat&512)==0) { - int32_t nsect = yax_getneighborsect(dax, day, sectnum, YAX_FLOOR); + int const nsect = yax_getneighborsect(vect.x, vect.y, sectnum, YAX_FLOOR); if (nsect >= 0) - return getflorzofslope(nsect, dax, day); + return getflorzofslope(nsect, vect.x, vect.y); } #endif - return getflorzofslope(sectnum, dax, day); + return getflorzofslope(sectnum, vect.x, vect.y); } //////////////////// @@ -652,8 +643,8 @@ GAMEEXEC_STATIC void VM_Move(void) // NOTE: commented out condition is dead since r3159 (making hi/lotag unsigned). // XXX: Does it break anything? Where are movflags with all bits set created? const uint16_t *movflagsptr = &AC_MOVFLAGS(vm.g_sp, &actor[vm.g_i]); - const int32_t movflags = /*(*movflagsptr==-1) ? 0 :*/ *movflagsptr; - const int32_t deadflag = (A_CheckEnemySprite((uspritetype *)vm.g_sp) && vm.g_sp->extra <= 0); + int const movflags = /*(*movflagsptr==-1) ? 0 :*/ *movflagsptr; + int const deadflag = (A_CheckEnemySprite(vm.g_sp) && vm.g_sp->extra <= 0); AC_COUNT(vm.g_t)++; @@ -688,10 +679,9 @@ GAMEEXEC_STATIC void VM_Move(void) if (movflags&face_player_smart) { - int32_t newx = vm.g_pp->pos.x + (vm.g_pp->vel.x/768); - int32_t newy = vm.g_pp->pos.y + (vm.g_pp->vel.y/768); - int32_t goalang = getangle(newx-vm.g_sp->x,newy-vm.g_sp->y); - VM_AddAngle(2, goalang); + vec2_t const vect = { vm.g_pp->pos.x + (vm.g_pp->vel.x / 768), + vm.g_pp->pos.y + (vm.g_pp->vel.y / 768) }; + VM_AddAngle(2, getangle(vect.x - vm.g_sp->x, vect.y - vm.g_sp->y)); } dead: @@ -721,12 +711,12 @@ dead: if (vm.g_sp->xvel > -6 && vm.g_sp->xvel < 6) vm.g_sp->xvel = 0; - int badguyp = A_CheckEnemySprite((uspritetype *)vm.g_sp); + int badguyp = A_CheckEnemySprite(vm.g_sp); if (vm.g_sp->xvel || vm.g_sp->zvel) { - int32_t daxvel = vm.g_sp->xvel; - int32_t angdif = vm.g_sp->ang; + int nXvel = vm.g_sp->xvel; + int nAngDiff = vm.g_sp->ang; if (badguyp && vm.g_sp->picnum != ROTATEGUN) { @@ -734,39 +724,39 @@ dead: { if (vm.g_sp->picnum == COMMANDER) { - int32_t l; + int32_t nSectorZ; // NOTE: COMMANDER updates both actor[].floorz and // .ceilingz regardless of its zvel. - actor[vm.g_i].floorz = l = VM_GetFlorZOfSlope(); - if (vm.g_sp->z > l-(8<<8)) + actor[vm.g_i].floorz = nSectorZ = VM_GetFlorZOfSlope(); + if (vm.g_sp->z > nSectorZ-(8<<8)) { - vm.g_sp->z = l-(8<<8); + vm.g_sp->z = nSectorZ-(8<<8); vm.g_sp->zvel = 0; } - actor[vm.g_i].ceilingz = l = VM_GetCeilZOfSlope(); - if (vm.g_sp->z < l+(80<<8)) + actor[vm.g_i].ceilingz = nSectorZ = VM_GetCeilZOfSlope(); + if (vm.g_sp->z < nSectorZ+(80<<8)) { - vm.g_sp->z = l+(80<<8); + vm.g_sp->z = nSectorZ+(80<<8); vm.g_sp->zvel = 0; } } else { - int32_t l; + int32_t nSectorZ; // The DRONE updates either .floorz or .ceilingz, not both. if (vm.g_sp->zvel > 0) { - actor[vm.g_i].floorz = l = VM_GetFlorZOfSlope(); - if (vm.g_sp->z > l-(30<<8)) - vm.g_sp->z = l-(30<<8); + actor[vm.g_i].floorz = nSectorZ = VM_GetFlorZOfSlope(); + if (vm.g_sp->z > nSectorZ-(30<<8)) + vm.g_sp->z = nSectorZ-(30<<8); } else { - actor[vm.g_i].ceilingz = l = VM_GetCeilZOfSlope(); - if (vm.g_sp->z < l+(50<<8)) + actor[vm.g_i].ceilingz = nSectorZ = VM_GetCeilZOfSlope(); + if (vm.g_sp->z < nSectorZ+(50<<8)) { - vm.g_sp->z = l+(50<<8); + vm.g_sp->z = nSectorZ+(50<<8); vm.g_sp->zvel = 0; } } @@ -784,7 +774,7 @@ dead: } else if (vm.g_sp->zvel < 0) { - const int32_t l = VM_GetCeilZOfSlope(); + int const l = VM_GetCeilZOfSlope(); if (vm.g_sp->z < l+(66<<8)) { @@ -796,8 +786,8 @@ dead: if (vm.g_x < 960 && vm.g_sp->xrepeat > 16) { - daxvel = -(1024 - vm.g_x); - angdif = getangle(vm.g_pp->pos.x - vm.g_sp->x, vm.g_pp->pos.y - vm.g_sp->y); + nXvel = -(1024 - vm.g_x); + nAngDiff = getangle(vm.g_pp->pos.x - vm.g_sp->x, vm.g_pp->pos.y - vm.g_sp->y); if (vm.g_x < 512) { @@ -819,7 +809,7 @@ dead: { if (AC_COUNT(vm.g_t) & 1) return; - daxvel <<= 1; + nXvel <<= 1; } } } @@ -827,31 +817,30 @@ dead: if (vm.g_sp->z < actor[vm.g_i].ceilingz+(32<<8)) vm.g_sp->z = actor[vm.g_i].ceilingz+(32<<8); - vec3_t tmpvect = { (daxvel * (sintable[(angdif + 512) & 2047])) >> 14, - (daxvel * (sintable[angdif & 2047])) >> 14, vm.g_sp->zvel }; + vec3_t const vect = { (nXvel * (sintable[(nAngDiff + 512) & 2047])) >> 14, + (nXvel * (sintable[nAngDiff & 2047])) >> 14, vm.g_sp->zvel }; - actor[vm.g_i].movflag = - A_MoveSprite(vm.g_i, &tmpvect, (A_CheckSpriteFlags(vm.g_i, SFLAG_NOCLIP) ? 0 : CLIPMASK0)); + actor[vm.g_i].movflag = A_MoveSprite(vm.g_i, &vect, (A_CheckSpriteFlags(vm.g_i, SFLAG_NOCLIP) ? 0 : CLIPMASK0)); } if (!badguyp) return; - vm.g_sp->shade += (sector[vm.g_sp->sectnum].ceilingstat & 1) ? - (sector[vm.g_sp->sectnum].ceilingshade - vm.g_sp->shade) >> 1 : - (sector[vm.g_sp->sectnum].floorshade - vm.g_sp->shade) >> 1; + vm.g_sp->shade += (sector[vm.g_sp->sectnum].ceilingstat & 1) ? (sector[vm.g_sp->sectnum].ceilingshade - vm.g_sp->shade) >> 1 + : (sector[vm.g_sp->sectnum].floorshade - vm.g_sp->shade) >> 1; } -static void P_AddWeaponMaybeSwitch(DukePlayer_t *ps, int32_t weap) +static void P_AddWeaponMaybeSwitch(DukePlayer_t *ps, int nWeapon) { if ((ps->weaponswitch & (1|4)) == (1|4)) { - const int32_t snum = P_Get(ps->i); - int32_t i, new_wchoice = -1, curr_wchoice = -1; + int const nPlayer = P_Get(ps->i); + int new_wchoice = -1; + int curr_wchoice = -1; - for (i=0; i<=FREEZE_WEAPON && (new_wchoice < 0 || curr_wchoice < 0); i++) + for (int i=0; i<=FREEZE_WEAPON && (new_wchoice < 0 || curr_wchoice < 0); i++) { - int32_t w = g_player[snum].wchoice[i]; + int w = g_player[nPlayer].wchoice[i]; if (w == KNEE_WEAPON) w = FREEZE_WEAPON; @@ -859,15 +848,15 @@ static void P_AddWeaponMaybeSwitch(DukePlayer_t *ps, int32_t weap) if (w == ps->curr_weapon) curr_wchoice = i; - if (w == weap) + if (w == nWeapon) new_wchoice = i; } - P_AddWeapon(ps, weap, (new_wchoice < curr_wchoice)); + P_AddWeapon(ps, nWeapon, (new_wchoice < curr_wchoice)); } else { - P_AddWeapon(ps, weap, (ps->weaponswitch & 1)); + P_AddWeapon(ps, nWeapon, (ps->weaponswitch & 1)); } } @@ -877,65 +866,61 @@ void P_AddWeaponMaybeSwitchI(int32_t snum, int32_t weap) P_AddWeaponMaybeSwitch(g_player[snum].ps, weap); } #else -static void P_AddWeaponAmmoCommon(DukePlayer_t *ps, int32_t weap, int32_t amount) +static void P_AddWeaponAmmoCommon(DukePlayer_t *ps, int nWeapon, int nAmount) { - P_AddAmmo(weap, ps, amount); + P_AddAmmo(nWeapon, ps, nAmount); - if (PWEAPON(vm.g_p, ps->curr_weapon, WorksLike) == KNEE_WEAPON && (ps->gotweapon & (1 << weap))) - P_AddWeaponMaybeSwitch(ps, weap); + if (PWEAPON(vm.g_p, ps->curr_weapon, WorksLike) == KNEE_WEAPON && (ps->gotweapon & (1 << nWeapon))) + P_AddWeaponMaybeSwitch(ps, nWeapon); } -static int32_t VM_AddWeapon(int32_t weap, int32_t amount, DukePlayer_t *ps) +static int VM_AddWeapon(DukePlayer_t *ps, int nWeapon, int nAmount) { - if (EDUKE32_PREDICT_FALSE((unsigned)weap >= MAX_WEAPONS)) + if (EDUKE32_PREDICT_FALSE((unsigned)nWeapon >= MAX_WEAPONS)) { - CON_ERRPRINTF("Invalid weapon ID %d\n", weap); + CON_ERRPRINTF("Invalid weapon ID %d\n", nWeapon); return 1; } - if ((ps->gotweapon & (1 << weap)) == 0) + if ((ps->gotweapon & (1 << nWeapon)) == 0) { - P_AddWeaponMaybeSwitch(ps, weap); + P_AddWeaponMaybeSwitch(ps, nWeapon); } - else if (ps->ammo_amount[weap] >= ps->max_ammo_amount[weap]) + else if (ps->ammo_amount[nWeapon] >= ps->max_ammo_amount[nWeapon]) { vm.g_flags |= VM_NOEXECUTE; return 2; } - P_AddWeaponAmmoCommon(ps, weap, amount); + P_AddWeaponAmmoCommon(ps, nWeapon, nAmount); return 0; } #endif -static int32_t A_GetVerticalVel(const actor_t *ac) +static int32_t A_GetVerticalVel(actor_t const * const pActor) { #ifdef LUNATIC - return ac->mv.vvel; + return pActor->mv.vvel; #else - int32_t moveScriptOfs = AC_MOVE_ID(ac->t_data); + int32_t moveScriptOfs = AC_MOVE_ID(pActor->t_data); - if ((unsigned)moveScriptOfs < (unsigned)g_scriptSize-1) - return script[moveScriptOfs + 1]; - else - return 0; + return ((unsigned) moveScriptOfs < (unsigned) g_scriptSize - 1) ? script[moveScriptOfs + 1] : 0; #endif } -static int32_t A_GetWaterZOffset(int spritenum) +static int32_t A_GetWaterZOffset(int nSprite) { - const spritetype *const sp = &sprite[spritenum]; - const actor_t *const ac = &actor[spritenum]; + uspritetype const *const pSprite = (uspritetype *)&sprite[nSprite]; + actor_t const *const pActor = &actor[nSprite]; - if (sector[sp->sectnum].lotag == ST_1_ABOVE_WATER) + if (sector[pSprite->sectnum].lotag == ST_1_ABOVE_WATER) { - if (A_CheckSpriteFlags(spritenum, SFLAG_NOWATERDIP)) + if (A_CheckSpriteFlags(nSprite, SFLAG_NOWATERDIP)) return 0; // fix for flying/jumping monsters getting stuck in water - if ((AC_MOVFLAGS(sp, ac) & jumptoplayer_only) || - (G_HaveActor(sp->picnum) && A_GetVerticalVel(ac) != 0)) + if ((AC_MOVFLAGS(pSprite, pActor) & jumptoplayer_only) || (G_HaveActor(pSprite->picnum) && A_GetVerticalVel(pActor) != 0)) return 0; return ACTOR_ONWATER_ADDZ; @@ -944,121 +929,121 @@ static int32_t A_GetWaterZOffset(int spritenum) return 0; } -static void VM_Fall(int32_t g_i, spritetype *g_sp) +static void VM_Fall(int nSprite, spritetype *pSprite) { - int32_t grav = g_spriteGravity; + int nGravity = g_spriteGravity; - g_sp->xoffset = g_sp->yoffset = 0; + pSprite->xoffset = pSprite->yoffset = 0; - if (sector[g_sp->sectnum].lotag == ST_2_UNDERWATER || EDUKE32_PREDICT_FALSE(G_CheckForSpaceCeiling(g_sp->sectnum))) - grav = g_spriteGravity/6; - else if (EDUKE32_PREDICT_FALSE(G_CheckForSpaceFloor(g_sp->sectnum))) - grav = 0; + if (sector[pSprite->sectnum].lotag == ST_2_UNDERWATER || EDUKE32_PREDICT_FALSE(G_CheckForSpaceCeiling(pSprite->sectnum))) + nGravity = g_spriteGravity/6; + else if (EDUKE32_PREDICT_FALSE(G_CheckForSpaceFloor(pSprite->sectnum))) + nGravity = 0; - if (!actor[g_i].cgg-- || (sector[g_sp->sectnum].floorstat&2)) + if (!actor[nSprite].cgg-- || (sector[pSprite->sectnum].floorstat&2)) { - A_GetZLimits(g_i); - actor[g_i].cgg = 3; + A_GetZLimits(nSprite); + actor[nSprite].cgg = 3; } - if (g_sp->z < actor[g_i].floorz-ZOFFSET) + if (pSprite->z < actor[nSprite].floorz-ZOFFSET) { // Free fall. - g_sp->zvel = min(g_sp->zvel+grav, ACTOR_MAXFALLINGZVEL); - int32_t z = g_sp->z + g_sp->zvel; + pSprite->zvel = min(pSprite->zvel+nGravity, ACTOR_MAXFALLINGZVEL); + int32_t z = pSprite->z + pSprite->zvel; #ifdef YAX_ENABLE - if (yax_getbunch(g_sp->sectnum, YAX_FLOOR) >= 0 && - (sector[g_sp->sectnum].floorstat&512)==0) - setspritez(g_i, (vec3_t *)g_sp); + if (yax_getbunch(pSprite->sectnum, YAX_FLOOR) >= 0 && + (sector[pSprite->sectnum].floorstat&512)==0) + setspritez(nSprite, (vec3_t *)pSprite); else #endif - if (z > actor[g_i].floorz - ZOFFSET) - z = actor[g_i].floorz - ZOFFSET; + if (z > actor[nSprite].floorz - ZOFFSET) + z = actor[nSprite].floorz - ZOFFSET; - g_sp->z = z; + pSprite->z = z; return; } // Preliminary new z position of the actor. - int32_t z = actor[g_i].floorz - ZOFFSET; + int32_t z = actor[nSprite].floorz - ZOFFSET; - if (A_CheckEnemySprite((uspritetype *)g_sp) || (g_sp->picnum == APLAYER && g_sp->owner >= 0)) + if (A_CheckEnemySprite(pSprite) || (pSprite->picnum == APLAYER && pSprite->owner >= 0)) { - if (g_sp->zvel > 3084 && g_sp->extra <= 1) + if (pSprite->zvel > 3084 && pSprite->extra <= 1) { // I'm guessing this DRONE check is from a beta version of the game // where they crashed into the ground when killed - if (!(g_sp->picnum == APLAYER && g_sp->extra > 0) && g_sp->pal != 1 && g_sp->picnum != DRONE) + if (!(pSprite->picnum == APLAYER && pSprite->extra > 0) && pSprite->pal != 1 && pSprite->picnum != DRONE) { - A_DoGuts(g_i,JIBS6,15); - A_PlaySound(SQUISHED,g_i); - A_Spawn(g_i,BLOODPOOL); + A_DoGuts(nSprite,JIBS6,15); + A_PlaySound(SQUISHED,nSprite); + A_Spawn(nSprite,BLOODPOOL); } - actor[g_i].picnum = SHOTSPARK1; - actor[g_i].extra = 1; - g_sp->zvel = 0; + actor[nSprite].picnum = SHOTSPARK1; + actor[nSprite].extra = 1; + pSprite->zvel = 0; } - else if (g_sp->zvel > 2048 && sector[g_sp->sectnum].lotag != ST_1_ABOVE_WATER) + else if (pSprite->zvel > 2048 && sector[pSprite->sectnum].lotag != ST_1_ABOVE_WATER) { - int16_t newsect = g_sp->sectnum; + int16_t newsect = pSprite->sectnum; - pushmove((vec3_t *)g_sp, &newsect, 128, 4<<8, 4<<8, CLIPMASK0); + pushmove((vec3_t *)pSprite, &newsect, 128, 4<<8, 4<<8, CLIPMASK0); if ((unsigned)newsect < MAXSECTORS) - changespritesect(g_i, newsect); + changespritesect(nSprite, newsect); - A_PlaySound(THUD, g_i); + A_PlaySound(THUD, nSprite); } } - if (sector[g_sp->sectnum].lotag == ST_1_ABOVE_WATER) + if (sector[pSprite->sectnum].lotag == ST_1_ABOVE_WATER) { - g_sp->z = z + A_GetWaterZOffset(g_i); + pSprite->z = z + A_GetWaterZOffset(nSprite); return; } - g_sp->z = z; - g_sp->zvel = 0; + pSprite->z = z; + pSprite->zvel = 0; } -static int32_t VM_ResetPlayer(int32_t g_p, int32_t g_flags, int32_t flags) +static int32_t VM_ResetPlayer(int nPlayer, int32_t g_flags, int32_t nFlags) { //AddLog("resetplayer"); - if (!g_netServer && ud.multimode < 2) + if (!g_netServer && ud.multimode < 2 && !(nFlags & 2)) { - if (g_lastSaveSlot >= 0 && ud.recstat != 2 && !(flags & 1)) + if (g_lastSaveSlot >= 0 && ud.recstat != 2 && !(nFlags & 1)) { - M_OpenMenu(g_p); + M_OpenMenu(nPlayer); KB_ClearKeyDown(sc_Space); I_AdvanceTriggerClear(); M_ChangeMenu(MENU_RESETPLAYER); } - else g_player[g_p].ps->gm = MODE_RESTART; + else g_player[nPlayer].ps->gm = MODE_RESTART; #if !defined LUNATIC g_flags |= VM_NOEXECUTE; #endif } else { - if (g_p == myconnectindex) + if (nPlayer == myconnectindex) { CAMERADIST = 0; CAMERACLOCK = totalclock; } if (g_fakeMultiMode) - P_ResetPlayer(g_p); + P_ResetPlayer(nPlayer); #ifndef NETCODE_DISABLE if (g_netServer) { - P_ResetPlayer(g_p); - Net_SpawnPlayer(g_p); + P_ResetPlayer(nPlayer); + Net_SpawnPlayer(nPlayer); } #endif } - P_UpdateScreenPal(g_player[g_p].ps); + P_UpdateScreenPal(g_player[nPlayer].ps); //AddLog("EOF: resetplayer"); return g_flags; @@ -1067,10 +1052,9 @@ static int32_t VM_ResetPlayer(int32_t g_p, int32_t g_flags, int32_t flags) void G_GetTimeDate(int32_t *vals) { time_t rawtime; - struct tm *ti; - time(&rawtime); - ti=localtime(&rawtime); + struct tm *ti = localtime(&rawtime); + // initprintf("Time&date: %s\n",asctime (ti)); vals[0] = ti->tm_sec; @@ -1083,17 +1067,17 @@ void G_GetTimeDate(int32_t *vals) vals[7] = ti->tm_yday; } -int32_t G_StartTrack(int32_t level) +int G_StartTrack(int nLevel) { - if ((unsigned)level < MAXLEVELS) + if ((unsigned)nLevel < MAXLEVELS) { - int32_t musicIndex = MAXLEVELS*ud.volume_number + level; + int nTrackNum = MAXLEVELS*ud.volume_number + nLevel; - if (MapInfo[musicIndex].musicfn != NULL) + if (MapInfo[nTrackNum].musicfn != NULL) { // Only set g_musicIndex on success. - g_musicIndex = musicIndex; - S_PlayMusic(MapInfo[musicIndex].musicfn); + g_musicIndex = nTrackNum; + S_PlayMusic(MapInfo[nTrackNum].musicfn); return 0; } @@ -1105,11 +1089,6 @@ int32_t G_StartTrack(int32_t level) LUNATIC_EXTERN void G_ShowView(vec3_t vec, int32_t a, int32_t horiz, int32_t sect, int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t unbiasedp) { - int32_t smoothratio = calc_smoothratio(totalclock, ototalclock); -#ifdef USE_OPENGL - int32_t oprojhacks; -#endif - if (g_screenCapture) return; @@ -1145,22 +1124,18 @@ LUNATIC_EXTERN void G_ShowView(vec3_t vec, int32_t a, int32_t horiz, int32_t sec horiz = clamp(horiz, HORIZ_MIN, HORIZ_MAX); #ifdef USE_OPENGL - oprojhacks = glprojectionhacks; + int const oprojhacks = glprojectionhacks; glprojectionhacks = 0; #endif - { - int32_t o = newaspect_enable; - newaspect_enable = r_usenewaspect; - setaspect_new_use_dimen = 1; - - setview(x1,y1,x2,y2); - - setaspect_new_use_dimen = 0; - newaspect_enable = o; - } + int const onewaspect = newaspect_enable; + newaspect_enable = r_usenewaspect; + setaspect_new_use_dimen = 1; + setview(x1,y1,x2,y2); + setaspect_new_use_dimen = 0; + newaspect_enable = onewaspect; + int const smoothratio = calc_smoothratio(totalclock, ototalclock); G_DoInterpolations(smoothratio); - G_HandleMirror(vec.x, vec.y, vec.z, a, horiz, smoothratio); #ifdef POLYMER if (getrendermode() == REND_POLYMER) @@ -1239,13 +1214,14 @@ skip_check: case CON_REDEFINEQUOTE: insptr++; { - int32_t q = *insptr++, i = *insptr++; - if (EDUKE32_PREDICT_FALSE((ScriptQuotes[q] == NULL || ScriptQuoteRedefinitions[i] == NULL))) + int const nDestQuote = *insptr++; + int const nRedef = *insptr++; + if (EDUKE32_PREDICT_FALSE((ScriptQuotes[nDestQuote] == NULL || ScriptQuoteRedefinitions[nRedef] == NULL))) { - CON_ERRPRINTF("%d %d null quote\n", q,i); + CON_ERRPRINTF("%d %d null quote\n", nDestQuote,nRedef); break; } - Bstrcpy(ScriptQuotes[q],ScriptQuoteRedefinitions[i]); + Bstrcpy(ScriptQuotes[nDestQuote],ScriptQuoteRedefinitions[nRedef]); continue; } @@ -1253,11 +1229,10 @@ skip_check: insptr++; { tw = *insptr++; - int32_t lLabelID=*insptr++, lVar2=*insptr++; + int const nSprite = (tw != g_iThisActorID) ? Gv_GetVarX(tw) : vm.g_i; + int const nLabel = *insptr++; - register int32_t const iActor = (tw != g_iThisActorID) ? Gv_GetVarX(tw) : vm.g_i; - - Gv_SetVarX(lVar2, VM_GetActiveProjectile(iActor, lLabelID)); + Gv_SetVarX(*insptr++, VM_GetActiveProjectile(nSprite, nLabel)); continue; } @@ -1265,12 +1240,10 @@ skip_check: insptr++; { tw = *insptr++; - int32_t lLabelID=*insptr++, lVar2=*insptr++; + int const nSprite = (tw != g_iThisActorID) ? Gv_GetVarX(tw) : vm.g_i; + int const nLabel = *insptr++; - register int32_t const iActor = (tw != g_iThisActorID) ? Gv_GetVarX(tw) : vm.g_i; - register int32_t const iSet = Gv_GetVarX(lVar2); - - VM_SetActiveProjectile(iActor, lLabelID, iSet); + VM_SetActiveProjectile(nSprite, nLabel, Gv_GetVarX(*insptr++)); continue; } @@ -1290,26 +1263,27 @@ skip_check: continue; } - int32_t sclip = 768, angdif = 16; + int nClip = 768; + int nAngDiff = 16; - if (A_CheckEnemySprite((uspritetype *)vm.g_sp) && vm.g_sp->xrepeat > 56) + if (A_CheckEnemySprite(vm.g_sp) && vm.g_sp->xrepeat > 56) { - sclip = 3084; - angdif = 48; + nClip = 3084; + nAngDiff = 48; } #define CHECK(x) if (x >= 0 && sprite[x].picnum == vm.g_sp->picnum) { VM_CONDITIONAL(0); continue; } #define CHECK2(x) do { vm.g_sp->ang += x; tw = A_CheckHitSprite(vm.g_i, &temphit); vm.g_sp->ang -= x; } while(0) - if (tw > sclip) + if (tw > nClip) { CHECK(temphit); - CHECK2(angdif); + CHECK2(nAngDiff); - if (tw > sclip) + if (tw > nClip) { CHECK(temphit); - CHECK2(-angdif); + CHECK2(-nAngDiff); if (tw > 768) { @@ -1338,7 +1312,7 @@ skip_check: case CON_IFCANSEE: { - uspritetype * s = (uspritetype *)&sprite[ps->i]; + uspritetype *s = (uspritetype *)&sprite[ps->i]; // select sprite for monster to target // if holoduke is on, let them target holoduke first. @@ -1413,7 +1387,7 @@ skip_check: AC_COUNT(vm.g_t) = AC_ACTION_COUNT(vm.g_t) = AC_CURFRAME(vm.g_t) = 0; - if (!A_CheckEnemySprite((uspritetype *)vm.g_sp) || vm.g_sp->extra > 0) // hack + if (!A_CheckEnemySprite(vm.g_sp) || vm.g_sp->extra > 0) // hack if (vm.g_sp->hitag&random_angle) vm.g_sp->ang = krand()&2047; continue; @@ -1457,7 +1431,7 @@ skip_check: { if (*insptr == 0) { - int32_t j = 0; + int j = 0; for (; j < ps->weapreccnt; j++) if (ps->weaprecs[j] == vm.g_sp->picnum) break; @@ -1600,16 +1574,16 @@ skip_check: case CON_STOPACTORSOUND: insptr++; { - int const i = Gv_GetVarX(*insptr++), j = Gv_GetVarX(*insptr++); + int const nSprite = Gv_GetVarX(*insptr++), nSound = Gv_GetVarX(*insptr++); - if (EDUKE32_PREDICT_FALSE((unsigned)j >= MAXSOUNDS)) + if (EDUKE32_PREDICT_FALSE((unsigned)nSound >= MAXSOUNDS)) { - CON_ERRPRINTF("Invalid sound %d\n", j); + CON_ERRPRINTF("Invalid sound %d\n", nSound); continue; } - if (A_CheckSoundPlaying(i, j)) - S_StopEnvSound(j, i); + if (A_CheckSoundPlaying(nSprite, nSound)) + S_StopEnvSound(nSound, nSprite); continue; } @@ -1617,15 +1591,17 @@ skip_check: case CON_SETACTORSOUNDPITCH: insptr++; { - int const i = Gv_GetVarX(*insptr++), j = Gv_GetVarX(*insptr++), pitchoffset = Gv_GetVarX(*insptr++); + int const nSprite = Gv_GetVarX(*insptr++); + int const nSound = Gv_GetVarX(*insptr++); + int const nPitch = Gv_GetVarX(*insptr++); - if (EDUKE32_PREDICT_FALSE((unsigned)j>=MAXSOUNDS)) + if (EDUKE32_PREDICT_FALSE((unsigned)nSound>=MAXSOUNDS)) { - CON_ERRPRINTF("Invalid sound %d\n", j); + CON_ERRPRINTF("Invalid sound %d\n", nSound); continue; } - S_ChangeSoundPitch(j,i,pitchoffset); + S_ChangeSoundPitch(nSound, nSprite, nPitch); continue; } @@ -1679,21 +1655,22 @@ skip_check: case CON_ADDAMMO: insptr++; { - int const weap = *insptr++, amount = *insptr++; + int const nWeapon = *insptr++; + int const nAmount = *insptr++; - if (EDUKE32_PREDICT_FALSE((unsigned)weap >= MAX_WEAPONS)) + if (EDUKE32_PREDICT_FALSE((unsigned)nWeapon >= MAX_WEAPONS)) { - CON_ERRPRINTF("Invalid weapon ID %d\n", weap); + CON_ERRPRINTF("Invalid weapon ID %d\n", nWeapon); break; } - if (ps->ammo_amount[weap] >= ps->max_ammo_amount[weap]) + if (ps->ammo_amount[nWeapon] >= ps->max_ammo_amount[nWeapon]) { vm.g_flags |= VM_NOEXECUTE; return; } - P_AddWeaponAmmoCommon(ps, weap, amount); + P_AddWeaponAmmoCommon(ps, nWeapon, nAmount); continue; } @@ -1737,9 +1714,8 @@ skip_check: case CON_ADDWEAPON: insptr++; { - int const weap=*insptr++, amount=*insptr++; - VM_AddWeapon(weap, amount, ps); - + int const nWeapon = *insptr++; + VM_AddWeapon(ps, nWeapon, *insptr++); continue; } @@ -1763,45 +1739,45 @@ skip_check: if (ps->newowner >= 0) G_ClearCameraView(ps); - int j = sprite[ps->i].extra; + int nHealth = sprite[ps->i].extra; if (vm.g_sp->picnum != ATOMICHEALTH) { - if (j > ps->max_player_health && *insptr > 0) + if (nHealth > ps->max_player_health && *insptr > 0) { insptr++; continue; } else { - if (j > 0) - j += *insptr; - if (j > ps->max_player_health && *insptr > 0) - j = ps->max_player_health; + if (nHealth > 0) + nHealth += *insptr; + if (nHealth > ps->max_player_health && *insptr > 0) + nHealth = ps->max_player_health; } } else { - if (j > 0) - j += *insptr; - if (j > (ps->max_player_health<<1)) - j = (ps->max_player_health<<1); + if (nHealth > 0) + nHealth += *insptr; + if (nHealth > (ps->max_player_health<<1)) + nHealth = (ps->max_player_health<<1); } - if (j < 0) j = 0; + if (nHealth < 0) nHealth = 0; if (ud.god == 0) { if (*insptr > 0) { - if ((j - *insptr) < (ps->max_player_health>>2) && - j >= (ps->max_player_health>>2)) + if ((nHealth - *insptr) < (ps->max_player_health>>2) && + nHealth >= (ps->max_player_health>>2)) A_PlaySound(DUKE_GOTHEALTHATLOW,ps->i); - ps->last_extra = j; + ps->last_extra = nHealth; } - sprite[ps->i].extra = j; + sprite[ps->i].extra = nHealth; } } @@ -1813,7 +1789,7 @@ skip_check: AC_COUNT(vm.g_t) = 0; AC_MOVE_ID(vm.g_t) = *insptr++; vm.g_sp->hitag = *insptr++; - if (A_CheckEnemySprite((uspritetype *)vm.g_sp) && vm.g_sp->extra <= 0) // hack + if (A_CheckEnemySprite(vm.g_sp) && vm.g_sp->extra <= 0) // hack continue; if (vm.g_sp->hitag&random_angle) vm.g_sp->ang = krand()&2047; @@ -1822,83 +1798,96 @@ skip_check: case CON_ADDWEAPONVAR: insptr++; { - int const weap = Gv_GetVarX(*insptr++), amount = Gv_GetVarX(*insptr++); - VM_AddWeapon(weap, amount, ps); + int const nWeapon = Gv_GetVarX(*insptr++); + VM_AddWeapon(ps, nWeapon, Gv_GetVarX(*insptr++)); continue; } - case CON_ACTIVATEBYSECTOR: - case CON_OPERATESECTORS: - case CON_OPERATEACTIVATORS: case CON_SETASPECT: + insptr++; + { + int const nRange = Gv_GetVarX(*insptr++); + setaspect(nRange, Gv_GetVarX(*insptr++)); + break; + } + case CON_SSP: insptr++; { - int const var1 = Gv_GetVarX(*insptr++); - int var2; - if (tw == CON_OPERATEACTIVATORS && *insptr == g_iThisActorID) - { - var2 = vm.g_p; - insptr++; - } - else var2 = Gv_GetVarX(*insptr++); + int const nSprite = Gv_GetVarX(*insptr++); + int const nClipType = Gv_GetVarX(*insptr++); - switch (tw) + if (EDUKE32_PREDICT_FALSE((unsigned)nSprite >= MAXSPRITES)) { - case CON_ACTIVATEBYSECTOR: - if (EDUKE32_PREDICT_FALSE((unsigned)var1 >= (unsigned)numsectors)) - { - CON_ERRPRINTF("Invalid sector %d\n", var1); - break; - } - G_ActivateBySector(var1, var2); - break; - case CON_OPERATESECTORS: - if (EDUKE32_PREDICT_FALSE((unsigned)var1 >= (unsigned)numsectors)) - { - CON_ERRPRINTF("Invalid sector %d\n", var1); - break; - } - G_OperateSectors(var1, var2); - break; - case CON_OPERATEACTIVATORS: - if (EDUKE32_PREDICT_FALSE((unsigned)var2>=(unsigned)playerswhenstarted)) - { - CON_ERRPRINTF("Invalid player %d\n", var2); - break; - } - G_OperateActivators(var1, var2); - break; - case CON_SETASPECT: - setaspect(var1, var2); - break; - case CON_SSP: - if (EDUKE32_PREDICT_FALSE((unsigned)var1 >= MAXSPRITES)) - { - CON_ERRPRINTF("Invalid sprite %d\n", var1); - break; - } - A_SetSprite(var1, var2); + CON_ERRPRINTF("Invalid sprite %d\n", nSprite); break; } - continue; + A_SetSprite(nSprite, nClipType); + break; } + case CON_ACTIVATEBYSECTOR: + insptr++; + { + int const nSector = Gv_GetVarX(*insptr++); + int const nSprite = Gv_GetVarX(*insptr++); + + if (EDUKE32_PREDICT_FALSE((unsigned)nSector >= (unsigned)numsectors)) + { + CON_ERRPRINTF("Invalid sector %d\n", nSector); + break; + } + G_ActivateBySector(nSector, nSprite); + break; + } + + case CON_OPERATESECTORS: + insptr++; + { + int const nSector = Gv_GetVarX(*insptr++); + int const nSprite = Gv_GetVarX(*insptr++); + + if (EDUKE32_PREDICT_FALSE((unsigned)nSector >= (unsigned)numsectors)) + { + CON_ERRPRINTF("Invalid sector %d\n", nSector); + break; + } + G_OperateSectors(nSector, nSprite); + break; + } + + case CON_OPERATEACTIVATORS: + insptr++; + { + int const nTag = Gv_GetVarX(*insptr++); + int const nPlayer = (*insptr++ == g_iThisActorID) ? vm.g_p : Gv_GetVarX(*(insptr-1)); + + if (EDUKE32_PREDICT_FALSE((unsigned)nPlayer >= (unsigned)playerswhenstarted)) + { + CON_ERRPRINTF("Invalid player %d\n", nPlayer); + break; + } + G_OperateActivators(nTag, nPlayer); + break; + } + + case CON_CANSEESPR: insptr++; { - int const lVar1 = Gv_GetVarX(*insptr++), lVar2 = Gv_GetVarX(*insptr++); - int res = 0; + int const nSprite1 = Gv_GetVarX(*insptr++); + int const nSprite2 = Gv_GetVarX(*insptr++); + int nResult = 0; - if (EDUKE32_PREDICT_FALSE((unsigned)lVar1 >= MAXSPRITES || (unsigned)lVar2 >= MAXSPRITES)) - CON_ERRPRINTF("Invalid sprite %d\n", (unsigned)lVar1 >= MAXSPRITES ? lVar1 : lVar2); + if (EDUKE32_PREDICT_FALSE((unsigned)nSprite1 >= MAXSPRITES || (unsigned)nSprite2 >= MAXSPRITES)) + CON_ERRPRINTF("Invalid sprite %d\n", (unsigned)nSprite1 >= MAXSPRITES ? nSprite1 : nSprite2); 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); + nResult = cansee(sprite[nSprite1].x, sprite[nSprite1].y, sprite[nSprite1].z, sprite[nSprite1].sectnum, + sprite[nSprite2].x, sprite[nSprite2].y, sprite[nSprite2].z, sprite[nSprite2].sectnum); } - Gv_SetVarX(*insptr++, res); + Gv_SetVarX(*insptr++, nResult); continue; } @@ -1914,7 +1903,7 @@ skip_check: case CON_CHECKACTIVATORMOTION: insptr++; - aGameVars[g_iReturnVarID].val.lValue = G_CheckActivatorMotion(Gv_GetVarX(*insptr++)); + aGameVars[g_iReturnVarID].nValue = G_CheckActivatorMotion(Gv_GetVarX(*insptr++)); continue; case CON_INSERTSPRITEQ: @@ -1925,17 +1914,17 @@ skip_check: case CON_QSTRLEN: insptr++; { - int const i = *insptr++, - j = Gv_GetVarX(*insptr++); + int const nGameVar = *insptr++; + int const nQuote = Gv_GetVarX(*insptr++); - if (EDUKE32_PREDICT_FALSE(ScriptQuotes[j] == NULL)) + if (EDUKE32_PREDICT_FALSE(ScriptQuotes[nQuote] == NULL)) { - CON_ERRPRINTF("null quote %d\n", j); - Gv_SetVarX(i, -1); + CON_ERRPRINTF("null quote %d\n", nQuote); + Gv_SetVarX(nGameVar, -1); continue; } - Gv_SetVarX(i, Bstrlen(ScriptQuotes[j])); + Gv_SetVarX(nGameVar, Bstrlen(ScriptQuotes[nQuote])); continue; } @@ -1974,131 +1963,131 @@ skip_check: case CON_HEADSPRITESTAT: insptr++; { - int const i = *insptr++, - j = Gv_GetVarX(*insptr++); + int const nGameVar = *insptr++; + int const nSprite = Gv_GetVarX(*insptr++); - if (EDUKE32_PREDICT_FALSE((unsigned)j > MAXSTATUS)) + if (EDUKE32_PREDICT_FALSE((unsigned)nSprite > MAXSTATUS)) { - CON_ERRPRINTF("invalid status list %d\n", j); + CON_ERRPRINTF("invalid status list %d\n", nSprite); continue; } - Gv_SetVarX(i,headspritestat[j]); + Gv_SetVarX(nGameVar,headspritestat[nSprite]); continue; } case CON_PREVSPRITESTAT: insptr++; { - int const i = *insptr++, - j = Gv_GetVarX(*insptr++); + int const nGameVar = *insptr++; + int const nSprite = Gv_GetVarX(*insptr++); - if (EDUKE32_PREDICT_FALSE((unsigned)j >= MAXSPRITES)) + if (EDUKE32_PREDICT_FALSE((unsigned)nSprite >= MAXSPRITES)) { - CON_ERRPRINTF("invalid sprite ID %d\n", j); + CON_ERRPRINTF("invalid sprite ID %d\n", nSprite); continue; } - Gv_SetVarX(i, prevspritestat[j]); + Gv_SetVarX(nGameVar, prevspritestat[nSprite]); continue; } case CON_NEXTSPRITESTAT: insptr++; { - int const i = *insptr++, - j = Gv_GetVarX(*insptr++); + int const nGameVar = *insptr++; + int const nSprite = Gv_GetVarX(*insptr++); - if (EDUKE32_PREDICT_FALSE((unsigned)j >= MAXSPRITES)) + if (EDUKE32_PREDICT_FALSE((unsigned)nSprite >= MAXSPRITES)) { - CON_ERRPRINTF("invalid sprite ID %d\n", j); + CON_ERRPRINTF("invalid sprite ID %d\n", nSprite); continue; } - Gv_SetVarX(i,nextspritestat[j]); + Gv_SetVarX(nGameVar, nextspritestat[nSprite]); continue; } case CON_HEADSPRITESECT: insptr++; { - int const i = *insptr++, - j = Gv_GetVarX(*insptr++); + int const nGameVar = *insptr++, + nSprite = Gv_GetVarX(*insptr++); - if (EDUKE32_PREDICT_FALSE((unsigned)j >= (unsigned)numsectors)) + if (EDUKE32_PREDICT_FALSE((unsigned)nSprite >= (unsigned)numsectors)) { - CON_ERRPRINTF("invalid sector %d\n", j); + CON_ERRPRINTF("invalid sector %d\n", nSprite); continue; } - Gv_SetVarX(i,headspritesect[j]); + Gv_SetVarX(nGameVar, headspritesect[nSprite]); continue; } case CON_PREVSPRITESECT: insptr++; { - int const i = *insptr++; - int const j = Gv_GetVarX(*insptr++); + int const nGameVar = *insptr++; + int const nSprite = Gv_GetVarX(*insptr++); - if (EDUKE32_PREDICT_FALSE((unsigned)j >= MAXSPRITES)) + if (EDUKE32_PREDICT_FALSE((unsigned)nSprite >= MAXSPRITES)) { - CON_ERRPRINTF("invalid sprite ID %d\n", j); + CON_ERRPRINTF("invalid sprite ID %d\n", nSprite); continue; } - Gv_SetVarX(i, prevspritesect[j]); + Gv_SetVarX(nGameVar, prevspritesect[nSprite]); continue; } case CON_NEXTSPRITESECT: insptr++; { - int const i=*insptr++; - int const j=Gv_GetVarX(*insptr++); + int const nGameVar = *insptr++; + int const nSprite = Gv_GetVarX(*insptr++); - if (EDUKE32_PREDICT_FALSE((unsigned)j >= MAXSPRITES)) + if (EDUKE32_PREDICT_FALSE((unsigned)nSprite >= MAXSPRITES)) { - CON_ERRPRINTF("invalid sprite ID %d\n", j); + CON_ERRPRINTF("invalid sprite ID %d\n", nSprite); continue; } - Gv_SetVarX(i,nextspritesect[j]); + Gv_SetVarX(nGameVar, nextspritesect[nSprite]); continue; } case CON_GETKEYNAME: insptr++; { - int const i = Gv_GetVarX(*insptr++), - f = Gv_GetVarX(*insptr++), - j = Gv_GetVarX(*insptr++); + int const nQuoteIndex = Gv_GetVarX(*insptr++); + int const nGameFunc = Gv_GetVarX(*insptr++); + int const nFuncPos = Gv_GetVarX(*insptr++); - if (EDUKE32_PREDICT_FALSE((unsigned)i >= MAXQUOTES || ScriptQuotes[i] == NULL)) + if (EDUKE32_PREDICT_FALSE((unsigned)nQuoteIndex >= MAXQUOTES || ScriptQuotes[nQuoteIndex] == NULL)) { - CON_ERRPRINTF("invalid quote ID %d\n", i); + CON_ERRPRINTF("invalid quote ID %d\n", nQuoteIndex); continue; } - else if (EDUKE32_PREDICT_FALSE((unsigned)f >= NUMGAMEFUNCTIONS)) + else if (EDUKE32_PREDICT_FALSE((unsigned)nGameFunc >= NUMGAMEFUNCTIONS)) { - CON_ERRPRINTF("invalid function %d\n", f); + CON_ERRPRINTF("invalid function %d\n", nGameFunc); continue; } else { - if (j < 2) - Bstrcpy(tempbuf, KB_ScanCodeToString(ud.config.KeyboardKeys[f][j])); + if (nFuncPos < 2) + Bstrcpy(tempbuf, KB_ScanCodeToString(ud.config.KeyboardKeys[nGameFunc][nFuncPos])); else { - Bstrcpy(tempbuf, KB_ScanCodeToString(ud.config.KeyboardKeys[f][0])); + Bstrcpy(tempbuf, KB_ScanCodeToString(ud.config.KeyboardKeys[nGameFunc][0])); if (!*tempbuf) - Bstrcpy(tempbuf, KB_ScanCodeToString(ud.config.KeyboardKeys[f][1])); + Bstrcpy(tempbuf, KB_ScanCodeToString(ud.config.KeyboardKeys[nGameFunc][1])); } } if (*tempbuf) - Bstrcpy(ScriptQuotes[i], tempbuf); + Bstrcpy(ScriptQuotes[nQuoteIndex], tempbuf); continue; } @@ -2110,44 +2099,44 @@ skip_check: Gv_GetManyVars(4, params); - const int q1 = params[0], q2 = params[1]; + const int nDestQuote = params[0], nSrcQuote = params[1]; - if (EDUKE32_PREDICT_FALSE((unsigned)q1>=MAXQUOTES || ScriptQuotes[q1] == NULL)) + if (EDUKE32_PREDICT_FALSE((unsigned)nDestQuote>=MAXQUOTES || ScriptQuotes[nDestQuote] == NULL)) { - CON_ERRPRINTF("invalid quote ID %d\n", q1); + CON_ERRPRINTF("invalid quote ID %d\n", nDestQuote); continue; } - if (EDUKE32_PREDICT_FALSE((unsigned)q2>=MAXQUOTES || ScriptQuotes[q2] == NULL)) + if (EDUKE32_PREDICT_FALSE((unsigned)nSrcQuote>=MAXQUOTES || ScriptQuotes[nSrcQuote] == NULL)) { - CON_ERRPRINTF("invalid quote ID %d\n", q2); + CON_ERRPRINTF("invalid quote ID %d\n", nSrcQuote); continue; } - int st = params[2], ln = params[3]; + int nPos = params[2], nLength = params[3]; - if (EDUKE32_PREDICT_FALSE((unsigned)st >= MAXQUOTELEN)) + if (EDUKE32_PREDICT_FALSE((unsigned)nPos >= MAXQUOTELEN)) { - CON_ERRPRINTF("invalid start position %d\n", st); + CON_ERRPRINTF("invalid start position %d\n", nPos); continue; } - if (EDUKE32_PREDICT_FALSE(ln < 0)) + if (EDUKE32_PREDICT_FALSE(nLength < 0)) { - CON_ERRPRINTF("invalid length %d\n", ln); + CON_ERRPRINTF("invalid length %d\n", nLength); continue; } - char *s1 = ScriptQuotes[q1]; - char const * s2 = ScriptQuotes[q2]; + char *pDestQuote = ScriptQuotes[nDestQuote]; + char const * pSrcQuote = ScriptQuotes[nSrcQuote]; - while (*s2 && st--) s2++; - while ((*s1 = *s2) && ln--) + while (*pSrcQuote && nPos--) pSrcQuote++; + while ((*pDestQuote = *pSrcQuote) && nLength--) { - s1++; - s2++; + pDestQuote++; + pSrcQuote++; } - *s1 = 0; + *pDestQuote = 0; continue; } @@ -2289,28 +2278,28 @@ nullquote: case CON_CHANGESPRITESTAT: insptr++; { - int32_t i = Gv_GetVarX(*insptr++); - int32_t j = Gv_GetVarX(*insptr++); + int32_t const nSprite = Gv_GetVarX(*insptr++); + int32_t nStatnum = Gv_GetVarX(*insptr++); - if (EDUKE32_PREDICT_FALSE((unsigned)i >= MAXSPRITES)) + if (EDUKE32_PREDICT_FALSE((unsigned)nSprite >= MAXSPRITES)) { - CON_ERRPRINTF("Invalid sprite: %d\n", i); + CON_ERRPRINTF("Invalid sprite: %d\n", nSprite); continue; } - if (EDUKE32_PREDICT_FALSE((unsigned)j >= MAXSTATUS)) + if (EDUKE32_PREDICT_FALSE((unsigned)nStatnum >= MAXSTATUS)) { - CON_ERRPRINTF("Invalid statnum: %d\n", j); + CON_ERRPRINTF("Invalid statnum: %d\n", nStatnum); continue; } - if (sprite[i].statnum == j) + if (sprite[nSprite].statnum == nStatnum) continue; /* initialize actor data when changing to an actor statnum because there's usually garbage left over from being handled as a hard coded object */ - if (sprite[i].statnum > STAT_ZOMBIEACTOR && (j == STAT_ACTOR || j == STAT_ZOMBIEACTOR)) + if (sprite[nSprite].statnum > STAT_ZOMBIEACTOR && (nStatnum == STAT_ACTOR || nStatnum == STAT_ZOMBIEACTOR)) { - actor_t * const a = &actor[i]; + actor_t * const a = &actor[nSprite]; a->lastvx = 0; a->lastvy = 0; @@ -2319,21 +2308,21 @@ nullquote: a->movflag = 0; a->tempang = 0; a->dispicnum = 0; - T1=T2=T3=T4=T5=T6=T7=T8=T9=0; + Bmemset(&a->t_data, 0, sizeof a->t_data); a->flags = 0; - sprite[i].hitag = 0; + sprite[nSprite].hitag = 0; - if (G_HaveActor(sprite[i].picnum)) + if (G_HaveActor(sprite[nSprite].picnum)) { - const intptr_t *actorptr = g_tile[sprite[i].picnum].execPtr; + const intptr_t *actorptr = g_tile[sprite[nSprite].picnum].execPtr; // offsets AC_ACTION_ID(a->t_data) = actorptr[1]; AC_MOVE_ID(a->t_data) = actorptr[2]; - AC_MOVFLAGS(&sprite[i], &actor[i]) = actorptr[3]; // ai bits (movflags) + AC_MOVFLAGS(&sprite[nSprite], &actor[nSprite]) = actorptr[3]; // ai bits (movflags) } } - changespritestat(i,j); + changespritestat(nSprite, nStatnum); continue; } @@ -2341,22 +2330,23 @@ nullquote: insptr++; // skip command { // from 'level' cheat in game.c (about line 6250) - int32_t volnume=Gv_GetVarX(*insptr++), levnume=Gv_GetVarX(*insptr++); + int const nVolume = Gv_GetVarX(*insptr++); + int const nLevel = Gv_GetVarX(*insptr++); - if (EDUKE32_PREDICT_FALSE((unsigned)volnume >= MAXVOLUMES)) + if (EDUKE32_PREDICT_FALSE((unsigned)nVolume >= MAXVOLUMES)) { - CON_ERRPRINTF("invalid volume (%d)\n", volnume); + CON_ERRPRINTF("invalid volume (%d)\n", nVolume); continue; } - if (EDUKE32_PREDICT_FALSE((unsigned)levnume >= MAXLEVELS)) + if (EDUKE32_PREDICT_FALSE((unsigned)nLevel >= MAXLEVELS)) { - CON_ERRPRINTF("invalid level (%d)\n", levnume); + CON_ERRPRINTF("invalid level (%d)\n", nLevel); continue; } - ud.m_volume_number = ud.volume_number = volnume; - ud.m_level_number = ud.level_number = levnume; + ud.m_volume_number = ud.volume_number = nVolume; + ud.m_level_number = ud.level_number = nLevel; //if (numplayers > 1 && g_netServer) // Net_NewGame(volnume,levnume); //else @@ -2378,7 +2368,9 @@ nullquote: Gv_GetManyVars(5, values); vec2_t const pos = *(vec2_t *)values; - int const tilenum = values[2], shade = values[3], orientation = values[4]; + int const tilenum = values[2]; + int const shade = values[3]; + int const orientation = values[4]; switch (tw) { @@ -2459,18 +2451,18 @@ nullquote: case CON_DRAGPOINT: insptr++; { - int const wallnum = Gv_GetVarX(*insptr++); + int const nWall = Gv_GetVarX(*insptr++); vec2_t n; Gv_GetManyVars(2, (int32_t *)&n); - if (EDUKE32_PREDICT_FALSE((unsigned)wallnum >= (unsigned)numwalls)) + if (EDUKE32_PREDICT_FALSE((unsigned)nWall >= (unsigned)numwalls)) { - CON_ERRPRINTF("Invalid wall %d\n", wallnum); + CON_ERRPRINTF("Invalid wall %d\n", nWall); continue; } - dragpoint(wallnum, n.x, n.y, 0); + dragpoint(nWall, n.x, n.y, 0); continue; } @@ -2553,7 +2545,7 @@ nullquote: { int32_t params[4]; Gv_GetManyVars(4, params); - aGameVars[g_iReturnVarID].val.lValue = nextsectorneighborz(params[0], params[1], params[2], params[3]); + aGameVars[g_iReturnVarID].nValue = nextsectorneighborz(params[0], params[1], params[2], params[3]); } continue; @@ -2571,28 +2563,28 @@ nullquote: case CON_QSPAWNVAR: insptr++; { - int const lIn = Gv_GetVarX(*insptr++); + int const nPicnum = Gv_GetVarX(*insptr++); if (EDUKE32_PREDICT_FALSE((unsigned)vm.g_sp->sectnum >= (unsigned)numsectors)) { CON_ERRPRINTF("Invalid sector %d\n", TrackerCast(vm.g_sp->sectnum)); continue; } - int const j = A_Spawn(vm.g_i, lIn); + + int const nSprite = A_Spawn(vm.g_i, nPicnum); switch (tw) { - case CON_EQSPAWNVAR: - if (j != -1) - A_AddToDeleteQueue(j); - case CON_ESPAWNVAR: - aGameVars[g_iReturnVarID].val.lValue = j; - break; - - case CON_QSPAWNVAR: - if (j != -1) - A_AddToDeleteQueue(j); - break; + case CON_EQSPAWNVAR: + if (nSprite != -1) + A_AddToDeleteQueue(nSprite); + case CON_ESPAWNVAR: + aGameVars[g_iReturnVarID].nValue = nSprite; + break; + case CON_QSPAWNVAR: + if (nSprite != -1) + A_AddToDeleteQueue(nSprite); + break; } continue; } @@ -2610,20 +2602,20 @@ nullquote: continue; } - int const j = A_Spawn(vm.g_i,*insptr++); + int const nSprite = A_Spawn(vm.g_i,*insptr++); switch (tw) { - case CON_EQSPAWN: - if (j != -1) - A_AddToDeleteQueue(j); - case CON_ESPAWN: - aGameVars[g_iReturnVarID].val.lValue = j; - break; - case CON_QSPAWN: - if (j != -1) - A_AddToDeleteQueue(j); - break; + case CON_EQSPAWN: + if (nSprite != -1) + A_AddToDeleteQueue(nSprite); + case CON_ESPAWN: + aGameVars[g_iReturnVarID].nValue = nSprite; + break; + case CON_QSPAWN: + if (nSprite != -1) + A_AddToDeleteQueue(nSprite); + break; } } continue; @@ -2645,10 +2637,10 @@ nullquote: continue; } - int const j = A_ShootWithZvel(vm.g_i,*insptr++,zvel); + int const nSprite = A_ShootWithZvel(vm.g_i,*insptr++,zvel); if (tw != CON_ZSHOOT) - aGameVars[g_iReturnVarID].val.lValue = j; + aGameVars[g_iReturnVarID].nValue = nSprite; } continue; @@ -2667,7 +2659,7 @@ nullquote: j = A_Shoot(vm.g_i, j); if (tw == CON_ESHOOTVAR) - aGameVars[g_iReturnVarID].val.lValue = j; + aGameVars[g_iReturnVarID].nValue = j; continue; } @@ -2688,7 +2680,7 @@ nullquote: j = A_ShootWithZvel(vm.g_i, j, zvel); if (tw == CON_EZSHOOTVAR) - aGameVars[g_iReturnVarID].val.lValue = j; + aGameVars[g_iReturnVarID].nValue = j; continue; } @@ -2705,30 +2697,30 @@ nullquote: case CON_SCREENSOUND: insptr++; { - int const j = Gv_GetVarX(*insptr++); + int const nSound = Gv_GetVarX(*insptr++); - if (EDUKE32_PREDICT_FALSE((unsigned)j>=MAXSOUNDS)) + if (EDUKE32_PREDICT_FALSE((unsigned)nSound>=MAXSOUNDS)) { - CON_ERRPRINTF("Invalid sound %d\n", j); + CON_ERRPRINTF("Invalid sound %d\n", nSound); continue; } switch (tw) { case CON_SOUNDONCEVAR: // falls through to CON_SOUNDVAR - if (!S_CheckSoundPlaying(vm.g_i, j)) + if (!S_CheckSoundPlaying(vm.g_i, nSound)) case CON_SOUNDVAR: - A_PlaySound((int16_t)j, vm.g_i); + A_PlaySound((int16_t)nSound, vm.g_i); continue; case CON_GLOBALSOUNDVAR: - A_PlaySound((int16_t)j, g_player[screenpeek].ps->i); + A_PlaySound((int16_t)nSound, g_player[screenpeek].ps->i); continue; case CON_STOPSOUNDVAR: - if (S_CheckSoundPlaying(vm.g_i, j)) - S_StopSound((int16_t)j); + if (S_CheckSoundPlaying(vm.g_i, nSound)) + S_StopSound((int16_t)nSound); continue; case CON_SCREENSOUND: - A_PlaySound(j, -1); + A_PlaySound(nSound, -1); continue; } } @@ -2738,23 +2730,23 @@ nullquote: case CON_IFCUTSCENE: insptr++; { - int const j = Gv_GetVarX(*insptr++); + int const nQuote = Gv_GetVarX(*insptr++); - if (EDUKE32_PREDICT_FALSE((unsigned)j >= MAXQUOTES || ScriptQuotes[j] == NULL)) + if (EDUKE32_PREDICT_FALSE((unsigned)nQuote >= MAXQUOTES || ScriptQuotes[nQuote] == NULL)) { - CON_ERRPRINTF("invalid quote ID %d for anim!\n", j); + CON_ERRPRINTF("invalid quote ID %d for anim!\n", nQuote); continue; } if (tw == CON_IFCUTSCENE) { insptr--; - VM_CONDITIONAL(g_animPtr == Anim_Find(ScriptQuotes[j])); + VM_CONDITIONAL(g_animPtr == Anim_Find(ScriptQuotes[nQuote])); continue; } tw = ps->palette; - Anim_Play(ScriptQuotes[j]); + Anim_Play(ScriptQuotes[nQuote]); P_SetGamePalette(ps, tw, 2 + 16); continue; } @@ -2775,7 +2767,7 @@ nullquote: case CON_SAVEGAMEVAR: case CON_READGAMEVAR: { - int32_t i=0; + int32_t nValue = 0; insptr++; if (ud.config.scripthandle < 0) { @@ -2784,14 +2776,14 @@ nullquote: } switch (tw) { - case CON_SAVEGAMEVAR: - i=Gv_GetVarX(*insptr); - 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); - Gv_SetVarX(*insptr++, i); - break; + case CON_SAVEGAMEVAR: + nValue = Gv_GetVarX(*insptr); + SCRIPT_PutNumber(ud.config.scripthandle, "Gamevars", aGameVars[*insptr++].szLabel, nValue, FALSE, FALSE); + break; + case CON_READGAMEVAR: + SCRIPT_GetNumber(ud.config.scripthandle, "Gamevars", aGameVars[*insptr].szLabel, &nValue); + Gv_SetVarX(*insptr++, nValue); + break; } continue; } @@ -2835,31 +2827,33 @@ nullquote: Gv_GetManyVars(8, params); - vec3_t c = *(vec3_t *)params; - int const a = params[3], tilenum = params[4], shade = params[5]; - int const pal = params[6]; - int orientation = params[7] & (ROTATESPRITE_MAX-1); + vec3_t pos = *(vec3_t *)params; + int const ang = params[3]; + int const tilenum = params[4]; + int const shade = params[5]; + int const pal = params[6]; + int orientation = params[7] & (ROTATESPRITE_MAX - 1); int32_t alpha = (tw == CON_ROTATESPRITEA) ? Gv_GetVarX(*insptr++) : 0; vec2_t scrn[2]; - Gv_GetManyVars(4, (int32_t *)scrn); + Gv_GetManyVars(4, (int32_t *) scrn); if (tw != CON_ROTATESPRITE16 && !(orientation&ROTATESPRITE_FULL16)) { - c.x<<=16; - c.y<<=16; + pos.x <<= 16; + pos.y <<= 16; } - if (EDUKE32_PREDICT_FALSE((unsigned)tilenum >= MAXTILES)) + if (EDUKE32_PREDICT_FALSE((unsigned) tilenum >= MAXTILES)) { CON_ERRPRINTF("invalid tilenum %d\n", tilenum); continue; } - if (EDUKE32_PREDICT_FALSE(c.x < -(320<<16) || c.x >= (640<<16) || c.y < -(200<<16) || c.y >= (400<<16))) + if (EDUKE32_PREDICT_FALSE(pos.x < -(320<<16) || pos.x >= (640<<16) || pos.y < -(200<<16) || pos.y >= (400<<16))) { - CON_ERRPRINTF("invalid coordinates: %d, %d\n", c.x, c.y); + CON_ERRPRINTF("invalid coordinates: %d, %d\n", pos.x, pos.y); continue; } @@ -2867,7 +2861,7 @@ nullquote: NEG_ALPHA_TO_BLEND(alpha, blendidx, orientation); - rotatesprite_(c.x, c.y, c.z, a, tilenum, shade, pal, 2 | orientation, alpha, blendidx, + rotatesprite_(pos.x, pos.y, pos.z, ang, tilenum, shade, pal, 2 | orientation, alpha, blendidx, scrn[0].x, scrn[0].y, scrn[1].x, scrn[1].y); continue; } @@ -2877,18 +2871,17 @@ nullquote: insptr++; { int32_t params[11]; - Gv_GetManyVars(11, params); - int const tilenum = params[0]; - int const x = params[1], y = params[2], q = params[3]; - int const shade = params[4], pal = params[5]; - int const orientation = params[6] & (ROTATESPRITE_MAX - 1); - - vec2_t const b1 = *(vec2_t *)¶ms[7]; - vec2_t const b2 = *(vec2_t *)¶ms[9]; - - int32_t z = (tw == CON_GAMETEXTZ) ? Gv_GetVarX(*insptr++) : 65536; + int const tilenum = params[0]; + vec2_t const pos = { params[1], params[2] }; + int const nQuote = params[3]; + int const shade = params[4]; + int const pal = params[5]; + int const orientation = params[6] & (ROTATESPRITE_MAX - 1); + vec2_t const bound1 = *(vec2_t *)¶ms[7]; + vec2_t const bound2 = *(vec2_t *)¶ms[9]; + int32_t z = (tw == CON_GAMETEXTZ) ? Gv_GetVarX(*insptr++) : 65536; if (EDUKE32_PREDICT_FALSE(tilenum < 0 || tilenum + 255 >= MAXTILES)) { @@ -2896,13 +2889,13 @@ nullquote: continue; } - if (EDUKE32_PREDICT_FALSE((unsigned)q >= MAXQUOTES || ScriptQuotes[q] == NULL)) + if (EDUKE32_PREDICT_FALSE((unsigned)nQuote >= MAXQUOTES || ScriptQuotes[nQuote] == NULL)) { - CON_ERRPRINTF("invalid quote ID %d\n", q); + CON_ERRPRINTF("invalid quote ID %d\n", nQuote); continue; } - G_PrintGameText(0, tilenum, x >> 1, y, ScriptQuotes[q], shade, pal, orientation, b1.x, b1.y, b2.x, b2.y, z, 0); + G_PrintGameText(0, tilenum, pos.x >> 1, pos.y, ScriptQuotes[nQuote], shade, pal, orientation, bound1.x, bound1.y, bound2.x, bound2.y, z, 0); continue; } @@ -2913,15 +2906,15 @@ nullquote: int32_t params[11]; Gv_GetManyVars(11, params); - int const tilenum = params[0]; - int const x = params[1], y = params[2], q = params[3]; - int const shade = params[4], pal = params[5]; - int const orientation = params[6] & (ROTATESPRITE_MAX - 1); - - vec2_t const b1 = *(vec2_t *) ¶ms[7]; - vec2_t const b2 = *(vec2_t *) ¶ms[9]; - - int32_t z = (tw == CON_DIGITALNUMBERZ) ? Gv_GetVarX(*insptr++) : 65536; + int const tilenum = params[0]; + vec2_t const pos = { params[1], params[2] }; + int const q = params[3]; + int const shade = params[4]; + int const pal = params[5]; + int const orientation = params[6] & (ROTATESPRITE_MAX - 1); + vec2_t const bound1 = *(vec2_t *)¶ms[7]; + vec2_t const bound2 = *(vec2_t *)¶ms[9]; + int32_t nZoom = (tw == CON_DIGITALNUMBERZ) ? Gv_GetVarX(*insptr++) : 65536; // NOTE: '-' not taken into account, but we have rotatesprite() bound check now anyway if (EDUKE32_PREDICT_FALSE(tilenum < 0 || tilenum+9 >= MAXTILES)) @@ -2930,7 +2923,7 @@ nullquote: continue; } - G_DrawTXDigiNumZ(tilenum, x, y, q, shade, pal, orientation, b1.x, b1.y, b2.x, b2.y, z); + G_DrawTXDigiNumZ(tilenum, pos.x, pos.y, q, shade, pal, orientation, bound1.x, bound1.y, bound2.x, bound2.y, nZoom); continue; } @@ -2938,19 +2931,19 @@ nullquote: insptr++; { int32_t params[5]; - Gv_GetManyVars(5, params); - int const x = params[0], y = params[1], q = params[2]; + vec2_t const pos = { params[0], params[1] }; + int const nQuote = params[2]; int const shade = params[3], pal = params[4]; - if (EDUKE32_PREDICT_FALSE((unsigned)q >= MAXQUOTES || ScriptQuotes[q] == NULL)) + if (EDUKE32_PREDICT_FALSE((unsigned)nQuote >= MAXQUOTES || ScriptQuotes[nQuote] == NULL)) { - CON_ERRPRINTF("invalid quote ID %d\n", q); + CON_ERRPRINTF("invalid quote ID %d\n", nQuote); continue; } - minitextshade(x,y,ScriptQuotes[q],shade,pal, 2+8+16); + minitextshade(pos.x, pos.y, ScriptQuotes[nQuote], shade, pal, 2+8+16); continue; } @@ -2958,20 +2951,21 @@ nullquote: insptr++; { int32_t params[20]; - Gv_GetManyVars(20, params); - int const tilenum = params[0]; - vec3_t const v = *(vec3_t *)¶ms[1]; - int const blockangle = params[4], charangle = params[5]; - int const q = params[6]; - int const shade = params[7], pal = params[8]; - int const orientation = params[9] & (ROTATESPRITE_MAX - 1); - int const alpha = params[10]; - int const xspace = params[11], yline = params[12]; - int const xbetween = params[13], ybetween = params[14]; - int const f = params[15]; - vec2_t const scrn[2] = { *(vec2_t *)¶ms[16], *(vec2_t *)¶ms[18] } ; + int const tilenum = params[0]; + vec3_t const v = *(vec3_t *)¶ms[1]; + int const blockangle = params[4]; + int const charangle = params[5]; + int const nQuote = params[6]; + int const shade = params[7]; + int const pal = params[8]; + int const orientation = params[9] & (ROTATESPRITE_MAX - 1); + int const alpha = params[10]; + vec2_t const spacing = { params[11], params[12] }; + vec2_t const between = { params[13], params[14] }; + int const f = params[15]; + vec2_t const scrn[2] = { *(vec2_t *)¶ms[16], *(vec2_t *)¶ms[18] }; if (EDUKE32_PREDICT_FALSE(tilenum < 0 || tilenum+255 >= MAXTILES)) { @@ -2979,14 +2973,14 @@ nullquote: continue; } - if (EDUKE32_PREDICT_FALSE((unsigned)q >= MAXQUOTES || ScriptQuotes[q] == NULL)) + if (EDUKE32_PREDICT_FALSE((unsigned)nQuote >= MAXQUOTES || ScriptQuotes[nQuote] == NULL)) { - CON_ERRPRINTF("invalid quote ID %d\n", q); + CON_ERRPRINTF("invalid quote ID %d\n", nQuote); continue; } - G_ScreenText(tilenum, v.x, v.y, v.z, blockangle, charangle, ScriptQuotes[q], shade, pal, 2 | orientation, - alpha, xspace, yline, xbetween, ybetween, f, scrn[0].x, scrn[0].y, scrn[1].x, scrn[1].y); + G_ScreenText(tilenum, v.x, v.y, v.z, blockangle, charangle, ScriptQuotes[nQuote], shade, pal, 2 | orientation, + alpha, spacing.x, spacing.y, between.x, between.y, f, scrn[0].x, scrn[0].y, scrn[1].x, scrn[1].y); continue; } @@ -2999,13 +2993,15 @@ nullquote: insptr++; { vec3_t vect; - Gv_GetManyVars(3, (int32_t *)&vect); - int const sectnum = Gv_GetVarX(*insptr++); - int const ceilzvar = *insptr++, ceilhitvar = *insptr++, florzvar = *insptr++, florhitvar = *insptr++; - int const walldist = Gv_GetVarX(*insptr++), clipmask = Gv_GetVarX(*insptr++); - int32_t ceilz, ceilhit, florz, florhit; + int const sectnum = Gv_GetVarX(*insptr++); + int const ceilzvar = *insptr++; + int const ceilhitvar = *insptr++; + int const florzvar = *insptr++; + int const florhitvar = *insptr++; + int const walldist = Gv_GetVarX(*insptr++); + int const clipmask = Gv_GetVarX(*insptr++); if (EDUKE32_PREDICT_FALSE((unsigned)sectnum >= (unsigned)numsectors)) { @@ -3013,6 +3009,8 @@ nullquote: continue; } + int32_t ceilz, ceilhit, florz, florhit; + getzrange(&vect, sectnum, &ceilz, &ceilhit, &florz, &florhit, walldist, clipmask); Gv_SetVarX(ceilzvar, ceilz); Gv_SetVarX(ceilhitvar, ceilhit); @@ -3063,21 +3061,21 @@ nullquote: insptr++; { vec3_t vec[2]; - Gv_GetManyVars(6, (int32_t *)vec); vec2_t vec2[2]; - Gv_GetManyVars(4, (int32_t *)vec2); - int32_t intxvar=*insptr++, intyvar=*insptr++, intzvar=*insptr++, retvar=*insptr++, ret; - - vec3_t in; - - if (tw==CON_LINEINTERSECT) - ret = lintersect(vec[0].x, vec[0].y, vec[0].z, vec[1].x, vec[1].y, vec[1].z, vec2[0].x, vec2[0].y, vec2[1].x, vec2[1].y, &in.x, &in.y, &in.z); - else - ret = rayintersect(vec[0].x, vec[0].y, vec[0].z, vec[1].x, vec[1].y, vec[1].z, vec2[0].x, vec2[0].y, vec2[1].x, vec2[1].y, &in.x, &in.y, &in.z); + int const intxvar = *insptr++; + int const intyvar = *insptr++; + int const intzvar = *insptr++; + int const retvar = *insptr++; + vec3_t in; + int ret = (tw == CON_LINEINTERSECT) + ? lintersect(vec[0].x, vec[0].y, vec[0].z, vec[1].x, vec[1].y, vec[1].z, vec2[0].x, vec2[0].y, + vec2[1].x, vec2[1].y, &in.x, &in.y, &in.z) + : rayintersect(vec[0].x, vec[0].y, vec[0].z, vec[1].x, vec[1].y, vec[1].z, vec2[0].x, vec2[0].y, + vec2[1].x, vec2[1].y, &in.x, &in.y, &in.z); Gv_SetVarX(retvar, ret); @@ -3099,7 +3097,9 @@ nullquote: int32_t w, f, c; } vec3dist_t; - int const retvar = *insptr++, xvar = *insptr++, yvar = *insptr++; + int const retvar = *insptr++; + int const xvar = *insptr++; + int const yvar = *insptr++; insptr -= 2; @@ -3115,7 +3115,7 @@ nullquote: Gv_GetManyVars(3, (int32_t *)&dist); int const clipmask = Gv_GetVarX(*insptr++); - int16_t sectnum = Gv_GetVarX(sectnumvar); + int16_t sectnum = Gv_GetVarX(sectnumvar); if (EDUKE32_PREDICT_FALSE((unsigned)sectnum >= (unsigned)numsectors)) { @@ -3143,8 +3143,13 @@ nullquote: vec3_t v; Gv_GetManyVars(3, (int32_t *) &v); - int const hitsectvar = *insptr++, hitwallvar = *insptr++, hitspritevar = *insptr++; - int const hitxvar = *insptr++, hityvar = *insptr++, hitzvar = *insptr++, cliptype = Gv_GetVarX(*insptr++); + int const hitsectvar = *insptr++; + int const hitwallvar = *insptr++; + int const hitspritevar = *insptr++; + int const hitxvar = *insptr++; + int const hityvar = *insptr++; + int const hitzvar = *insptr++; + int const cliptype = Gv_GetVarX(*insptr++); if (EDUKE32_PREDICT_FALSE((unsigned)sectnum >= (unsigned)numsectors)) { @@ -3170,7 +3175,7 @@ nullquote: vec3_t vec1; Gv_GetManyVars(3, (int32_t *) &vec1); - int32_t sect1=Gv_GetVarX(*insptr++); + int const sect1 = Gv_GetVarX(*insptr++); vec3_t vec2; Gv_GetManyVars(3, (int32_t *) &vec2); @@ -3194,9 +3199,9 @@ nullquote: Gv_GetManyVars(4, (int32_t *)point); int const angle = Gv_GetVarX(*insptr++); - int const x2var = *insptr++, y2var = *insptr++; - - vec2_t result; + int const x2var = *insptr++; + int const y2var = *insptr++; + vec2_t result; rotatepoint(point[0], point[1], angle, &result); @@ -3218,18 +3223,24 @@ nullquote: vec3_t point; Gv_GetManyVars(3, (int32_t *)&point); - int const sectnum=Gv_GetVarX(*insptr++), ang=Gv_GetVarX(*insptr++); - int const neartagsectorvar=*insptr++, neartagwallvar=*insptr++, neartagspritevar=*insptr++, neartaghitdistvar=*insptr++; - int const neartagrange=Gv_GetVarX(*insptr++), tagsearch=Gv_GetVarX(*insptr++); - - int16_t neartagsector, neartagwall, neartagsprite; - int32_t neartaghitdist; + int const sectnum = Gv_GetVarX(*insptr++); + int const ang = Gv_GetVarX(*insptr++); + int const neartagsectorvar = *insptr++; + int const neartagwallvar = *insptr++; + int const neartagspritevar = *insptr++; + int const neartaghitdistvar = *insptr++; + int const neartagrange = Gv_GetVarX(*insptr++); + int const tagsearch = Gv_GetVarX(*insptr++); if (EDUKE32_PREDICT_FALSE((unsigned)sectnum >= (unsigned)numsectors)) { CON_ERRPRINTF("Invalid sector %d\n", sectnum); continue; } + + int16_t neartagsector, neartagwall, neartagsprite; + int32_t neartaghitdist; + neartag(point.x, point.y, point.z, sectnum, ang, &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, neartagrange, tagsearch, NULL); @@ -3296,7 +3307,7 @@ nullquote: insptr++; { int const sectnum = Gv_GetVarX(*insptr++); - vec2_t vect; + vec2_t vect; Gv_GetManyVars(2, (int32_t *)&vect); if (EDUKE32_PREDICT_FALSE((unsigned)sectnum >= (unsigned)numsectors)) @@ -3316,27 +3327,27 @@ nullquote: insptr++; { vec2_t vect = { 0, 0 }; - Gv_GetManyVars(2, (int32_t *) &vect); - int const var=*insptr++; - int16_t w = sprite[vm.g_i].sectnum; + Gv_GetManyVars(2, (int32_t *)&vect); + int const var = *insptr++; + int16_t sectnum = sprite[vm.g_i].sectnum; - updatesector(vect.x, vect.y, &w); + updatesector(vect.x, vect.y, §num); - Gv_SetVarX(var, w); + Gv_SetVarX(var, sectnum); continue; } case CON_UPDATESECTORZ: insptr++; { - vec3_t vect ={ 0, 0, 0 }; - Gv_GetManyVars(3, (int32_t *) &vect); - int const var=*insptr++; - int16_t w = sprite[vm.g_i].sectnum; + vec3_t vect = { 0, 0, 0 }; + Gv_GetManyVars(3, (int32_t *)&vect); + int const var = *insptr++; + int16_t sectnum = sprite[vm.g_i].sectnum; - updatesectorz(vect.x, vect.y, vect.z, &w); + updatesectorz(vect.x, vect.y, vect.z, §num); - Gv_SetVarX(var, w); + Gv_SetVarX(var, sectnum); continue; } @@ -3434,11 +3445,12 @@ nullquote: if (tw == CON_SAVE || ud.savegame[g_lastSaveSlot][0] == 0) { - time_t curtime = time(NULL); + time_t curtime = time(NULL); struct tm *timeptr = localtime(&curtime); - Bsnprintf(ud.savegame[g_lastSaveSlot], sizeof(ud.savegame[g_lastSaveSlot]), "Auto %.4d%.2d%.2d %.2d%.2d%.2d\n", - timeptr->tm_year + 1900, timeptr->tm_mon + 1, timeptr->tm_mday, - timeptr->tm_hour, timeptr->tm_min, timeptr->tm_sec); + + Bsnprintf(ud.savegame[g_lastSaveSlot], sizeof(ud.savegame[g_lastSaveSlot]), + "Auto %.4d%.2d%.2d %.2d%.2d%.2d\n", timeptr->tm_year + 1900, timeptr->tm_mon + 1, timeptr->tm_mday, + timeptr->tm_hour, timeptr->tm_min, timeptr->tm_sec); } OSD_Printf("Saving to slot %d\n",g_lastSaveSlot); @@ -3476,7 +3488,8 @@ nullquote: continue; case CON_IFONWATER: - VM_CONDITIONAL(sector[vm.g_sp->sectnum].lotag == ST_1_ABOVE_WATER && klabs(vm.g_sp->z-sector[vm.g_sp->sectnum].floorz) < (32<<8)); + VM_CONDITIONAL(sector[vm.g_sp->sectnum].lotag == ST_1_ABOVE_WATER && + klabs(vm.g_sp->z - sector[vm.g_sp->sectnum].floorz) < (32 << 8)); continue; case CON_IFINWATER: @@ -3560,9 +3573,9 @@ nullquote: case CON_IFP: { - int const l = *(++insptr); - int j = 0; - int const s = sprite[ps->i].xvel; + int const l = *(++insptr); + int j = 0; + int const s = sprite[ps->i].xvel; int const bits = g_player[vm.g_p].sync->bits; if (((l & pducking) && ps->on_ground && TEST_SYNC_KEY(bits, SK_CROUCH)) || @@ -3725,7 +3738,7 @@ nullquote: continue; case CON_IFRESPAWN: - if (A_CheckEnemySprite((uspritetype *)vm.g_sp)) VM_CONDITIONAL(ud.respawn_monsters) + if (A_CheckEnemySprite(vm.g_sp)) VM_CONDITIONAL(ud.respawn_monsters) else if (A_CheckInventorySprite(vm.g_sp)) VM_CONDITIONAL(ud.respawn_inventory) else VM_CONDITIONAL(ud.respawn_items) continue; @@ -3749,9 +3762,10 @@ nullquote: } else { - uint8_t f=*insptr++, r=*insptr++, g=*insptr++, b=*insptr++; - - P_PalFrom(ps, f, r,g,b); + palette_t const pal = { (uint8_t) * (insptr + 1), (uint8_t) * (insptr + 2), (uint8_t) * (insptr + 3), + (uint8_t) * (insptr) }; + insptr += 4; + P_PalFrom(ps, pal.f, pal.r, pal.g, pal.b); } continue; @@ -3764,10 +3778,12 @@ nullquote: case CON_QSPRINTF: insptr++; { - int32_t dq = Gv_GetVarX(*insptr++), sq = Gv_GetVarX(*insptr++); - if (EDUKE32_PREDICT_FALSE(ScriptQuotes[sq] == NULL || ScriptQuotes[dq] == NULL)) + int const nDestQuote = Gv_GetVarX(*insptr++); + int const nSrcQuote = Gv_GetVarX(*insptr++); + + if (EDUKE32_PREDICT_FALSE(ScriptQuotes[nSrcQuote] == NULL || ScriptQuotes[nDestQuote] == NULL)) { - CON_ERRPRINTF("null quote %d\n", ScriptQuotes[sq] ? dq : sq); + CON_ERRPRINTF("null quote %d\n", ScriptQuotes[nSrcQuote] ? nDestQuote : nSrcQuote); while ((*insptr & VM_INSTMASK) != CON_NULLOP) Gv_GetVarX(*insptr++); @@ -3776,79 +3792,78 @@ nullquote: continue; } + int32_t arg[32], i = 0, j = 0, k = 0, numargs; + int const nQuoteLen = Bstrlen(ScriptQuotes[nSrcQuote]); + char tempbuf[MAXQUOTELEN]; + + while ((*insptr & VM_INSTMASK) != CON_NULLOP && i < 32) + arg[i++] = Gv_GetVarX(*insptr++); + + numargs = i; + + insptr++; // skip the NOP + + i = 0; + + do { - int32_t arg[32], i = 0, j = 0, k = 0, numargs; - int const len = Bstrlen(ScriptQuotes[sq]); - char tempbuf[MAXQUOTELEN]; + while (k < nQuoteLen && j < MAXQUOTELEN && ScriptQuotes[nSrcQuote][k] != '%') + tempbuf[j++] = ScriptQuotes[nSrcQuote][k++]; - while ((*insptr & VM_INSTMASK) != CON_NULLOP && i < 32) - arg[i++] = Gv_GetVarX(*insptr++); - numargs = i; - - insptr++; // skip the NOP - - i = 0; - - do + if (ScriptQuotes[nSrcQuote][k] == '%') { - while (k < len && j < MAXQUOTELEN && ScriptQuotes[sq][k] != '%') - tempbuf[j++] = ScriptQuotes[sq][k++]; - - if (ScriptQuotes[sq][k] == '%') + k++; + switch (ScriptQuotes[nSrcQuote][k]) { - k++; - switch (ScriptQuotes[sq][k]) + case 'l': + if (ScriptQuotes[nSrcQuote][k+1] != 'd') { - case 'l': - if (ScriptQuotes[sq][k+1] != 'd') - { - // write the % and l - tempbuf[j++] = ScriptQuotes[sq][k-1]; - tempbuf[j++] = ScriptQuotes[sq][k++]; - break; - } - k++; - case 'd': - { - if (i >= numargs) - goto finish_qsprintf; - - char buf[16]; - Bsprintf(buf, "%d", arg[i++]); - - int const ii = Bstrlen(buf); - Bmemcpy(&tempbuf[j], buf, ii); - j += ii; - k++; - } - break; - - case 's': - { - if (i >= numargs) - goto finish_qsprintf; - - int const ii = Bstrlen(ScriptQuotes[arg[i]]); - - Bmemcpy(&tempbuf[j], ScriptQuotes[arg[i]], ii); - j += ii; - i++; - k++; - } - break; - - default: - tempbuf[j++] = ScriptQuotes[sq][k-1]; + // write the % and l + tempbuf[j++] = ScriptQuotes[nSrcQuote][k-1]; + tempbuf[j++] = ScriptQuotes[nSrcQuote][k++]; break; } + k++; + case 'd': + { + if (i >= numargs) + goto finish_qsprintf; + + char buf[16]; + Bsprintf(buf, "%d", arg[i++]); + + int const ii = Bstrlen(buf); + Bmemcpy(&tempbuf[j], buf, ii); + j += ii; + k++; + } + break; + + case 's': + { + if (i >= numargs) + goto finish_qsprintf; + + int const ii = Bstrlen(ScriptQuotes[arg[i]]); + + Bmemcpy(&tempbuf[j], ScriptQuotes[arg[i]], ii); + j += ii; + i++; + k++; + } + break; + + default: + tempbuf[j++] = ScriptQuotes[nSrcQuote][k-1]; + break; } } - while (k < len && j < MAXQUOTELEN); -finish_qsprintf: - tempbuf[j] = '\0'; - Bstrncpyz(ScriptQuotes[dq], tempbuf, MAXQUOTELEN); - continue; } + while (k < nQuoteLen && j < MAXQUOTELEN); +finish_qsprintf: + tempbuf[j] = '\0'; + Bstrncpyz(ScriptQuotes[nDestQuote], tempbuf, MAXQUOTELEN); + continue; } case CON_ADDLOG: @@ -3933,16 +3948,16 @@ finish_qsprintf: Bsprintf(szBuf,"CONLOGVAR: L=%d %s ",g_errorLineNum, aGameVars[lVarID].szLabel); strcpy(g_szBuf,szBuf); - if (aGameVars[lVarID].dwFlags & GAMEVAR_READONLY) + if (aGameVars[lVarID].nFlags & GAMEVAR_READONLY) { Bsprintf(szBuf," (read-only)"); strcat(g_szBuf,szBuf); } - if (aGameVars[lVarID].dwFlags & GAMEVAR_PERPLAYER) + if (aGameVars[lVarID].nFlags & GAMEVAR_PERPLAYER) { Bsprintf(szBuf," (Per Player. Player=%d)",vm.g_p); } - else if (aGameVars[lVarID].dwFlags & GAMEVAR_PERACTOR) + else if (aGameVars[lVarID].nFlags & GAMEVAR_PERACTOR) { Bsprintf(szBuf," (Per Actor. Actor=%d)",vm.g_i); } @@ -3962,12 +3977,13 @@ finish_qsprintf: insptr++; { tw = *insptr++; - int const lLabelID=*insptr++, lVar2=*insptr++; - register int32_t const iSector = (tw != g_iThisActorID) ? Gv_GetVarX(tw) : sprite[vm.g_i].sectnum; - register int32_t const iSet = Gv_GetVarX(lVar2); + int const nLabel = *insptr++; + int const lVar2 = *insptr++; + register int32_t const nSector = (tw != g_iThisActorID) ? Gv_GetVarX(tw) : sprite[vm.g_i].sectnum; + register int32_t const nSet = Gv_GetVarX(lVar2); - VM_SetSector(iSector, lLabelID, iSet); + VM_SetSector(nSector, nLabel, nSet); continue; } @@ -3975,11 +3991,12 @@ finish_qsprintf: insptr++; { tw = *insptr++; - int const lLabelID=*insptr++, lVar2=*insptr++; - register int32_t const iSector = (tw != g_iThisActorID) ? Gv_GetVarX(tw) : sprite[vm.g_i].sectnum; + int const nLabel = *insptr++; + int const lVar2 = *insptr++; + register int32_t const nSector = (tw != g_iThisActorID) ? Gv_GetVarX(tw) : sprite[vm.g_i].sectnum; - Gv_SetVarX(lVar2, VM_GetSector(iSector, lLabelID)); + Gv_SetVarX(lVar2, VM_GetSector(nSector, nLabel)); continue; } @@ -4003,54 +4020,58 @@ finish_qsprintf: // that is of into // -1 for none found // - int const lType=*insptr++, lMaxDist=*insptr++, lVarID=*insptr++; - int32_t lFound=-1, j, k = MAXSTATUS-1; + int const nType = *insptr++; + int const nMaxDist = *insptr++; + int const nGameVar = *insptr++; + int lFound = -1; + int nStatnum = MAXSTATUS - 1; + int nSprite; if (tw == CON_FINDNEARACTOR || tw == CON_FINDNEARACTOR3D) - k = 1; + nStatnum = 1; if (tw==CON_FINDNEARSPRITE3D || tw==CON_FINDNEARACTOR3D) { do { - j=headspritestat[k]; // all sprites - while (j>=0) + nSprite=headspritestat[nStatnum]; // all sprites + while (nSprite>=0) { - if (sprite[j].picnum == lType && j != vm.g_i && dist(&sprite[vm.g_i], &sprite[j]) < lMaxDist) + if (sprite[nSprite].picnum == nType && nSprite != vm.g_i && dist(&sprite[vm.g_i], &sprite[nSprite]) < nMaxDist) { - lFound=j; - j = MAXSPRITES; + lFound=nSprite; + nSprite = MAXSPRITES; break; } - j = nextspritestat[j]; + nSprite = nextspritestat[nSprite]; } - if (j == MAXSPRITES || tw == CON_FINDNEARACTOR3D) + if (nSprite == MAXSPRITES || tw == CON_FINDNEARACTOR3D) break; } - while (k--); - Gv_SetVarX(lVarID, lFound); + while (nStatnum--); + Gv_SetVarX(nGameVar, lFound); continue; } do { - j=headspritestat[k]; // all sprites - while (j>=0) + nSprite=headspritestat[nStatnum]; // all sprites + while (nSprite>=0) { - if (sprite[j].picnum == lType && j != vm.g_i && ldist(&sprite[vm.g_i], &sprite[j]) < lMaxDist) + if (sprite[nSprite].picnum == nType && nSprite != vm.g_i && ldist(&sprite[vm.g_i], &sprite[nSprite]) < nMaxDist) { - lFound=j; - j = MAXSPRITES; + lFound=nSprite; + nSprite = MAXSPRITES; break; } - j = nextspritestat[j]; + nSprite = nextspritestat[nSprite]; } - if (j == MAXSPRITES || tw == CON_FINDNEARACTOR) + if (nSprite == MAXSPRITES || tw == CON_FINDNEARACTOR) break; } - while (k--); - Gv_SetVarX(lVarID, lFound); + while (nStatnum--); + Gv_SetVarX(nGameVar, lFound); continue; } @@ -4065,56 +4086,60 @@ finish_qsprintf: // that is of into // -1 for none found // - int const lType=*insptr++, lMaxDist=Gv_GetVarX(*insptr++), lVarID=*insptr++; - int32_t lFound=-1, j, k = 1; + int const nPicnum = *insptr++; + int const nMaxDist = Gv_GetVarX(*insptr++); + int const nGameVar = *insptr++; + int lFound = -1; + int nStatnum = 1; + int nSprite; if (tw == CON_FINDNEARSPRITEVAR || tw == CON_FINDNEARSPRITE3DVAR) - k = MAXSTATUS-1; + nStatnum = MAXSTATUS-1; if (tw==CON_FINDNEARACTOR3DVAR || tw==CON_FINDNEARSPRITE3DVAR) { do { - j=headspritestat[k]; // all sprites + nSprite=headspritestat[nStatnum]; // all sprites - while (j >= 0) + while (nSprite >= 0) { - if (sprite[j].picnum == lType && j != vm.g_i && dist(&sprite[vm.g_i], &sprite[j]) < lMaxDist) + if (sprite[nSprite].picnum == nPicnum && nSprite != vm.g_i && dist(&sprite[vm.g_i], &sprite[nSprite]) < nMaxDist) { - lFound=j; - j = MAXSPRITES; + lFound=nSprite; + nSprite = MAXSPRITES; break; } - j = nextspritestat[j]; + nSprite = nextspritestat[nSprite]; } - if (j == MAXSPRITES || tw==CON_FINDNEARACTOR3DVAR) + if (nSprite == MAXSPRITES || tw==CON_FINDNEARACTOR3DVAR) break; } - while (k--); - Gv_SetVarX(lVarID, lFound); + while (nStatnum--); + Gv_SetVarX(nGameVar, lFound); continue; } do { - j=headspritestat[k]; // all sprites + nSprite=headspritestat[nStatnum]; // all sprites - while (j >= 0) + while (nSprite >= 0) { - if (sprite[j].picnum == lType && j != vm.g_i && ldist(&sprite[vm.g_i], &sprite[j]) < lMaxDist) + if (sprite[nSprite].picnum == nPicnum && nSprite != vm.g_i && ldist(&sprite[vm.g_i], &sprite[nSprite]) < nMaxDist) { - lFound=j; - j = MAXSPRITES; + lFound=nSprite; + nSprite = MAXSPRITES; break; } - j = nextspritestat[j]; + nSprite = nextspritestat[nSprite]; } - if (j == MAXSPRITES || tw==CON_FINDNEARACTORVAR) + if (nSprite == MAXSPRITES || tw==CON_FINDNEARACTORVAR) break; } - while (k--); - Gv_SetVarX(lVarID, lFound); + while (nStatnum--); + Gv_SetVarX(nGameVar, lFound); continue; } @@ -4127,36 +4152,41 @@ finish_qsprintf: // that is of into // -1 for none found // - int const lType=*insptr++, lMaxDist=Gv_GetVarX(*insptr++), lMaxZDist=Gv_GetVarX(*insptr++), lVarID = *insptr++; - int32_t lFound=-1, lTemp, lTemp2, j, k=MAXSTATUS-1; + int const lType = *insptr++; + int const lMaxDist = Gv_GetVarX(*insptr++); + int const lMaxZDist = Gv_GetVarX(*insptr++); + int const nGameVar = *insptr++; + int lFound = -1; + int nStatnum = MAXSTATUS-1; + do { - j=headspritestat[tw==CON_FINDNEARACTORZVAR?1:k]; // all sprites - if (j == -1) continue; + int nSprite = headspritestat[tw == CON_FINDNEARACTORZVAR ? 1 : nStatnum]; // all sprites + + if (nSprite == -1) + continue; do { - if (sprite[j].picnum == lType && j != vm.g_i) + if (sprite[nSprite].picnum == lType && nSprite != vm.g_i) { - lTemp=ldist(&sprite[vm.g_i], &sprite[j]); - if (lTemp < lMaxDist) + if (ldist(&sprite[vm.g_i], &sprite[nSprite]) < lMaxDist) { - lTemp2=klabs(sprite[vm.g_i].z-sprite[j].z); - if (lTemp2 < lMaxZDist) + if (klabs(sprite[vm.g_i].z-sprite[nSprite].z) < lMaxZDist) { - lFound=j; - j = MAXSPRITES; + lFound = nSprite; + nSprite = MAXSPRITES; break; } } } - j = nextspritestat[j]; + nSprite = nextspritestat[nSprite]; } - while (j>=0); - if (tw==CON_FINDNEARACTORZVAR || j == MAXSPRITES) + while (nSprite>=0); + if (tw==CON_FINDNEARACTORZVAR || nSprite == MAXSPRITES) break; } - while (k--); - Gv_SetVarX(lVarID, lFound); + while (nStatnum--); + Gv_SetVarX(nGameVar, lFound); continue; } @@ -4170,62 +4200,67 @@ finish_qsprintf: // that is of into // -1 for none found // - int const lType=*insptr++, lMaxDist=*insptr++, lMaxZDist=*insptr++, lVarID=*insptr++; - int32_t lTemp, lTemp2, lFound=-1, j, k=MAXSTATUS-1; + int const lType = *insptr++; + int const lMaxDist = *insptr++; + int const lMaxZDist = *insptr++; + int const nGameVar = *insptr++; + int lFound = -1; + int nStatnum = MAXSTATUS - 1; + do { - j=headspritestat[tw==CON_FINDNEARACTORZ?1:k]; // all sprites - if (j == -1) continue; + int nSprite = headspritestat[tw == CON_FINDNEARACTORZ ? 1 : nStatnum]; // all sprites + + if (nSprite == -1) + continue; do { - if (sprite[j].picnum == lType && j != vm.g_i) + if (sprite[nSprite].picnum == lType && nSprite != vm.g_i) { - lTemp=ldist(&sprite[vm.g_i], &sprite[j]); - if (lTemp < lMaxDist) + if (ldist(&sprite[vm.g_i], &sprite[nSprite]) < lMaxDist) { - lTemp2=klabs(sprite[vm.g_i].z-sprite[j].z); - if (lTemp2 < lMaxZDist) + if (klabs(sprite[vm.g_i].z-sprite[nSprite].z) < lMaxZDist) { - lFound=j; - j = MAXSPRITES; + lFound=nSprite; + nSprite = MAXSPRITES; break; } } } - j = nextspritestat[j]; + nSprite = nextspritestat[nSprite]; } - while (j>=0); + while (nSprite>=0); - if (tw==CON_FINDNEARACTORZ || j == MAXSPRITES) + if (tw==CON_FINDNEARACTORZ || nSprite == MAXSPRITES) break; } - while (k--); - Gv_SetVarX(lVarID, lFound); + while (nStatnum--); + Gv_SetVarX(nGameVar, lFound); continue; } case CON_FINDPLAYER: insptr++; - aGameVars[g_iReturnVarID].val.lValue = A_FindPlayer(&sprite[vm.g_i], &tw); + aGameVars[g_iReturnVarID].nValue = A_FindPlayer(&sprite[vm.g_i], &tw); Gv_SetVarX(*insptr++, tw); continue; case CON_FINDOTHERPLAYER: insptr++; - aGameVars[g_iReturnVarID].val.lValue = P_FindOtherPlayer(vm.g_p,&tw); + aGameVars[g_iReturnVarID].nValue = P_FindOtherPlayer(vm.g_p,&tw); Gv_SetVarX(*insptr++, tw); continue; case CON_SETPLAYER: insptr++; { - tw=*insptr++; - int const lLabelID=*insptr++; - int const lParm2 = (PlayerLabels[lLabelID].flags & LABEL_HASPARM2) ? Gv_GetVarX(*insptr++) : 0; - int const lVar2 = *insptr++; + tw = *insptr++; - register int32_t const iPlayer = (tw != g_iThisActorID) ? Gv_GetVarX(tw) : vm.g_p; - register int32_t const iSet = Gv_GetVarX(lVar2); + int const lLabelID = *insptr++; + int const lParm2 = (PlayerLabels[lLabelID].flags & LABEL_HASPARM2) ? Gv_GetVarX(*insptr++) : 0; + int const lVar2 = *insptr++; + int const iPlayer = (tw != g_iThisActorID) ? Gv_GetVarX(tw) : vm.g_p; + int const iSet = Gv_GetVarX(lVar2); VM_SetPlayer(iPlayer, lLabelID, lParm2, iSet); continue; @@ -4234,12 +4269,12 @@ finish_qsprintf: case CON_GETPLAYER: insptr++; { - tw=*insptr++; - int const lLabelID=*insptr++; - int const lParm2 = (PlayerLabels[lLabelID].flags & LABEL_HASPARM2) ? Gv_GetVarX(*insptr++) : 0; - int const lVar2 = *insptr++; + tw = *insptr++; - register int32_t const iPlayer = (tw != g_iThisActorID) ? Gv_GetVarX(tw) : vm.g_p; + int const lLabelID = *insptr++; + int const lParm2 = (PlayerLabels[lLabelID].flags & LABEL_HASPARM2) ? Gv_GetVarX(*insptr++) : 0; + int const lVar2 = *insptr++; + int const iPlayer = (tw != g_iThisActorID) ? Gv_GetVarX(tw) : vm.g_p; Gv_SetVarX(lVar2, VM_GetPlayer(iPlayer, lLabelID, lParm2)); continue; @@ -4248,10 +4283,11 @@ finish_qsprintf: case CON_GETINPUT: insptr++; { - tw=*insptr++; - int const lLabelID=*insptr++, lVar2=*insptr++; + tw = *insptr++; - register int32_t const iPlayer = (tw != g_iThisActorID) ? Gv_GetVarX(tw) : vm.g_p; + int const lLabelID = *insptr++; + int const lVar2 = *insptr++; + int const iPlayer = (tw != g_iThisActorID) ? Gv_GetVarX(tw) : vm.g_p; Gv_SetVarX(lVar2, VM_GetPlayerInput(iPlayer, lLabelID)); continue; @@ -4260,11 +4296,12 @@ finish_qsprintf: case CON_SETINPUT: insptr++; { - tw=*insptr++; - int const lLabelID=*insptr++, lVar2=*insptr++; + tw = *insptr++; - register int32_t const iPlayer = (tw != g_iThisActorID) ? Gv_GetVarX(tw) : vm.g_p; - register int32_t const iSet = Gv_GetVarX(lVar2); + int const lLabelID = *insptr++; + int const lVar2 = *insptr++; + int const iPlayer = (tw != g_iThisActorID) ? Gv_GetVarX(tw) : vm.g_p; + int const iSet = Gv_GetVarX(lVar2); VM_SetPlayerInput(iPlayer, lLabelID, iSet); continue; @@ -4273,8 +4310,9 @@ finish_qsprintf: case CON_GETUSERDEF: insptr++; { - tw=*insptr++; - int const lVar2=*insptr++; + tw = *insptr++; + + int const lVar2 = *insptr++; Gv_SetVarX(lVar2, VM_GetUserdef(tw)); continue; @@ -4283,10 +4321,10 @@ finish_qsprintf: case CON_SETUSERDEF: insptr++; { - tw=*insptr++; - int const lVar2=*insptr++; + tw = *insptr++; - register int32_t const iSet = Gv_GetVarX(lVar2); + int const lVar2 = *insptr++; + int const iSet = Gv_GetVarX(lVar2); VM_SetUserdef(tw, iSet); continue; @@ -4296,7 +4334,9 @@ finish_qsprintf: insptr++; { tw = Gv_GetVarX(*insptr++); - int const lLabelID = *insptr++, lVar2 = *insptr++; + + int const lLabelID = *insptr++; + int const lVar2 = *insptr++; Gv_SetVarX(lVar2, VM_GetProjectile(tw, lLabelID)); continue; @@ -4305,10 +4345,11 @@ finish_qsprintf: case CON_SETPROJECTILE: insptr++; { - tw=Gv_GetVarX(*insptr++); - int const lLabelID = *insptr++, lVar2 = *insptr++; + tw = Gv_GetVarX(*insptr++); - register int32_t const iSet = Gv_GetVarX(lVar2); + int const lLabelID = *insptr++; + int const lVar2 = *insptr++; + int const iSet = Gv_GetVarX(lVar2); VM_SetProjectile(tw, lLabelID, iSet); continue; @@ -4317,11 +4358,12 @@ finish_qsprintf: case CON_SETWALL: insptr++; { - tw=*insptr++; - int const lLabelID=*insptr++, lVar2=*insptr++; + tw = *insptr++; - register int32_t const iWall = Gv_GetVarX(tw); - register int32_t const iSet = Gv_GetVarX(lVar2); + int const lLabelID = *insptr++; + int const lVar2 = *insptr++; + int const iWall = Gv_GetVarX(tw); + int const iSet = Gv_GetVarX(lVar2); VM_SetWall(iWall, lLabelID, iSet); continue; @@ -4330,10 +4372,11 @@ finish_qsprintf: case CON_GETWALL: insptr++; { - tw=*insptr++; - int const lLabelID=*insptr++, lVar2=*insptr++; + tw = *insptr++; - register int32_t const iWall = Gv_GetVarX(tw); + int const lLabelID = *insptr++; + int const lVar2 = *insptr++; + int const iWall = Gv_GetVarX(tw); Gv_SetVarX(lVar2, VM_GetWall(iWall, lLabelID)); continue; @@ -4343,23 +4386,27 @@ finish_qsprintf: case CON_GETACTORVAR: insptr++; { - int const lSprite=Gv_GetVarX(*insptr++), lVar1=*insptr++; - int const lVar2=*insptr++; + int const lSprite = Gv_GetVarX(*insptr++); + int const lVar1 = *insptr++; + int const lVar2 = *insptr++; if (EDUKE32_PREDICT_FALSE((unsigned)lSprite >= MAXSPRITES)) { CON_ERRPRINTF("invalid sprite ID %d\n", lSprite); - if (lVar1 == MAXGAMEVARS || lVar1 & ((MAXGAMEVARS<<2)|(MAXGAMEVARS<<3))) insptr++; - if (lVar2 == MAXGAMEVARS || lVar2 & ((MAXGAMEVARS<<2)|(MAXGAMEVARS<<3))) insptr++; + + if (lVar1 == MAXGAMEVARS || lVar1 & ((MAXGAMEVARS << 2) | (MAXGAMEVARS << 3))) + insptr++; + + if (lVar2 == MAXGAMEVARS || lVar2 & ((MAXGAMEVARS << 2) | (MAXGAMEVARS << 3))) + insptr++; continue; } if (tw == CON_SETACTORVAR) - { Gv_SetVar(lVar1, Gv_GetVarX(lVar2), lSprite, vm.g_p); - continue; - } - Gv_SetVarX(lVar2, Gv_GetVar(lVar1, lSprite, vm.g_p)); + else + Gv_SetVarX(lVar2, Gv_GetVar(lVar1, lSprite, vm.g_p)); + continue; } @@ -4367,11 +4414,9 @@ finish_qsprintf: case CON_GETPLAYERVAR: insptr++; { - int const iPlayer = (*insptr != g_iThisActorID) ? Gv_GetVarX(*insptr) : vm.g_p; - - insptr++; - - int const lVar1 = *insptr++, lVar2 = *insptr++; + int const iPlayer = (*insptr++ != g_iThisActorID) ? Gv_GetVarX(*(insptr-1)) : vm.g_p; + int const lVar1 = *insptr++; + int const lVar2 = *insptr++; if (EDUKE32_PREDICT_FALSE((unsigned)iPlayer >= (unsigned)playerswhenstarted)) { @@ -4398,12 +4443,12 @@ finish_qsprintf: insptr++; { tw = *insptr++; - int const lLabelID = *insptr++; - int const lParm2 = (ActorLabels[lLabelID].flags & LABEL_HASPARM2) ? Gv_GetVarX(*insptr++) : 0; - int const lVar2 = *insptr++; - register int32_t const iActor = (tw != g_iThisActorID) ? Gv_GetVarX(tw) : vm.g_i; - register int32_t const iSet = Gv_GetVarX(lVar2); + int const lLabelID = *insptr++; + int const lParm2 = (ActorLabels[lLabelID].flags & LABEL_HASPARM2) ? Gv_GetVarX(*insptr++) : 0; + int const lVar2 = *insptr++; + int const iActor = (tw != g_iThisActorID) ? Gv_GetVarX(tw) : vm.g_i; + int const iSet = Gv_GetVarX(lVar2); VM_SetSprite(iActor, lLabelID, lParm2, iSet); continue; @@ -4413,11 +4458,11 @@ finish_qsprintf: insptr++; { tw = *insptr++; - int const lLabelID = *insptr++; - int const lParm2 = (ActorLabels[lLabelID].flags & LABEL_HASPARM2) ? Gv_GetVarX(*insptr++) : 0; - int const lVar2 = *insptr++; - register int32_t const iActor = (tw != g_iThisActorID) ? Gv_GetVarX(tw) : vm.g_i; + int const lLabelID = *insptr++; + int const lParm2 = (ActorLabels[lLabelID].flags & LABEL_HASPARM2) ? Gv_GetVarX(*insptr++) : 0; + int const lVar2 = *insptr++; + int const iActor = (tw != g_iThisActorID) ? Gv_GetVarX(tw) : vm.g_i; Gv_SetVarX(lVar2, VM_GetSprite(iActor, lLabelID, lParm2)); continue; @@ -4427,10 +4472,11 @@ finish_qsprintf: insptr++; { tw = *insptr++; - int const lLabelID=*insptr++, lVar2=*insptr++; - register int32_t const iActor = (tw != g_iThisActorID) ? Gv_GetVarX(tw) : vm.g_i; - register int32_t const iSet = Gv_GetVarX(lVar2); + int const lLabelID = *insptr++; + int const lVar2 = *insptr++; + int const iActor = (tw != g_iThisActorID) ? Gv_GetVarX(tw) : vm.g_i; + int const iSet = Gv_GetVarX(lVar2); VM_SetTsprite(iActor, lLabelID, iSet); continue; @@ -4440,9 +4486,10 @@ finish_qsprintf: insptr++; { tw = *insptr++; - int const lLabelID=*insptr++, lVar2=*insptr++; - register int32_t const iActor = (tw != g_iThisActorID) ? Gv_GetVarX(tw) : vm.g_i; + int const lLabelID = *insptr++; + int const lVar2 = *insptr++; + int const iActor = (tw != g_iThisActorID) ? Gv_GetVarX(tw) : vm.g_i; Gv_SetVarX(lVar2, VM_GetTsprite(iActor, lLabelID)); continue; @@ -4514,16 +4561,16 @@ finish_qsprintf: case CON_SETVAR: insptr++; - if ((aGameVars[*insptr].dwFlags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK)) == 0) - aGameVars[*insptr].val.lValue = *(insptr + 1); + if ((aGameVars[*insptr].nFlags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK)) == 0) + aGameVars[*insptr].nValue = *(insptr + 1); else Gv_SetVarX(*insptr, *(insptr + 1)); insptr += 2; continue; case CON_KLABS: - if ((aGameVars[*(insptr + 1)].dwFlags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK)) == 0) - aGameVars[*(insptr + 1)].val.lValue = klabs(aGameVars[*(insptr + 1)].val.lValue); + if ((aGameVars[*(insptr + 1)].nFlags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK)) == 0) + aGameVars[*(insptr + 1)].nValue = klabs(aGameVars[*(insptr + 1)].nValue); else Gv_SetVarX(*(insptr + 1), klabs(Gv_GetVarX(*(insptr + 1)))); insptr += 2; @@ -4532,7 +4579,8 @@ finish_qsprintf: case CON_SETARRAY: insptr++; { - tw=*insptr++; + tw = *insptr++; + int const index = Gv_GetVarX(*insptr++); int const value = Gv_GetVarX(*insptr++); @@ -4542,68 +4590,71 @@ finish_qsprintf: tw,vm.g_i,TrackerCast(sprite[vm.g_i].picnum),vm.g_p); continue; } - if (EDUKE32_PREDICT_FALSE(aGameArrays[tw].dwFlags & GAMEARRAY_READONLY)) + + if (EDUKE32_PREDICT_FALSE(aGameArrays[tw].nFlags & GAMEARRAY_READONLY)) { OSD_Printf("Tried to set on read-only array `%s'", aGameArrays[tw].szLabel); continue; } - aGameArrays[tw].plValues[index]=value; + + aGameArrays[tw].pValues[index]=value; continue; } + case CON_WRITEARRAYTOFILE: case CON_READARRAYFROMFILE: insptr++; { - const int32_t j=*insptr++; - const int q = *insptr++; + int const nArray = *insptr++; + int const qFilename = *insptr++; - if (EDUKE32_PREDICT_FALSE(ScriptQuotes[q] == NULL)) + if (EDUKE32_PREDICT_FALSE(ScriptQuotes[qFilename] == NULL)) { - CON_ERRPRINTF("null quote %d\n", q); + CON_ERRPRINTF("null quote %d\n", qFilename); continue; } if (tw == CON_READARRAYFROMFILE) { - int32_t fil = kopen4loadfrommod(ScriptQuotes[q], 0); + int32_t kfil = kopen4loadfrommod(ScriptQuotes[qFilename], 0); - if (fil < 0) + if (kfil < 0) continue; - int32_t numelts = kfilelength(fil) / sizeof(int32_t); + int32_t nElements = kfilelength(kfil) / sizeof(int32_t); - if (numelts == 0) + if (nElements == 0) { - Baligned_free(aGameArrays[j].plValues); - aGameArrays[j].plValues = NULL; - aGameArrays[j].size = numelts; + Baligned_free(aGameArrays[nArray].pValues); + aGameArrays[nArray].pValues = NULL; + aGameArrays[nArray].size = nElements; } - else if (numelts > 0) + else if (nElements > 0) { - int32_t numbytes = numelts * sizeof(int32_t); + int const numbytes = nElements * sizeof(int32_t); #ifdef BITNESS64 - int32_t *tmpar = (int32_t *)Xcalloc(numelts, sizeof(int32_t)); - kread(fil, tmpar, numbytes); + int32_t *pArray = (int32_t *)Xcalloc(nElements, sizeof(int32_t)); + kread(kfil, pArray, numbytes); #endif - Baligned_free(aGameArrays[j].plValues); - aGameArrays[j].plValues = (intptr_t *)Xaligned_alloc(ACTOR_VAR_ALIGNMENT, numelts * GAR_ELTSZ); - aGameArrays[j].size = numelts; + Baligned_free(aGameArrays[nArray].pValues); + aGameArrays[nArray].pValues = (intptr_t *)Xaligned_alloc(ACTOR_VAR_ALIGNMENT, nElements * GAR_ELTSZ); + aGameArrays[nArray].size = nElements; #ifdef BITNESS64 - for (int32_t i = 0; i < numelts; i++) - aGameArrays[j].plValues[i] = tmpar[i]; // int32_t --> int64_t - Bfree(tmpar); + for (int i = 0; i < nElements; i++) + aGameArrays[nArray].pValues[i] = pArray[i]; // int32_t --> int64_t + Bfree(pArray); #else - kread(fil, aGameArrays[j].plValues, numbytes); + kread(kfil, aGameArrays[nArray].pValues, numbytes); #endif } - kclose(fil); + kclose(kfil); continue; } char temp[BMAX_PATH]; - if (EDUKE32_PREDICT_FALSE(G_ModDirSnprintf(temp, sizeof(temp), "%s", ScriptQuotes[q]))) + if (EDUKE32_PREDICT_FALSE(G_ModDirSnprintf(temp, sizeof(temp), "%s", ScriptQuotes[qFilename]))) { CON_ERRPRINTF("file name too long\n"); continue; @@ -4617,11 +4668,14 @@ finish_qsprintf: continue; } - const int32_t n = aGameArrays[j].size; - int32_t *const array = (int32_t *)Xmalloc(sizeof(int32_t) * n); - for (int32_t k = 0; k < n; k++) array[k] = Gv_GetGameArrayValue(j, k); - fwrite(array, 1, sizeof(int32_t) * n, fil); - Bfree(array); + int const nSize = aGameArrays[nArray].size; + int *const pArray = (int32_t *)Xmalloc(sizeof(int32_t) * nSize); + + for (int k = 0; k < nSize; k++) + pArray[k] = Gv_GetGameArrayValue(nArray, k); + + fwrite(pArray, 1, sizeof(int32_t) * nSize, fil); + Bfree(pArray); fclose(fil); continue; @@ -4630,33 +4684,38 @@ finish_qsprintf: case CON_GETARRAYSIZE: insptr++; tw = *insptr++; - Gv_SetVarX(*insptr++,(aGameArrays[tw].dwFlags & GAMEARRAY_VARSIZE) ? + Gv_SetVarX(*insptr++,(aGameArrays[tw].nFlags & GAMEARRAY_VARSIZE) ? Gv_GetVarX(aGameArrays[tw].size) : aGameArrays[tw].size); continue; case CON_RESIZEARRAY: insptr++; { - tw=*insptr++; - const int32_t newSize = Gv_GetVarX(*insptr++); - const int32_t oldSize = aGameArrays[tw].size; + tw = *insptr++; + + int const newSize = Gv_GetVarX(*insptr++); + int const oldSize = aGameArrays[tw].size; if (newSize >= 0 && newSize != oldSize) { // OSD_Printf(OSDTEXT_GREEN "CON_RESIZEARRAY: resizing array %s from %d to %d\n", // aGameArrays[j].szLabel, aGameArrays[j].size, newSize); - intptr_t *const tmpar = oldSize != 0 ? (intptr_t *)Xmalloc(GAR_ELTSZ * oldSize) : NULL; - if (oldSize != 0) - memcpy(tmpar, aGameArrays[tw].plValues, GAR_ELTSZ * oldSize); - Baligned_free(aGameArrays[tw].plValues); - aGameArrays[tw].plValues = newSize != 0 ? (intptr_t *)Xaligned_alloc(ACTOR_VAR_ALIGNMENT, GAR_ELTSZ * newSize) : NULL; + intptr_t * const tmpar = oldSize != 0 ? (intptr_t *)Xmalloc(GAR_ELTSZ * oldSize) : NULL; + + if (oldSize != 0) + memcpy(tmpar, aGameArrays[tw].pValues, GAR_ELTSZ * oldSize); + + Baligned_free(aGameArrays[tw].pValues); + + aGameArrays[tw].pValues = newSize != 0 ? (intptr_t *)Xaligned_alloc(ACTOR_VAR_ALIGNMENT, GAR_ELTSZ * newSize) : NULL; aGameArrays[tw].size = newSize; if (oldSize != 0) - memcpy(aGameArrays[tw].plValues, tmpar, GAR_ELTSZ * min(oldSize, newSize)); + memcpy(aGameArrays[tw].pValues, tmpar, GAR_ELTSZ * min(oldSize, newSize)); + if (newSize > oldSize) - memset(&aGameArrays[tw].plValues[oldSize], 0, GAR_ELTSZ * (newSize - oldSize)); + memset(&aGameArrays[tw].pValues[oldSize], 0, GAR_ELTSZ * (newSize - oldSize)); } continue; } @@ -4664,91 +4723,95 @@ finish_qsprintf: case CON_COPY: insptr++; { - int const si = *insptr++; - int sidx = Gv_GetVarX(*insptr++); //, vm.g_i, vm.g_p); - int const di = *insptr++; - int didx = Gv_GetVarX(*insptr++); - int32_t numelts = Gv_GetVarX(*insptr++); + int const aSrc = *insptr++; + int nSrcIndex = Gv_GetVarX(*insptr++); //, vm.g_i, vm.g_p); + int const aDest = *insptr++; + int nDestIndex = Gv_GetVarX(*insptr++); + int nElements = Gv_GetVarX(*insptr++); tw = 0; - if (EDUKE32_PREDICT_FALSE((unsigned)si>=(unsigned)g_gameArrayCount)) + if (EDUKE32_PREDICT_FALSE((unsigned)aSrc>=(unsigned)g_gameArrayCount)) { - CON_ERRPRINTF("Invalid array %d!", si); + CON_ERRPRINTF("Invalid array %d!", aSrc); tw = 1; } - if (EDUKE32_PREDICT_FALSE((unsigned)di>=(unsigned)g_gameArrayCount)) + + if (EDUKE32_PREDICT_FALSE((unsigned)aDest>=(unsigned)g_gameArrayCount)) { - CON_ERRPRINTF("Invalid array %d!", di); + CON_ERRPRINTF("Invalid array %d!", aDest); tw = 1; } - if (EDUKE32_PREDICT_FALSE(aGameArrays[di].dwFlags & GAMEARRAY_READONLY)) + + if (EDUKE32_PREDICT_FALSE(aGameArrays[aDest].nFlags & GAMEARRAY_READONLY)) { - CON_ERRPRINTF("Array %d is read-only!", di); + CON_ERRPRINTF("Array %d is read-only!", aDest); tw = 1; } if (EDUKE32_PREDICT_FALSE(tw)) continue; // dirty replacement for VMFLAG_ERROR - int const ssiz = - (aGameArrays[si].dwFlags & GAMEARRAY_VARSIZE) ? Gv_GetVarX(aGameArrays[si].size) : aGameArrays[si].size; - int const dsiz = - (aGameArrays[di].dwFlags & GAMEARRAY_VARSIZE) ? Gv_GetVarX(aGameArrays[si].size) : aGameArrays[di].size; + int const nSrcSize = + (aGameArrays[aSrc].nFlags & GAMEARRAY_VARSIZE) ? Gv_GetVarX(aGameArrays[aSrc].size) : aGameArrays[aSrc].size; + int const nDestSize = + (aGameArrays[aDest].nFlags & GAMEARRAY_VARSIZE) ? Gv_GetVarX(aGameArrays[aSrc].size) : aGameArrays[aDest].size; - if (EDUKE32_PREDICT_FALSE(sidx > ssiz || didx > dsiz)) + if (EDUKE32_PREDICT_FALSE(nSrcIndex > nSrcSize || nDestIndex > nDestSize)) continue; - if ((sidx + numelts) > ssiz) - numelts = ssiz - sidx; - if ((didx + numelts) > dsiz) - numelts = dsiz - didx; + + if ((nSrcIndex + nElements) > nSrcSize) + nElements = nSrcSize - nSrcIndex; + + if ((nDestIndex + nElements) > nDestSize) + nElements = nDestSize - nDestIndex; // Switch depending on the source array type. - switch (aGameArrays[si].dwFlags & GAMEARRAY_TYPE_MASK) + switch (aGameArrays[aSrc].nFlags & GAMEARRAY_TYPE_MASK) { case 0: // CON array to CON array. - if (EDUKE32_PREDICT_FALSE(aGameArrays[si].dwFlags & GAMEARRAY_STRIDE2)) + if (EDUKE32_PREDICT_FALSE(aGameArrays[aSrc].nFlags & GAMEARRAY_STRIDE2)) { - for (; numelts>0; --numelts) - (aGameArrays[di].plValues)[didx++] = ((int32_t *)aGameArrays[si].plValues)[sidx+=2]; + for (; nElements>0; --nElements) + (aGameArrays[aDest].pValues)[nDestIndex++] = ((int32_t *)aGameArrays[aSrc].pValues)[nSrcIndex+=2]; break; } - Bmemcpy(aGameArrays[di].plValues+didx, aGameArrays[si].plValues+sidx, numelts*GAR_ELTSZ); + Bmemcpy(aGameArrays[aDest].pValues+nDestIndex, aGameArrays[aSrc].pValues+nSrcIndex, nElements*GAR_ELTSZ); break; case GAMEARRAY_OFINT: // From int32-sized array. Note that the CON array element // type is intptr_t, so it is different-sized on 64-bit // archs, but same-sized on 32-bit ones. - if (EDUKE32_PREDICT_FALSE(aGameArrays[si].dwFlags & GAMEARRAY_STRIDE2)) + if (EDUKE32_PREDICT_FALSE(aGameArrays[aSrc].nFlags & GAMEARRAY_STRIDE2)) { - for (; numelts>0; --numelts) - (aGameArrays[di].plValues)[didx++] = ((int32_t *)aGameArrays[si].plValues)[sidx+=2]; + for (; nElements>0; --nElements) + (aGameArrays[aDest].pValues)[nDestIndex++] = ((int32_t *)aGameArrays[aSrc].pValues)[nSrcIndex+=2]; break; } - for (; numelts>0; --numelts) - (aGameArrays[di].plValues)[didx++] = ((int32_t *)aGameArrays[si].plValues)[sidx++]; + for (; nElements>0; --nElements) + (aGameArrays[aDest].pValues)[nDestIndex++] = ((int32_t *)aGameArrays[aSrc].pValues)[nSrcIndex++]; break; case GAMEARRAY_OFSHORT: // From int16_t array. Always different-sized. - if (EDUKE32_PREDICT_FALSE(aGameArrays[si].dwFlags & GAMEARRAY_STRIDE2)) + if (EDUKE32_PREDICT_FALSE(aGameArrays[aSrc].nFlags & GAMEARRAY_STRIDE2)) { - for (; numelts>0; --numelts) - (aGameArrays[di].plValues)[didx++] = ((int16_t *)aGameArrays[si].plValues)[sidx+=2]; + for (; nElements>0; --nElements) + (aGameArrays[aDest].pValues)[nDestIndex++] = ((int16_t *)aGameArrays[aSrc].pValues)[nSrcIndex+=2]; break; } - for (; numelts>0; --numelts) - (aGameArrays[di].plValues)[didx++] = ((int16_t *)aGameArrays[si].plValues)[sidx++]; + for (; nElements>0; --nElements) + (aGameArrays[aDest].pValues)[nDestIndex++] = ((int16_t *)aGameArrays[aSrc].pValues)[nSrcIndex++]; break; case GAMEARRAY_OFCHAR: // From char array. Always different-sized. - if (EDUKE32_PREDICT_FALSE(aGameArrays[si].dwFlags & GAMEARRAY_STRIDE2)) + if (EDUKE32_PREDICT_FALSE(aGameArrays[aSrc].nFlags & GAMEARRAY_STRIDE2)) { - for (; numelts>0; --numelts) - (aGameArrays[di].plValues)[didx++] = ((uint8_t *)aGameArrays[si].plValues)[sidx+=2]; + for (; nElements>0; --nElements) + (aGameArrays[aDest].pValues)[nDestIndex++] = ((uint8_t *)aGameArrays[aSrc].pValues)[nSrcIndex+=2]; break; } - for (; numelts>0; --numelts) - (aGameArrays[di].plValues)[didx++] = ((uint8_t *)aGameArrays[si].plValues)[sidx++]; + for (; nElements>0; --nElements) + (aGameArrays[aDest].pValues)[nDestIndex++] = ((uint8_t *)aGameArrays[aSrc].pValues)[nSrcIndex++]; break; } continue; @@ -4776,8 +4839,8 @@ finish_qsprintf: continue; case CON_INV: - if ((aGameVars[*(insptr + 1)].dwFlags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK)) == 0) - aGameVars[*(insptr + 1)].val.lValue = -aGameVars[*(insptr + 1)].val.lValue; + if ((aGameVars[*(insptr + 1)].nFlags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK)) == 0) + aGameVars[*(insptr + 1)].nValue = -aGameVars[*(insptr + 1)].nValue; else Gv_SetVarX(*(insptr + 1), -Gv_GetVarX(*(insptr + 1))); insptr += 2; @@ -4836,10 +4899,10 @@ finish_qsprintf: insptr++; { tw = *insptr++; - int32_t const gv = Gv_GetVarX(*insptr++); + int const gv = Gv_GetVarX(*insptr++); - if ((aGameVars[tw].dwFlags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK)) == 0) - aGameVars[tw].val.lValue = gv; + if ((aGameVars[tw].nFlags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK)) == 0) + aGameVars[tw].nValue = gv; else Gv_SetVarX(tw, gv); } @@ -4890,8 +4953,8 @@ finish_qsprintf: case CON_DIVVARVAR: insptr++; { - tw=*insptr++; - int32_t const l2=Gv_GetVarX(*insptr++); + tw = *insptr++; + int const l2 = Gv_GetVarX(*insptr++); if (EDUKE32_PREDICT_FALSE(!l2)) { @@ -4907,7 +4970,7 @@ finish_qsprintf: insptr++; { tw=*insptr++; - int32_t const l2=Gv_GetVarX(*insptr++); + int const l2 = Gv_GetVarX(*insptr++); if (EDUKE32_PREDICT_FALSE(!l2)) { @@ -4915,7 +4978,6 @@ finish_qsprintf: continue; } - Gv_ModVar(tw, l2); continue; } @@ -4958,9 +5020,9 @@ finish_qsprintf: case CON_SHIFTVARL: insptr++; - if ((aGameVars[*insptr].dwFlags & (GAMEVAR_USER_MASK|GAMEVAR_PTR_MASK)) == 0) + if ((aGameVars[*insptr].nFlags & (GAMEVAR_USER_MASK|GAMEVAR_PTR_MASK)) == 0) { - aGameVars[*insptr].val.lValue <<= *(insptr+1); + aGameVars[*insptr].nValue <<= *(insptr+1); insptr += 2; continue; } @@ -4970,9 +5032,9 @@ finish_qsprintf: case CON_SHIFTVARR: insptr++; - if ((aGameVars[*insptr].dwFlags & (GAMEVAR_USER_MASK|GAMEVAR_PTR_MASK)) == 0) + if ((aGameVars[*insptr].nFlags & (GAMEVAR_USER_MASK|GAMEVAR_PTR_MASK)) == 0) { - aGameVars[*insptr].val.lValue >>= *(insptr+1); + aGameVars[*insptr].nValue >>= *(insptr+1); insptr += 2; continue; } @@ -5012,35 +5074,34 @@ finish_qsprintf: case CON_SPGETLOTAG: insptr++; - aGameVars[g_iLoTagID].val.lValue = vm.g_sp->lotag; + aGameVars[g_iLoTagID].nValue = vm.g_sp->lotag; continue; case CON_SPGETHITAG: insptr++; - aGameVars[g_iHiTagID].val.lValue = vm.g_sp->hitag; + aGameVars[g_iHiTagID].nValue = vm.g_sp->hitag; continue; case CON_SECTGETLOTAG: insptr++; - aGameVars[g_iLoTagID].val.lValue = sector[vm.g_sp->sectnum].lotag; + aGameVars[g_iLoTagID].nValue = sector[vm.g_sp->sectnum].lotag; continue; case CON_SECTGETHITAG: insptr++; - aGameVars[g_iHiTagID].val.lValue = sector[vm.g_sp->sectnum].hitag; + aGameVars[g_iHiTagID].nValue = sector[vm.g_sp->sectnum].hitag; continue; case CON_GETTEXTUREFLOOR: insptr++; - aGameVars[g_iTextureID].val.lValue = sector[vm.g_sp->sectnum].floorpicnum; + aGameVars[g_iTextureID].nValue = sector[vm.g_sp->sectnum].floorpicnum; continue; case CON_STARTTRACK: case CON_STARTTRACKVAR: insptr++; { - int32_t const level = (tw == CON_STARTTRACK) ? *(insptr++) : - Gv_GetVarX(*(insptr++)); + int const level = (tw == CON_STARTTRACK) ? *(insptr++) : Gv_GetVarX(*(insptr++)); if (EDUKE32_PREDICT_FALSE(G_StartTrack(level))) CON_ERRPRINTF("invalid level %d or null music for volume %d level %d\n", @@ -5076,7 +5137,7 @@ finish_qsprintf: case CON_GETTEXTURECEILING: insptr++; - aGameVars[g_iTextureID].val.lValue = sector[vm.g_sp->sectnum].ceilingpicnum; + aGameVars[g_iTextureID].nValue = sector[vm.g_sp->sectnum].ceilingpicnum; continue; case CON_IFVARVARAND: @@ -5230,14 +5291,16 @@ finish_qsprintf: case CON_FOR: // special-purpose iteration insptr++; { - const int32_t var = *insptr++, how = *insptr++; - const int32_t parm2 = how<=ITER_DRAWNSPRITES ? 0 : Gv_GetVarX(*insptr++); - intptr_t const *const end = insptr + *insptr, *const beg = ++insptr; + int const var = *insptr++; + int const how = *insptr++; + int const parm2 = how <= ITER_DRAWNSPRITES ? 0 : Gv_GetVarX(*insptr++); + intptr_t const *const end = insptr + *insptr; + intptr_t const *const beg = ++insptr; switch (how) { case ITER_ALLSPRITES: - for (int jj=0; jjinv_amount[GET_STEROIDS] != *insptr); break; - case GET_SHIELD: tw = (ps->inv_amount[GET_SHIELD] != ps->max_shield_amount); break; - case GET_SCUBA: tw = (ps->inv_amount[GET_SCUBA] != *insptr); break; + case GET_SHIELD: tw = (ps->inv_amount[GET_SHIELD] != ps->max_shield_amount); break; + case GET_SCUBA: tw = (ps->inv_amount[GET_SCUBA] != *insptr); break; case GET_HOLODUKE: tw = (ps->inv_amount[GET_HOLODUKE] != *insptr); break; - case GET_JETPACK: tw = (ps->inv_amount[GET_JETPACK] != *insptr); break; + case GET_JETPACK: tw = (ps->inv_amount[GET_JETPACK] != *insptr); break; case GET_ACCESS: switch (vm.g_sp->pal) { - case 0: tw = (ps->got_access & 1); break; + case 0: tw = (ps->got_access & 1); break; case 21: tw = (ps->got_access & 2); break; case 23: tw = (ps->got_access & 4); break; } break; - case GET_HEATS: tw = (ps->inv_amount[GET_HEATS] != *insptr); break; + case GET_HEATS: tw = (ps->inv_amount[GET_HEATS] != *insptr); break; case GET_FIRSTAID: tw = (ps->inv_amount[GET_FIRSTAID] != *insptr); break; - case GET_BOOTS: tw = (ps->inv_amount[GET_BOOTS] != *insptr); break; + case GET_BOOTS: tw = (ps->inv_amount[GET_BOOTS] != *insptr); break; default: tw = 0; CON_ERRPRINTF("invalid inventory ID: %d\n", (int32_t) * (insptr - 1)); } @@ -5462,7 +5525,7 @@ finish_qsprintf: insptr++; if (ps->knee_incs == 0 && sprite[ps->i].xrepeat >= 40) if (cansee(vm.g_sp->x, vm.g_sp->y, vm.g_sp->z - (4 << 8), vm.g_sp->sectnum, ps->pos.x, - ps->pos.y, ps->pos.z + (16 << 8), sprite[ps->i].sectnum)) + ps->pos.y, ps->pos.z + ZOFFSET2, sprite[ps->i].sectnum)) { int32_t j = playerswhenstarted - 1; @@ -5648,15 +5711,15 @@ finish_qsprintf: // NORECURSE void A_LoadActor(int32_t iActor) { - vm.g_i = iActor; // Sprite ID - vm.g_sp = &sprite[iActor]; // Pointer to sprite structure + vm.g_i = iActor; // Sprite ID + vm.g_sp = &sprite[iActor]; // Pointer to sprite structure if (g_tile[vm.g_sp->picnum].loadPtr == NULL) return; - vm.g_t = &actor[iActor].t_data[0]; // Sprite's 'extra' data - vm.g_p = -1; // Player ID - vm.g_x = -1; // Distance + vm.g_t = &actor[iActor].t_data[0]; // Sprite's 'extra' data + vm.g_p = -1; // Player ID + vm.g_x = -1; // Distance vm.g_pp = g_player[0].ps; vm.g_flags &= ~(VM_RETURN | VM_KILL | VM_NOEXECUTE); @@ -5701,7 +5764,7 @@ void A_Execute(int32_t iActor, int32_t iPlayer, int32_t lDist) if (EDUKE32_PREDICT_FALSE((unsigned)vm.g_sp->sectnum >= MAXSECTORS)) { - if (A_CheckEnemySprite((uspritetype *)vm.g_sp)) + if (A_CheckEnemySprite(vm.g_sp)) vm.g_pp->actors_killed++; A_DeleteSprite(vm.g_i); @@ -5716,13 +5779,13 @@ void A_Execute(int32_t iActor, int32_t iPlayer, int32_t lDist) #endif { #if !defined LUNATIC - const int32_t action_frames = actionptr[1]; - const int32_t action_incval = actionptr[3]; - const int32_t action_delay = actionptr[4]; + int const action_frames = actionptr[1]; + int const action_incval = actionptr[3]; + int const action_delay = actionptr[4]; #else - const int32_t action_frames = actor[vm.g_i].ac.numframes; - const int32_t action_incval = actor[vm.g_i].ac.incval; - const int32_t action_delay = actor[vm.g_i].ac.delay; + int const action_frames = actor[vm.g_i].ac.numframes; + int const action_incval = actor[vm.g_i].ac.incval; + int const action_delay = actor[vm.g_i].ac.delay; #endif uint16_t *actionticsptr = &AC_ACTIONTICS(vm.g_sp, &actor[vm.g_i]); *actionticsptr += TICSPERFRAME; @@ -5739,7 +5802,7 @@ void A_Execute(int32_t iActor, int32_t iPlayer, int32_t lDist) } #ifdef LUNATIC - const int32_t picnum = vm.g_sp->picnum; + int const picnum = vm.g_sp->picnum; if (L_IsInitialized(&g_ElState) && El_HaveActor(picnum)) { @@ -5798,7 +5861,7 @@ void A_Execute(int32_t iActor, int32_t iPlayer, int32_t lDist) return; } - if (A_CheckEnemySprite((uspritetype *)vm.g_sp)) + if (A_CheckEnemySprite(vm.g_sp)) { if (vm.g_sp->xrepeat > 60 || (ud.respawn_monsters == 1 && vm.g_sp->extra <= 0)) return; @@ -5904,20 +5967,20 @@ void G_SaveMapState(void) #if !defined LUNATIC for (int i=g_gameVarCount-1; i>=0; i--) { - if (aGameVars[i].dwFlags & GAMEVAR_NORESET) continue; - if (aGameVars[i].dwFlags & GAMEVAR_PERPLAYER) + if (aGameVars[i].nFlags & GAMEVAR_NORESET) continue; + if (aGameVars[i].nFlags & GAMEVAR_PERPLAYER) { if (!save->vars[i]) save->vars[i] = (intptr_t *)Xaligned_alloc(16, MAXPLAYERS * sizeof(intptr_t)); - Bmemcpy(&save->vars[i][0],&aGameVars[i].val.plValues[0],sizeof(intptr_t) * MAXPLAYERS); + Bmemcpy(&save->vars[i][0],&aGameVars[i].pValues[0],sizeof(intptr_t) * MAXPLAYERS); } - else if (aGameVars[i].dwFlags & GAMEVAR_PERACTOR) + else if (aGameVars[i].nFlags & GAMEVAR_PERACTOR) { if (!save->vars[i]) save->vars[i] = (intptr_t *)Xaligned_alloc(16, MAXSPRITES * sizeof(intptr_t)); - Bmemcpy(&save->vars[i][0],&aGameVars[i].val.plValues[0],sizeof(intptr_t) * MAXSPRITES); + Bmemcpy(&save->vars[i][0],&aGameVars[i].pValues[0],sizeof(intptr_t) * MAXSPRITES); } - else save->vars[i] = (intptr_t *)aGameVars[i].val.lValue; + else save->vars[i] = (intptr_t *)aGameVars[i].nValue; } #else int32_t slen; @@ -6021,18 +6084,18 @@ void G_RestoreMapState(void) #if !defined LUNATIC for (i=g_gameVarCount-1; i>=0; i--) { - if (aGameVars[i].dwFlags & GAMEVAR_NORESET) continue; - if (aGameVars[i].dwFlags & GAMEVAR_PERPLAYER) + if (aGameVars[i].nFlags & GAMEVAR_NORESET) continue; + if (aGameVars[i].nFlags & GAMEVAR_PERPLAYER) { if (!save->vars[i]) continue; - Bmemcpy(&aGameVars[i].val.plValues[0],&save->vars[i][0],sizeof(intptr_t) * MAXPLAYERS); + Bmemcpy(&aGameVars[i].pValues[0],&save->vars[i][0],sizeof(intptr_t) * MAXPLAYERS); } - else if (aGameVars[i].dwFlags & GAMEVAR_PERACTOR) + else if (aGameVars[i].nFlags & GAMEVAR_PERACTOR) { if (!save->vars[i]) continue; - Bmemcpy(&aGameVars[i].val.plValues[0],&save->vars[i][0],sizeof(intptr_t) * MAXSPRITES); + Bmemcpy(&aGameVars[i].pValues[0],&save->vars[i][0],sizeof(intptr_t) * MAXSPRITES); } - else aGameVars[i].val.lValue = (intptr_t)save->vars[i]; + else aGameVars[i].nValue = (intptr_t)save->vars[i]; } Gv_RefreshPointers(); diff --git a/polymer/eduke32/source/gameexec.h b/polymer/eduke32/source/gameexec.h index c21f8731a..946cc1c53 100644 --- a/polymer/eduke32/source/gameexec.h +++ b/polymer/eduke32/source/gameexec.h @@ -48,11 +48,11 @@ void A_LoadActor(int32_t iActor); #endif void A_Execute(int32_t iActor, int32_t iPlayer, int32_t lDist); -void A_Fall(int32_t iActor); +void A_Fall(int nSprite); int32_t A_FurthestVisiblePoint(int32_t iActor,uspritetype * const ts,int32_t *dax,int32_t *day); int32_t A_GetFurthestAngle(int32_t iActor,int32_t angs); void A_GetZLimits(int32_t iActor); -int32_t G_GetAngleDelta(int32_t a,int32_t na); +int G_GetAngleDelta(int a,int na); void G_RestoreMapState(); void G_SaveMapState(); @@ -66,38 +66,38 @@ void VM_DrawTileGeneric(int32_t x, int32_t y, int32_t zoom, int32_t tilenum, int32_t shade, int32_t orientation, int32_t p); #endif -int32_t VM_OnEventWithBoth_(int32_t iEventID, int32_t iActor, int32_t iPlayer, int32_t lDist, int32_t iReturn); -int32_t VM_OnEventWithReturn_(int32_t iEventID, int32_t iActor, int32_t iPlayer, int32_t iReturn); -int32_t VM_OnEventWithDist_(int32_t iEventID, int32_t iActor, int32_t iPlayer, int32_t lDist); -int32_t VM_OnEvent_(int32_t iEventID, int32_t iActor, int32_t iPlayer); +int32_t VM_OnEventWithBoth_(int nEventID, int nSprite, int nPlayer, int nDist, int32_t nReturn); +int32_t VM_OnEventWithReturn_(int nEventID, int nSprite, int nPlayer, int32_t nReturn); +int32_t VM_OnEventWithDist_(int nEventID, int nSprite, int nPlayer, int nDist); +int32_t VM_OnEvent_(int nEventID, int nSprite, int nPlayer); -FORCE_INLINE int32_t VM_HaveEvent(int32_t iEventID) +FORCE_INLINE int VM_HaveEvent(int nEventID) { #ifdef LUNATIC - return L_IsInitialized(&g_ElState) && El_HaveEvent(iEventID); + return L_IsInitialized(&g_ElState) && El_HaveEvent(nEventID); #else - return !!apScriptGameEvent[iEventID]; + return !!apScriptGameEvent[nEventID]; #endif } -FORCE_INLINE int32_t VM_OnEventWithBoth(int32_t iEventID, int32_t iActor, int32_t iPlayer, int32_t lDist, int32_t iReturn) +FORCE_INLINE int32_t VM_OnEventWithBoth(int nEventID, int nSprite, int nPlayer, int nDist, int32_t nReturn) { - return VM_HaveEvent(iEventID) ? VM_OnEventWithBoth_(iEventID, iActor, iPlayer, lDist, iReturn) : iReturn; + return VM_HaveEvent(nEventID) ? VM_OnEventWithBoth_(nEventID, nSprite, nPlayer, nDist, nReturn) : nReturn; } -FORCE_INLINE int32_t VM_OnEventWithReturn(int32_t iEventID, int32_t iActor, int32_t iPlayer, int32_t iReturn) +FORCE_INLINE int32_t VM_OnEventWithReturn(int nEventID, int nSprite, int nPlayer, int nReturn) { - return VM_HaveEvent(iEventID) ? VM_OnEventWithReturn_(iEventID, iActor, iPlayer, iReturn) : iReturn; + return VM_HaveEvent(nEventID) ? VM_OnEventWithReturn_(nEventID, nSprite, nPlayer, nReturn) : nReturn; } -FORCE_INLINE int32_t VM_OnEventWithDist(int32_t iEventID, int32_t iActor, int32_t iPlayer, int32_t lDist) +FORCE_INLINE int32_t VM_OnEventWithDist(int nEventID, int nSprite, int nPlayer, int nDist) { - return VM_HaveEvent(iEventID) ? VM_OnEventWithDist_(iEventID, iActor, iPlayer, lDist) : 0; + return VM_HaveEvent(nEventID) ? VM_OnEventWithDist_(nEventID, nSprite, nPlayer, nDist) : 0; } -FORCE_INLINE int32_t VM_OnEvent(int32_t iEventID, int32_t iActor, int32_t iPlayer) +FORCE_INLINE int32_t VM_OnEvent(int nEventID, int nSprite, int nPlayer) { - return VM_HaveEvent(iEventID) ? VM_OnEvent_(iEventID, iActor, iPlayer) : 0; + return VM_HaveEvent(nEventID) ? VM_OnEvent_(nEventID, nSprite, nPlayer) : 0; } #define CON_ERRPRINTF(Text, ...) do { \ @@ -105,7 +105,7 @@ FORCE_INLINE int32_t VM_OnEvent(int32_t iEventID, int32_t iActor, int32_t iPlaye } while (0) void G_GetTimeDate(int32_t *vals); -int32_t G_StartTrack(int32_t level); +int G_StartTrack(int nLevel); int32_t A_Dodge(spritetype *s); #ifdef LUNATIC void G_ShowView(vec3_t vec, int32_t a, int32_t horiz, int32_t sect, diff --git a/polymer/eduke32/source/gamevars.c b/polymer/eduke32/source/gamevars.c index cd939ea2d..17d204028 100644 --- a/polymer/eduke32/source/gamevars.c +++ b/polymer/eduke32/source/gamevars.c @@ -66,18 +66,18 @@ static int32_t Gv_Free(void) { for (int32_t i=0; ivars[j]) MapInfo[i].savedstate->vars[j] = (intptr_t *)Xaligned_alloc(PLAYER_VAR_ALIGNMENT, 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_PERACTOR) + else if (aGameVars[j].nFlags & GAMEVAR_PERACTOR) { // if (!MapInfo[i].savedstate->vars[j]) MapInfo[i].savedstate->vars[j] = (intptr_t *)Xaligned_alloc(ACTOR_VAR_ALIGNMENT, MAXSPRITES * sizeof(intptr_t)); @@ -283,17 +283,17 @@ void Gv_WriteSave(FILE *fil, int32_t newbehav) dfwrite(&(aGameVars[i]),sizeof(gamevar_t),1,fil); dfwrite(aGameVars[i].szLabel,sizeof(uint8_t) * MAXVARLABEL, 1, fil); - if (aGameVars[i].dwFlags & GAMEVAR_PERPLAYER) + if (aGameVars[i].nFlags & GAMEVAR_PERPLAYER) { //Bsprintf(g_szBuf,"Writing value array for %s (%d)",aGameVars[i].szLabel,sizeof(int32_t) * MAXPLAYERS); //AddLog(g_szBuf); - dfwrite(aGameVars[i].val.plValues,sizeof(intptr_t) * MAXPLAYERS, 1, fil); + dfwrite(aGameVars[i].pValues,sizeof(intptr_t) * MAXPLAYERS, 1, fil); } - else if (aGameVars[i].dwFlags & GAMEVAR_PERACTOR) + else if (aGameVars[i].nFlags & GAMEVAR_PERACTOR) { //Bsprintf(g_szBuf,"Writing value array for %s (%d)",aGameVars[i].szLabel,sizeof(int32_t) * MAXSPRITES); //AddLog(g_szBuf); - dfwrite(&aGameVars[i].val.plValues[0],sizeof(intptr_t), MAXSPRITES, fil); + dfwrite(&aGameVars[i].pValues[0],sizeof(intptr_t), MAXSPRITES, fil); } } @@ -301,14 +301,14 @@ void Gv_WriteSave(FILE *fil, int32_t newbehav) for (int i=0; ivars[j][0],sizeof(intptr_t) * MAXPLAYERS, 1, fil); } - else if (aGameVars[j].dwFlags & GAMEVAR_PERACTOR) + else if (aGameVars[j].nFlags & GAMEVAR_PERACTOR) { dfwrite(&MapInfo[i].savedstate->vars[j][0],sizeof(intptr_t), MAXSPRITES, fil); } @@ -360,30 +360,30 @@ void Gv_DumpValues(void) { OSD_Printf("gamevar %s ",aGameVars[i].szLabel); - if (aGameVars[i].dwFlags & (GAMEVAR_INTPTR)) - OSD_Printf("%d",*((int32_t *)aGameVars[i].val.lValue)); - else if (aGameVars[i].dwFlags & (GAMEVAR_SHORTPTR)) - OSD_Printf("%d",*((int16_t *)aGameVars[i].val.lValue)); - else if (aGameVars[i].dwFlags & (GAMEVAR_CHARPTR)) - OSD_Printf("%d",*((char *)aGameVars[i].val.lValue)); + if (aGameVars[i].nFlags & (GAMEVAR_INTPTR)) + OSD_Printf("%d",*((int32_t *)aGameVars[i].nValue)); + else if (aGameVars[i].nFlags & (GAMEVAR_SHORTPTR)) + OSD_Printf("%d",*((int16_t *)aGameVars[i].nValue)); + else if (aGameVars[i].nFlags & (GAMEVAR_CHARPTR)) + OSD_Printf("%d",*((char *)aGameVars[i].nValue)); else - OSD_Printf("%" PRIdPTR "",aGameVars[i].val.lValue); + OSD_Printf("%" PRIdPTR "",aGameVars[i].nValue); - if (aGameVars[i].dwFlags & (GAMEVAR_PERPLAYER)) + if (aGameVars[i].nFlags & (GAMEVAR_PERPLAYER)) OSD_Printf(" GAMEVAR_PERPLAYER"); - else if (aGameVars[i].dwFlags & (GAMEVAR_PERACTOR)) + else if (aGameVars[i].nFlags & (GAMEVAR_PERACTOR)) OSD_Printf(" GAMEVAR_PERACTOR"); else - OSD_Printf(" %" PRIdPTR,aGameVars[i].dwFlags/* & (GAMEVAR_USER_MASK)*/); + OSD_Printf(" %" PRIdPTR,aGameVars[i].nFlags/* & (GAMEVAR_USER_MASK)*/); OSD_Printf(" // "); - if (aGameVars[i].dwFlags & (GAMEVAR_SYSTEM)) + if (aGameVars[i].nFlags & (GAMEVAR_SYSTEM)) OSD_Printf(" (system)"); - if (aGameVars[i].dwFlags & (GAMEVAR_PTR_MASK)) + if (aGameVars[i].nFlags & (GAMEVAR_PTR_MASK)) OSD_Printf(" (pointer)"); - if (aGameVars[i].dwFlags & (GAMEVAR_READONLY)) + if (aGameVars[i].nFlags & (GAMEVAR_READONLY)) OSD_Printf(" (read only)"); - if (aGameVars[i].dwFlags & (GAMEVAR_SPECIAL)) + if (aGameVars[i].nFlags & (GAMEVAR_SPECIAL)) OSD_Printf(" (special)"); OSD_Printf("\n"); } @@ -401,14 +401,14 @@ void Gv_ResetVars(void) /* this is called during a new game and nowhere else */ { if (aGameVars[i].szLabel != NULL) Gv_NewVar(aGameVars[i].szLabel, - aGameVars[i].dwFlags & GAMEVAR_NODEFAULT ? aGameVars[i].val.lValue : aGameVars[i].lDefault, - aGameVars[i].dwFlags); + aGameVars[i].nFlags & GAMEVAR_NODEFAULT ? aGameVars[i].nValue : aGameVars[i].nDefault, + aGameVars[i].nFlags); } for (int i=0; i=0 && !(aGameArrays[i].dwFlags & GAMEARRAY_RESET))) + if (EDUKE32_PREDICT_FALSE(i >=0 && !(aGameArrays[i].nFlags & GAMEARRAY_RESET))) { // found it it's a duplicate in error g_numCompilerWarnings++; - if (aGameArrays[i].dwFlags&GAMEARRAY_TYPE_MASK) + if (aGameArrays[i].nFlags&GAMEARRAY_TYPE_MASK) { C_ReportError(-1); initprintf("ignored redefining system array `%s'.", pszLabel); @@ -460,20 +460,20 @@ int32_t Gv_NewArray(const char *pszLabel, void *arrayptr, intptr_t asize, uint32 if (!(dwFlags & GAMEARRAY_TYPE_MASK)) { - Baligned_free(aGameArrays[i].plValues); + Baligned_free(aGameArrays[i].pValues); if (asize != 0) { - aGameArrays[i].plValues = (intptr_t *)Xaligned_alloc(ACTOR_VAR_ALIGNMENT, asize * GAR_ELTSZ); - Bmemset(aGameArrays[i].plValues, 0, asize * GAR_ELTSZ); + aGameArrays[i].pValues = (intptr_t *)Xaligned_alloc(ACTOR_VAR_ALIGNMENT, asize * GAR_ELTSZ); + Bmemset(aGameArrays[i].pValues, 0, asize * GAR_ELTSZ); } else - aGameArrays[i].plValues = NULL; + aGameArrays[i].pValues = NULL; } else - aGameArrays[i].plValues=(intptr_t *)arrayptr; + aGameArrays[i].pValues=(intptr_t *)arrayptr; aGameArrays[i].size=asize; - aGameArrays[i].dwFlags = dwFlags & ~GAMEARRAY_RESET; + aGameArrays[i].nFlags = dwFlags & ~GAMEARRAY_RESET; g_gameArrayCount++; hash_add(&h_arrays, aGameArrays[i].szLabel, i, 1); @@ -506,16 +506,16 @@ int32_t Gv_NewVar(const char *pszLabel, intptr_t lValue, uint32_t dwFlags) i = hash_find(&h_gamevars,pszLabel); - if (i >= 0 && !(aGameVars[i].dwFlags & GAMEVAR_RESET)) + if (i >= 0 && !(aGameVars[i].nFlags & GAMEVAR_RESET)) { // found it... - if (EDUKE32_PREDICT_FALSE(aGameVars[i].dwFlags & (GAMEVAR_PTR_MASK))) + if (EDUKE32_PREDICT_FALSE(aGameVars[i].nFlags & (GAMEVAR_PTR_MASK))) { 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 (EDUKE32_PREDICT_FALSE(!(aGameVars[i].dwFlags & GAMEVAR_SYSTEM))) + else if (EDUKE32_PREDICT_FALSE(!(aGameVars[i].nFlags & GAMEVAR_SYSTEM))) { // it's a duplicate in error g_numCompilerWarnings++; @@ -528,7 +528,7 @@ int32_t Gv_NewVar(const char *pszLabel, intptr_t lValue, uint32_t dwFlags) i = g_gameVarCount; // If it's a user gamevar... - if ((aGameVars[i].dwFlags & GAMEVAR_SYSTEM) == 0) + if ((aGameVars[i].nFlags & GAMEVAR_SYSTEM) == 0) { // Allocate and set its label if (aGameVars[i].szLabel == NULL) @@ -538,16 +538,16 @@ int32_t Gv_NewVar(const char *pszLabel, intptr_t lValue, uint32_t dwFlags) Bstrcpy(aGameVars[i].szLabel,pszLabel); // and the flags - aGameVars[i].dwFlags=dwFlags; + aGameVars[i].nFlags=dwFlags; // only free if per-{actor,player} - if (aGameVars[i].dwFlags & GAMEVAR_USER_MASK) - ALIGNED_FREE_AND_NULL(aGameVars[i].val.plValues); + if (aGameVars[i].nFlags & GAMEVAR_USER_MASK) + ALIGNED_FREE_AND_NULL(aGameVars[i].pValues); } // if existing is system, they only get to change default value.... - aGameVars[i].lDefault = lValue; - aGameVars[i].dwFlags &= ~GAMEVAR_RESET; + aGameVars[i].nDefault = lValue; + aGameVars[i].nFlags &= ~GAMEVAR_RESET; if (i == g_gameVarCount) { @@ -556,27 +556,27 @@ int32_t Gv_NewVar(const char *pszLabel, intptr_t lValue, uint32_t dwFlags) } // Set initial values. (Or, override values for system gamevars.) - if (aGameVars[i].dwFlags & GAMEVAR_PERPLAYER) + if (aGameVars[i].nFlags & GAMEVAR_PERPLAYER) { - if (!aGameVars[i].val.plValues) + if (!aGameVars[i].pValues) { - aGameVars[i].val.plValues = (intptr_t *) Xaligned_alloc(PLAYER_VAR_ALIGNMENT, MAXPLAYERS * sizeof(intptr_t)); - Bmemset(aGameVars[i].val.plValues, 0, MAXPLAYERS * sizeof(intptr_t)); + aGameVars[i].pValues = (intptr_t *) Xaligned_alloc(PLAYER_VAR_ALIGNMENT, MAXPLAYERS * sizeof(intptr_t)); + Bmemset(aGameVars[i].pValues, 0, MAXPLAYERS * sizeof(intptr_t)); } for (j=MAXPLAYERS-1; j>=0; j--) - aGameVars[i].val.plValues[j]=lValue; + aGameVars[i].pValues[j]=lValue; } - else if (aGameVars[i].dwFlags & GAMEVAR_PERACTOR) + else if (aGameVars[i].nFlags & GAMEVAR_PERACTOR) { - if (!aGameVars[i].val.plValues) + if (!aGameVars[i].pValues) { - aGameVars[i].val.plValues = (intptr_t *) Xaligned_alloc(ACTOR_VAR_ALIGNMENT, MAXSPRITES * sizeof(intptr_t)); - Bmemset(aGameVars[i].val.plValues, 0, MAXSPRITES * sizeof(intptr_t)); + aGameVars[i].pValues = (intptr_t *) Xaligned_alloc(ACTOR_VAR_ALIGNMENT, MAXSPRITES * sizeof(intptr_t)); + Bmemset(aGameVars[i].pValues, 0, MAXSPRITES * sizeof(intptr_t)); } for (j=MAXSPRITES-1; j>=0; j--) - aGameVars[i].val.plValues[j]=lValue; + aGameVars[i].pValues[j]=lValue; } - else aGameVars[i].val.lValue = lValue; + else aGameVars[i].nValue = lValue; return 1; } @@ -594,131 +594,131 @@ static int32_t Gv_GetVarIndex(const char *szGameLabel) return i; } -int32_t __fastcall Gv_GetGameArrayValue(register int32_t const id, register int32_t index) +int32_t __fastcall Gv_GetGameArrayValue(int const id, int index) { - int rv = -1; - - if (aGameArrays[id].dwFlags & GAMEARRAY_STRIDE2) + if (aGameArrays[id].nFlags & GAMEARRAY_STRIDE2) index <<= 1; - switch (aGameArrays[id].dwFlags & GAMEARRAY_TYPE_MASK) + int rv = -1; + + switch (aGameArrays[id].nFlags & GAMEARRAY_TYPE_MASK) { - case 0: rv = (aGameArrays[id].plValues)[index]; break; - case GAMEARRAY_OFINT: rv = ((int32_t *) aGameArrays[id].plValues)[index]; break; - case GAMEARRAY_OFSHORT: rv = ((int16_t *) aGameArrays[id].plValues)[index]; break; - case GAMEARRAY_OFCHAR: rv = ((uint8_t *) aGameArrays[id].plValues)[index]; break; + case 0: rv = (aGameArrays[id].pValues)[index]; break; + case GAMEARRAY_OFINT: rv = ((int32_t *)aGameArrays[id].pValues)[index]; break; + case GAMEARRAY_OFSHORT: rv = ((int16_t *)aGameArrays[id].pValues)[index]; break; + case GAMEARRAY_OFCHAR: rv = ((uint8_t *)aGameArrays[id].pValues)[index]; break; } return rv; } -int32_t __fastcall Gv_GetVar(int32_t id, int32_t iActor, int32_t iPlayer) +int32_t __fastcall Gv_GetVar(int nGameVar, int nSprite, int nPlayer) { - if (id == g_iThisActorID) - return iActor; + if (nGameVar == g_iThisActorID) + return nSprite; - if (id == MAXGAMEVARS) + if (nGameVar == MAXGAMEVARS) return *insptr++; - int negateResult = !!(id & (MAXGAMEVARS << 1)); + int nNegative = !!(nGameVar & (MAXGAMEVARS << 1)); - if (EDUKE32_PREDICT_FALSE((id & ~(MAXGAMEVARS << 1)) >= g_gameVarCount)) + if (EDUKE32_PREDICT_FALSE((nGameVar & ~(MAXGAMEVARS << 1)) >= g_gameVarCount)) goto nastyhacks; - id &= (MAXGAMEVARS - 1); + nGameVar &= (MAXGAMEVARS - 1); - int rv, f; - f = aGameVars[id].dwFlags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK); + int nReturn, nFlags; + nFlags = aGameVars[nGameVar].nFlags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK); - if (f == GAMEVAR_PERACTOR) + if (nFlags == GAMEVAR_PERACTOR) { - if (EDUKE32_PREDICT_FALSE((unsigned) iActor >= MAXSPRITES)) goto badindex; - rv = aGameVars[id].val.plValues[iActor]; + if (EDUKE32_PREDICT_FALSE((unsigned) nSprite >= MAXSPRITES)) goto badindex; + nReturn = aGameVars[nGameVar].pValues[nSprite]; } - else if (!f) rv = aGameVars[id].val.lValue; - else if (f == GAMEVAR_PERPLAYER) + else if (!nFlags) nReturn = aGameVars[nGameVar].nValue; + else if (nFlags == GAMEVAR_PERPLAYER) { - if (EDUKE32_PREDICT_FALSE((unsigned) iPlayer >= MAXPLAYERS)) + if (EDUKE32_PREDICT_FALSE((unsigned) nPlayer >= MAXPLAYERS)) { - iActor = iPlayer; + nSprite = nPlayer; goto badindex; } - rv = aGameVars[id].val.plValues[iPlayer]; + nReturn = aGameVars[nGameVar].pValues[nPlayer]; } - else switch (f) + else switch (nFlags) { - case GAMEVAR_INTPTR: rv = *(int32_t *)aGameVars[id].val.lValue; break; - case GAMEVAR_SHORTPTR: rv = *(int16_t *)aGameVars[id].val.lValue; break; - case GAMEVAR_CHARPTR: rv = *(char *)aGameVars[id].val.lValue; break; - default: EDUKE32_UNREACHABLE_SECTION(rv = 0; break); + case GAMEVAR_INTPTR: nReturn = *(int32_t *)aGameVars[nGameVar].nValue; break; + case GAMEVAR_SHORTPTR: nReturn = *(int16_t *)aGameVars[nGameVar].nValue; break; + case GAMEVAR_CHARPTR: nReturn = *(char *)aGameVars[nGameVar].nValue; break; + default: EDUKE32_UNREACHABLE_SECTION(nReturn = 0; break); } - return (rv ^ -negateResult) + negateResult; + return (nReturn ^ -nNegative) + nNegative; nastyhacks: - if (id & (MAXGAMEVARS << 2)) // array + if (nGameVar & (MAXGAMEVARS << 2)) // array { - id &= (MAXGAMEVARS - 1); // ~((MAXGAMEVARS<<2)|(MAXGAMEVARS<<1)); + nGameVar &= (MAXGAMEVARS - 1); // ~((MAXGAMEVARS<<2)|(MAXGAMEVARS<<1)); - int32_t index = Gv_GetVar(*insptr++, iActor, iPlayer); + int nArrayIndex = Gv_GetVar(*insptr++, nSprite, nPlayer); - if (EDUKE32_PREDICT_FALSE((unsigned)index >= (unsigned)aGameArrays[id].size)) + if (EDUKE32_PREDICT_FALSE((unsigned)nArrayIndex >= (unsigned)aGameArrays[nGameVar].size)) { - iActor = index; + nSprite = nArrayIndex; goto badarrayindex; } - rv = Gv_GetGameArrayValue(id, index); + nReturn = Gv_GetGameArrayValue(nGameVar, nArrayIndex); } - else if (id&(MAXGAMEVARS<<3)) // struct shortcut vars + else if (nGameVar&(MAXGAMEVARS<<3)) // struct shortcut vars { - int indexvar = *insptr++; - int32_t index = Gv_GetVar(indexvar, iActor, iPlayer); + int nArrayIndexVar = *insptr++; + int nArrayIndex = Gv_GetVar(nArrayIndexVar, nSprite, nPlayer); - id &= (MAXGAMEVARS - 1); + nGameVar &= (MAXGAMEVARS - 1); - switch (id - g_iStructVarIDs) + switch (nGameVar - g_iStructVarIDs) { case STRUCT_SPRITE: { int const label = *insptr++; - indexvar = (EDUKE32_PREDICT_FALSE(ActorLabels[label].flags & LABEL_HASPARM2)) ? - Gv_GetVar(*insptr++, iActor, iPlayer) : 0; + nArrayIndexVar = (EDUKE32_PREDICT_FALSE(ActorLabels[label].flags & LABEL_HASPARM2)) ? + Gv_GetVar(*insptr++, nSprite, nPlayer) : 0; - if (EDUKE32_PREDICT_FALSE((unsigned) index >= MAXSPRITES)) + if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXSPRITES)) { - iActor = index; + nSprite = nArrayIndex; goto badindex; } - rv = VM_GetSprite(index, label, indexvar); + nReturn = VM_GetSprite(nArrayIndex, label, nArrayIndexVar); break; } case STRUCT_TSPR: { int const label = *insptr++; - if (EDUKE32_PREDICT_FALSE((unsigned) index >= MAXSPRITES)) + if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXSPRITES)) { - iActor = index; + nSprite = nArrayIndex; goto badindex; } - rv = VM_GetTsprite(index, label); + nReturn = VM_GetTsprite(nArrayIndex, label); break; } case STRUCT_THISPROJECTILE: { int const label = *insptr++; - if (EDUKE32_PREDICT_FALSE((unsigned) index >= MAXSPRITES)) + if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXSPRITES)) { - iActor = index; + nSprite = nArrayIndex; goto badindex; } - rv = VM_GetActiveProjectile(index, label); + nReturn = VM_GetActiveProjectile(nArrayIndex, label); break; } @@ -726,26 +726,26 @@ nastyhacks: { int const label = *insptr++; - if (EDUKE32_PREDICT_FALSE((unsigned) index >= MAXTILES)) + if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXTILES)) { - iActor = index; + nSprite = nArrayIndex; goto badindex; } - rv = VM_GetProjectile(index, label); + nReturn = VM_GetProjectile(nArrayIndex, label); break; } case STRUCT_TILEDATA: { int const label = *insptr++; - if (EDUKE32_PREDICT_FALSE((unsigned) index >= MAXTILES)) + if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXTILES)) { - iActor = index; + nSprite = nArrayIndex; goto badindex; } - rv = VM_GetTileData(index, label); + nReturn = VM_GetTileData(nArrayIndex, label); break; } @@ -753,13 +753,13 @@ nastyhacks: { int const label = *insptr++; - if (EDUKE32_PREDICT_FALSE((unsigned) index >= MAXPALOOKUPS)) + if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXPALOOKUPS)) { - iActor = index; + nSprite = nArrayIndex; goto badindex; } - rv = VM_GetPalData(index, label); + nReturn = VM_GetPalData(nArrayIndex, label); break; } @@ -767,64 +767,64 @@ nastyhacks: { int const label = *insptr++; - if (indexvar == g_iThisActorID) index = vm.g_p; + if (nArrayIndexVar == g_iThisActorID) nArrayIndex = vm.g_p; - indexvar = (EDUKE32_PREDICT_FALSE(PlayerLabels[label].flags & LABEL_HASPARM2)) ? - Gv_GetVar(*insptr++, iActor, iPlayer) : 0; + nArrayIndexVar = (EDUKE32_PREDICT_FALSE(PlayerLabels[label].flags & LABEL_HASPARM2)) ? + Gv_GetVar(*insptr++, nSprite, nPlayer) : 0; - if (EDUKE32_PREDICT_FALSE((unsigned) index >= MAXPLAYERS)) + if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXPLAYERS)) { - iActor = index; + nSprite = nArrayIndex; goto badindex; } - rv = VM_GetPlayer(index, label, indexvar); + nReturn = VM_GetPlayer(nArrayIndex, label, nArrayIndexVar); break; } case STRUCT_INPUT: { int const label = *insptr++; - if (indexvar == g_iThisActorID) index = vm.g_p; + if (nArrayIndexVar == g_iThisActorID) nArrayIndex = vm.g_p; - if (EDUKE32_PREDICT_FALSE((unsigned) index >= MAXPLAYERS)) + if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXPLAYERS)) { - iActor = index; + nSprite = nArrayIndex; goto badindex; } - rv = VM_GetPlayerInput(index, label); + nReturn = VM_GetPlayerInput(nArrayIndex, label); break; } case STRUCT_ACTORVAR: case STRUCT_PLAYERVAR: - rv = Gv_GetVar(*insptr++, index, iPlayer); + nReturn = Gv_GetVar(*insptr++, nArrayIndex, nPlayer); break; case STRUCT_SECTOR: - if (indexvar == g_iThisActorID) index = sprite[vm.g_i].sectnum; - if (EDUKE32_PREDICT_FALSE((unsigned) index >= MAXSECTORS)) + if (nArrayIndexVar == g_iThisActorID) nArrayIndex = sprite[vm.g_i].sectnum; + if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXSECTORS)) { - iActor = index; + nSprite = nArrayIndex; insptr++; goto badindex; } - rv = VM_GetSector(index, *insptr++); + nReturn = VM_GetSector(nArrayIndex, *insptr++); break; case STRUCT_WALL: - if (EDUKE32_PREDICT_FALSE((unsigned) index >= MAXWALLS)) + if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXWALLS)) { - iActor = index; + nSprite = nArrayIndex; insptr++; goto badindex; } - rv = VM_GetWall(index, *insptr++); + nReturn = VM_GetWall(nArrayIndex, *insptr++); break; case STRUCT_USERDEF: - rv = VM_GetUserdef(*insptr++); + nReturn = VM_GetUserdef(*insptr++); break; default: @@ -833,62 +833,63 @@ nastyhacks: } else { - CON_ERRPRINTF("Gv_GetVar(): invalid gamevar ID (%d)\n", id); + CON_ERRPRINTF("Gv_GetVar(): invalid gamevar ID (%d)\n", nGameVar); return -1; } - return (rv ^ -negateResult) + negateResult; + return (nReturn ^ -nNegative) + nNegative; badarrayindex: - CON_ERRPRINTF("Gv_GetVar(): invalid array index (%s[%d])\n", aGameArrays[id].szLabel,iActor); + CON_ERRPRINTF("Gv_GetVar(): invalid array index (%s[%d])\n", aGameArrays[nGameVar].szLabel,nSprite); return -1; badindex: - CON_ERRPRINTF("Gv_GetVar(): invalid index %d for \"%s\"\n", iActor, aGameVars[id].szLabel); + CON_ERRPRINTF("Gv_GetVar(): invalid index %d for \"%s\"\n", nSprite, aGameVars[nGameVar].szLabel); return -1; } -void __fastcall Gv_SetVar(int32_t const id, int32_t const lValue, int32_t const iActor, int32_t const iPlayer) +void __fastcall Gv_SetVar(int const nGameVar, int32_t const nValue, int const nSprite, int const nPlayer) { - int const f = aGameVars[id].dwFlags & (GAMEVAR_USER_MASK|GAMEVAR_PTR_MASK); + int const nFlags = aGameVars[nGameVar].nFlags & (GAMEVAR_USER_MASK|GAMEVAR_PTR_MASK); - if (EDUKE32_PREDICT_FALSE((unsigned)id >= (unsigned)g_gameVarCount)) goto badvarid; + if (EDUKE32_PREDICT_FALSE((unsigned)nGameVar >= (unsigned)g_gameVarCount)) goto badvarid; - if (!f) aGameVars[id].val.lValue=lValue; - else if (f == GAMEVAR_PERPLAYER) + if (!nFlags) aGameVars[nGameVar].nValue=nValue; + else if (nFlags == GAMEVAR_PERPLAYER) { - if (EDUKE32_PREDICT_FALSE((unsigned) iPlayer > MAXPLAYERS-1)) goto badindex; + if (EDUKE32_PREDICT_FALSE((unsigned) nPlayer > MAXPLAYERS-1)) goto badindex; // for the current player - aGameVars[id].val.plValues[iPlayer]=lValue; + aGameVars[nGameVar].pValues[nPlayer]=nValue; } - else if (f == GAMEVAR_PERACTOR) + else if (nFlags == GAMEVAR_PERACTOR) { - if (EDUKE32_PREDICT_FALSE((unsigned) iActor > MAXSPRITES-1)) goto badindex; - aGameVars[id].val.plValues[iActor]=lValue; + if (EDUKE32_PREDICT_FALSE((unsigned) nSprite > MAXSPRITES-1)) goto badindex; + aGameVars[nGameVar].pValues[nSprite]=nValue; } else { - switch (f) + switch (nFlags) { - case GAMEVAR_INTPTR: *((int32_t *)aGameVars[id].val.lValue) = (int32_t)lValue; break; - case GAMEVAR_SHORTPTR: *((int16_t *)aGameVars[id].val.lValue) = (int16_t)lValue; break; - case GAMEVAR_CHARPTR: *((uint8_t *)aGameVars[id].val.lValue) = (uint8_t)lValue; break; + case GAMEVAR_INTPTR: *((int32_t *)aGameVars[nGameVar].nValue) = (int32_t)nValue; break; + case GAMEVAR_SHORTPTR: *((int16_t *)aGameVars[nGameVar].nValue) = (int16_t)nValue; break; + case GAMEVAR_CHARPTR: *((uint8_t *)aGameVars[nGameVar].nValue) = (uint8_t)nValue; break; } } return; badvarid: CON_ERRPRINTF("Gv_SetVar(): invalid gamevar (%d) from sprite %d (%d), player %d\n", - id,vm.g_i,TrackerCast(sprite[vm.g_i].picnum),vm.g_p); + nGameVar,vm.g_i,TrackerCast(sprite[vm.g_i].picnum),vm.g_p); return; badindex: CON_ERRPRINTF("Gv_SetVar(): invalid index (%d) for gamevar %s from sprite %d, player %d\n", - aGameVars[id].dwFlags & GAMEVAR_PERACTOR ? iActor : iPlayer, - aGameVars[id].szLabel,vm.g_i,vm.g_p); + aGameVars[nGameVar].nFlags & GAMEVAR_PERACTOR ? nSprite : nPlayer, + aGameVars[nGameVar].szLabel,vm.g_i,vm.g_p); } -enum { +enum +{ GVX_BADVARID = 0, GVX_BADPLAYER, GVX_BADSPRITE, @@ -910,298 +911,296 @@ static const char *gvxerrs[] = { "Gv_GetVarX(): invalid pal ID", }; -int32_t __fastcall Gv_GetSpecialVarX(int32_t id) +int32_t __fastcall Gv_GetSpecialVarX(int nGameVar) { - int rv = -1; + int nReturn = -1; - if (id & (MAXGAMEVARS << 2)) // array + if (nGameVar & (MAXGAMEVARS << 2)) // array { - int const index = Gv_GetVarX(*insptr++); + int const nArrayIndex = Gv_GetVarX(*insptr++); - id &= (MAXGAMEVARS - 1); // ~((MAXGAMEVARS<<2)|(MAXGAMEVARS<<1)); + nGameVar &= (MAXGAMEVARS - 1); // ~((MAXGAMEVARS<<2)|(MAXGAMEVARS<<1)); - int const siz = (aGameArrays[id].dwFlags & GAMEARRAY_VARSIZE) ? - Gv_GetVarX(aGameArrays[id].size) : aGameArrays[id].size; + int const nArraySize = + (aGameArrays[nGameVar].nFlags & GAMEARRAY_VARSIZE) ? Gv_GetVarX(aGameArrays[nGameVar].size) : aGameArrays[nGameVar].size; - if (EDUKE32_PREDICT_FALSE((unsigned) index >= (unsigned) siz)) + if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= (unsigned) nArraySize)) { - CON_ERRPRINTF("%s %s[%d]\n", gvxerrs[GVX_BADINDEX], aGameArrays[id].szLabel, index); + CON_ERRPRINTF("%s %s[%d]\n", gvxerrs[GVX_BADINDEX], aGameArrays[nGameVar].szLabel, nArrayIndex); return -1; } - rv = Gv_GetGameArrayValue(id, index); + nReturn = Gv_GetGameArrayValue(nGameVar, nArrayIndex); } - else if (id & (MAXGAMEVARS << 3)) // struct shortcut vars + else if (nGameVar & (MAXGAMEVARS << 3)) // struct shortcut vars { - int indexvar = *insptr++; - int index = Gv_GetVarX(indexvar); + int nArrayIndexVar = *insptr++; + int nArrayIndex = Gv_GetVarX(nArrayIndexVar); - switch ((id & (MAXGAMEVARS - 1)) - g_iStructVarIDs) + switch ((nGameVar & (MAXGAMEVARS - 1)) - g_iStructVarIDs) { case STRUCT_SPRITE: { - int const label = *insptr++; + int const nLabel = *insptr++; - indexvar = (EDUKE32_PREDICT_FALSE(ActorLabels[label].flags & LABEL_HASPARM2)) ? + nArrayIndexVar = (EDUKE32_PREDICT_FALSE(ActorLabels[nLabel].flags & LABEL_HASPARM2)) ? Gv_GetVarX(*insptr++) : 0; - if (EDUKE32_PREDICT_FALSE((unsigned) index >= MAXSPRITES)) + if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXSPRITES)) { - id = index; - CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADSPRITE], id); + nGameVar = nArrayIndex; + CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADSPRITE], nGameVar); return -1; } - rv = VM_GetSprite(index, label, indexvar); + nReturn = VM_GetSprite(nArrayIndex, nLabel, nArrayIndexVar); break; } case STRUCT_TSPR: { - int const label = *insptr++; + int const nLabel = *insptr++; - if (EDUKE32_PREDICT_FALSE((unsigned) index >= MAXSPRITES)) + if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXSPRITES)) { - id = index; - CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADSPRITE], id); + nGameVar = nArrayIndex; + CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADSPRITE], nGameVar); return -1; } - rv = VM_GetTsprite(index, label); + nReturn = VM_GetTsprite(nArrayIndex, nLabel); break; } case STRUCT_THISPROJECTILE: { - int const label = *insptr++; + int const nLabel = *insptr++; - if (EDUKE32_PREDICT_FALSE((unsigned) index >= MAXSPRITES)) + if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXSPRITES)) { - id = index; - CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADSPRITE], id); + nGameVar = nArrayIndex; + CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADSPRITE], nGameVar); return -1; } - rv = VM_GetActiveProjectile(index, label); + nReturn = VM_GetActiveProjectile(nArrayIndex, nLabel); break; } case STRUCT_PROJECTILE: { - int const label = *insptr++; + int const nLabel = *insptr++; - if (EDUKE32_PREDICT_FALSE((unsigned) index >= MAXTILES)) + if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXTILES)) { - id = index; - CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADTILE], id); + nGameVar = nArrayIndex; + CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADTILE], nGameVar); return -1; } - rv = VM_GetProjectile(index, label); + nReturn = VM_GetProjectile(nArrayIndex, nLabel); break; } case STRUCT_TILEDATA: { - int const label = *insptr++; + int const nLabel = *insptr++; - if (EDUKE32_PREDICT_FALSE((unsigned) index >= MAXTILES)) + if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXTILES)) { - id = index; - CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADTILE], id); + nGameVar = nArrayIndex; + CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADTILE], nGameVar); return -1; } - rv = VM_GetTileData(index, label); + nReturn = VM_GetTileData(nArrayIndex, nLabel); break; } case STRUCT_PALDATA: { - int const label = *insptr++; + int const nLabel = *insptr++; - if (EDUKE32_PREDICT_FALSE((unsigned) index >= MAXPALOOKUPS)) + if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXPALOOKUPS)) { - id = index; - CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADPAL], id); + nGameVar = nArrayIndex; + CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADPAL], nGameVar); return -1; } - rv = VM_GetPalData(index, label); + nReturn = VM_GetPalData(nArrayIndex, nLabel); break; } case STRUCT_PLAYER: { - int const label = *insptr++; + int const nLabel = *insptr++; - if (indexvar == g_iThisActorID) - index = vm.g_p; + if (nArrayIndexVar == g_iThisActorID) + nArrayIndex = vm.g_p; - indexvar = (EDUKE32_PREDICT_FALSE(PlayerLabels[label].flags & LABEL_HASPARM2)) ? + nArrayIndexVar = (EDUKE32_PREDICT_FALSE(PlayerLabels[nLabel].flags & LABEL_HASPARM2)) ? Gv_GetVarX(*insptr++) : 0; - if (EDUKE32_PREDICT_FALSE((unsigned) index >= MAXPLAYERS)) + if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXPLAYERS)) { - id = index; - CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADPLAYER], id); + nGameVar = nArrayIndex; + CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADPLAYER], nGameVar); return -1; } - rv = VM_GetPlayer(index, label, indexvar); + nReturn = VM_GetPlayer(nArrayIndex, nLabel, nArrayIndexVar); break; } case STRUCT_INPUT: { - int const label = *insptr++; + int const nLabel = *insptr++; - if (indexvar == g_iThisActorID) - index = vm.g_p; + if (nArrayIndexVar == g_iThisActorID) + nArrayIndex = vm.g_p; - if (EDUKE32_PREDICT_FALSE((unsigned) index >= MAXPLAYERS)) + if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXPLAYERS)) { - id = index; - CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADPLAYER], id); + nGameVar = nArrayIndex; + CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADPLAYER], nGameVar); return -1; } - rv = VM_GetPlayerInput(index, label); + nReturn = VM_GetPlayerInput(nArrayIndex, nLabel); break; } case STRUCT_ACTORVAR: case STRUCT_PLAYERVAR: - rv = Gv_GetVar(*insptr++, index, vm.g_p); + nReturn = Gv_GetVar(*insptr++, nArrayIndex, vm.g_p); break; case STRUCT_SECTOR: - if (indexvar == g_iThisActorID) - index = sprite[vm.g_i].sectnum; + if (nArrayIndexVar == g_iThisActorID) + nArrayIndex = sprite[vm.g_i].sectnum; - if (EDUKE32_PREDICT_FALSE((unsigned) index >= MAXSECTORS)) + if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXSECTORS)) { - id = index; + nGameVar = nArrayIndex; insptr++; - CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADSECTOR], id); + CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADSECTOR], nGameVar); return -1; } - rv = VM_GetSector(index, *insptr++); + nReturn = VM_GetSector(nArrayIndex, *insptr++); break; case STRUCT_WALL: - if (EDUKE32_PREDICT_FALSE((unsigned) index >= MAXWALLS)) + if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXWALLS)) { - id = index; + nGameVar = nArrayIndex; insptr++; - CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADWALL], id); + CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADWALL], nGameVar); return -1; } - rv = VM_GetWall(index, *insptr++); + nReturn = VM_GetWall(nArrayIndex, *insptr++); break; case STRUCT_USERDEF: - rv = VM_GetUserdef(*insptr++); + nReturn = VM_GetUserdef(*insptr++); break; default: EDUKE32_UNREACHABLE_SECTION(return -1); } } - return rv; + return nReturn; } -int32_t __fastcall Gv_GetVarX(int32_t id) +int32_t __fastcall Gv_GetVarX(int nGameVar) { - if (id == g_iThisActorID) + if (nGameVar == g_iThisActorID) return vm.g_i; - if (id == MAXGAMEVARS) + if (nGameVar == MAXGAMEVARS) return *insptr++; - int const negateResult = !!(id & (MAXGAMEVARS << 1)); - int rv = -1; + int const nNegative = !!(nGameVar & (MAXGAMEVARS << 1)); + int nReturn = -1; - if (EDUKE32_PREDICT_FALSE(id >= g_gameVarCount && negateResult == 0)) - rv = Gv_GetSpecialVarX(id); + if (EDUKE32_PREDICT_FALSE(nGameVar >= g_gameVarCount && nNegative == 0)) + nReturn = Gv_GetSpecialVarX(nGameVar); else { - id &= MAXGAMEVARS-1; + nGameVar &= MAXGAMEVARS-1; - int const f = aGameVars[id].dwFlags & (GAMEVAR_USER_MASK|GAMEVAR_PTR_MASK); + int const nFlags = aGameVars[nGameVar].nFlags & (GAMEVAR_USER_MASK|GAMEVAR_PTR_MASK); - if (!f) rv = aGameVars[id].val.lValue; - else if (f == GAMEVAR_PERPLAYER) + if (!nFlags) nReturn = aGameVars[nGameVar].nValue; + else if (nFlags == GAMEVAR_PERPLAYER) { if (EDUKE32_PREDICT_FALSE((unsigned) vm.g_p >= MAXPLAYERS)) goto perr; - rv = aGameVars[id].val.plValues[vm.g_p]; + nReturn = aGameVars[nGameVar].pValues[vm.g_p]; } - else if (f == GAMEVAR_PERACTOR) - rv = aGameVars[id].val.plValues[vm.g_i]; - else switch (f) + else if (nFlags == GAMEVAR_PERACTOR) + nReturn = aGameVars[nGameVar].pValues[vm.g_i]; + else switch (nFlags) { - case GAMEVAR_INTPTR: - rv = (*((int32_t *) aGameVars[id].val.lValue)); break; - case GAMEVAR_SHORTPTR: - rv = (*((int16_t *) aGameVars[id].val.lValue)); break; - case GAMEVAR_CHARPTR: - rv = (*((uint8_t *) aGameVars[id].val.lValue)); break; + case GAMEVAR_INTPTR: nReturn = (*((int32_t *)aGameVars[nGameVar].nValue)); break; + case GAMEVAR_SHORTPTR: nReturn = (*((int16_t *)aGameVars[nGameVar].nValue)); break; + case GAMEVAR_CHARPTR: nReturn = (*((uint8_t *)aGameVars[nGameVar].nValue)); break; } - } - return (rv ^ -negateResult) + negateResult; + return (nReturn ^ -nNegative) + nNegative; perr: CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADPLAYER], vm.g_p); return -1; } -void __fastcall Gv_GetManyVars(int32_t const count, int32_t * const rv) +void __fastcall Gv_GetManyVars(int const count, int32_t * const rv) { for (int j = 0; j < count; ++j) { - int id = *insptr++; + int nGameVar = *insptr++; - if (id == g_iThisActorID) + if (nGameVar == g_iThisActorID) { rv[j] = vm.g_i; continue; } - if (id == MAXGAMEVARS) + if (nGameVar == MAXGAMEVARS) { rv[j] = *insptr++; continue; } - int const negateResult = !!(id & (MAXGAMEVARS << 1)); + int const nNegative = !!(nGameVar & (MAXGAMEVARS << 1)); - if (EDUKE32_PREDICT_FALSE(id >= g_gameVarCount && negateResult == 0)) + if (EDUKE32_PREDICT_FALSE(nGameVar >= g_gameVarCount && nNegative == 0)) { - rv[j] = Gv_GetSpecialVarX(id); + rv[j] = Gv_GetSpecialVarX(nGameVar); continue; } - id &= MAXGAMEVARS - 1; + nGameVar &= MAXGAMEVARS - 1; - int const f = aGameVars[id].dwFlags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK); - int val = aGameVars[id].val.lValue; + int const nFlags = aGameVars[nGameVar].nFlags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK); + int nValue = aGameVars[nGameVar].nValue; - if (f == GAMEVAR_PERPLAYER) + if (nFlags == GAMEVAR_PERPLAYER) { if (EDUKE32_PREDICT_FALSE((unsigned)vm.g_p >= MAXPLAYERS)) goto perr; - val = aGameVars[id].val.plValues[vm.g_p]; + nValue = aGameVars[nGameVar].pValues[vm.g_p]; } - else if (f == GAMEVAR_PERACTOR) - val = aGameVars[id].val.plValues[vm.g_i]; + else if (nFlags == GAMEVAR_PERACTOR) + nValue = aGameVars[nGameVar].pValues[vm.g_i]; else - switch (f) + { + switch (nFlags) { - case GAMEVAR_INTPTR: val = (*((int32_t *)aGameVars[id].val.lValue)); break; - case GAMEVAR_SHORTPTR: val = (*((int16_t *)aGameVars[id].val.lValue)); break; - case GAMEVAR_CHARPTR: val = (*((uint8_t *)aGameVars[id].val.lValue)); break; + case GAMEVAR_INTPTR: nValue = (*((int32_t *)aGameVars[nGameVar].nValue)); break; + case GAMEVAR_SHORTPTR: nValue = (*((int16_t *)aGameVars[nGameVar].nValue)); break; + case GAMEVAR_CHARPTR: nValue = (*((uint8_t *)aGameVars[nGameVar].nValue)); break; } + } - rv[j] = (val ^ -negateResult) + negateResult; + rv[j] = (nValue ^ -nNegative) + nNegative; continue; perr: @@ -1209,57 +1208,57 @@ void __fastcall Gv_GetManyVars(int32_t const count, int32_t * const rv) } } -void __fastcall Gv_SetVarX(int32_t const id, int32_t const lValue) +void __fastcall Gv_SetVarX(int const nGameVar, int32_t const nValue) { - int const f = aGameVars[id].dwFlags & (GAMEVAR_USER_MASK|GAMEVAR_PTR_MASK); + int const nFlags = aGameVars[nGameVar].nFlags & (GAMEVAR_USER_MASK|GAMEVAR_PTR_MASK); - if (!f) aGameVars[id].val.lValue = lValue; - else if (f == GAMEVAR_PERPLAYER) + if (!nFlags) aGameVars[nGameVar].nValue = nValue; + else if (nFlags == GAMEVAR_PERPLAYER) { if (EDUKE32_PREDICT_FALSE((unsigned)vm.g_p >= MAXPLAYERS)) goto badindex; - aGameVars[id].val.plValues[vm.g_p] = lValue; + aGameVars[nGameVar].pValues[vm.g_p] = nValue; } - else if (f == GAMEVAR_PERACTOR) + else if (nFlags == GAMEVAR_PERACTOR) { if (EDUKE32_PREDICT_FALSE((unsigned)vm.g_i >= MAXSPRITES)) goto badindex; - aGameVars[id].val.plValues[vm.g_i] = lValue; + aGameVars[nGameVar].pValues[vm.g_i] = nValue; } - else switch (f) + else switch (nFlags) { - case GAMEVAR_INTPTR: *((int32_t *)aGameVars[id].val.lValue) = (int32_t)lValue; break; - case GAMEVAR_SHORTPTR: *((int16_t *)aGameVars[id].val.lValue) = (int16_t)lValue; break; - case GAMEVAR_CHARPTR: *((uint8_t *)aGameVars[id].val.lValue) = (uint8_t)lValue; break; + case GAMEVAR_INTPTR: *((int32_t *)aGameVars[nGameVar].nValue) = (int32_t)nValue; break; + case GAMEVAR_SHORTPTR: *((int16_t *)aGameVars[nGameVar].nValue) = (int16_t)nValue; break; + case GAMEVAR_CHARPTR: *((uint8_t *)aGameVars[nGameVar].nValue) = (uint8_t)nValue; break; } return; badindex: CON_ERRPRINTF("Gv_SetVar(): invalid index (%d) for gamevar %s\n", - aGameVars[id].dwFlags & GAMEVAR_PERACTOR ? vm.g_i : vm.g_p, - aGameVars[id].szLabel); + aGameVars[nGameVar].nFlags & GAMEVAR_PERACTOR ? vm.g_i : vm.g_p, + aGameVars[nGameVar].szLabel); } -int32_t Gv_GetVarByLabel(const char *szGameLabel, int32_t const lDefault, int32_t const iActor, int32_t const iPlayer) +int32_t Gv_GetVarByLabel(const char *szGameLabel, int32_t const nDefault, int const nSprite, int const nPlayer) { - int32_t const i = hash_find(&h_gamevars,szGameLabel); - return EDUKE32_PREDICT_FALSE(i < 0) ? lDefault : Gv_GetVar(i, iActor, iPlayer); + int const nGameVar = hash_find(&h_gamevars, szGameLabel); + return EDUKE32_PREDICT_FALSE(nGameVar < 0) ? nDefault : Gv_GetVar(nGameVar, nSprite, nPlayer); } static intptr_t *Gv_GetVarDataPtr(const char *szGameLabel) { - int32_t const i = hash_find(&h_gamevars,szGameLabel); + int const nGameVar = hash_find(&h_gamevars, szGameLabel); - if (EDUKE32_PREDICT_FALSE(i < 0)) + if (EDUKE32_PREDICT_FALSE(nGameVar < 0)) return NULL; - if (aGameVars[i].dwFlags & (GAMEVAR_PERACTOR | GAMEVAR_PERPLAYER)) + if (aGameVars[nGameVar].nFlags & (GAMEVAR_PERACTOR | GAMEVAR_PERPLAYER)) { - if (EDUKE32_PREDICT_FALSE(!aGameVars[i].val.plValues)) + if (EDUKE32_PREDICT_FALSE(!aGameVars[nGameVar].pValues)) CON_ERRPRINTF("Gv_GetVarDataPtr(): INTERNAL ERROR: NULL array !!!\n"); - return aGameVars[i].val.plValues; + return aGameVars[nGameVar].pValues; } - return &(aGameVars[i].val.lValue); + return &(aGameVars[nGameVar].nValue); } #endif // !defined LUNATIC @@ -1271,70 +1270,69 @@ void Gv_ResetSystemDefaults(void) //AddLog("ResetWeaponDefaults"); - for (int i = 0; i < MAX_WEAPONS; ++i) + for (int nWeapon = 0; nWeapon < MAX_WEAPONS; ++nWeapon) { - for (int j = 0; j < MAXPLAYERS; ++j) + for (int nPlayer = 0; nPlayer < MAXPLAYERS; ++nPlayer) { - Bsprintf(aszBuf, "WEAPON%d_CLIP", i); - aplWeaponClip[i][j] = Gv_GetVarByLabel(aszBuf, 0, -1, j); - Bsprintf(aszBuf, "WEAPON%d_RELOAD", i); - aplWeaponReload[i][j] = Gv_GetVarByLabel(aszBuf, 0, -1, j); - Bsprintf(aszBuf, "WEAPON%d_FIREDELAY", i); - aplWeaponFireDelay[i][j] = Gv_GetVarByLabel(aszBuf, 0, -1, j); - Bsprintf(aszBuf, "WEAPON%d_TOTALTIME", i); - aplWeaponTotalTime[i][j] = Gv_GetVarByLabel(aszBuf, 0, -1, j); - Bsprintf(aszBuf, "WEAPON%d_HOLDDELAY", i); - aplWeaponHoldDelay[i][j] = Gv_GetVarByLabel(aszBuf, 0, -1, j); - Bsprintf(aszBuf, "WEAPON%d_FLAGS", i); - aplWeaponFlags[i][j] = Gv_GetVarByLabel(aszBuf, 0, -1, j); - Bsprintf(aszBuf, "WEAPON%d_SHOOTS", i); - aplWeaponShoots[i][j] = Gv_GetVarByLabel(aszBuf, 0, -1, j); - if ((unsigned)aplWeaponShoots[i][j] >= MAXTILES) - aplWeaponShoots[i][j] = 0; - Bsprintf(aszBuf, "WEAPON%d_SPAWNTIME", i); - aplWeaponSpawnTime[i][j] = Gv_GetVarByLabel(aszBuf, 0, -1, j); - Bsprintf(aszBuf, "WEAPON%d_SPAWN", i); - aplWeaponSpawn[i][j] = Gv_GetVarByLabel(aszBuf, 0, -1, j); - Bsprintf(aszBuf, "WEAPON%d_SHOTSPERBURST", i); - aplWeaponShotsPerBurst[i][j] = Gv_GetVarByLabel(aszBuf, 0, -1, j); - Bsprintf(aszBuf, "WEAPON%d_WORKSLIKE", i); - aplWeaponWorksLike[i][j] = Gv_GetVarByLabel(aszBuf, 0, -1, j); - Bsprintf(aszBuf, "WEAPON%d_INITIALSOUND", i); - aplWeaponInitialSound[i][j] = Gv_GetVarByLabel(aszBuf, 0, -1, j); - Bsprintf(aszBuf, "WEAPON%d_FIRESOUND", i); - aplWeaponFireSound[i][j] = Gv_GetVarByLabel(aszBuf, 0, -1, j); - Bsprintf(aszBuf, "WEAPON%d_SOUND2TIME", i); - aplWeaponSound2Time[i][j] = Gv_GetVarByLabel(aszBuf, 0, -1, j); - Bsprintf(aszBuf, "WEAPON%d_SOUND2SOUND", i); - aplWeaponSound2Sound[i][j] = Gv_GetVarByLabel(aszBuf, 0, -1, j); - Bsprintf(aszBuf, "WEAPON%d_RELOADSOUND1", i); - aplWeaponReloadSound1[i][j] = Gv_GetVarByLabel(aszBuf, 0, -1, j); - Bsprintf(aszBuf, "WEAPON%d_RELOADSOUND2", i); - aplWeaponReloadSound2[i][j] = Gv_GetVarByLabel(aszBuf, 0, -1, j); - Bsprintf(aszBuf, "WEAPON%d_SELECTSOUND", i); - aplWeaponSelectSound[i][j] = Gv_GetVarByLabel(aszBuf, 0, -1, j); - Bsprintf(aszBuf, "WEAPON%d_FLASHCOLOR", i); - aplWeaponFlashColor[i][j] = Gv_GetVarByLabel(aszBuf, 0, -1, j); + Bsprintf(aszBuf, "WEAPON%d_CLIP", nWeapon); + aplWeaponClip[nWeapon][nPlayer] = Gv_GetVarByLabel(aszBuf, 0, -1, nPlayer); + Bsprintf(aszBuf, "WEAPON%d_RELOAD", nWeapon); + aplWeaponReload[nWeapon][nPlayer] = Gv_GetVarByLabel(aszBuf, 0, -1, nPlayer); + Bsprintf(aszBuf, "WEAPON%d_FIREDELAY", nWeapon); + aplWeaponFireDelay[nWeapon][nPlayer] = Gv_GetVarByLabel(aszBuf, 0, -1, nPlayer); + Bsprintf(aszBuf, "WEAPON%d_TOTALTIME", nWeapon); + aplWeaponTotalTime[nWeapon][nPlayer] = Gv_GetVarByLabel(aszBuf, 0, -1, nPlayer); + Bsprintf(aszBuf, "WEAPON%d_HOLDDELAY", nWeapon); + aplWeaponHoldDelay[nWeapon][nPlayer] = Gv_GetVarByLabel(aszBuf, 0, -1, nPlayer); + Bsprintf(aszBuf, "WEAPON%d_FLAGS", nWeapon); + aplWeaponFlags[nWeapon][nPlayer] = Gv_GetVarByLabel(aszBuf, 0, -1, nPlayer); + Bsprintf(aszBuf, "WEAPON%d_SHOOTS", nWeapon); + aplWeaponShoots[nWeapon][nPlayer] = Gv_GetVarByLabel(aszBuf, 0, -1, nPlayer); + if ((unsigned)aplWeaponShoots[nWeapon][nPlayer] >= MAXTILES) + aplWeaponShoots[nWeapon][nPlayer] = 0; + Bsprintf(aszBuf, "WEAPON%d_SPAWNTIME", nWeapon); + aplWeaponSpawnTime[nWeapon][nPlayer] = Gv_GetVarByLabel(aszBuf, 0, -1, nPlayer); + Bsprintf(aszBuf, "WEAPON%d_SPAWN", nWeapon); + aplWeaponSpawn[nWeapon][nPlayer] = Gv_GetVarByLabel(aszBuf, 0, -1, nPlayer); + Bsprintf(aszBuf, "WEAPON%d_SHOTSPERBURST", nWeapon); + aplWeaponShotsPerBurst[nWeapon][nPlayer] = Gv_GetVarByLabel(aszBuf, 0, -1, nPlayer); + Bsprintf(aszBuf, "WEAPON%d_WORKSLIKE", nWeapon); + aplWeaponWorksLike[nWeapon][nPlayer] = Gv_GetVarByLabel(aszBuf, 0, -1, nPlayer); + Bsprintf(aszBuf, "WEAPON%d_INITIALSOUND", nWeapon); + aplWeaponInitialSound[nWeapon][nPlayer] = Gv_GetVarByLabel(aszBuf, 0, -1, nPlayer); + Bsprintf(aszBuf, "WEAPON%d_FIRESOUND", nWeapon); + aplWeaponFireSound[nWeapon][nPlayer] = Gv_GetVarByLabel(aszBuf, 0, -1, nPlayer); + Bsprintf(aszBuf, "WEAPON%d_SOUND2TIME", nWeapon); + aplWeaponSound2Time[nWeapon][nPlayer] = Gv_GetVarByLabel(aszBuf, 0, -1, nPlayer); + Bsprintf(aszBuf, "WEAPON%d_SOUND2SOUND", nWeapon); + aplWeaponSound2Sound[nWeapon][nPlayer] = Gv_GetVarByLabel(aszBuf, 0, -1, nPlayer); + Bsprintf(aszBuf, "WEAPON%d_RELOADSOUND1", nWeapon); + aplWeaponReloadSound1[nWeapon][nPlayer] = Gv_GetVarByLabel(aszBuf, 0, -1, nPlayer); + Bsprintf(aszBuf, "WEAPON%d_RELOADSOUND2", nWeapon); + aplWeaponReloadSound2[nWeapon][nPlayer] = Gv_GetVarByLabel(aszBuf, 0, -1, nPlayer); + Bsprintf(aszBuf, "WEAPON%d_SELECTSOUND", nWeapon); + aplWeaponSelectSound[nWeapon][nPlayer] = Gv_GetVarByLabel(aszBuf, 0, -1, nPlayer); + Bsprintf(aszBuf, "WEAPON%d_FLASHCOLOR", nWeapon); + aplWeaponFlashColor[nWeapon][nPlayer] = Gv_GetVarByLabel(aszBuf, 0, -1, nPlayer); } } - g_iReturnVarID = Gv_GetVarIndex("RETURN"); - g_iWeaponVarID = Gv_GetVarIndex("WEAPON"); + 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"); - - g_iStructVarIDs = Gv_GetVarIndex("sprite"); + 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"); + g_iStructVarIDs = Gv_GetVarIndex("sprite"); #endif - for (int i = 0; i <= MAXTILES - 1; i++) - if (g_tile[i].defproj) - *g_tile[i].proj = *g_tile[i].defproj; + for (int nWeapon = 0; nWeapon <= MAXTILES - 1; nWeapon++) + if (g_tile[nWeapon].defproj) + *g_tile[nWeapon].proj = *g_tile[nWeapon].defproj; //AddLog("EOF:ResetWeaponDefaults"); } @@ -1738,7 +1736,7 @@ void Gv_Init(void) { #if !defined LUNATIC // already initialized - if (aGameVars[0].dwFlags) + if (aGameVars[0].nFlags) return; Gv_Clear(); @@ -1816,87 +1814,87 @@ void Gv_InitWeaponPointers(void) void Gv_RefreshPointers(void) { - aGameVars[Gv_GetVarIndex("RESPAWN_MONSTERS")].val.lValue = (intptr_t)&ud.respawn_monsters; - aGameVars[Gv_GetVarIndex("RESPAWN_ITEMS")].val.lValue = (intptr_t)&ud.respawn_items; - aGameVars[Gv_GetVarIndex("RESPAWN_INVENTORY")].val.lValue = (intptr_t)&ud.respawn_inventory; - aGameVars[Gv_GetVarIndex("MONSTERS_OFF")].val.lValue = (intptr_t)&ud.monsters_off; - aGameVars[Gv_GetVarIndex("MARKER")].val.lValue = (intptr_t)&ud.marker; - aGameVars[Gv_GetVarIndex("FFIRE")].val.lValue = (intptr_t)&ud.ffire; - aGameVars[Gv_GetVarIndex("LEVEL")].val.lValue = (intptr_t)&ud.level_number; - aGameVars[Gv_GetVarIndex("VOLUME")].val.lValue = (intptr_t)&ud.volume_number; + aGameVars[Gv_GetVarIndex("RESPAWN_MONSTERS")].nValue = (intptr_t)&ud.respawn_monsters; + aGameVars[Gv_GetVarIndex("RESPAWN_ITEMS")].nValue = (intptr_t)&ud.respawn_items; + aGameVars[Gv_GetVarIndex("RESPAWN_INVENTORY")].nValue = (intptr_t)&ud.respawn_inventory; + aGameVars[Gv_GetVarIndex("MONSTERS_OFF")].nValue = (intptr_t)&ud.monsters_off; + aGameVars[Gv_GetVarIndex("MARKER")].nValue = (intptr_t)&ud.marker; + aGameVars[Gv_GetVarIndex("FFIRE")].nValue = (intptr_t)&ud.ffire; + aGameVars[Gv_GetVarIndex("LEVEL")].nValue = (intptr_t)&ud.level_number; + aGameVars[Gv_GetVarIndex("VOLUME")].nValue = (intptr_t)&ud.volume_number; - aGameVars[Gv_GetVarIndex("COOP")].val.lValue = (intptr_t)&ud.coop; - aGameVars[Gv_GetVarIndex("MULTIMODE")].val.lValue = (intptr_t)&ud.multimode; + aGameVars[Gv_GetVarIndex("COOP")].nValue = (intptr_t)&ud.coop; + aGameVars[Gv_GetVarIndex("MULTIMODE")].nValue = (intptr_t)&ud.multimode; - aGameVars[Gv_GetVarIndex("myconnectindex")].val.lValue = (intptr_t)&myconnectindex; - aGameVars[Gv_GetVarIndex("screenpeek")].val.lValue = (intptr_t)&screenpeek; - aGameVars[Gv_GetVarIndex("currentweapon")].val.lValue = (intptr_t)&hudweap.cur; - aGameVars[Gv_GetVarIndex("gs")].val.lValue = (intptr_t)&hudweap.shade; - aGameVars[Gv_GetVarIndex("looking_arc")].val.lValue = (intptr_t)&hudweap.lookhoriz; - aGameVars[Gv_GetVarIndex("gun_pos")].val.lValue = (intptr_t)&hudweap.gunposy; - aGameVars[Gv_GetVarIndex("weapon_xoffset")].val.lValue = (intptr_t)&hudweap.gunposx; - aGameVars[Gv_GetVarIndex("weaponcount")].val.lValue = (intptr_t)&hudweap.count; - aGameVars[Gv_GetVarIndex("looking_angSR1")].val.lValue = (intptr_t)&hudweap.lookhalfang; - aGameVars[Gv_GetVarIndex("xdim")].val.lValue = (intptr_t)&xdim; - aGameVars[Gv_GetVarIndex("ydim")].val.lValue = (intptr_t)&ydim; - aGameVars[Gv_GetVarIndex("windowx1")].val.lValue = (intptr_t)&windowxy1.x; - aGameVars[Gv_GetVarIndex("windowx2")].val.lValue = (intptr_t)&windowxy2.x; - aGameVars[Gv_GetVarIndex("windowy1")].val.lValue = (intptr_t)&windowxy1.y; - aGameVars[Gv_GetVarIndex("windowy2")].val.lValue = (intptr_t)&windowxy2.y; - aGameVars[Gv_GetVarIndex("totalclock")].val.lValue = (intptr_t)&totalclock; - aGameVars[Gv_GetVarIndex("lastvisinc")].val.lValue = (intptr_t)&lastvisinc; - aGameVars[Gv_GetVarIndex("numsectors")].val.lValue = (intptr_t)&numsectors; - aGameVars[Gv_GetVarIndex("numplayers")].val.lValue = (intptr_t)&numplayers; - aGameVars[Gv_GetVarIndex("current_menu")].val.lValue = (intptr_t)&g_currentMenu; - aGameVars[Gv_GetVarIndex("viewingrange")].val.lValue = (intptr_t)&viewingrange; - aGameVars[Gv_GetVarIndex("yxaspect")].val.lValue = (intptr_t)&yxaspect; - aGameVars[Gv_GetVarIndex("gravitationalconstant")].val.lValue = (intptr_t)&g_spriteGravity; - aGameVars[Gv_GetVarIndex("gametype_flags")].val.lValue = (intptr_t)&GametypeFlags[ud.coop]; - aGameVars[Gv_GetVarIndex("framerate")].val.lValue = (intptr_t)&g_currentFrameRate; + aGameVars[Gv_GetVarIndex("myconnectindex")].nValue = (intptr_t)&myconnectindex; + aGameVars[Gv_GetVarIndex("screenpeek")].nValue = (intptr_t)&screenpeek; + aGameVars[Gv_GetVarIndex("currentweapon")].nValue = (intptr_t)&hudweap.cur; + aGameVars[Gv_GetVarIndex("gs")].nValue = (intptr_t)&hudweap.shade; + aGameVars[Gv_GetVarIndex("looking_arc")].nValue = (intptr_t)&hudweap.lookhoriz; + aGameVars[Gv_GetVarIndex("gun_pos")].nValue = (intptr_t)&hudweap.gunposy; + aGameVars[Gv_GetVarIndex("weapon_xoffset")].nValue = (intptr_t)&hudweap.gunposx; + aGameVars[Gv_GetVarIndex("weaponcount")].nValue = (intptr_t)&hudweap.count; + aGameVars[Gv_GetVarIndex("looking_angSR1")].nValue = (intptr_t)&hudweap.lookhalfang; + aGameVars[Gv_GetVarIndex("xdim")].nValue = (intptr_t)&xdim; + aGameVars[Gv_GetVarIndex("ydim")].nValue = (intptr_t)&ydim; + aGameVars[Gv_GetVarIndex("windowx1")].nValue = (intptr_t)&windowxy1.x; + aGameVars[Gv_GetVarIndex("windowx2")].nValue = (intptr_t)&windowxy2.x; + aGameVars[Gv_GetVarIndex("windowy1")].nValue = (intptr_t)&windowxy1.y; + aGameVars[Gv_GetVarIndex("windowy2")].nValue = (intptr_t)&windowxy2.y; + aGameVars[Gv_GetVarIndex("totalclock")].nValue = (intptr_t)&totalclock; + aGameVars[Gv_GetVarIndex("lastvisinc")].nValue = (intptr_t)&lastvisinc; + aGameVars[Gv_GetVarIndex("numsectors")].nValue = (intptr_t)&numsectors; + aGameVars[Gv_GetVarIndex("numplayers")].nValue = (intptr_t)&numplayers; + aGameVars[Gv_GetVarIndex("current_menu")].nValue = (intptr_t)&g_currentMenu; + aGameVars[Gv_GetVarIndex("viewingrange")].nValue = (intptr_t)&viewingrange; + aGameVars[Gv_GetVarIndex("yxaspect")].nValue = (intptr_t)&yxaspect; + aGameVars[Gv_GetVarIndex("gravitationalconstant")].nValue = (intptr_t)&g_spriteGravity; + aGameVars[Gv_GetVarIndex("gametype_flags")].nValue = (intptr_t)&GametypeFlags[ud.coop]; + aGameVars[Gv_GetVarIndex("framerate")].nValue = (intptr_t)&g_currentFrameRate; - aGameVars[Gv_GetVarIndex("camerax")].val.lValue = (intptr_t)&ud.camerapos.x; - aGameVars[Gv_GetVarIndex("cameray")].val.lValue = (intptr_t)&ud.camerapos.y; - aGameVars[Gv_GetVarIndex("cameraz")].val.lValue = (intptr_t)&ud.camerapos.z; - aGameVars[Gv_GetVarIndex("cameraang")].val.lValue = (intptr_t)&ud.cameraang; - aGameVars[Gv_GetVarIndex("camerahoriz")].val.lValue = (intptr_t)&ud.camerahoriz; - aGameVars[Gv_GetVarIndex("camerasect")].val.lValue = (intptr_t)&ud.camerasect; - aGameVars[Gv_GetVarIndex("cameradist")].val.lValue = (intptr_t)&g_cameraDistance; - aGameVars[Gv_GetVarIndex("cameraclock")].val.lValue = (intptr_t)&g_cameraClock; + aGameVars[Gv_GetVarIndex("camerax")].nValue = (intptr_t)&ud.camerapos.x; + aGameVars[Gv_GetVarIndex("cameray")].nValue = (intptr_t)&ud.camerapos.y; + aGameVars[Gv_GetVarIndex("cameraz")].nValue = (intptr_t)&ud.camerapos.z; + aGameVars[Gv_GetVarIndex("cameraang")].nValue = (intptr_t)&ud.cameraang; + aGameVars[Gv_GetVarIndex("camerahoriz")].nValue = (intptr_t)&ud.camerahoriz; + aGameVars[Gv_GetVarIndex("camerasect")].nValue = (intptr_t)&ud.camerasect; + aGameVars[Gv_GetVarIndex("cameradist")].nValue = (intptr_t)&g_cameraDistance; + aGameVars[Gv_GetVarIndex("cameraclock")].nValue = (intptr_t)&g_cameraClock; - aGameVars[Gv_GetVarIndex("myx")].val.lValue = (intptr_t)&my.x; - aGameVars[Gv_GetVarIndex("myy")].val.lValue = (intptr_t)&my.y; - aGameVars[Gv_GetVarIndex("myz")].val.lValue = (intptr_t)&my.z; - aGameVars[Gv_GetVarIndex("omyx")].val.lValue = (intptr_t)&omy.x; - aGameVars[Gv_GetVarIndex("omyy")].val.lValue = (intptr_t)&omy.y; - aGameVars[Gv_GetVarIndex("omyz")].val.lValue = (intptr_t)&omy.z; - aGameVars[Gv_GetVarIndex("myvelx")].val.lValue = (intptr_t)&myvel.x; - aGameVars[Gv_GetVarIndex("myvely")].val.lValue = (intptr_t)&myvel.y; - aGameVars[Gv_GetVarIndex("myvelz")].val.lValue = (intptr_t)&myvel.z; + aGameVars[Gv_GetVarIndex("myx")].nValue = (intptr_t)&my.x; + aGameVars[Gv_GetVarIndex("myy")].nValue = (intptr_t)&my.y; + aGameVars[Gv_GetVarIndex("myz")].nValue = (intptr_t)&my.z; + aGameVars[Gv_GetVarIndex("omyx")].nValue = (intptr_t)&omy.x; + aGameVars[Gv_GetVarIndex("omyy")].nValue = (intptr_t)&omy.y; + aGameVars[Gv_GetVarIndex("omyz")].nValue = (intptr_t)&omy.z; + aGameVars[Gv_GetVarIndex("myvelx")].nValue = (intptr_t)&myvel.x; + aGameVars[Gv_GetVarIndex("myvely")].nValue = (intptr_t)&myvel.y; + aGameVars[Gv_GetVarIndex("myvelz")].nValue = (intptr_t)&myvel.z; - aGameVars[Gv_GetVarIndex("myhoriz")].val.lValue = (intptr_t)&myhoriz; - aGameVars[Gv_GetVarIndex("myhorizoff")].val.lValue = (intptr_t)&myhorizoff; - aGameVars[Gv_GetVarIndex("omyhoriz")].val.lValue = (intptr_t)&omyhoriz; - aGameVars[Gv_GetVarIndex("omyhorizoff")].val.lValue = (intptr_t)&omyhorizoff; - aGameVars[Gv_GetVarIndex("myang")].val.lValue = (intptr_t)&myang; - aGameVars[Gv_GetVarIndex("omyang")].val.lValue = (intptr_t)&omyang; - aGameVars[Gv_GetVarIndex("mycursectnum")].val.lValue = (intptr_t)&mycursectnum; - aGameVars[Gv_GetVarIndex("myjumpingcounter")].val.lValue = (intptr_t)&myjumpingcounter; + aGameVars[Gv_GetVarIndex("myhoriz")].nValue = (intptr_t)&myhoriz; + aGameVars[Gv_GetVarIndex("myhorizoff")].nValue = (intptr_t)&myhorizoff; + aGameVars[Gv_GetVarIndex("omyhoriz")].nValue = (intptr_t)&omyhoriz; + aGameVars[Gv_GetVarIndex("omyhorizoff")].nValue = (intptr_t)&omyhorizoff; + aGameVars[Gv_GetVarIndex("myang")].nValue = (intptr_t)&myang; + aGameVars[Gv_GetVarIndex("omyang")].nValue = (intptr_t)&omyang; + aGameVars[Gv_GetVarIndex("mycursectnum")].nValue = (intptr_t)&mycursectnum; + aGameVars[Gv_GetVarIndex("myjumpingcounter")].nValue = (intptr_t)&myjumpingcounter; - aGameVars[Gv_GetVarIndex("myjumpingtoggle")].val.lValue = (intptr_t)&myjumpingtoggle; - aGameVars[Gv_GetVarIndex("myonground")].val.lValue = (intptr_t)&myonground; - aGameVars[Gv_GetVarIndex("myhardlanding")].val.lValue = (intptr_t)&myhardlanding; - aGameVars[Gv_GetVarIndex("myreturntocenter")].val.lValue = (intptr_t)&myreturntocenter; + aGameVars[Gv_GetVarIndex("myjumpingtoggle")].nValue = (intptr_t)&myjumpingtoggle; + aGameVars[Gv_GetVarIndex("myonground")].nValue = (intptr_t)&myonground; + aGameVars[Gv_GetVarIndex("myhardlanding")].nValue = (intptr_t)&myhardlanding; + aGameVars[Gv_GetVarIndex("myreturntocenter")].nValue = (intptr_t)&myreturntocenter; - aGameVars[Gv_GetVarIndex("display_mirror")].val.lValue = (intptr_t)&display_mirror; - aGameVars[Gv_GetVarIndex("randomseed")].val.lValue = (intptr_t)&randomseed; + aGameVars[Gv_GetVarIndex("display_mirror")].nValue = (intptr_t)&display_mirror; + aGameVars[Gv_GetVarIndex("randomseed")].nValue = (intptr_t)&randomseed; - aGameVars[Gv_GetVarIndex("NUMWALLS")].val.lValue = (intptr_t)&numwalls; - aGameVars[Gv_GetVarIndex("NUMSECTORS")].val.lValue = (intptr_t)&numsectors; - aGameVars[Gv_GetVarIndex("Numsprites")].val.lValue = (intptr_t)&Numsprites; + aGameVars[Gv_GetVarIndex("NUMWALLS")].nValue = (intptr_t)&numwalls; + aGameVars[Gv_GetVarIndex("NUMSECTORS")].nValue = (intptr_t)&numsectors; + aGameVars[Gv_GetVarIndex("Numsprites")].nValue = (intptr_t)&Numsprites; - aGameVars[Gv_GetVarIndex("lastsavepos")].val.lValue = (intptr_t)&g_lastSaveSlot; + aGameVars[Gv_GetVarIndex("lastsavepos")].nValue = (intptr_t)&g_lastSaveSlot; # ifdef USE_OPENGL - aGameVars[Gv_GetVarIndex("rendmode")].val.lValue = (intptr_t)&rendmode; + aGameVars[Gv_GetVarIndex("rendmode")].nValue = (intptr_t)&rendmode; # endif } #endif diff --git a/polymer/eduke32/source/gamevars.h b/polymer/eduke32/source/gamevars.h index da39505db..6883add25 100644 --- a/polymer/eduke32/source/gamevars.h +++ b/polymer/eduke32/source/gamevars.h @@ -29,22 +29,23 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #define MAXVARLABEL 26 // store global game definitions -enum GamevarFlags_t { - GAMEVAR_PERPLAYER = 0x00000001, // per-player variable - GAMEVAR_PERACTOR = 0x00000002, // per-actor variable - GAMEVAR_USER_MASK = (GAMEVAR_PERPLAYER|GAMEVAR_PERACTOR), - GAMEVAR_RESET = 0x00000008, // INTERNAL, don't use - GAMEVAR_DEFAULT = 0x00000100, // UNUSED, but always cleared for user-defined gamevars - GAMEVAR_NODEFAULT = 0x00000400, // don't reset on actor spawn - GAMEVAR_SYSTEM = 0x00000800, // cannot change mode flags...(only default value) - GAMEVAR_READONLY = 0x00001000, // values are read-only (no setvar allowed) - GAMEVAR_INTPTR = 0x00002000, // plValues is a pointer to an int32_t - GAMEVAR_SHORTPTR = 0x00008000, // plValues is a pointer to a short - GAMEVAR_CHARPTR = 0x00010000, // plValues is a pointer to a char - GAMEVAR_PTR_MASK = (GAMEVAR_INTPTR|GAMEVAR_SHORTPTR|GAMEVAR_CHARPTR), - GAMEVAR_NORESET = 0x00020000, // var values are not reset when restoring map state - GAMEVAR_SPECIAL = 0x00040000, // flag for structure member shortcut vars - GAMEVAR_NOMULTI = 0x00080000, // don't attach to multiplayer packets +enum GamevarFlags_t +{ + GAMEVAR_PERPLAYER = 0x00000001, // per-player variable + GAMEVAR_PERACTOR = 0x00000002, // per-actor variable + GAMEVAR_USER_MASK = (GAMEVAR_PERPLAYER | GAMEVAR_PERACTOR), + GAMEVAR_RESET = 0x00000008, // INTERNAL, don't use + GAMEVAR_DEFAULT = 0x00000100, // UNUSED, but always cleared for user-defined gamevars + GAMEVAR_NODEFAULT = 0x00000400, // don't reset on actor spawn + GAMEVAR_SYSTEM = 0x00000800, // cannot change mode flags...(only default value) + GAMEVAR_READONLY = 0x00001000, // values are read-only (no setvar allowed) + GAMEVAR_INTPTR = 0x00002000, // plValues is a pointer to an int32_t + GAMEVAR_SHORTPTR = 0x00008000, // plValues is a pointer to a short + GAMEVAR_CHARPTR = 0x00010000, // plValues is a pointer to a char + GAMEVAR_PTR_MASK = (GAMEVAR_INTPTR | GAMEVAR_SHORTPTR | GAMEVAR_CHARPTR), + GAMEVAR_NORESET = 0x00020000, // var values are not reset when restoring map state + GAMEVAR_SPECIAL = 0x00040000, // flag for structure member shortcut vars + GAMEVAR_NOMULTI = 0x00080000, // don't attach to multiplayer packets }; #if !defined LUNATIC @@ -56,69 +57,67 @@ enum GamevarFlags_t { # define MAXGAMEARRAYS (MAXGAMEVARS>>2) // must be strictly smaller than MAXGAMEVARS # define MAXARRAYLABEL MAXVARLABEL -enum GamearrayFlags_t { - - GAMEARRAY_READONLY = 0x00001000, - GAMEARRAY_WARN = 0x00002000, - - GAMEARRAY_NORMAL = 0x00004000, - GAMEARRAY_OFCHAR = 0x00000001, - GAMEARRAY_OFSHORT = 0x00000002, - GAMEARRAY_OFINT = 0x00000004, - GAMEARRAY_RESET = 0x00000008, - GAMEARRAY_TYPE_MASK = GAMEARRAY_OFCHAR|GAMEARRAY_OFSHORT|GAMEARRAY_OFINT, - GAMEARRAY_RESTORE = 0x00000010, - - GAMEARRAY_VARSIZE = 0x00000020, - - GAMEARRAY_STRIDE2 = 0x00000100, - +enum GamearrayFlags_t +{ + GAMEARRAY_READONLY = 0x00001000, + GAMEARRAY_WARN = 0x00002000, + GAMEARRAY_NORMAL = 0x00004000, + GAMEARRAY_OFCHAR = 0x00000001, + GAMEARRAY_OFSHORT = 0x00000002, + GAMEARRAY_OFINT = 0x00000004, + GAMEARRAY_RESET = 0x00000008, + GAMEARRAY_TYPE_MASK = GAMEARRAY_OFCHAR | GAMEARRAY_OFSHORT | GAMEARRAY_OFINT, + GAMEARRAY_RESTORE = 0x00000010, + GAMEARRAY_VARSIZE = 0x00000020, + GAMEARRAY_STRIDE2 = 0x00000100, }; #pragma pack(push,1) -typedef struct { +typedef struct +{ union { - intptr_t lValue; - intptr_t *plValues; // array of values when 'per-player', or 'per-actor' - } val; - intptr_t lDefault; - uintptr_t dwFlags; - char *szLabel; + intptr_t nValue; + intptr_t *pValues; // array of values when 'per-player', or 'per-actor' + }; + intptr_t nDefault; + uintptr_t nFlags; + char * szLabel; } gamevar_t; -typedef struct { - char *szLabel; - intptr_t *plValues; // array of values - intptr_t size; - intptr_t dwFlags; +typedef struct +{ + char * szLabel; + intptr_t *pValues; // array of values + intptr_t size; + intptr_t nFlags; } gamearray_t; #pragma pack(pop) -# define GAR_ELTSZ (sizeof(aGameArrays[0].plValues[0])) +# define GAR_ELTSZ (sizeof(aGameArrays[0].pValues[0])) -extern gamevar_t aGameVars[MAXGAMEVARS]; +extern gamevar_t aGameVars[MAXGAMEVARS]; extern gamearray_t aGameArrays[MAXGAMEARRAYS]; -extern int32_t g_gameVarCount; -extern int32_t g_gameArrayCount; +extern int32_t g_gameVarCount; +extern int32_t g_gameArrayCount; -int32_t __fastcall Gv_GetGameArrayValue(register int32_t const id, register int32_t index); -int32_t __fastcall Gv_GetVar(int32_t id, int32_t iActor, int32_t iPlayer); -void __fastcall Gv_SetVar(int32_t const id, int32_t const lValue, int32_t const iActor, int32_t const iPlayer); -int32_t __fastcall Gv_GetVarX(int32_t id); -void __fastcall Gv_GetManyVars(int32_t const count, int32_t * const rv); -void __fastcall Gv_SetVarX(int32_t const id, int32_t const lValue); +int32_t __fastcall Gv_GetGameArrayValue(int const id, int index); +int32_t __fastcall Gv_GetVar(int id, int nSprite, int nPlayer); +void __fastcall Gv_SetVar(int const id, int32_t const lValue, int const nSprite, int const nPlayer); +int32_t __fastcall Gv_GetVarX(int id); +void __fastcall Gv_GetManyVars(int const count, int32_t * const rv); +void __fastcall Gv_SetVarX(int const id, int32_t const lValue); int32_t Gv_GetVarByLabel(const char *szGameLabel,int32_t const lDefault,int32_t const iActor,int32_t const iPlayer); int32_t Gv_NewArray(const char *pszLabel,void *arrayptr,intptr_t asize,uint32_t dwFlags); int32_t Gv_NewVar(const char *pszLabel,intptr_t lValue,uint32_t dwFlags); -FORCE_INLINE void A_ResetVars(const int32_t iActor) +FORCE_INLINE void A_ResetVars(int const nSprite) { for (int i = 0; i < g_gameVarCount; ++i) { - if ((aGameVars[i].dwFlags & (GAMEVAR_PERACTOR | GAMEVAR_NODEFAULT)) != GAMEVAR_PERACTOR) + if ((aGameVars[i].nFlags & (GAMEVAR_PERACTOR | GAMEVAR_NODEFAULT)) != GAMEVAR_PERACTOR) continue; - aGameVars[i].val.plValues[iActor] = aGameVars[i].lDefault; + aGameVars[i].pValues[nSprite] = aGameVars[i].nDefault; } } @@ -138,62 +137,62 @@ void Gv_Init(void); void Gv_FinalizeWeaponDefaults(void); #if !defined LUNATIC -#define VM_GAMEVAR_OPERATOR(func, operator) \ - FORCE_INLINE void __fastcall func(const int32_t id, const int32_t lValue) \ - { \ - switch (aGameVars[id].dwFlags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK)) \ - { \ - default: aGameVars[id].val.lValue operator lValue; break; \ - case GAMEVAR_PERPLAYER: \ - if (EDUKE32_PREDICT_FALSE((unsigned)vm.g_p > MAXPLAYERS - 1)) \ - break; \ - aGameVars[id].val.plValues[vm.g_p] operator lValue; \ - break; \ - case GAMEVAR_PERACTOR: \ - if (EDUKE32_PREDICT_FALSE((unsigned)vm.g_i > MAXSPRITES - 1)) \ - break; \ - aGameVars[id].val.plValues[vm.g_i] operator lValue; \ - break; \ - case GAMEVAR_INTPTR: *((int32_t *)aGameVars[id].val.lValue) operator (int32_t) lValue; break; \ - case GAMEVAR_SHORTPTR: *((int16_t *)aGameVars[id].val.lValue) operator (int16_t) lValue; break; \ - case GAMEVAR_CHARPTR: *((uint8_t *)aGameVars[id].val.lValue) operator (uint8_t) lValue; break; \ - } \ +#define VM_GAMEVAR_OPERATOR(func, operator) \ + FORCE_INLINE void __fastcall func(int const id, int32_t const nValue) \ + { \ + switch (aGameVars[id].nFlags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK)) \ + { \ + default: aGameVars[id].nValue operator nValue; break; \ + case GAMEVAR_PERPLAYER: \ + if (EDUKE32_PREDICT_FALSE((unsigned)vm.g_p > MAXPLAYERS - 1)) \ + break; \ + aGameVars[id].pValues[vm.g_p] operator nValue; \ + break; \ + case GAMEVAR_PERACTOR: \ + if (EDUKE32_PREDICT_FALSE((unsigned)vm.g_i > MAXSPRITES - 1)) \ + break; \ + aGameVars[id].pValues[vm.g_i] operator nValue; \ + break; \ + case GAMEVAR_INTPTR: *((int32_t *)aGameVars[id].nValue) operator(int32_t) nValue; break; \ + case GAMEVAR_SHORTPTR: *((int16_t *)aGameVars[id].nValue) operator(int16_t) nValue; break; \ + case GAMEVAR_CHARPTR: *((uint8_t *)aGameVars[id].nValue) operator(uint8_t) nValue; break; \ + } \ } #if defined(__arm__) || defined(LIBDIVIDE_ALWAYS) -FORCE_INLINE void __fastcall Gv_DivVar(const int32_t id, const int32_t lValue) +FORCE_INLINE void __fastcall Gv_DivVar(int const id, int32_t const nValue) { - if (EDUKE32_PREDICT_FALSE((aGameVars[id].dwFlags & GAMEVAR_PERPLAYER && (unsigned) vm.g_p > MAXPLAYERS - 1) || - (aGameVars[id].dwFlags & GAMEVAR_PERACTOR && (unsigned) vm.g_i > MAXSPRITES - 1))) + if (EDUKE32_PREDICT_FALSE((aGameVars[id].nFlags & GAMEVAR_PERPLAYER && (unsigned) vm.g_p > MAXPLAYERS - 1) || + (aGameVars[id].nFlags & GAMEVAR_PERACTOR && (unsigned) vm.g_i > MAXSPRITES - 1))) return; static libdivide_s32_t sdiv; - static int32_t lastlValue; - libdivide_s32_t *dptr = ((unsigned) lValue < DIVTABLESIZE) ? (libdivide_s32_t *) &divtable32[lValue] : &sdiv; - intptr_t *iptr = &aGameVars[id].val.lValue; + static int32_t nLastValue; + libdivide_s32_t *dptr = ((unsigned) nValue < DIVTABLESIZE) ? (libdivide_s32_t *) &divtable32[nValue] : &sdiv; + intptr_t *iptr = &aGameVars[id].nValue; - if (lValue == lastlValue || dptr != &sdiv) + if (nValue == nLastValue || dptr != &sdiv) goto skip; - sdiv = libdivide_s32_gen((lastlValue = lValue)); + sdiv = libdivide_s32_gen((nLastValue = nValue)); skip: - switch (aGameVars[id].dwFlags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK)) + switch (aGameVars[id].nFlags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK)) { - case GAMEVAR_PERPLAYER: iptr = &aGameVars[id].val.plValues[vm.g_p]; + case GAMEVAR_PERPLAYER: iptr = &aGameVars[id].pValues[vm.g_p]; default: break; - case GAMEVAR_PERACTOR: iptr = &aGameVars[id].val.plValues[vm.g_i]; break; + case GAMEVAR_PERACTOR: iptr = &aGameVars[id].pValues[vm.g_i]; break; case GAMEVAR_INTPTR: - *((int32_t *)aGameVars[id].val.lValue) = - (int32_t)libdivide_s32_do(*((int32_t *)aGameVars[id].val.lValue), dptr); + *((int32_t *)aGameVars[id].nValue) = + (int32_t)libdivide_s32_do(*((int32_t *)aGameVars[id].nValue), dptr); return; case GAMEVAR_SHORTPTR: - *((int16_t *)aGameVars[id].val.lValue) = - (int16_t)libdivide_s32_do(*((int16_t *)aGameVars[id].val.lValue), dptr); + *((int16_t *)aGameVars[id].nValue) = + (int16_t)libdivide_s32_do(*((int16_t *)aGameVars[id].nValue), dptr); return; case GAMEVAR_CHARPTR: - *((uint8_t *)aGameVars[id].val.lValue) = - (uint8_t)libdivide_s32_do(*((uint8_t *)aGameVars[id].val.lValue), dptr); + *((uint8_t *)aGameVars[id].nValue) = + (uint8_t)libdivide_s32_do(*((uint8_t *)aGameVars[id].nValue), dptr); return; } diff --git a/polymer/eduke32/source/player.c b/polymer/eduke32/source/player.c index a1e1856a1..9e349c908 100644 --- a/polymer/eduke32/source/player.c +++ b/polymer/eduke32/source/player.c @@ -258,9 +258,9 @@ static int32_t A_FindTargetSprite(const spritetype *s, int32_t aang, int32_t atw 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 (A_CheckEnemySprite((uspritetype *)&sprite[i]) || k < 2) + if (A_CheckEnemySprite(&sprite[i]) || k < 2) { - if (A_CheckEnemySprite((uspritetype *)&sprite[i]) || PN == APLAYER || PN == SHARK) + if (A_CheckEnemySprite(&sprite[i]) || PN == APLAYER || PN == SHARK) { if (PN == APLAYER && s->picnum == APLAYER && s != &sprite[i] && // ud.ffire == 0 && @@ -978,7 +978,7 @@ static int32_t A_ShootCustom(const int32_t i, const int32_t atwith, int16_t sa, l = safeldist(g_player[j].ps->i, s); zvel = tabledivide32_noinline((g_player[j].ps->opos.z - srcvect->z)*vel, l); - if (A_CheckEnemySprite((uspritetype *)s) && (AC_MOVFLAGS(s, &actor[i]) & face_player_smart)) + if (A_CheckEnemySprite(s) && (AC_MOVFLAGS(s, &actor[i]) & face_player_smart)) sa = s->ang + (krand() & 31) - 16; } } @@ -1386,7 +1386,7 @@ static int32_t A_ShootHardcoded(int32_t i, int32_t atwith, int16_t sa, vec3_t sr l = safeldist(g_player[j].ps->i, s); zvel = tabledivide32_noinline((g_player[j].ps->opos.z - srcvect.z)*vel, l); - if (A_CheckEnemySprite((uspritetype *)s) && (AC_MOVFLAGS(s, &actor[i]) & face_player_smart)) + if (A_CheckEnemySprite(s) && (AC_MOVFLAGS(s, &actor[i]) & face_player_smart)) sa = s->ang+(krand()&31)-16; } @@ -1636,7 +1636,7 @@ int32_t A_ShootWithZvel(int32_t i, int32_t atwith, int32_t override_zvel) { srcvect.z -= (7<<8); - if (A_CheckEnemySprite((uspritetype *)s) && PN != COMMANDER) + if (A_CheckEnemySprite(s) && PN != COMMANDER) { srcvect.x += (sintable[(sa+1024+96)&2047]>>7); srcvect.y += (sintable[(sa+512+96)&2047]>>7); @@ -3753,8 +3753,8 @@ void P_FragPlayer(int32_t snum) { P_PalFrom(p, 63, 63,0,0); - p->pos.z -= (16<<8); - s->z -= (16<<8); + p->pos.z -= ZOFFSET2; + s->z -= ZOFFSET2; p->dead_flag = (512-((krand()&1)<<10)+(krand()&255)-512)&2047; if (p->dead_flag == 0) @@ -4531,7 +4531,7 @@ void P_ProcessInput(int32_t snum) truefdist = klabs(p->pos.z-j); - if ((lz&49152) == 16384 && psectlotag == 1 && truefdist > PHEIGHT+(16<<8)) + if ((lz&49152) == 16384 && psectlotag == 1 && truefdist > PHEIGHT+ZOFFSET2) psectlotag = 0; actor[p->i].floorz = fz; @@ -4587,7 +4587,7 @@ void P_ProcessInput(int32_t snum) p->sbs = j; } } - else if (A_CheckEnemySprite((uspritetype *)&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)) { // TX: I think this is what makes the player slide off enemies... might // be a good sprite flag to add later. @@ -4707,7 +4707,7 @@ void P_ProcessInput(int32_t snum) pushmove((vec3_t *)p,&p->cursectnum,128L,(4L<<8),(20L<<8),CLIPMASK0); - if (fz > cz+(16<<8) && s->pal != 1) + if (fz > cz+ZOFFSET2 && s->pal != 1) p->rotscrnang = (p->dead_flag + ((fz+p->pos.z)>>7))&2047; p->on_warping_sector = 0; @@ -5024,7 +5024,7 @@ void P_ProcessInput(int32_t snum) // not jumping or crouching if (!TEST_SYNC_KEY(sb_snum, SK_JUMP) && !TEST_SYNC_KEY(sb_snum, SK_CROUCH) && - p->on_ground && (sector[p->cursectnum].floorstat&2) && p->pos.z >= (fz-(i<<8)-(16<<8))) + p->on_ground && (sector[p->cursectnum].floorstat&2) && p->pos.z >= (fz-(i<<8)-ZOFFSET2)) p->pos.z = fz-(i<<8); else { @@ -5100,9 +5100,9 @@ void P_ProcessInput(int32_t snum) else if (p->jumping_counter == 0) { p->pos.z += ((fz-(i<<7))-p->pos.z)>>1; //Smooth on the water - if (p->on_warping_sector == 0 && p->pos.z > fz-(16<<8)) + if (p->on_warping_sector == 0 && p->pos.z > fz-ZOFFSET2) { - p->pos.z = fz-(16<<8); + p->pos.z = fz-ZOFFSET2; p->vel.z >>= 1; } } @@ -5220,7 +5220,7 @@ void P_ProcessInput(int32_t snum) } } - if (p->on_ground && truefdist <= PHEIGHT+(16<<8) && P_CheckFloorDamage(p, j)) + if (p->on_ground && truefdist <= PHEIGHT+ZOFFSET2 && P_CheckFloorDamage(p, j)) { P_DoQuote(QUOTE_BOOTS_ON, p); p->inv_amount[GET_BOOTS] -= 2; @@ -5567,7 +5567,7 @@ HORIZONLY: break; } default: - if (A_CheckEnemySprite((uspritetype *)&sprite[p->actorsqu])) + if (A_CheckEnemySprite(&sprite[p->actorsqu])) p->actors_killed++; A_DeleteSprite(p->actorsqu); break; diff --git a/polymer/eduke32/source/premap.c b/polymer/eduke32/source/premap.c index 42c8a2f3f..4d7519dd9 100644 --- a/polymer/eduke32/source/premap.c +++ b/polymer/eduke32/source/premap.c @@ -71,7 +71,7 @@ static void G_CacheSpriteNum(int32_t i) char maxc; int32_t j; - if (ud.monsters_off && A_CheckEnemySprite((uspritetype *)&sprite[i])) return; + if (ud.monsters_off && A_CheckEnemySprite(&sprite[i])) return; maxc = 1; @@ -2039,8 +2039,8 @@ void G_FreeMapState(int32_t mapnum) #if !defined LUNATIC for (j=0; jsavedstate->vars[j]); } #else diff --git a/polymer/eduke32/source/savegame.c b/polymer/eduke32/source/savegame.c index a80ce1dbb..ad4aa2e42 100644 --- a/polymer/eduke32/source/savegame.c +++ b/polymer/eduke32/source/savegame.c @@ -1196,10 +1196,10 @@ static void sv_makevarspec() int32_t i, j, numsavedvars=0, numsavedarrays=0, per; for (i=0; ilotag&(0xffff-49152)) + switch (pSector->lotag&(0xffff-49152)) { case ST_30_ROTATE_RISE_BRIDGE: - j = sector[sn].hitag; + j = sector[nSector].hitag; if (E_SpriteIsValid(j)) { if (actor[j].tempang == 0 || actor[j].tempang == 256) - A_CallSound(sn,ii); + A_CallSound(nSector,nSprite); sprite[j].extra = (sprite[j].extra == 1) ? 3 : 1; } break; case ST_31_TWO_WAY_TRAIN: - j = sector[sn].hitag; + j = sector[nSector].hitag; if (E_SpriteIsValid(j)) { if (actor[j].t_data[4] == 0) actor[j].t_data[4] = 1; - A_CallSound(sn,ii); + A_CallSound(nSector,nSprite); } break; case ST_26_SPLITTING_ST_DOOR: //The split doors - if (GetAnimationGoal(&sptr->ceilingz) == -1) //if the door has stopped + if (GetAnimationGoal(&pSector->ceilingz) == -1) //if the door has stopped { g_haltSoundHack = 1; - sptr->lotag &= 0xff00; - sptr->lotag |= ST_22_SPLITTING_DOOR; - G_OperateSectors(sn,ii); - sptr->lotag &= 0xff00; - sptr->lotag |= ST_9_SLIDING_ST_DOOR; - G_OperateSectors(sn,ii); - sptr->lotag &= 0xff00; - sptr->lotag |= ST_26_SPLITTING_ST_DOOR; + pSector->lotag &= 0xff00; + pSector->lotag |= ST_22_SPLITTING_DOOR; + G_OperateSectors(nSector,nSprite); + pSector->lotag &= 0xff00; + pSector->lotag |= ST_9_SLIDING_ST_DOOR; + G_OperateSectors(nSector,nSprite); + pSector->lotag &= 0xff00; + pSector->lotag |= ST_26_SPLITTING_ST_DOOR; } return; case ST_9_SLIDING_ST_DOOR: { - int32_t dax, day; int32_t wallfind[2]; - const int32_t startwall = sptr->wallptr; - const int32_t endwall = startwall+sptr->wallnum-1; + const int32_t startwall = pSector->wallptr; + const int32_t endwall = startwall+pSector->wallnum-1; - const int32_t sp = sptr->extra>>4; + const int32_t sp = pSector->extra>>4; //first find center point by averaging all points - dax = 0, day = 0; - for (i=startwall; i<=endwall; i++) + + vec2_t vect = { 0, 0 }; + + for (i = startwall; i <= endwall; i++) { - dax += wall[i].x; - day += wall[i].y; + vect.x += wall[i].x; + vect.y += wall[i].y; } - dax = tabledivide32_noinline(dax, (endwall-startwall+1)); - day = tabledivide32_noinline(day, (endwall-startwall+1)); + vect.x = tabledivide32_noinline(vect.x, (endwall-startwall+1)); + vect.y = tabledivide32_noinline(vect.y, (endwall-startwall+1)); //find any points with either same x or same y coordinate // as center (dax, day) - should be 2 points found. wallfind[0] = -1; wallfind[1] = -1; - for (i=startwall; i<=endwall; i++) - if (wall[i].x == dax || wall[i].y == day) + + for (i = startwall; i <= endwall; i++) + { + if (wall[i].x == vect.x || wall[i].y == vect.y) { if (wallfind[0] == -1) wallfind[0] = i; - else wallfind[1] = i; + else + wallfind[1] = i; } + } if (wallfind[1] == -1) return; for (j=0; j<2; j++) { - const int32_t wf = wallfind[j]; - int32_t dax2, day2; + int const nFoundWall = wallfind[j]; - i = wf-1; - if (i < startwall) i = endwall; - dax2 = ((wall[i].x+wall[wall[wf].point2].x)>>1) - wall[wf].x; - day2 = ((wall[i].y+wall[wall[wf].point2].y)>>1) - wall[wf].y; + i = nFoundWall - 1; - if (wall[wf].x == dax && wall[wf].y == day) + if (i < startwall) + i = endwall; + + vec2_t vect2 = { ((wall[i].x + wall[wall[nFoundWall].point2].x) >> 1) - wall[nFoundWall].x, + ((wall[i].y + wall[wall[nFoundWall].point2].y) >> 1) - wall[nFoundWall].y }; + + if (wall[nFoundWall].x == vect.x && wall[nFoundWall].y == vect.y) { //find what direction door should open by averaging the // 2 neighboring points of wallfind[0] & wallfind[1]. - if (dax2 != 0) + if (vect2.x != 0) { - dax2 = wall[wall[wall[wf].point2].point2].x; - dax2 -= wall[wall[wf].point2].x; - SetAnimation(sn,&wall[wf].x,wall[wf].x+dax2,sp); - SetAnimation(sn,&wall[i].x,wall[i].x+dax2,sp); - SetAnimation(sn,&wall[wall[wf].point2].x,wall[wall[wf].point2].x+dax2,sp); - A_CallSound(sn,ii); + vect2.x = wall[wall[wall[nFoundWall].point2].point2].x; + vect2.x -= wall[wall[nFoundWall].point2].x; + SetAnimation(nSector,&wall[nFoundWall].x,wall[nFoundWall].x+vect2.x,sp); + SetAnimation(nSector,&wall[i].x,wall[i].x+vect2.x,sp); + SetAnimation(nSector,&wall[wall[nFoundWall].point2].x,wall[wall[nFoundWall].point2].x+vect2.x,sp); + A_CallSound(nSector,nSprite); } - else if (day2 != 0) + else if (vect2.y != 0) { - day2 = wall[wall[wall[wf].point2].point2].y; - day2 -= wall[wall[wf].point2].y; - SetAnimation(sn,&wall[wf].y,wall[wf].y+day2,sp); - SetAnimation(sn,&wall[i].y,wall[i].y+day2,sp); - SetAnimation(sn,&wall[wall[wf].point2].y,wall[wall[wf].point2].y+day2,sp); - A_CallSound(sn,ii); + vect2.y = wall[wall[wall[nFoundWall].point2].point2].y; + vect2.y -= wall[wall[nFoundWall].point2].y; + SetAnimation(nSector,&wall[nFoundWall].y,wall[nFoundWall].y+vect2.y,sp); + SetAnimation(nSector,&wall[i].y,wall[i].y+vect2.y,sp); + SetAnimation(nSector,&wall[wall[nFoundWall].point2].y,wall[wall[nFoundWall].point2].y+vect2.y,sp); + A_CallSound(nSector,nSprite); } } else { - if (dax2 != 0) + if (vect2.x != 0) { - SetAnimation(sn,&wall[wf].x,dax,sp); - SetAnimation(sn,&wall[i].x,dax+dax2,sp); - SetAnimation(sn,&wall[wall[wf].point2].x,dax+dax2,sp); - A_CallSound(sn,ii); + SetAnimation(nSector,&wall[nFoundWall].x,vect.x,sp); + SetAnimation(nSector,&wall[i].x,vect.x+vect2.x,sp); + SetAnimation(nSector,&wall[wall[nFoundWall].point2].x,vect.x+vect2.x,sp); + A_CallSound(nSector,nSprite); } - else if (day2 != 0) + else if (vect2.y != 0) { - SetAnimation(sn,&wall[wf].y,day,sp); - SetAnimation(sn,&wall[i].y,day+day2,sp); - SetAnimation(sn,&wall[wall[wf].point2].y,day+day2,sp); - A_CallSound(sn,ii); + SetAnimation(nSector,&wall[nFoundWall].y,vect.y,sp); + SetAnimation(nSector,&wall[i].y,vect.y+vect2.y,sp); + SetAnimation(nSector,&wall[wall[nFoundWall].point2].y,vect.y+vect2.y,sp); + A_CallSound(nSector,nSprite); } } } @@ -668,17 +675,17 @@ void G_OperateSectors(int32_t sn, int32_t ii) case ST_15_WARP_ELEVATOR://Warping elevators - if (sprite[ii].picnum != APLAYER) + if (sprite[nSprite].picnum != APLAYER) return; - for (SPRITES_OF_SECT(sn, i)) + for (SPRITES_OF_SECT(nSector, i)) if (PN==SECTOREFFECTOR && SLT == SE_17_WARP_ELEVATOR) break; if (i < 0) return; - if (sprite[ii].sectnum == sn) + if (sprite[nSprite].sectnum == nSector) { if (G_ActivateWarpElevators(i,-1)) G_ActivateWarpElevators(i,1); @@ -687,7 +694,7 @@ void G_OperateSectors(int32_t sn, int32_t ii) } else { - if (sptr->floorz > SZ) + if (pSector->floorz > SZ) G_ActivateWarpElevators(i,-1); else G_ActivateWarpElevators(i,1); @@ -698,24 +705,24 @@ void G_OperateSectors(int32_t sn, int32_t ii) case ST_16_PLATFORM_DOWN: case ST_17_PLATFORM_UP: - i = GetAnimationGoal(&sptr->floorz); + i = GetAnimationGoal(&pSector->floorz); if (i == -1) { - i = nextsectorneighborz(sn,sptr->floorz,1,1); + i = nextsectorneighborz(nSector,pSector->floorz,1,1); if (i == -1) { - i = nextsectorneighborz(sn,sptr->floorz,1,-1); + i = nextsectorneighborz(nSector,pSector->floorz,1,-1); if (i == -1) return; j = sector[i].floorz; - SetAnimation(sn,&sptr->floorz,j,sptr->extra); + SetAnimation(nSector,&pSector->floorz,j,pSector->extra); } else { j = sector[i].floorz; - SetAnimation(sn,&sptr->floorz,j,sptr->extra); + SetAnimation(nSector,&pSector->floorz,j,pSector->extra); } - A_CallSound(sn,ii); + A_CallSound(nSector,nSprite); } return; @@ -723,43 +730,48 @@ void G_OperateSectors(int32_t sn, int32_t ii) case ST_18_ELEVATOR_DOWN: case ST_19_ELEVATOR_UP: - i = GetAnimationGoal(&sptr->floorz); + i = GetAnimationGoal(&pSector->floorz); if (i==-1) { - int32_t q; + i = nextsectorneighborz(nSector, pSector->floorz, 1, -1); + + if (i == -1) + i = nextsectorneighborz(nSector, pSector->floorz, 1, 1); + + if (i == -1) + return; - i = nextsectorneighborz(sn,sptr->floorz,1,-1); - if (i==-1) i = nextsectorneighborz(sn,sptr->floorz,1,1); - if (i==-1) return; 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); - A_CallSound(sn,ii); + + int const nSectorExtra = pSector->extra; + int const nZdiff = pSector->ceilingz - pSector->floorz; + + SetAnimation(nSector, &pSector->floorz, j, nSectorExtra); + SetAnimation(nSector, &pSector->ceilingz, j + nZdiff, nSectorExtra); + A_CallSound(nSector, nSprite); } return; case ST_29_TEETH_DOOR: for (SPRITES_OF(STAT_EFFECTOR, i)) - if (SLT == SE_22_TEETH_DOOR && SHT == sptr->hitag) + if (SLT == SE_22_TEETH_DOOR && SHT == pSector->hitag) { sector[SECT].extra = -sector[SECT].extra; - T1 = sn; + T1 = nSector; T2 = 1; } - A_CallSound(sn, ii); + A_CallSound(nSector, nSprite); - sptr->lotag ^= 0x8000; + pSector->lotag ^= 0x8000; - if (sptr->lotag&0x8000) + if (pSector->lotag&0x8000) { - j = nextsectorneighborz(sn,sptr->ceilingz,-1,-1); - if (j == -1) j = nextsectorneighborz(sn,sptr->ceilingz,1,1); + j = nextsectorneighborz(nSector,pSector->ceilingz,-1,-1); + if (j == -1) j = nextsectorneighborz(nSector,pSector->ceilingz,1,1); if (j == -1) { OSD_Printf("WARNING: ST29: null sector!\n"); @@ -769,8 +781,8 @@ void G_OperateSectors(int32_t sn, int32_t ii) } else { - j = nextsectorneighborz(sn,sptr->ceilingz,1,1); - if (j == -1) j = nextsectorneighborz(sn,sptr->ceilingz,-1,-1); + j = nextsectorneighborz(nSector,pSector->ceilingz,1,1); + if (j == -1) j = nextsectorneighborz(nSector,pSector->ceilingz,-1,-1); if (j == -1) { OSD_Printf("WARNING: ST29: null sector!\n"); @@ -779,16 +791,16 @@ void G_OperateSectors(int32_t sn, int32_t ii) j = sector[j].floorz; } - SetAnimation(sn,&sptr->ceilingz,j,sptr->extra); + SetAnimation(nSector,&pSector->ceilingz,j,pSector->extra); return; case ST_20_CEILING_DOOR: REDODOOR: - if (sptr->lotag&0x8000) + if (pSector->lotag&0x8000) { - for (SPRITES_OF_SECT(sn, i)) + for (SPRITES_OF_SECT(nSector, i)) if (sprite[i].statnum == STAT_EFFECTOR && SLT==SE_9_DOWN_OPEN_DOOR_LIGHTS) { j = SZ; @@ -796,125 +808,126 @@ REDODOOR: } if (i==-1) - j = sptr->floorz; + j = pSector->floorz; } else { - j = nextsectorneighborz(sn,sptr->ceilingz,-1,-1); + j = nextsectorneighborz(nSector,pSector->ceilingz,-1,-1); if (j >= 0) j = sector[j].ceilingz; else { - sptr->lotag |= 32768; + pSector->lotag |= 32768; goto REDODOOR; } } - sptr->lotag ^= 0x8000; + pSector->lotag ^= 0x8000; - SetAnimation(sn,&sptr->ceilingz,j,sptr->extra); - A_CallSound(sn,ii); + SetAnimation(nSector,&pSector->ceilingz,j,pSector->extra); + A_CallSound(nSector,nSprite); return; case ST_21_FLOOR_DOOR: - i = GetAnimationGoal(&sptr->floorz); + i = GetAnimationGoal(&pSector->floorz); if (i >= 0) { - if (animategoal[sn] == sptr->ceilingz) - animategoal[i] = sector[nextsectorneighborz(sn,sptr->ceilingz,1,1)].floorz; - else animategoal[i] = sptr->ceilingz; + if (animategoal[nSector] == pSector->ceilingz) + animategoal[i] = sector[nextsectorneighborz(nSector,pSector->ceilingz,1,1)].floorz; + else animategoal[i] = pSector->ceilingz; } else { - if (sptr->ceilingz == sptr->floorz) - j = sector[nextsectorneighborz(sn,sptr->ceilingz,1,1)].floorz; - else j = sptr->ceilingz; + if (pSector->ceilingz == pSector->floorz) + j = sector[nextsectorneighborz(nSector,pSector->ceilingz,1,1)].floorz; + else j = pSector->ceilingz; - sptr->lotag ^= 0x8000; + pSector->lotag ^= 0x8000; - if (SetAnimation(sn,&sptr->floorz,j,sptr->extra) >= 0) - A_CallSound(sn,ii); + if (SetAnimation(nSector,&pSector->floorz,j,pSector->extra) >= 0) + A_CallSound(nSector,nSprite); } return; case ST_22_SPLITTING_DOOR: - if (sptr->lotag&0x8000) + if (pSector->lotag&0x8000) { - int32_t q = (sptr->ceilingz+sptr->floorz)>>1; - j = SetAnimation(sn, &sptr->floorz, q, sptr->extra); - j = SetAnimation(sn, &sptr->ceilingz, q, sptr->extra); + int32_t q = (pSector->ceilingz+pSector->floorz)>>1; + j = SetAnimation(nSector, &pSector->floorz, q, pSector->extra); + j = SetAnimation(nSector, &pSector->ceilingz, q, pSector->extra); } else { - int32_t fneigh = nextsectorneighborz(sn, sptr->floorz, 1, 1); - int32_t cneigh = nextsectorneighborz(sn, sptr->ceilingz, -1, -1); + int32_t fneigh = nextsectorneighborz(nSector, pSector->floorz, 1, 1); + int32_t cneigh = nextsectorneighborz(nSector, pSector->ceilingz, -1, -1); if (fneigh>=0 && cneigh>=0) { - j = SetAnimation(sn, &sptr->floorz, sector[fneigh].floorz, sptr->extra); - j = SetAnimation(sn, &sptr->ceilingz, sector[cneigh].ceilingz, sptr->extra); + j = SetAnimation(nSector, &pSector->floorz, sector[fneigh].floorz, pSector->extra); + j = SetAnimation(nSector, &pSector->ceilingz, sector[cneigh].ceilingz, pSector->extra); } else { OSD_Printf("WARNING: ST22: null sector: floor neighbor=%d, ceiling neighbor=%d!\n", fneigh, cneigh); - sptr->lotag ^= 0x8000; + pSector->lotag ^= 0x8000; } } - sptr->lotag ^= 0x8000; + pSector->lotag ^= 0x8000; - A_CallSound(sn,ii); + A_CallSound(nSector,nSprite); return; case ST_23_SWINGING_DOOR: //Swingdoor - - j = -1; - - for (SPRITES_OF(STAT_EFFECTOR, i)) - if (SLT == SE_11_SWINGING_DOOR && SECT == sn && !T5) - { - j = i; - break; - } - - if (i < 0) { - OSD_Printf("WARNING: SE23 i<0!\n"); - return; - } // JBF - - l = sector[SECT].lotag&0x8000; - - if (j >= 0) - { - int32_t playedsnd = 0; + j = -1; for (SPRITES_OF(STAT_EFFECTOR, i)) - if (l == (sector[SECT].lotag&0x8000) && SLT == SE_11_SWINGING_DOOR && sprite[j].hitag == SHT && !T5) + if (SLT == SE_11_SWINGING_DOOR && SECT == nSector && !T5) { - if (sector[SECT].lotag&0x8000) sector[SECT].lotag &= 0x7fff; - else sector[SECT].lotag |= 0x8000; - - T5 = 1; - T4 = -T4; - - if (!playedsnd) - { - A_CallSound(sn,i); - playedsnd = 1; - } + j = i; + break; } + + if (i < 0) + { + OSD_Printf("WARNING: SE23 i<0!\n"); + return; + } // JBF + + int const nTag = sector[SECT].lotag&0x8000; + + if (j >= 0) + { + int32_t playedsnd = 0; + + for (SPRITES_OF(STAT_EFFECTOR, i)) + if (nTag == (sector[SECT].lotag&0x8000) && SLT == SE_11_SWINGING_DOOR && sprite[j].hitag == SHT && !T5) + { + if (sector[SECT].lotag&0x8000) sector[SECT].lotag &= 0x7fff; + else sector[SECT].lotag |= 0x8000; + + T5 = 1; + T4 = -T4; + + if (!playedsnd) + { + A_CallSound(nSector, i); + playedsnd = 1; + } + } + } } return; case ST_25_SLIDING_DOOR: //Subway type sliding doors for (SPRITES_OF(STAT_EFFECTOR, j)) - if (sprite[j].lotag == SE_15_SLIDING_DOOR && sprite[j].sectnum == sn) + if (sprite[j].lotag == SE_15_SLIDING_DOOR && sprite[j].sectnum == nSector) break; //Found the sectoreffector. if (j < 0) @@ -941,13 +954,13 @@ REDODOOR: case ST_27_STRETCH_BRIDGE: //Extended bridge for (SPRITES_OF(STAT_EFFECTOR, j)) - if ((sprite[j].lotag&0xff)==SE_20_STRETCH_BRIDGE && sprite[j].sectnum == sn) //Bridge + if ((sprite[j].lotag&0xff)==SE_20_STRETCH_BRIDGE && sprite[j].sectnum == nSector) //Bridge { - sector[sn].lotag ^= 0x8000; + sector[nSector].lotag ^= 0x8000; // Highest bit now set means we're opening. - actor[j].t_data[0] = (sector[sn].lotag&0x8000) ? 1 : 2; - A_CallSound(sn,ii); + actor[j].t_data[0] = (sector[nSector].lotag&0x8000) ? 1 : 2; + A_CallSound(nSector,nSprite); break; } @@ -956,7 +969,7 @@ REDODOOR: case ST_28_DROP_FLOOR: //activate the rest of them - for (SPRITES_OF_SECT(sn, j)) + for (SPRITES_OF_SECT(nSector, j)) if (sprite[j].statnum==STAT_EFFECTOR && (sprite[j].lotag&0xff)==SE_21_DROP_FLOOR) break; @@ -964,14 +977,14 @@ REDODOOR: { j = sprite[j].hitag; - for (SPRITES_OF(STAT_EFFECTOR, l)) + for (int SPRITES_OF(STAT_EFFECTOR, l)) { if ((sprite[l].lotag&0xff)==SE_21_DROP_FLOOR && !actor[l].t_data[0] && sprite[l].hitag == j) actor[l].t_data[0] = 1; } - A_CallSound(sn,ii); + A_CallSound(nSector,nSprite); } return; @@ -1000,23 +1013,24 @@ void G_OperateRespawns(int32_t low) } } -void G_OperateActivators(int32_t low, int32_t snum) +void G_OperateActivators(int nTag, int nPlayer) { int32_t i, nexti, j, k; - walltype *wal; for (i=g_numCyclers-1; i>=0; i--) { int16_t *const p = &cyclers[i][0]; - if (p[4] == low) + if (p[4] == nTag) { p[5] = !p[5]; sector[p[0]].floorshade = sector[p[0]].ceilingshade = p[3]; - wal = &wall[sector[p[0]].wallptr]; - for (j=sector[p[0]].wallnum; j > 0; j--,wal++) - wal->shade = p[3]; + + walltype *pWall = &wall[sector[p[0]].wallptr]; + + for (j = sector[p[0]].wallnum; j > 0; j--, pWall++) + pWall->shade = p[3]; } } @@ -1024,28 +1038,27 @@ void G_OperateActivators(int32_t low, int32_t snum) for (SPRITES_OF_STAT_SAFE(STAT_ACTIVATOR, i, nexti)) { - if (sprite[i].lotag == low) + if (sprite[i].lotag == nTag) { if (sprite[i].picnum == ACTIVATORLOCKED) { sector[SECT].lotag ^= 16384; - if (snum >= 0 && snum < ud.multimode) - P_DoQuote((sector[SECT].lotag&16384) ? QUOTE_LOCKED : QUOTE_UNLOCKED, - g_player[snum].ps); + if (nPlayer >= 0 && nPlayer < ud.multimode) + P_DoQuote((sector[SECT].lotag & 16384) ? QUOTE_LOCKED : QUOTE_UNLOCKED, g_player[nPlayer].ps); } else { switch (SHT) { - case 1: - if (sector[SECT].floorz != sector[SECT].ceilingz) - continue; - break; - case 2: - if (sector[SECT].floorz == sector[SECT].ceilingz) - continue; - break; + case 1: + if (sector[SECT].floorz != sector[SECT].ceilingz) + continue; + break; + case 2: + if (sector[SECT].floorz == sector[SECT].ceilingz) + continue; + break; } // ST_2_UNDERWATER @@ -1055,13 +1068,13 @@ void G_OperateActivators(int32_t low, int32_t snum) if (sprite[j].statnum == STAT_EFFECTOR) switch (sprite[j].lotag) { - case SE_36_PROJ_SHOOTER: - case SE_31_FLOOR_RISE_FALL: - case SE_32_CEILING_RISE_FALL: - case SE_18_INCREMENTAL_SECTOR_RISE_FALL: - actor[j].t_data[0] = 1-actor[j].t_data[0]; - A_CallSound(SECT,j); - break; + case SE_36_PROJ_SHOOTER: + case SE_31_FLOOR_RISE_FALL: + case SE_32_CEILING_RISE_FALL: + case SE_18_INCREMENTAL_SECTOR_RISE_FALL: + actor[j].t_data[0] = 1 - actor[j].t_data[0]; + A_CallSound(SECT, j); + break; } } @@ -1073,42 +1086,37 @@ void G_OperateActivators(int32_t low, int32_t snum) } } - G_OperateRespawns(low); + G_OperateRespawns(nTag); } -void G_OperateMasterSwitches(int32_t low) +void G_OperateMasterSwitches(int nTag) { - int32_t i; - - for (SPRITES_OF(STAT_STANDABLE, i)) - if (PN == MASTERSWITCH && SLT == low && SP == 0) + for (int SPRITES_OF(STAT_STANDABLE, i)) + if (PN == MASTERSWITCH && SLT == nTag && SP == 0) SP = 1; } void G_OperateForceFields(int32_t s, int32_t low) { - int32_t p=g_numAnimWalls; - - for (; p>=0; p--) + for (int nAnim = 0; nAnim < g_numAnimWalls; ++nAnim) { - const int32_t i = animwall[p].wallnum; + int const nWall = animwall[nAnim].wallnum; - if (low == wall[i].lotag || low == -1) - if (G_GetForcefieldPicnum(i) == W_FORCEFIELD - || (wall[i].overpicnum == BIGFORCE)) + if ((low == wall[nWall].lotag || low == -1) || G_GetForcefieldPicnum(nWall) == W_FORCEFIELD || + (wall[nWall].overpicnum == BIGFORCE)) + { + animwall[nAnim].tag = 0; + + if (wall[nWall].cstat) { - animwall[p].tag = 0; + wall[nWall].cstat = 0; - if (wall[i].cstat) - { - wall[i].cstat = 0; - - if (s >= 0 && sprite[s].picnum == SECTOREFFECTOR && sprite[s].lotag == SE_30_TWO_WAY_TRAIN) - wall[i].lotag = 0; - } - else - wall[i].cstat = FORCEFIELD_CSTAT; + if (s >= 0 && sprite[s].picnum == SECTOREFFECTOR && sprite[s].lotag == SE_30_TWO_WAY_TRAIN) + wall[nWall].lotag = 0; } + else + wall[nWall].cstat = FORCEFIELD_CSTAT; + } } } @@ -1144,127 +1152,105 @@ void G_OperateForceFields(int32_t s, int32_t low) // 0: is not a dipswitch-like switch // 1: is one, off // 2: is one, on -static int32_t G_IsLikeDipswitch(int32_t picnum) +static int G_IsLikeDipswitch(int nPicnum) { - int32_t i; - - for (i=0; i<2; i++) - if (picnum == DIPSWITCH+i || picnum == TECHSWITCH+i || picnum == ALIENSWITCH+i) + for (int i=0; i<2; i++) + if (nPicnum == DIPSWITCH+i || nPicnum == TECHSWITCH+i || nPicnum == ALIENSWITCH+i) return 1+i; return 0; } // Get base (unpressed) tile number for switch. -static int32_t G_GetBaseSwitch(int32_t picnum) +static int G_GetBaseSwitch(int nPicnum) { - if (picnum==DIPSWITCH+1 - || picnum==TECHSWITCH+1 - || picnum==ALIENSWITCH+1 - || picnum==DIPSWITCH2+1 - || picnum==DIPSWITCH3+1 - || picnum==PULLSWITCH+1 - || picnum==HANDSWITCH+1 - || picnum==SLOTDOOR+1 - || picnum==LIGHTSWITCH+1 - || picnum==SPACELIGHTSWITCH+1 - || picnum==SPACEDOORSWITCH+1 - || picnum==FRANKENSTINESWITCH+1 - || picnum==LIGHTSWITCH2+1 - || picnum==POWERSWITCH1+1 - || picnum==LOCKSWITCH1+1 - || picnum==POWERSWITCH2+1 - ) - { - return picnum-1; - } - - if (picnum > MULTISWITCH && picnum <= MULTISWITCH+3) - { + if (nPicnum > MULTISWITCH && nPicnum <= MULTISWITCH+3) return MULTISWITCH; - } - return picnum; + return (nPicnum == DIPSWITCH + 1 || nPicnum == DIPSWITCH2 + 1 || nPicnum == DIPSWITCH3 + 1 || + nPicnum == TECHSWITCH + 1 || nPicnum == ALIENSWITCH + 1 || nPicnum == PULLSWITCH + 1 || + nPicnum == HANDSWITCH + 1 || nPicnum == SLOTDOOR + 1 || nPicnum == SPACEDOORSWITCH + 1 || + nPicnum == SPACELIGHTSWITCH + 1 || nPicnum == LIGHTSWITCH + 1 || nPicnum == LIGHTSWITCH2 + 1 || + nPicnum == FRANKENSTINESWITCH + 1 || nPicnum == POWERSWITCH1 + 1 || nPicnum == POWERSWITCH2 + 1 || + nPicnum == LOCKSWITCH1 + 1) ? + nPicnum-1 : nPicnum; } -int32_t P_ActivateSwitch(int32_t snum, int32_t w, int32_t switchissprite) +enum { SWITCH_WALL, SWITCH_SPRITE }; + +int P_ActivateSwitch(int nPlayer, int nObject, int nSwitchType) { - int32_t lotag, hitag, picnum, switchpal; - vec3_t davector; - - int32_t switchpicnum; - int32_t i, correctdips = 1, numdips = 0; - - if (w < 0) + if (nObject < 0) return 0; - if (switchissprite == 1) // A wall sprite + int lotag, hitag, nSwitchPicnum, nSwitchPal; + vec3_t davector; + + if (nSwitchType == SWITCH_SPRITE) // A wall sprite { - if (actor[w].lasttransport == totalclock) + if (actor[nObject].lasttransport == totalclock) return 0; - actor[w].lasttransport = totalclock; + actor[nObject].lasttransport = totalclock; - lotag = sprite[w].lotag; - if (lotag == 0) + if (sprite[nObject].lotag == 0) return 0; - hitag = sprite[w].hitag; - - Bmemcpy(&davector, &sprite[w], sizeof(vec3_t)); - picnum = sprite[w].picnum; - switchpal = sprite[w].pal; + lotag = sprite[nObject].lotag; + hitag = sprite[nObject].hitag; + davector = *(vec3_t *)&sprite[nObject]; + nSwitchPicnum = sprite[nObject].picnum; + nSwitchPal = sprite[nObject].pal; } else { - lotag = wall[w].lotag; - if (lotag == 0) + if (wall[nObject].lotag == 0) return 0; - hitag = wall[w].hitag; - - Bmemcpy(&davector, &wall[w], sizeof(int32_t) * 2); - davector.z = g_player[snum].ps->pos.z; - picnum = wall[w].picnum; - switchpal = wall[w].pal; + lotag = wall[nObject].lotag; + hitag = wall[nObject].hitag; + davector = *(vec3_t *)&wall[nObject]; + davector.z = g_player[nPlayer].ps->pos.z; + nSwitchPicnum = wall[nObject].picnum; + nSwitchPal = wall[nObject].pal; } -// initprintf("P_ActivateSwitch called picnum=%i switchissprite=%i\n",picnum,switchissprite); + // initprintf("P_ActivateSwitch called picnum=%i switchissprite=%i\n",picnum,switchissprite); - switchpicnum = G_GetBaseSwitch(picnum); + int nBasePicnum = G_GetBaseSwitch(nSwitchPicnum); + int nCorrectDips = 1; + int nNumDips = 0; - switch (DYNAMICTILEMAP(switchpicnum)) + switch (DYNAMICTILEMAP(nBasePicnum)) { case DIPSWITCH_LIKE_CASES: break; case ACCESSSWITCH_CASES: - if (g_player[snum].ps->access_incs == 0) + if (g_player[nPlayer].ps->access_incs == 0) { - int32_t pp; + static const int32_t key_switchpal[3] = { 0, 21, 23 }; + static const int32_t need_key_quote[3] = { QUOTE_NEED_BLUE_KEY, QUOTE_NEED_RED_KEY, QUOTE_NEED_YELLOW_KEY }; - static const int32_t key_switchpal[3] = { 0, 21, 23 }; - static const int32_t need_key_quote[3] = { - QUOTE_NEED_BLUE_KEY, QUOTE_NEED_RED_KEY, QUOTE_NEED_YELLOW_KEY - }; - - for (pp=0; pp<3; pp++) - if (switchpal == key_switchpal[pp]) + for (int nKeyPal = 0; nKeyPal < 3; nKeyPal++) + { + if (nSwitchPal == key_switchpal[nKeyPal]) { - if (g_player[snum].ps->got_access & (1<access_incs = 1; + if (g_player[nPlayer].ps->got_access & (1 << nKeyPal)) + g_player[nPlayer].ps->access_incs = 1; else - P_DoQuote(need_key_quote[pp], g_player[snum].ps); + P_DoQuote(need_key_quote[nKeyPal], g_player[nPlayer].ps); break; } + } - if (g_player[snum].ps->access_incs == 1) + if (g_player[nPlayer].ps->access_incs == 1) { - if (switchissprite == 0) - g_player[snum].ps->access_wallnum = w; + if (nSwitchType == SWITCH_WALL) + g_player[nPlayer].ps->access_wallnum = nObject; else - g_player[snum].ps->access_spritenum = w; + g_player[nPlayer].ps->access_spritenum = nObject; } return 0; @@ -1277,34 +1263,34 @@ int32_t P_ActivateSwitch(int32_t snum, int32_t w, int32_t switchissprite) break; default: - if (CheckDoorTile(picnum) == 0) + if (CheckDoorTile(nSwitchPicnum) == 0) return 0; break; } - for (SPRITES_OF(STAT_DEFAULT, i)) + for (int SPRITES_OF(STAT_DEFAULT, i)) { if (lotag == SLT) { // Put the tile number into a variable so later switches don't // trigger on the result of changes: - const int32_t switchpic = PN; + int const nSpritePicnum = PN; - if (switchpic >= MULTISWITCH && switchpic <= MULTISWITCH+3) + if (nSpritePicnum >= MULTISWITCH && nSpritePicnum <= MULTISWITCH+3) { sprite[i].picnum++; if (sprite[i].picnum > MULTISWITCH+3) sprite[i].picnum = MULTISWITCH; } - switch (DYNAMICTILEMAP(switchpic)) + switch (DYNAMICTILEMAP(nSpritePicnum)) { case DIPSWITCH_LIKE_CASES: - if (switchissprite == 1 && w == i) + if (nSwitchType == SWITCH_SPRITE && nObject == i) PN++; else if (SHT == 0) - correctdips++; - numdips++; + nCorrectDips++; + nNumDips++; break; case ACCESSSWITCH_CASES: @@ -1313,75 +1299,73 @@ int32_t P_ActivateSwitch(int32_t snum, int32_t w, int32_t switchissprite) break; default: - if (switchpic <= 0) // oob safety + if (nSpritePicnum <= 0) // oob safety break; - switch (DYNAMICTILEMAP(switchpic-1)) + switch (DYNAMICTILEMAP(nSpritePicnum - 1)) { - case DIPSWITCH_LIKE_CASES: - if (switchissprite == 1 && w == i) - PN--; - else if (SHT == 1) - correctdips++; - numdips++; - break; + case DIPSWITCH_LIKE_CASES: + if (nSwitchType == SWITCH_SPRITE && nObject == i) + PN--; + else if (SHT == 1) + nCorrectDips++; + nNumDips++; + break; - case REST_SWITCH_CASES: - sprite[i].picnum--; - break; + case REST_SWITCH_CASES: + sprite[i].picnum--; + break; } break; } } } - for (i=numwalls-1; i>=0; i--) + for (int nWall=numwalls-1; nWall>=0; nWall--) { - const int32_t x = i; - - if (lotag == wall[x].lotag) + if (lotag == wall[nWall].lotag) { - if (wall[x].picnum >= MULTISWITCH && wall[x].picnum <= MULTISWITCH+3) + if (wall[nWall].picnum >= MULTISWITCH && wall[nWall].picnum <= MULTISWITCH+3) { - wall[x].picnum++; - if (wall[x].picnum > MULTISWITCH+3) - wall[x].picnum = MULTISWITCH; + wall[nWall].picnum++; + if (wall[nWall].picnum > MULTISWITCH+3) + wall[nWall].picnum = MULTISWITCH; } - switch (DYNAMICTILEMAP(wall[x].picnum)) + switch (DYNAMICTILEMAP(wall[nWall].picnum)) { - case DIPSWITCH_LIKE_CASES: - if (switchissprite == 0 && i == w) - wall[x].picnum++; - else if (wall[x].hitag == 0) - correctdips++; - numdips++; - break; - - case ACCESSSWITCH_CASES: - case REST_SWITCH_CASES: - wall[x].picnum++; - break; - - default: - if (wall[x].picnum <= 0) // oob safety - break; - - switch (DYNAMICTILEMAP(wall[x].picnum-1)) - { case DIPSWITCH_LIKE_CASES: - if (switchissprite == 0 && i == w) - wall[x].picnum--; - else if (wall[x].hitag == 1) - correctdips++; - numdips++; + if (nSwitchType == SWITCH_WALL && nWall == nObject) + wall[nWall].picnum++; + else if (wall[nWall].hitag == 0) + nCorrectDips++; + nNumDips++; break; + case ACCESSSWITCH_CASES: case REST_SWITCH_CASES: - wall[x].picnum--; + wall[nWall].picnum++; + break; + + default: + if (wall[nWall].picnum <= 0) // oob safety + break; + + switch (DYNAMICTILEMAP(wall[nWall].picnum - 1)) + { + case DIPSWITCH_LIKE_CASES: + if (nSwitchType == SWITCH_WALL && nWall == nObject) + wall[nWall].picnum--; + else if (wall[nWall].hitag == 1) + nCorrectDips++; + nNumDips++; + break; + + case REST_SWITCH_CASES: + wall[nWall].picnum--; + break; + } break; - } - break; } } } @@ -1392,473 +1376,439 @@ int32_t P_ActivateSwitch(int32_t snum, int32_t w, int32_t switchissprite) return 1; } - switchpicnum = G_GetBaseSwitch(picnum); + nBasePicnum = G_GetBaseSwitch(nSwitchPicnum); - switch (DYNAMICTILEMAP(switchpicnum)) + switch (DYNAMICTILEMAP(nBasePicnum)) { - default: - if (CheckDoorTile(picnum) == 0) - break; - /* fall-through */ - case DIPSWITCH_LIKE_CASES: - if (G_IsLikeDipswitch(picnum)) - { - if (picnum == ALIENSWITCH || picnum == ALIENSWITCH+1) - { - if (switchissprite == 1) - S_PlaySound3D(ALIEN_SWITCH1, w, &davector); - else - S_PlaySound3D(ALIEN_SWITCH1, g_player[snum].ps->i, &davector); - } - else - { - if (switchissprite == 1) - S_PlaySound3D(SWITCH_ON, w, &davector); - else - S_PlaySound3D(SWITCH_ON, g_player[snum].ps->i, &davector); - } - - if (numdips != correctdips) + default: + if (CheckDoorTile(nSwitchPicnum) == 0) break; - - S_PlaySound3D(END_OF_LEVEL_WARN, g_player[snum].ps->i, &davector); - } /* fall-through */ - case ACCESSSWITCH_CASES: - case MULTISWITCH__STATIC: - case REST_SWITCH_CASES: - { - int32_t x; - - if (picnum >= MULTISWITCH && picnum <= MULTISWITCH+3) - lotag += picnum - MULTISWITCH; - - for (SPRITES_OF(STAT_EFFECTOR, x)) - { - if (sprite[x].hitag == lotag) + case DIPSWITCH_LIKE_CASES: + if (G_IsLikeDipswitch(nSwitchPicnum)) { - switch (sprite[x].lotag) + S_PlaySound3D((nSwitchPicnum == ALIENSWITCH || nSwitchPicnum == ALIENSWITCH + 1) ? ALIEN_SWITCH1 : SWITCH_ON, + (nSwitchType == SWITCH_SPRITE) ? nObject : g_player[nPlayer].ps->i, &davector); + + if (nNumDips != nCorrectDips) + break; + + S_PlaySound3D(END_OF_LEVEL_WARN, g_player[nPlayer].ps->i, &davector); + } + /* fall-through */ + case ACCESSSWITCH_CASES: + case MULTISWITCH__STATIC: + case REST_SWITCH_CASES: + { + if (nSwitchPicnum >= MULTISWITCH && nSwitchPicnum <= MULTISWITCH + 3) + lotag += nSwitchPicnum - MULTISWITCH; + + for (int SPRITES_OF(STAT_EFFECTOR, nSprite)) + { + if (sprite[nSprite].hitag == lotag) { - case SE_12_LIGHT_SWITCH: - sector[sprite[x].sectnum].floorpal = 0; - actor[x].t_data[0]++; - if (actor[x].t_data[0] == 2) - actor[x].t_data[0]++; - break; + switch (sprite[nSprite].lotag) + { + case SE_12_LIGHT_SWITCH: + sector[sprite[nSprite].sectnum].floorpal = 0; + actor[nSprite].t_data[0]++; + if (actor[nSprite].t_data[0] == 2) + actor[nSprite].t_data[0]++; + break; - case SE_24_CONVEYOR: - case SE_34: - case SE_25_PISTON: - actor[x].t_data[4] = !actor[x].t_data[4]; - P_DoQuote(actor[x].t_data[4] ? QUOTE_DEACTIVATED : QUOTE_ACTIVATED, - g_player[snum].ps); - break; + case SE_24_CONVEYOR: + case SE_34: + case SE_25_PISTON: + actor[nSprite].t_data[4] = !actor[nSprite].t_data[4]; + P_DoQuote(actor[nSprite].t_data[4] ? QUOTE_DEACTIVATED : QUOTE_ACTIVATED, g_player[nPlayer].ps); + break; - case SE_21_DROP_FLOOR: - P_DoQuote(QUOTE_ACTIVATED, g_player[screenpeek].ps); - break; + case SE_21_DROP_FLOOR: + P_DoQuote(QUOTE_ACTIVATED, g_player[screenpeek].ps); + break; + } } } - } - G_OperateActivators(lotag,snum); - G_OperateForceFields(g_player[snum].ps->i, lotag); - G_OperateMasterSwitches(lotag); + G_OperateActivators(lotag, nPlayer); + G_OperateForceFields(g_player[nPlayer].ps->i, lotag); + G_OperateMasterSwitches(lotag); + + if (G_IsLikeDipswitch(nSwitchPicnum)) + return 1; + + if (!hitag && CheckDoorTile(nSwitchPicnum) == 0) + S_PlaySound3D(SWITCH_ON, (nSwitchType == SWITCH_SPRITE) ? nObject : g_player[nPlayer].ps->i, &davector); + else if (hitag) + { + if (nSwitchType == SWITCH_SPRITE && (g_sounds[hitag].m & SF_TALK) == 0) + S_PlaySound3D(hitag, nObject, &davector); + else + A_PlaySound(hitag, g_player[nPlayer].ps->i); + } - if (G_IsLikeDipswitch(picnum)) return 1; - - if (hitag == 0 && CheckDoorTile(picnum) == 0) - { - if (switchissprite == 1) - S_PlaySound3D(SWITCH_ON, w, &davector); - else - S_PlaySound3D(SWITCH_ON, g_player[snum].ps->i, &davector); } - else if (hitag != 0) - { - if (switchissprite == 1 && (g_sounds[hitag].m & SF_TALK) == 0) - S_PlaySound3D(hitag, w, &davector); - else - A_PlaySound(hitag, g_player[snum].ps->i); - } - - return 1; - } } return 0; } -void G_ActivateBySector(int32_t sect, int32_t j) +void G_ActivateBySector(int nSector, int nSprite) { - int32_t i; - int32_t didit = 0; + int nActivatedSectors = 0; - for (SPRITES_OF_SECT(sect, i)) + for (int SPRITES_OF_SECT(nSector, i)) if (PN == ACTIVATOR) { G_OperateActivators(SLT,-1); - didit = 1; + ++nActivatedSectors; } - if (didit == 0) - G_OperateSectors(sect,j); + if (!nActivatedSectors) + G_OperateSectors(nSector, nSprite); } -static void BreakWall(int32_t newpn, int32_t spr, int32_t dawallnum) +static void G_BreakWall(int nPicnum, int nSprite, int nWall) { - wall[dawallnum].picnum = newpn; - A_PlaySound(VENT_BUST,spr); - A_PlaySound(GLASS_HEAVYBREAK,spr); - A_SpawnWallGlass(spr,dawallnum,10); + wall[nWall].picnum = nPicnum; + A_PlaySound(VENT_BUST,nSprite); + A_PlaySound(GLASS_HEAVYBREAK,nSprite); + A_SpawnWallGlass(nSprite,nWall,10); } -void A_DamageWall(int32_t spr, int32_t dawallnum, const vec3_t *pos, int32_t atwith) +void A_DamageWall(int nSprite, int nWall, const vec3_t *vPos, int nWeapon) { - int16_t sn = -1; - int32_t j, i, darkestwall; - walltype *wal = &wall[dawallnum]; + int16_t nSectnum = -1; + int32_t i; + walltype *pWall = &wall[nWall]; - if (wal->overpicnum == MIRROR && wal->pal != 4 && - A_CheckSpriteFlags(spr,SFLAG_PROJECTILE) && - (SpriteProjectile[spr].workslike & PROJECTILE_RPG)) + if (pWall->overpicnum == MIRROR && pWall->pal != 4 && + A_CheckSpriteFlags(nSprite, SFLAG_PROJECTILE) && + (SpriteProjectile[nSprite].workslike & PROJECTILE_RPG)) { - if (wal->nextwall == -1 || wall[wal->nextwall].pal != 4) + if (pWall->nextwall == -1 || wall[pWall->nextwall].pal != 4) { - A_SpawnWallGlass(spr,dawallnum,70); - wal->cstat &= ~16; - wal->overpicnum = MIRRORBROKE; - A_PlaySound(GLASS_HEAVYBREAK,spr); + A_SpawnWallGlass(nSprite, nWall, 70); + pWall->cstat &= ~16; + pWall->overpicnum = MIRRORBROKE; + A_PlaySound(GLASS_HEAVYBREAK, nSprite); return; } } - if (wal->overpicnum == MIRROR && wal->pal != 4) + if (pWall->overpicnum == MIRROR && pWall->pal != 4) { - switch (DYNAMICTILEMAP(atwith)) + switch (DYNAMICTILEMAP(nWeapon)) { - case HEAVYHBOMB__STATIC: - case RADIUSEXPLOSION__STATIC: - case RPG__STATIC: - case HYDRENT__STATIC: - case SEENINE__STATIC: - case OOZFILTER__STATIC: - case EXPLODINGBARREL__STATIC: - if (wal->nextwall == -1 || wall[wal->nextwall].pal != 4) - { - A_SpawnWallGlass(spr,dawallnum,70); - wal->cstat &= ~16; - wal->overpicnum = MIRRORBROKE; - A_PlaySound(GLASS_HEAVYBREAK,spr); - return; - } - } - } - - if (((wal->cstat&16) || wal->overpicnum == BIGFORCE) && wal->nextsector >= 0) - if (sector[wal->nextsector].floorz > pos->z) - if (sector[wal->nextsector].floorz != sector[wal->nextsector].ceilingz) - { - int32_t switchpicnum = G_GetForcefieldPicnum(dawallnum); - - switch (DYNAMICTILEMAP(switchpicnum)) + case HEAVYHBOMB__STATIC: + case RADIUSEXPLOSION__STATIC: + case RPG__STATIC: + case HYDRENT__STATIC: + case SEENINE__STATIC: + case OOZFILTER__STATIC: + case EXPLODINGBARREL__STATIC: + if (pWall->nextwall == -1 || wall[pWall->nextwall].pal != 4) { - case W_FORCEFIELD__STATIC: - wal->extra = 1; // tell the forces to animate - /* fall-through */ - case BIGFORCE__STATIC: - updatesector(pos->x, pos->y, &sn); - if (sn < 0) - return; - - { - int32_t xr=32, yr=32; - - if (atwith == -1) - xr = yr = 8; - else if (atwith == CHAINGUN) - { - xr = 16+sprite[spr].xrepeat; - yr = 16+sprite[spr].yrepeat; - } - - i = A_InsertSprite(sn, pos->x,pos->y,pos->z, FORCERIPPLE, - -127, xr,yr, 0,0,0,spr,5); - } - - CS |= 18+128; - SA = getangle(wal->x-wall[wal->point2].x, - wal->y-wall[wal->point2].y)-512; - - A_PlaySound(SOMETHINGHITFORCE,i); - return; - - case FANSPRITE__STATIC: - wal->overpicnum = FANSPRITEBROKE; - wal->cstat &= 65535-65; - if (wal->nextwall >= 0) - { - wall[wal->nextwall].overpicnum = FANSPRITEBROKE; - wall[wal->nextwall].cstat &= 65535-65; - } - A_PlaySound(VENT_BUST,spr); - A_PlaySound(GLASS_BREAKING,spr); - return; - - case GLASS__STATIC: - updatesector(pos->x,pos->y,&sn); - if (sn < 0) - return; - wal->overpicnum=GLASS2; - A_SpawnWallGlass(spr,dawallnum,10); - wal->cstat = 0; - - if (wal->nextwall >= 0) - wall[wal->nextwall].cstat = 0; - - i = A_InsertSprite(sn,pos->x,pos->y,pos->z,SECTOREFFECTOR,0,0,0,g_player[0].ps->ang,0,0,spr,3); - SLT = 128; - T2 = 5; - T3 = dawallnum; - A_PlaySound(GLASS_BREAKING,i); - return; - - case STAINGLASS1__STATIC: - updatesector(pos->x,pos->y,&sn); - if (sn < 0) - return; - A_SpawnRandomGlass(spr,dawallnum,80); - wal->cstat = 0; - if (wal->nextwall >= 0) - wall[wal->nextwall].cstat = 0; - A_PlaySound(VENT_BUST,spr); - A_PlaySound(GLASS_BREAKING,spr); + A_SpawnWallGlass(nSprite, nWall, 70); + pWall->cstat &= ~16; + pWall->overpicnum = MIRRORBROKE; + A_PlaySound(GLASS_HEAVYBREAK, nSprite); return; } - } + } + } - switch (DYNAMICTILEMAP(wal->picnum)) + if ((((pWall->cstat & 16) || pWall->overpicnum == BIGFORCE) && pWall->nextsector >= 0) && + (sector[pWall->nextsector].floorz > vPos->z) && + (sector[pWall->nextsector].floorz != sector[pWall->nextsector].ceilingz)) { - case COLAMACHINE__STATIC: - case VENDMACHINE__STATIC: - BreakWall(wal->picnum+2,spr,dawallnum); - A_PlaySound(VENT_BUST,spr); - return; + int const nSwitchPicnum = G_GetForcefieldPicnum(nWall); - case OJ__STATIC: - case FEMPIC2__STATIC: - case FEMPIC3__STATIC: - - case SCREENBREAK6__STATIC: - case SCREENBREAK7__STATIC: - case SCREENBREAK8__STATIC: - - case SCREENBREAK1__STATIC: - case SCREENBREAK2__STATIC: - case SCREENBREAK3__STATIC: - case SCREENBREAK4__STATIC: - case SCREENBREAK5__STATIC: - - case SCREENBREAK9__STATIC: - case SCREENBREAK10__STATIC: - case SCREENBREAK11__STATIC: - case SCREENBREAK12__STATIC: - case SCREENBREAK13__STATIC: - case SCREENBREAK14__STATIC: - case SCREENBREAK15__STATIC: - case SCREENBREAK16__STATIC: - case SCREENBREAK17__STATIC: - case SCREENBREAK18__STATIC: - case SCREENBREAK19__STATIC: - case BORNTOBEWILDSCREEN__STATIC: - A_SpawnWallGlass(spr,dawallnum,30); - wal->picnum=W_SCREENBREAK+(krand()%3); - A_PlaySound(GLASS_HEAVYBREAK,spr); - return; - - case W_TECHWALL5__STATIC: - case W_TECHWALL6__STATIC: - case W_TECHWALL7__STATIC: - case W_TECHWALL8__STATIC: - case W_TECHWALL9__STATIC: - BreakWall(wal->picnum+1,spr,dawallnum); - return; - - case W_MILKSHELF__STATIC: - BreakWall(W_MILKSHELFBROKE,spr,dawallnum); - return; - - case W_TECHWALL10__STATIC: - BreakWall(W_HITTECHWALL10,spr,dawallnum); - return; - - case W_TECHWALL1__STATIC: - case W_TECHWALL11__STATIC: - case W_TECHWALL12__STATIC: - case W_TECHWALL13__STATIC: - case W_TECHWALL14__STATIC: - BreakWall(W_HITTECHWALL1,spr,dawallnum); - return; - - case W_TECHWALL15__STATIC: - BreakWall(W_HITTECHWALL15,spr,dawallnum); - return; - - case W_TECHWALL16__STATIC: - BreakWall(W_HITTECHWALL16,spr,dawallnum); - return; - - case W_TECHWALL2__STATIC: - BreakWall(W_HITTECHWALL2,spr,dawallnum); - return; - - case W_TECHWALL3__STATIC: - BreakWall(W_HITTECHWALL3,spr,dawallnum); - return; - - case W_TECHWALL4__STATIC: - BreakWall(W_HITTECHWALL4,spr,dawallnum); - return; - - case ATM__STATIC: - wal->picnum = ATMBROKE; - A_SpawnMultiple(spr, MONEY, 1+(krand()&7)); - A_PlaySound(GLASS_HEAVYBREAK,spr); - break; - - case WALLLIGHT1__STATIC: - case WALLLIGHT2__STATIC: - case WALLLIGHT3__STATIC: - case WALLLIGHT4__STATIC: - case TECHLIGHT2__STATIC: - case TECHLIGHT4__STATIC: - A_PlaySound(rnd(128) ? GLASS_HEAVYBREAK : GLASS_BREAKING, spr); - A_SpawnWallGlass(spr,dawallnum,30); - - if (wal->picnum == WALLLIGHT1) - wal->picnum = WALLLIGHTBUST1; - - if (wal->picnum == WALLLIGHT2) - wal->picnum = WALLLIGHTBUST2; - - if (wal->picnum == WALLLIGHT3) - wal->picnum = WALLLIGHTBUST3; - - if (wal->picnum == WALLLIGHT4) - wal->picnum = WALLLIGHTBUST4; - - if (wal->picnum == TECHLIGHT2) - wal->picnum = TECHLIGHTBUST2; - - if (wal->picnum == TECHLIGHT4) - wal->picnum = TECHLIGHTBUST4; - - if (wal->lotag == 0) - return; - - sn = wal->nextsector; - if (sn < 0) - return; - darkestwall = 0; - - wal = &wall[sector[sn].wallptr]; - for (i=sector[sn].wallnum; i > 0; i--,wal++) - if (wal->shade > darkestwall) - darkestwall=wal->shade; - - j = krand()&1; - - for (SPRITES_OF(STAT_EFFECTOR, i)) - if (SHT == wall[dawallnum].lotag && SLT == SE_3_RANDOM_LIGHTS_AFTER_SHOT_OUT) + switch (DYNAMICTILEMAP(nSwitchPicnum)) + { + case W_FORCEFIELD__STATIC: + pWall->extra = 1; // tell the forces to animate + /* fall-through */ + case BIGFORCE__STATIC: { - T3 = j; - T4 = darkestwall; - T5 = 1; + updatesector(vPos->x, vPos->y, &nSectnum); + if (nSectnum < 0) + return; + + int nXrepeat = 32; + int nYrepeat = 32; + + if (nWeapon == -1) + nXrepeat = nYrepeat = 8; + else if (nWeapon == CHAINGUN) + { + nXrepeat = 16 + sprite[nSprite].xrepeat; + nYrepeat = 16 + sprite[nSprite].yrepeat; + } + + i = A_InsertSprite(nSectnum, vPos->x, vPos->y, vPos->z, FORCERIPPLE, -127, nXrepeat, nYrepeat, 0, + 0, 0, nSprite, 5); + + CS |= 18 + 128; + SA = getangle(pWall->x - wall[pWall->point2].x, pWall->y - wall[pWall->point2].y) - 512; + + A_PlaySound(SOMETHINGHITFORCE, i); + } + return; + + case FANSPRITE__STATIC: + pWall->overpicnum = FANSPRITEBROKE; + pWall->cstat &= 65535 - 65; + if (pWall->nextwall >= 0) + { + wall[pWall->nextwall].overpicnum = FANSPRITEBROKE; + wall[pWall->nextwall].cstat &= 65535 - 65; + } + A_PlaySound(VENT_BUST, nSprite); + A_PlaySound(GLASS_BREAKING, nSprite); + return; + + case GLASS__STATIC: + updatesector(vPos->x, vPos->y, &nSectnum); + if (nSectnum < 0) + return; + pWall->overpicnum = GLASS2; + A_SpawnWallGlass(nSprite, nWall, 10); + pWall->cstat = 0; + + if (pWall->nextwall >= 0) + wall[pWall->nextwall].cstat = 0; + + i = A_InsertSprite(nSectnum, vPos->x, vPos->y, vPos->z, SECTOREFFECTOR, 0, 0, 0, + g_player[0].ps->ang, 0, 0, nSprite, 3); + SLT = 128; + T2 = 5; + T3 = nWall; + A_PlaySound(GLASS_BREAKING, i); + return; + + case STAINGLASS1__STATIC: + updatesector(vPos->x, vPos->y, &nSectnum); + if (nSectnum < 0) + return; + A_SpawnRandomGlass(nSprite, nWall, 80); + pWall->cstat = 0; + if (pWall->nextwall >= 0) + wall[pWall->nextwall].cstat = 0; + A_PlaySound(VENT_BUST, nSprite); + A_PlaySound(GLASS_BREAKING, nSprite); + return; + } } - break; + switch (DYNAMICTILEMAP(pWall->picnum)) + { + case COLAMACHINE__STATIC: + case VENDMACHINE__STATIC: + G_BreakWall(pWall->picnum + 2, nSprite, nWall); + A_PlaySound(VENT_BUST, nSprite); + return; + + case OJ__STATIC: + case FEMPIC2__STATIC: + case FEMPIC3__STATIC: + + case SCREENBREAK6__STATIC: + case SCREENBREAK7__STATIC: + case SCREENBREAK8__STATIC: + + case SCREENBREAK1__STATIC: + case SCREENBREAK2__STATIC: + case SCREENBREAK3__STATIC: + case SCREENBREAK4__STATIC: + case SCREENBREAK5__STATIC: + + case SCREENBREAK9__STATIC: + case SCREENBREAK10__STATIC: + case SCREENBREAK11__STATIC: + case SCREENBREAK12__STATIC: + case SCREENBREAK13__STATIC: + case SCREENBREAK14__STATIC: + case SCREENBREAK15__STATIC: + case SCREENBREAK16__STATIC: + case SCREENBREAK17__STATIC: + case SCREENBREAK18__STATIC: + case SCREENBREAK19__STATIC: + case BORNTOBEWILDSCREEN__STATIC: + A_SpawnWallGlass(nSprite, nWall, 30); + pWall->picnum = W_SCREENBREAK + (krand() % 3); + A_PlaySound(GLASS_HEAVYBREAK, nSprite); + return; + + case W_TECHWALL5__STATIC: + case W_TECHWALL6__STATIC: + case W_TECHWALL7__STATIC: + case W_TECHWALL8__STATIC: + case W_TECHWALL9__STATIC: + G_BreakWall(pWall->picnum + 1, nSprite, nWall); + return; + + case W_MILKSHELF__STATIC: + G_BreakWall(W_MILKSHELFBROKE, nSprite, nWall); + return; + + case W_TECHWALL10__STATIC: + G_BreakWall(W_HITTECHWALL10, nSprite, nWall); + return; + + case W_TECHWALL1__STATIC: + case W_TECHWALL11__STATIC: + case W_TECHWALL12__STATIC: + case W_TECHWALL13__STATIC: + case W_TECHWALL14__STATIC: + G_BreakWall(W_HITTECHWALL1, nSprite, nWall); + return; + + case W_TECHWALL15__STATIC: + G_BreakWall(W_HITTECHWALL15, nSprite, nWall); + return; + + case W_TECHWALL16__STATIC: + G_BreakWall(W_HITTECHWALL16, nSprite, nWall); + return; + + case W_TECHWALL2__STATIC: + G_BreakWall(W_HITTECHWALL2, nSprite, nWall); + return; + + case W_TECHWALL3__STATIC: + G_BreakWall(W_HITTECHWALL3, nSprite, nWall); + return; + + case W_TECHWALL4__STATIC: + G_BreakWall(W_HITTECHWALL4, nSprite, nWall); + return; + + case ATM__STATIC: + pWall->picnum = ATMBROKE; + A_SpawnMultiple(nSprite, MONEY, 1 + (krand() & 7)); + A_PlaySound(GLASS_HEAVYBREAK, nSprite); + break; + + case WALLLIGHT1__STATIC: + case WALLLIGHT2__STATIC: + case WALLLIGHT3__STATIC: + case WALLLIGHT4__STATIC: + case TECHLIGHT2__STATIC: + case TECHLIGHT4__STATIC: + { + A_PlaySound(rnd(128) ? GLASS_HEAVYBREAK : GLASS_BREAKING, nSprite); + A_SpawnWallGlass(nSprite, nWall, 30); + + if (pWall->picnum == WALLLIGHT1) + pWall->picnum = WALLLIGHTBUST1; + + if (pWall->picnum == WALLLIGHT2) + pWall->picnum = WALLLIGHTBUST2; + + if (pWall->picnum == WALLLIGHT3) + pWall->picnum = WALLLIGHTBUST3; + + if (pWall->picnum == WALLLIGHT4) + pWall->picnum = WALLLIGHTBUST4; + + if (pWall->picnum == TECHLIGHT2) + pWall->picnum = TECHLIGHTBUST2; + + if (pWall->picnum == TECHLIGHT4) + pWall->picnum = TECHLIGHTBUST4; + + if (pWall->lotag == 0) + return; + + nSectnum = pWall->nextsector; + + if (nSectnum < 0) + return; + + int nDarkestWall = 0; + + pWall = &wall[sector[nSectnum].wallptr]; + + for (i = sector[nSectnum].wallnum; i > 0; i--, pWall++) + if (pWall->shade > nDarkestWall) + nDarkestWall = pWall->shade; + + int const nRand = krand() & 1; + + for (SPRITES_OF(STAT_EFFECTOR, i)) + if (SHT == wall[nWall].lotag && SLT == SE_3_RANDOM_LIGHTS_AFTER_SHOT_OUT) + { + T3 = nRand; + T4 = nDarkestWall; + T5 = 1; + } + + break; + } } } // NOTE: return value never examined in any of the callers. -int32_t Sect_DamageCeilingOrFloor(int32_t floorp, int32_t sn) +int Sect_DamageCeilingOrFloor(int nDmgFloor, int const nSectnum) { - int32_t i, j; - - const int32_t RETURN_in = floorp ? 131072+sn : 65536+sn; + int const RETURN_in = nDmgFloor ? 131072+nSectnum : 65536+nSectnum; // NOTE: pass RETURN in the dist argument, too. - int32_t ret = VM_OnEventWithBoth(EVENT_DAMAGEHPLANE, g_player[screenpeek].ps->i, screenpeek, + int32_t const nReturn = VM_OnEventWithBoth(EVENT_DAMAGEHPLANE, g_player[screenpeek].ps->i, screenpeek, RETURN_in, RETURN_in); - if (ret < 0) + if (nReturn < 0) return 0; - if (floorp) - return 0; + int16_t * const pPicnum = nDmgFloor ? §or[nSectnum].floorpicnum : §or[nSectnum].ceilingpicnum; - if (ret == (1<<20)) + if (nReturn == (1<<20)) { // Execute the hard-coded stuff without changing picnum (expected to // have been done by the event). goto GLASSBREAK_CODE; } - switch (DYNAMICTILEMAP(sector[sn].ceilingpicnum)) + switch (DYNAMICTILEMAP(*pPicnum)) { - case WALLLIGHT1__STATIC: - case WALLLIGHT2__STATIC: - case WALLLIGHT3__STATIC: - case WALLLIGHT4__STATIC: - case TECHLIGHT2__STATIC: - case TECHLIGHT4__STATIC: + case WALLLIGHT1__STATIC: *pPicnum = WALLLIGHTBUST1; goto GLASSBREAK_CODE; + case WALLLIGHT2__STATIC: *pPicnum = WALLLIGHTBUST2; goto GLASSBREAK_CODE; + case WALLLIGHT3__STATIC: *pPicnum = WALLLIGHTBUST3; goto GLASSBREAK_CODE; + case WALLLIGHT4__STATIC: *pPicnum = WALLLIGHTBUST4; goto GLASSBREAK_CODE; + case TECHLIGHT2__STATIC: sector[nSectnum].ceilingpicnum = TECHLIGHTBUST2; goto GLASSBREAK_CODE; + case TECHLIGHT4__STATIC: sector[nSectnum].ceilingpicnum = TECHLIGHTBUST4; - if (sector[sn].ceilingpicnum == WALLLIGHT1) - sector[sn].ceilingpicnum = WALLLIGHTBUST1; + GLASSBREAK_CODE: + A_SpawnCeilingGlass(g_player[myconnectindex].ps->i, nSectnum, 10); + A_PlaySound(GLASS_BREAKING, g_player[screenpeek].ps->i); - if (sector[sn].ceilingpicnum == WALLLIGHT2) - sector[sn].ceilingpicnum = WALLLIGHTBUST2; - - if (sector[sn].ceilingpicnum == WALLLIGHT3) - sector[sn].ceilingpicnum = WALLLIGHTBUST3; - - if (sector[sn].ceilingpicnum == WALLLIGHT4) - sector[sn].ceilingpicnum = WALLLIGHTBUST4; - - if (sector[sn].ceilingpicnum == TECHLIGHT2) - sector[sn].ceilingpicnum = TECHLIGHTBUST2; - - if (sector[sn].ceilingpicnum == TECHLIGHT4) - sector[sn].ceilingpicnum = TECHLIGHTBUST4; - - GLASSBREAK_CODE: - A_SpawnCeilingGlass(g_player[myconnectindex].ps->i,sn,10); - A_PlaySound(GLASS_BREAKING,g_player[screenpeek].ps->i); - - if (sector[sn].hitag == 0) - { - for (SPRITES_OF_SECT(sn, i)) + if (sector[nSectnum].hitag == 0) { - if (PN == SECTOREFFECTOR && SLT == SE_12_LIGHT_SWITCH) + for (int SPRITES_OF_SECT(nSectnum, i)) { - for (SPRITES_OF(STAT_EFFECTOR, j)) - if (sprite[j].hitag == SHT) - actor[j].t_data[3] = 1; - break; + if (PN == SECTOREFFECTOR && SLT == SE_12_LIGHT_SWITCH) + { + for (int SPRITES_OF(STAT_EFFECTOR, j)) + if (sprite[j].hitag == SHT) + actor[j].t_data[3] = 1; + break; + } } } - } - j = krand()&1; + int j = krand() & 1; - for (SPRITES_OF(STAT_EFFECTOR, i)) - if (SHT == sector[sn].hitag && SLT == SE_3_RANDOM_LIGHTS_AFTER_SHOT_OUT) + for (int SPRITES_OF(STAT_EFFECTOR, i)) { - T3 = j; - T5 = 1; + if (SHT == sector[nSectnum].hitag && SLT == SE_3_RANDOM_LIGHTS_AFTER_SHOT_OUT) + { + T3 = j; + T5 = 1; + } } - return 1; + return 1; } return 0; @@ -2260,7 +2210,7 @@ void A_DamageObject(int32_t i,int32_t sn) if ((sprite[sn].picnum == FREEZEBLAST || sprite[sn].owner != i) && sprite[i].statnum != STAT_PROJECTILE) { - if (A_CheckEnemySprite((uspritetype *)&sprite[i]) == 1) + if (A_CheckEnemySprite(&sprite[i]) == 1) { if (sprite[sn].picnum == RPG) sprite[sn].extra <<= 1; @@ -2383,13 +2333,13 @@ static int32_t P_CheckDetonatorSpecialCase(DukePlayer_t *const p, int32_t weapid return 0; } -void P_HandleSharedKeys(int32_t snum) +void P_HandleSharedKeys(int32_t nPlayer) { - int32_t i, k = 0; - uint32_t sb_snum = g_player[snum].sync->bits, j; - DukePlayer_t *const p = g_player[snum].ps; + DukePlayer_t *const pPlayer = g_player[nPlayer].ps; - if (p->cheat_phase == 1) return; + if (pPlayer->cheat_phase == 1) return; + + uint32_t nPlayerBits = g_player[nPlayer].sync->bits, j; // 1<<0 = jump // 1<<1 = crouch @@ -2421,32 +2371,33 @@ void P_HandleSharedKeys(int32_t snum) // 1<<30 = !inventory // 1<<31 = !escape - i = p->aim_mode; - p->aim_mode = (sb_snum>>SK_AIMMODE)&1; - if (p->aim_mode < i) - p->return_to_center = 9; + int const nAimMode = pPlayer->aim_mode; - if (TEST_SYNC_KEY(sb_snum, SK_QUICK_KICK) && p->quick_kick == 0) - if (PWEAPON(snum, p->curr_weapon, WorksLike) != KNEE_WEAPON || p->kickback_pic == 0) + pPlayer->aim_mode = (nPlayerBits>>SK_AIMMODE)&1; + if (pPlayer->aim_mode < nAimMode) + pPlayer->return_to_center = 9; + + if (TEST_SYNC_KEY(nPlayerBits, SK_QUICK_KICK) && pPlayer->quick_kick == 0) + if (PWEAPON(nPlayer, pPlayer->curr_weapon, WorksLike) != KNEE_WEAPON || pPlayer->kickback_pic == 0) { - if (VM_OnEvent(EVENT_QUICKKICK,g_player[snum].ps->i,snum) == 0) + if (VM_OnEvent(EVENT_QUICKKICK,g_player[nPlayer].ps->i,nPlayer) == 0) { - p->quick_kick = 14; - if (p->fta == 0 || p->ftq == 80) - P_DoQuote(QUOTE_MIGHTY_FOOT,p); + pPlayer->quick_kick = 14; + if (pPlayer->fta == 0 || pPlayer->ftq == 80) + P_DoQuote(QUOTE_MIGHTY_FOOT,pPlayer); } } - j = sb_snum & ((15u<interface_toggle_flag; - p->interface_toggle_flag |= sb_snum | ((sb_snum&0xf00)?0xf00:0); - p->interface_toggle_flag &= j | ((j&0xf00)?0xf00:0); + nPlayerBits = j & ~pPlayer->interface_toggle_flag; + pPlayer->interface_toggle_flag |= nPlayerBits | ((nPlayerBits&0xf00)?0xf00:0); + pPlayer->interface_toggle_flag &= j | ((j&0xf00)?0xf00:0); - if (sb_snum && TEST_SYNC_KEY(sb_snum, SK_MULTIFLAG) == 0) + if (nPlayerBits && TEST_SYNC_KEY(nPlayerBits, SK_MULTIFLAG) == 0) { - if (TEST_SYNC_KEY(sb_snum, SK_PAUSE)) + if (TEST_SYNC_KEY(nPlayerBits, SK_PAUSE)) { KB_ClearKeyDown(sc_Pause); if (ud.pause_on) @@ -2470,138 +2421,138 @@ void P_HandleSharedKeys(int32_t snum) if (ud.pause_on) return; - if (sprite[p->i].extra <= 0) return; // if dead... + if (sprite[pPlayer->i].extra <= 0) return; // if dead... - if (TEST_SYNC_KEY(sb_snum, SK_INVENTORY) && p->newowner == -1) // inventory button generates event for selected item + if (TEST_SYNC_KEY(nPlayerBits, SK_INVENTORY) && pPlayer->newowner == -1) // inventory button generates event for selected item { - if (VM_OnEvent(EVENT_INVENTORY,g_player[snum].ps->i,snum) == 0) + if (VM_OnEvent(EVENT_INVENTORY,g_player[nPlayer].ps->i,nPlayer) == 0) { - switch (p->inven_icon) + switch (pPlayer->inven_icon) { - case ICON_JETPACK: sb_snum |= BIT(SK_JETPACK); break; - case ICON_HOLODUKE: sb_snum |= BIT(SK_HOLODUKE); break; - case ICON_HEATS: sb_snum |= BIT(SK_NIGHTVISION); break; - case ICON_FIRSTAID: sb_snum |= BIT(SK_MEDKIT); break; - case ICON_STEROIDS: sb_snum |= BIT(SK_STEROIDS); break; + case ICON_JETPACK: nPlayerBits |= BIT(SK_JETPACK); break; + case ICON_HOLODUKE: nPlayerBits |= BIT(SK_HOLODUKE); break; + case ICON_HEATS: nPlayerBits |= BIT(SK_NIGHTVISION); break; + case ICON_FIRSTAID: nPlayerBits |= BIT(SK_MEDKIT); break; + case ICON_STEROIDS: nPlayerBits |= BIT(SK_STEROIDS); break; } } } - if (TEST_SYNC_KEY(sb_snum, SK_NIGHTVISION)) + if (TEST_SYNC_KEY(nPlayerBits, SK_NIGHTVISION)) { - if (VM_OnEvent(EVENT_USENIGHTVISION,g_player[snum].ps->i,snum) == 0 - && p->inv_amount[GET_HEATS] > 0) + if (VM_OnEvent(EVENT_USENIGHTVISION,g_player[nPlayer].ps->i,nPlayer) == 0 + && pPlayer->inv_amount[GET_HEATS] > 0) { - p->heat_on = !p->heat_on; - P_UpdateScreenPal(p); - p->inven_icon = ICON_HEATS; - A_PlaySound(NITEVISION_ONOFF,p->i); - P_DoQuote(QUOTE_NVG_OFF-!!p->heat_on,p); + pPlayer->heat_on = !pPlayer->heat_on; + P_UpdateScreenPal(pPlayer); + pPlayer->inven_icon = ICON_HEATS; + A_PlaySound(NITEVISION_ONOFF,pPlayer->i); + P_DoQuote(QUOTE_NVG_OFF-!!pPlayer->heat_on,pPlayer); } } - if (TEST_SYNC_KEY(sb_snum, SK_STEROIDS)) + if (TEST_SYNC_KEY(nPlayerBits, SK_STEROIDS)) { - if (VM_OnEvent(EVENT_USESTEROIDS,g_player[snum].ps->i,snum) == 0) + if (VM_OnEvent(EVENT_USESTEROIDS,g_player[nPlayer].ps->i,nPlayer) == 0) { - if (p->inv_amount[GET_STEROIDS] == 400) + if (pPlayer->inv_amount[GET_STEROIDS] == 400) { - p->inv_amount[GET_STEROIDS]--; - A_PlaySound(DUKE_TAKEPILLS,p->i); - P_DoQuote(QUOTE_USED_STEROIDS,p); + pPlayer->inv_amount[GET_STEROIDS]--; + A_PlaySound(DUKE_TAKEPILLS,pPlayer->i); + P_DoQuote(QUOTE_USED_STEROIDS,pPlayer); } - if (p->inv_amount[GET_STEROIDS] > 0) - p->inven_icon = ICON_STEROIDS; + if (pPlayer->inv_amount[GET_STEROIDS] > 0) + pPlayer->inven_icon = ICON_STEROIDS; } return; // is there significance to returning? } - if (p->refresh_inventory) - sb_snum |= BIT(SK_INV_LEFT); // emulate move left... + if (pPlayer->refresh_inventory) + nPlayerBits |= BIT(SK_INV_LEFT); // emulate move left... - if (p->newowner == -1 && (TEST_SYNC_KEY(sb_snum, SK_INV_LEFT) || TEST_SYNC_KEY(sb_snum, SK_INV_RIGHT))) + if (pPlayer->newowner == -1 && (TEST_SYNC_KEY(nPlayerBits, SK_INV_LEFT) || TEST_SYNC_KEY(nPlayerBits, SK_INV_RIGHT))) { - p->invdisptime = GAMETICSPERSEC*2; + pPlayer->invdisptime = GAMETICSPERSEC*2; - int32_t k = !!(TEST_SYNC_KEY(sb_snum, SK_INV_RIGHT)); + int const nInventoryRight = !!(TEST_SYNC_KEY(nPlayerBits, SK_INV_RIGHT)); - if (p->refresh_inventory) p->refresh_inventory = 0; - int32_t dainv = p->inven_icon; + if (pPlayer->refresh_inventory) pPlayer->refresh_inventory = 0; + int32_t nInventory = pPlayer->inven_icon; - i = 0; + int i = 0; CHECKINV1: if (i < 9) { i++; - switch (dainv) + switch (nInventory) { - case ICON_JETPACK: - case ICON_SCUBA: - case ICON_STEROIDS: - case ICON_HOLODUKE: - case ICON_HEATS: - if (p->inv_amount[icon_to_inv[dainv]] > 0 && i > 1) - break; - if (k) dainv++; - else dainv--; - goto CHECKINV1; - case ICON_NONE: - case ICON_FIRSTAID: - if (p->inv_amount[GET_FIRSTAID] > 0 && i > 1) - break; - if (k) dainv = 2; - else dainv = 7; - goto CHECKINV1; - case ICON_BOOTS: - if (p->inv_amount[GET_BOOTS] > 0 && i > 1) - break; - if (k) dainv = 1; - else dainv = 6; - goto CHECKINV1; + case ICON_JETPACK: + case ICON_SCUBA: + case ICON_STEROIDS: + case ICON_HOLODUKE: + case ICON_HEATS: + if (pPlayer->inv_amount[icon_to_inv[nInventory]] > 0 && i > 1) + break; + if (nInventoryRight) + nInventory++; + else + nInventory--; + goto CHECKINV1; + case ICON_NONE: + case ICON_FIRSTAID: + if (pPlayer->inv_amount[GET_FIRSTAID] > 0 && i > 1) + break; + nInventory = nInventoryRight ? 2 : 7; + goto CHECKINV1; + case ICON_BOOTS: + if (pPlayer->inv_amount[GET_BOOTS] > 0 && i > 1) + break; + nInventory = nInventoryRight ? 1 : 6; + goto CHECKINV1; } } - else dainv = 0; + else nInventory = 0; - if (TEST_SYNC_KEY(sb_snum, SK_INV_LEFT)) // Inventory_Left + if (TEST_SYNC_KEY(nPlayerBits, SK_INV_LEFT)) // Inventory_Left { /*Gv_SetVar(g_iReturnVarID,dainv,g_player[snum].ps->i,snum);*/ - dainv = VM_OnEventWithReturn(EVENT_INVENTORYLEFT,g_player[snum].ps->i,snum, dainv); + nInventory = VM_OnEventWithReturn(EVENT_INVENTORYLEFT,g_player[nPlayer].ps->i,nPlayer, nInventory); } - else if (TEST_SYNC_KEY(sb_snum, SK_INV_RIGHT)) // Inventory_Right + else if (TEST_SYNC_KEY(nPlayerBits, SK_INV_RIGHT)) // Inventory_Right { /*Gv_SetVar(g_iReturnVarID,dainv,g_player[snum].ps->i,snum);*/ - dainv = VM_OnEventWithReturn(EVENT_INVENTORYRIGHT,g_player[snum].ps->i,snum, dainv); + nInventory = VM_OnEventWithReturn(EVENT_INVENTORYRIGHT,g_player[nPlayer].ps->i,nPlayer, nInventory); } - if (dainv >= 1) + if (nInventory >= 1) { - p->inven_icon = dainv; + pPlayer->inven_icon = nInventory; - if (dainv || p->inv_amount[GET_FIRSTAID]) + if (nInventory || pPlayer->inv_amount[GET_FIRSTAID]) { static const int32_t i[8] = { QUOTE_MEDKIT, QUOTE_STEROIDS, QUOTE_HOLODUKE, QUOTE_JETPACK, QUOTE_NVG, QUOTE_SCUBA, QUOTE_BOOTS, 0 }; - if (dainv>=1 && dainv<=9) - P_DoQuote(i[dainv-1], p); + if (nInventory>=1 && nInventory<=9) + P_DoQuote(i[nInventory-1], pPlayer); } } } - j = ((sb_snum&(15<>SK_WEAPON_BITS) - 1; + j = ((nPlayerBits&(15<>SK_WEAPON_BITS) - 1; switch ((int32_t)j) { case -1: break; default: - j = VM_OnEventWithReturn(EVENT_WEAPKEY1+j,p->i,snum, j); + j = VM_OnEventWithReturn(EVENT_WEAPKEY1+j,pPlayer->i,nPlayer, j); break; case 10: - j = VM_OnEventWithReturn(EVENT_PREVIOUSWEAPON,p->i,snum, j); + j = VM_OnEventWithReturn(EVENT_PREVIOUSWEAPON,pPlayer->i,nPlayer, j); break; case 11: - j = VM_OnEventWithReturn(EVENT_NEXTWEAPON,p->i,snum, j); + j = VM_OnEventWithReturn(EVENT_NEXTWEAPON,pPlayer->i,nPlayer, j); break; } @@ -2610,80 +2561,78 @@ CHECKINV1: // positive ones >= MAX_WEAPONS are allowed. However, the code below is // a bit inconsistent in checking "j". - if (p->reloading == 1) + if (pPlayer->reloading == 1) j = -1; - else if ((uint32_t)j < MAX_WEAPONS && p->kickback_pic == 1 && p->weapon_pos == 1) + else if ((uint32_t)j < MAX_WEAPONS && pPlayer->kickback_pic == 1 && pPlayer->weapon_pos == 1) { - p->wantweaponfire = j; - p->kickback_pic = 0; + pPlayer->wantweaponfire = j; + pPlayer->kickback_pic = 0; } - if ((int32_t)j != -1 && p->last_pissed_time <= (GAMETICSPERSEC * 218) && p->show_empty_weapon == 0 && - p->kickback_pic == 0 && p->quick_kick == 0 && sprite[p->i].xrepeat > 32 && p->access_incs == 0 && - p->knee_incs == 0) + if ((int32_t)j != -1 && pPlayer->last_pissed_time <= (GAMETICSPERSEC * 218) && pPlayer->show_empty_weapon == 0 && + pPlayer->kickback_pic == 0 && pPlayer->quick_kick == 0 && sprite[pPlayer->i].xrepeat > 32 && pPlayer->access_incs == 0 && + pPlayer->knee_incs == 0) { // if( ( p->weapon_pos == 0 || ( p->holster_weapon && p->weapon_pos == WEAPON_POS_LOWER ) )) { if (j == 10 || j == 11) { - k = p->curr_weapon; - j = (j == 10 ? -1 : 1); // JBF: prev (-1) or next (1) weapon choice - i = k; + int nWeapon = pPlayer->curr_weapon; - while ((k >= 0 && k < 11) || (PLUTOPAK && k == GROW_WEAPON)) + j = (j == 10 ? -1 : 1); // JBF: prev (-1) or next (1) weapon choice + int i = nWeapon; + + while ((nWeapon >= 0 && nWeapon < 11) || (PLUTOPAK && nWeapon == GROW_WEAPON)) { // this accounts for the expander when handling next/previous - switch (k) + switch (nWeapon) { case DEVISTATOR_WEAPON: if ((int32_t) j == -1) { if (PLUTOPAK) - k = GROW_WEAPON; + nWeapon = GROW_WEAPON; else - k--; + nWeapon--; } else - k++; + nWeapon++; break; case GROW_WEAPON: - if ((int32_t)j == -1) - k = SHRINKER_WEAPON; - else - k = DEVISTATOR_WEAPON; + nWeapon = ((int32_t) j == -1) ? SHRINKER_WEAPON : DEVISTATOR_WEAPON; break; case SHRINKER_WEAPON: if ((int32_t)j == 1) { if (PLUTOPAK) - k = GROW_WEAPON; + nWeapon = GROW_WEAPON; else - k++; + nWeapon++; } else - k--; + nWeapon--; break; case HANDREMOTE_WEAPON: - i = k = HANDBOMB_WEAPON; + i = nWeapon = HANDBOMB_WEAPON; default: - k += j; + nWeapon += j; break; } - if (k == -1) k = FREEZE_WEAPON; - else if (k == 10) k = KNEE_WEAPON; + if (nWeapon == -1) nWeapon = FREEZE_WEAPON; + else if (nWeapon == 10) nWeapon = KNEE_WEAPON; - if (((p->gotweapon & (1<ammo_amount[k] > 0) || P_CheckDetonatorSpecialCase(p, k)) + if (((pPlayer->gotweapon & (1<ammo_amount[nWeapon] > 0) || P_CheckDetonatorSpecialCase(pPlayer, nWeapon)) { - j = k; + j = nWeapon; break; } - if (i == k) // absolutely no weapons, so use foot + if (i == nWeapon) // absolutely no weapons, so use foot { j = KNEE_WEAPON; break; @@ -2691,58 +2640,58 @@ CHECKINV1: } if (j == SHRINKER_WEAPON) - p->subweapon &= ~(1 << GROW_WEAPON); + pPlayer->subweapon &= ~(1 << GROW_WEAPON); else if (j == GROW_WEAPON) - p->subweapon |= (1<subweapon |= (1<i,snum, j); + j = VM_OnEventWithReturn(EVENT_SELECTWEAPON,pPlayer->i,nPlayer, j); // XXX: any signifcance to "<= MAX_WEAPONS" instead of "<"? if ((int32_t)j != -1 && j <= MAX_WEAPONS) { - if (P_CheckDetonatorSpecialCase(p, j)) + if (P_CheckDetonatorSpecialCase(pPlayer, j)) { - p->gotweapon |= (1<gotweapon |= (1<curr_weapon != GROW_WEAPON && p->curr_weapon != SHRINKER_WEAPON) + if (pPlayer->curr_weapon != GROW_WEAPON && pPlayer->curr_weapon != SHRINKER_WEAPON) { - if (p->ammo_amount[GROW_WEAPON] > 0) + if (pPlayer->ammo_amount[GROW_WEAPON] > 0) { - if ((p->subweapon&(1<subweapon&(1<ammo_amount[SHRINKER_WEAPON] == 0) + else if (pPlayer->ammo_amount[SHRINKER_WEAPON] == 0) { j = GROW_WEAPON; - p->subweapon |= (1<subweapon |= (1<ammo_amount[SHRINKER_WEAPON] > 0) - p->subweapon &= ~(1<ammo_amount[SHRINKER_WEAPON] > 0) + pPlayer->subweapon &= ~(1<curr_weapon == SHRINKER_WEAPON) + else if (pPlayer->curr_weapon == SHRINKER_WEAPON) { - p->subweapon |= (1<subweapon |= (1<subweapon &= ~(1<subweapon &= ~(1<holster_weapon) + if (pPlayer->holster_weapon) { - sb_snum |= BIT(SK_HOLSTER); - p->weapon_pos = WEAPON_POS_LOWER; + nPlayerBits |= BIT(SK_HOLSTER); + pPlayer->weapon_pos = WEAPON_POS_LOWER; } - else if ((uint32_t)j < MAX_WEAPONS && (p->gotweapon & (1<curr_weapon != j) + else if ((uint32_t)j < MAX_WEAPONS && (pPlayer->gotweapon & (1<curr_weapon != j) switch (j) { case PISTOL_WEAPON: @@ -2753,122 +2702,123 @@ CHECKINV1: case FREEZE_WEAPON: case GROW_WEAPON: case SHRINKER_WEAPON: - if (p->ammo_amount[j] == 0 && p->show_empty_weapon == 0) + if (pPlayer->ammo_amount[j] == 0 && pPlayer->show_empty_weapon == 0) { - p->last_full_weapon = p->curr_weapon; - p->show_empty_weapon = 32; + pPlayer->last_full_weapon = pPlayer->curr_weapon; + pPlayer->show_empty_weapon = 32; } case KNEE_WEAPON: case HANDREMOTE_WEAPON: - P_AddWeapon(p, j, 1); + P_AddWeapon(pPlayer, j, 1); break; case HANDBOMB_WEAPON: case TRIPBOMB_WEAPON: - if (p->ammo_amount[j] > 0 && (p->gotweapon & (1<ammo_amount[j] > 0 && (pPlayer->gotweapon & (1<newowner == -1 || p->holoduke_on != -1)) + if (TEST_SYNC_KEY(nPlayerBits, SK_HOLODUKE) && (pPlayer->newowner == -1 || pPlayer->holoduke_on != -1)) { - if (p->holoduke_on == -1) + if (pPlayer->holoduke_on == -1) { - if (VM_OnEvent(EVENT_HOLODUKEON,g_player[snum].ps->i,snum) == 0) + if (VM_OnEvent(EVENT_HOLODUKEON,g_player[nPlayer].ps->i,nPlayer) == 0) { - if (p->inv_amount[GET_HOLODUKE] > 0) + if (pPlayer->inv_amount[GET_HOLODUKE] > 0) { - p->inven_icon = ICON_HOLODUKE; + pPlayer->inven_icon = ICON_HOLODUKE; - if (p->cursectnum > -1) + if (pPlayer->cursectnum > -1) { - p->holoduke_on = i = A_InsertSprite(p->cursectnum,p->pos.x,p->pos.y, - p->pos.z+(30<<8),APLAYER,-64,0,0,p->ang,0,0,-1,10); + int const i = A_InsertSprite(pPlayer->cursectnum, pPlayer->pos.x, pPlayer->pos.y, + pPlayer->pos.z+(30<<8), APLAYER, -64, 0, 0, pPlayer->ang, 0, 0, -1, 10); + pPlayer->holoduke_on = i; T4 = T5 = 0; - sprite[i].yvel = snum; + sprite[i].yvel = nPlayer; sprite[i].extra = 0; - P_DoQuote(QUOTE_HOLODUKE_ON,p); - A_PlaySound(TELEPORTER,p->holoduke_on); + P_DoQuote(QUOTE_HOLODUKE_ON,pPlayer); + A_PlaySound(TELEPORTER,pPlayer->holoduke_on); } } - else P_DoQuote(QUOTE_HOLODUKE_NOT_FOUND,p); + else P_DoQuote(QUOTE_HOLODUKE_NOT_FOUND,pPlayer); } } else { - if (VM_OnEvent(EVENT_HOLODUKEOFF,g_player[snum].ps->i,snum) == 0) + if (VM_OnEvent(EVENT_HOLODUKEOFF,g_player[nPlayer].ps->i,nPlayer) == 0) { - A_PlaySound(TELEPORTER,p->holoduke_on); - p->holoduke_on = -1; - P_DoQuote(QUOTE_HOLODUKE_OFF,p); + A_PlaySound(TELEPORTER,pPlayer->holoduke_on); + pPlayer->holoduke_on = -1; + P_DoQuote(QUOTE_HOLODUKE_OFF,pPlayer); } } } - if (TEST_SYNC_KEY(sb_snum, SK_MEDKIT)) + if (TEST_SYNC_KEY(nPlayerBits, SK_MEDKIT)) { - if (VM_OnEvent(EVENT_USEMEDKIT,g_player[snum].ps->i,snum) == 0) + if (VM_OnEvent(EVENT_USEMEDKIT,g_player[nPlayer].ps->i,nPlayer) == 0) { - if (p->inv_amount[GET_FIRSTAID] > 0 && sprite[p->i].extra < p->max_player_health) + if (pPlayer->inv_amount[GET_FIRSTAID] > 0 && sprite[pPlayer->i].extra < pPlayer->max_player_health) { - j = p->max_player_health-sprite[p->i].extra; + j = pPlayer->max_player_health-sprite[pPlayer->i].extra; - if ((uint32_t)p->inv_amount[GET_FIRSTAID] > j) + if ((uint32_t)pPlayer->inv_amount[GET_FIRSTAID] > j) { - p->inv_amount[GET_FIRSTAID] -= j; - sprite[p->i].extra = p->max_player_health; - p->inven_icon = ICON_FIRSTAID; + pPlayer->inv_amount[GET_FIRSTAID] -= j; + sprite[pPlayer->i].extra = pPlayer->max_player_health; + pPlayer->inven_icon = ICON_FIRSTAID; } else { - sprite[p->i].extra += p->inv_amount[GET_FIRSTAID]; - p->inv_amount[GET_FIRSTAID] = 0; - P_SelectNextInvItem(p); + sprite[pPlayer->i].extra += pPlayer->inv_amount[GET_FIRSTAID]; + pPlayer->inv_amount[GET_FIRSTAID] = 0; + P_SelectNextInvItem(pPlayer); } - A_PlaySound(DUKE_USEMEDKIT,p->i); + A_PlaySound(DUKE_USEMEDKIT,pPlayer->i); } } } - if ((p->newowner == -1 || p->jetpack_on) && TEST_SYNC_KEY(sb_snum, SK_JETPACK)) + if ((pPlayer->newowner == -1 || pPlayer->jetpack_on) && TEST_SYNC_KEY(nPlayerBits, SK_JETPACK)) { - if (VM_OnEvent(EVENT_USEJETPACK,g_player[snum].ps->i,snum) == 0) + if (VM_OnEvent(EVENT_USEJETPACK,g_player[nPlayer].ps->i,nPlayer) == 0) { - if (p->inv_amount[GET_JETPACK] > 0) + if (pPlayer->inv_amount[GET_JETPACK] > 0) { - p->jetpack_on = !p->jetpack_on; - if (p->jetpack_on) + pPlayer->jetpack_on = !pPlayer->jetpack_on; + if (pPlayer->jetpack_on) { - p->inven_icon = ICON_JETPACK; - if (p->scream_voice > FX_Ok) + pPlayer->inven_icon = ICON_JETPACK; + if (pPlayer->scream_voice > FX_Ok) { - FX_StopSound(p->scream_voice); - p->scream_voice = -1; + FX_StopSound(pPlayer->scream_voice); + pPlayer->scream_voice = -1; } - A_PlaySound(DUKE_JETPACK_ON,p->i); + A_PlaySound(DUKE_JETPACK_ON,pPlayer->i); - P_DoQuote(QUOTE_JETPACK_ON,p); + P_DoQuote(QUOTE_JETPACK_ON,pPlayer); } else { - p->hard_landing = 0; - p->vel.z = 0; - A_PlaySound(DUKE_JETPACK_OFF,p->i); - S_StopEnvSound(DUKE_JETPACK_IDLE,p->i); - S_StopEnvSound(DUKE_JETPACK_ON,p->i); - P_DoQuote(QUOTE_JETPACK_OFF,p); + pPlayer->hard_landing = 0; + pPlayer->vel.z = 0; + A_PlaySound(DUKE_JETPACK_OFF,pPlayer->i); + S_StopEnvSound(DUKE_JETPACK_IDLE,pPlayer->i); + S_StopEnvSound(DUKE_JETPACK_ON,pPlayer->i); + P_DoQuote(QUOTE_JETPACK_OFF,pPlayer); } } - else P_DoQuote(QUOTE_JETPACK_NOT_FOUND,p); + else P_DoQuote(QUOTE_JETPACK_NOT_FOUND,pPlayer); } } - if (TEST_SYNC_KEY(sb_snum, SK_TURNAROUND) && p->one_eighty_count == 0) - if (VM_OnEvent(EVENT_TURNAROUND,p->i,snum) == 0) - p->one_eighty_count = -1024; + if (TEST_SYNC_KEY(nPlayerBits, SK_TURNAROUND) && pPlayer->one_eighty_count == 0) + if (VM_OnEvent(EVENT_TURNAROUND,pPlayer->i,nPlayer) == 0) + pPlayer->one_eighty_count = -1024; } } @@ -2877,7 +2827,7 @@ int32_t A_CheckHitSprite(int32_t i, int16_t *hitsp) hitdata_t hit; int32_t zoff = 0; - if (A_CheckEnemySprite((uspritetype *) &sprite[i])) + if (A_CheckEnemySprite( &sprite[i])) zoff = (42<<8); else if (PN == APLAYER) zoff = (39<<8); @@ -2892,26 +2842,25 @@ int32_t A_CheckHitSprite(int32_t i, int16_t *hitsp) if (hitsp) *hitsp = hit.sprite; - if (hit.wall >= 0 && (wall[hit.wall].cstat&16) && A_CheckEnemySprite((uspritetype *) &sprite[i])) + if (hit.wall >= 0 && (wall[hit.wall].cstat&16) && A_CheckEnemySprite( &sprite[i])) return 1<<30; return FindDistance2D(hit.pos.x-SX,hit.pos.y-SY); } -static int32_t P_FindWall(DukePlayer_t *p, int16_t *hitw) +static int32_t P_FindWall(DukePlayer_t *pPlayer, int16_t *pHitWall) { hitdata_t hit; - hitscan((const vec3_t *)p,p->cursectnum, - sintable[(p->ang+512)&2047], - sintable[p->ang&2047], - 0,&hit,CLIPMASK0); + hitscan((const vec3_t *)pPlayer, pPlayer->cursectnum, sintable[(pPlayer->ang + 512) & 2047], + sintable[pPlayer->ang & 2047], 0, &hit, CLIPMASK0); + + *pHitWall = hit.wall; - *hitw = hit.wall; if (hit.wall < 0) return INT32_MAX; - return FindDistance2D(hit.pos.x-p->pos.x,hit.pos.y-p->pos.y); + return FindDistance2D(hit.pos.x - pPlayer->pos.x, hit.pos.y - pPlayer->pos.y); } // returns 1 if sprite i should not be considered by neartag @@ -2928,89 +2877,89 @@ static void G_ClearCameras(DukePlayer_t *p) I_EscapeTriggerClear(); } -void P_CheckSectors(int32_t snum) +void P_CheckSectors(int nPlayer) { - DukePlayer_t *const p = g_player[snum].ps; + DukePlayer_t *const pPlayer = g_player[nPlayer].ps; - if (p->cursectnum > -1) - switch (sector[p->cursectnum].lotag) + if (pPlayer->cursectnum > -1) + switch (sector[pPlayer->cursectnum].lotag) { case 32767: - sector[p->cursectnum].lotag = 0; - P_DoQuote(QUOTE_FOUND_SECRET,p); - p->secret_rooms++; + sector[pPlayer->cursectnum].lotag = 0; + P_DoQuote(QUOTE_FOUND_SECRET,pPlayer); + pPlayer->secret_rooms++; return; case UINT16_MAX: - sector[p->cursectnum].lotag = 0; + sector[pPlayer->cursectnum].lotag = 0; P_EndLevel(); return; case UINT16_MAX-1: - sector[p->cursectnum].lotag = 0; - p->timebeforeexit = GAMETICSPERSEC*8; - p->customexitsound = sector[p->cursectnum].hitag; + sector[pPlayer->cursectnum].lotag = 0; + pPlayer->timebeforeexit = GAMETICSPERSEC*8; + pPlayer->customexitsound = sector[pPlayer->cursectnum].hitag; return; default: - if (sector[p->cursectnum].lotag >= 10000 && sector[p->cursectnum].lotag < 16383) + if (sector[pPlayer->cursectnum].lotag >= 10000 && sector[pPlayer->cursectnum].lotag < 16383) { - if (snum == screenpeek || (GametypeFlags[ud.coop]&GAMETYPE_COOPSOUND)) - A_PlaySound(sector[p->cursectnum].lotag-10000,p->i); - sector[p->cursectnum].lotag = 0; + if (nPlayer == screenpeek || (GametypeFlags[ud.coop]&GAMETYPE_COOPSOUND)) + A_PlaySound(sector[pPlayer->cursectnum].lotag-10000,pPlayer->i); + sector[pPlayer->cursectnum].lotag = 0; } break; } //After this point the the player effects the map with space - if (p->gm &MODE_TYPE || sprite[p->i].extra <= 0) + if (pPlayer->gm &MODE_TYPE || sprite[pPlayer->i].extra <= 0) return; - if (TEST_SYNC_KEY(g_player[snum].sync->bits, SK_OPEN)) + if (TEST_SYNC_KEY(g_player[nPlayer].sync->bits, SK_OPEN)) { - if (VM_OnEvent(EVENT_USE, p->i, snum) != 0) - g_player[snum].sync->bits &= ~BIT(SK_OPEN); + if (VM_OnEvent(EVENT_USE, pPlayer->i, nPlayer) != 0) + g_player[nPlayer].sync->bits &= ~BIT(SK_OPEN); } - if (ud.cashman && TEST_SYNC_KEY(g_player[snum].sync->bits, SK_OPEN)) - A_SpawnMultiple(p->i, MONEY, 2); + if (ud.cashman && TEST_SYNC_KEY(g_player[nPlayer].sync->bits, SK_OPEN)) + A_SpawnMultiple(pPlayer->i, MONEY, 2); - if (p->newowner >= 0) + if (pPlayer->newowner >= 0) { - if (klabs(g_player[snum].sync->svel) > 768 || klabs(g_player[snum].sync->fvel) > 768) + if (klabs(g_player[nPlayer].sync->svel) > 768 || klabs(g_player[nPlayer].sync->fvel) > 768) { - G_ClearCameras(p); + G_ClearCameras(pPlayer); return; } } - 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 (!TEST_SYNC_KEY(g_player[nPlayer].sync->bits, SK_OPEN) && !TEST_SYNC_KEY(g_player[nPlayer].sync->bits, SK_ESCAPE)) + pPlayer->toggle_key_flag = 0; + else if (!pPlayer->toggle_key_flag) { int16_t hitscanwall; int16_t neartagsector, neartagwall, neartagsprite; int32_t neartaghitdist; - if (TEST_SYNC_KEY(g_player[snum].sync->bits, SK_ESCAPE)) + if (TEST_SYNC_KEY(g_player[nPlayer].sync->bits, SK_ESCAPE)) { - if (p->newowner >= 0) - G_ClearCameras(p); + if (pPlayer->newowner >= 0) + G_ClearCameras(pPlayer); return; } neartagsprite = -1; - p->toggle_key_flag = 1; + pPlayer->toggle_key_flag = 1; hitscanwall = -1; - int32_t i = P_FindWall(p,&hitscanwall); + int32_t i = P_FindWall(pPlayer,&hitscanwall); if (hitscanwall >= 0 && i < 1280 && wall[hitscanwall].overpicnum == MIRROR) - if (wall[hitscanwall].lotag > 0 && !A_CheckSoundPlaying(p->i,wall[hitscanwall].lotag) && snum == screenpeek) + if (wall[hitscanwall].lotag > 0 && !A_CheckSoundPlaying(pPlayer->i,wall[hitscanwall].lotag) && nPlayer == screenpeek) { - A_PlaySound(wall[hitscanwall].lotag,p->i); + A_PlaySound(wall[hitscanwall].lotag,pPlayer->i); return; } @@ -3018,22 +2967,22 @@ void P_CheckSectors(int32_t snum) if (wall[hitscanwall].lotag) return; - if (p->newowner >= 0) - neartag(p->opos.x,p->opos.y,p->opos.z,sprite[p->i].sectnum,p->oang,&neartagsector, + if (pPlayer->newowner >= 0) + neartag(pPlayer->opos.x,pPlayer->opos.y,pPlayer->opos.z,sprite[pPlayer->i].sectnum,pPlayer->oang,&neartagsector, &neartagwall,&neartagsprite,&neartaghitdist, 1280, 1, our_neartag_blacklist); else { - neartag(p->pos.x,p->pos.y,p->pos.z,sprite[p->i].sectnum,p->oang,&neartagsector, + neartag(pPlayer->pos.x,pPlayer->pos.y,pPlayer->pos.z,sprite[pPlayer->i].sectnum,pPlayer->oang,&neartagsector, &neartagwall,&neartagsprite,&neartaghitdist, 1280, 1, our_neartag_blacklist); if (neartagsprite == -1 && neartagwall == -1 && neartagsector == -1) - neartag(p->pos.x,p->pos.y,p->pos.z+(8<<8),sprite[p->i].sectnum,p->oang,&neartagsector, + neartag(pPlayer->pos.x,pPlayer->pos.y,pPlayer->pos.z+(8<<8),sprite[pPlayer->i].sectnum,pPlayer->oang,&neartagsector, &neartagwall,&neartagsprite,&neartaghitdist, 1280, 1, our_neartag_blacklist); if (neartagsprite == -1 && neartagwall == -1 && neartagsector == -1) - neartag(p->pos.x,p->pos.y,p->pos.z+(16<<8),sprite[p->i].sectnum,p->oang,&neartagsector, + neartag(pPlayer->pos.x,pPlayer->pos.y,pPlayer->pos.z+ZOFFSET2,sprite[pPlayer->i].sectnum,pPlayer->oang,&neartagsector, &neartagwall,&neartagsprite,&neartaghitdist, 1280, 1, our_neartag_blacklist); if (neartagsprite == -1 && neartagwall == -1 && neartagsector == -1) { - neartag(p->pos.x,p->pos.y,p->pos.z+(16<<8),sprite[p->i].sectnum,p->oang,&neartagsector, + neartag(pPlayer->pos.x,pPlayer->pos.y,pPlayer->pos.z+ZOFFSET2,sprite[pPlayer->i].sectnum,pPlayer->oang,&neartagsector, &neartagwall,&neartagsprite,&neartaghitdist, 1280, 3, our_neartag_blacklist); if (neartagsprite >= 0) { @@ -3063,48 +3012,48 @@ void P_CheckSectors(int32_t snum) } } - if (p->newowner == -1 && neartagsprite == -1 && neartagsector == -1 && neartagwall == -1) - if (isanunderoperator(sector[sprite[p->i].sectnum].lotag)) - neartagsector = sprite[p->i].sectnum; + if (pPlayer->newowner == -1 && neartagsprite == -1 && neartagsector == -1 && neartagwall == -1) + if (isanunderoperator(sector[sprite[pPlayer->i].sectnum].lotag)) + neartagsector = sprite[pPlayer->i].sectnum; if (neartagsector >= 0 && (sector[neartagsector].lotag&16384)) return; if (neartagsprite == -1 && neartagwall == -1) - if (p->cursectnum >= 0 && sector[p->cursectnum].lotag == 2) + if (pPlayer->cursectnum >= 0 && sector[pPlayer->cursectnum].lotag == 2) { - int32_t oldz = A_CheckHitSprite(p->i,&neartagsprite); + int32_t oldz = A_CheckHitSprite(pPlayer->i,&neartagsprite); if (oldz > 1280) neartagsprite = -1; } if (neartagsprite >= 0) { - if (P_ActivateSwitch(snum, neartagsprite, 1)) + if (P_ActivateSwitch(nPlayer, neartagsprite, 1)) return; switch (DYNAMICTILEMAP(sprite[neartagsprite].picnum)) { case TOILET__STATIC: case STALL__STATIC: - if (p->last_pissed_time == 0) + if (pPlayer->last_pissed_time == 0) { - if (ud.lockout == 0) A_PlaySound(DUKE_URINATE,p->i); + if (ud.lockout == 0) A_PlaySound(DUKE_URINATE,pPlayer->i); - p->last_pissed_time = GAMETICSPERSEC*220; - p->transporter_hold = 29*2; - if (p->holster_weapon == 0) + pPlayer->last_pissed_time = GAMETICSPERSEC*220; + pPlayer->transporter_hold = 29*2; + if (pPlayer->holster_weapon == 0) { - p->holster_weapon = 1; - p->weapon_pos = -1; + pPlayer->holster_weapon = 1; + pPlayer->weapon_pos = -1; } - if (sprite[p->i].extra <= (p->max_player_health-(p->max_player_health/10))) + if (sprite[pPlayer->i].extra <= (pPlayer->max_player_health-(pPlayer->max_player_health/10))) { - sprite[p->i].extra += p->max_player_health/10; - p->last_extra = sprite[p->i].extra; + sprite[pPlayer->i].extra += pPlayer->max_player_health/10; + pPlayer->last_extra = sprite[pPlayer->i].extra; } - else if (sprite[p->i].extra < p->max_player_health) - sprite[p->i].extra = p->max_player_health; + else if (sprite[pPlayer->i].extra < pPlayer->max_player_health) + sprite[pPlayer->i].extra = pPlayer->max_player_health; } else if (!A_CheckSoundPlaying(neartagsprite,FLUSH_TOILET)) A_PlaySound(FLUSH_TOILET,neartagsprite); @@ -3114,7 +3063,7 @@ void P_CheckSectors(int32_t snum) { int16_t j; - P_FindWall(p, &j); + P_FindWall(pPlayer, &j); if (j >= 0 && wall[j].overpicnum == 0) if (actor[neartagsprite].t_data[0] == 0) @@ -3122,15 +3071,15 @@ void P_CheckSectors(int32_t snum) if (ud.noexits && (g_netServer || ud.multimode > 1)) { // NUKEBUTTON frags the player - actor[p->i].picnum = NUKEBUTTON; - actor[p->i].extra = 250; + actor[pPlayer->i].picnum = NUKEBUTTON; + actor[pPlayer->i].extra = 250; } else { actor[neartagsprite].t_data[0] = 1; - sprite[neartagsprite].owner = p->i; + sprite[neartagsprite].owner = pPlayer->i; ud.secretlevel = - (p->buttonpalette = sprite[neartagsprite].pal) ? sprite[neartagsprite].lotag : 0; + (pPlayer->buttonpalette = sprite[neartagsprite].pal) ? sprite[neartagsprite].lotag : 0; } } return; @@ -3140,21 +3089,21 @@ void P_CheckSectors(int32_t snum) if (actor[neartagsprite].t_data[0] != 1) { actor[neartagsprite].t_data[0] = 1; - sprite[neartagsprite].owner = p->i; + sprite[neartagsprite].owner = pPlayer->i; - if (sprite[p->i].extra < p->max_player_health) + if (sprite[pPlayer->i].extra < pPlayer->max_player_health) { - sprite[p->i].extra++; - A_PlaySound(DUKE_DRINKING,p->i); + sprite[pPlayer->i].extra++; + A_PlaySound(DUKE_DRINKING,pPlayer->i); } } return; case PLUG__STATIC: - A_PlaySound(SHORT_CIRCUIT,p->i); - sprite[p->i].extra -= 2+(krand()&3); + A_PlaySound(SHORT_CIRCUIT,pPlayer->i); + sprite[pPlayer->i].extra -= 2+(krand()&3); - P_PalFrom(p, 32, 48,48,64); + P_PalFrom(pPlayer, 32, 48,48,64); break; case VIEWSCREEN__STATIC: @@ -3165,48 +3114,48 @@ void P_CheckSectors(int32_t snum) if (PN == CAMERA1 && SP == 0 && sprite[neartagsprite].hitag == SLT) { sprite[i].yvel = 1; // Using this camera - A_PlaySound(MONITOR_ACTIVE,p->i); + A_PlaySound(MONITOR_ACTIVE,pPlayer->i); sprite[neartagsprite].owner = i; sprite[neartagsprite].yvel = 1; // VIEWSCREEN_YVEL g_curViewscreen = neartagsprite; { - int32_t j = p->cursectnum; - p->cursectnum = SECT; - P_UpdateScreenPal(p); - p->cursectnum = j; + int32_t j = pPlayer->cursectnum; + pPlayer->cursectnum = SECT; + P_UpdateScreenPal(pPlayer); + pPlayer->cursectnum = j; } // parallaxtype = 2; - p->newowner = i; + pPlayer->newowner = i; - P_UpdatePosWhenViewingCam(p); + P_UpdatePosWhenViewingCam(pPlayer); return; } } - G_ClearCameras(p); + G_ClearCameras(pPlayer); return; } // switch } - if (TEST_SYNC_KEY(g_player[snum].sync->bits, SK_OPEN) == 0) + if (TEST_SYNC_KEY(g_player[nPlayer].sync->bits, SK_OPEN) == 0) return; - if (p->newowner >= 0) + if (pPlayer->newowner >= 0) { - G_ClearCameras(p); + G_ClearCameras(pPlayer); return; } if (neartagwall == -1 && neartagsector == -1 && neartagsprite == -1) - if (klabs(A_GetHitscanRange(p->i)) < 512) + if (klabs(A_GetHitscanRange(pPlayer->i)) < 512) { if ((krand()&255) < 16) - A_PlaySound(DUKE_SEARCH2,p->i); - else A_PlaySound(DUKE_SEARCH,p->i); + A_PlaySound(DUKE_SEARCH2,pPlayer->i); + else A_PlaySound(DUKE_SEARCH,pPlayer->i); return; } @@ -3215,12 +3164,12 @@ void P_CheckSectors(int32_t snum) if (wall[neartagwall].lotag > 0 && CheckDoorTile(wall[neartagwall].picnum)) { if (hitscanwall == neartagwall || hitscanwall == -1) - P_ActivateSwitch(snum,neartagwall,0); + P_ActivateSwitch(nPlayer,neartagwall,0); return; } - else if (p->newowner >= 0) + else if (pPlayer->newowner >= 0) { - G_ClearCameras(p); + G_ClearCameras(pPlayer); return; } } @@ -3235,21 +3184,21 @@ void P_CheckSectors(int32_t snum) return; } - G_OperateSectors(neartagsector,p->i); + G_OperateSectors(neartagsector,pPlayer->i); } - else if ((sector[sprite[p->i].sectnum].lotag&16384) == 0) + else if ((sector[sprite[pPlayer->i].sectnum].lotag&16384) == 0) { - if (isanunderoperator(sector[sprite[p->i].sectnum].lotag)) + if (isanunderoperator(sector[sprite[pPlayer->i].sectnum].lotag)) { - for (SPRITES_OF_SECT(sprite[p->i].sectnum, i)) + for (SPRITES_OF_SECT(sprite[pPlayer->i].sectnum, i)) { if (PN == ACTIVATOR || PN == MASTERSWITCH) return; } - G_OperateSectors(sprite[p->i].sectnum,p->i); + G_OperateSectors(sprite[pPlayer->i].sectnum,pPlayer->i); } - else P_ActivateSwitch(snum,neartagwall,0); + else P_ActivateSwitch(nPlayer,neartagwall,0); } } } diff --git a/polymer/eduke32/source/sector.h b/polymer/eduke32/source/sector.h index c243e19d8..c2ad743a7 100644 --- a/polymer/eduke32/source/sector.h +++ b/polymer/eduke32/source/sector.h @@ -124,18 +124,18 @@ void G_AnimateWalls(void); int32_t G_ActivateWarpElevators(int32_t s,int32_t d); int32_t G_CheckActivatorMotion(int32_t lotag); void G_DoSectorAnimations(void); -void G_OperateActivators(int32_t low,int32_t snum); +void G_OperateActivators(int nTag, int nPlayer); void G_OperateForceFields(int32_t s,int32_t low); -void G_OperateMasterSwitches(int32_t low); +void G_OperateMasterSwitches(int nTag); void G_OperateRespawns(int32_t low); void G_OperateSectors(int32_t sn,int32_t ii); void P_HandleSharedKeys(int32_t snum); int32_t GetAnimationGoal(const int32_t *animptr); int32_t isanearoperator(int32_t lotag); int32_t isanunderoperator(int32_t lotag); -int32_t P_ActivateSwitch(int32_t snum,int32_t w,int32_t switchissprite); +int P_ActivateSwitch(int nPlayer, int nObject, int nSwitchType); void P_CheckSectors(int32_t snum); -int32_t Sect_DamageCeilingOrFloor(int32_t floorp, int32_t sn); +int Sect_DamageCeilingOrFloor(int nDmgFloor, int const nSectnum); int32_t SetAnimation(int32_t animsect,int32_t *animptr,int32_t thegoal,int32_t thevel); #define FORCEFIELD_CSTAT (64+16+4+1)