From 5b9152abfd17c803bf557006eb80399515d692de Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 5 Sep 2021 08:41:44 +0200 Subject: [PATCH] - eliminated the last access to playerActors in trigger.cpp and made AimTargets a pointer array. --- source/games/blood/src/actor.cpp | 2 +- source/games/blood/src/db.h | 1 + source/games/blood/src/loadsave.cpp | 1 + source/games/blood/src/player.cpp | 2 +- source/games/blood/src/player.h | 2 +- source/games/blood/src/triggers.cpp | 6 ++++-- source/games/blood/src/weapon.cpp | 12 +++++------- wadsrc/static/zscript/games/blood/bloodgame.zs | 2 +- 8 files changed, 15 insertions(+), 13 deletions(-) diff --git a/source/games/blood/src/actor.cpp b/source/games/blood/src/actor.cpp index 9a2530f7c..786eed31d 100644 --- a/source/games/blood/src/actor.cpp +++ b/source/games/blood/src/actor.cpp @@ -4970,7 +4970,7 @@ void MoveDude(DBloodActor* actor) if (pXSector && pXSector->Enter && (pPlayer || !pXSector->dudeLockout)) { if (sector[nSector].type == kSectorTeleport) - pXSector->data = pPlayer ? pSprite->index : -1; + pXSector->actordata = actor; trTriggerSector(nSector, pXSector, kCmdSectorEnter); } diff --git a/source/games/blood/src/db.h b/source/games/blood/src/db.h index 624117153..01b8b2a2e 100644 --- a/source/games/blood/src/db.h +++ b/source/games/blood/src/db.h @@ -203,6 +203,7 @@ struct XSECTOR { DBloodActor* marker0; DBloodActor* marker1; DBloodActor* basePath; + DBloodActor* actordata; uint16_t windAng; // Wind ang uint16_t bobTheta; // Motion Theta int16_t bobSpeed; // Motion speed diff --git a/source/games/blood/src/loadsave.cpp b/source/games/blood/src/loadsave.cpp index ebdf4d9e3..effb75605 100644 --- a/source/games/blood/src/loadsave.cpp +++ b/source/games/blood/src/loadsave.cpp @@ -572,6 +572,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, XSECTOR& w, XSECTO ("marker0", w.marker0, def->marker0) ("marker1", w.marker1, def->marker1) ("basepath", w.basePath, def->basePath) + ("actordata", w.actordata, def->actordata) ("windang", w.windAng, def->windAng) ("bobtheta", w.bobTheta, def->bobTheta) ("bobspeed", w.bobSpeed, def->bobSpeed) diff --git a/source/games/blood/src/player.cpp b/source/games/blood/src/player.cpp index a8a61326e..c4bf8fd26 100644 --- a/source/games/blood/src/player.cpp +++ b/source/games/blood/src/player.cpp @@ -2445,7 +2445,7 @@ DEFINE_FIELD_X(BloodPlayer, PLAYER, throwTime) DEFINE_FIELD_X(BloodPlayer, PLAYER, throwPower) DEFINE_FIELD_X(BloodPlayer, PLAYER, aim) // world DEFINE_FIELD_X(BloodPlayer, PLAYER, aimTargetsCount) -DEFINE_FIELD_X(BloodPlayer, PLAYER, aimTargets) +//DEFINE_FIELD_X(BloodPlayer, PLAYER, aimTargets) DEFINE_FIELD_X(BloodPlayer, PLAYER, deathTime) DEFINE_FIELD_X(BloodPlayer, PLAYER, pwUpTime) DEFINE_FIELD_X(BloodPlayer, PLAYER, teamId) diff --git a/source/games/blood/src/player.h b/source/games/blood/src/player.h index 738bdfe66..7bacbd270 100644 --- a/source/games/blood/src/player.h +++ b/source/games/blood/src/player.h @@ -141,7 +141,7 @@ struct PLAYER //int at1d2; DBloodActor* aimTarget; // aim target sprite int aimTargetsCount; - short aimTargets[16]; + DBloodActor* aimTargets[16]; int deathTime; int pwUpTime[kMaxPowerUps]; int fragCount; diff --git a/source/games/blood/src/triggers.cpp b/source/games/blood/src/triggers.cpp index c31404c6b..48325b7b3 100644 --- a/source/games/blood/src/triggers.cpp +++ b/source/games/blood/src/triggers.cpp @@ -1447,8 +1447,10 @@ void OperateTeleport(unsigned int nSector, XSECTOR *pXSector) pPlayer = NULL; if (bPlayer || !SectorContainsDudes(pDest->sectnum)) { - if (!(gGameOptions.uNetGameFlags&2)) - TeleFrag(&bloodActors[pXSector->data], pDest->sectnum); + if (!(gGameOptions.uNetGameFlags & 2)) + { + TeleFrag(pXSector->actordata, pDest->sectnum); + } pSprite->x = pDest->x; pSprite->y = pDest->y; pSprite->z += sector[pDest->sectnum].floorz-sector[nSector].floorz; diff --git a/source/games/blood/src/weapon.cpp b/source/games/blood/src/weapon.cpp index c382cfeed..97e033c66 100644 --- a/source/games/blood/src/weapon.cpp +++ b/source/games/blood/src/weapon.cpp @@ -398,7 +398,7 @@ void UpdateAimVector(PLAYER * pPlayer) if (abs(((angle-pPSprite->ang+1024)&2047)-1024) > pWeaponTrack->angleRange) continue; if (pPlayer->aimTargetsCount < 16 && cansee(x,y,z,pPSprite->sectnum,x2,y2,z2,pSprite->sectnum)) - pPlayer->aimTargets[pPlayer->aimTargetsCount++] = pSprite->index; + pPlayer->aimTargets[pPlayer->aimTargetsCount++] = actor; // Inlined? int dz = (lz-z2)>>8; int dy = (ly-y2)>>4; @@ -449,7 +449,7 @@ void UpdateAimVector(PLAYER * pPlayer) if (abs(((angle-pPSprite->ang+1024)&2047)-1024) > pWeaponTrack->thingAngle) continue; if (pPlayer->aimTargetsCount < 16 && cansee(x,y,z,pPSprite->sectnum,pSprite->x,pSprite->y,pSprite->z,pSprite->sectnum)) - pPlayer->aimTargets[pPlayer->aimTargetsCount++] = pSprite->index; + pPlayer->aimTargets[pPlayer->aimTargetsCount++] = actor; // Inlined? int dz2 = (lz-z2)>>8; int dy2 = (ly-y2)>>4; @@ -1517,8 +1517,7 @@ void AltFireVoodoo(int nTrigger, PLAYER *pPlayer) { for (int i = 0; i < pPlayer->aimTargetsCount; i++) { - int nTarget = pPlayer->aimTargets[i]; - auto targetactor = &bloodActors[nTarget]; + auto targetactor = pPlayer->aimTargets[i]; spritetype* pTarget = &targetactor->s(); if (!gGameOptions.bFriendlyFire && IsTargetTeammate(pPlayer, pTarget)) continue; @@ -1554,8 +1553,7 @@ void AltFireVoodoo(int nTrigger, PLAYER *pPlayer) int v4 = pPlayer->ammoCount[9] - (pPlayer->ammoCount[9] / nCount) * nCount; for (int i = 0; i < pPlayer->aimTargetsCount; i++) { - int nTarget = pPlayer->aimTargets[i]; - auto targetactor = &bloodActors[nTarget]; + auto targetactor = pPlayer->aimTargets[i]; spritetype* pTarget = &targetactor->s(); if (!gGameOptions.bFriendlyFire && IsTargetTeammate(pPlayer, pTarget)) continue; @@ -1738,7 +1736,7 @@ void AltFireLifeLeech(int , PLAYER *pPlayer) pXSprite->DudeLockout = 1; pXSprite->data4 = ClipHigh(pPlayer->ammoCount[4], 12); pXSprite->stateTimer = 1; - evPostActor(&bloodActors[pMissile->index], 120, kCallbackLeechStateTimer); + evPostActor(missile, 120, kCallbackLeechStateTimer); if (gGameOptions.nGameType <= 1) { int nAmmo = pPlayer->ammoCount[8]; diff --git a/wadsrc/static/zscript/games/blood/bloodgame.zs b/wadsrc/static/zscript/games/blood/bloodgame.zs index 96ffa4278..1a6b8c7a2 100644 --- a/wadsrc/static/zscript/games/blood/bloodgame.zs +++ b/wadsrc/static/zscript/games/blood/bloodgame.zs @@ -100,7 +100,7 @@ struct BloodPlayer native //native Aim aim; // world //native int aimTarget; // aim target sprite native int aimTargetsCount; - native short aimTargets[16]; + //native short aimTargets[16]; native int deathTime; native int pwUpTime[51]; // kMaxPowerUps native int fragCount;