From 8f360f3bea82075b155039c69184bc2a61f503fe Mon Sep 17 00:00:00 2001 From: Leonard2 Date: Thu, 26 May 2016 21:58:46 +0200 Subject: [PATCH] Small refactor --- src/d_player.h | 2 +- src/p_pspr.cpp | 48 ++++++++++++++++++++++++------------------------ src/p_pspr.h | 12 ++++++------ 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index 650799f6d..8a90d9680 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -531,8 +531,8 @@ public: // PSprite layers void TickPSprites(); void DestroyPSprites(); - DPSprite *GetPSprite(psprnum_t layer); // Used ONLY for compatibility with the old hardcoded layers. DPSprite *FindPSprite(int layer); + DPSprite *GetPSprite(psprnum_t layer); // Used ONLY for compatibility with the old hardcoded layers. }; // Bookkeeping on players - state. diff --git a/src/p_pspr.cpp b/src/p_pspr.cpp index d918c40c5..ab50fc982 100644 --- a/src/p_pspr.cpp +++ b/src/p_pspr.cpp @@ -128,7 +128,7 @@ DPSprite::DPSprite(player_t *owner, AInventory *caller, int id) } Next = next; GC::WriteBarrier(this, next); - if (prev == NULL) + if (prev == nullptr) { Owner->psprites = this; GC::WriteBarrier(this); @@ -149,6 +149,29 @@ DPSprite::DPSprite(player_t *owner, AInventory *caller, int id) // //------------------------------------------------------------------------ +DPSprite *player_t::FindPSprite(int layer) +{ + if (layer == 0) + return nullptr; + + DPSprite *pspr = psprites; + while (pspr) + { + if (pspr->ID == layer) + break; + + pspr = pspr->Next; + } + + return pspr; +} + +//------------------------------------------------------------------------ +// +// +// +//------------------------------------------------------------------------ + DPSprite *player_t::GetPSprite(psprnum_t layer) { assert(layer > 0 && layer < NUMPSPRITES); @@ -177,29 +200,6 @@ DPSprite *player_t::GetPSprite(psprnum_t layer) return pspr; } -//------------------------------------------------------------------------ -// -// -// -//------------------------------------------------------------------------ - -DPSprite *player_t::FindPSprite(int layer) -{ - if (layer == 0) - return nullptr; - - DPSprite *pspr = psprites; - while (pspr) - { - if (pspr->ID == layer) - break; - - pspr = pspr->Next; - } - - return pspr; -} - //--------------------------------------------------------------------------- // // PROC P_NewPspriteTick diff --git a/src/p_pspr.h b/src/p_pspr.h index 68baddc70..b9104d4aa 100644 --- a/src/p_pspr.h +++ b/src/p_pspr.h @@ -62,12 +62,12 @@ public: static void NewTick(); void SetState(FState *newstate, bool pending = false); - int GetID() const { return ID; } - int GetSprite() const { return Sprite; } - int GetFrame() const { return Frame; } - FState* GetState() const { return State; } - DPSprite* GetNext() { return Next; } - AInventory* GetCaller() { return Caller; } + int GetID() const { return ID; } + int GetSprite() const { return Sprite; } + int GetFrame() const { return Frame; } + FState* GetState() const { return State; } + DPSprite* GetNext() { return Next; } + AInventory* GetCaller() { return Caller; } double x, y; double oldx, oldy;