- Exhumed: Eliminate initsectp global.

This commit is contained in:
Mitchell Richters 2023-03-18 12:52:54 +11:00
parent d30ce9691a
commit 0cf44e42fc
7 changed files with 6 additions and 26 deletions

View file

@ -56,8 +56,6 @@ enum {
kSectLava = 0x4000,
};
extern sectortype* initsectp;
extern int nCurChunkNum;
// all static counters combined in an array for easier maintenance.

View file

@ -942,7 +942,7 @@ void DrawWeapons(double interpfrac)
int var_28 = var_30 + WeaponInfo[nWeapon].b[var_34];
int8_t nShade = initsectp->ceilingshade;
int8_t nShade = PlayerList[nLocalPlayer].pActor->sector()->ceilingshade;
int nDouble = PlayerList[nLocalPlayer].nDouble;
int nPal = kPalNormal;

View file

@ -39,8 +39,6 @@ enum
kTagRamses = 61,
};
sectortype* initsectp;
int nCurChunkNum = 0;
int Counters[kNumCounters];
@ -146,7 +144,6 @@ uint8_t LoadLevel(MapRecord* map)
DVector3 initpos;
int16_t mapang;
loadMap(currentLevel->fileName, 0, &initpos, &mapang, &initsect, spawned);
initsectp = initsect;
auto actors = spawnactors(spawned);
int i;
@ -165,7 +162,7 @@ uint8_t LoadLevel(MapRecord* map)
for (int i = 0; i < nTotalPlayers; i++)
{
SetSavePoint(i, initpos, initsectp, DAngle::fromBuild(mapang));
SetSavePoint(i, initpos, initsect, DAngle::fromBuild(mapang));
RestartPlayer(i);
InitPlayerKeys(i);
}
@ -767,7 +764,7 @@ void ExamineSprites(TArray<DExhumedActor*>& actors)
if (nNetPlayerCount)
{
auto pActor = insertActor(initsectp, 0);
auto pActor = insertActor(PlayerList[nLocalPlayer].pActor->sector(), 0);
pActor->spr.pos = PlayerList[nLocalPlayer].pActor->spr.pos;
pActor->spr.cstat = CSTAT_SPRITE_INVISIBLE;
@ -849,8 +846,7 @@ void SerializeInit(FSerializer& arc)
{
if (arc.BeginObject("init"))
{
arc("initsect", initsectp)
("curchunk", nCurChunkNum)
arc("curchunk", nCurChunkNum)
.Array("counters", Counters, kNumCounters)
.EndObject();
}

View file

@ -45,6 +45,7 @@ void GrabMap()
void UpdateMap()
{
const auto initsectp = PlayerList[nLocalPlayer].pActor->sector();
if (initsectp->ceilingpal != 3 || (PlayerList[nLocalPlayer].nTorch != 0)) {
MarkSectorSeen(initsectp);
}

View file

@ -936,15 +936,6 @@ void MoveSector(sectortype* pSector, DAngle nAngle, DVector2& nVel)
}
nVel = vect;
/*
Update player position variables, in case the player sprite was moved by a sector,
Otherwise these can be out of sync when used in sound code (before being updated in PlayerFunc()).
Can cause local player sounds to play off-centre.
TODO: Might need to be done elsewhere too?
*/
auto pActor = PlayerList[nLocalPlayer].pActor;
initsectp = pActor->sector();
}
//---------------------------------------------------------------------------

View file

@ -78,7 +78,7 @@ static int osdcmd_spawn(CCmdFuncPtr parm)
if (!pActor) return CCMD_SHOWHELP;
auto c = parm->parms[0];
auto& initpos = pActor->spr.pos;
auto sectp = initsectp;
auto sectp = pActor->sector();
auto inita = pActor->spr.Angles.Yaw;
if (!stricmp(c, "anubis")) BuildAnubis(nullptr, initpos, sectp, inita, false);
else if (!stricmp(c, "spider")) BuildSpider(nullptr, initpos, sectp, inita);

View file

@ -2583,12 +2583,6 @@ sectdone:
}
}
// loc_1C3B4:
if (nPlayer == nLocalPlayer)
{
initsectp = pPlayerActor->sector();
}
if (!PlayerList[nPlayer].nHealth)
{
PlayerList[nPlayer].nThrust.Zero();