From 276c000f9fc44e4b740b7098cd81cb0c9b45197c Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Mon, 23 Aug 2021 20:54:30 +1000 Subject: [PATCH] - Blood: Add mechanism to be able to force QAV interpolation based on picnum for testing purposes and not for end-user usage. --- source/core/gamecvars.cpp | 1 + source/core/gamecvars.h | 1 + source/games/blood/src/qav.cpp | 22 +++++++++++++++++++++- source/games/blood/src/qav.h | 16 ---------------- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/source/core/gamecvars.cpp b/source/core/gamecvars.cpp index 60e1a626b..35982b9dd 100644 --- a/source/core/gamecvars.cpp +++ b/source/core/gamecvars.cpp @@ -87,6 +87,7 @@ CVARD(Bool, cl_bloodvanillabobbing, true, CVAR_ARCHIVE, "enable/disable Blood's CVARD(Bool, cl_bloodvanillaexplosions, false, CVAR_ARCHIVE, "enable/disable Blood's vanilla explosion behavior") CVARD(Bool, cl_bloodvanillaenemies, false, CVAR_ARCHIVE, "enable/disable Blood's vanilla enemy behavior") CVARD(Bool, cl_bloodqavinterp, true, CVAR_ARCHIVE, "enable/disable Blood's QAV interpolation") +CVARD(Bool, cl_bloodqavforcedinterp, false, CVAR_ARCHIVE, "enable/disable Blood's QAV interpolation forcefully for QAVs that aren't defined as interpolatable") CVARD(Bool, cl_bloodweapinterp, false, CVAR_ARCHIVE, "enable/disable Blood's weapon interpolation. Depends on 'cl_bloodqavinterp'") CVARD(Bool, cl_bloodoldweapbalance, false, CVAR_ARCHIVE, "enable/disable legacy 1.0 weapon handling for Blood") diff --git a/source/core/gamecvars.h b/source/core/gamecvars.h index 883af97d6..99dfc7798 100644 --- a/source/core/gamecvars.h +++ b/source/core/gamecvars.h @@ -32,6 +32,7 @@ EXTERN_CVAR(Bool, cl_bloodvanillabobbing) EXTERN_CVAR(Bool, cl_bloodvanillaexplosions) EXTERN_CVAR(Bool, cl_bloodvanillaenemies) EXTERN_CVAR(Bool, cl_bloodqavinterp) +EXTERN_CVAR(Bool, cl_bloodqavforcedinterp) EXTERN_CVAR(Bool, cl_bloodweapinterp) EXTERN_CVAR(Bool, cl_bloodoldweapbalance) diff --git a/source/games/blood/src/qav.cpp b/source/games/blood/src/qav.cpp index 33c8d1750..ae472db18 100644 --- a/source/games/blood/src/qav.cpp +++ b/source/games/blood/src/qav.cpp @@ -45,6 +45,22 @@ enum kQAVIsLoopable = 1 << 0, }; +using QAVPrevTileFinder = TILE_FRAME* (*)(FRAMEINFO* const thisFrame, FRAMEINFO* const prevFrame, const int& i); + +struct QAVInterpProps +{ + int flags; + QAVPrevTileFinder PrevTileFinder; + TMap> IgnoreData; + + bool CanInterpFrameTile(const int& nFrame, const int& i) + { + // Check whether the current frame's tile is skippable. + auto thisFrame = IgnoreData.CheckKey(nFrame); + return thisFrame ? !thisFrame->Contains(i) : true; + } +}; + static TMap qavPrevTileFinders; static TMap qavInterpProps; @@ -139,11 +155,15 @@ void DrawFrame(double x, double y, double z, double a, TILE_FRAME *pTile, int st } } + +static QAVInterpProps forcedinterpdata{ 0, qavGetInterpType("picnum") }; + void QAV::Draw(double x, double y, int ticks, int stat, int shade, int palnum, bool to3dview, double const smoothratio) { assert(ticksPerFrame > 0); - auto const interpdata = qavInterpProps.CheckKey(res_id); + QAVInterpProps* interpdata = qavInterpProps.CheckKey(res_id); + if (!interpdata && cl_bloodqavforcedinterp) interpdata = &forcedinterpdata; auto const nFrame = clamp(ticks / ticksPerFrame, 0, nFrames - 1); FRAMEINFO* const thisFrame = &frames[nFrame]; diff --git a/source/games/blood/src/qav.h b/source/games/blood/src/qav.h index 50c6a74f1..aca60789a 100644 --- a/source/games/blood/src/qav.h +++ b/source/games/blood/src/qav.h @@ -238,22 +238,6 @@ struct QAV void Precache(int palette = 0); }; -using QAVPrevTileFinder = TILE_FRAME* (*)(FRAMEINFO* const thisFrame, FRAMEINFO* const prevFrame, const int& i); - -struct QAVInterpProps -{ - int flags; - QAVPrevTileFinder PrevTileFinder; - TMap> IgnoreData; - - bool CanInterpFrameTile(const int& nFrame, const int& i) - { - // Check whether the current frame's tile is skippable. - auto thisFrame = IgnoreData.CheckKey(nFrame); - return thisFrame ? !thisFrame->Contains(i) : true; - } -}; - QAV* getQAV(int res_id); void qavProcessTicker(QAV* const pQAV, int* duration, int* lastTick); void qavProcessTimer(PLAYER* const pPlayer, QAV* const pQAV, int* duration, double* smoothratio, bool const fixedduration = false);