From 5441272becdc8787c35c3e9d0b7070c7e1b2908d Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Sun, 11 Jul 2021 19:22:59 +1000 Subject: [PATCH] - SW: Create inline function `pspPresentRetractScale()` to scale the rate at which weapons present and retract based on the current tile's height vs. the original asset's height. * Reported to me by @Phredreeke, who had it reported to him from someone else. * The sword in the widescreen assets pack we load by default has a height of 216px vs 136px of the default tile. * Because the game presents and retracts weapons at a set rate, the time it took to swap between the sword and other weapons took ~1.58x longer than the original assets. * This speeds up the present/retract rate based on the loaded asset's height to ensure the weapon switches in the same elapsed time. * This may be extended to other weapons if required but the sword is the only one I'm aware of that has more height. * Confirmed no matter what motion the sword was performing, `psp->picndx` was always 2080 so we shouldn't need a hashtable or anything like this. --- source/games/sw/src/panel.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/source/games/sw/src/panel.cpp b/source/games/sw/src/panel.cpp index 1acf32d4d..eb4549d51 100644 --- a/source/games/sw/src/panel.cpp +++ b/source/games/sw/src/panel.cpp @@ -745,6 +745,12 @@ inline double pspCosVel(PANEL_SPRITEp const psp, int const ang = INT_MAX) return psp->vel * synctics * bcosf(ang == INT_MAX ? psp->ang : ang, -6) * (1. / FRACUNIT); } +inline double pspPresentRetractScale(int const picnum, double const defaultheight) +{ + double const picheight = tileHeight(picnum); + return picheight == defaultheight ? 1 : picheight / defaultheight; +} + ////////////////////////////////////////////////////////////////////////////////////////// // @@ -1009,7 +1015,7 @@ pSwordPresent(PANEL_SPRITEp psp) return; psp->backupy(); - psp->y -= 3 * synctics; + psp->y -= 3 * synctics * pspPresentRetractScale(psp->picndx, 136); if (psp->y < SWORD_YOFF) { @@ -1239,7 +1245,7 @@ pSwordRetract(PANEL_SPRITEp psp) short picnum = psp->picndx; psp->backupy(); - psp->y += 3 * synctics; + psp->y += 3 * synctics * pspPresentRetractScale(picnum, 136); if (psp->y >= SWORD_YOFF + tileHeight(picnum)) {