- Blood: Initial setup to convert PlayerArray array to array of BloodPlayer pointers.

This commit is contained in:
Mitchell Richters 2023-10-02 14:37:08 +11:00
parent 1604cf009c
commit 0aac044da6
4 changed files with 20 additions and 12 deletions

View file

@ -96,14 +96,14 @@ static void markgcroots()
GC::MarkArray(gPhysSpritesList, gPhysSpritesCount);
GC::MarkArray(gImpactSpritesList, gImpactSpritesCount);
MarkSprInSect();
for (auto& pl : PlayerArray)
for (auto pl : PlayerArray)
{
GC::Mark(pl.actor);
GC::MarkArray(pl.ctfFlagState, 2);
GC::Mark(pl.aimTarget);
GC::MarkArray(pl.aimTargets, 16);
GC::Mark(pl.fragger);
GC::Mark(pl.voodooTarget);
GC::Mark(pl->actor);
GC::MarkArray(pl->ctfFlagState, 2);
GC::Mark(pl->aimTarget);
GC::MarkArray(pl->aimTargets, 16);
GC::Mark(pl->fragger);
GC::Mark(pl->voodooTarget);
}
for (auto& evobj : rxBucket)
{
@ -586,6 +586,13 @@ void GameInterface::loadPalette(void)
void GameInterface::app_init()
{
// Initialise player array.
for (unsigned i = 0; i < kMaxPlayers; i++)
{
PlayerArray[i] = new BloodPlayer;
*PlayerArray[i] = {};
}
mirrortile = tileGetTextureID(504);
InitTextureIDs();

View file

@ -247,11 +247,11 @@ struct BloodPlayer final : public CorePlayer
}
};
extern BloodPlayer PlayerArray[kMaxPlayers];
extern BloodPlayer* PlayerArray[kMaxPlayers];
inline BloodPlayer* getPlayer(int index)
{
return &PlayerArray[index];
return PlayerArray[index];
}
// subclassed to add a game specific actor() method

View file

@ -34,7 +34,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_BLD_NS
BloodPlayer PlayerArray[kMaxPlayers];
BloodPlayer* PlayerArray[kMaxPlayers];
bool gBlueFlagDropped = false;
bool gRedFlagDropped = false;
@ -2528,7 +2528,8 @@ void SerializePlayers(FSerializer& arc)
{
arc("numplayers", gNetPlayers)
.Array("teamscore", team_score, gNetPlayers)
.Array("players", PlayerArray, gNetPlayers)
#pragma message("Blood: Fix saving!")
//.Array("players", PlayerArray, gNetPlayers)
#ifdef NOONE_EXTENSIONS
.Array("playerctrl", gPlayerCtrl, gNetPlayers)
#endif

View file

@ -2063,7 +2063,7 @@ static const uint8_t gWeaponUpgrade[][13] = {
int WeaponUpgrade(BloodPlayer* pPlayer, int newWeapon)
{
int weaponswitch = WeaponSwitch(pPlayer - PlayerArray);
int weaponswitch = WeaponSwitch(pPlayer - *PlayerArray);
int weapon = pPlayer->curWeapon;
if (!checkLitSprayOrTNT(pPlayer) && (weaponswitch & 1) && (gWeaponUpgrade[pPlayer->curWeapon][newWeapon] || (weaponswitch & 2)))
weapon = newWeapon;