- Exhumed: some inlines for upcoming actor refactoring.

This commit is contained in:
Christoph Oelckers 2021-10-17 15:15:33 +02:00
parent 2a905e8026
commit 1b8d3f9a89
7 changed files with 98 additions and 16 deletions

View file

@ -180,6 +180,10 @@ void UseItem(short nPlayer, short nItem);
void UseCurItem(short nPlayer);
int GrabItem(short nPlayer, short nItem);
void DropMagic(short nSprite);
inline void DropMagic(DExhumedActor* actor)
{
DropMagic(actor->GetSpriteIndex());
}
void InitItems();
void StartRegenerate(short nSprite);
void DoRegenerates();
@ -236,9 +240,21 @@ void ResetMoveFifo();
void InitChunks();
void InitPushBlocks();
void Gravity(short nSprite);
inline void Gravity(DExhumedActor* actor)
{
Gravity(actor->GetSpriteIndex());
}
short UpdateEnemy(short *nEnemy);
int MoveCreature(short nSprite);
Collision MoveCreature(DExhumedActor* nSprite)
{
return Collision(MoveCreature(nSprite->GetSpriteIndex()));
}
int MoveCreatureWithCaution(int nSprite);
inline Collision MoveCreatureWithCaution(DExhumedActor* actor)
{
return Collision(MoveCreatureWithCaution(actor->GetSpriteIndex()));
}
void WheresMyMouth(int nPlayer, int *x, int *y, int *z, short *sectnum);
int GetSpriteHeight(int nSprite);
int GetActorHeight(DExhumedActor* nSprite);
@ -248,15 +264,29 @@ DExhumedActor* GrabBodyGunSprite();
void CreatePushBlock(int nSector);
void FuncCreatureChunk(int a, int, int nRun);
int FindPlayer(int nSprite, int nDistance);
inline DExhumedActor* FindPlayer(DExhumedActor* nSprite, int nDistance)
{
int targ = FindPlayer(nSprite->GetSpriteIndex(), nDistance);
return targ > -1 ? &exhumedActors[targ] : nullptr;
}
int BuildCreatureChunk(int nVal, int nPic);
void BuildNear(int x, int y, int walldist, int nSector);
int PlotCourseToSprite(int nSprite1, int nSprite2);
inline int PlotCourseToSprite(DExhumedActor* nSprite1, DExhumedActor* nSprite2)
{
return PlotCourseToSprite(nSprite1->GetSpriteIndex(), nSprite2->GetSpriteIndex());
}
void CheckSectorFloor(short nSector, int z, int *x, int *y);
int GetAngleToSprite(int nSprite1, int nSprite2);
int GetWallNormal(short nWall);
int GetUpAngle(short nSprite1, int nVal, short nSprite2, int ecx);
void MoveSector(short nSector, int nAngle, int *nXVel, int *nYVel);
int AngleChase(int nSprite, int nSprite2, int ebx, int ecx, int push1);
inline Collision AngleChase(DExhumedActor* nSprite, DExhumedActor* nSprite2, int ebx, int ecx, int push1)
{
return Collision(AngleChase(nSprite->GetSpriteIndex(), nSprite2->GetSpriteIndex(), ebx, ecx, push1));
}
void SetQuake(short nSprite, int nVal);
// mummy
@ -731,8 +761,20 @@ void runlist_DoSubRunRec(int RunPtr);
void runlist_SubRunRec(int RunPtr);
void runlist_ProcessWallTag(int nWall, short nLotag, short nHitag);
int runlist_CheckRadialDamage(short nSprite);
inline int runlist_CheckRadialDamage(DExhumedActor* actor)
{
return runlist_CheckRadialDamage(actor->GetSpriteIndex());
}
void runlist_RadialDamageEnemy(short nSprite, short nDamage, short nRadius);
inline void runlist_RadialDamageEnemy(DExhumedActor* nSprite, short nSprite2, short nDamage)
{
return runlist_RadialDamageEnemy(nSprite->GetSpriteIndex(), nSprite2, nDamage);
}
void runlist_DamageEnemy(int nSprite, int nSprite2, short nDamage);
inline void runlist_DamageEnemy(DExhumedActor* nSprite, DExhumedActor* nSprite2, short nDamage)
{
return runlist_DamageEnemy(nSprite? nSprite->GetSpriteIndex() : -1, nSprite2? nSprite2->GetSpriteIndex() : -1, nDamage);
}
void runlist_SignalRun(int NxtPtr, int edx);
void runlist_CleanRunRecs();

View file

@ -38,6 +38,11 @@ enum
int movesprite(short spritenum, int dx, int dy, int dz, int ceildist, int flordist, unsigned int clipmask);
inline Collision movesprite(DExhumedActor* spritenum, int dx, int dy, int dz, int ceildist, int flordist, unsigned int clipmask)
{
return Collision(movesprite(spritenum->GetSpriteIndex(), dx, dy, dz, ceildist, flordist, clipmask));
}
void precache();
void resettiming();

View file

@ -68,6 +68,7 @@ void EraseScreen(int eax);
void mychangespritesect(int nSprite, int nSector);
void mydeletesprite(int nSprite);
void DeleteActor(DExhumedActor* actor);
void GrabPalette();

View file

@ -6,16 +6,24 @@ void mydeletesprite(int nSprite);
class DExhumedActor;
enum
{
kHitAuxMask = 0x30000,
kHitAux1 = 0x10000,
kHitAux2 = 0x20000,
};
// Wrapper around the insane collision info mess from Build.
struct Collision
{
int type;
int index;
int exbits;
int legacyVal; // should be removed later, but needed for converting back for unadjusted code.
DExhumedActor* actor;
Collision() = default;
Collision(int legacyval) { setFromEngine(legacyval); }
explicit Collision(int legacyval) { setFromEngine(legacyval); }
// need forward declarations of these.
int actorIndex(DExhumedActor*);
@ -25,6 +33,7 @@ struct Collision
{
type = kHitNone;
index = -1;
exbits = 0;
legacyVal = 0;
actor = nullptr;
return kHitNone;
@ -34,6 +43,7 @@ struct Collision
{
type = kHitSector;
index = num;
exbits = 0;
legacyVal = type | index;
actor = nullptr;
return kHitSector;
@ -42,6 +52,7 @@ struct Collision
{
type = kHitWall;
index = num;
exbits = 0;
legacyVal = type | index;
actor = nullptr;
return kHitWall;
@ -50,6 +61,7 @@ struct Collision
{
type = kHitSprite;
index = -1;
exbits = 0;
legacyVal = type | actorIndex(num);
actor = num;
return kHitSprite;
@ -59,6 +71,7 @@ struct Collision
{
legacyVal = value;
type = value & kHitTypeMask;
exbits = value & kHitAuxMask;
if (type == 0) { index = -1; actor = nullptr; }
else if (type != kHitSprite) { index = value & kHitIndexMask; actor = nullptr; }
else { index = -1; actor = Actor(value & kHitIndexMask); }
@ -83,23 +96,21 @@ public:
spritetype& s() { return sprite[index]; }
int GetIndex() { return index; } // should only be for error reporting or for masking to a slot index
int GetSpriteIndex() { return index; } // this is only here to mark places that need changing later!
/*
void SetOwner(DExhumedActor* own)
{
s().owner = own ? own->GetSpriteIndex() : -1;
}
DExhumedActor* GetOwner()
{
if (s().owner == -1 || s().owner == MAXSPRITES - 1) return nullptr;
return base() + s().owner;
}
*/
};
extern DExhumedActor exhumedActors[MAXSPRITES];
inline DExhumedActor* Collision::Actor(int i)
{
return &exhumedActors[i];
}
inline int Collision::actorIndex(DExhumedActor* a)
{
return a->GetSpriteIndex();
}
inline DExhumedActor* DExhumedActor::base() { return exhumedActors; }
// Iterator wrappers that return an actor pointer, not an index.
@ -217,4 +228,9 @@ inline void setActorPos(DExhumedActor* actor, vec3_t* pos)
setsprite(actor->GetSpriteIndex(), pos);
}
inline DExhumedActor* GetActor(const hitdata_t& hitData)
{
return &exhumedActors[hitData.sprite];
}
END_BLD_NS

View file

@ -123,6 +123,10 @@ extern int nPlayerDY[kMaxPlayers];
extern int nPlayerDX[kMaxPlayers];
short GetPlayerFromSprite(short nSprite);
short GetPlayerFromActor(DExhumedActor* actor)
{
return GetPlayerFromSprite(actor->GetSpriteIndex());
}
void SetPlayerMummified(int nPlayer, int bIsMummified);
int AddAmmo(int nPlayer, int nWeapon, int nAmmoAmount);
void ShootStaff(int nPlayer);

View file

@ -134,6 +134,11 @@ extern short FrameBase[];
void seq_LoadSequences();
int seq_GetFrameSound(int val, int edx);
void seq_MoveSequence(short nSprite, short nSeq, short bx);
inline void seq_MoveSequence(DExhumedActor* actor, short nSeq, short bx)
{
seq_MoveSequence(actor->GetSpriteIndex(), nSeq, bx);
}
int seq_GetSeqPicnum2(short nSeq, short nFrame);
int seq_GetSeqPicnum(short nSeq, short edx, short ebx);
void seq_DrawStatusSequence(short nSequence, uint16_t edx, short ebx);

View file

@ -133,11 +133,20 @@ void CheckAmbience(short nSector);
void PlayFX2(unsigned short nSound, short nSprite, int sectf = 0, EChanFlags chanflags = CHANF_NONE, int sprflags = 0);
void PlayFXAtXYZ(unsigned short nSound, int x, int y, int z, int nSector, EChanFlags chanflags = CHANF_NONE, int sectf = 0);
inline void D3PlayFX(unsigned short nSound, short nVal, short flags = 0)
inline void D3PlayFX(unsigned short nSound, short nSprite, short flags = 0)
{
PlayFX2(nSound, nVal, 0, CHANF_NONE, flags);
PlayFX2(nSound, nSprite, 0, CHANF_NONE, flags);
}
inline void D3PlayFX(unsigned short nSound, DExhumedActor* actor, short flags = 0)
{
PlayFX2(nSound, actor->GetSpriteIndex(), 0, CHANF_NONE, flags);
}
void StopSpriteSound(short nSprite);
inline void StopActorSound(DExhumedActor* actor)
{
if (actor) StopSpriteSound(actor->GetSpriteIndex());
}
void StartSwirlies();
void UpdateSwirlies();