From 9f36ef69e678eed958f7933cc73ef4e2d8a645f4 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 21 Mar 2021 08:58:38 +0100 Subject: [PATCH] - fixed variable name clash caused by viewUpdateShake's global variables. removed the redundant call in the Ticker, because all its results are discarded. Use arguments instead of global variables to pass data around. --- source/games/blood/src/blood.cpp | 1 - source/games/blood/src/view.cpp | 41 ++++++++++++++++---------------- source/games/blood/src/view.h | 1 - 3 files changed, 20 insertions(+), 23 deletions(-) diff --git a/source/games/blood/src/blood.cpp b/source/games/blood/src/blood.cpp index 8f4c3bb31..9aea146d5 100644 --- a/source/games/blood/src/blood.cpp +++ b/source/games/blood/src/blood.cpp @@ -304,7 +304,6 @@ void GameInterface::Ticker() viewCorrectPrediction(); ambProcess(); viewUpdateDelirium(); - viewUpdateShake(); gi->UpdateSounds(); if (gMe->hand == 1) { diff --git a/source/games/blood/src/view.cpp b/source/games/blood/src/view.cpp index 1bfc9f1fd..b2e990627 100644 --- a/source/games/blood/src/view.cpp +++ b/source/games/blood/src/view.cpp @@ -395,17 +395,15 @@ void viewUpdateDelirium(void) } } -int shakeHoriz, shakeAngle, shakeX, shakeY, shakeZ, shakeBobX, shakeBobY; - -void viewUpdateShake(void) +void viewUpdateShake(int& cX, int& cY, int& cZ, binangle& cA, fixedhoriz& cH, double& pshakeX, double& pshakeY) { - shakeHoriz = 0; - shakeAngle = 0; - shakeX = 0; - shakeY = 0; - shakeZ = 0; - shakeBobX = 0; - shakeBobY = 0; + int shakeHoriz = 0; + int shakeAngle = 0; + int shakeX = 0; + int shakeY = 0; + int shakeZ = 0; + int shakeBobX = 0; + int shakeBobY = 0; if (gView->flickerEffect) { int nValue = ClipHigh(gView->flickerEffect * 8, 2000); @@ -428,6 +426,14 @@ void viewUpdateShake(void) shakeBobX += QRandom2(nValue); shakeBobY += QRandom2(nValue); } + cH += buildhoriz(shakeHoriz); + cA += buildang(shakeAngle); + cX += shakeX; + cY += shakeY; + cZ += shakeZ; + pshakeX += shakeBobX; + pshakeY += shakeBobY; + } @@ -452,11 +458,10 @@ static void DrawMap(spritetype* pSprite) setViewport(hud_size); } -void SetupView(int &cX, int& cY, int& cZ, binangle& cA, fixedhoriz& cH, int& nSectnum, double& zDelta) +void SetupView(int &cX, int& cY, int& cZ, binangle& cA, fixedhoriz& cH, int& nSectnum, double& zDelta, double& shakeX, double& shakeY) { int bobWidth, bobHeight; lookangle rotscrnang; - double shakeX, shakeY; nSectnum = gView->pSprite->sectnum; if (numplayers > 1 && gView == gMe && gPrediction && gMe->pXSprite->health > 0) { @@ -515,14 +520,7 @@ void SetupView(int &cX, int& cY, int& cZ, binangle& cA, fixedhoriz& cH, int& nSe } } - viewUpdateShake(); - cH += buildhoriz(shakeHoriz); - cA += buildang(shakeAngle); - cX += shakeX; - cY += shakeY; - cZ += shakeZ; - shakeX += shakeBobX; - shakeY += shakeBobY; + viewUpdateShake(cX, cY, cZ, cA, cH, shakeX, shakeY); cH += buildhoriz(MulScale(0x40000000 - Cos(gView->tiltEffect << 2), 30, 30)); if (gViewPos == 0) { @@ -686,7 +684,8 @@ void viewDrawScreen(bool sceneonly) fixedhoriz cH; int nSectnum; double zDelta; - SetupView(cX, cY, cZ, cA, cH, nSectnum, zDelta); + double shakeX, shakeY; + SetupView(cX, cY, cZ, cA, cH, nSectnum, zDelta, shakeX, shakeY); int tilt = interpolateang(gScreenTiltO, gScreenTilt, gInterpolate); uint8_t v14 = 0; diff --git a/source/games/blood/src/view.h b/source/games/blood/src/view.h index 1fbfdc83a..4e36ac1d4 100644 --- a/source/games/blood/src/view.h +++ b/source/games/blood/src/view.h @@ -153,7 +153,6 @@ void DoLensEffect(void); void UpdateDacs(int nPalette, bool bNoTint = false); void viewDrawScreen(bool sceneonly = false); void viewUpdateDelirium(void); -void viewUpdateShake(void); void viewSetSystemMessage(const char* pMessage, ...); inline void viewInterpolateSector(int nSector, sectortype *pSector)