mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 08:52:00 +00:00
- started porting functions - using a simple one as the first case.
This commit is contained in:
parent
e72869c947
commit
bd6047a097
13 changed files with 141 additions and 57 deletions
|
@ -1,5 +1,6 @@
|
|||
|
||||
set( PCH_SOURCES
|
||||
src/actors.cpp
|
||||
src/actors_e.cpp
|
||||
src/anim.cpp
|
||||
src/cheats.cpp
|
||||
|
|
92
source/games/duke/src/actors.cpp
Normal file
92
source/games/duke/src/actors.cpp
Normal file
|
@ -0,0 +1,92 @@
|
|||
//-------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (C) 1996, 2003 - 3D Realms Entertainment
|
||||
Copyright (C) 2000, 2003 - Matt Saettler (EDuke Enhancements)
|
||||
Copyright (C) 2017-2019 - Nuke.YKT
|
||||
Copyright (C) 2020 - Christoph Oelckers
|
||||
|
||||
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.
|
||||
|
||||
This file is a combination of code from the following sources:
|
||||
- EDuke 2 by Matt Saettler
|
||||
- JFDuke by Jonathon Fowler (jf@jonof.id.au),
|
||||
- DukeGDX and RedneckGDX by Alexander Makarov-[M210] (m210-2007@mail.ru)
|
||||
- Redneck Rampage reconstructed source by Nuke.YKT
|
||||
|
||||
Note:
|
||||
Most of this code follows DukeGDX and RedneckGDX because for Java it had
|
||||
to undo all the macro hackery that make the Duke source extremely hard to read.
|
||||
The other code bases were mainly used to add missing feature support (e.g. WW2GI)
|
||||
and verify correctness.
|
||||
|
||||
*/
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
#include "ns.h"
|
||||
#include "global.h"
|
||||
|
||||
BEGIN_DUKE_NS
|
||||
|
||||
bool ifsquished(int i, int p)
|
||||
{
|
||||
if (g_gameType & GAMEFLAG_RRALL) return false; // this function is a no-op in RR's source.
|
||||
|
||||
bool squishme = false;
|
||||
if (sprite[i].picnum == APLAYER && ud.clipping)
|
||||
return false;
|
||||
|
||||
auto &sc = sector[sprite[i].sectnum];
|
||||
int floorceildist = sc.floorz - sc.ceilingz;
|
||||
|
||||
if (sc.lotag != ST_23_SWINGING_DOOR)
|
||||
{
|
||||
if (sprite[i].pal == 1)
|
||||
squishme = floorceildist < (32 << 8) && (sc.lotag & 32768) == 0;
|
||||
else
|
||||
squishme = floorceildist < (12 << 8);
|
||||
}
|
||||
|
||||
if (squishme)
|
||||
{
|
||||
FTA(QUOTE_SQUISHED, ps[p]);
|
||||
|
||||
if (badguy(&sprite[i]))
|
||||
sprite[i].xvel = 0;
|
||||
|
||||
if (sprite[i].pal == 1)
|
||||
{
|
||||
hittype[i].picnum = SHOTSPARK1;
|
||||
hittype[i].extra = 1;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
END_DUKE_NS
|
|
@ -249,6 +249,7 @@ enum pflags_t
|
|||
|
||||
extern tiledata_t g_tile[MAXTILES];
|
||||
extern actor_t actor[MAXSPRITES];
|
||||
extern actor_t* hittype;
|
||||
extern int32_t block_deletesprite;
|
||||
extern int32_t g_noEnemies;
|
||||
extern int32_t otherp;
|
||||
|
@ -337,6 +338,11 @@ EXTERN_INLINE int A_CheckEnemySprite(void const * const pSprite)
|
|||
return A_CheckEnemyTile(((uspritetype const *) pSprite)->picnum);
|
||||
}
|
||||
|
||||
inline int badguy(void const* const pSprite)
|
||||
{
|
||||
return A_CheckEnemySprite(pSprite);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
END_DUKE_NS
|
||||
|
|
|
@ -6851,7 +6851,7 @@ static void MaybeTrainKillPlayer(const spritetype *pSprite, int const setOPos)
|
|||
|
||||
updatesector(pPlayer->pos.x, pPlayer->pos.y, &playerSectnum);
|
||||
|
||||
if ((playerSectnum == -1 && !ud.noclip) || (pPlayer->cursectnum != pSprite->sectnum && playerSectnum == pSprite->sectnum))
|
||||
if ((playerSectnum == -1 && !ud.clipping) || (pPlayer->cursectnum != pSprite->sectnum && playerSectnum == pSprite->sectnum))
|
||||
{
|
||||
*(vec2_t *)pPlayer = *(vec2_t const *)pSprite;
|
||||
|
||||
|
@ -7244,7 +7244,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
|
|||
|
||||
if ((pSector->floorz-pSector->ceilingz) < (108<<8))
|
||||
{
|
||||
if (ud.noclip == 0 && pSprite->xvel >= 192)
|
||||
if (ud.clipping == 0 && pSprite->xvel >= 192)
|
||||
MaybeTrainKillPlayer(pSprite, 0);
|
||||
}
|
||||
|
||||
|
@ -7339,7 +7339,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
|
|||
|
||||
if ((pSector->floorz-pSector->ceilingz) < (108<<8))
|
||||
{
|
||||
if (ud.noclip == 0 && pSprite->xvel >= 192)
|
||||
if (ud.clipping == 0 && pSprite->xvel >= 192)
|
||||
MaybeTrainKillPlayer(pSprite, 1);
|
||||
|
||||
MaybeTrainKillEnemies(spriteNum, 72);
|
||||
|
@ -7406,7 +7406,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
|
|||
x = (pSprite->xvel*sintable[pSprite->ang&2047])>>14;
|
||||
|
||||
if ((pSector->floorz-pSector->ceilingz) < (108<<8))
|
||||
if (ud.noclip == 0)
|
||||
if (ud.clipping == 0)
|
||||
MaybeTrainKillPlayer(pSprite, 0);
|
||||
|
||||
for (int TRAVERSE_CONNECT(playerNum))
|
||||
|
@ -7463,7 +7463,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
|
|||
|
||||
if (pSector->floorz-pSector->ceilingz < (108<<8))
|
||||
{
|
||||
if (ud.noclip == 0)
|
||||
if (ud.clipping == 0)
|
||||
MaybeTrainKillPlayer(pSprite, 1);
|
||||
|
||||
MaybeTrainKillEnemies(spriteNum, 24);
|
||||
|
|
|
@ -472,8 +472,8 @@ void G_DoCheats(void)
|
|||
break;
|
||||
|
||||
case CHEAT_CLIP:
|
||||
ud.noclip = !ud.noclip;
|
||||
P_DoQuote(QUOTE_CHEAT_NOCLIP-!ud.noclip, pPlayer);
|
||||
ud.clipping = !ud.clipping;
|
||||
P_DoQuote(QUOTE_CHEAT_NOCLIP-!ud.clipping, pPlayer);
|
||||
end_cheat(pPlayer);
|
||||
return;
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ static int32_t G_OpenDemoRead(int32_t g_whichDemo) // 0 = mine
|
|||
|
||||
gFullMap = false;
|
||||
ud.god = ud.cashman = ud.eog = 0;
|
||||
ud.noclip = ud.scrollmode = ud.overhead_on = 0; //= ud.pause_on = 0;
|
||||
ud.clipping = ud.scrollmode = ud.overhead_on = 0; //= ud.pause_on = 0;
|
||||
|
||||
totalclock = ototalclock = lockclock = 0;
|
||||
|
||||
|
|
|
@ -6999,6 +6999,7 @@ static const char* actions[] = {
|
|||
"Toggle_Crouch", // This is the last one used by EDuke32.
|
||||
};
|
||||
|
||||
void InitFonts();
|
||||
|
||||
int GameInterface::app_main()
|
||||
{
|
||||
|
@ -7144,6 +7145,7 @@ int GameInterface::app_main()
|
|||
#endif
|
||||
|
||||
videoInit();
|
||||
InitFonts();
|
||||
videoSetPalette(0, g_player[myconnectindex].ps->palette, 0);
|
||||
|
||||
// check if the minifont will support lowercase letters (3136-3161)
|
||||
|
@ -7751,4 +7753,8 @@ void GameInterface::UpdateScreenSize()
|
|||
return new GameInterface;
|
||||
}
|
||||
|
||||
// access wrappers that alias old names to current data.
|
||||
psaccess ps;
|
||||
actor_t* hittype = actor;
|
||||
|
||||
END_DUKE_NS
|
||||
|
|
|
@ -167,7 +167,7 @@ typedef struct {
|
|||
|
||||
char overhead_on,last_overhead,showweapons;
|
||||
char god,warp_on,cashman,eog;
|
||||
char scrollmode,noclip;
|
||||
char scrollmode,clipping;
|
||||
char display_bonus_screen;
|
||||
char show_level_text;
|
||||
|
||||
|
@ -268,6 +268,10 @@ void G_PrintGameQuotes(int32_t snum);
|
|||
//void G_SE40(int32_t smoothratio);
|
||||
void G_UpdatePlayerFromMenu(void);
|
||||
void P_DoQuote(int32_t q,DukePlayer_t *p);
|
||||
inline void FTA(int q, DukePlayer_t* p)
|
||||
{
|
||||
P_DoQuote(q, p);
|
||||
}
|
||||
void P_SetGamePalette(DukePlayer_t* player, uint32_t palid, ESetPalFlags flags);
|
||||
void G_OnMotorcycle(DukePlayer_t *pPlayer, int spriteNum);
|
||||
void G_OffMotorcycle(DukePlayer_t *pPlayer);
|
||||
|
|
|
@ -127,7 +127,7 @@ typedef struct {
|
|||
int flags;
|
||||
|
||||
union {
|
||||
spritetype * pSprite;
|
||||
spritetype *pSprite;
|
||||
uspritetype *pUSprite;
|
||||
};
|
||||
|
||||
|
|
|
@ -213,46 +213,11 @@ int32_t VM_ExecuteEventWithValue(int const nEventID, int const spriteNum, int co
|
|||
return VM_EventInlineInternal__(nEventID, spriteNum, playerNum, -1, nReturn);
|
||||
}
|
||||
|
||||
bool ifsquished(int i, int p);
|
||||
|
||||
static int32_t VM_CheckSquished(void)
|
||||
{
|
||||
if (RR)
|
||||
return 0;
|
||||
|
||||
usectortype const * const pSector = (usectortype *)§or[vm.pSprite->sectnum];
|
||||
|
||||
if (pSector->lotag == ST_23_SWINGING_DOOR ||
|
||||
(vm.pSprite->picnum == APLAYER && ud.noclip))
|
||||
return 0;
|
||||
|
||||
int32_t floorZ = pSector->floorz;
|
||||
int32_t ceilZ = pSector->ceilingz;
|
||||
#ifdef YAX_ENABLE
|
||||
int16_t cb, fb;
|
||||
|
||||
yax_getbunches(vm.pSprite->sectnum, &cb, &fb);
|
||||
|
||||
if (cb >= 0 && (pSector->ceilingstat&512)==0) // if ceiling non-blocking...
|
||||
ceilZ -= ZOFFSET5; // unconditionally don't squish... yax_getneighborsect is slowish :/
|
||||
if (fb >= 0 && (pSector->floorstat&512)==0)
|
||||
floorZ += ZOFFSET5;
|
||||
#endif
|
||||
|
||||
if (vm.pSprite->pal == 1 ? (floorZ - ceilZ >= ZOFFSET5 || (pSector->lotag & 32768u)) : (floorZ - ceilZ >= ZOFFSET4))
|
||||
return 0;
|
||||
|
||||
P_DoQuote(QUOTE_SQUISHED, vm.pPlayer);
|
||||
|
||||
if (A_CheckEnemySprite(vm.pSprite))
|
||||
vm.pSprite->xvel = 0;
|
||||
|
||||
if (EDUKE32_PREDICT_FALSE(vm.pSprite->pal == 1)) // frozen
|
||||
{
|
||||
vm.pActor->picnum = SHOTSPARK1;
|
||||
vm.pActor->extra = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return ifsquished(vm.spriteNum, vm.playerNum);
|
||||
}
|
||||
|
||||
GAMEEXEC_STATIC GAMEEXEC_INLINE void P_ForceAngle(DukePlayer_t *pPlayer)
|
||||
|
|
|
@ -306,6 +306,16 @@ EXTERN_INLINE void G_RestoreInterpolations(void) //Stick at end of drawscreen
|
|||
|
||||
#endif
|
||||
|
||||
// Hack struct to allow old code to access the EDuke-style player data without changing it.
|
||||
struct psaccess
|
||||
{
|
||||
DukePlayer_t* operator[](int index)
|
||||
{
|
||||
return g_player[index].ps;
|
||||
}
|
||||
};
|
||||
extern psaccess ps;
|
||||
|
||||
END_DUKE_NS
|
||||
|
||||
#endif
|
||||
|
|
|
@ -668,7 +668,7 @@ void Net_DoPrediction(void)
|
|||
int stepHeight, centerHoriz;
|
||||
int16_t ceilingBunch, floorBunch;
|
||||
|
||||
if (ud.noclip == 0 && (mycursectnum < 0 || mycursectnum >= MAXSECTORS || sector[mycursectnum].floorpicnum == MIRROR))
|
||||
if (ud.clipping == 0 && (mycursectnum < 0 || mycursectnum >= MAXSECTORS || sector[mycursectnum].floorpicnum == MIRROR))
|
||||
{
|
||||
mypos.x = omypos.x;
|
||||
mypos.y = omypos.y;
|
||||
|
|
|
@ -7508,7 +7508,7 @@ void P_ProcessInput(int playerNum)
|
|||
|
||||
if (pPlayer->cursectnum == -1)
|
||||
{
|
||||
if (pSprite->extra > 0 && ud.noclip == 0)
|
||||
if (pSprite->extra > 0 && ud.clipping == 0)
|
||||
{
|
||||
P_QuickKill(pPlayer);
|
||||
A_PlaySound(SQUISHED, pPlayer->i);
|
||||
|
@ -7832,7 +7832,7 @@ check_enemy_sprite:
|
|||
if (pPlayer->on_ground)
|
||||
pPlayer->bobcounter += sprite[pPlayer->i].xvel>>1;
|
||||
|
||||
if (ud.noclip == 0 && ((uint16_t)pPlayer->cursectnum >= MAXSECTORS || sector[pPlayer->cursectnum].floorpicnum == MIRROR))
|
||||
if (ud.clipping == 0 && ((uint16_t)pPlayer->cursectnum >= MAXSECTORS || sector[pPlayer->cursectnum].floorpicnum == MIRROR))
|
||||
{
|
||||
pPlayer->pos.x = pPlayer->opos.x;
|
||||
pPlayer->pos.y = pPlayer->opos.y;
|
||||
|
@ -8358,7 +8358,7 @@ HORIZONLY:;
|
|||
stepHeight = pPlayer->autostep_sbw;
|
||||
#endif
|
||||
|
||||
if (ud.noclip)
|
||||
if (ud.clipping)
|
||||
{
|
||||
pPlayer->pos.x += pPlayer->vel.x >> 14;
|
||||
pPlayer->pos.y += pPlayer->vel.y >> 14;
|
||||
|
@ -8660,7 +8660,7 @@ HORIZONLY:;
|
|||
usectortype const *pSector = (usectortype *)§or[pPlayer->cursectnum];
|
||||
|
||||
// TRAIN_SECTOR_TO_SE_INDEX
|
||||
if ((!ud.noclip && pSector->lotag == ST_31_TWO_WAY_TRAIN) &&
|
||||
if ((!ud.clipping && pSector->lotag == ST_31_TWO_WAY_TRAIN) &&
|
||||
((unsigned)pSector->hitag < MAXSPRITES && sprite[pSector->hitag].xvel && actor[pSector->hitag].t_data[0] == 0))
|
||||
{
|
||||
P_QuickKill(pPlayer);
|
||||
|
@ -8676,7 +8676,7 @@ HORIZONLY:;
|
|||
if (pPlayer->cursectnum >= 0 && pPlayer->cursectnum != pSprite->sectnum)
|
||||
changespritesect(pPlayer->i, pPlayer->cursectnum);
|
||||
|
||||
if (pPlayer->cursectnum >= 0 && ud.noclip == 0)
|
||||
if (pPlayer->cursectnum >= 0 && ud.clipping == 0)
|
||||
{
|
||||
int const squishPlayer = (pushmove((vec3_t *)pPlayer, &pPlayer->cursectnum, (!RR || pSprite->clipdist == 64) ? 164 : 16, (4L << 8), (4L << 8), CLIPMASK0) < 0 &&
|
||||
A_GetFurthestAngle(pPlayer->i, 8) < 512);
|
||||
|
@ -9057,7 +9057,7 @@ void P_DHProcessInput(int playerNum)
|
|||
if (pPlayer->on_ground)
|
||||
pPlayer->bobcounter += sprite[pPlayer->i].xvel>>1;
|
||||
|
||||
if (ud.noclip == 0 && ((uint16_t)pPlayer->cursectnum >= MAXSECTORS || sector[pPlayer->cursectnum].floorpicnum == MIRROR))
|
||||
if (ud.clipping == 0 && ((uint16_t)pPlayer->cursectnum >= MAXSECTORS || sector[pPlayer->cursectnum].floorpicnum == MIRROR))
|
||||
{
|
||||
pPlayer->pos.x = pPlayer->opos.x;
|
||||
pPlayer->pos.y = pPlayer->opos.y;
|
||||
|
@ -9250,7 +9250,7 @@ void P_DHProcessInput(int playerNum)
|
|||
|
||||
int spriteNum;
|
||||
|
||||
if (ud.noclip)
|
||||
if (ud.clipping)
|
||||
{
|
||||
spriteNum = 0;
|
||||
pPlayer->pos.x += pPlayer->vel.x >> 14;
|
||||
|
@ -9347,7 +9347,7 @@ void P_DHProcessInput(int playerNum)
|
|||
if (pPlayer->cursectnum >= 0 && pPlayer->cursectnum != pSprite->sectnum)
|
||||
changespritesect(pPlayer->i, pPlayer->cursectnum);
|
||||
|
||||
if (pPlayer->cursectnum >= 0 && ud.noclip == 0)
|
||||
if (pPlayer->cursectnum >= 0 && ud.clipping == 0)
|
||||
{
|
||||
int const squishPlayer = (pushmove((vec3_t *)pPlayer, &pPlayer->cursectnum, (!RR || pSprite->clipdist == 64) ? 164 : 16, (4L << 8), (4L << 8), CLIPMASK0) < 0 &&
|
||||
A_GetFurthestAngle(pPlayer->i, 8) < 512);
|
||||
|
|
Loading…
Reference in a new issue