From e1c76e4c26a9f320b19c33211aa73689c581105a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 14 May 2020 12:14:03 +0200 Subject: [PATCH] - safety commit. # Conflicts: # source/games/duke/src/zz_sbar.cpp --- source/games/duke/CMakeLists.txt | 6 +- source/games/duke/src/actors.cpp | 145 +++----------- source/games/duke/src/actors.h | 23 --- source/games/duke/src/actors_d.cpp | 76 ++++---- source/games/duke/src/actors_r.cpp | 206 ++++++++++++++++---- source/games/duke/src/condef.h | 8 +- source/games/duke/src/dispatch.cpp | 145 ++++++++++++++ source/games/duke/src/game.h | 39 +++- source/games/duke/src/gameexec.cpp | 271 ++++++++++++++++++++------ source/games/duke/src/global.h | 2 +- source/games/duke/src/player.cpp | 40 ++++ source/games/duke/src/player.h | 3 +- source/games/duke/src/player_d.cpp | 40 ++++ source/games/duke/src/player_r.cpp | 33 ++++ source/games/duke/src/sector.h | 20 +- source/games/duke/src/sectors.cpp | 87 +-------- source/games/duke/src/sectors_d.cpp | 38 ++-- source/games/duke/src/sectors_r.cpp | 48 ++--- source/games/duke/src/zz_actors.cpp | 23 +-- source/games/duke/src/zz_cheats.cpp | 2 +- source/games/duke/src/zz_game.cpp | 8 +- source/games/duke/src/zz_gameexec.cpp | 28 +-- source/games/duke/src/zz_global.cpp | 2 +- source/games/duke/src/zz_namesdyn.cpp | 30 +-- source/games/duke/src/zz_player.cpp | 79 ++++---- source/games/duke/src/zz_premap.cpp | 6 +- source/games/duke/src/zz_sbar.cpp | 8 +- source/games/duke/src/zz_sector.cpp | 10 +- 28 files changed, 885 insertions(+), 541 deletions(-) create mode 100644 source/games/duke/src/dispatch.cpp create mode 100644 source/games/duke/src/player.cpp create mode 100644 source/games/duke/src/player_d.cpp create mode 100644 source/games/duke/src/player_r.cpp diff --git a/source/games/duke/CMakeLists.txt b/source/games/duke/CMakeLists.txt index 556975c31..76446608d 100644 --- a/source/games/duke/CMakeLists.txt +++ b/source/games/duke/CMakeLists.txt @@ -5,13 +5,17 @@ set( PCH_SOURCES src/actors_d.cpp src/actors_lava.cpp src/bowling.cpp + src/dispatcher.cpp src/gamedef.cpp src/gameexec.cpp src/gamevar.cpp - src/zz_actors.cpp + src/player.cpp + src/player_d.cpp + src/player_r.cpp src/sectors.cpp src/sectors_d.cpp src/sectors_r.cpp + src/zz_actors.cpp src/zz_anim.cpp src/zz_cheats.cpp src/zz_cmdline.cpp diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index bb9d45ac7..70707ee8d 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -45,104 +45,7 @@ This file is a combination of code from the following sources: BEGIN_DUKE_NS -bool ceilingspace_d(int sectnum); -bool ceilingspace_r(int sectnum); -bool floorspace_d(int sectnum); -bool floorspace_r(int sectnum); -void addweapon_d(struct player_struct *p, int weapon); -void addweapon_r(struct player_struct *p, int weapon); -void hitradius_d(short i, int r, int hp1, int hp2, int hp3, int hp4); -void hitradius_r(short i, int r, int hp1, int hp2, int hp3, int hp4); -int movesprite_d(short spritenum, int xchange, int ychange, int zchange, unsigned int cliptype); -int movesprite_r(short spritenum, int xchange, int ychange, int zchange, unsigned int cliptype); -void lotsofmoney_d(spritetype *s, short n); -void lotsofmail_d(spritetype *s, short n); -void lotsofpaper_d(spritetype *s, short n); -void lotsoffeathers_r(spritetype *s, short n); -void guts_d(spritetype* s, short gtype, short n, short p); -void guts_r(spritetype* s, short gtype, short n, short p); -void gutsdir_d(spritetype* s, short gtype, short n, short p); -void gutsdir_r(spritetype* s, short gtype, short n, short p); -int ifhitsectors_d(int sectnum); -int ifhitsectors_r(int sectnum); -int ifhitbyweapon_r(int sn); -int ifhitbyweapon_d(int sn); int adjustfall(spritetype* s, int c); -void fall_d(int g_i, int g_p); -void fall_r(int g_i, int g_p); - -bool ceilingspace(int sectnum) -{ - return isRR()? ceilingspace_r(sectnum) : ceilingspace_d(sectnum); -} - -bool floorspace(int sectnum) -{ - return isRR()? floorspace_r(sectnum) : floorspace_d(sectnum); -} - -void addweapon(struct player_struct *p, int weapon) -{ - if (isRR()) addweapon_r(p, weapon); - else addweapon_d(p, weapon); -} - -void hitradius(short i, int r, int hp1, int hp2, int hp3, int hp4) -{ - if (isRR()) hitradius_r(i, r, hp1, hp2, hp3, hp4); - else hitradius_d(i, r, hp1, hp2, hp3, hp4); -} - -int movesprite(short spritenum, int xchange, int ychange, int zchange, unsigned int cliptype) -{ - if (isRR()) return movesprite_r(spritenum, xchange, ychange, zchange, cliptype); - else return movesprite_d(spritenum, xchange, ychange, zchange, cliptype); -} - -void lotsofmoney(spritetype *s, short n) -{ - if (isRR()) lotsoffeathers_r(s, n); - else lotsofmoney_d(s, n); -} - -void lotsofmail(spritetype *s, short n) -{ - if (isRR()) lotsoffeathers_r(s, n); - else lotsofmail_d(s, n); -} - -void lotsofpaper(spritetype *s, short n) -{ - if (isRR()) lotsoffeathers_r(s, n); - else lotsofpaper_d(s, n); -} - -void guts(spritetype* s, short gtype, short n, short p) -{ - if (isRR()) guts_r(s, gtype, n, p); - else guts_d(s, gtype, n, p); -} - -void gutsdir(spritetype* s, short gtype, short n, short p) -{ - if (isRR()) gutsdir_r(s, gtype, n, p); - else gutsdir_d(s, gtype, n, p); -} - -int ifhitsectors(int sectnum) -{ - return isRR()? ifhitsectors_r(sectnum) : ifhitsectors_d(sectnum); -} - -int ifhitbyweapon(int sectnum) -{ - return isRR()? ifhitbyweapon_r(sectnum) : ifhitbyweapon_d(sectnum); -} - -void fall(int g_i, int g_p) -{ - if (isRR()) fall_r(g_i, g_p); else fall_d(g_i, g_p); -} //--------------------------------------------------------------------------- // @@ -203,7 +106,7 @@ void checkavailweapon(struct player_struct* p) if (weap == p->curr_weapon) return; else if (p->gotweapon[weap] && p->ammo_amount[weap] > 0) { - addweapon(p, weap); + fi.addweapon(p, weap); return; } } @@ -295,7 +198,7 @@ int ssp(short i, unsigned int cliptype) //The set sprite function s = &sprite[i]; - movetype = movesprite(i, + movetype = fi.movesprite(i, (s->xvel * (sintable[(s->ang + 512) & 2047])) >> 14, (s->xvel * (sintable[s->ang & 2047])) >> 14, s->zvel, cliptype); @@ -542,7 +445,7 @@ void moveplayers(void) //Players hittype[i].owner = i; if (ud.god == 0) - if (ceilingspace(s->sectnum) || floorspace(s->sectnum)) + if (fi.ceilingspace(s->sectnum) || fi.floorspace(s->sectnum)) quickkill(p); } else @@ -880,7 +783,7 @@ void movecrane(int i, int crane) { auto p = findplayer(s, &x); - int j = ifhitbyweapon(i); + int j = fi.ifhitbyweapon(i); if (j >= 0) { if (s->owner == -2) @@ -1044,7 +947,7 @@ void detonate(int i, int explosion) { int x = s->extra; spawn(i, explosion); - hitradius(i, seenineblastradius, x >> 2, x - (x >> 1), x - (x >> 2), x); + fi.hitradius(i, seenineblastradius, x >> 2, x - (x >> 1), x - (x >> 2), x); spritesound(PIPEBOMB_EXPLODE, i); } @@ -1285,7 +1188,7 @@ void moveooz(int i, int seenine, int seeninedead, int ooz, int explosion) if (s->shade != -32 && s->shade != -33) { if (s->xrepeat) - j = (ifhitbyweapon(i) >= 0); + j = (fi.ifhitbyweapon(i) >= 0); else j = 0; @@ -1361,7 +1264,7 @@ void movecanwithsomething(int i) { auto s = &sprite[i]; makeitfall(i); - int j = ifhitbyweapon(i); + int j = fi.ifhitbyweapon(i); if (j >= 0) { spritesound(VENT_BUST, i); @@ -1565,7 +1468,7 @@ bool queball(int i, int pocket, int queball, int stripeball) else if ((j & 49152) == 49152) { j &= (MAXSPRITES - 1); - checkhitsprite(i, j); + fi.checkhitsprite(i, j); } } s->xvel--; @@ -1712,7 +1615,7 @@ void recon(int i, int explosion, int firelaser, int attacksnd, int painsnd, int } else if (actor_tog == 2) s->cstat = 257; } - j = ifhitbyweapon(i); if (j >= 0) + j = fi.ifhitbyweapon(i); if (j >= 0) { if (s->extra < 0 && t[0] != -1) { @@ -1981,7 +1884,7 @@ void reactor(int i, int REACTOR, int REACTOR2, int REACTORBURNT, int REACTOR2BUR { case 3: //Turn on all of those flashing sectoreffector. - hitradius(i, 4096, + fi.hitradius(i, 4096, impact_damage << 2, impact_damage << 2, impact_damage << 2, @@ -2024,7 +1927,7 @@ void reactor(int i, int REACTOR, int REACTOR2, int REACTORBURNT, int REACTOR2BUR } else { - int j = ifhitbyweapon(i); + int j = fi.ifhitbyweapon(i); if (j >= 0) { for (x = 0; x < 32; x++) @@ -2050,7 +1953,7 @@ void camera(int i) t[1] += 8; if (camerashitable) { - int j = ifhitbyweapon(i); + int j = fi.ifhitbyweapon(i); if (j >= 0) { t[0] = 1; // static @@ -3002,7 +2905,7 @@ void handle_se14(int i, bool checkstat, int RPG, int JIBS6) updatesector(sprite[j].x, sprite[j].y, &k); if (sprite[j].extra >= 0 && k == s->sectnum) { - gutsdir(&sprite[j], JIBS6, 72, myconnectindex); + fi.gutsdir(&sprite[j], JIBS6, 72, myconnectindex); spritesound(SQUISHED, i); deletesprite(j); } @@ -3063,7 +2966,7 @@ void handle_se30(int i, int JIBS6) s->owner = -1; s->ang += 1024; t[4] = 0; - operateforcefields(i, s->hitag); + fi.operateforcefields(i, s->hitag); int j = headspritesect[s->sectnum]; while (j >= 0) @@ -3188,7 +3091,7 @@ void handle_se30(int i, int JIBS6) updatesector(sprite[j].x, sprite[j].y, &k); if (sprite[j].extra >= 0 && k == s->sectnum) { - gutsdir_d(&sprite[j], JIBS6, 24, myconnectindex); + fi.gutsdir(&sprite[j], JIBS6, 24, myconnectindex); spritesound(SQUISHED, j); deletesprite(j); } @@ -3478,7 +3381,7 @@ void handle_se05(int i, int FIRELASER) getincangle(t[2] + 512, getangle(ps[p].posx - s->x, ps[p].posy - s->y)) >> 2; sc->ceilingshade = 0; } - j = ifhitbyweapon(i); + j = fi.ifhitbyweapon(i); if (j >= 0) { t[3]++; @@ -3620,7 +3523,7 @@ void handle_se10(int i, const int* specialtags) return; } } - activatebysector(s->sectnum, i); + fi.activatebysector(s->sectnum, i); t[0] = 0; } else t[0]++; @@ -4241,7 +4144,7 @@ void handle_se19(int i, int BIGFORCE) } else //Not hit yet { - j = ifhitsectors(s->sectnum); + j = fi.ifhitsectors(s->sectnum); if (j >= 0) { FTA(8, &ps[myconnectindex]); @@ -4825,11 +4728,11 @@ void makeitfall(int i) spritetype *s = &sprite[i]; int hz,lz,c; - if( floorspace(s->sectnum) ) + if( fi.floorspace(s->sectnum) ) c = 0; else { - if( ceilingspace(s->sectnum) || sector[s->sectnum].lotag == ST_2_UNDERWATER) + if( fi.ceilingspace(s->sectnum) || sector[s->sectnum].lotag == ST_2_UNDERWATER) c = gc/6; else c = gc; } @@ -5075,11 +4978,11 @@ void fall_common(int g_i, int g_p, int JIBS6, int DRONE, int BLOODPOOL, int SHOT long c; int sphit = fallspecial? fallspecial(g_i, g_p) : 0; - if (floorspace(g_sp->sectnum)) + if (fi.floorspace(g_sp->sectnum)) c = 0; else { - if (ceilingspace(g_sp->sectnum) || sector[g_sp->sectnum].lotag == 2) + if (fi.ceilingspace(g_sp->sectnum) || sector[g_sp->sectnum].lotag == 2) c = gc / 6; else c = gc; } @@ -5113,12 +5016,12 @@ void fall_common(int g_i, int g_p, int JIBS6, int DRONE, int BLOODPOOL, int SHOT goto SKIPJIBS; if (sphit) { - guts(g_sp, JIBS6, 5, g_p); + fi.guts(g_sp, JIBS6, 5, g_p); spritesound(squished, g_i); } else { - guts(g_sp, JIBS6, 15, g_p); + fi.guts(g_sp, JIBS6, 15, g_p); spritesound(squished, g_i); spawn(g_i, BLOODPOOL); } diff --git a/source/games/duke/src/actors.h b/source/games/duke/src/actors.h index 32165a0ab..ab5ba6b72 100644 --- a/source/games/duke/src/actors.h +++ b/source/games/duke/src/actors.h @@ -286,7 +286,6 @@ inline int wallswitchcheck(int s) int A_IncurDamage(int spriteNum); void A_AddToDeleteQueue(int spriteNum); void A_DeleteSprite(int spriteNum); -void guts(spritetype* s, short gtype, short n, short p); void A_DoGuts(int spriteNum, int tileNum, int spawnCnt); void A_DoGutsDir(int spriteNum, int tileNum, int spawnCnt); @@ -331,9 +330,6 @@ extern int32_t A_MoveSprite(int32_t spritenum, vec3_t const * change, uint32_t c ACTOR_INLINE_HEADER int A_CheckEnemyTile(int tileNum); ACTOR_INLINE_HEADER int A_SetSprite(int spriteNum, uint32_t cliptype); -EXTERN_INLINE_HEADER int G_CheckForSpaceCeiling(int sectnum); -EXTERN_INLINE_HEADER int G_CheckForSpaceFloor(int sectnum); - EXTERN_INLINE_HEADER int A_CheckEnemySprite(void const * s); #if defined actors_c_ || !defined DISABLE_INLINING @@ -355,18 +351,6 @@ ACTOR_INLINE int A_SetSprite(int const spriteNum, uint32_t cliptype) # endif -bool ceilingspace(int sectnum); -bool floorspace(int sectnum); - -EXTERN_INLINE int G_CheckForSpaceCeiling(int const sectnum) -{ - return ceilingspace(sectnum); -} - -EXTERN_INLINE int G_CheckForSpaceFloor(int const sectnum) -{ - return floorspace(sectnum); -} EXTERN_INLINE int A_CheckEnemySprite(void const * const pSprite) { @@ -389,7 +373,6 @@ inline int wakeup(int sn, int pn) } // shared functions -int ifhitsectors(int sn); void ms(short i); void movecrane(int i, int crane); void movefountain(int i, int fountain); @@ -453,14 +436,8 @@ void handle_se130(int i, int countmax, int EXPLOSION2); void respawn_rrra(int i, int j); -void hitradius(short i, int r, int hp1, int hp2, int hp3, int hp4); -int ifhitbyweapon(int sn); -int movesprite(short spritenum, int xchange, int ychange, int zchange, unsigned int cliptype); -void lotsofmoney(spritetype* s, short n); - int dodge(spritetype*); void alterang(int a, int g_i, int g_p); -void fall(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*)); // tile names which are identical for all games. diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 58ff8a8e9..0bf5c762e 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -241,13 +241,13 @@ void hitradius_d(short i, int r, int hp1, int hp2, int hp3, int hp4) { d = abs(wall[sector[dasect].wallptr].x - s->x) + abs(wall[sector[dasect].wallptr].y - s->y); if (d < r) - checkhitceiling(dasect); + fi.checkhitceiling(dasect); else { // ouch... d = abs(wall[wall[wall[sector[dasect].wallptr].point2].point2].x - s->x) + abs(wall[wall[wall[sector[dasect].wallptr].point2].point2].y - s->y); if (d < r) - checkhitceiling(dasect); + fi.checkhitceiling(dasect); } } @@ -267,7 +267,7 @@ void hitradius_d(short i, int r, int hp1, int hp2, int hp3, int hp4) y1 = (((wal->y + wall[wal->point2].y) >> 1) + s->y) >> 1; updatesector(x1, y1, §); if (sect >= 0 && cansee(x1, y1, s->z, sect, s->x, s->y, s->z, s->sectnum)) - checkhitwall(i, x, wal->x, wal->y, s->z, s->picnum); + fi.checkhitwall(i, x, wal->x, wal->y, s->z, s->picnum); } } while (sectcnt < sectend); } @@ -300,7 +300,7 @@ SKIPWALLCHECK: { if (badguy(sj) && !cansee(sj->x, sj->y, sj->z + q, sj->sectnum, s->x, s->y, s->z + q, s->sectnum)) goto BOLT; - checkhitsprite(j, i); + fi.checkhitsprite(j, i); } } else if (sj->extra >= 0 && sj != s && (sj->picnum == TRIPBOMB || badguy(sj) || sj->picnum == QUEBALL || sj->picnum == STRIPEBALL || (sj->cstat & 257) || sj->picnum == DUKELYINGDEAD)) @@ -378,7 +378,7 @@ SKIPWALLCHECK: sj->picnum == FEM8 || sj->picnum == FEM9 || sj->picnum == FEM10 || sj->picnum == STATUE || sj->picnum == STATUEFLASH || sj->picnum == SPACEMARINE || sj->picnum == QUEBALL || sj->picnum == STRIPEBALL) - checkhitsprite(j, i); + fi.checkhitsprite(j, i); } else if (s->extra == 0) hittype[j].extra = 0; @@ -884,7 +884,7 @@ void movefallers_d(void) s->z -= (16 << 8); hittype[i].temp_data[1] = s->ang; x = s->extra; - j = ifhitbyweapon(i); + j = fi.ifhitbyweapon(i); if (j >= 0) { if (j == FIREEXT || j == RPG || j == RADIUSEXPLOSION || j == SEENINE || j == OOZFILTER) @@ -934,10 +934,10 @@ void movefallers_d(void) ssp(i,CLIPMASK0); } - if (floorspace(s->sectnum)) x = 0; + if (fi.floorspace(s->sectnum)) x = 0; else { - if (ceilingspace(s->sectnum)) + if (fi.ceilingspace(s->sectnum)) x = gc / 6; else x = gc; @@ -1001,7 +1001,7 @@ static void movetripbomb(int i) spritesound(LASERTRIP_EXPLODE, i); for (j = 0; j < 5; j++) RANDOMSCRAP(s, i); x = s->extra; - hitradius(i, tripbombblastradius, x >> 2, x >> 1, x - (x >> 2), x); + fi.hitradius(i, tripbombblastradius, x >> 2, x >> 1, x - (x >> 2), x); j = spawn(i, EXPLOSION2); sprite[j].ang = s->ang; @@ -1024,7 +1024,7 @@ static void movetripbomb(int i) x = s->extra; s->extra = 1; int16_t l = s->ang; - j = ifhitbyweapon(i); + j = fi.ifhitbyweapon(i); if (j >= 0) { hittype[i].temp_data[2] = 16; @@ -1133,7 +1133,7 @@ static void movecrack(int i) { t[0] = s->cstat; t[1] = s->ang; - int j = ifhitbyweapon(i); + int j = fi.ifhitbyweapon(i); if (j == FIREEXT || j == RPG || j == RADIUSEXPLOSION || j == SEENINE || j == OOZFILTER) { j = headspritestat[STAT_STANDABLE]; @@ -1163,7 +1163,7 @@ static void movecrack(int i) static void movefireext(int i) { - int j = ifhitbyweapon(i); + int j = fi.ifhitbyweapon(i); if (j == -1) return; auto s = &sprite[i]; @@ -1192,13 +1192,13 @@ static void movefireext(int i) int x = s->extra; spawn(i, EXPLOSION2); - hitradius(i, pipebombblastradius, x >> 2, x - (x >> 1), x - (x >> 2), x); + fi.hitradius(i, pipebombblastradius, x >> 2, x - (x >> 1), x - (x >> 2), x); spritesound(PIPEBOMB_EXPLODE, i); detonate(i, EXPLOSION2); } else { - hitradius(i, seenineblastradius, 10, 15, 20, 25); + fi.hitradius(i, seenineblastradius, 10, 15, 20, 25); deletesprite(i); } } @@ -1617,7 +1617,7 @@ void moveweapons_d(void) break; } - j = movesprite(i, + j = fi.movesprite(i, (k*(sintable[(s->ang+512)&2047]))>>14, (k*(sintable[s->ang&2047]))>>14,ll,qq); @@ -1696,7 +1696,7 @@ void moveweapons_d(void) } if (!isWorldTour() || s->picnum != FIREBALL || fireball) - checkhitsprite(j,i); + fi.checkhitsprite(j,i); if (sprite[j].picnum == APLAYER) { @@ -1750,7 +1750,7 @@ void moveweapons_d(void) else { setsprite(i,dax,day,daz); - checkhitwall(i,j,s->x,s->y,s->z,s->picnum); + fi.checkhitwall(i,j,s->x,s->y,s->z,s->picnum); if (s->picnum == FREEZEBLAST) { @@ -1781,7 +1781,7 @@ void moveweapons_d(void) continue; } - checkhitceiling(s->sectnum); + fi.checkhitceiling(s->sectnum); } else if (fireball) { @@ -1834,7 +1834,7 @@ void moveweapons_d(void) { spawn(i,SHRINKEREXPLOSION); spritesound(SHRINKER_HIT,i); - hitradius(i,shrinkerblastradius,0,0,0,0); + fi.hitradius(i,shrinkerblastradius,0,0,0,0); } else if (s->picnum != COOLEXPLOSION1 && s->picnum != FREEZEBLAST && s->picnum != FIRELASER && (!isWorldTour() || s->picnum != FIREBALL)) { @@ -1855,12 +1855,12 @@ void moveweapons_d(void) if (s->xrepeat >= 10) { x = s->extra; - hitradius(i, rpgblastradius, x >> 2, x >> 1, x - (x >> 2), x); + fi.hitradius(i, rpgblastradius, x >> 2, x >> 1, x - (x >> 2), x); } else { x = s->extra+(global_random&3); - hitradius(i, (rpgblastradius >> 1), x >> 2, x >> 1, x - (x >> 2), x); + fi.hitradius(i, (rpgblastradius >> 1), x >> 2, x >> 1, x - (x >> 2), x); } } if (fireball) @@ -2298,7 +2298,7 @@ static void greenslime(int i) s->picnum = GREENSLIME + 2; s->extra = 1; s->pal = 1; - j = ifhitbyweapon(i); if (j >= 0) + j = fi.ifhitbyweapon(i); if (j >= 0) { if (j == FREEZEBLAST) return; @@ -2433,7 +2433,7 @@ static void greenslime(int i) } } - j = ifhitbyweapon(i); if (j >= 0) + j = fi.ifhitbyweapon(i); if (j >= 0) { spritesound(SLIM_DYING, i); @@ -2471,7 +2471,7 @@ static void greenslime(int i) s->picnum = GREENSLIME + 4; // if(s->yrepeat > 62) - // guts(s,JIBS6,5,myconnectindex); + // fi.guts(s,JIBS6,5,myconnectindex); if (s->xrepeat > 32) s->xrepeat -= krand() & 7; if (s->yrepeat > 16) s->yrepeat -= krand() & 7; @@ -2685,7 +2685,7 @@ static void flamethrowerflame(int i) return; } - j = movesprite(i, (s->xvel * (sintable[(s->ang + 512) & 2047])) >> 14, + j = fi.movesprite(i, (s->xvel * (sintable[(s->ang + 512) & 2047])) >> 14, (s->xvel * (sintable[s->ang & 2047])) >> 14, s->zvel, CLIPMASK1); if (s->sectnum < 0) @@ -2715,7 +2715,7 @@ static void flamethrowerflame(int i) if ((j & kHitTypeMask) == kHitSprite) { j &= (MAXSPRITES - 1); - checkhitsprite((short)j, i); + fi.checkhitsprite((short)j, i); if (sprite[j].picnum == APLAYER) spritesound(j, PISTOL_BODYHIT); } @@ -2723,24 +2723,24 @@ static void flamethrowerflame(int i) { j &= (MAXWALLS - 1); setsprite(i, dax, day, daz); - checkhitwall(i, j, s->x, s->y, s->z, s->picnum); + fi.checkhitwall(i, j, s->x, s->y, s->z, s->picnum); } else if ((j & kHitTypeMask) == kHitSector) { setsprite(i, dax, day, daz); if (s->zvel < 0) - checkhitceiling(s->sectnum); + fi.checkhitceiling(s->sectnum); } if (s->xrepeat >= 10) { x = s->extra; - hitradius(i, rpgblastradius, x >> 2, x >> 1, x - (x >> 2), x); + fi.hitradius(i, rpgblastradius, x >> 2, x >> 1, x - (x >> 2), x); } else { x = s->extra + (global_random & 3); - hitradius(i, (rpgblastradius >> 1), x >> 2, x >> 1, x - (x >> 2), x); + fi.hitradius(i, (rpgblastradius >> 1), x >> 2, x >> 1, x - (x >> 2), x); } } } @@ -2777,7 +2777,7 @@ static void heavyhbomb(int i) if (t[3] == 0) { - j = ifhitbyweapon(i); + j = fi.ifhitbyweapon(i); if (j >= 0) { t[3] = 1; @@ -2808,7 +2808,7 @@ static void heavyhbomb(int i) } } - j = movesprite(i, + j = fi.movesprite(i, (s->xvel * (sintable[(s->ang + 512) & 2047])) >> 14, (s->xvel * (sintable[s->ang & 2047])) >> 14, s->zvel, CLIPMASK0); @@ -2852,7 +2852,7 @@ static void heavyhbomb(int i) { j &= (MAXWALLS - 1); - checkhitwall(i, j, s->x, s->y, s->z, s->picnum); + fi.checkhitwall(i, j, s->x, s->y, s->z, s->picnum); int k = getangle( wall[wall[j].point2].x - wall[j].x, @@ -2888,7 +2888,7 @@ DETONATEB: case BOUNCEMINE: m = bouncemineblastradius; break; } - hitradius(i, m, x >> 2, x >> 1, x - (x >> 2), x); + fi.hitradius(i, m, x >> 2, x >> 1, x - (x >> 2), x); spawn(i, EXPLOSION2); if (s->zvel == 0) spawn(i, EXPLOSION2BOT); @@ -2938,7 +2938,7 @@ DETONATEB: spritesound(DUKE_GET, ps[p].i); if (ps[p].gotweapon[HANDBOMB_WEAPON] == 0 || s->owner == ps[p].i) - addweapon(&ps[p], HANDBOMB_WEAPON); + fi.addweapon(&ps[p], HANDBOMB_WEAPON); if (sprite[s->owner].picnum != APLAYER) { @@ -3019,7 +3019,7 @@ void moveactors_d(void) } else { - j = ifhitbyweapon(i); + j = fi.ifhitbyweapon(i); if (j >= 0) { s->cstat = 32 + 128; @@ -3046,7 +3046,7 @@ void moveactors_d(void) if (k == 1) { operateactivators(s->lotag, -1); - operateforcefields(i, s->lotag); + fi.operateforcefields(i, s->lotag); operatemasterswitches(s->lotag); } } @@ -4140,7 +4140,7 @@ void move_d(int g_i, int g_p, int g_x) } } - hittype[g_i].movflag = movesprite(g_i, + hittype[g_i].movflag = fi.movesprite(g_i, (daxvel * (sintable[(angdif + 512) & 2047])) >> 14, (daxvel * (sintable[angdif & 2047])) >> 14, g_sp->zvel, CLIPMASK0); } diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index 74db21ed7..266d69b51 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -222,13 +222,13 @@ void hitradius_r(short i, int r, int hp1, int hp2, int hp3, int hp4) { d = abs(wall[sector[dasect].wallptr].x - s->x) + abs(wall[sector[dasect].wallptr].y - s->y); if (d < r) - checkhitceiling(dasect); + fi.checkhitceiling(dasect); else { // ouch... d = abs(wall[wall[wall[sector[dasect].wallptr].point2].point2].x - s->x) + abs(wall[wall[wall[sector[dasect].wallptr].point2].point2].y - s->y); if (d < r) - checkhitceiling(dasect); + fi.checkhitceiling(dasect); } } @@ -248,7 +248,7 @@ void hitradius_r(short i, int r, int hp1, int hp2, int hp3, int hp4) y1 = (((wal->y + wall[wal->point2].y) >> 1) + s->y) >> 1; updatesector(x1, y1, §); if (sect >= 0 && cansee(x1, y1, s->z, sect, s->x, s->y, s->z, s->sectnum)) - checkhitwall(i, x, wal->x, wal->y, s->z, s->picnum); + fi.checkhitwall(i, x, wal->x, wal->y, s->z, s->picnum); } } while (sectcnt < sectend); @@ -271,7 +271,7 @@ SKIPWALLCHECK: { if (badguy(sj) && !cansee(sj->x, sj->y, sj->z + q, sj->sectnum, s->x, s->y, s->z + q, s->sectnum)) continue; - checkhitsprite(j, i); + fi.checkhitsprite(j, i); } } else if (sj->extra >= 0 && sj != s && (badguy(sj) || sj->picnum == QUEBALL || sj->picnum == RRTILE3440 || sj->picnum == STRIPEBALL || (sj->cstat & 257) || sj->picnum == DUKELYINGDEAD)) @@ -335,7 +335,7 @@ SKIPWALLCHECK: if (sj->picnum == STATUEFLASH || sj->picnum == QUEBALL || sj->picnum == STRIPEBALL || sj->picnum == RRTILE3440) - checkhitsprite(j, i); + fi.checkhitsprite(j, i); if (sprite[j].picnum != RADIUSEXPLOSION && s->owner >= 0 && sprite[s->owner].statnum < MAXSTATUS) @@ -890,10 +890,10 @@ void movefallers_r(void) ssp(i, CLIPMASK0); } - if (floorspace(s->sectnum)) x = 0; + if (fi.floorspace(s->sectnum)) x = 0; else { - if (ceilingspace(s->sectnum)) + if (fi.ceilingspace(s->sectnum)) x = gc / 6; else x = gc; @@ -1366,7 +1366,7 @@ void moveweapons_r(void) continue; } - checkhitsprite(j,i); + fi.checkhitsprite(j,i); if (sprite[j].picnum == APLAYER) { @@ -1425,7 +1425,7 @@ void moveweapons_r(void) else { setsprite(i, dax, day, daz); - checkhitwall(i, j, s->x, s->y, s->z, s->picnum); + fi.checkhitwall(i, j, s->x, s->y, s->z, s->picnum); if (!isRRRA() && s->picnum == FREEZEBLAST) { @@ -1501,7 +1501,7 @@ void moveweapons_r(void) continue; } - checkhitceiling(s->sectnum); + fi.checkhitceiling(s->sectnum); } if (!isRRRA() && s->picnum == FREEZEBLAST) @@ -1594,12 +1594,12 @@ void moveweapons_r(void) if (s->xrepeat >= 10) { x = s->extra; - hitradius(i, rpgblastradius, x >> 2, x >> 1, x - (x >> 2), x); + fi.hitradius(i, rpgblastradius, x >> 2, x >> 1, x - (x >> 2), x); } else { x = s->extra + (global_random & 3); - hitradius(i, (rpgblastradius >> 1), x >> 2, x >> 1, x - (x >> 2), x); + fi.hitradius(i, (rpgblastradius >> 1), x >> 2, x >> 1, x - (x >> 2), x); } } else if (isRRRA() && s->picnum == RPG2) @@ -1610,12 +1610,12 @@ void moveweapons_r(void) if (s->xrepeat >= 10) { x = s->extra; - hitradius(i, rpgblastradius, x >> 2, x >> 1, x - (x >> 2), x); + fi.hitradius(i, rpgblastradius, x >> 2, x >> 1, x - (x >> 2), x); } else { x = s->extra + (global_random & 3); - hitradius(i, (rpgblastradius >> 1), x >> 2, x >> 1, x - (x >> 2), x); + fi.hitradius(i, (rpgblastradius >> 1), x >> 2, x >> 1, x - (x >> 2), x); } } else if (isRRRA() && s->picnum == RRTILE1790) @@ -1626,12 +1626,12 @@ void moveweapons_r(void) if (s->xrepeat >= 10) { x = s->extra; - hitradius(i, rpgblastradius, x >> 2, x >> 1, x - (x >> 2), x); + fi.hitradius(i, rpgblastradius, x >> 2, x >> 1, x - (x >> 2), x); } else { x = s->extra + (global_random & 3); - hitradius(i, (rpgblastradius >> 1), x >> 2, x >> 1, x - (x >> 2), x); + fi.hitradius(i, (rpgblastradius >> 1), x >> 2, x >> 1, x - (x >> 2), x); } } } @@ -2012,7 +2012,7 @@ void movetransports_r(void) changespritesect(j, sprite[OW].sectnum); - movesprite(j, (sprite[j].xvel * sintable[(sprite[j].ang + 512) & 2047]) >> 14, + fi.movesprite(j, (sprite[j].xvel * sintable[(sprite[j].ang + 512) & 2047]) >> 14, (sprite[j].xvel * sintable[sprite[j].ang & 2047]) >> 14, 0, CLIPMASK1); break; @@ -2028,7 +2028,7 @@ void movetransports_r(void) changespritesect(j, sprite[OW].sectnum); - movesprite(j, (sprite[j].xvel * sintable[(sprite[j].ang + 512) & 2047]) >> 14, + fi.movesprite(j, (sprite[j].xvel * sintable[(sprite[j].ang + 512) & 2047]) >> 14, (sprite[j].xvel * sintable[sprite[j].ang & 2047]) >> 14, 0, CLIPMASK1); break; @@ -2089,7 +2089,7 @@ static void rrra_specialstats() deletesprite(i); } } - j = movesprite(i, 0, 0, sprite[i].extra * 2, CLIPMASK0); + j = fi.movesprite(i, 0, 0, sprite[i].extra * 2, CLIPMASK0); i = nexti; } @@ -2111,7 +2111,7 @@ static void rrra_specialstats() if (sprite[i].extra <= -20) sprite[i].hitag = 0; } - j = movesprite(i, 0, 0, sprite[i].extra, CLIPMASK0); + j = fi.movesprite(i, 0, 0, sprite[i].extra, CLIPMASK0); i = nexti; } @@ -2206,7 +2206,7 @@ static void rrra_specialstats() sprite[i].picnum = PIG + 7; sprite[i].extra = 1; } - movesprite(i, 0, 0, -300, CLIPMASK0); + fi.movesprite(i, 0, 0, -300, CLIPMASK0); if (sector[sprite[i].sectnum].ceilingz + (4 << 8) > sprite[i].z) { sprite[i].picnum = 0; @@ -2249,7 +2249,7 @@ static void rrra_specialstats() if (sprite[i].extra == sprite[i].lotag) sound(183); sprite[i].extra--; - j = movesprite(i, + j = fi.movesprite(i, (sprite[i].hitag * sintable[(sprite[i].ang + 512) & 2047]) >> 14, (sprite[i].hitag * sintable[sprite[i].ang & 2047]) >> 14, sprite[i].hitag << 1, CLIPMASK0); @@ -2675,7 +2675,7 @@ static void heavyhbomb(int i) if (t[3] == 0) { - j = ifhitbyweapon(i); + j = fi.ifhitbyweapon(i); if (j >= 0) { t[3] = 1; @@ -2713,7 +2713,7 @@ static void heavyhbomb(int i) s->zvel = 0; } - j = movesprite(i, + j = fi.movesprite(i, (s->xvel * (sintable[(s->ang + 512) & 2047])) >> 14, (s->xvel * (sintable[s->ang & 2047])) >> 14, s->zvel, CLIPMASK0); @@ -2768,7 +2768,7 @@ static void heavyhbomb(int i) { j &= (MAXWALLS - 1); - checkhitwall(i, j, s->x, s->y, s->z, s->picnum); + fi.checkhitwall(i, j, s->x, s->y, s->z, s->picnum); int k = getangle( wall[wall[j].point2].x - wall[j].x, @@ -2807,7 +2807,7 @@ DETONATEB: if (sector[s->sectnum].lotag != 800) { - hitradius(i, m, x >> 2, x >> 1, x - (x >> 2), x); + fi.hitradius(i, m, x >> 2, x >> 1, x - (x >> 2), x); spawn(i, EXPLOSION2); if (s->picnum == CHEERBOMB) spawn(i, BURNING); @@ -2855,7 +2855,7 @@ DETONATEB: spritesound(DUKE_GET, ps[p].i); if (ps[p].gotweapon[DYNAMITE_WEAPON] == 0 || s->owner == ps[p].i) - addweapon(&ps[p], DYNAMITE_WEAPON); + fi.addweapon(&ps[p], DYNAMITE_WEAPON); if (sprite[s->owner].picnum != APLAYER) { @@ -2909,7 +2909,7 @@ static int henstand(int i) if (s->xvel) { makeitfall(i); - j = movesprite(i, + j = fi.movesprite(i, (sintable[(s->ang + 512) & 2047] * s->xvel) >> 14, (sintable[s->ang & 2047] * s->xvel) >> 14, s->zvel, CLIPMASK0); @@ -2926,7 +2926,7 @@ static int henstand(int i) else if ((j & 49152) == 49152) { j &= (MAXSPRITES - 1); - checkhitsprite(i, j); + fi.checkhitsprite(i, j); if (sprite[j].picnum == HEN) { int ns = spawn(j, HENSTAND); @@ -3034,7 +3034,7 @@ void moveactors_r(void) } if (sector[sprite[i].sectnum].lotag == 903) makeitfall(i); - j = movesprite(i, + j = fi.movesprite(i, (s->xvel*sintable[(s->ang+512)&2047])>>14, (s->xvel*sintable[s->ang&2047])>>14, s->zvel,CLIPMASK0); @@ -3075,7 +3075,7 @@ void moveactors_r(void) continue; } makeitfall(i); - j = movesprite(i, + j = fi.movesprite(i, (s->xvel*(sintable[(s->ang+512)&2047]))>>14, (s->xvel*(sintable[s->ang&2047]))>>14, s->zvel,CLIPMASK0); @@ -3106,7 +3106,7 @@ void moveactors_r(void) continue; } makeitfall(i); - j = movesprite(i, + j = fi.movesprite(i, (s->xvel*sintable[(s->ang+512)&2047])>>14, (s->xvel*sintable[s->ang&2047])>>14, s->zvel,CLIPMASK0); @@ -3205,7 +3205,7 @@ void moveactors_r(void) if (!isRRRA() || (sector[sect].lotag != 1 && sector[sect].lotag != 160)) if (s->xvel) { - j = movesprite(i, + j = fi.movesprite(i, (s->xvel*sintable[(s->ang+512)&2047])>>14, (s->xvel*sintable[s->ang&2047])>>14, s->zvel,CLIPMASK0); @@ -4325,7 +4325,7 @@ void move_r(int g_i, int g_p, int g_x) } } - hittype[g_i].movflag = movesprite(g_i, + hittype[g_i].movflag = fi.movesprite(g_i, (daxvel * (sintable[(angdif + 512) & 2047])) >> 14, (daxvel * (sintable[angdif & 2047])) >> 14, g_sp->zvel, CLIPMASK0); } @@ -4375,7 +4375,7 @@ void fakebubbaspawn(int g_i, int g_p) //--------------------------------------------------------------------------- // -// special checks in fall that only apply to RR. +// special checks in fi.fall that only apply to RR. // //--------------------------------------------------------------------------- @@ -4399,7 +4399,7 @@ static int fallspecial(int g_i, int g_p) { if (g_sp->picnum != APLAYER && badguy(g_sp) && g_sp->z == hittype[g_i].floorz - FOURSLEIGHT) { - guts(g_sp, JIBS6, 5, g_p); + fi.guts(g_sp, JIBS6, 5, g_p); spritesound(SQUISHED, g_i); deletesprite(g_i); } @@ -4480,4 +4480,138 @@ void fall_r(int g_i, int g_p) fall_common(g_i, g_p, JIBS6, DRONE, BLOODPOOL, SHOTSPARK1, 69, 158, fallspecial, falladjustz); } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void destroyit(int g_i) +{ + auto g_sp = &sprite[g_i]; + spritetype* js; + short lotag, hitag; + short k, jj; + short wi, wj; + short spr; + short nextk, nextjj; + short wallstart2, wallend2; + short sectnum; + short wallstart, wallend; + + hitag = 0; + k = headspritesect[g_sp->sectnum]; + while (k != -1) + { + nextk = nextspritesect[k]; + if (sprite[k].picnum == RRTILE63) + { + lotag = sprite[k].lotag; + spr = k; + if (sprite[k].hitag) + hitag = sprite[k].hitag; + } + k = nextk; + } + jj = headspritestat[100]; + while (jj >= 0) + { + nextjj = nextspritestat[jj]; + js = &sprite[jj]; + if (hitag) + if (hitag == js->hitag) + { + k = headspritesect[js->sectnum]; + while (k != -1) + { + nextk = nextspritesect[k]; + if (sprite[k].picnum == DESTRUCTO) + { + hittype[k].picnum = SHOTSPARK1; + hittype[k].extra = 1; + } + k = nextk; + } + } + if (sprite[spr].sectnum != js->sectnum) + if (lotag == js->lotag) + { + sectnum = sprite[spr].sectnum; + wallstart = sector[sectnum].wallptr; + wallend = wallstart + sector[sectnum].wallnum; + wallstart2 = sector[js->sectnum].wallptr; + wallend2 = wallstart2 + sector[js->sectnum].wallnum; + for (wi = wallstart, wj = wallstart2; wi < wallend; wi++, wj++) + { + wall[wi].picnum = wall[wj].picnum; + wall[wi].overpicnum = wall[wj].overpicnum; + wall[wi].shade = wall[wj].shade; + wall[wi].xrepeat = wall[wj].xrepeat; + wall[wi].yrepeat = wall[wj].yrepeat; + wall[wi].xpanning = wall[wj].xpanning; + wall[wi].ypanning = wall[wj].ypanning; + if (isRRRA() && wall[wi].nextwall != -1) + { + wall[wi].cstat = 0; + wall[wall[wi].nextwall].cstat = 0; + } + } + sector[sectnum].floorz = sector[js->sectnum].floorz; + sector[sectnum].ceilingz = sector[js->sectnum].ceilingz; + sector[sectnum].ceilingstat = sector[js->sectnum].ceilingstat; + sector[sectnum].floorstat = sector[js->sectnum].floorstat; + sector[sectnum].ceilingpicnum = sector[js->sectnum].ceilingpicnum; + sector[sectnum].ceilingheinum = sector[js->sectnum].ceilingheinum; + sector[sectnum].ceilingshade = sector[js->sectnum].ceilingshade; + sector[sectnum].ceilingpal = sector[js->sectnum].ceilingpal; + sector[sectnum].ceilingxpanning = sector[js->sectnum].ceilingxpanning; + sector[sectnum].ceilingypanning = sector[js->sectnum].ceilingypanning; + sector[sectnum].floorpicnum = sector[js->sectnum].floorpicnum; + sector[sectnum].floorheinum = sector[js->sectnum].floorheinum; + sector[sectnum].floorshade = sector[js->sectnum].floorshade; + sector[sectnum].floorpal = sector[js->sectnum].floorpal; + sector[sectnum].floorxpanning = sector[js->sectnum].floorxpanning; + sector[sectnum].floorypanning = sector[js->sectnum].floorypanning; + sector[sectnum].visibility = sector[js->sectnum].visibility; + g_sectorExtra[sectnum] = g_sectorExtra[js->sectnum]; // TRANSITIONAL: at least rename this. + sector[sectnum].lotag = sector[js->sectnum].lotag; + sector[sectnum].hitag = sector[js->sectnum].hitag; + sector[sectnum].extra = sector[js->sectnum].extra; + } + jj = nextjj; + } + k = headspritesect[g_sp->sectnum]; + while (k != -1) + { + nextk = nextspritesect[k]; + switch (sprite[k].picnum) + { + case DESTRUCTO: + case RRTILE63: + case TORNADO: + case RR_APLAYER: + case COOT: + break; + default: + deletesprite(k); + break; + } + k = nextk; + } +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void mamaspawn(int g_i) +{ + if (mamaspawn_count) + { + mamaspawn_count--; + spawn(g_i, RABBIT); + } +} END_DUKE_NS diff --git a/source/games/duke/src/condef.h b/source/games/duke/src/condef.h index 56edfe81a..bb30bc70f 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(fall) // 16 +cmd(fi.fall) // 16 cmd(state) // 17 cmd(ends) // 18 cmd(define) // 19 //cmdx(comment, "//") // 20 cmd(ifai) // 21 cmd(killit) // 22 -cmd(addweapon) // 23 +cmd(fi.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(hitradius) // 50 +cmd(fi.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(guts) // 58 +cmd(fi.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 new file mode 100644 index 000000000..207300de8 --- /dev/null +++ b/source/games/duke/src/dispatch.cpp @@ -0,0 +1,145 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 2020 - Christoph Oelckers + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ +//------------------------------------------------------------------------- + + +//--------------------------------------------------------------------------- +// +// Dispatcher for functions where different variants exist for the two families of games. +// +//--------------------------------------------------------------------------- + +bool isadoorwall_d(int dapic); +bool isadoorwall_r(int dapic); +void animatewalls_d(void); +void animatewalls_r(void); +void operaterespawns_d(int low); +void operaterespawns_r(int low); +void operateforcefields_r(int s, int low); +void operateforcefields_d(int s, int low); +bool checkhitswitch_d(int snum, int w, int switchtype); +bool checkhitswitch_r(int snum, int w, int switchtype); +void activatebysector_d(int sect, int j); +void activatebysector_r(int sect, int j); +void checkhitwall_d(int spr, int dawallnum, int x, int y, int z, int atwith); +void checkhitwall_r(int spr, int dawallnum, int x, int y, int z, int atwith); +void checkplayerhurt_d(struct player_struct* p, int j); +void checkplayerhurt_r(struct player_struct* p, int j); +bool checkhitceiling_d(int sn); +bool checkhitceiling_r(int sn); +void checkhitsprite_d(int i, int sn); +void checkhitsprite_r(int i, int sn); +void checksectors_d(int snum); +void checksectors_r(int snum); + +bool ceilingspace_d(int sectnum); +bool ceilingspace_r(int sectnum); +bool floorspace_d(int sectnum); +bool floorspace_r(int sectnum); +void addweapon_d(struct player_struct *p, int weapon); +void addweapon_r(struct player_struct *p, int weapon); +void hitradius_d(short i, int r, int hp1, int hp2, int hp3, int hp4); +void hitradius_r(short i, int r, int hp1, int hp2, int hp3, int hp4); +int movesprite_d(short spritenum, int xchange, int ychange, int zchange, unsigned int cliptype); +int movesprite_r(short spritenum, int xchange, int ychange, int zchange, unsigned int cliptype); +void lotsofmoney_d(spritetype *s, short n); +void lotsofmail_d(spritetype *s, short n); +void lotsofpaper_d(spritetype *s, short n); +void lotsoffeathers_r(spritetype *s, short n); +void guts_d(spritetype* s, short gtype, short n, short p); +void guts_r(spritetype* s, short gtype, short n, short p); +void gutsdir_d(spritetype* s, short gtype, short n, short p); +void gutsdir_r(spritetype* s, short gtype, short n, short p); +int ifhitsectors_d(int sectnum); +int ifhitsectors_r(int sectnum); +int ifhitbyweapon_r(int sn); +int ifhitbyweapon_d(int sn); +void fall_d(int g_i, int g_p); +void fall_r(int g_i, int g_p); + +Dispatcher fi; + +void SetDispatcher() +{ + if (!isRR()) + { + fi = { + isadoorwall_d, + animatewalls_d, + operaterespawns_d, + operateforcefields_d, + checkhitswitch_d, + activatebysector_d, + checkhitwall_d, + checkplayerhurt_d, + checkhitceiling_d, + checkhitsprite_d, + checksectors_d, + + ceilingspace_d, + floorspace_d, + addweapon_d, + hitradius_d, + movesprite_d, + lotsofmoney_d, + lotsofmail_d, + lotsofpaper_d, + guts_d, + gutsdir_d, + ifhitsectors_d, + ifhitbyweapon_d, + fall_d + }; + } + else + { + fi = { + isadoorwall_r, + animatewalls_r, + operaterespawns_r, + operateforcefields_r, + checkhitswitch_r, + activatebysector_r, + checkhitwall_r, + checkplayerhurt_r, + checkhitceiling_r, + checkhitsprite_r, + checksectors_r, + + ceilingspace_r, + floorspace_r, + addweapon_r, + hitradius_r, + movesprite_r, + lotsoffeathers_r, + lotsoffeathers_r, + lotsoffeathers_r, + guts_r, + gutsdir_r, + ifhitsectors_r, + ifhitbyweapon_r, + fall_r + }; + } +} + + + diff --git a/source/games/duke/src/game.h b/source/games/duke/src/game.h index ab5bff815..9e82f9146 100644 --- a/source/games/duke/src/game.h +++ b/source/games/duke/src/game.h @@ -245,7 +245,7 @@ void G_PostCreateGameState(void); void A_SpawnCeilingGlass(int spriteNum,int sectNum,int glassCnt); #define ceilingglass A_SpawnCeilingGlass -void A_SpawnGlass(int spriteNum,int glassCnt); +void spriteglass(int spriteNum,int glassCnt); void A_SpawnRandomGlass(int spriteNum,int wallNum,int glassCnt); #define lotsofcolourglass A_SpawnRandomGlass void A_SpawnWallGlass(int spriteNum,int wallnum,int glassCnt); @@ -307,6 +307,11 @@ inline int32_t G_GetTeamPalette(int32_t team) } #define A_CheckSpriteFlags(spriteNum, iType) (((g_tile[sprite[spriteNum].picnum].flags^actor[spriteNum].flags) & iType) != 0) + +inline int actorfella(int spnum) +{ + return A_CheckSpriteFlags(spnum, SFLAG_KILLCOUNT); +} // (unsigned)iPicnum check: AMC TC Rusty Nails, bayonet MG alt. fire, iPicnum == -1 (via aplWeaponShoots) #define A_CheckSpriteTileFlags(iPicnum, iType) (((unsigned)iPicnum < MAXTILES) && (g_tile[iPicnum].flags & iType) != 0) #define S_StopSound(num) S_StopEnvSound(num, -1) @@ -440,6 +445,38 @@ static inline int G_GetMusicIdx(const char *str) extern void G_PrintCurrentMusic(void); +struct Dispatcher +{ + // sectors_?.cpp + bool (*isadoorwall)(int dapic); + void (*animatewalls)(); + void (*operaterespawns)(int low); + void (*operateforcefields)(int s, int low); + bool (*checkhitswitch)(int snum, int w, int switchtype); + void (*activatebysector)(int sect, int j); + void (*checkhitwall)(int spr, int dawallnum, int x, int y, int z, int atwith); + void (*checkplayerhurt)(struct player_struct* p, int j); + bool (*checkhitceiling)(int sn); + void (*checkhitsprite)(int i, int sn); + void (*checksectors)(int low); + + bool (*ceilingspace)(int sectnum); + bool (*floorspace)(int sectnum); + void (*addweapon)(struct player_struct *p, int weapon); + void (*hitradius)(short i, int r, int hp1, int hp2, int hp3, int hp4); + int (*movesprite)(short spritenum, int xchange, int ychange, int zchange, unsigned int cliptype); + void (*lotsofmoney)(spritetype *s, short n); + void (*lotsofmail)(spritetype *s, short n); + void (*lotsofpaper)(spritetype *s, short n); + void (*guts)(spritetype* s, short gtype, short n, short p); + void (*gutsdir)(spritetype* s, short gtype, short n, short p); + int (*ifhitsectors)(int sectnum); + int (*ifhitbyweapon)(int sectnum); + void (*fall)(int g_i, int g_p); +}; + +extern Dispatcher fi; + #endif END_DUKE_NS diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index 2154994fd..1e6f36423 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -52,6 +52,8 @@ int furthestcanseepoint(int i, spritetype* ts, int* dax, int* day); bool ifsquished(int i, int p); void fakebubbaspawn(int g_i, int g_p); void tearitup(int sect); +void destroyit(int g_i); +void mamaspawn(int g_i); //--------------------------------------------------------------------------- // @@ -247,7 +249,7 @@ char parse(void) break; case concmd_ifhitweapon: - parseifelse(ifhitbyweapon(g_i) >= 0); + parseifelse(fi.ifhitbyweapon(g_i) >= 0); break; case concmd_ifsquished: parseifelse(ifsquished(g_i, g_p) == 1); @@ -331,11 +333,7 @@ char parse(void) insptr++; break; case concmd_mamaspawn: - if (mamaspawn_count) - { - mamaspawn_count--; - spawn(g_i, RABBIT); - } + mamaspawn(g_i); insptr++; break; case concmd_mamaquake: @@ -440,7 +438,7 @@ char parse(void) insptr++; - if ((g_sp->picnum == APLAYER && g_sp->yrepeat < 36) || *insptr < g_sp->yrepeat || ((g_sp->yrepeat * (tilesizy[g_sp->picnum] + 8)) << 2) < (hittype[g_i].floorz - hittype[g_i].ceilingz)) + if ((g_sp->picnum == APLAYER && g_sp->yrepeat < 36) || *insptr < g_sp->yrepeat || ((g_sp->yrepeat * (tilesiz[g_sp->picnum].y + 8)) << 2) < (hittype[g_i].floorz - hittype[g_i].ceilingz)) { j = ((*insptr) - g_sp->yrepeat) << 1; if (abs(j)) g_sp->yrepeat += ksgn(j); @@ -552,17 +550,17 @@ char parse(void) insptr++; g_sp->xoffset = 0; g_sp->yoffset = 0; - fall(g_i, g_p); + fi.fall(g_i, g_p); break; case concmd_enda: case concmd_break: case concmd_ends: case concmd_endevent: return 1; - case 30: + case concmd_rightbrace: insptr++; return 1; - case 2: + case concmd_addammo: insptr++; if( ps[g_p].ammo_amount[*insptr] >= max_ammo_amount[*insptr] ) { @@ -572,47 +570,55 @@ char parse(void) addammo( *insptr, &ps[g_p], *(insptr+1) ); if(ps[g_p].curr_weapon == KNEE_WEAPON) if( ps[g_p].gotweapon[*insptr] ) - addweapon( &ps[g_p], *insptr ); + fi.addweapon( &ps[g_p], *insptr ); insptr += 2; break; - case 86: + case concmd_money: insptr++; - lotsofmoney(g_sp,*insptr); + fi.lotsofmoney(g_sp,*insptr); insptr++; break; - case 102: + case concmd_mail: insptr++; - lotsofmail(g_sp,*insptr); + fi.lotsofmail(g_sp,*insptr); insptr++; break; - case 105: + case concmd_sleeptime: insptr++; hittype[g_i].timetosleep = (short)*insptr; insptr++; break; - case 103: + case concmd_paper: insptr++; - lotsofpaper(g_sp,*insptr); + fi.lotsofpaper(g_sp,*insptr); insptr++; break; - case 88: + case concmd_addkills: insptr++; - ps[g_p].actors_killed += *insptr; + if (isRR()) + { + if (g_spriteExtra[g_i] < 1 || g_spriteExtra[g_i] == 128) + { + if (actorfella(g_i)) + ps[g_p].actors_killed += *insptr; + } + } + else ps[g_p].actors_killed += *insptr; hittype[g_i].actorstayput = -1; insptr++; break; - case 93: + case concmd_lotsofglass: insptr++; spriteglass(g_i,*insptr); insptr++; break; - case 22: + case concmd_killit: insptr++; killit_flag = 1; break; - case 23: // addweapon + case concmd_addweapon: insptr++; - if( ps[g_p].gotweapon[*insptr] == 0 ) addweapon( &ps[g_p], *insptr ); + if( ps[g_p].gotweapon[*insptr] == 0 ) fi.addweapon( &ps[g_p], *insptr ); else if( ps[g_p].ammo_amount[*insptr] >= max_ammo_amount[*insptr] ) { killit_flag = 2; @@ -621,31 +627,135 @@ char parse(void) addammo( *insptr, &ps[g_p], *(insptr+1) ); if(ps[g_p].curr_weapon == KNEE_WEAPON) if( ps[g_p].gotweapon[*insptr] ) - addweapon( &ps[g_p], *insptr ); + fi.addweapon( &ps[g_p], *insptr ); insptr+=2; break; - case 68: + case concmd_debug: insptr++; - printf("%ld\n",*insptr); + Printf("%ld\n",*insptr); insptr++; break; - case 69: - insptr++; + case concmd_endofgame: ps[g_p].timebeforeexit = *insptr; ps[g_p].customexitsound = -1; ud.eog = 1; insptr++; break; - case 25: + + case concmd_isdrunk: // todo: move out to player_r. + insptr++; + ps[g_p].drink_amt += *insptr; + j = sprite[ps[g_p].i].extra; + if (j > 0) + j += *insptr; + if (j > max_player_health * 2) + j = max_player_health * 2; + if (j < 0) + j = 0; + + if (ud.god == 0) + { + if (*insptr > 0) + { + if ((j - *insptr) < (max_player_health >> 2) && + j >= (max_player_health >> 2)) + spritesound(DUKE_GOTHEALTHATLOW, ps[g_p].i); + + ps[g_p].last_extra = j; + } + + sprite[ps[g_p].i].extra = j; + } + if (ps[g_p].drink_amt > 100) + ps[g_p].drink_amt = 100; + + if (sprite[ps[g_p].i].extra >= max_player_health) + { + sprite[ps[g_p].i].extra = max_player_health; + ps[g_p].last_extra = max_player_health; + } + insptr++; + break; + case concmd_strafeleft: + insptr++; + fi.movesprite(g_i, sintable[(g_sp->ang + 1024) & 2047] >> 10, sintable[(g_sp->ang + 512) & 2047] >> 10, g_sp->zvel, CLIPMASK0); + break; + case concmd_straferight: + insptr++; + fi.movesprite(g_i, sintable[(g_sp->ang - 0) & 2047] >> 10, sintable[(g_sp->ang - 512) & 2047] >> 10, g_sp->zvel, CLIPMASK0); + break; + case concmd_larrybird: + insptr++; + ps[g_p].posz = sector[sprite[ps[g_p].i].sectnum].ceilingz; + sprite[ps[g_p].i].z = ps[g_p].posz; + break; + case concmd_destroyit: + insptr++; + destroyit(g_i); + break; + case concmd_iseat: // move out to player_r. + insptr++; + ps[g_p].eat += *insptr; + if (ps[g_p].eat > 100) + { + ps[g_p].eat = 100; + } + ps[g_p].drink_amt -= *insptr; + if (ps[g_p].drink_amt < 0) + ps[g_p].drink_amt = 0; + j = sprite[ps[g_p].i].extra; + if (g_sp->picnum != TILE_ATOMICHEALTH) + { + if (j > max_player_health && *insptr > 0) + { + insptr++; + break; + } + else + { + if (j > 0) + j += (*insptr) * 3; + if (j > max_player_health && *insptr > 0) + j = max_player_health; + } + } + else + { + if (j > 0) + j += *insptr; + if (j > (max_player_health << 1)) + j = (max_player_health << 1); + } + + if (j < 0) j = 0; + + if (ud.god == 0) + { + if (*insptr > 0) + { + if ((j - *insptr) < (max_player_health >> 2) && + j >= (max_player_health >> 2)) + spritesound(229, ps[g_p].i); + + ps[g_p].last_extra = j; + } + + sprite[ps[g_p].i].extra = j; + } + + insptr++; + break; + + case concmd_addphealth: // todo: move out to player. insptr++; - if(ps[g_p].newowner >= 0) + if(!isRR() && ps[g_p].newowner >= 0) { ps[g_p].newowner = -1; ps[g_p].posx = ps[g_p].oposx; ps[g_p].posy = ps[g_p].oposy; ps[g_p].posz = ps[g_p].oposz; - ps[g_p].ang = ps[g_p].oang; + ps[g_p].q16ang = ps[g_p].oq16ang; updatesector(ps[g_p].posx,ps[g_p].posy,&ps[g_p].cursectnum); setpal(&ps[g_p]); @@ -660,7 +770,7 @@ char parse(void) j = sprite[ps[g_p].i].extra; - if(g_sp->picnum != ATOMICHEALTH) + if(g_sp->picnum != TILE_ATOMICHEALTH) { if( j > max_player_health && *insptr > 0 ) { @@ -691,7 +801,7 @@ char parse(void) { if( ( j - *insptr ) < (max_player_health>>2) && j >= (max_player_health>>2) ) - spritesound(DUKE_GOTHEALTHATLOW,ps[g_p].i); + spritesound(isRR()? 229 : DUKE_GOTHEALTHATLOW,ps[g_p].i); ps[g_p].last_extra = j; } @@ -701,22 +811,20 @@ char parse(void) insptr++; break; - case 17: + + case concmd_state: { - int *tempscrptr; - - tempscrptr = insptr+2; - - insptr = (int *) *(insptr+1); - while(1) if(parse()) break; + auto tempscrptr = insptr + 2; + insptr = apScript + *(insptr + 1); + while (1) if (parse()) break; insptr = tempscrptr; } break; - case 29: + case concmd_leftbrace: insptr++; while(1) if(parse()) break; break; - case 32: + case concmd_move: g_t[0]=0; insptr++; g_t[1] = *insptr; @@ -726,34 +834,35 @@ char parse(void) if(g_sp->hitag&random_angle) g_sp->ang = krand()&2047; break; - case 31: + case concmd_spawn: insptr++; if(g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS) spawn(g_i,*insptr); insptr++; break; - case 33: + case concmd_ifwasweapon: + case concmd_ifspawnedby: // these two are the same insptr++; parseifelse( hittype[g_i].picnum == *insptr); break; - case 21: + case concmd_ifai: insptr++; parseifelse(g_t[5] == *insptr); break; - case 34: + case concmd_ifaction: insptr++; parseifelse(g_t[4] == *insptr); break; - case 35: + case concmd_ifactioncount: insptr++; parseifelse(g_t[2] >= *insptr); break; - case 36: + case concmd_resetactioncount: insptr++; g_t[2] = 0; break; - case 37: - { + case concmd_debris: + { short dnum; insptr++; @@ -876,10 +985,35 @@ char parse(void) setpal(&ps[g_p]); //AddLog("EOF: resetplayer"); + break; + case 130: + parseifelse(ud.coop || numplayers > 2); + break; + case 129: + parseifelse(abs(g_sp->z - sector[g_sp->sectnum].floorz) < (32 << 8) && sector[g_sp->sectnum].floorpicnum == 3073); break; case 43: parseifelse( abs(g_sp->z-sector[g_sp->sectnum].floorz) < (32<<8) && sector[g_sp->sectnum].lotag == 1); break; +#ifdef RRRA + case 131: + parseifelse(ps[g_p].MotoSpeed > 60); + break; + case 134: + parseifelse(ps[g_p].OnMotorcycle == 1); + break; + case 135: + parseifelse(ps[g_p].OnBoat == 1); + break; + case 145: + g_sp->xrepeat--; + g_sp->yrepeat--; + parseifelse(g_sp->xrepeat <= 5); + break; + case 132: + parseifelse(WindTime > 0); + break; +#endif case 44: parseifelse( sector[g_sp->sectnum].lotag == 2); break; @@ -944,7 +1078,7 @@ char parse(void) insptr++; break; case 50: - hitradius(g_i,*(insptr+1),*(insptr+2),*(insptr+3),*(insptr+4),*(insptr+5)); + fi.hitradius(g_i,*(insptr+1),*(insptr+2),*(insptr+3),*(insptr+4),*(insptr+5)); insptr+=6; break; case 51: @@ -1012,19 +1146,26 @@ char parse(void) break; case 58: insptr += 2; - guts(g_sp,*(insptr-1),*insptr,g_p); + fi.guts(g_sp,*(insptr-1),*insptr,g_p); insptr++; break; - case 59: - insptr++; -// if(g_sp->owner >= 0 && sprite[g_sp->owner].picnum == *insptr) - // parseifelse(1); -// else - parseifelse( hittype[g_i].picnum == *insptr); - break; - case 61: + case 121: insptr++; forceplayerangle(&ps[g_p]); + ps[g_p].posxv -= sintable[(ps[g_p].ang + 512) & 2047] << 7; + ps[g_p].posyv -= sintable[ps[g_p].ang & 2047] << 7; + return 0; + case 61: + insptr++; + if (!isRR()) + forceplayerangle(&ps[g_p]); + else + { + ps[g_p].posxv -= sintable[(ps[g_p].ang + 512) & 2047] << 10; + ps[g_p].posyv -= sintable[ps[g_p].ang & 2047] << 10; + ps[g_p].jumping_counter = 767; + ps[g_p].jumping_toggle = 1; + } return 0; case 62: insptr++; @@ -1062,7 +1203,7 @@ char parse(void) } break; case 67: - parseifelse(ceilingspace(g_sp->sectnum)); + parseifelse(fi.ceilingspace(g_sp->sectnum)); break; case 74: @@ -1366,7 +1507,7 @@ char parse(void) insptr++; break; case 81: - parseifelse( floorspace(g_sp->sectnum)); + parseifelse( fi.floorspace(g_sp->sectnum)); break; case 82: parseifelse( (hittype[g_i].movflag&49152) > 16384 ); @@ -1388,10 +1529,10 @@ char parse(void) case PODFEM1: case NAKED1: case STATUE: - if(g_sp->yvel) operaterespawns(g_sp->yvel); + if(g_sp->yvel) fi.operaterespawns(g_sp->yvel); break; default: - if(g_sp->hitag >= 0) operaterespawns(g_sp->hitag); + if(g_sp->hitag >= 0) fi.operaterespawns(g_sp->hitag); break; } break; diff --git a/source/games/duke/src/global.h b/source/games/duke/src/global.h index afda03dd5..f1212749e 100644 --- a/source/games/duke/src/global.h +++ b/source/games/duke/src/global.h @@ -280,7 +280,7 @@ extern int32_t g_tripbombRadius; extern int32_t g_volumeCnt; #define gc g_spriteGravity -extern int16_t g_blimpSpawnItems[15]; +extern int16_t weaponsandammosprites[15]; extern int32_t g_gametypeFlags[MAXGAMETYPES]; extern const char *s_buildDate; diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp new file mode 100644 index 000000000..68b23c24d --- /dev/null +++ b/source/games/duke/src/player.cpp @@ -0,0 +1,40 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 1996, 2003 - 3D Realms Entertainment +Copyright (C) 2000, 2003 - Matt Saettler (EDuke Enhancements) + +This file is part of Enhanced Duke Nukem 3D version 1.5 - Atomic Edition + +Duke Nukem 3D is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +Original Source: 1996 - Todd Replogle +Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms + +EDuke enhancements integrated: 04/13/2003 - Matt Saettler + +Note: EDuke source was in transition. Changes are in-progress in the +source as it is released. + +*/ +//------------------------------------------------------------------------- + + +#include "ns.h" +#include "global.h" + +BEGIN_DUKE_NS + +END_DUKE_NS diff --git a/source/games/duke/src/player.h b/source/games/duke/src/player.h index 0721eeeeb..6070ab483 100644 --- a/source/games/duke/src/player.h +++ b/source/games/duke/src/player.h @@ -248,7 +248,7 @@ typedef struct player_struct { int32_t noise_x, noise_y, noise_radius; uint8_t keys[5]; int16_t yehaa_timer; - int16_t drink_amt, eat_amt, drink_ang, eat_ang; + int16_t drink_amt, eat, drink_ang, eat_ang; int32_t drink_timer, eat_timer; int16_t MamaEnd; int16_t MotoSpeed, tilt_status, moto_drink; @@ -392,7 +392,6 @@ inline void addammo(int weaponNum, DukePlayer_t* pPlayer, int addAmount) P_AddAmmo(pPlayer, weaponNum, addAmount); } void P_AddWeapon(DukePlayer_t *pPlayer, int weaponNum); -void addweapon(DukePlayer_t* pPlayer, int weaponNum); void P_CheckWeapon(DukePlayer_t *pPlayer); void P_DisplayScuba(void); void P_DisplayWeapon(void); diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp new file mode 100644 index 000000000..68b23c24d --- /dev/null +++ b/source/games/duke/src/player_d.cpp @@ -0,0 +1,40 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 1996, 2003 - 3D Realms Entertainment +Copyright (C) 2000, 2003 - Matt Saettler (EDuke Enhancements) + +This file is part of Enhanced Duke Nukem 3D version 1.5 - Atomic Edition + +Duke Nukem 3D is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +Original Source: 1996 - Todd Replogle +Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms + +EDuke enhancements integrated: 04/13/2003 - Matt Saettler + +Note: EDuke source was in transition. Changes are in-progress in the +source as it is released. + +*/ +//------------------------------------------------------------------------- + + +#include "ns.h" +#include "global.h" + +BEGIN_DUKE_NS + +END_DUKE_NS diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp new file mode 100644 index 000000000..28c050b00 --- /dev/null +++ b/source/games/duke/src/player_r.cpp @@ -0,0 +1,33 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 1996, 2003 - 3D Realms Entertainment +Copyright (C) 2017-2019 Nuke.YKT + +This file is part of Duke Nukem 3D version 1.5 - Atomic Edition + +Duke Nukem 3D is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +Original Source: 1996 - Todd Replogle +Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms +*/ +//------------------------------------------------------------------------- + +#include "ns.h" +#include "global.h" + +BEGIN_DUKE_NS + +END_DUKE_NS diff --git a/source/games/duke/src/sector.h b/source/games/duke/src/sector.h index 8040d7825..0f199c293 100644 --- a/source/games/duke/src/sector.h +++ b/source/games/duke/src/sector.h @@ -48,44 +48,26 @@ typedef struct { void breakwall(short newpn, short spr, short dawallnum); -void activatebysector(int s, int sn); int S_FindMusicSFX(int sectNum, int *sndptr); void callsound2(int soundNum, int playerNum); int callsound(int sectNum,int spriteNum); -int A_CheckHitSprite(int spriteNum,int16_t *hitSprite); -inline int hitasprite(int s, int16_t* h) -{ - return A_CheckHitSprite(s, h); -} -void checkhitsprite(int s, int d); -void checkhitwall(int spr, int wal, int x, int y, int z, int w); -inline void A_DamageWall(int spr, int dawallnum, const vec3_t* pos, int weaponNum) -{ - checkhitwall(spr, dawallnum, pos->x, pos->y, pos->z, weaponNum); -} +int hitasprite(int spriteNum,int16_t *hitSprite); int findplayer(const spritetype* pSprite, int32_t* dist); void operatejaildoors(int hitag); void allignwarpelevators(void); -bool isadoorwall(int tileNum); bool isablockdoor(int tileNum); void G_AnimateCamSprite(int smoothRatio); -void animatewalls(void); bool activatewarpelevators(int s, int w); int check_activator_motion(int lotag); void operateactivators(int l, int w); -void operateforcefields(int s,int low); void operateforcefields_common(int s, int low, const std::initializer_list& tiles); void operatemasterswitches(int lotag); -void operaterespawns(int lotag); void operatesectors(int s, int i); void P_HandleSharedKeys(int playerNum); int getanimationgoal(const int32_t* animPtr); bool isanearoperator(int lotag); bool isanunderoperator(int lotag); -bool checkhitswitch(int playerNum, int wallOrSprite, int nSwitchType); -void checksectors(int playerNum); -bool checkhitceiling(int sec); int setanimation(short animsect, int* animptr, int thegoal, int thevel); void dofurniture(int wallNum, int sectNum, int playerNum); void dotorch(); diff --git a/source/games/duke/src/sectors.cpp b/source/games/duke/src/sectors.cpp index e4807d912..bcd81c5a1 100644 --- a/source/games/duke/src/sectors.cpp +++ b/source/games/duke/src/sectors.cpp @@ -42,91 +42,6 @@ using std::max; // PRIMITIVE BEGIN_DUKE_NS -//--------------------------------------------------------------------------- -// -// game dependent dispatchers -// -//--------------------------------------------------------------------------- - -bool isadoorwall_d(int dapic); -bool isadoorwall_r(int dapic); -void animatewalls_d(void); -void animatewalls_r(void); -void operaterespawns_d(int low); -void operaterespawns_r(int low); -void operateforcefields_r(int s, int low); -void operateforcefields_d(int s, int low); -bool checkhitswitch_d(int snum, int w, int switchtype); -bool checkhitswitch_r(int snum, int w, int switchtype); -void activatebysector_d(int sect, int j); -void activatebysector_r(int sect, int j); -void checkhitwall_d(int spr, int dawallnum, int x, int y, int z, int atwith); -void checkhitwall_r(int spr, int dawallnum, int x, int y, int z, int atwith); -void checkplayerhurt_d(struct player_struct* p, int j); -void checkplayerhurt_r(struct player_struct* p, int j); -bool checkhitceiling_d(int sn); -bool checkhitceiling_r(int sn); -void checkhitsprite_d(int i, int sn); -void checkhitsprite_r(int i, int sn); -void checksectors_d(int snum); -void checksectors_r(int snum); - -bool isadoorwall(int dapic) -{ - return isRR() ? isadoorwall_r(dapic) : isadoorwall_d(dapic); -} - -void animatewalls() -{ - if (isRR()) animatewalls_r(); else animatewalls_d(); -} - -void operaterespawns(int low) -{ - if (isRR()) operaterespawns_r(low); else operaterespawns_d(low); -} - -void operateforcefields(int s, int low) -{ - if (isRR()) operateforcefields_r(s, low); else operateforcefields_d(s, low); -} - -bool checkhitswitch(int snum, int w, int switchtype) -{ - return isRR() ? checkhitswitch_r(snum, w, switchtype) : checkhitswitch_d(snum, w, switchtype); -} - -void activatebysector(int sect, int j) -{ - if (isRR()) activatebysector_r(sect, j); else activatebysector_d(sect, j); -} - -void checkhitwall(int spr, int dawallnum, int x, int y, int z, int atwith) -{ - if (isRR()) checkhitwall_r(spr, dawallnum, x, y, z, atwith); else checkhitwall_d(spr, dawallnum, x, y, z, atwith); -} - -void checkplayerhurt(struct player_struct* p, int j) -{ - if (isRR()) checkplayerhurt_r(p, j); else checkplayerhurt_d(p, j); -} - -bool checkhitceiling(int sn) -{ - return isRR() ? checkhitceiling_r(sn) : checkhitceiling_d(sn); -} - -void checkhitsprite(int i, int sn) -{ - if (isRR()) checkhitsprite_r(i, sn); else checkhitsprite_d(i, sn); -} - -void checksectors(int low) -{ - if (isRR()) checksectors_r(low); else checksectors_d(low); -} - - //--------------------------------------------------------------------------- // // @@ -1083,7 +998,7 @@ void operateactivators(int low, int snum) i = nextspritestat[i]; } - operaterespawns(low); + fi.operaterespawns(low); } //--------------------------------------------------------------------------- diff --git a/source/games/duke/src/sectors_d.cpp b/source/games/duke/src/sectors_d.cpp index 56f866496..6ce427a3f 100644 --- a/source/games/duke/src/sectors_d.cpp +++ b/source/games/duke/src/sectors_d.cpp @@ -347,7 +347,7 @@ bool checkhitswitch_d(int snum, int w, int switchtype) if (check_activator_motion(lotag)) return 0; break; default: - if (isadoorwall(picnum) == 0) return 0; + if (fi.isadoorwall(picnum) == 0) return 0; break; } @@ -497,7 +497,7 @@ bool checkhitswitch_d(int snum, int w, int switchtype) switch (picnum) { default: - if (isadoorwall(picnum) == 0) break; + if (fi.isadoorwall(picnum) == 0) break; case DIPSWITCH: case DIPSWITCH + 1: case TECHSWITCH: @@ -591,14 +591,14 @@ bool checkhitswitch_d(int snum, int w, int switchtype) } operateactivators(lotag, snum); - operateforcefields(ps[snum].i, lotag); + fi.operateforcefields(ps[snum].i, lotag); operatemasterswitches(lotag); if (picnum == DIPSWITCH || picnum == DIPSWITCH + 1 || picnum == ALIENSWITCH || picnum == ALIENSWITCH + 1 || picnum == TECHSWITCH || picnum == TECHSWITCH + 1) return 1; - if (hitag == 0 && isadoorwall(picnum) == 0) + if (hitag == 0 && fi.isadoorwall(picnum) == 0) { if (switchtype == SWITCH_SPRITE) S_PlaySound3D(SWITCH_ON, w, &v); @@ -830,7 +830,7 @@ void checkhitwall_d(int spr, int dawallnum, int x, int y, int z, int atwith) case ATM: wal->picnum = ATMBROKE; - lotsofmoney(&sprite[spr], 1 + (krand() & 7)); + fi.lotsofmoney(&sprite[spr], 1 + (krand() & 7)); spritesound(GLASS_HEAVYBREAK, spr); break; @@ -936,7 +936,7 @@ void checkplayerhurt_d(struct player_struct* p, int j) p->posyv = -(sintable[(p->getang()) & 2047] << 8); spritesound(DUKE_LONGTERM_PAIN, p->i); - checkhitwall(p->i, j, + fi.checkhitwall(p->i, j, p->posx + (sintable[(p->getang() + 512) & 2047] >> 9), p->posy + (sintable[p->getang() & 2047] >> 9), p->posz, -1); @@ -945,7 +945,7 @@ void checkplayerhurt_d(struct player_struct* p, int j) case BIGFORCE: p->hurt_delay = 26; - checkhitwall(p->i, j, + fi.checkhitwall(p->i, j, p->posx + (sintable[(p->getang() + 512) & 2047] >> 9), p->posy + (sintable[p->getang() & 2047] >> 9), p->posz, -1); @@ -1193,7 +1193,7 @@ void checkhitsprite_d(int i, int sn) case STATUEFLASH: case STATUE: if (sprite[i].picnum == BOTTLE10) - lotsofmoney(&sprite[i], 4 + (krand() & 3)); + fi.lotsofmoney(&sprite[i], 4 + (krand() & 3)); else if (sprite[i].picnum == STATUE || sprite[i].picnum == STATUEFLASH) { lotsofcolourglass(i, -1, 40); @@ -1344,12 +1344,12 @@ void checkhitsprite_d(int i, int sn) shoot(i, BLOODSPLAT3); sprite[i].ang = krand() & 2047; shoot(i, BLOODSPLAT4); - guts(&sprite[i], JIBS1, 1, myconnectindex); - guts(&sprite[i], JIBS2, 2, myconnectindex); - guts(&sprite[i], JIBS3, 3, myconnectindex); - guts(&sprite[i], JIBS4, 4, myconnectindex); - guts(&sprite[i], JIBS5, 1, myconnectindex); - guts(&sprite[i], JIBS3, 6, myconnectindex); + fi.guts(&sprite[i], JIBS1, 1, myconnectindex); + fi.guts(&sprite[i], JIBS2, 2, myconnectindex); + fi.guts(&sprite[i], JIBS3, 3, myconnectindex); + fi.guts(&sprite[i], JIBS4, 4, myconnectindex); + fi.guts(&sprite[i], JIBS5, 1, myconnectindex); + fi.guts(&sprite[i], JIBS3, 6, myconnectindex); sound(SQUISHED); deletesprite(i); break; @@ -1537,7 +1537,7 @@ void checksectors_d(int snum) if (p->gm & MODE_TYPE || sprite[p->i].extra <= 0) return; if (ud.cashman && PlayerInput(snum, SK_OPEN)) - lotsofmoney(&sprite[p->i], 2); + fi.lotsofmoney(&sprite[p->i], 2); if (p->newowner >= 0) { @@ -1637,7 +1637,7 @@ void checksectors_d(int snum) if (neartagsprite >= 0) { - if (checkhitswitch(snum, neartagsprite, 1)) return; + if (fi.checkhitswitch(snum, neartagsprite, 1)) return; switch (sprite[neartagsprite].picnum) { @@ -1769,10 +1769,10 @@ void checksectors_d(int snum) if (neartagwall >= 0) { - if (wall[neartagwall].lotag > 0 && isadoorwall(wall[neartagwall].picnum)) + if (wall[neartagwall].lotag > 0 && fi.isadoorwall(wall[neartagwall].picnum)) { if (hitscanwall == neartagwall || hitscanwall == -1) - checkhitswitch(snum, neartagwall, 0); + fi.checkhitswitch(snum, neartagwall, 0); return; } else if (p->newowner >= 0) @@ -1805,7 +1805,7 @@ void checksectors_d(int snum) } operatesectors(sprite[p->i].sectnum, p->i); } - else checkhitswitch(snum, neartagwall, 0); + else fi.checkhitswitch(snum, neartagwall, 0); } } } diff --git a/source/games/duke/src/sectors_r.cpp b/source/games/duke/src/sectors_r.cpp index 3a0436b78..e0480c0f2 100644 --- a/source/games/duke/src/sectors_r.cpp +++ b/source/games/duke/src/sectors_r.cpp @@ -475,7 +475,7 @@ bool checkhitswitch_r(int snum, int w, int switchtype) if (check_activator_motion(lotag)) return 0; break; default: - if (isadoorwall(picnum) == 0) return 0; + if (fi.isadoorwall(picnum) == 0) return 0; break; } @@ -696,7 +696,7 @@ bool checkhitswitch_r(int snum, int w, int switchtype) switch (picnum) { default: - if (isadoorwall(picnum) == 0) break; + if (fi.isadoorwall(picnum) == 0) break; case DIPSWITCH: case DIPSWITCH + 1: case TECHSWITCH: @@ -872,14 +872,14 @@ bool checkhitswitch_r(int snum, int w, int switchtype) } operateactivators(lotag, snum); - operateforcefields(ps[snum].i, lotag); + fi.operateforcefields(ps[snum].i, lotag); operatemasterswitches(lotag); if (picnum == DIPSWITCH || picnum == DIPSWITCH + 1 || picnum == ALIENSWITCH || picnum == ALIENSWITCH + 1 || picnum == TECHSWITCH || picnum == TECHSWITCH + 1) return 1; - if (hitag == 0 && isadoorwall(picnum) == 0) + if (hitag == 0 && fi.isadoorwall(picnum) == 0) { if (switchtype == SWITCH_SPRITE) S_PlaySound3D(SWITCH_ON, w, &v); @@ -1209,7 +1209,7 @@ void checkhitwall_r(int spr, int dawallnum, int x, int y, int z, int atwith) case ATM: wal->picnum = ATMBROKE; - lotsofmoney(&sprite[spr], 1 + (krand() & 7)); + fi.lotsofmoney(&sprite[spr], 1 + (krand() & 7)); spritesound(GLASS_HEAVYBREAK, spr); break; @@ -1372,7 +1372,7 @@ void checkplayerhurt_r(struct player_struct* p, int j) { case BIGFORCE: p->hurt_delay = 26; - checkhitwall(p->i, j, + fi.checkhitwall(p->i, j, p->posx + (sintable[(p->getang() + 512) & 2047] >> 9), p->posy + (sintable[p->getang() & 2047] >> 9), p->posz, -1); @@ -1523,7 +1523,7 @@ void checkhitsprite_r(int i, int sn) case RRTILE7879: sprite[i].picnum++; spritesound(495, i); - hitradius(i, 10, 0, 0, 1, 1); + fi.hitradius(i, 10, 0, 0, 1, 1); break; case RRTILE7648: case RRTILE7694: @@ -1724,17 +1724,17 @@ void checkhitsprite_r(int i, int sn) case RRTILE7890: sprite[i].picnum = RRTILE5045; spritesound(495, i); - hitradius(i, 10, 0, 0, 1, 1); + fi.hitradius(i, 10, 0, 0, 1, 1); break; case RRTILE7886: sprite[i].picnum = RRTILE5046; spritesound(495, i); - hitradius(i, 10, 0, 0, 1, 1); + fi.hitradius(i, 10, 0, 0, 1, 1); break; case RRTILE7887: sprite[i].picnum = RRTILE5044; spritesound(GLASS_HEAVYBREAK, i); - hitradius(i, 10, 0, 0, 1, 1); + fi.hitradius(i, 10, 0, 0, 1, 1); break; case RRTILE7900: sprite[i].picnum = RRTILE5047; @@ -1858,7 +1858,7 @@ void checkhitsprite_r(int i, int sn) case RRTILE7533: sprite[i].picnum = RRTILE5035; spritesound(495, i); - hitradius(i, 10, 0, 0, 1, 1); + fi.hitradius(i, 10, 0, 0, 1, 1); break; case RRTILE8394: sprite[i].picnum = RRTILE5072; @@ -1872,7 +1872,7 @@ void checkhitsprite_r(int i, int sn) case RRTILE8679: sprite[i].picnum = RRTILE8680; spritesound(DUKE_SHUCKS, i); - hitradius(i, 10, 0, 0, 1, 1); + fi.hitradius(i, 10, 0, 0, 1, 1); if (sprite[i].lotag != 0) { short j; @@ -1889,7 +1889,7 @@ void checkhitsprite_r(int i, int sn) case RRTILE3584: sprite[i].picnum = RRTILE8681; spritesound(495, i); - hitradius(i, 250, 0, 0, 1, 1); + fi.hitradius(i, 250, 0, 0, 1, 1); break; case RRTILE8682: sprite[i].picnum = RRTILE8683; @@ -1933,7 +1933,7 @@ void checkhitsprite_r(int i, int sn) break; case RRTILE2455: spritesound(SQUISHED, i); - guts(&sprite[i], RRTILE2465, 3, myconnectindex); + fi.guts(&sprite[i], RRTILE2465, 3, myconnectindex); deletesprite(i); break; case RRTILE2451: @@ -1949,8 +1949,8 @@ void checkhitsprite_r(int i, int sn) { if (sprite[i].lotag == sprite[j].lotag) { - guts(&sprite[i], RRTILE2460, 12, myconnectindex); - guts(&sprite[i], RRTILE2465, 3, myconnectindex); + fi.guts(&sprite[i], RRTILE2460, 12, myconnectindex); + fi.guts(&sprite[i], RRTILE2465, 3, myconnectindex); sprite[j].xrepeat = 0; sprite[j].yrepeat = 0; sprite[i].xrepeat = 0; @@ -1961,8 +1961,8 @@ void checkhitsprite_r(int i, int sn) } else { - guts(&sprite[i], RRTILE2460, 12, myconnectindex); - guts(&sprite[i], RRTILE2465, 3, myconnectindex); + fi.guts(&sprite[i], RRTILE2460, 12, myconnectindex); + fi.guts(&sprite[i], RRTILE2465, 3, myconnectindex); sprite[i].xrepeat = 0; sprite[i].yrepeat = 0; } @@ -2189,7 +2189,7 @@ void checkhitsprite_r(int i, int sn) case STATUEFLASH: case STATUE: if (sprite[i].picnum == BOTTLE10) - lotsofmoney(&sprite[i], 4 + (krand() & 3)); + fi.lotsofmoney(&sprite[i], 4 + (krand() & 3)); else if (sprite[i].picnum == STATUE || sprite[i].picnum == STATUEFLASH) { lotsofcolourglass(i, -1, 40); @@ -2455,7 +2455,7 @@ void checksectors_r(int snum) if (p->gm & MODE_TYPE || sprite[p->i].extra <= 0) return; if (ud.cashman && PlayerInput(snum, SK_OPEN)) - lotsofmoney(&sprite[p->i], 2); + fi.lotsofmoney(&sprite[p->i], 2); if (!(PlayerInput(snum, SK_OPEN)) && !PlayerInput(snum, SK_ESCAPE)) @@ -2578,7 +2578,7 @@ void checksectors_r(int snum) if (neartagsprite >= 0) { - if (checkhitswitch(snum, neartagsprite, 1)) return; + if (fi.checkhitswitch(snum, neartagsprite, 1)) return; switch (sprite[neartagsprite].picnum) { @@ -2693,10 +2693,10 @@ void checksectors_r(int snum) if (neartagwall >= 0) { - if (wall[neartagwall].lotag > 0 && isadoorwall(wall[neartagwall].picnum)) + if (wall[neartagwall].lotag > 0 && fi.isadoorwall(wall[neartagwall].picnum)) { if (hitscanwall == neartagwall || hitscanwall == -1) - checkhitswitch(snum, neartagwall, 0); + fi.checkhitswitch(snum, neartagwall, 0); return; } } @@ -2743,7 +2743,7 @@ void checksectors_r(int snum) FTA(41, p); } } - else checkhitswitch(snum, neartagwall, 0); + else fi.checkhitswitch(snum, neartagwall, 0); } } } diff --git a/source/games/duke/src/zz_actors.cpp b/source/games/duke/src/zz_actors.cpp index 9ee71f856..e7616d1e1 100644 --- a/source/games/duke/src/zz_actors.cpp +++ b/source/games/duke/src/zz_actors.cpp @@ -50,20 +50,20 @@ void G_ClearCameraView(DukePlayer_t *ps) sprite[k].yvel = 0; } -void hitradius(short i, int r, int hp1, int hp2, int hp3, int hp4); +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) { - hitradius(spriteNum, blastRadius, dmg1, dmg2, dmg3, dmg4); + fi.hitradius(spriteNum, blastRadius, dmg1, dmg2, dmg3, dmg4); } -int movesprite(short spritenum, int xchange, int ychange, int zchange, unsigned int cliptype); +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) { - return movesprite(spriteNum, change->x, change->y, change->z, clipType); + return fi.movesprite(spriteNum, change->x, change->y, change->z, clipType); } int32_t block_deletesprite = 0; @@ -135,17 +135,14 @@ void A_SpawnMultiple(int spriteNum, int tileNum, int spawnCnt) } } -void guts(spritetype* s, short gtype, short n, short p); -void gutsdir(spritetype* s, short gtype, short n, short p); - void A_DoGuts(int spriteNum, int tileNum, int spawnCnt) { - guts(&sprite[spriteNum], tileNum, spawnCnt, 0); + fi.guts(&sprite[spriteNum], tileNum, spawnCnt, 0); } void A_DoGutsDir(int spriteNum, int tileNum, int spawnCnt) { - gutsdir(&sprite[spriteNum], tileNum, spawnCnt, 0); + fi.gutsdir(&sprite[spriteNum], tileNum, spawnCnt, 0); } static int32_t G_ToggleWallInterpolation(int32_t wallNum, int32_t setInterpolation) @@ -283,18 +280,16 @@ int G_WakeUp(spritetype *const pSprite, int const playerNum) // sleeping monsters, etc -// stupid name, but it's what the function does. -int ifhitsectors(int sectnum); static FORCE_INLINE int G_FindExplosionInSector(int const sectNum) { - return ifhitsectors(sectNum); + return fi.ifhitsectors(sectNum); } -int ifhitbyweapon(int s); +int fi.ifhitbyweapon(int s); int A_IncurDamage(int const spriteNum) { - return ifhitbyweapon(spriteNum); + return fi.ifhitbyweapon(spriteNum); } diff --git a/source/games/duke/src/zz_cheats.cpp b/source/games/duke/src/zz_cheats.cpp index f4d47885e..7272d1cab 100644 --- a/source/games/duke/src/zz_cheats.cpp +++ b/source/games/duke/src/zz_cheats.cpp @@ -664,7 +664,7 @@ void G_DoCheats(void) operatesectors(i, pPlayer->i); } } - operateforcefields(pPlayer->i, -1); + fi.operateforcefields(pPlayer->i, -1); P_DoQuote(QUOTE_CHEAT_UNLOCK, pPlayer); end_cheat(pPlayer); diff --git a/source/games/duke/src/zz_game.cpp b/source/games/duke/src/zz_game.cpp index 10e6354dd..7149a5e5f 100644 --- a/source/games/duke/src/zz_game.cpp +++ b/source/games/duke/src/zz_game.cpp @@ -3614,7 +3614,7 @@ rr_badguy: case 46: if (RR) break; ror_protectedsectors[pSprite->sectnum] = 1; - /* XXX: fall-through intended? */ + /* XXX: fi.fall-through intended? */ fallthrough__; #endif case SE_49_POINT_LIGHT: @@ -7529,7 +7529,7 @@ int G_DoMoveThings(void) { P_ProcessInput(i); if (!DEER) - checksectors(i); + fi.checksectors(i); } } @@ -7549,7 +7549,7 @@ int G_DoMoveThings(void) } else { - animatewalls(); + fi.animatewalls(); movecyclers(); } @@ -7659,7 +7659,7 @@ void lotsofpopcorn(int spriteNum, int wallNum, int glassCnt) } } -void A_SpawnGlass(int spriteNum, int glassCnt) +void spriteglass(int spriteNum, int glassCnt) { for (; glassCnt>0; glassCnt--) { diff --git a/source/games/duke/src/zz_gameexec.cpp b/source/games/duke/src/zz_gameexec.cpp index 796e8969f..10b00495f 100644 --- a/source/games/duke/src/zz_gameexec.cpp +++ b/source/games/duke/src/zz_gameexec.cpp @@ -471,9 +471,9 @@ static void VM_Fall(int const spriteNum, spritetype * const pSprite) } } - if (sector[pSprite->sectnum].lotag == ST_2_UNDERWATER || EDUKE32_PREDICT_FALSE(G_CheckForSpaceCeiling(pSprite->sectnum))) + if (sector[pSprite->sectnum].lotag == ST_2_UNDERWATER || EDUKE32_PREDICT_FALSE(fi.ceilingspace(pSprite->sectnum))) spriteGravity = g_spriteGravity/6; - else if (EDUKE32_PREDICT_FALSE(G_CheckForSpaceFloor(pSprite->sectnum))) + else if (EDUKE32_PREDICT_FALSE(fi.floorspace(pSprite->sectnum))) spriteGravity = 0; if (actor[spriteNum].cgg <= 0 || (sector[pSprite->sectnum].floorstat&2)) @@ -485,7 +485,7 @@ static void VM_Fall(int const spriteNum, spritetype * const pSprite) if (pSprite->z < actor[spriteNum].floorz-ZOFFSET) { - // Free fall. + // Free fi.fall. pSprite->zvel += spriteGravity; pSprite->z += pSprite->zvel; @@ -689,7 +689,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) { int16_t temphit; - if ((tw = A_CheckHitSprite(vm.spriteNum, &temphit)) == (1 << 30)) + if ((tw = hitasprite(vm.spriteNum, &temphit)) == (1 << 30)) { VM_CONDITIONAL(1); continue; @@ -714,7 +714,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) do \ { \ vm.pSprite->ang += x; \ - tw = A_CheckHitSprite(vm.spriteNum, &temphit); \ + tw = hitasprite(vm.spriteNum, &temphit); \ vm.pSprite->ang -= x; \ } while (0) @@ -1290,7 +1290,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) case concmd_lotsofglass: insptr++; - A_SpawnGlass(vm.spriteNum, *insptr++); + spriteglass(vm.spriteNum, *insptr++); continue; case concmd_killit: @@ -1480,9 +1480,9 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) insptr++; { - pPlayer->eat_amt += *insptr; - if (pPlayer->eat_amt > 100) - pPlayer->eat_amt = 100; + pPlayer->eat += *insptr; + if (pPlayer->eat > 100) + pPlayer->eat = 100; pPlayer->drink_amt -= *insptr; if (pPlayer->drink_amt < 0) @@ -1645,7 +1645,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) debrisTile + tileOffset, vm.pSprite->shade, 32 + (r5 & 15), 32 + (r4 & 15), r3 & 2047, (r2 & 127) + 32, -(r1 & 2047), vm.spriteNum, 5); - sprite[spriteNum].yvel = ((RR || vm.pSprite->picnum == TILE_BLIMP) && debrisTile == TILE_SCRAP1) ? g_blimpSpawnItems[cnt % 14] : -1; + sprite[spriteNum].yvel = ((RR || vm.pSprite->picnum == TILE_BLIMP) && debrisTile == TILE_SCRAP1) ? weaponsandammosprites[cnt % 14] : -1; sprite[spriteNum].pal = vm.pSprite->pal; } insptr++; @@ -1885,7 +1885,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) } continue; - case concmd_ifinspace: VM_CONDITIONAL(G_CheckForSpaceCeiling(vm.pSprite->sectnum)); continue; + case concmd_ifinspace: VM_CONDITIONAL(fi.ceilingspace(vm.pSprite->sectnum)); continue; case concmd_spritepal: insptr++; @@ -2045,7 +2045,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) P_DoQuote(*(insptr++) | MAXQUOTES, pPlayer); continue; - case concmd_ifinouterspace: VM_CONDITIONAL(G_CheckForSpaceFloor(vm.pSprite->sectnum)); continue; + case concmd_ifinouterspace: VM_CONDITIONAL(fi.floorspace(vm.pSprite->sectnum)); continue; case concmd_ifnotmoving: VM_CONDITIONAL((vm.pActor->movflag & 49152) > 16384); continue; @@ -2069,11 +2069,11 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) case NAKED1__STATIC: case STATUE__STATIC: if (vm.pSprite->yvel) - operaterespawns(vm.pSprite->yvel); + fi.operaterespawns(vm.pSprite->yvel); break; default: if (vm.pSprite->hitag >= 0) - operaterespawns(vm.pSprite->hitag); + fi.operaterespawns(vm.pSprite->hitag); break; } continue; diff --git a/source/games/duke/src/zz_global.cpp b/source/games/duke/src/zz_global.cpp index 1bd6b2556..57bf2473d 100644 --- a/source/games/duke/src/zz_global.cpp +++ b/source/games/duke/src/zz_global.cpp @@ -99,7 +99,7 @@ int32_t g_spriteGravity = 176; int32_t g_timerTicsPerSecond = TICRATE; int32_t g_tripbombRadius = 3880; -int16_t g_blimpSpawnItems[15] = +int16_t weaponsandammosprites[15] = { RPGSPRITE__STATIC, CHAINGUNSPRITE__STATIC, diff --git a/source/games/duke/src/zz_namesdyn.cpp b/source/games/duke/src/zz_namesdyn.cpp index 48539de49..bb63d56eb 100644 --- a/source/games/duke/src/zz_namesdyn.cpp +++ b/source/games/duke/src/zz_namesdyn.cpp @@ -2930,21 +2930,21 @@ void G_InitDynamicTiles(void) DynamicTileMap[0] = 0; - g_blimpSpawnItems[0] = TILE_RPGSPRITE; - g_blimpSpawnItems[1] = TILE_CHAINGUNSPRITE; - g_blimpSpawnItems[2] = TILE_DEVISTATORAMMO; - g_blimpSpawnItems[3] = TILE_RPGAMMO; - g_blimpSpawnItems[4] = TILE_RPGAMMO; - g_blimpSpawnItems[5] = TILE_JETPACK; - g_blimpSpawnItems[6] = TILE_SHIELD; - g_blimpSpawnItems[7] = TILE_FIRSTAID; - g_blimpSpawnItems[8] = TILE_STEROIDS; - g_blimpSpawnItems[9] = TILE_RPGAMMO; - g_blimpSpawnItems[10] = TILE_RPGAMMO; - g_blimpSpawnItems[11] = TILE_RPGSPRITE; - g_blimpSpawnItems[12] = TILE_RPGAMMO; - g_blimpSpawnItems[13] = TILE_FREEZESPRITE; - g_blimpSpawnItems[14] = TILE_FREEZEAMMO; + weaponsandammosprites[0] = TILE_RPGSPRITE; + weaponsandammosprites[1] = TILE_CHAINGUNSPRITE; + weaponsandammosprites[2] = TILE_DEVISTATORAMMO; + weaponsandammosprites[3] = TILE_RPGAMMO; + weaponsandammosprites[4] = TILE_RPGAMMO; + weaponsandammosprites[5] = TILE_JETPACK; + weaponsandammosprites[6] = TILE_SHIELD; + weaponsandammosprites[7] = TILE_FIRSTAID; + weaponsandammosprites[8] = TILE_STEROIDS; + weaponsandammosprites[9] = TILE_RPGAMMO; + weaponsandammosprites[10] = TILE_RPGAMMO; + weaponsandammosprites[11] = TILE_RPGSPRITE; + weaponsandammosprites[12] = TILE_RPGAMMO; + weaponsandammosprites[13] = TILE_FREEZESPRITE; + weaponsandammosprites[14] = TILE_FREEZEAMMO; if (RR) { diff --git a/source/games/duke/src/zz_player.cpp b/source/games/duke/src/zz_player.cpp index 81a35118d..9b66154a1 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 guts = 0; + int fi.guts = 0; if (pPlayer->drink_amt > 31 && pPlayer->drink_amt < 65) - guts++; - if (pPlayer->eat_amt > 31 && pPlayer->eat_amt < 65) - guts++; + fi.guts++; + if (pPlayer->eat > 31 && pPlayer->eat < 65) + fi.guts++; - switch (guts) + switch (fi.guts) { case 1: playerDamage = (int)(playerDamage*0.75); @@ -670,9 +670,9 @@ growspark_rr: if (hitData.sprite >= 0 && sprite[hitData.sprite].picnum != TILE_ACCESSSWITCH && sprite[hitData.sprite].picnum != TILE_ACCESSSWITCH2) { - checkhitsprite(hitData.sprite, kneeSprite); + fi.checkhitsprite(hitData.sprite, kneeSprite); if (playerNum >= 0) - checkhitswitch(playerNum, hitData.sprite, 1); + fi.checkhitswitch(playerNum, hitData.sprite, 1); } else if (hitData.wall >= 0) { @@ -680,9 +680,9 @@ growspark_rr: if (hitData.wall >= 0 && wall[hitData.wall].picnum != TILE_ACCESSSWITCH && wall[hitData.wall].picnum != TILE_ACCESSSWITCH2) { - A_DamageWall(kneeSprite, hitData.wall, &hitData.pos, projecTile); + fi.checkhitwall(kneeSprite, hitData.wall, &hitData.pos, projecTile); if (playerNum >= 0) - checkhitswitch(playerNum, hitData.wall, 0); + fi.checkhitswitch(playerNum, hitData.wall, 0); } } } @@ -741,7 +741,7 @@ growspark_rr: return -1; } else - checkhitceiling(hitData.sect); + fi.checkhitceiling(hitData.sect); } if (!RR || sector[hitData.sect].lotag != ST_1_ABOVE_WATER) @@ -752,7 +752,7 @@ growspark_rr: { if (RR && sprite[hitData.sprite].picnum == TILE_TORNADO) return -1; - checkhitsprite(hitData.sprite, spawnedSprite); + fi.checkhitsprite(hitData.sprite, spawnedSprite); if (sprite[hitData.sprite].picnum == TILE_APLAYER && (ud.ffire == 1 || (!GTFLAGS(GAMETYPE_PLAYERSFRIENDLY) && GTFLAGS(GAMETYPE_TDM) && @@ -773,7 +773,7 @@ growspark_rr: if (playerNum >= 0 && CheckShootSwitchTile(sprite[hitData.sprite].picnum)) { - checkhitswitch(playerNum, hitData.sprite, 1); + fi.checkhitswitch(playerNum, hitData.sprite, 1); return -1; } } @@ -783,7 +783,7 @@ growspark_rr: A_Spawn(spawnedSprite, TILE_SMALLSMOKE); - if (isadoorwall(hitWall->picnum) == 1) + if (fi.isadoorwall(hitWall->picnum) == 1) goto SKIPBULLETHOLE; if (RR && isablockdoor(hitWall->picnum) == 1) @@ -791,7 +791,7 @@ growspark_rr: if (playerNum >= 0 && CheckShootSwitchTile(hitWall->picnum)) { - checkhitswitch(playerNum, hitData.wall, 0); + fi.checkhitswitch(playerNum, hitData.wall, 0); return -1; } @@ -823,7 +823,7 @@ growspark_rr: SKIPBULLETHOLE: HandleHitWall(&hitData); - A_DamageWall(spawnedSprite, hitData.wall, &hitData.pos, TILE_SHOTSPARK1); + fi.checkhitwall(spawnedSprite, hitData.wall, &hitData.pos, TILE_SHOTSPARK1); } } else @@ -833,7 +833,7 @@ growspark_rr: if (hitData.sprite >= 0) { - checkhitsprite(hitData.sprite, spawnedSprite); + fi.checkhitsprite(hitData.sprite, spawnedSprite); if (sprite[hitData.sprite].picnum != TILE_APLAYER) A_Spawn(spawnedSprite, TILE_SMALLSMOKE); else @@ -843,7 +843,7 @@ growspark_rr: } } else if (hitData.wall >= 0) - A_DamageWall(spawnedSprite, hitData.wall, &hitData.pos, TILE_SHOTSPARK1); + fi.checkhitwall(spawnedSprite, hitData.wall, &hitData.pos, TILE_SHOTSPARK1); } if ((krand2() & 255) < (RR ? 10 : 4)) @@ -943,12 +943,12 @@ growspark_rr: if (hitData.wall == -1 && hitData.sprite == -1 && hitData.sect >= 0 && Zvel < 0 && (sector[hitData.sprite].ceilingstat & 1) == 0) { - checkhitceiling(hitData.sect); + fi.checkhitceiling(hitData.sect); } else if (hitData.sprite >= 0) - checkhitsprite(hitData.sprite, otherSprite); + fi.checkhitsprite(hitData.sprite, otherSprite); else if (hitData.wall >= 0 && wall[hitData.wall].picnum != TILE_ACCESSSWITCH && wall[hitData.wall].picnum != TILE_ACCESSSWITCH2) - A_DamageWall(otherSprite, hitData.wall, &hitData.pos, projecTile); + fi.checkhitwall(otherSprite, hitData.wall, &hitData.pos, projecTile); } break; @@ -4250,8 +4250,8 @@ static int32_t P_DoCounters(int playerNum) if (--pPlayer->eat_timer <= 0) { pPlayer->eat_timer = 1024; - if (pPlayer->eat_amt) - pPlayer->eat_amt--; + if (pPlayer->eat) + pPlayer->eat--; } if (pPlayer->drink_amt == 100) @@ -4259,14 +4259,14 @@ static int32_t P_DoCounters(int playerNum) if (!A_CheckSoundPlaying(pPlayer->i, 420)) A_PlaySound(420, pPlayer->i); pPlayer->drink_amt -= 9; - pPlayer->eat_amt >>= 1; + pPlayer->eat >>= 1; } - pPlayer->eat_ang = (1647 + pPlayer->eat_amt * 8) & 2047; + pPlayer->eat_ang = (1647 + pPlayer->eat * 8) & 2047; - if (pPlayer->eat_amt >= 100) - pPlayer->eat_amt = 100; + if (pPlayer->eat >= 100) + pPlayer->eat = 100; - if (pPlayer->eat_amt >= 31 && krand2() < pPlayer->eat_amt) + if (pPlayer->eat >= 31 && krand2() < pPlayer->eat) { switch (krand2()&3) { @@ -4289,9 +4289,9 @@ static int32_t P_DoCounters(int playerNum) P_MadeNoise(playerNum); P_Thrust(pPlayer, 4); } - pPlayer->eat_amt -= 4; - if (pPlayer->eat_amt < 0) - pPlayer->eat_amt = 0; + pPlayer->eat -= 4; + if (pPlayer->eat < 0) + pPlayer->eat = 0; } } @@ -4375,7 +4375,7 @@ static int32_t P_DoCounters(int playerNum) P_SelectNextInvItem(pPlayer); if (RR) { - pPlayer->eat_amt = pPlayer->drink_amt = 0; + pPlayer->eat = pPlayer->drink_amt = 0; pPlayer->eat_ang = pPlayer->drink_ang = 1647; } } @@ -4442,7 +4442,7 @@ static int32_t P_DoCounters(int playerNum) { if (pPlayer->access_spritenum >= 0) { - checkhitswitch(playerNum, pPlayer->access_spritenum, 1); + fi.checkhitswitch(playerNum, pPlayer->access_spritenum, 1); switch (sprite[pPlayer->access_spritenum].pal) { case 0: RR ? pPlayer->keys[1] = 1 : pPlayer->got_access &= (0xffff - 0x1); break; @@ -4453,7 +4453,7 @@ static int32_t P_DoCounters(int playerNum) } else { - checkhitswitch(playerNum,pPlayer->access_wallnum,0); + fi.checkhitswitch(playerNum,pPlayer->access_wallnum,0); switch (wall[pPlayer->access_wallnum].pal) { case 0: RR ? pPlayer->keys[1] = 1 : pPlayer->got_access &= (0xffff - 0x1); break; @@ -4684,13 +4684,12 @@ void P_AddAmmo(DukePlayer_t * const pPlayer, int const weaponNum, int const addA pPlayer->ammo_amount[weaponNum] = max_ammo_amount[weaponNum]; } -void addweapon(player_struct* p, int w); void checkavailinven(struct player_struct* p); void checkavailweapon(struct player_struct* p); void P_AddWeapon(DukePlayer_t *pPlayer, int weaponNum) { - addweapon(pPlayer, weaponNum); + fi.addweapon(pPlayer, weaponNum); } void P_SelectNextInvItem(DukePlayer_t *pPlayer) @@ -4708,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 }; - A_DamageWall(pPlayer->i, wallNum, &davect, -1); + fi.checkhitwall(pPlayer->i, wallNum, &davect, -1); } static void P_CheckTouchDamage(DukePlayer_t *pPlayer, int touchObject) @@ -7471,7 +7470,7 @@ check_enemy_sprite: { A_PlaySound(436, pPlayer->i); pPlayer->last_pissed_time = 4000; - pPlayer->eat_amt = 0; + pPlayer->eat = 0; } } } @@ -8486,7 +8485,7 @@ HORIZONLY:; { if (!(sector[pSprite->sectnum].lotag & 0x8000u) && (isanunderoperator(sector[pSprite->sectnum].lotag) || isanearoperator(sector[pSprite->sectnum].lotag))) - activatebysector(pSprite->sectnum, pPlayer->i); + fi.activatebysector(pSprite->sectnum, pPlayer->i); if (squishPlayer) { @@ -8495,7 +8494,7 @@ HORIZONLY:; } } else if (klabs(floorZ - ceilZ) < ZOFFSET5 && isanunderoperator(sector[pPlayer->cursectnum].lotag)) - activatebysector(pPlayer->cursectnum, pPlayer->i); + fi.activatebysector(pPlayer->cursectnum, pPlayer->i); if (RR && sector[pPlayer->cursectnum].ceilingz > (sector[pPlayer->cursectnum].floorz-ZOFFSET4)) { @@ -8620,7 +8619,7 @@ HORIZONLY:; case NAKED1__STATIC: case STATUE__STATIC: if (sprite[pPlayer->actorsqu].yvel) - operaterespawns(sprite[pPlayer->actorsqu].yvel); + fi.operaterespawns(sprite[pPlayer->actorsqu].yvel); A_DeleteSprite(pPlayer->actorsqu); break; case APLAYER__STATIC: diff --git a/source/games/duke/src/zz_premap.cpp b/source/games/duke/src/zz_premap.cpp index 48ab21550..a521c61d7 100644 --- a/source/games/duke/src/zz_premap.cpp +++ b/source/games/duke/src/zz_premap.cpp @@ -964,7 +964,7 @@ void P_ResetStatus(int playerNum) g_wupass = 0; pPlayer->drink_ang = pPlayer->eat_ang = 1647; - pPlayer->drink_amt = pPlayer->eat_amt = 0; + pPlayer->drink_amt = pPlayer->eat = 0; pPlayer->drink_timer = pPlayer->eat_timer = 4096; pPlayer->shotgun_state[0] = pPlayer->shotgun_state[1] = 0; pPlayer->hbomb_time = 0; @@ -1092,7 +1092,7 @@ void P_ResetInventory(int playerNum) } pPlayer->drink_ang = pPlayer->eat_ang = 1647; - pPlayer->drink_amt = pPlayer->eat_amt = 0; + pPlayer->drink_amt = pPlayer->eat = 0; pPlayer->drink_timer = pPlayer->eat_timer = 4096; pPlayer->shotgun_state[0] = pPlayer->shotgun_state[1] = 0; pPlayer->hbomb_time = 0; @@ -1211,7 +1211,7 @@ static void resetprestat(int playerNum, int gameMode) } pPlayer->drink_ang = pPlayer->eat_ang = 1647; - pPlayer->drink_amt = pPlayer->eat_amt = 0; + pPlayer->drink_amt = pPlayer->eat = 0; pPlayer->drink_timer = pPlayer->eat_timer = 4096; pPlayer->shotgun_state[0] = pPlayer->shotgun_state[1] = 0; pPlayer->hbomb_time = 0; diff --git a/source/games/duke/src/zz_sbar.cpp b/source/games/duke/src/zz_sbar.cpp index 29e03e8ca..98f00f6fc 100644 --- a/source/games/duke/src/zz_sbar.cpp +++ b/source/games/duke/src/zz_sbar.cpp @@ -482,7 +482,7 @@ public: // eat // DrawGraphic(tileGetTexture(TILE_JETPACK), 122, -2, DI_ITEM_LEFT_BOTTOM, 1, 0, 0, 20000. / 65536., 20000. / 65536.); - format.Format("%d", p->eat_amt); + format.Format("%d", p->eat); SBar_DrawString(this, &numberFont, format, 175, -BigFont->GetHeight() * scale - 0.5, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); // @@ -890,15 +890,15 @@ public: DrawGraphic(tileGetTexture(TILE_GUTMETER_LIGHT4), 265, top + 24, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale); } - if (p->eat_amt >= 0 && p->eat_amt <= 30) + if (p->eat >= 0 && p->eat <= 30) { DrawGraphic(tileGetTexture(TILE_GUTMETER_LIGHT1), 276, top + 24, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale); } - else if (p->eat_amt >= 31 && p->eat_amt <= 65) + else if (p->eat >= 31 && p->eat <= 65) { DrawGraphic(tileGetTexture(TILE_GUTMETER_LIGHT2), 285, top + 24, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale); } - else if (p->eat_amt >= 66 && p->eat_amt <= 87) + else if (p->eat >= 66 && p->eat <= 87) { DrawGraphic(tileGetTexture(TILE_GUTMETER_LIGHT3), 294, top + 24, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale); } diff --git a/source/games/duke/src/zz_sector.cpp b/source/games/duke/src/zz_sector.cpp index 245a74058..f9a619bce 100644 --- a/source/games/duke/src/zz_sector.cpp +++ b/source/games/duke/src/zz_sector.cpp @@ -753,11 +753,11 @@ rrtripbomb_case: pPlayer->drink_amt = 0; } - if (pPlayer->eat_amt < 100) + if (pPlayer->eat < 100) { - pPlayer->eat_amt += 5; - if (pPlayer->eat_amt > 100) - pPlayer->eat_amt = 100; + pPlayer->eat += 5; + if (pPlayer->eat > 100) + pPlayer->eat = 100; } sprite[pPlayer->i].extra += 5; @@ -806,7 +806,7 @@ rrtripbomb_case: } } -int A_CheckHitSprite(int spriteNum, int16_t *hitSprite) +int hitasprite(int spriteNum, int16_t *hitSprite) { hitdata_t hitData; int32_t zOffset = 0;