From fddc213fa8392618bd6ef1a1c5ae0269ee22b8f6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 4 Sep 2021 21:59:34 +0200 Subject: [PATCH] - made PLAYER::fragger an actor pointer. --- source/games/blood/src/actor.cpp | 4 ++-- source/games/blood/src/aiunicult.cpp | 2 +- source/games/blood/src/bloodactor.h | 10 ---------- source/games/blood/src/nnexts.cpp | 4 ++-- source/games/blood/src/player.cpp | 16 ++++++++-------- source/games/blood/src/player.h | 4 +--- 6 files changed, 14 insertions(+), 26 deletions(-) diff --git a/source/games/blood/src/actor.cpp b/source/games/blood/src/actor.cpp index 1eac6b0fc..365d3dcdc 100644 --- a/source/games/blood/src/actor.cpp +++ b/source/games/blood/src/actor.cpp @@ -3461,8 +3461,8 @@ void actKillDude(DBloodActor* killerActor, DBloodActor* actor, DAMAGE_TYPE damag for (int p = connecthead; p >= 0; p = connectpoint2[p]) { - if (gPlayer[p].fragger() == actor && gPlayer[p].deathTime > 0) - gPlayer[p].setFragger(nullptr); + if (gPlayer[p].fragger == actor && gPlayer[p].deathTime > 0) + gPlayer[p].fragger = nullptr; } if (pSprite->type != kDudeCultistBeast) trTriggerSprite(actor, kCmdOff); diff --git a/source/games/blood/src/aiunicult.cpp b/source/games/blood/src/aiunicult.cpp index 5a48e545d..1f3f01117 100644 --- a/source/games/blood/src/aiunicult.cpp +++ b/source/games/blood/src/aiunicult.cpp @@ -498,7 +498,7 @@ static void unicultThinkChase(DBloodActor* actor) if (pXTarget->health <= 0) // target is dead { PLAYER* pPlayer = NULL; - if ((!IsPlayerSprite(pTarget)) || ((pPlayer = getPlayerById(pTarget->type)) != NULL && pPlayer->fragger() == actor)) + if ((!IsPlayerSprite(pTarget)) || ((pPlayer = getPlayerById(pTarget->type)) != NULL && pPlayer->fragger == actor)) { playGenDudeSound(actor, kGenDudeSndTargetDead); if (spriteIsUnderwater(actor, false)) aiGenDudeNewState(actor, &genDudeSearchShortW); diff --git a/source/games/blood/src/bloodactor.h b/source/games/blood/src/bloodactor.h index 4bab1ea1b..8e2f7562c 100644 --- a/source/games/blood/src/bloodactor.h +++ b/source/games/blood/src/bloodactor.h @@ -322,16 +322,6 @@ inline void GetActorExtents(DBloodActor* actor, int* top, int* bottom) GetSpriteExtents(&actor->s(), top, bottom); } -inline DBloodActor *PLAYER::fragger() -{ - return fraggerId == -1? nullptr : &bloodActors[fraggerId]; -} - -inline void PLAYER::setFragger(DBloodActor* actor) -{ - fraggerId = actor == nullptr ? -1 : actor->s().index; -} - inline DBloodActor* PLAYER::actor() { return &bloodActors[pSprite->index]; diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index f5a6b7579..edbe382ef 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -4326,8 +4326,8 @@ bool condCheckPlayer(DBloodActor* aCond, int cmpOp, bool PUSH) condError(aCond, "Unexpected powerup #%d", arg3); return false; case 9: - if (!pPlayer->fragger()) return false; - else if (PUSH) condPush(aCond, OBJ_SPRITE, 0, pPlayer->fragger()); + if (!pPlayer->fragger) return false; + else if (PUSH) condPush(aCond, OBJ_SPRITE, 0, pPlayer->fragger); return true; case 10: // check keys pressed switch (arg1) { diff --git a/source/games/blood/src/player.cpp b/source/games/blood/src/player.cpp index 4f2db0b6c..514289b92 100644 --- a/source/games/blood/src/player.cpp +++ b/source/games/blood/src/player.cpp @@ -689,7 +689,7 @@ void playerStart(int nPlayer, int bNewLevel) pPlayer->bloodlust = 0; pPlayer->horizon.horiz = pPlayer->horizon.horizoff = q16horiz(0); pPlayer->slope = 0; - pPlayer->setFragger(0); + pPlayer->fragger = nullptr; pPlayer->underwaterTime = 1200; pPlayer->bubbleTime = 0; pPlayer->restTime = 0; @@ -1375,7 +1375,7 @@ void ProcessInput(PLAYER *pPlayer) if (pXSprite->health == 0) { char bSeqStat = playerSeqPlaying(pPlayer, 16); - auto fragger = pPlayer->fragger(); + auto fragger = pPlayer->fragger; if (fragger) { pPlayer->angle.addadjustment(getincanglebam(pPlayer->angle.ang, bvectangbam(fragger->s().x - pSprite->x, fragger->s().y - pSprite->y))); @@ -1810,7 +1810,7 @@ void playerFrag(PLAYER *pKiller, PLAYER *pVictim) assert(nVictim >= 0 && nVictim < kMaxPlayers); if (nKiller == nVictim) { - pVictim->setFragger(nullptr); + pVictim->fragger = nullptr; if (VanillaMode() || gGameOptions.nGameType != 1) { pVictim->fragCount--; @@ -2014,7 +2014,7 @@ int playerDamageSprite(DBloodActor* source, PLAYER *pPlayer, DAMAGE_TYPE nDamage pPlayer->deathTime = 0; pPlayer->qavLoop = 0; pPlayer->curWeapon = kWeapNone; - pPlayer->setFragger(source); + pPlayer->fragger = source; pPlayer->voodooTargets = 0; if (nDamageType == kDamageExplode && nDamage < (9<<4)) nDamageType = kDamageFall; @@ -2063,8 +2063,8 @@ int playerDamageSprite(DBloodActor* source, PLAYER *pPlayer, DAMAGE_TYPE nDamage pSprite->flags |= 7; for (int p = connecthead; p >= 0; p = connectpoint2[p]) { - if (gPlayer[p].fragger() == pPlayer->actor() && gPlayer[p].deathTime > 0) - gPlayer[p].setFragger(nullptr); + if (gPlayer[p].fragger == pPlayer->actor() && gPlayer[p].deathTime > 0) + gPlayer[p].fragger = nullptr; } FragPlayer(pPlayer, source); trTriggerSprite(pSprite->index, pXSprite, kCmdOff); @@ -2193,7 +2193,7 @@ void PlayerKneelsOver(int, DBloodActor* actor) if (gPlayer[p].pXSprite == pXSprite) { PLAYER *pPlayer = &gPlayer[p]; - playerDamageSprite(pPlayer->fragger(), pPlayer, kDamageSpirit, 500<<4); + playerDamageSprite(pPlayer->fragger, pPlayer, kDamageSpirit, 500<<4); return; } } @@ -2314,7 +2314,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, PLAYER& w, PLAYER* ("fragcount", w.fragCount) .Array("fraginfo", w.fragInfo, countof(w.fragInfo)) ("teamid", w.teamId) - ("fraggerid", w.fraggerId) + ("fraggerid", w.fragger) ("undserwatertime", w.underwaterTime) ("bubbletime", w.bubbleTime) ("resttime", w.restTime) diff --git a/source/games/blood/src/player.h b/source/games/blood/src/player.h index 41693dd06..ae9e35ca3 100644 --- a/source/games/blood/src/player.h +++ b/source/games/blood/src/player.h @@ -147,9 +147,7 @@ struct PLAYER int fragCount; int fragInfo[8]; int teamId; - int fraggerId; - DBloodActor* fragger(); - void setFragger(DBloodActor*); + DBloodActor* fragger; int underwaterTime; int bubbleTime; int restTime;