From f524abdf47c2bd0c7b62b96a7fd15ecbd0690ba2 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Tue, 25 Oct 2022 22:16:15 +1100 Subject: [PATCH] - Blood: Utilise new weapon drawing offsets from the backend. --- source/games/blood/src/choke.cpp | 2 +- source/games/blood/src/hudsprites.cpp | 22 +++++++++------------- source/games/blood/src/misc.h | 2 +- source/games/blood/src/nnexts.cpp | 14 +++++++------- source/games/blood/src/nnexts.h | 2 +- source/games/blood/src/qav.cpp | 8 ++++---- source/games/blood/src/qav.h | 2 +- source/games/blood/src/view.cpp | 2 +- source/games/blood/src/view.h | 2 +- source/games/blood/src/weapon.cpp | 4 ++-- 10 files changed, 28 insertions(+), 32 deletions(-) diff --git a/source/games/blood/src/choke.cpp b/source/games/blood/src/choke.cpp index 326412e44..5877cc350 100644 --- a/source/games/blood/src/choke.cpp +++ b/source/games/blood/src/choke.cpp @@ -72,7 +72,7 @@ void CChoke::animateChoke(int x, int y, double interpfrac) qav->Play(vdi - vd, vdi, -1, nullptr); // This originally overlaid the HUD but that simply doesn't work right with the HUD being a genuine overlay. // It also never adjusted for a reduced 3D view - qav->Draw(vdi, 10, 0, 0, true); + qav->Draw(vdi, 10, 0, 0, true, interpfrac); } diff --git a/source/games/blood/src/hudsprites.cpp b/source/games/blood/src/hudsprites.cpp index c9d63c3c3..9b596f5be 100644 --- a/source/games/blood/src/hudsprites.cpp +++ b/source/games/blood/src/hudsprites.cpp @@ -104,32 +104,28 @@ static void viewBurnTime(int gScale) // //--------------------------------------------------------------------------- -void hudDraw(PLAYER* pPlayer, sectortype* pSector, double bobx, double boby, double zDelta, int basepal, double interpfrac) +void hudDraw(PLAYER* pPlayer, sectortype* pSector, double bobx, double boby, double zDelta, DAngle angle, int basepal, double interpfrac) { - double look_anghalf = pPlayer->angle.look_anghalf(interpfrac); - if (gViewPos == 0) { - double looking_arc = pPlayer->angle.looking_arc(interpfrac); + auto cXY = DVector2(160, 220) + pPlayer->angle.weaponoffsets(interpfrac); - double cX = 160 - look_anghalf; - double cY = 220 + looking_arc; if (cl_weaponsway) { if (cl_hudinterpolation) { - cX += bobx; - cY += boby + (zDelta * 2.); + cXY.X += bobx; + cXY.Y += boby + (zDelta * 2.); } else { - cX += int(bobx); - cY += int(boby) + int(zDelta * 2); + cXY.X += int(bobx); + cXY.Y += int(boby) + int(zDelta * 2); } } else { - cY += (-2048. / 128.); + cXY.Y += (-2048. / 128.); } int nShade = pSector? pSector->floorshade : 0; int nPalette = 0; @@ -141,8 +137,8 @@ void hudDraw(PLAYER* pPlayer, sectortype* pSector, double bobx, double boby, dou } #ifdef NOONE_EXTENSIONS - if (pPlayer->sceneQav < 0) WeaponDraw(pPlayer, nShade, cX, cY, nPalette); - else if (pPlayer->actor->xspr.health > 0) playerQavSceneDraw(pPlayer, nShade, cX, cY, nPalette); + if (pPlayer->sceneQav < 0) WeaponDraw(pPlayer, nShade, cXY.X, cXY.Y, nPalette, angle); + else if (pPlayer->actor->xspr.health > 0) playerQavSceneDraw(pPlayer, nShade, cXY.X, cXY.Y, nPalette, angle); else { pPlayer->sceneQav = pPlayer->weaponQav = kQAVNone; pPlayer->qavTimer = pPlayer->weaponTimer = pPlayer->curWeapon = 0; diff --git a/source/games/blood/src/misc.h b/source/games/blood/src/misc.h index b74d46cf8..2cb187b32 100644 --- a/source/games/blood/src/misc.h +++ b/source/games/blood/src/misc.h @@ -49,7 +49,7 @@ struct PLAYER; bool checkLitSprayOrTNT(PLAYER* pPlayer); void WeaponInit(void); -void WeaponDraw(PLAYER* pPlayer, int a2, double a3, double a4, int a5); +void WeaponDraw(PLAYER* pPlayer, int shade, double xpos, double ypos, int palnum, DAngle angle); void WeaponRaise(PLAYER* pPlayer); void WeaponLower(PLAYER* pPlayer); int WeaponUpgrade(PLAYER* pPlayer, int newWeapon); diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index cc3b78641..8e2a7e6d3 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -7293,7 +7293,7 @@ void playerQavSceneProcess(PLAYER* pPlayer, QAVSCENE* pQavScene) // //--------------------------------------------------------------------------- -void playerQavSceneDraw(PLAYER* pPlayer, int a2, double a3, double a4, int a5) +void playerQavSceneDraw(PLAYER* pPlayer, int shade, double xpos, double ypos, int palnum, DAngle angle) { if (pPlayer == NULL || pPlayer->sceneQav == -1) return; @@ -7303,22 +7303,22 @@ void playerQavSceneDraw(PLAYER* pPlayer, int a2, double a3, double a4, int a5) if (pQavScene->qavResrc != NULL) { QAV* pQAV = pQavScene->qavResrc; - int v4; + int duration; double interpfrac; - qavProcessTimer(pPlayer, pQAV, &v4, &interpfrac); + qavProcessTimer(pPlayer, pQAV, &duration, &interpfrac); int flags = 2; int nInv = powerupCheck(pPlayer, kPwUpShadowCloak); if (nInv >= 120 * 8 || (nInv != 0 && (PlayClock & 32))) { - a2 = -128; flags |= 1; + shade = -128; flags |= 1; } // draw as weapon if (!(actor->spr.flags & kModernTypeFlag1)) { - pQAV->x = a3; pQAV->y = a4; - pQAV->Draw(v4, flags, a2, a5, true, interpfrac); + pQAV->x = xpos; pQAV->y = ypos; + pQAV->Draw(duration, flags, shade, palnum, true, interpfrac, angle); // draw fullscreen (currently 4:3 only) } @@ -7326,7 +7326,7 @@ void playerQavSceneDraw(PLAYER* pPlayer, int a2, double a3, double a4, int a5) { // What an awful hack. This throws proper ordering out of the window, but there is no way to reproduce this better with strict layering of elements. // From the above commit it seems to be incomplete anyway... - pQAV->Draw(v4, flags, a2, a5, false, interpfrac); + pQAV->Draw(duration, flags, shade, palnum, false, interpfrac, angle); } } } diff --git a/source/games/blood/src/nnexts.h b/source/games/blood/src/nnexts.h index b28eb8169..aa6ed8223 100644 --- a/source/games/blood/src/nnexts.h +++ b/source/games/blood/src/nnexts.h @@ -347,7 +347,7 @@ void playerDeactivateShrooms(PLAYER* pPlayer); QAV* playerQavSceneLoad(int qavId); void playerQavSceneProcess(PLAYER* pPlayer, QAVSCENE* pQavScene); void playerQavScenePlay(PLAYER* pPlayer); -void playerQavSceneDraw(PLAYER* pPlayer, int a2, double a3, double a4, int a5); +void playerQavSceneDraw(PLAYER* pPlayer, int shade, double xpos, double ypos, int palnum, DAngle angle); void playerQavSceneReset(PLAYER* pPlayer); // ------------------------------------------------------------------------- // void callbackUniMissileBurst(DBloodActor* actor, sectortype* nSprite); diff --git a/source/games/blood/src/qav.cpp b/source/games/blood/src/qav.cpp index db357e7d8..7e1f22ae5 100644 --- a/source/games/blood/src/qav.cpp +++ b/source/games/blood/src/qav.cpp @@ -163,7 +163,7 @@ void DrawFrame(double x, double y, double z, double a, double alpha, int picnum, // //--------------------------------------------------------------------------- -void QAV::Draw(int ticks, int stat, int shade, int palnum, bool to3dview, double const interpfrac) +void QAV::Draw(int ticks, int stat, int shade, int palnum, bool to3dview, double const interpfrac, DAngle angle) { assert(ticksPerFrame > 0); @@ -201,7 +201,7 @@ void QAV::Draw(int ticks, int stat, int shade, int palnum, bool to3dview, double tileY = interpolatedvalue(prevTile->y, thisTile->y, interpfrac); tileZ = interpolatedvalue(prevTile->z, thisTile->z, interpfrac); tileA = interpolatedvalue(prevTile->angle, thisTile->angle, interpfrac); - tileShade = (int)interpolatedvalue(prevTile->shade, thisTile->shade, interpfrac) + shade; + tileShade = (int)interpolatedvalue(prevTile->shade, thisTile->shade, interpfrac); tileAlpha = interpolatedvalue(prevAlpha, thisAlpha, interpfrac); } else @@ -210,11 +210,11 @@ void QAV::Draw(int ticks, int stat, int shade, int palnum, bool to3dview, double tileY = thisTile->y; tileZ = thisTile->z; tileA = thisTile->angle; - tileShade = thisTile->shade + shade; + tileShade = thisTile->shade; tileAlpha = (tileStat & RS_TRANS1) ? glblend[0].def[!!(tileStat & RS_TRANS2)].alpha : 1.f; } - DrawFrame(tileX + x, tileY + y, tileZ, tileA.Buildfang(), tileAlpha, thisTile->picnum, tileStat, tileShade, (palnum <= 0 ? thisTile->palnum : palnum), to3dview); + DrawFrame(tileX + x, tileY + y, tileZ, (tileA + angle).Buildfang(), tileAlpha, thisTile->picnum, tileStat, tileShade + shade, (palnum <= 0 ? thisTile->palnum : palnum), to3dview); } } } diff --git a/source/games/blood/src/qav.h b/source/games/blood/src/qav.h index 30a7d783a..d81d8016d 100644 --- a/source/games/blood/src/qav.h +++ b/source/games/blood/src/qav.h @@ -229,7 +229,7 @@ struct QAV double y; // 18 uint16_t res_id; FRAMEINFO frames[1]; // 24 - void Draw(int ticks, int stat, int shade, int palnum, bool to3dview, double const interpfrac = 1.); + void Draw(int ticks, int stat, int shade, int palnum, bool to3dview, double const interpfrac, DAngle angle = nullAngle); void Play(int, int, int, PLAYER*); void Precache(int palette = 0); }; diff --git a/source/games/blood/src/view.cpp b/source/games/blood/src/view.cpp index 5c960c539..516005900 100644 --- a/source/games/blood/src/view.cpp +++ b/source/games/blood/src/view.cpp @@ -734,7 +734,7 @@ void viewDrawScreen(bool sceneonly) } } - if (!sceneonly) hudDraw(pPlayer, pSector, shakeX, shakeY, zDelta, basepal, interpfrac); + if (!sceneonly) hudDraw(pPlayer, pSector, shakeX, shakeY, zDelta, rotscrnang, basepal, interpfrac); DAngle deliriumPitchI = interpolatedvalue(maphoriz(deliriumPitchO), maphoriz(deliriumPitch), interpfrac); auto bakCstat = pPlayer->actor->spr.cstat; pPlayer->actor->spr.cstat |= (gViewPos == 0) ? CSTAT_SPRITE_INVISIBLE : CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP; diff --git a/source/games/blood/src/view.h b/source/games/blood/src/view.h index 25e26f241..f2fa25de5 100644 --- a/source/games/blood/src/view.h +++ b/source/games/blood/src/view.h @@ -92,7 +92,7 @@ extern DAngle gScreenTiltO, gScreenTilt; extern int gShowFrameRate; extern int gLastPal; -void hudDraw(PLAYER* pPlayer, sectortype* pSector, double bobx, double boby, double zDelta, int basepal, double interpfrac); +void hudDraw(PLAYER* pPlayer, sectortype* pSector, double bobx, double boby, double zDelta, DAngle angle, int basepal, double interpfrac); void viewInitializePrediction(void); void viewUpdatePrediction(InputPacket* pInput); void viewCorrectPrediction(void); diff --git a/source/games/blood/src/weapon.cpp b/source/games/blood/src/weapon.cpp index e0bb4cc47..e11862422 100644 --- a/source/games/blood/src/weapon.cpp +++ b/source/games/blood/src/weapon.cpp @@ -328,7 +328,7 @@ void WeaponPrecache() // //--------------------------------------------------------------------------- -void WeaponDraw(PLAYER* pPlayer, int shade, double xpos, double ypos, int palnum) +void WeaponDraw(PLAYER* pPlayer, int shade, double xpos, double ypos, int palnum, DAngle angle) { assert(pPlayer != NULL); if (pPlayer->weaponQav == kQAVNone) @@ -348,7 +348,7 @@ void WeaponDraw(PLAYER* pPlayer, int shade, double xpos, double ypos, int palnum shade = -128; flags |= 1; } - pQAV->Draw(duration, flags, shade, palnum, true, interpfrac); + pQAV->Draw(duration, flags, shade, palnum, true, interpfrac, angle); } //---------------------------------------------------------------------------