From 18d6a8e65d3291e105e5b2b8336e3b7661867fe9 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 14 May 2020 12:52:59 +0200 Subject: [PATCH] - another safety commit. # Conflicts: # source/games/duke/src/zz_actors.cpp --- source/build/include/build.h | 2 +- source/games/duke/CMakeLists.txt | 2 +- source/games/duke/src/actors.cpp | 3 +-- source/games/duke/src/actors.h | 1 - source/games/duke/src/condef.h | 8 ++++---- source/games/duke/src/dispatch.cpp | 5 +++++ source/games/duke/src/gameexec.cpp | 17 +++++++++++++---- source/games/duke/src/zz_actors.cpp | 25 +------------------------ source/games/duke/src/zz_game.cpp | 2 ++ source/games/duke/src/zz_gameexec.cpp | 4 ++-- source/games/duke/src/zz_player.cpp | 18 +++++++++--------- 11 files changed, 39 insertions(+), 48 deletions(-) diff --git a/source/build/include/build.h b/source/build/include/build.h index c876c6950..487b1ed36 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -1077,7 +1077,7 @@ inline int32_t setsprite(int16_t spritenum, int x, int y, int z) return setsprite(spritenum, &v); } -void setspritepos(int spnum, int x, int y, int z) +inline void setspritepos(int spnum, int x, int y, int z) { sprite[spnum].pos = { x,y,z }; } diff --git a/source/games/duke/CMakeLists.txt b/source/games/duke/CMakeLists.txt index 76446608d..49f048b20 100644 --- a/source/games/duke/CMakeLists.txt +++ b/source/games/duke/CMakeLists.txt @@ -5,7 +5,7 @@ set( PCH_SOURCES src/actors_d.cpp src/actors_lava.cpp src/bowling.cpp - src/dispatcher.cpp + src/dispatch.cpp src/gamedef.cpp src/gameexec.cpp src/gamevar.cpp diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 70707ee8d..43506e438 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -4969,13 +4969,12 @@ void alterang(int a, int g_i, int g_p) void fall_common(int g_i, int g_p, int JIBS6, int DRONE, int BLOODPOOL, int SHOTSPARK1, int squished, int thud, int(*fallspecial)(int, int), void (*falladjustz)(spritetype*)) { - int j; auto g_sp = &sprite[g_i]; g_sp->xoffset = 0; g_sp->yoffset = 0; // if(!gotz) { - long c; + int c; int sphit = fallspecial? fallspecial(g_i, g_p) : 0; if (fi.floorspace(g_sp->sectnum)) diff --git a/source/games/duke/src/actors.h b/source/games/duke/src/actors.h index ab5ba6b72..456fbc2fe 100644 --- a/source/games/duke/src/actors.h +++ b/source/games/duke/src/actors.h @@ -297,7 +297,6 @@ inline void check_fta_sounds(int s) { A_PlayAlertSound(s); } -void A_RadiusDamage(int spriteNum, int blastRadius, int dmg1, int dmg2, int dmg3, int dmg4); void A_SpawnMultiple(int spriteNum, int tileNum, int spawnCnt); void resetlanepics(void); diff --git a/source/games/duke/src/condef.h b/source/games/duke/src/condef.h index bb30bc70f..56edfe81a 100644 --- a/source/games/duke/src/condef.h +++ b/source/games/duke/src/condef.h @@ -14,14 +14,14 @@ cmd(break) // 12 cmd(shoot) // 13 cmd(palfrom) // 14 cmd(sound) // 15 -cmd(fi.fall) // 16 +cmd(fall) // 16 cmd(state) // 17 cmd(ends) // 18 cmd(define) // 19 //cmdx(comment, "//") // 20 cmd(ifai) // 21 cmd(killit) // 22 -cmd(fi.addweapon) // 23 +cmd(addweapon) // 23 cmd(ai) // 24 cmd(addphealth) // 25 cmd(ifdead) // 26 @@ -48,7 +48,7 @@ cmd(ifcount) // 46 cmd(resetcount) // 47 cmd(addinventory) // 48 cmd(ifactornotstayput) // 49 -cmd(fi.hitradius) // 50 +cmd(hitradius) // 50 cmd(ifp) // 51 cmd(count) // 52 cmd(ifactor) // 53 @@ -56,7 +56,7 @@ cmd(music) // 54 cmd(include) // 55 cmd(ifstrength) // 56 cmd(definesound) // 57 -cmd(fi.guts) // 58 +cmd(guts) // 58 cmd(ifspawnedby) // 59 cmd(gamestartup) // 60 cmd(wackplayer) // 61 diff --git a/source/games/duke/src/dispatch.cpp b/source/games/duke/src/dispatch.cpp index 207300de8..0f00bb5f8 100644 --- a/source/games/duke/src/dispatch.cpp +++ b/source/games/duke/src/dispatch.cpp @@ -20,6 +20,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ //------------------------------------------------------------------------- +#include "ns.h" +#include "global.h" + +BEGIN_DUKE_NS //--------------------------------------------------------------------------- // @@ -143,3 +147,4 @@ void SetDispatcher() +END_DUKE_NS diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index 1e6f36423..9fb699a49 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -146,11 +146,16 @@ static int ifcanshoottarget(int g_i, int g_p, int g_x) return j; } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + static bool ifcansee(int g_i, int g_p) { auto g_sp = &sprite[g_i]; spritetype* s; - short sect; int j; // select sprite for monster to target @@ -500,7 +505,7 @@ char parse(void) break; case concmd_smackbubba: insptr++; - if (!isRRRA || g_sp->pal != 105) + if (!isRRRA() || g_sp->pal != 105) { ps[myconnectindex].gm = MODE_EOL; ud.level_number++; @@ -861,6 +866,7 @@ char parse(void) insptr++; g_t[2] = 0; break; +#if 0 case concmd_debris: { short dnum; @@ -1555,6 +1561,7 @@ char parse(void) parseifelse( j == NUM_SOUNDS ); break; +#endif default: #ifdef WW2 sprintf(g_szBuf,"Unrecognized PCode of %ld in parse. Killing current sprite.",*insptr); @@ -1570,6 +1577,7 @@ AddLog(g_szBuf); void LoadActor(short i,short p,int x) { +#if 0 char done; g_i = i; // Sprite ID @@ -1647,11 +1655,12 @@ void LoadActor(short i,short p,int x) } } } - +#endif } void execute(short i,short p,int x) { +#if 0 char done; g_i = i; // Sprite ID @@ -1738,8 +1747,8 @@ void execute(short i,short p,int x) break; } } +#endif } -#endif END_DUKE_NS diff --git a/source/games/duke/src/zz_actors.cpp b/source/games/duke/src/zz_actors.cpp index e7616d1e1..332a8b84f 100644 --- a/source/games/duke/src/zz_actors.cpp +++ b/source/games/duke/src/zz_actors.cpp @@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #define actors_c_ -#include "duke3d.h" +#include "global.h" BEGIN_DUKE_NS @@ -50,16 +50,6 @@ void G_ClearCameraView(DukePlayer_t *ps) sprite[k].yvel = 0; } -void fi.hitradius(short i, int r, int hp1, int hp2, int hp3, int hp4); - -void A_RadiusDamage(int spriteNum, int blastRadius, int dmg1, int dmg2, int dmg3, int dmg4) -{ - fi.hitradius(spriteNum, blastRadius, dmg1, dmg2, dmg3, dmg4); -} - - -int fi.movesprite(short spritenum, int xchange, int ychange, int zchange, unsigned int cliptype); - int32_t A_MoveSprite(int32_t spriteNum, vec3_t const * const change, uint32_t clipType) { @@ -280,19 +270,6 @@ int G_WakeUp(spritetype *const pSprite, int const playerNum) // sleeping monsters, etc - -static FORCE_INLINE int G_FindExplosionInSector(int const sectNum) -{ - return fi.ifhitsectors(sectNum); -} - -int fi.ifhitbyweapon(int s); -int A_IncurDamage(int const spriteNum) -{ - return fi.ifhitbyweapon(spriteNum); -} - - int A_FindLocator(int const tag, int const sectNum) { for (bssize_t SPRITES_OF(STAT_LOCATOR, spriteNum)) diff --git a/source/games/duke/src/zz_game.cpp b/source/games/duke/src/zz_game.cpp index 7149a5e5f..6bc55ba0e 100644 --- a/source/games/duke/src/zz_game.cpp +++ b/source/games/duke/src/zz_game.cpp @@ -64,6 +64,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_DUKE_NS +void SetDispatcher(); int32_t g_quitDeadline = 0; @@ -7001,6 +7002,7 @@ int GameInterface::app_main() } } + SetDispatcher(); buttonMap.SetButtons(actions, NUM_ACTIONS); playing_rr = 1; g_skillCnt = 4; diff --git a/source/games/duke/src/zz_gameexec.cpp b/source/games/duke/src/zz_gameexec.cpp index 10b00495f..6bd5eb918 100644 --- a/source/games/duke/src/zz_gameexec.cpp +++ b/source/games/duke/src/zz_gameexec.cpp @@ -829,7 +829,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) } else { - VM_CONDITIONAL(A_IncurDamage(vm.spriteNum) >= 0); + VM_CONDITIONAL(fi.ifhitbyweapon(vm.spriteNum) >= 0); } continue; @@ -1766,7 +1766,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) continue; case concmd_hitradius: - A_RadiusDamage(vm.spriteNum, *(insptr + 1), *(insptr + 2), *(insptr + 3), *(insptr + 4), *(insptr + 5)); + fi.hitradius(vm.spriteNum, *(insptr + 1), *(insptr + 2), *(insptr + 3), *(insptr + 4), *(insptr + 5)); insptr += 6; continue; diff --git a/source/games/duke/src/zz_player.cpp b/source/games/duke/src/zz_player.cpp index 9b66154a1..5f7a91bba 100644 --- a/source/games/duke/src/zz_player.cpp +++ b/source/games/duke/src/zz_player.cpp @@ -110,13 +110,13 @@ static void P_IncurDamage(DukePlayer_t * const pPlayer) if (RR) { - int fi.guts = 0; + int guts = 0; if (pPlayer->drink_amt > 31 && pPlayer->drink_amt < 65) - fi.guts++; + guts++; if (pPlayer->eat > 31 && pPlayer->eat < 65) - fi.guts++; + guts++; - switch (fi.guts) + switch (guts) { case 1: playerDamage = (int)(playerDamage*0.75); @@ -680,7 +680,7 @@ growspark_rr: if (hitData.wall >= 0 && wall[hitData.wall].picnum != TILE_ACCESSSWITCH && wall[hitData.wall].picnum != TILE_ACCESSSWITCH2) { - fi.checkhitwall(kneeSprite, hitData.wall, &hitData.pos, projecTile); + fi.checkhitwall(kneeSprite, hitData.wall, hitData.pos.x, hitData.pos.y, hitData.pos.z, projecTile); if (playerNum >= 0) fi.checkhitswitch(playerNum, hitData.wall, 0); } @@ -823,7 +823,7 @@ growspark_rr: SKIPBULLETHOLE: HandleHitWall(&hitData); - fi.checkhitwall(spawnedSprite, hitData.wall, &hitData.pos, TILE_SHOTSPARK1); + fi.checkhitwall(spawnedSprite, hitData.wall, hitData.pos.x, hitData.pos.y, hitData.pos.z, TILE_SHOTSPARK1); } } else @@ -843,7 +843,7 @@ growspark_rr: } } else if (hitData.wall >= 0) - fi.checkhitwall(spawnedSprite, hitData.wall, &hitData.pos, TILE_SHOTSPARK1); + fi.checkhitwall(spawnedSprite, hitData.wall, hitData.pos.x, hitData.pos.y, hitData.pos.z, TILE_SHOTSPARK1); } if ((krand2() & 255) < (RR ? 10 : 4)) @@ -948,7 +948,7 @@ growspark_rr: else if (hitData.sprite >= 0) fi.checkhitsprite(hitData.sprite, otherSprite); else if (hitData.wall >= 0 && wall[hitData.wall].picnum != TILE_ACCESSSWITCH && wall[hitData.wall].picnum != TILE_ACCESSSWITCH2) - fi.checkhitwall(otherSprite, hitData.wall, &hitData.pos, projecTile); + fi.checkhitwall(otherSprite, hitData.wall, hitData.pos.x, hitData.pos.y, hitData.pos.z, projecTile); } break; @@ -4707,7 +4707,7 @@ static void DoWallTouchDamage(const DukePlayer_t *pPlayer, int32_t wallNum) vec3_t const davect = { pPlayer->pos.x + (sintable[(fix16_to_int(pPlayer->q16ang) + 512) & 2047] >> 9), pPlayer->pos.y + (sintable[fix16_to_int(pPlayer->q16ang) & 2047] >> 9), pPlayer->pos.z }; - fi.checkhitwall(pPlayer->i, wallNum, &davect, -1); + fi.checkhitwall(pPlayer->i, wallNum, davect.x, davect.y, davect.z, -1); } static void P_CheckTouchDamage(DukePlayer_t *pPlayer, int touchObject)