From 182b8023ca59d06cb4b63db079ef9945b8c40947 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 22 Nov 2020 20:09:09 +0100 Subject: [PATCH] - Blood: ported BloodGDX's fix for the double shotgun graphics glitch. Fixes #114 --- source/blood/src/gameutil.cpp | 2 +- source/blood/src/weapon.cpp | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/source/blood/src/gameutil.cpp b/source/blood/src/gameutil.cpp index bf5a9b76d..fee90ced7 100644 --- a/source/blood/src/gameutil.cpp +++ b/source/blood/src/gameutil.cpp @@ -875,7 +875,7 @@ int GetClosestSpriteSectors(int nSector, int x, int y, int nDist, uint8_t *pSect } i++; } - walls[m] = -1; + if (walls) walls[m] = -1; return n; } diff --git a/source/blood/src/weapon.cpp b/source/blood/src/weapon.cpp index 741163715..cf6eb23a4 100644 --- a/source/blood/src/weapon.cpp +++ b/source/blood/src/weapon.cpp @@ -261,6 +261,15 @@ void WeaponPrecache(HitList &hits) } } +bool isOriginalQAV() +{ + static int cached = -1; + if (cached != -1) return cached; + int lump = fileSystem.FindResource(60, "QAV"); + cached = lump >= 0 && fileSystem.GetFileContainer(lump) < fileSystem.GetMaxIwadNum(); + return cached; +} + void WeaponDraw(PLAYER *pPlayer, int shade, double xpos, double ypos, int palnum, int smoothratio) { assert(pPlayer != NULL); @@ -268,6 +277,17 @@ void WeaponDraw(PLAYER *pPlayer, int shade, double xpos, double ypos, int palnum return; QAV * pQAV = weaponQAV[pPlayer->weaponQav]; int duration; + + if (pPlayer->weaponTimer == 0) // playing idle QAV? + { + // Double shotgun fix from BloodGDX. + if (/*!IsOriginalDemo() &&*/ (pPlayer->weaponState == -1 || (pPlayer->curWeapon == 3 && pPlayer->weaponState == 7)) && isOriginalQAV()) + duration = pQAV->duration - 1; + else duration = (gFrameClock + mulscale16(4, smoothratio)) % pQAV->duration; + } + else duration = pQAV->duration - pPlayer->weaponTimer; + + if (pPlayer->weaponTimer == 0) duration = (gFrameClock + mulscale16(4, smoothratio)) % pQAV->duration; else