- ported RR's noise.c.

This commit is contained in:
Christoph Oelckers 2020-06-30 17:30:48 +02:00
parent fc11447e59
commit 51ac1019d2
11 changed files with 83 additions and 91 deletions

View file

@ -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

View file

@ -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

View file

@ -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);
}
//---------------------------------------------------------------------------
//
//

View file

@ -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

View file

@ -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

View file

@ -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.

View file

@ -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

View file

@ -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"

View file

@ -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

View file

@ -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);
}
}

View file

@ -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;