diff --git a/src/hwrenderer/scene/hw_weapon.cpp b/src/hwrenderer/scene/hw_weapon.cpp index d0bb20e4d..171c28647 100644 --- a/src/hwrenderer/scene/hw_weapon.cpp +++ b/src/hwrenderer/scene/hw_weapon.cpp @@ -433,21 +433,7 @@ bool HUDSprite::GetWeaponRect(HWDrawInfo *di, DPSprite *psp, float sx, float sy, x2 += viewwindowx; // killough 12/98: fix psprite positioning problem - ftexturemid = 100.f - sy - r.top; - - AWeapon * wi = player->ReadyWeapon; - if (wi && wi->YAdjust != 0) - { - float fYAd = wi->YAdjust; - if (screenblocks >= 11) - { - ftexturemid -= fYAd; - } - else - { - ftexturemid -= float(StatusBar->GetDisplacement()) * fYAd; - } - } + ftexturemid = 100.f - sy - r.top - psp->GetYAdjust(screenblocks >= 11); scale = (SCREENHEIGHT*vw) / (SCREENWIDTH * 200.0f); y1 = viewwindowy + vh / 2 - (ftexturemid * scale); diff --git a/src/p_pspr.cpp b/src/p_pspr.cpp index f0a1a3856..6634fb7b5 100644 --- a/src/p_pspr.cpp +++ b/src/p_pspr.cpp @@ -44,6 +44,7 @@ #include "cmdlib.h" #include "g_levellocals.h" #include "vm.h" +#include "sbar.h" // MACROS ------------------------------------------------------------------ @@ -1348,6 +1349,32 @@ void DPSprite::OnDestroy() // //------------------------------------------------------------------------ +float DPSprite::GetYAdjust(bool fullscreen) +{ + AWeapon *weapon = dyn_cast(GetCaller()); + if (weapon != nullptr) + { + float fYAd = weapon->YAdjust; + if (fYAd != 0) + { + if (fullscreen) + { + return fYAd; + } + else + { + return StatusBar->GetDisplacement() * fYAd; + } + } + } +} + +//------------------------------------------------------------------------ +// +// +// +//------------------------------------------------------------------------ + ADD_STAT(psprites) { FString out; diff --git a/src/p_pspr.h b/src/p_pspr.h index 2113a854e..33d46d29c 100644 --- a/src/p_pspr.h +++ b/src/p_pspr.h @@ -92,6 +92,7 @@ public: void ResetInterpolation() { oldx = x; oldy = y; } void OnDestroy() override; std::pair GetRenderStyle(FRenderStyle ownerstyle, double owneralpha); + float GetYAdjust(bool fullscreen); double x, y, alpha; double oldx, oldy; diff --git a/src/polyrenderer/scene/poly_playersprite.cpp b/src/polyrenderer/scene/poly_playersprite.cpp index fecbc77ac..ada83a747 100644 --- a/src/polyrenderer/scene/poly_playersprite.cpp +++ b/src/polyrenderer/scene/poly_playersprite.cpp @@ -296,18 +296,7 @@ void RenderPolyPlayerSprites::RenderSprite(PolyRenderThread *thread, DPSprite *p viewheight == renderTarget->GetHeight() || (renderTarget->GetWidth() > (BASEXCENTER * 2)))) { // Adjust PSprite for fullscreen views - AWeapon *weapon = dyn_cast(pspr->GetCaller()); - if (weapon != nullptr && weapon->YAdjust != 0) - { - if (renderToCanvas || viewheight == renderTarget->GetHeight()) - { - vis.texturemid -= weapon->YAdjust; - } - else - { - vis.texturemid -= StatusBar->GetDisplacement() * weapon->YAdjust; - } - } + vis.texturemid -= pspr->GetYAdjust(renderToCanvas || viewheight == renderTarget->GetHeight()); } if (pspr->GetID() < PSP_TARGETCENTER) { // Move the weapon down for 1280x1024. diff --git a/src/swrenderer/things/r_playersprite.cpp b/src/swrenderer/things/r_playersprite.cpp index 1a6f52e2d..a51b3b5fd 100644 --- a/src/swrenderer/things/r_playersprite.cpp +++ b/src/swrenderer/things/r_playersprite.cpp @@ -295,18 +295,7 @@ namespace swrenderer viewheight == viewport->RenderTarget->GetHeight() || (viewport->RenderTarget->GetWidth() > (BASEXCENTER * 2)))) { // Adjust PSprite for fullscreen views - AWeapon *weapon = dyn_cast(pspr->GetCaller()); - if (weapon != nullptr && weapon->YAdjust != 0) - { - if (renderToCanvas || viewheight == viewport->RenderTarget->GetHeight()) - { - vis.texturemid -= weapon->YAdjust; - } - else - { - vis.texturemid -= StatusBar->GetDisplacement() * weapon->YAdjust; - } - } + vis.texturemid -= pspr->GetYAdjust(renderToCanvas || viewheight == viewport->RenderTarget->GetHeight()); } if (pspr->GetID() < PSP_TARGETCENTER) { // Move the weapon down for 1280x1024.