From 2f1e23a65416ee680baff9621dc51a4afe3d96af Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 6 Nov 2021 10:24:11 +0100 Subject: [PATCH] - replaced PLAYER::PlayerSprite with PLAYER::actor # Conflicts: # source/games/sw/src/save.cpp --- source/games/sw/src/draw.cpp | 5 ++--- source/games/sw/src/game.cpp | 2 +- source/games/sw/src/game.h | 14 ++++++-------- source/games/sw/src/input.cpp | 2 +- source/games/sw/src/ninja.cpp | 7 ++----- source/games/sw/src/save.cpp | 4 ++-- source/games/sw/src/sprite.cpp | 4 ++-- 7 files changed, 16 insertions(+), 22 deletions(-) diff --git a/source/games/sw/src/draw.cpp b/source/games/sw/src/draw.cpp index 9260724f7..fcb57ef97 100644 --- a/source/games/sw/src/draw.cpp +++ b/source/games/sw/src/draw.cpp @@ -733,8 +733,7 @@ void analyzesprites(spritetype* tsprite, int& spritesortcnt, int viewx, int view ShadeSprite(tsp); // sw if its your playersprite - //if ((Player + screenpeek)->PlayerSprite == SpriteNum) - if ((Player + screenpeek)->PlayerSprite == tu->SpriteNum) + if (Player[screenpeek].Actor() == tActor) { PLAYERp pp = Player + screenpeek; if (display_mirror || TEST(pp->Flags, PF_VIEW_FROM_OUTSIDE|PF_VIEW_FROM_CAMERA)) @@ -837,7 +836,7 @@ void analyzesprites(spritetype* tsprite, int& spritesortcnt, int viewx, int view { if (TEST(tu->Flags2, SPR2_VIS_SHADING)) { - if ((Player + screenpeek)->PlayerSprite != tu->SpriteNum) + if (Player[screenpeek].Actor() != tActor) { if (!TEST(tu->PlayerP->Flags, PF_VIEW_FROM_OUTSIDE)) { diff --git a/source/games/sw/src/game.cpp b/source/games/sw/src/game.cpp index ab0a3f410..cbce93bfd 100644 --- a/source/games/sw/src/game.cpp +++ b/source/games/sw/src/game.cpp @@ -469,7 +469,7 @@ void TerminateLevel(void) memset(pp->cookieQuote, 0, sizeof(pp->cookieQuote)); pp->DoPlayerAction = nullptr; - pp->PlayerSprite = -1; + pp->actor = nullptr; pp->PlayerUnderActor = nullptr; diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index c6652ae7e..3a153afef 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -733,7 +733,6 @@ typedef struct struct PLAYERstruct { - DSWActor* Actor(); // variable that fit in the sprite or user structure union { @@ -741,12 +740,18 @@ struct PLAYERstruct vec3_t pos; }; + DSWActor* actor; DSWActor* lowActor, * highActor; DSWActor* remoteActor; DSWActor* PlayerUnderActor; DSWActor* KillerActor; //who killed me DSWActor* HitBy; // SpriteNum of whatever player was last hit by + DSWActor* Actor() const + { + return actor; + } + // interpolation int oposx, oposy, oposz; @@ -800,9 +805,6 @@ struct PLAYERstruct short RevolveDeltaAng; binangle RevolveAng; - // under vars are for wading and swimming - short PlayerSprite; - short pnum; // carry along the player number short LadderSector; @@ -2231,10 +2233,6 @@ END_SW_NS #include "swactor.h" BEGIN_SW_NS -DSWActor* PLAYERstruct::Actor() -{ - return &swActors[PlayerSprite]; -} inline int ActorUpper(DSWActor* actor) { diff --git a/source/games/sw/src/input.cpp b/source/games/sw/src/input.cpp index 66c0df56a..006f205fa 100644 --- a/source/games/sw/src/input.cpp +++ b/source/games/sw/src/input.cpp @@ -162,7 +162,7 @@ void GameInterface::GetInput(ControlInfo* const hidInput, double const scaleAdju { PLAYERp pp = &Player[myconnectindex]; - if (paused || M_Active() || pp->PlayerSprite <= -1) + if (paused || M_Active() || pp->Actor() == nullptr) { loc = {}; return; diff --git a/source/games/sw/src/ninja.cpp b/source/games/sw/src/ninja.cpp index 5f4278d85..ad0f46c4a 100644 --- a/source/games/sw/src/ninja.cpp +++ b/source/games/sw/src/ninja.cpp @@ -2283,13 +2283,10 @@ void PlayerPanelSetup(void) { pp = Player + pnum; - u = User[pp->PlayerSprite].Data(); + u = pp->Actor()->u(); ASSERT(u != nullptr); - //u->WeaponNum = WPN_STAR; - //pp->WpnFirstType = WPN_SWORD; - PlayerUpdateWeapon(pp, u->WeaponNum); } } @@ -2366,7 +2363,7 @@ void InitPlayerSprite(PLAYERp pp) auto actor = SpawnActor(STAT_PLAYER0 + pnum, NINJA_RUN_R0, nullptr, pp->cursectnum, pp->posx, pp->posy, pp->posz, pp->angle.ang.asbuild(), 0); - pp->PlayerSprite = actor->GetSpriteIndex(); + pp->actor = actor; sp = &actor->s(); pp->pnum = pnum; diff --git a/source/games/sw/src/save.cpp b/source/games/sw/src/save.cpp index 9706b122e..2694134be 100644 --- a/source/games/sw/src/save.cpp +++ b/source/games/sw/src/save.cpp @@ -497,7 +497,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, PLAYERstruct& w, P ("revolvey", w.RevolveY) ("RevolveDeltaAng", w.RevolveDeltaAng) ("RevolveAng", w.RevolveAng) - ("PlayerSprite", w.PlayerSprite) + ("PlayerSprite", w.actor) #ifdef OLD_SAVEGAME ; // need to write out UnderSpriteP so that older revisions still load it. if (arc.isWriting()) arc("UnderSpriteP", w.PlayerUnderActor); @@ -581,7 +581,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, PLAYERstruct& w, P ("chops", w.Chops); if (arc.isWriting()) // we need this for loading saves in older builds for debugging. - arc("SpriteP", w.PlayerSprite); + arc("SpriteP", w.actor); SerializeCodePtr(arc, "DoPlayerAction", (void**)&w.DoPlayerAction); diff --git a/source/games/sw/src/sprite.cpp b/source/games/sw/src/sprite.cpp index 94d6d157c..5f0f04fe3 100644 --- a/source/games/sw/src/sprite.cpp +++ b/source/games/sw/src/sprite.cpp @@ -6146,7 +6146,7 @@ KeyMain: case ICON_FLAG: { - if (sp->pal == sprite[pp->PlayerSprite].pal) break; // Can't pick up your own flag! + if (sp->pal == pp->Actor()->s().pal) break; // Can't pick up your own flag! PlaySound(DIGI_ITEM, actor, v3df_dontpan); @@ -6167,7 +6167,7 @@ KeyMain: RESET(np->cstat, CSTAT_SPRITE_BLOCK|CSTAT_SPRITE_BLOCK_HITSCAN); SET(np->cstat, CSTAT_SPRITE_ALIGNMENT_WALL); SetAttach(pp->Actor(), actorNew); - nu->sz = SPRITEp_MID(&sprite[pp->PlayerSprite]); // Set mid way up who it hit + nu->sz = SPRITEp_MID(&pp->Actor()->s()); // Set mid way up who it hit nu->spal = np->pal = sp->pal; // Set the palette of the flag SetOwner(pp->Actor(), actorNew); // Player now owns the flag