- Add DCoreActor pointer as PlayerAngles::pActor, setting and nulling where the player's actor is set.

This commit is contained in:
Mitchell Richters 2022-11-27 13:36:55 +11:00 committed by Christoph Oelckers
parent b9f5bb71cc
commit 60a97f781e
8 changed files with 16 additions and 0 deletions

View file

@ -338,6 +338,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerAngles& w, P
("lookang", w.ZzLOOKANG)
("rotscrnang", w.ZzROTSCRNANG)
("spin", w.YawSpin)
("actor", w.pActor)
("inputdisabled", w.legacyDisabledYaw)
("horiz", w.ZzHORIZON)
("horizoff", w.ZzHORIZOFF)

View file

@ -17,6 +17,9 @@ struct PlayerAngles
// Prototypes for applying view.
void doViewPitch(const DVector2& pos, DAngle const ang, bool const aimmode, bool const canslopetilt, sectortype* const cursectnum, double const scaleAdjust = 1, bool const climbing = false);
// General methods.
void setActor(DCoreActor* const actor) { pActor = actor; }
// Pitch methods.
void lockPitch() { legacyDisabledPitch = true; }
void unlockPitch() { legacyDisabledPitch = false; }
@ -180,6 +183,8 @@ struct PlayerAngles
void resetAdjustmentYaw() { legacyAdjustmentYaw = nullAngle; }
private:
// Private data which should never be accessed publically.
DCoreActor* pActor;
// Legacy, to be removed.

View file

@ -801,6 +801,7 @@ void playerStart(int nPlayer, int bNewLevel)
auto actor = actSpawnSprite(pStartZone->sector, pStartZone->pos, 6, 1);
assert(actor->hasX());
pPlayer->actor = actor;
pPlayer->Angles.setActor(actor);
DUDEINFO* pDudeInfo = &dudeInfo[kDudePlayer1 + nPlayer - kDudeBase];
pPlayer->pDudeInfo = pDudeInfo;
playerSetRace(pPlayer, kModeHuman);

View file

@ -622,6 +622,7 @@ void resetpspritevars(int g, const DVector3& startpos)
act->spr.pal = ps[j].palookup = ud.user_pals[j];
ps[j].actor = act;
ps[j].Angles.setActor(act);
ps[j].frag_ps = j;
act->SetOwner(act);

View file

@ -156,6 +156,7 @@ uint8_t LoadLevel(MapRecord* map)
for (i = 0; i < kMaxPlayers; i++)
{
PlayerList[i].pActor = nullptr;
PlayerList[i].Angles.setActor(nullptr);
}
g_visibility = 1024;

View file

@ -181,6 +181,7 @@ void InitPlayer()
{
for (int i = 0; i < kMaxPlayers; i++) {
PlayerList[i].pActor = nullptr;
PlayerList[i].Angles.setActor(nullptr);
PlayerList[i].pPlayerPushSect = nullptr;
PlayerList[i].pPlayerViewSect = nullptr;
}
@ -209,6 +210,7 @@ void InitPlayerInventory(int nPlayer)
PlayerList[nPlayer].nLives = kDefaultLives;
PlayerList[nPlayer].pActor = nullptr;
PlayerList[nPlayer].Angles.setActor(nullptr);
PlayerList[nPlayer].nRun = -1;
PlayerList[nPlayer].nPistolClip = 6;
@ -260,6 +262,7 @@ void RestartPlayer(int nPlayer)
ChangeActorStat(pActor, 0);
plr->pActor = nullptr;
plr->Angles.setActor(nullptr);
DExhumedActor* pFloorSprite = plr->pPlayerFloorSprite;
if (pFloorSprite != nullptr) {
@ -356,6 +359,7 @@ void RestartPlayer(int nPlayer)
plr->nSeqSize = 0;
plr->pActor = pActor;
plr->Angles.setActor(pActor);
plr->bIsMummified = false;
if (plr->invincibility >= 0) {

View file

@ -574,6 +574,7 @@ void TerminateLevel(void)
pp->DoPlayerAction = nullptr;
pp->actor = nullptr;
pp->Angles.setActor(nullptr);
pp->PlayerUnderActor = nullptr;

View file

@ -2407,6 +2407,8 @@ void InitPlayerSprite(PLAYER* pp, const DVector3& spawnpos)
pp->actor = actor;
pp->pnum = pnum;
pp->Angles.setActor(actor);
actor->spr.cstat |= (CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN);
actor->spr.extra |= (SPRX_PLAYER_OR_ENEMY);
actor->spr.cstat &= ~(CSTAT_SPRITE_TRANSLUCENT);