- Move the actor pointer for each game's player structures into CorePlayer.

* Something strange was going on here with Blood where the static_cast would not work... Moved the player structure into `bloodactor.h` for now to work around it.
This commit is contained in:
Mitchell Richters 2023-10-02 13:27:16 +11:00
parent 6beec5eed2
commit 1604cf009c
7 changed files with 117 additions and 115 deletions

View file

@ -7,4 +7,7 @@ struct CorePlayer
{
InputPacket input;
PlayerAngles Angles;
DCoreActor* actor;
virtual DCoreActor* GetActor() = 0;
};

View file

@ -147,6 +147,113 @@ public:
};
struct BloodPlayer final : public CorePlayer
{
DUDEINFO* pDudeInfo;
uint8_t newWeapon;
int weaponQav;
int qavCallback;
bool isRunning;
int posture; // stand, crouch, swim
int sceneQav; // by NoOne: used to keep qav id
double bobPhase;
int bobAmp;
double bobHeight;
double bobWidth;
double obobHeight;
double obobWidth;
int swayAmp;
double swayHeight;
double swayWidth;
double oswayHeight;
double oswayWidth;
int nPlayer; // Connect id
int lifeMode;
double zView;
double ozView;
double zViewVel;
double zWeapon;
double ozWeapon;
double zWeaponVel;
double slope;
bool isUnderwater;
bool hasKey[8];
int8_t hasFlag;
TObjPtr<DBloodActor*> ctfFlagState[2];
int damageControl[7];
int8_t curWeapon;
int8_t nextWeapon;
int weaponTimer;
int weaponState;
int weaponAmmo; //rename
bool hasWeapon[kWeapMax];
int weaponMode[kWeapMax];
int weaponOrder[2][kWeapMax];
//int at149[14];
int ammoCount[12];
bool qavLoop;
int qavLastTick;
int qavTimer;
int fuseTime;
int throwTime;
double throwPower;
DVector3 aim; // world
DVector3 relAim; // relative
TObjPtr<DBloodActor*> aimTarget; // aim target sprite
int aimTargetsCount;
TObjPtr<DBloodActor*> aimTargets[16];
int deathTime;
int pwUpTime[kMaxPowerUps];
int fragCount;
int fragInfo[8];
int teamId;
TObjPtr<DBloodActor*> fragger;
int underwaterTime;
int bubbleTime;
int restTime;
int kickPower;
int laughCount;
bool godMode;
bool fallScream;
bool cantJump;
int packItemTime; // pack timer
int packItemId; // pack id 1: diving suit, 2: crystal ball, 3: beast vision 4: jump boots
PACKINFO packSlots[5]; // at325 [1]: diving suit, [2]: crystal ball, [3]: beast vision [4]: jump boots
int armor[3]; // armor
//int at342;
//int at346;
TObjPtr<DBloodActor*> voodooTarget;
int voodooTargets; // --> useless
int voodooVar1; // --> useless
int vodooVar2; // --> useless
int flickerEffect;
int tiltEffect;
int visibility;
int painEffect;
int blindEffect;
int chokeEffect;
int handTime;
bool hand; // if true, there is hand start choking the player
int pickupEffect;
bool flashEffect; // if true, reduce pPlayer->visibility counter
int quakeEffect;
int player_par;
int nWaterPal;
POSTURE pPosture[kModeMax][kPostureMax];
inline DBloodActor* GetActor() override
{
return static_cast<DBloodActor*>(actor);
}
};
extern BloodPlayer PlayerArray[kMaxPlayers];
inline BloodPlayer* getPlayer(int index)
{
return &PlayerArray[index];
}
// subclassed to add a game specific actor() method
extern HitInfo gHitInfo;

View file

@ -78,106 +78,7 @@ struct POSTURE
extern POSTURE gPostureDefaults[kModeMax][kPostureMax];
struct BloodPlayer final : public CorePlayer
{
DBloodActor* actor;
DUDEINFO* pDudeInfo;
uint8_t newWeapon;
int weaponQav;
int qavCallback;
bool isRunning;
int posture; // stand, crouch, swim
int sceneQav; // by NoOne: used to keep qav id
double bobPhase;
int bobAmp;
double bobHeight;
double bobWidth;
double obobHeight;
double obobWidth;
int swayAmp;
double swayHeight;
double swayWidth;
double oswayHeight;
double oswayWidth;
int nPlayer; // Connect id
int lifeMode;
double zView;
double ozView;
double zViewVel;
double zWeapon;
double ozWeapon;
double zWeaponVel;
double slope;
bool isUnderwater;
bool hasKey[8];
int8_t hasFlag;
TObjPtr<DBloodActor*> ctfFlagState[2];
int damageControl[7];
int8_t curWeapon;
int8_t nextWeapon;
int weaponTimer;
int weaponState;
int weaponAmmo; //rename
bool hasWeapon[kWeapMax];
int weaponMode[kWeapMax];
int weaponOrder[2][kWeapMax];
//int at149[14];
int ammoCount[12];
bool qavLoop;
int qavLastTick;
int qavTimer;
int fuseTime;
int throwTime;
double throwPower;
DVector3 aim; // world
DVector3 relAim; // relative
TObjPtr<DBloodActor*> aimTarget; // aim target sprite
int aimTargetsCount;
TObjPtr<DBloodActor*> aimTargets[16];
int deathTime;
int pwUpTime[kMaxPowerUps];
int fragCount;
int fragInfo[8];
int teamId;
TObjPtr<DBloodActor*> fragger;
int underwaterTime;
int bubbleTime;
int restTime;
int kickPower;
int laughCount;
bool godMode;
bool fallScream;
bool cantJump;
int packItemTime; // pack timer
int packItemId; // pack id 1: diving suit, 2: crystal ball, 3: beast vision 4: jump boots
PACKINFO packSlots[5]; // at325 [1]: diving suit, [2]: crystal ball, [3]: beast vision [4]: jump boots
int armor[3]; // armor
//int at342;
//int at346;
TObjPtr<DBloodActor*> voodooTarget;
int voodooTargets; // --> useless
int voodooVar1; // --> useless
int vodooVar2; // --> useless
int flickerEffect;
int tiltEffect;
int visibility;
int painEffect;
int blindEffect;
int chokeEffect;
int handTime;
bool hand; // if true, there is hand start choking the player
int pickupEffect;
bool flashEffect; // if true, reduce pPlayer->visibility counter
int quakeEffect;
int player_par;
int nWaterPal;
POSTURE pPosture[kModeMax][kPostureMax];
inline DBloodActor* GetActor()
{
return actor;
}
};
struct BloodPlayer;
struct AMMOINFO
{
@ -196,13 +97,6 @@ struct POWERUPINFO
void playerResetPosture(BloodPlayer* pPlayer);
extern BloodPlayer PlayerArray[kMaxPlayers];
inline BloodPlayer* getPlayer(int index)
{
return &PlayerArray[index];
}
extern bool gBlueFlagDropped;
extern bool gRedFlagDropped;

View file

@ -11,7 +11,7 @@ using DukeSpriteIterator = TSpriteIterator<DDukeActor>;
inline DDukeActor* DukePlayer::GetActor()
{
return actor;
return static_cast<DDukeActor*>(actor);
}
inline int DukePlayer::GetPlayerNum()

View file

@ -268,7 +268,7 @@ struct DukePlayer final : public CorePlayer
sectortype* cursector;
sectortype* one_parallax_sectnum; // wall + sector references.
walltype* access_wall;
DDukeActor* GetActor();
DDukeActor* GetActor() override;
TObjPtr<DDukeActor*> actorsqu, wackedbyactor, on_crane, holoduke_on, somethingonplayer, access_spritenum, dummyplayersprite, newOwner;
short last_extra, subweapon;
@ -345,7 +345,6 @@ struct DukePlayer final : public CorePlayer
TArray<GameVarValue> uservars;
DDukeActor* actor;
int GetPlayerNum();
void apply_seasick();

View file

@ -49,7 +49,6 @@ struct PlayerSave
struct ExhumedPlayer final : public CorePlayer
{
DExhumedActor* actor;
int16_t nHealth;
int16_t nLives;
int16_t nDouble;
@ -110,9 +109,9 @@ struct ExhumedPlayer final : public CorePlayer
TObjPtr<DExhumedActor*> pDoppleSprite;
TObjPtr<DExhumedActor*> pTarget;
inline DExhumedActor* GetActor()
inline DExhumedActor* GetActor() override
{
return actor;
return static_cast<DExhumedActor*>(actor);
}
};

View file

@ -1848,9 +1848,9 @@ struct SWPlayer final : public CorePlayer
uint8_t WpnReloadState;
inline DSWActor* GetActor()
inline DSWActor* GetActor() override
{
return actor;
return static_cast<DSWActor*>(actor);
}
void posZset(const double val)