diff --git a/source/games/duke/CMakeLists.txt b/source/games/duke/CMakeLists.txt index a25c2f7fa..f09c2bef0 100644 --- a/source/games/duke/CMakeLists.txt +++ b/source/games/duke/CMakeLists.txt @@ -20,6 +20,7 @@ set( PCH_SOURCES src/hudweapon_r.cpp src/input.cpp src/interpolate.cpp + src/noise.cpp src/player.cpp src/player_d.cpp src/player_r.cpp @@ -34,7 +35,6 @@ set( PCH_SOURCES src/spawn.cpp src/spawn_d.cpp src/spawn_r.cpp - src/zz_actors.cpp src/zz_cheats.cpp src/zz_common.cpp src/zz_d_menu.cpp diff --git a/source/games/duke/src/actor.h b/source/games/duke/src/actor.h index e077e0535..9e5298d43 100644 --- a/source/games/duke/src/actor.h +++ b/source/games/duke/src/actor.h @@ -75,6 +75,7 @@ int dodge(spritetype*); void alterang(int a, int g_i, int g_p); void fall_common(int g_i, int g_p, int JIBS6, int DRONE, int BLOODPOOL, int SHOTSPARK1, int squished, int thud, int(*fallspecial)(int, int), void (*falladjustz)(spritetype*)); void checkavailweapon(struct player_struct* p); +void deletesprite(int num); // tile names which are identical for all games. enum diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 1d9a85134..d72c25098 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -50,6 +50,20 @@ int otherp; int adjustfall(spritetype* s, int c); + +//--------------------------------------------------------------------------- +// +// wrapper to ensure that if a sound actor is killed, the sound is stopped as well. +// +//--------------------------------------------------------------------------- + +void deletesprite(int num) +{ + if (sprite[num].picnum == MUSICANDSFX && hittype[num].temp_data[0] == 1) + S_StopEnvSound(sprite[num].lotag, num); + ::deletesprite(num); +} + //--------------------------------------------------------------------------- // // diff --git a/source/games/duke/src/game.h b/source/games/duke/src/game.h index ecc36f7b9..2797697f6 100644 --- a/source/games/duke/src/game.h +++ b/source/games/duke/src/game.h @@ -103,12 +103,6 @@ enum { STATUSBAR_NOMODERN = 0x00000040, }; -void A_DeleteSprite(int spriteNum); - -//static inline int32_t G_GetLogoFlags(void) -//{ -// return 255; -//} # define CAMERA(Membname) (ud.camera ## Membname) # define CAMERADIST g_cameraDistance diff --git a/source/games/duke/src/noise.cpp b/source/games/duke/src/noise.cpp new file mode 100644 index 000000000..77fd03787 --- /dev/null +++ b/source/games/duke/src/noise.cpp @@ -0,0 +1,60 @@ +//------------------------------------------------------------------------- +/* +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 "duke3d.h" + +BEGIN_DUKE_NS + +int madenoise(int snum) +{ + player_struct *p; + p = &ps[snum]; + p->make_noise = 1; + p->noise_x = p->posx; + p->noise_y = p->posy; + return 1; +} + +int wakeup(int i, int snum) +{ + player_struct *p; + int radius; + p = &ps[snum]; + if (!p->make_noise) + return 0; + if (sprite[i].pal == 30 || sprite[i].pal == 32 || sprite[i].pal == 33 || (isRRRA() && sprite[i].pal == 8)) + return 0; + + radius = p->noise_radius; + + if (p->noise_x - radius < sprite[i].x && p->noise_x + radius > sprite[i].x + && p->noise_y - radius < sprite[i].y && p->noise_y + radius > sprite[i].y) + return 1; + return 0; +} + +END_DUKE_NS diff --git a/source/games/duke/src/player.h b/source/games/duke/src/player.h index e4b078be1..090e1877e 100644 --- a/source/games/duke/src/player.h +++ b/source/games/duke/src/player.h @@ -260,8 +260,8 @@ typedef struct player_struct { int32_t detonate_count; int16_t detonate_time; uint8_t shotgun_state[2]; - uint8_t make_noise; - int32_t noise_x, noise_y, noise_radius; + uint8_t make_noise; // at28e + int32_t noise_x, noise_y, noise_radius; // at286, at28a, at290 uint8_t keys[5]; int16_t yehaa_timer; int16_t drink_amt, eat, drunkang, eatang; @@ -422,7 +422,7 @@ inline void setpal(DukePlayer_t* pPlayer) void P_EndLevel(void); void P_CheckWeaponI(int playerNum); int P_GetOverheadPal(const DukePlayer_t *pPlayer); -void madenoise(int playerNum); +int madenoise(int playerNum); int haskey(int sect, int snum); // Get the player index given an TILE_APLAYER sprite pointer. diff --git a/source/games/duke/src/zz_actors.cpp b/source/games/duke/src/zz_actors.cpp deleted file mode 100644 index 8808d4a26..000000000 --- a/source/games/duke/src/zz_actors.cpp +++ /dev/null @@ -1,66 +0,0 @@ -//------------------------------------------------------------------------- -/* -Copyright (C) 2016 EDuke32 developers and contributors - -This file is part of EDuke32. - -EDuke32 is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License version 2 -as published by the Free Software Foundation. - -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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ -//------------------------------------------------------------------------- - -#include "ns.h" // Must come before everything else! - -#define actors_c_ - -#include "global.h" - -BEGIN_DUKE_NS - - -#define DELETE_SPRITE_AND_CONTINUE(KX) do { A_DeleteSprite(KX); goto next_sprite; } while (0) - -// deletesprite() game wrapper -void A_DeleteSprite(int spriteNum) -{ - // AMBIENT_SFX_PLAYING - if (sprite[spriteNum].picnum == MUSICANDSFX && actor[spriteNum].t_data[0] == 1) - S_StopEnvSound(sprite[spriteNum].lotag, spriteNum); - - deletesprite(spriteNum); -} - -void insertspriteq(int i); - -int g_canSeePlayer = 0; - -int G_WakeUp(spritetype *const pSprite, int const playerNum) -{ - DukePlayer_t *const pPlayer = g_player[playerNum].ps; - if (!pPlayer->make_noise) - return 0; - int const radius = pPlayer->noise_radius; - - if (pSprite->pal == 30 || pSprite->pal == 32 || pSprite->pal == 33 || (RRRA && pSprite->pal == 8)) - return 0; - - return (pPlayer->noise_x - radius < pSprite->x && pPlayer->noise_x + radius > pSprite->x - && pPlayer->noise_y - radius < pSprite->y && pPlayer->noise_y + radius > pSprite->y); -} - - -TileInfo tileinfo[MAXTILES]; - -END_DUKE_NS - diff --git a/source/games/duke/src/zz_actors.h b/source/games/duke/src/zz_actors.h index 19cd3c50a..a4117339b 100644 --- a/source/games/duke/src/zz_actors.h +++ b/source/games/duke/src/zz_actors.h @@ -245,7 +245,6 @@ extern int g_canSeePlayer; int LocateTheLocator(int const tag, int const sectNum); int A_IncurDamage(int spriteNum); -void A_DeleteSprite(int spriteNum); void clearcamera(player_struct* ps); void G_RefreshLights(void); @@ -300,11 +299,7 @@ inline int badguypic(int tile) { return A_CheckEnemyTile(tile); } -int G_WakeUp(spritetype* const pSprite, int const playerNum); -inline int wakeup(int sn, int pn) -{ - return G_WakeUp(&sprite[sn], pn); -} +int wakeup(int sn, int pn); #include "actor.h" diff --git a/source/games/duke/src/zz_global.cpp b/source/games/duke/src/zz_global.cpp index 08b0c286b..4c2935944 100644 --- a/source/games/duke/src/zz_global.cpp +++ b/source/games/duke/src/zz_global.cpp @@ -103,4 +103,6 @@ int16_t weaponsandammosprites[15]; char CheatKeys[2] = { sc_D, sc_N }; +TileInfo tileinfo[MAXTILES]; // This is not from EDuke32. + END_DUKE_NS diff --git a/source/games/duke/src/zz_osdcmds.cpp b/source/games/duke/src/zz_osdcmds.cpp index d6d7211b5..2a9be4de0 100644 --- a/source/games/duke/src/zz_osdcmds.cpp +++ b/source/games/duke/src/zz_osdcmds.cpp @@ -267,7 +267,7 @@ static int osdcmd_spawn(CCmdFuncPtr parm) if (setsprite(idx, &vect) < 0) { Printf("spawn: Sprite can't be spawned into null space\n"); - A_DeleteSprite(idx); + deletesprite(idx); } } diff --git a/source/games/duke/src/zz_player.cpp b/source/games/duke/src/zz_player.cpp index 0a2bec84a..578325484 100644 --- a/source/games/duke/src/zz_player.cpp +++ b/source/games/duke/src/zz_player.cpp @@ -892,14 +892,6 @@ void P_GetInputBoat(int playerNum) localInput.fvel = clamp((input.fvel += pPlayer->MotoSpeed), -(MAXVELMOTO / 8), MAXVELMOTO); } -void madenoise(int playerNum) -{ - DukePlayer_t *const pPlayer = g_player[playerNum].ps; - pPlayer->make_noise = 1; - pPlayer->noise_x = pPlayer->pos.x; - pPlayer->noise_y = pPlayer->pos.y; -} - void P_AddAmmo(DukePlayer_t * const pPlayer, int const weaponNum, int const addAmount) { pPlayer->ammo_amount[weaponNum] += addAmount;