- Exhumed: Rename PlayerList[] array to PlayerArray[] and wrap its access.

This commit is contained in:
Mitchell Richters 2023-10-02 15:42:09 +11:00
parent 5008ac08ac
commit d107b6a1fa
26 changed files with 191 additions and 186 deletions

View file

@ -53,7 +53,7 @@ static DExhumedActor* BuildBubble(const DVector3& pos, sectortype* pSector, cons
nSize -= 4;
// Was inita global previously.
const auto nAngle = PlayerList[nPlayer].GetActor()->spr.Angles.Yaw;
const auto nAngle = getPlayer(nPlayer)->GetActor()->spr.Angles.Yaw;
const auto pActor = insertActor(pSector, 402);
pActor->spr.pos = pos;

View file

@ -449,9 +449,9 @@ HITSPRITE:
if (pActor->spr.pal == 5 && hitactor->spr.statnum == 100)
{
int nPlayer = GetPlayerFromActor(hitactor);
if (!PlayerList[nPlayer].bIsMummified)
if (!getPlayer(nPlayer)->bIsMummified)
{
PlayerList[nPlayer].bIsMummified = true;
getPlayer(nPlayer)->bIsMummified = true;
SetNewWeapon(nPlayer, kWeaponMummified);
}
}
@ -598,7 +598,7 @@ DExhumedActor* BuildBullet(DExhumedActor* pActor, int nType, double fZOffset, DA
if (pActor->spr.statnum == 100)
{
pSector = PlayerList[GetPlayerFromActor(pActor)].pPlayerViewSect;
pSector = getPlayer(GetPlayerFromActor(pActor))->pPlayerViewSect;
}
else
{

View file

@ -57,14 +57,14 @@ static const char* GodCheat(int nPlayer, int state)
{
if (state == -1)
{
if (PlayerList[nPlayer].invincibility >= 0)
PlayerList[nPlayer].invincibility = -1;
if (getPlayer(nPlayer)->invincibility >= 0)
getPlayer(nPlayer)->invincibility = -1;
else
PlayerList[nPlayer].invincibility = 0;
getPlayer(nPlayer)->invincibility = 0;
}
else PlayerList[nPlayer].invincibility = -state;
else getPlayer(nPlayer)->invincibility = -state;
return GStrings(PlayerList[nPlayer].invincibility ? "TXT_EX_DEITYON" : "TXT_EX_DEITYOFF");
return GStrings(getPlayer(nPlayer)->invincibility ? "TXT_EX_DEITYON" : "TXT_EX_DEITYOFF");
}
//---------------------------------------------------------------------------
@ -211,7 +211,7 @@ static void cmd_Give(int player, uint8_t** stream, bool skip)
int type = ReadByte(stream);
if (skip) return;
if (PlayerList[player].nHealth <= 0 || nNetPlayerCount || gamestate != GS_LEVEL)
if (getPlayer(player)->nHealth <= 0 || nNetPlayerCount || gamestate != GS_LEVEL)
{
Printf("give: Cannot give while dead or not in a single-player game.\n");
return;
@ -225,7 +225,7 @@ static void cmd_Give(int player, uint8_t** stream, bool skip)
break;
case GIVE_HEALTH:
PlayerList[player].nHealth = 800;
getPlayer(player)->nHealth = 800;
return;
case GIVE_WEAPONS:
@ -257,7 +257,7 @@ static void cmd_Give(int player, uint8_t** stream, bool skip)
}
if (buttons & kButtonCheatKeys) // LOBOPICK cheat
{
PlayerList[player].keys = 0xFFFF;
getPlayer(player)->keys = 0xFFFF;
if (player == myconnectindex) Printf(PRINT_NOTIFY, "%s\n", GStrings("TXT_EX_KEYS"));
}
if (buttons & kButtonCheatItems) // LOBOSWAG cheat

View file

@ -323,7 +323,7 @@ void GameInterface::Ticker(const ticcmd_t* playercmds)
for (int i = connecthead; i >= 0; i = connectpoint2[i])
{
const auto pPlayer = &PlayerList[i];
const auto pPlayer = getPlayer(i);
pPlayer->Angles.resetCameraAngles();
pPlayer->input = playercmds[i].ucmd;
updatePlayerTarget(pPlayer);

View file

@ -234,13 +234,13 @@ struct GameInterface : public ::GameInterface
bool DrawAutomapPlayer(const DVector2& mxy, const DVector2& cpos, const DAngle cang, const DVector2& xydim, const double czoom, double const interpfrac) override;
DAngle playerPitchMin() override { return DAngle::fromDeg(49.5); }
DAngle playerPitchMax() override { return DAngle::fromDeg(-49.5); }
DCoreActor* getConsoleActor() override { return PlayerList[nLocalPlayer].GetActor(); }
DCoreActor* getConsoleActor() override { return getPlayer(nLocalPlayer)->GetActor(); }
void ToggleThirdPerson() override;
void processSprites(tspriteArray& tsprites, const DVector3& view, DAngle viewang, double interpfrac) override;
int GetCurrentSkill() override;
void StartSoundEngine() override;
void reapplyInputBits(InputPacket* const input) override { input->actions |= PlayerList[nLocalPlayer].input.actions & SB_CENTERVIEW; }
void doPlayerMovement(const float scaleAdjust) override { gameInput.processMovement(&PlayerList[nLocalPlayer].Angles, scaleAdjust); }
void reapplyInputBits(InputPacket* const input) override { input->actions |= getPlayer(nLocalPlayer)->input.actions & SB_CENTERVIEW; }
void doPlayerMovement(const float scaleAdjust) override { gameInput.processMovement(&getPlayer(nLocalPlayer)->Angles, scaleAdjust); }
unsigned getCrouchState() override;
};

View file

@ -79,8 +79,8 @@ void GameInterface::Render()
if (nFreeze != 2) // Hide when Ramses is talking.
{
DrawStatusBar();
auto offsets = PlayerList[nLocalPlayer].Angles.getCrosshairOffsets(interpfrac);
DrawCrosshair(PlayerList[nLocalPlayer].nHealth >> 3, offsets.first.X, offsets.first.Y, 1, offsets.second);
auto offsets = getPlayer(nLocalPlayer)->Angles.getCrosshairOffsets(interpfrac);
DrawCrosshair(getPlayer(nLocalPlayer)->nHealth >> 3, offsets.first.X, offsets.first.Y, 1, offsets.second);
if (paused && !M_Active())
{
@ -183,7 +183,7 @@ void GameInterface::LevelCompleted(MapRecord *to_map, int skill)
{
if (to_map->levelNumber > nBestLevel) nBestLevel = to_map->levelNumber - 1;
if (to_map->gameflags & LEVEL_EX_COUNTDOWN) PlayerList[0].nLives = 0;
if (to_map->gameflags & LEVEL_EX_COUNTDOWN) getPlayer(0)->nLives = 0;
if (to_map->gameflags & LEVEL_EX_TRAINING)
{
gameaction = ga_nextlevel;

View file

@ -65,15 +65,15 @@ void BounceGrenade(DExhumedActor* pActor, DAngle nAngle)
void ThrowGrenade(int nPlayer, double dz, double push1)
{
if (PlayerList[nPlayer].pPlayerGrenade == nullptr)
if (getPlayer(nPlayer)->pPlayerGrenade == nullptr)
return;
DExhumedActor* pActor = PlayerList[nPlayer].pPlayerGrenade;
auto pPlayerActor = PlayerList[nPlayer].GetActor();
DExhumedActor* pActor = getPlayer(nPlayer)->pPlayerGrenade;
auto pPlayerActor = getPlayer(nPlayer)->GetActor();
DAngle nAngle = pPlayerActor->spr.Angles.Yaw;
ChangeActorSect(pActor, PlayerList[nPlayer].pPlayerViewSect);
ChangeActorSect(pActor, getPlayer(nPlayer)->pPlayerViewSect);
pActor->spr.pos = pPlayerActor->spr.pos;
@ -86,7 +86,7 @@ void ThrowGrenade(int nPlayer, double dz, double push1)
if (push1 <= 23.4375)
{
int nVel = (int)(PlayerList[nPlayer].totalvel * 512.);
int nVel = (int)(getPlayer(nPlayer)->totalvel * 512.);
pActor->nTurn = ((90 - pActor->nIndex2) * (90 - pActor->nIndex2)) + nVel;
pActor->vel.Z = ((32. * push1) - 17);
@ -108,7 +108,7 @@ void ThrowGrenade(int nPlayer, double dz, double push1)
pActor->vec = nAngle.ToVector() * pActor->nTurn / 256;
PlayerList[nPlayer].pPlayerGrenade = nullptr;
getPlayer(nPlayer)->pPlayerGrenade = nullptr;
return;
}
@ -121,9 +121,9 @@ void ThrowGrenade(int nPlayer, double dz, double push1)
void BuildGrenade(int nPlayer)
{
auto pActor = insertActor(PlayerList[nPlayer].pPlayerViewSect, 201);
auto pActor = insertActor(getPlayer(nPlayer)->pPlayerViewSect, 201);
auto pPlayerActor = PlayerList[nPlayer].GetActor();
auto pPlayerActor = getPlayer(nPlayer)->GetActor();
pActor->spr.pos = pPlayerActor->spr.pos.plusZ(-15);
pActor->spr.shade = -64;
@ -155,7 +155,7 @@ void BuildGrenade(int nPlayer)
pActor->nPhase = runlist_AddRunRec(pActor->spr.lotag - 1, pActor, 0x0F0000);
pActor->nRun = runlist_AddRunRec(NewRun, pActor, 0x0F0000);
PlayerList[nPlayer].pPlayerGrenade = pActor;
getPlayer(nPlayer)->pPlayerGrenade = pActor;
}
//---------------------------------------------------------------------------
@ -199,7 +199,7 @@ void ExplodeGrenade(DExhumedActor* pActor)
if (pActor->nTurn < 0)
{
auto pPlayerActor = PlayerList[nPlayer].GetActor();
auto pPlayerActor = getPlayer(nPlayer)->GetActor();
auto nAngle = pPlayerActor->spr.Angles.Yaw;
DVector2 vect = nAngle.ToVector() * 32;
@ -207,14 +207,14 @@ void ExplodeGrenade(DExhumedActor* pActor)
ChangeActorSect(pActor, pPlayerActor->sector());
if (!PlayerList[nPlayer].invincibility) {
PlayerList[nPlayer].nHealth = 1;
if (!getPlayer(nPlayer)->invincibility) {
getPlayer(nPlayer)->nHealth = 1;
}
}
int nDamage = BulletInfo[kWeaponGrenade].nDamage;
if (PlayerList[nPlayer].nDouble > 0) {
if (getPlayer(nPlayer)->nDouble > 0) {
nDamage *= 2;
}
@ -271,19 +271,19 @@ void AIGrenade::Tick(RunListEvent* ev)
if (pActor->nTurn < 0)
{
PlayerList[nPlayer].nState = 0;
PlayerList[nPlayer].nWeapFrame = 0;
getPlayer(nPlayer)->nState = 0;
getPlayer(nPlayer)->nWeapFrame = 0;
if (PlayerList[nPlayer].nAmmo[kWeaponGrenade])
if (getPlayer(nPlayer)->nAmmo[kWeaponGrenade])
{
PlayerList[nPlayer].bIsFiring = false;
getPlayer(nPlayer)->bIsFiring = false;
}
else
{
SelectNewWeapon(nPlayer);
PlayerList[nPlayer].nCurrentWeapon = PlayerList[nPlayer].nNextWeapon;
PlayerList[nPlayer].nNextWeapon = -1;
getPlayer(nPlayer)->nCurrentWeapon = getPlayer(nPlayer)->nNextWeapon;
getPlayer(nPlayer)->nNextWeapon = -1;
}
}

View file

@ -78,10 +78,10 @@ void RestoreMinAmmo(int nPlayer)
continue;
}
if ((1 << i) & PlayerList[nPlayer].nPlayerWeapons)
if ((1 << i) & getPlayer(nPlayer)->nPlayerWeapons)
{
if (nMinAmmo[i] > PlayerList[nPlayer].nAmmo[i]) {
PlayerList[nPlayer].nAmmo[i] = nMinAmmo[i];
if (nMinAmmo[i] > getPlayer(nPlayer)->nAmmo[i]) {
getPlayer(nPlayer)->nAmmo[i] = nMinAmmo[i];
}
}
}
@ -97,12 +97,12 @@ void RestoreMinAmmo(int nPlayer)
void FillWeapons(int nPlayer)
{
PlayerList[nPlayer].nPlayerWeapons = 0xFFFF; // turn on all bits
getPlayer(nPlayer)->nPlayerWeapons = 0xFFFF; // turn on all bits
for (int i = 0; i < kMaxWeapons; i++)
{
if (WeaponInfo[i].d) {
PlayerList[nPlayer].nAmmo[i] = 300;
getPlayer(nPlayer)->nAmmo[i] = 300;
}
}
@ -119,20 +119,20 @@ void ResetPlayerWeapons(int nPlayer)
{
for (int i = 0; i < kMaxWeapons; i++)
{
PlayerList[nPlayer].nAmmo[i] = 0;
getPlayer(nPlayer)->nAmmo[i] = 0;
}
PlayerList[nPlayer].nCurrentWeapon = 0;
PlayerList[nPlayer].nState = 0;
PlayerList[nPlayer].nWeapFrame = 0;
getPlayer(nPlayer)->nCurrentWeapon = 0;
getPlayer(nPlayer)->nState = 0;
getPlayer(nPlayer)->nWeapFrame = 0;
PlayerList[nPlayer].pPlayerGrenade = nullptr;
PlayerList[nPlayer].nPlayerWeapons = 0x1; // turn on bit 1 only
getPlayer(nPlayer)->pPlayerGrenade = nullptr;
getPlayer(nPlayer)->nPlayerWeapons = 0x1; // turn on bit 1 only
}
void InitWeapons()
{
for (auto& p : PlayerList) p.pPlayerGrenade = nullptr;
for (auto& p : PlayerArray) p.pPlayerGrenade = nullptr;
}
//---------------------------------------------------------------------------
@ -145,33 +145,33 @@ void SetNewWeapon(int nPlayer, int nWeapon)
{
if (nWeapon == kWeaponMummified)
{
PlayerList[nPlayer].nLastWeapon = PlayerList[nPlayer].nCurrentWeapon;
PlayerList[nPlayer].bIsFiring = false;
PlayerList[nPlayer].nState = 5;
getPlayer(nPlayer)->nLastWeapon = getPlayer(nPlayer)->nCurrentWeapon;
getPlayer(nPlayer)->bIsFiring = false;
getPlayer(nPlayer)->nState = 5;
SetPlayerMummified(nPlayer, true);
PlayerList[nPlayer].nWeapFrame = 0;
getPlayer(nPlayer)->nWeapFrame = 0;
}
else
{
if (nWeapon < 0)
{
PlayerList[nPlayer].nPlayerOldWeapon = PlayerList[nPlayer].nCurrentWeapon;
getPlayer(nPlayer)->nPlayerOldWeapon = getPlayer(nPlayer)->nCurrentWeapon;
}
else if (nWeapon != kWeaponGrenade || PlayerList[nPlayer].nAmmo[kWeaponGrenade] > 0)
else if (nWeapon != kWeaponGrenade || getPlayer(nPlayer)->nAmmo[kWeaponGrenade] > 0)
{
int nCurrentWeapon = PlayerList[nPlayer].nCurrentWeapon;
int nCurrentWeapon = getPlayer(nPlayer)->nCurrentWeapon;
if (nCurrentWeapon != kWeaponMummified)
{
if (PlayerList[nPlayer].bIsFiring || nWeapon == nCurrentWeapon) {
if (getPlayer(nPlayer)->bIsFiring || nWeapon == nCurrentWeapon) {
return;
}
}
else
{
PlayerList[nPlayer].nCurrentWeapon = nWeapon;
PlayerList[nPlayer].nWeapFrame = 0;
getPlayer(nPlayer)->nCurrentWeapon = nWeapon;
getPlayer(nPlayer)->nWeapFrame = 0;
}
}
else {
@ -179,7 +179,7 @@ void SetNewWeapon(int nPlayer, int nWeapon)
}
}
PlayerList[nPlayer].nNextWeapon = nWeapon;
getPlayer(nPlayer)->nNextWeapon = nWeapon;
}
//---------------------------------------------------------------------------
@ -192,15 +192,15 @@ void SetNewWeaponImmediate(int nPlayer, int nWeapon)
{
SetNewWeapon(nPlayer, nWeapon);
PlayerList[nPlayer].nCurrentWeapon = nWeapon;
PlayerList[nPlayer].nNextWeapon = -1;
PlayerList[nPlayer].nWeapFrame = 0;
PlayerList[nPlayer].nState = 0;
getPlayer(nPlayer)->nCurrentWeapon = nWeapon;
getPlayer(nPlayer)->nNextWeapon = -1;
getPlayer(nPlayer)->nWeapFrame = 0;
getPlayer(nPlayer)->nState = 0;
}
void SetNewWeaponIfBetter(int nPlayer, int nWeapon)
{
if (nWeapon > PlayerList[nPlayer].nCurrentWeapon) {
if (nWeapon > getPlayer(nPlayer)->nCurrentWeapon) {
SetNewWeapon(nPlayer, nWeapon);
}
}
@ -215,7 +215,7 @@ void SelectNewWeapon(int nPlayer)
{
int nWeapon = kWeaponRing; // start at the highest weapon number
uint16_t di = PlayerList[nPlayer].nPlayerWeapons;
uint16_t di = getPlayer(nPlayer)->nPlayerWeapons;
uint16_t dx = 0x40; // bit 7 turned on
while (dx)
@ -223,7 +223,7 @@ void SelectNewWeapon(int nPlayer)
if (di & dx)
{
// we have this weapon
if (!WeaponInfo[nWeapon].d || PlayerList[nPlayer].nAmmo[WeaponInfo[nWeapon].nAmmoType])
if (!WeaponInfo[nWeapon].d || getPlayer(nPlayer)->nAmmo[WeaponInfo[nWeapon].nAmmoType])
break;
}
@ -234,7 +234,7 @@ void SelectNewWeapon(int nPlayer)
if (nWeapon < 0)
nWeapon = kWeaponSword;
PlayerList[nPlayer].bIsFiring = false;
getPlayer(nPlayer)->bIsFiring = false;
SetNewWeapon(nPlayer, nWeapon);
}
@ -257,14 +257,14 @@ void SetWeaponStatus(int nPlayer)
uint8_t WeaponCanFire(int nPlayer)
{
int nWeapon = PlayerList[nPlayer].nCurrentWeapon;
auto pSector =PlayerList[nPlayer].pPlayerViewSect;
int nWeapon = getPlayer(nPlayer)->nCurrentWeapon;
auto pSector =getPlayer(nPlayer)->pPlayerViewSect;
if (!(pSector->Flag & kSectUnderwater) || WeaponInfo[nWeapon].bFireUnderwater)
{
int nAmmoType = WeaponInfo[nWeapon].nAmmoType;
if (WeaponInfo[nWeapon].d <= PlayerList[nPlayer].nAmmo[nAmmoType]) {
if (WeaponInfo[nWeapon].d <= getPlayer(nPlayer)->nAmmo[nAmmoType]) {
return true;
}
}
@ -287,7 +287,7 @@ void ResetSwordSeqs()
Collision CheckCloseRange(int nPlayer, DVector3& pos, sectortype* *ppSector)
{
auto pActor = PlayerList[nPlayer].GetActor();
auto pActor = getPlayer(nPlayer)->GetActor();
HitInfo hit{};
hitscan(pos, *ppSector, DVector3(pActor->spr.Angles.Yaw.ToVector() * 1024, 0 ), hit, CLIPMASK1);
@ -322,7 +322,7 @@ Collision CheckCloseRange(int nPlayer, DVector3& pos, sectortype* *ppSector)
void CheckClip(int nPlayer)
{
const auto pPlayer = &PlayerList[nPlayer];
const auto pPlayer = getPlayer(nPlayer);
if (pPlayer->nPlayerClip <= 0)
pPlayer->nPlayerClip = min(pPlayer->nAmmo[kWeaponM60], (int16_t)100);
@ -339,7 +339,7 @@ void CheckClip(int nPlayer)
void MoveWeapons(int nPlayer)
{
const auto pPlayer = &PlayerList[nPlayer];
const auto pPlayer = getPlayer(nPlayer);
static int dword_96E22 = 0;

View file

@ -772,9 +772,9 @@ void ExamineSprites(TArray<DExhumedActor*>& actors)
if (nNetPlayerCount)
{
auto pActor = insertActor(PlayerList[nLocalPlayer].GetActor()->sector(), 0);
auto pActor = insertActor(getPlayer(nLocalPlayer)->GetActor()->sector(), 0);
pActor->spr.pos = PlayerList[nLocalPlayer].GetActor()->spr.pos;
pActor->spr.pos = getPlayer(nLocalPlayer)->GetActor()->spr.pos;
pActor->spr.cstat = CSTAT_SPRITE_INVISIBLE;
nNetStartSprite[nNetStartSprites] = pActor;
nNetStartSprites++;

View file

@ -178,18 +178,18 @@ void FillItems(int nPlayer)
{
for (int i = 0; i < 6; i++)
{
PlayerList[nPlayer].items[i] = 5;
getPlayer(nPlayer)->items[i] = 5;
}
PlayerList[nPlayer].nMagic = 1000;
getPlayer(nPlayer)->nMagic = 1000;
if (nPlayer == nLocalPlayer)
{
ItemFlash();
}
if (PlayerList[nPlayer].nItem == -1) {
PlayerList[nPlayer].nItem = 0;
if (getPlayer(nPlayer)->nItem == -1) {
getPlayer(nPlayer)->nItem = 0;
}
}
@ -201,14 +201,14 @@ void FillItems(int nPlayer)
static bool UseEye(int nPlayer)
{
if (PlayerList[nPlayer].nInvisible >= 0)
PlayerList[nPlayer].nInvisible = 900;
if (getPlayer(nPlayer)->nInvisible >= 0)
getPlayer(nPlayer)->nInvisible = 900;
auto pActor = PlayerList[nPlayer].GetActor();
auto pActor = getPlayer(nPlayer)->GetActor();
pActor->spr.cstat |= CSTAT_SPRITE_INVISIBLE;
if (PlayerList[nPlayer].pPlayerFloorSprite != nullptr) {
if (getPlayer(nPlayer)->pPlayerFloorSprite != nullptr) {
pActor->spr.cstat |= CSTAT_SPRITE_INVISIBLE;
}
@ -228,12 +228,12 @@ static bool UseEye(int nPlayer)
static bool UseMask(int nPlayer)
{
PlayerList[nPlayer].nMaskAmount = 1350;
PlayerList[nPlayer].nAir = 100;
getPlayer(nPlayer)->nMaskAmount = 1350;
getPlayer(nPlayer)->nAir = 100;
if (nPlayer == nLocalPlayer)
{
D3PlayFX(StaticSound[kSound31], PlayerList[nPlayer].GetActor());
D3PlayFX(StaticSound[kSound31], getPlayer(nPlayer)->GetActor());
}
return true;
}
@ -246,12 +246,12 @@ static bool UseMask(int nPlayer)
bool UseTorch(int nPlayer)
{
if (!PlayerList[nPlayer].nTorch)
if (!getPlayer(nPlayer)->nTorch)
{
SetTorch(nPlayer, 1);
}
PlayerList[nPlayer].nTorch = 900;
getPlayer(nPlayer)->nTorch = 900;
return true;
}
@ -263,13 +263,13 @@ bool UseTorch(int nPlayer)
bool UseHeart(int nPlayer)
{
if (PlayerList[nPlayer].nHealth < kMaxHealth) {
PlayerList[nPlayer].nHealth = kMaxHealth;
if (getPlayer(nPlayer)->nHealth < kMaxHealth) {
getPlayer(nPlayer)->nHealth = kMaxHealth;
if (nPlayer == nLocalPlayer)
{
ItemFlash();
D3PlayFX(StaticSound[kSound31], PlayerList[nPlayer].GetActor());
D3PlayFX(StaticSound[kSound31], getPlayer(nPlayer)->GetActor());
}
return true;
}
@ -284,13 +284,13 @@ bool UseHeart(int nPlayer)
bool UseScarab(int nPlayer)
{
if (PlayerList[nPlayer].invincibility >= 0 && PlayerList[nPlayer].invincibility < 900)
PlayerList[nPlayer].invincibility = 900;
if (getPlayer(nPlayer)->invincibility >= 0 && getPlayer(nPlayer)->invincibility < 900)
getPlayer(nPlayer)->invincibility = 900;
if (nPlayer == nLocalPlayer)
{
ItemFlash();
D3PlayFX(StaticSound[kSound31], PlayerList[nPlayer].GetActor());
D3PlayFX(StaticSound[kSound31], getPlayer(nPlayer)->GetActor());
}
return true;
}
@ -298,12 +298,12 @@ bool UseScarab(int nPlayer)
// faster firing
static bool UseHand(int nPlayer)
{
PlayerList[nPlayer].nDouble = 1350;
getPlayer(nPlayer)->nDouble = 1350;
if (nPlayer == nLocalPlayer)
{
ItemFlash();
D3PlayFX(StaticSound[kSound31], PlayerList[nPlayer].GetActor());
D3PlayFX(StaticSound[kSound31], getPlayer(nPlayer)->GetActor());
}
return true;
}
@ -342,8 +342,8 @@ void UseItem(int nPlayer, int nItem)
}
if (!didit) return;
PlayerList[nPlayer].items[nItem]--;
int nItemCount = PlayerList[nPlayer].items[nItem];
getPlayer(nPlayer)->items[nItem]--;
int nItemCount = getPlayer(nPlayer)->items[nItem];
int nMagic = nItemMagic[nItem];
@ -351,7 +351,7 @@ void UseItem(int nPlayer, int nItem)
{
for (nItem = 0; nItem < 6; nItem++)
{
if (PlayerList[nPlayer].items[nItem] > 0) {
if (getPlayer(nPlayer)->items[nItem] > 0) {
break;
}
}
@ -361,8 +361,8 @@ void UseItem(int nPlayer, int nItem)
}
}
PlayerList[nPlayer].nMagic -= nMagic;
PlayerList[nPlayer].nItem = nItem;
getPlayer(nPlayer)->nMagic -= nMagic;
getPlayer(nPlayer)->nItem = nItem;
}
//---------------------------------------------------------------------------
@ -373,14 +373,14 @@ void UseItem(int nPlayer, int nItem)
int GrabItem(int nPlayer, int nItem)
{
if (PlayerList[nPlayer].items[nItem] >= 5) {
if (getPlayer(nPlayer)->items[nItem] >= 5) {
return 0;
}
PlayerList[nPlayer].items[nItem]++;
getPlayer(nPlayer)->items[nItem]++;
if (PlayerList[nPlayer].nItem < 0 || nItem == PlayerList[nPlayer].nItem) {
PlayerList[nPlayer].nItem = nItem;
if (getPlayer(nPlayer)->nItem < 0 || nItem == getPlayer(nPlayer)->nItem) {
getPlayer(nPlayer)->nItem = nItem;
}
return 1;

View file

@ -45,8 +45,8 @@ void GrabMap()
void UpdateMap()
{
const auto initsectp = PlayerList[nLocalPlayer].GetActor()->sector();
if (initsectp->ceilingpal != 3 || (PlayerList[nLocalPlayer].nTorch != 0)) {
const auto initsectp = getPlayer(nLocalPlayer)->GetActor()->sector();
if (initsectp->ceilingpal != 3 || (getPlayer(nLocalPlayer)->nTorch != 0)) {
MarkSectorSeen(initsectp);
}
}
@ -73,7 +73,7 @@ bool GameInterface::DrawAutomapPlayer(const DVector2& mxy, const DVector2& cpos,
{
if (i == nLocalPlayer)// || gGameOptions.nGameType == 1)
{
auto pPlayerActor = PlayerList[i].GetActor();
auto pPlayerActor = getPlayer(i)->GetActor();
auto vect = OutAutomapVector(mxy - cpos, cangvect, czoom, xydim);
DrawTexture(twod, pPlayerActor->spr.spritetexture(), true, vect.X, vect.Y, DTA_ClipLeft, viewport3d.Left(), DTA_ClipTop, viewport3d.Top(), DTA_ScaleX, czoom * (2. / 3.), DTA_ScaleY, czoom * (2. / 3.), DTA_CenterOffset, true,

View file

@ -208,7 +208,7 @@ static int BelowNear(DExhumedActor* pActor, const Collision& loHit, double walld
pActor->vel.Z = 0;
if (pActor->spr.statnum == 100)
PlayerList[GetPlayerFromActor(pActor)].bTouchFloor = true;
getPlayer(GetPlayerFromActor(pActor))->bTouchFloor = true;
return kHitAux2;
}
@ -233,7 +233,7 @@ Collision movespritez(DExhumedActor* pActor, double z, double height, double cli
const auto pSect2 = pSector;
if (pActor->spr.statnum == 100)
PlayerList[GetPlayerFromActor(pActor)].bTouchFloor = false;
getPlayer(GetPlayerFromActor(pActor))->bTouchFloor = false;
// backup cstat
const auto cstat = pActor->spr.cstat;
@ -271,7 +271,7 @@ Collision movespritez(DExhumedActor* pActor, double z, double height, double cli
if (pSect2->Flag & kSectUnderwater)
{
if (pActor == PlayerList[nLocalPlayer].GetActor()) {
if (pActor == getPlayer(nLocalPlayer)->GetActor()) {
D3PlayFX(StaticSound[kSound2], pActor);
}
@ -306,7 +306,7 @@ Collision movespritez(DExhumedActor* pActor, double z, double height, double cli
if (z > 0)
{
if (pActor->spr.statnum == 100)
PlayerList[GetPlayerFromActor(pActor)].bTouchFloor = true;
getPlayer(GetPlayerFromActor(pActor))->bTouchFloor = true;
if (loHit.type == kHitSprite)
{
@ -442,10 +442,10 @@ Collision movesprite(DExhumedActor* pActor, DVector2 vect, double dz, double flo
CheckSectorFloor(overridesect, pActor->spr.pos.Z, thrust);
if (!thrust.isZero())
{
PlayerList[nPlayer].nThrust = thrust;
getPlayer(nPlayer)->nThrust = thrust;
}
vect += PlayerList[nPlayer].nThrust;
vect += getPlayer(nPlayer)->nThrust;
}
else
{
@ -616,7 +616,7 @@ DExhumedActor* FindPlayer(DExhumedActor* pActor, int nDistance, bool dontengage)
if (i >= nTotalPlayers)
return nullptr;
pPlayerActor = PlayerList[i].GetActor();
pPlayerActor = getPlayer(i)->GetActor();
if ((pPlayerActor->spr.cstat & CSTAT_SPRITE_BLOCK_ALL) && (!(pPlayerActor->spr.cstat & CSTAT_SPRITE_INVISIBLE)))
{
@ -930,16 +930,16 @@ void SetQuake(DExhumedActor* pActor, int nVal)
{
for (int i = 0; i < nTotalPlayers; i++)
{
auto nSqrt = ((PlayerList[i].GetActor()->spr.pos.XY() - pActor->spr.pos.XY()) * (1. / 16.)).Length();
auto nSqrt = ((getPlayer(i)->GetActor()->spr.pos.XY() - pActor->spr.pos.XY()) * (1. / 16.)).Length();
if (nSqrt)
{
nVal = clamp(int(nVal / nSqrt), 0, 15);
}
if (nVal > PlayerList[i].nQuake)
if (nVal > getPlayer(i)->nQuake)
{
PlayerList[i].nQuake = nVal;
getPlayer(i)->nQuake = nVal;
}
}
}
@ -1015,7 +1015,7 @@ Collision AngleChase(DExhumedActor* pActor, DExhumedActor* pActor2, int threshol
DVector3 WheresMyMouth(int nPlayer, sectortype **sectnum)
{
auto pActor = PlayerList[nPlayer].GetActor();
auto pActor = getPlayer(nPlayer)->GetActor();
double height = GetActorHeight(pActor) * 0.5;
*sectnum = pActor->sector();

View file

@ -622,7 +622,7 @@ int CheckSectorSprites(sectortype* pSector, int nVal)
runlist_DamageEnemy(pActor, nullptr, 5);
if (pActor->spr.statnum == 100 && PlayerList[GetPlayerFromActor(pActor)].nHealth <= 0)
if (pActor->spr.statnum == 100 && getPlayer(GetPlayerFromActor(pActor))->nHealth <= 0)
{
PlayFXAtXYZ(StaticSound[kSoundJonFDie],
pActor->spr.pos,
@ -1556,7 +1556,7 @@ void DoFinale()
PlayFX2(StaticSound[kSound78] | 0x2000, pFinaleSpr);
for (int i = 0; i < nTotalPlayers; i++) {
PlayerList[i].nQuake = 5.;
getPlayer(i)->nQuake = 5.;
}
}
}

View file

@ -61,7 +61,7 @@ static int osdcmd_doors(CCmdFuncPtr parm)
static int osdcmd_spawn(CCmdFuncPtr parm)
{
auto pActor = PlayerList[nLocalPlayer].GetActor();
auto pActor = getPlayer(nLocalPlayer)->GetActor();
if (parm->numparms != 1) return CCMD_SHOWHELP;
if (!pActor) return CCMD_SHOWHELP;
auto c = parm->parms[0];

View file

@ -69,7 +69,7 @@ static constexpr int16_t nItemText[] = {
};
int nLocalPlayer = 0;
ExhumedPlayer PlayerList[kMaxPlayers];
ExhumedPlayer PlayerArray[kMaxPlayers];
TObjPtr<DExhumedActor*> nNetStartSprite[kMaxPlayers] = { };
int PlayerCount;
int nNetStartSprites;
@ -84,7 +84,7 @@ int nCurStartSprite;
size_t MarkPlayers()
{
for (auto& p : PlayerList)
for (auto& p : PlayerArray)
{
GC::Mark(p.actor);
GC::Mark(p.pDoppleSprite);
@ -104,7 +104,7 @@ size_t MarkPlayers()
void SetSavePoint(int nPlayer, const DVector3& pos, sectortype* pSector, DAngle nAngle)
{
const auto pPlayer = &PlayerList[nPlayer];
const auto pPlayer = getPlayer(nPlayer);
pPlayer->sPlayerSave.pos = pos;
pPlayer->sPlayerSave.pSector = pSector;
@ -121,7 +121,7 @@ void InitPlayer()
{
for (int i = 0; i < kMaxPlayers; i++)
{
const auto pPlayer = &PlayerList[i];
const auto pPlayer = getPlayer(i);
pPlayer->actor = nullptr;
pPlayer->Angles = {};
@ -132,7 +132,7 @@ void InitPlayer()
void InitPlayerKeys(int nPlayer)
{
PlayerList[nPlayer].keys = 0;
getPlayer(nPlayer)->keys = 0;
}
//---------------------------------------------------------------------------
@ -143,7 +143,7 @@ void InitPlayerKeys(int nPlayer)
void InitPlayerInventory(int nPlayer)
{
const auto pPlayer = &PlayerList[nPlayer];
const auto pPlayer = getPlayer(nPlayer);
memset(pPlayer, 0, sizeof(ExhumedPlayer));
ResetPlayerWeapons(nPlayer);
@ -167,7 +167,7 @@ void InitPlayerInventory(int nPlayer)
auto texp = TexMan.GetGameTexture(tex);
auto pixels = GetRawPixels(tex);
PlayerList[nPlayer].nPlayerColor = pixels[texp->GetTexelWidth() * texp->GetTexelHeight() / 2];
getPlayer(nPlayer)->nPlayerColor = pixels[texp->GetTexelWidth() * texp->GetTexelHeight() / 2];
}
//---------------------------------------------------------------------------
@ -189,7 +189,7 @@ int GetPlayerFromActor(DExhumedActor* pActor)
void RestartPlayer(int nPlayer)
{
const auto pPlayer = &PlayerList[nPlayer];
const auto pPlayer = getPlayer(nPlayer);
DExhumedActor* pPlayerActor = pPlayer->GetActor();
DExhumedActor* pDopSprite = pPlayer->pDoppleSprite;
DExhumedActor* pFloorSprite = pPlayer->pPlayerFloorSprite;
@ -360,7 +360,7 @@ int GrabPlayer()
void StartDeathSeq(int nPlayer, int nVal)
{
const auto pPlayer = &PlayerList[nPlayer];
const auto pPlayer = getPlayer(nPlayer);
const auto pPlayerActor = pPlayer->GetActor();
const auto pPlayerSect = pPlayerActor->sector();
@ -428,7 +428,7 @@ void StartDeathSeq(int nPlayer, int nVal)
int AddAmmo(int nPlayer, int nWeapon, int nAmmoAmount)
{
const auto pPlayer = &PlayerList[nPlayer];
const auto pPlayer = getPlayer(nPlayer);
if (!nAmmoAmount)
nAmmoAmount = 1;
@ -454,7 +454,7 @@ int AddAmmo(int nPlayer, int nWeapon, int nAmmoAmount)
void SetPlayerMummified(int nPlayer, int bIsMummified)
{
const auto pPlayer = &PlayerList[nPlayer];
const auto pPlayer = getPlayer(nPlayer);
const auto pPlayerActor = pPlayer->GetActor();
pPlayerActor->vel.XY().Zero();
@ -481,7 +481,7 @@ void SetPlayerMummified(int nPlayer, int bIsMummified)
void ShootStaff(int nPlayer)
{
const auto pPlayer = &PlayerList[nPlayer];
const auto pPlayer = getPlayer(nPlayer);
const auto pPlayerActor = pPlayer->GetActor();
pPlayerActor->nAction = 15;
@ -530,7 +530,7 @@ void AIPlayer::Draw(RunListEvent* ev)
const int nPlayer = RunData[ev->nRun].nObjIndex;
assert(nPlayer >= 0 && nPlayer < kMaxPlayers);
const auto pPlayer = &PlayerList[nPlayer];
const auto pPlayer = getPlayer(nPlayer);
const auto pPlayerActor = pPlayer->GetActor();
const auto playerSeq = &PlayerSeq[pPlayerActor->nAction];
seq_PlotSequence(ev->nParam, pPlayerActor->nSeqFile, playerSeq->nSeqId, pPlayerActor->nFrame, playerSeq->nFlags);
@ -547,7 +547,7 @@ void AIPlayer::RadialDamage(RunListEvent* ev)
const int nPlayer = RunData[ev->nRun].nObjIndex;
assert(nPlayer >= 0 && nPlayer < kMaxPlayers);
const auto pPlayer = &PlayerList[nPlayer];
const auto pPlayer = getPlayer(nPlayer);
if (pPlayer->nHealth <= 0)
return;
@ -567,7 +567,7 @@ void AIPlayer::Damage(RunListEvent* ev)
const int nPlayer = RunData[ev->nRun].nObjIndex;
assert(nPlayer >= 0 && nPlayer < kMaxPlayers);
const auto pPlayer = &PlayerList[nPlayer];
const auto pPlayer = getPlayer(nPlayer);
const auto nDamage = ev->nDamage;
if (!nDamage || !pPlayer->nHealth)
@ -1224,7 +1224,7 @@ static void updatePlayerWeapon(ExhumedPlayer* const pPlayer)
unsigned GameInterface::getCrouchState()
{
const bool swimming = PlayerList[nLocalPlayer].bUnderwater;
const bool swimming = getPlayer(nLocalPlayer)->bUnderwater;
return (CS_CANCROUCH * !swimming) | (CS_DISABLETOGGLE * swimming);
}
@ -2058,7 +2058,7 @@ void AIPlayer::Tick(RunListEvent* ev)
const int nPlayer = RunData[ev->nRun].nObjIndex;
assert(nPlayer >= 0 && nPlayer < kMaxPlayers);
const auto pPlayer = &PlayerList[nPlayer];
const auto pPlayer = getPlayer(nPlayer);
const auto pPlayerActor = pPlayer->GetActor();
pPlayerActor->spr.setspritetexture(getSequence(pPlayerActor->nSeqFile, PlayerSeq[nHeightTemplate[pPlayerActor->nAction]].nSeqId)->getFirstFrameTexture());
@ -2183,7 +2183,7 @@ void SerializePlayer(FSerializer& arc)
("localplayer", nLocalPlayer)
("curstartsprite", nCurStartSprite)
.Array("netstartsprite", nNetStartSprite, kMaxPlayers)
.Array("list", PlayerList, PlayerCount);
.Array("list", PlayerArray, PlayerCount);
arc.EndObject();
}
@ -2221,24 +2221,24 @@ DEFINE_FIELD_X(ExhumedPlayer, ExhumedPlayer, nRun);
DEFINE_ACTION_FUNCTION(_Exhumed, GetViewPlayer)
{
ACTION_RETURN_POINTER(&PlayerList[nLocalPlayer]);
ACTION_RETURN_POINTER(getPlayer(nLocalPlayer));
}
DEFINE_ACTION_FUNCTION(_Exhumed, GetPistolClip)
{
ACTION_RETURN_INT(PlayerList[nLocalPlayer].nPistolClip);
ACTION_RETURN_INT(getPlayer(nLocalPlayer)->nPistolClip);
}
DEFINE_ACTION_FUNCTION(_Exhumed, GetPlayerClip)
{
ACTION_RETURN_INT(PlayerList[nLocalPlayer].nPlayerClip);
ACTION_RETURN_INT(getPlayer(nLocalPlayer)->nPlayerClip);
}
DEFINE_ACTION_FUNCTION(_ExhumedPlayer, IsUnderwater)
{
PARAM_SELF_STRUCT_PROLOGUE(ExhumedPlayer);
auto nLocalPlayer = self - PlayerList;
ACTION_RETURN_BOOL(PlayerList[nLocalPlayer].pPlayerViewSect->Flag & kSectUnderwater);
auto nLocalPlayer = self - PlayerArray;
ACTION_RETURN_BOOL(getPlayer(nLocalPlayer)->pPlayerViewSect->Flag & kSectUnderwater);
}
DEFINE_ACTION_FUNCTION(_ExhumedPlayer, GetAngle)

View file

@ -120,7 +120,12 @@ struct ExhumedPlayer
extern int PlayerCount;
extern ExhumedPlayer PlayerList[kMaxPlayers];
extern ExhumedPlayer PlayerArray[kMaxPlayers];
inline ExhumedPlayer* getPlayer(int index)
{
return &PlayerArray[index];
}
extern TObjPtr<DExhumedActor*> nNetStartSprite[kMaxPlayers];
extern int nNetStartSprites;

View file

@ -372,7 +372,7 @@ Collision QueenAngleChase(DExhumedActor* pActor, DExhumedActor* pActor2, int thr
double zz = pActor->pitch.Sin() * veclen;
return movesprite(pActor, vec, zz * 16 + BobVal(PlayerList[GetPlayerFromActor(pActor)].nWeapBob) * 2, 0, CLIPMASK1);
return movesprite(pActor, vec, zz * 16 + BobVal(getPlayer(GetPlayerFromActor(pActor))->nWeapBob) * 2, 0, CLIPMASK1);
}
//---------------------------------------------------------------------------

View file

@ -108,7 +108,7 @@ void FreeRa(int nPlayer)
void BuildRa(int nPlayer)
{
auto pPlayerActor = PlayerList[nPlayer].GetActor();
auto pPlayerActor = getPlayer(nPlayer)->GetActor();
auto pActor = insertActor(pPlayerActor->sector(), 203);
@ -189,7 +189,7 @@ void MoveRaToEnemy(int nPlayer)
}
pActor->spr.cstat = CSTAT_SPRITE_INVISIBLE;
pTarget = PlayerList[nPlayer].GetActor();
pTarget = getPlayer(nPlayer)->GetActor();
}
pActor->spr.pos = pTarget->spr.pos.plusZ(-GetActorHeight(pTarget));
@ -208,7 +208,7 @@ void MoveRaToEnemy(int nPlayer)
void AIRa::Tick(RunListEvent* ev)
{
int nPlayer = RunData[ev->nRun].nObjIndex;
int nCurrentWeapon = PlayerList[nPlayer].nCurrentWeapon;
int nCurrentWeapon = getPlayer(nPlayer)->nCurrentWeapon;
DExhumedActor* pActor = Ra[nPlayer].pActor;
if (!pActor) return;
@ -218,7 +218,7 @@ void AIRa::Tick(RunListEvent* ev)
bool bVal = false;
Ra[nPlayer].pTarget = PlayerList[nPlayer].pTarget;
Ra[nPlayer].pTarget = getPlayer(nPlayer)->pTarget;
pActor->spr.setspritetexture(seqFrame.getFirstChunkTexture());
if (Ra[nPlayer].nAction)
@ -295,9 +295,9 @@ void AIRa::Tick(RunListEvent* ev)
}
else
{
if (PlayerList[nPlayer].nAmmo[kWeaponRing] > 0)
if (getPlayer(nPlayer)->nAmmo[kWeaponRing] > 0)
{
runlist_DamageEnemy(Ra[nPlayer].pTarget, PlayerList[Ra[nPlayer].nPlayer].GetActor(), BulletInfo[kWeaponRing].nDamage);
runlist_DamageEnemy(Ra[nPlayer].pTarget, getPlayer(Ra[nPlayer].nPlayer)->GetActor(), BulletInfo[kWeaponRing].nDamage);
AddAmmo(nPlayer, kWeaponRing, -WeaponInfo[kWeaponRing].d);
SetQuake(pActor, 100);
}

View file

@ -195,7 +195,7 @@ void DoSpiritHead()
auto pSpiritSpr = pSpiritSprite;
auto Worktile = GetWritablePixels(aTexIds[kTexTileRamsesWorkTile]);
const auto pPlayer = &PlayerList[0];
const auto pPlayer = getPlayer(0);
const auto pPlayerActor = pPlayer->GetActor();
const auto nSpiritAngle = (pSpiritSprite->spr.pos.XY() - pPlayerActor->spr.pos.XY()).Angle();
pPlayerActor->spr.Angles.Yaw += deltaangle(pPlayerActor->spr.Angles.Yaw, nSpiritAngle) * 0.25;

View file

@ -364,7 +364,7 @@ void AIRex::Tick(RunListEvent* ev)
if (pHitActor->spr.statnum == 100)
{
auto nPlayer = GetPlayerFromActor(nMov.actor());
PlayerList[nPlayer].nThrust += vel / 4096;
getPlayer(nPlayer)->nThrust += vel / 4096;
pHitActor->vel.Z = -14;
}
else

View file

@ -245,7 +245,7 @@ void runlist_InitRun()
NewRun = nRun;
for (i = 0; i < kMaxPlayers; i++) {
PlayerList[i].nRun = -1;
getPlayer(i)->nRun = -1;
}
pRadialActor = nullptr;
@ -1786,7 +1786,7 @@ int runlist_CheckRadialDamage(DExhumedActor* pActor)
{
// The player's max vel is 15.25 for reference.
pActor->vel.XY() += nVel.XY() * 0.1875 * cl_exdamagepush;
PlayerList[GetPlayerFromActor(pActor)].bJumping = true;
getPlayer(GetPlayerFromActor(pActor))->bJumping = true;
}
else
{
@ -1860,12 +1860,12 @@ void runlist_DamageEnemy(DExhumedActor* pActor, DExhumedActor* pActor2, int nDam
// Due to the horrible setup we can award the kill to the player only here. Yuck!
Level.kills.player[nPlayer]++;
PlayerList[nPlayer].nTauntTimer--;
getPlayer(nPlayer)->nTauntTimer--;
if (PlayerList[nPlayer].nTauntTimer <= 0)
if (getPlayer(nPlayer)->nTauntTimer <= 0)
{
// Do a taunt
auto pPlayerActor = PlayerList[nPlayer].GetActor();
auto pPlayerActor = getPlayer(nPlayer)->GetActor();
auto pSector = pPlayerActor->sector();
if (!(pSector->Flag & kSectUnderwater))
@ -1876,10 +1876,10 @@ void runlist_DamageEnemy(DExhumedActor* pActor, DExhumedActor* pActor2, int nDam
ebx = 0x6000;
}
D3PlayFX(StaticSound[kSoundTauntStart + (RandomSize(3) % 5)], PlayerList[nPlayer].pDoppleSprite, ebx);
D3PlayFX(StaticSound[kSoundTauntStart + (RandomSize(3) % 5)], getPlayer(nPlayer)->pDoppleSprite, ebx);
}
PlayerList[nPlayer].nTauntTimer = RandomSize(3) + 3;
getPlayer(nPlayer)->nTauntTimer = RandomSize(3) + 3;
}
}
}

View file

@ -508,7 +508,7 @@ void seq_PlotSequence(const int nSprite, const FName seqFile, const int16_t seqI
const auto pSector = pTSprite->sectp;
const double nFloorZ = pSector->floorz;
if (nFloorZ <= PlayerList[nLocalPlayer].GetActor()->viewzoffset + PlayerList[nLocalPlayer].GetActor()->spr.pos.Z)
if (nFloorZ <= getPlayer(nLocalPlayer)->GetActor()->viewzoffset + getPlayer(nLocalPlayer)->GetActor()->spr.pos.Z)
{
pTSprite->ownerActor = nullptr;
}
@ -552,7 +552,7 @@ DEFINE_FIELD_X(Seq, Seq, flags);
DEFINE_ACTION_FUNCTION(_SeqFrame, playSound)
{
PARAM_SELF_STRUCT_PROLOGUE(SeqFrame);
self->playSound(PlayerList[nLocalPlayer].GetActor());
self->playSound(getPlayer(nLocalPlayer)->GetActor());
return 0;
}

View file

@ -132,13 +132,13 @@ void ExplodeSnakeSprite(DExhumedActor* pActor, int nPlayer)
{
int nDamage = BulletInfo[kWeaponStaff].nDamage;
if (PlayerList[nPlayer].nDouble > 0) {
if (getPlayer(nPlayer)->nDouble > 0) {
nDamage *= 2;
}
// take a copy of this, to revert after call to runlist_RadialDamageEnemy()
DExhumedActor* nOwner = pActor->pTarget;
pActor->pTarget = PlayerList[nPlayer].GetActor();
pActor->pTarget = getPlayer(nPlayer)->GetActor();
runlist_RadialDamageEnemy(pActor, nDamage, BulletInfo[kWeaponStaff].nRadius);
@ -161,8 +161,8 @@ void BuildSnake(int nPlayer, double zVal)
{
zVal -= 5;
auto pPlayerActor = PlayerList[nPlayer].GetActor();
auto pViewSect = PlayerList[nPlayer].pPlayerViewSect;
auto pPlayerActor = getPlayer(nPlayer)->GetActor();
auto pViewSect = getPlayer(nPlayer)->pPlayerViewSect;
auto nPic = getSequence("snakbody", 0)->getFirstFrameTexture();
auto pos = pPlayerActor->spr.pos.plusZ(zVal - 10);
@ -189,9 +189,9 @@ void BuildSnake(int nPlayer, double zVal)
if (hitactor && hitactor->spr.statnum >= 90 && hitactor->spr.statnum <= 199) {
pTarget = hitactor;
}
else if (PlayerList[nPlayer].pTarget != nullptr)
else if (getPlayer(nPlayer)->pTarget != nullptr)
{
pTarget = PlayerList[nPlayer].pTarget;
pTarget = getPlayer(nPlayer)->pTarget;
}
int nSnake = GrabSnake();
@ -277,7 +277,7 @@ void BuildSnake(int nPlayer, double zVal)
DExhumedActor* FindSnakeEnemy(int nSnake)
{
int nPlayer = SnakeList[nSnake].nSnakePlayer;
auto pPlayerActor = PlayerList[nPlayer].GetActor();
auto pPlayerActor = getPlayer(nPlayer)->GetActor();
DExhumedActor* pActor = SnakeList[nSnake].pSprites[0]; // CHECKME
if (!pActor) return nullptr;

View file

@ -224,7 +224,7 @@ void InitFX(void)
void GetSpriteSoundPitch(int* pVolume, int* pPitch)
{
auto pSoundSect = PlayerList[nLocalPlayer].pPlayerViewSect;
auto pSoundSect = getPlayer(nLocalPlayer)->pPlayerViewSect;
int nLocalSectFlags = pSoundSect->Flag;
if (nLocalSectFlags & kSectUnderwater)
{
@ -418,7 +418,7 @@ void EXSoundEngine::CalcPosVel(int type, const void* source, const float pt[3],
Snake* pSnake = &SnakeList[nSnakeCam];
campos = pSnake->pSprites[0]->spr.pos;
}
else if (const auto pActor = PlayerList[nLocalPlayer].GetActor())
else if (const auto pActor = getPlayer(nLocalPlayer)->GetActor())
{
campos = pActor->spr.pos;
}
@ -485,7 +485,7 @@ void GameInterface::UpdateSounds()
if (nFreeze)
return;
const auto pActor = PlayerList[nLocalPlayer].GetActor();
const auto pActor = getPlayer(nLocalPlayer)->GetActor();
DVector3 pos;
DAngle ang;
@ -628,7 +628,7 @@ void PlayFX2(int nSound, DExhumedActor* pActor, int sectf, EChanFlags chanflags,
}
// Nuke: added nSprite >= 0 check
if (pActor != PlayerList[nLocalPlayer].GetActor() && pActor != nullptr && (pActor->spr.cstat & CSTAT_SPRITE_BLOCK_ALL))
if (pActor != getPlayer(nLocalPlayer)->GetActor() && pActor != nullptr && (pActor->spr.cstat & CSTAT_SPRITE_BLOCK_ALL))
nCreepyTimer = kCreepyCount;
}
@ -669,7 +669,7 @@ void CheckAmbience(sectortype* sect)
{
if (sect == pSector2)
{
amb = GetSoundPos(PlayerList[0].GetActor()->spr.pos);
amb = GetSoundPos(getPlayer(0)->GetActor()->spr.pos);
}
else
{
@ -702,7 +702,7 @@ void UpdateCreepySounds()
nCreepyTimer--;
if (nCreepyTimer <= 0)
{
if (Level.kills.got < Level.kills.max && !(PlayerList[nLocalPlayer].pPlayerViewSect->Flag & 0x2000))
if (Level.kills.got < Level.kills.max && !(getPlayer(nLocalPlayer)->pPlayerViewSect->Flag & 0x2000))
{
const auto creepySeq = getSequence("creepy");
const auto seqFrameSound = creepySeq->frames[totalmoves % creepySeq->frames.Size()].sound;
@ -716,7 +716,7 @@ void UpdateCreepySounds()
if (totalmoves & 2)
adder.Y = -adder.Y;
auto sp = PlayerList[nLocalPlayer].GetActor()->spr.pos + adder;
auto sp = getPlayer(nLocalPlayer)->GetActor()->spr.pos + adder;
creepy = GetSoundPos(sp);
auto soundid = FSoundID::fromInt((seqFrameSound & 0x1ff) + 1);

View file

@ -548,7 +548,7 @@ void AISWPressSector::Use(RunListEvent* ev)
int nLink = SwitchData[nSwitch].nLink;
int nPlayer = ev->nParam;
if ((PlayerList[nPlayer].keys & SwitchData[nSwitch].nKeyMask) == SwitchData[nSwitch].nKeyMask)
if ((getPlayer(nPlayer)->keys & SwitchData[nSwitch].nKeyMask) == SwitchData[nSwitch].nKeyMask)
{
runlist_ChangeChannel(nChannel, LinkMap[nLink].v[sRunChannels[nChannel].c]);
}
@ -556,7 +556,7 @@ void AISWPressSector::Use(RunListEvent* ev)
{
if (SwitchData[nSwitch].nKeyMask)
{
PlayFXAtXYZ(StaticSound[nSwitchSound], PlayerList[nPlayer].GetActor()->spr.pos, CHANF_LISTENERZ);
PlayFXAtXYZ(StaticSound[nSwitchSound], getPlayer(nPlayer)->GetActor()->spr.pos, CHANF_LISTENERZ);
StatusMessage(300, GStrings("TXT_EX_NEEDKEY"));
}

View file

@ -72,7 +72,7 @@ void DrawView(double interpfrac, bool sceneonly)
DoInterpolations(interpfrac);
auto pPlayer = &PlayerList[nLocalPlayer];
auto pPlayer = getPlayer(nLocalPlayer);
auto pPlayerActor = pPlayer->GetActor();
auto nPlayerOldCstat = pPlayerActor->spr.cstat;
auto pDop = pPlayer->pDoppleSprite;
@ -107,11 +107,11 @@ void DrawView(double interpfrac, bool sceneonly)
{
nCamerapos = pPlayerActor->getRenderPos(interpfrac);
pSector = PlayerList[nLocalPlayer].pPlayerViewSect;
pSector = getPlayer(nLocalPlayer)->pPlayerViewSect;
updatesector(nCamerapos, &pSector);
if (pSector == nullptr) pSector = PlayerList[nLocalPlayer].pPlayerViewSect;
if (pSector == nullptr) pSector = getPlayer(nLocalPlayer)->pPlayerViewSect;
nCameraangles = PlayerList[nLocalPlayer].Angles.getRenderAngles(interpfrac);
nCameraangles = getPlayer(nLocalPlayer)->Angles.getRenderAngles(interpfrac);
if (!bCamera)
{