mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-23 04:22:16 +00:00
fixed GC handling of players.
These were missing null checks, the player pointers also weren't nulled after deleting the objects.
This commit is contained in:
parent
a941bbf89c
commit
d60834be3d
7 changed files with 58 additions and 37 deletions
|
@ -635,7 +635,11 @@ int GameMain()
|
|||
if (gi)
|
||||
{
|
||||
gi->FreeLevelData();
|
||||
for (int i = 0; i < MAXPLAYERS; i++) delete PlayerArray[i];
|
||||
for (int i = 0; i < MAXPLAYERS; i++)
|
||||
{
|
||||
delete PlayerArray[i];
|
||||
PlayerArray[i] = nullptr;
|
||||
}
|
||||
}
|
||||
DestroyAltHUD();
|
||||
DeinitMenus();
|
||||
|
|
|
@ -98,12 +98,16 @@ static void markgcroots()
|
|||
MarkSprInSect();
|
||||
for (int i = 0; i < MAXPLAYERS; i++)
|
||||
{
|
||||
GC::Mark(getPlayer(i)->actor);
|
||||
GC::MarkArray(getPlayer(i)->ctfFlagState, 2);
|
||||
GC::Mark(getPlayer(i)->aimTarget);
|
||||
GC::MarkArray(getPlayer(i)->aimTargets, 16);
|
||||
GC::Mark(getPlayer(i)->fragger);
|
||||
GC::Mark(getPlayer(i)->voodooTarget);
|
||||
auto plr = getPlayer(i);
|
||||
if (plr)
|
||||
{
|
||||
GC::Mark(plr->actor);
|
||||
GC::MarkArray(plr->ctfFlagState, 2);
|
||||
GC::Mark(plr->aimTarget);
|
||||
GC::MarkArray(plr->aimTargets, 16);
|
||||
GC::Mark(plr->fragger);
|
||||
GC::Mark(plr->voodooTarget);
|
||||
}
|
||||
}
|
||||
for (auto& evobj : rxBucket)
|
||||
{
|
||||
|
|
|
@ -85,18 +85,22 @@ static void markgcroots()
|
|||
GC::Mark(ud.cameraactor);
|
||||
for (int i = 0; i < MAXPLAYERS; i++)
|
||||
{
|
||||
GC::Mark(getPlayer(i)->actor);
|
||||
GC::Mark(getPlayer(i)->actorsqu);
|
||||
GC::Mark(getPlayer(i)->wackedbyactor);
|
||||
GC::Mark(getPlayer(i)->on_crane);
|
||||
GC::Mark(getPlayer(i)->holoduke_on);
|
||||
GC::Mark(getPlayer(i)->somethingonplayer);
|
||||
GC::Mark(getPlayer(i)->access_spritenum);
|
||||
GC::Mark(getPlayer(i)->dummyplayersprite);
|
||||
GC::Mark(getPlayer(i)->newOwner);
|
||||
for (auto& var : getPlayer(i)->uservars)
|
||||
auto plr = getPlayer(i);
|
||||
if (plr)
|
||||
{
|
||||
var.Mark();
|
||||
GC::Mark(plr->actor);
|
||||
GC::Mark(plr->actorsqu);
|
||||
GC::Mark(plr->wackedbyactor);
|
||||
GC::Mark(plr->on_crane);
|
||||
GC::Mark(plr->holoduke_on);
|
||||
GC::Mark(plr->somethingonplayer);
|
||||
GC::Mark(plr->access_spritenum);
|
||||
GC::Mark(plr->dummyplayersprite);
|
||||
GC::Mark(plr->newOwner);
|
||||
for (auto& var : plr->uservars)
|
||||
{
|
||||
var.Mark();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,16 +83,20 @@ int nCurStartSprite;
|
|||
|
||||
size_t MarkPlayers()
|
||||
{
|
||||
for (int i = 0; i < kMaxWeapons; i++)
|
||||
for (int i = 0; i < MAXPLAYERS; i++)
|
||||
{
|
||||
GC::Mark(getPlayer(i)->actor);
|
||||
GC::Mark(getPlayer(i)->pDoppleSprite);
|
||||
GC::Mark(getPlayer(i)->pPlayerFloorSprite);
|
||||
GC::Mark(getPlayer(i)->pPlayerGrenade);
|
||||
GC::Mark(getPlayer(i)->pTarget);
|
||||
auto plr = getPlayer(i);
|
||||
if (plr)
|
||||
{
|
||||
GC::Mark(plr->actor);
|
||||
GC::Mark(plr->pDoppleSprite);
|
||||
GC::Mark(plr->pPlayerFloorSprite);
|
||||
GC::Mark(plr->pPlayerGrenade);
|
||||
GC::Mark(plr->pTarget);
|
||||
}
|
||||
}
|
||||
GC::MarkArray(nNetStartSprite, kMaxPlayers);
|
||||
return 6 * kMaxPlayers;
|
||||
GC::MarkArray(nNetStartSprite, MAXPLAYERS);
|
||||
return 6 * MAXPLAYERS;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
|
|
@ -120,14 +120,18 @@ void markgcroots()
|
|||
GC::MarkArray(BossSpriteNum, 3);
|
||||
for (int i = 0; i < MAXPLAYERS; i++)
|
||||
{
|
||||
GC::Mark(getPlayer(i)->actor);
|
||||
GC::Mark(getPlayer(i)->lowActor);
|
||||
GC::Mark(getPlayer(i)->highActor);
|
||||
GC::Mark(getPlayer(i)->remoteActor);
|
||||
GC::Mark(getPlayer(i)->PlayerUnderActor);
|
||||
GC::Mark(getPlayer(i)->KillerActor);
|
||||
GC::Mark(getPlayer(i)->HitBy);
|
||||
GC::Mark(getPlayer(i)->last_camera_act);
|
||||
auto plr = getPlayer(i);
|
||||
if (plr)
|
||||
{
|
||||
GC::Mark(plr->actor);
|
||||
GC::Mark(plr->lowActor);
|
||||
GC::Mark(plr->highActor);
|
||||
GC::Mark(plr->remoteActor);
|
||||
GC::Mark(plr->PlayerUnderActor);
|
||||
GC::Mark(plr->KillerActor);
|
||||
GC::Mark(plr->HitBy);
|
||||
GC::Mark(plr->last_camera_act);
|
||||
}
|
||||
}
|
||||
for (auto& so : SectorObject)
|
||||
{
|
||||
|
|
|
@ -71,6 +71,8 @@ struct PACKINFO // not native!
|
|||
|
||||
struct BloodPlayer native
|
||||
{
|
||||
native uint8 pnum; // Connect id
|
||||
|
||||
native int GetHealth(); // health is stored in the XSPRITE which cannot be safely exported to scripting at the moment due to pending refactoring.
|
||||
native int powerupCheck(int pwup);
|
||||
//DUDEINFO* pDudeInfo;
|
||||
|
@ -89,7 +91,6 @@ struct BloodPlayer native
|
|||
native int swayAmp;
|
||||
native double swayHeight;
|
||||
native double swayWidth;
|
||||
native int nPlayer; // Connect id
|
||||
//native int nSprite;
|
||||
native int lifeMode;
|
||||
native double zView;
|
||||
|
|
|
@ -147,6 +147,8 @@ struct SW native
|
|||
|
||||
struct SWPlayer native
|
||||
{
|
||||
native uint8 pnum; // carry along the player number
|
||||
|
||||
// variable that fit in the sprite or user structure
|
||||
/*
|
||||
union
|
||||
|
@ -217,8 +219,6 @@ struct SWPlayer native
|
|||
|
||||
native double RevolveDeltaAng;
|
||||
|
||||
native int16 pnum; // carry along the player number
|
||||
|
||||
//native int16 LadderSector;
|
||||
native int16 JumpDuration;
|
||||
native int16 WadeDepth;
|
||||
|
|
Loading…
Reference in a new issue