From fe845d7e12085e6b0b4fc17dd841b9b4f82d5058 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 21 Nov 2020 15:45:37 +0100 Subject: [PATCH] - renamed some of those annoying 'atxx' variables. --- source/blood/src/blood.cpp | 2 +- source/blood/src/choke.cpp | 65 ++++++++++++++++++------------------- source/blood/src/choke.h | 40 +++++++++++------------ source/blood/src/d_menu.cpp | 16 ++++----- source/blood/src/nnexts.cpp | 8 ++--- source/blood/src/qav.cpp | 2 +- source/blood/src/qav.h | 2 +- source/blood/src/weapon.cpp | 10 +++--- 8 files changed, 72 insertions(+), 73 deletions(-) diff --git a/source/blood/src/blood.cpp b/source/blood/src/blood.cpp index 3334a8186..a8a97bc44 100644 --- a/source/blood/src/blood.cpp +++ b/source/blood/src/blood.cpp @@ -330,7 +330,7 @@ void GameInterface::Ticker() gChokeCounter += CHOKERATE; while (gChokeCounter >= COUNTRATE) { - gChoke.at1c(gMe); + gChoke.callback(gMe); gChokeCounter -= COUNTRATE; } } diff --git a/source/blood/src/choke.cpp b/source/blood/src/choke.cpp index 3e0578f73..60aa2ad26 100644 --- a/source/blood/src/choke.cpp +++ b/source/blood/src/choke.cpp @@ -37,49 +37,48 @@ BEGIN_BLD_NS void CChoke::init(int a1, void(*a2)(PLAYER*)) { - TotalKills = NULL; - at1c = a2; - if (!at8 && a1 != -1) - { - at8 = getQAV(a1); - if (!at8) - I_Error("Could not load QAV %d\n", a1); - at8->nSprite = -1; - at8->x = at14; - at8->y = at18; - //at8->Preload(); - atc = at8->at10; - at10 = 0; - } + TotalKills = nullptr; + callback = a2; + if (!qav && a1 != -1) + { + qav = getQAV(a1); + if (!qav) + I_Error("Could not load QAV %d\n", a1); + qav->nSprite = -1; + qav->x = x; + qav->y = y; + duration = qav->duration; + time = 0; + } } void CChoke::animateChoke(int x, int y, int smoothratio) { - if (!at8) - return; - int myclock = gFrameClock + mulscale16(4, smoothratio); - at8->x = x; - at8->y = y; - int vd = myclock-at10; - at10 = myclock; - atc -= vd; - if (atc <= 0 || atc > at8->at10) - atc = at8->at10; - int vdi = at8->at10-atc; - at8->Play(vdi-vd, vdi, -1, NULL); + if (!qav) + return; + int myclock = gFrameClock + mulscale16(4, smoothratio); + qav->x = x; + qav->y = y; + int vd = myclock - time; + time = myclock; + duration -= vd; + if (duration <= 0 || duration > qav->duration) + duration = qav->duration; + int vdi = qav->duration - duration; + 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 - at8->Draw(vdi, 10, 0, 0, true); + qav->Draw(vdi, 10, 0, 0, true); } -void sub_84230(PLAYER *pPlayer) +void sub_84230(PLAYER* pPlayer) { - int t = gGameOptions.nDifficulty+2; - if (pPlayer->handTime < 64) - pPlayer->handTime = ClipHigh(pPlayer->handTime+t, 64); - if (pPlayer->handTime > (7-gGameOptions.nDifficulty)*5) - pPlayer->blindEffect = ClipHigh(pPlayer->blindEffect+t*4, 128); + int t = gGameOptions.nDifficulty + 2; + if (pPlayer->handTime < 64) + pPlayer->handTime = min(pPlayer->handTime + t, 64); + if (pPlayer->handTime > (7 - gGameOptions.nDifficulty) * 5) + pPlayer->blindEffect = min(pPlayer->blindEffect + t * 4, 128); } CChoke gChoke; diff --git a/source/blood/src/choke.h b/source/blood/src/choke.h index f874a7063..283bc0279 100644 --- a/source/blood/src/choke.h +++ b/source/blood/src/choke.h @@ -31,26 +31,26 @@ BEGIN_BLD_NS class CChoke { public: - CChoke() - { - TotalKills = NULL; - at8 = NULL; - atc = 0; - at10 = 0; - at1c = NULL; - at14 = 0; - at18 = 0; - }; - void init(int a1, void(*a2)(PLAYER*)); - void animateChoke(int x, int y, int smoothratio); - void reset() { at10 = 0; } - char *TotalKills; - QAV *at8; - int atc; - int at10; - int at14; - int at18; - void(*at1c)(PLAYER *); + CChoke() + { + TotalKills = nullptr; + qav = nullptr; + duration = 0; + time = 0; + callback = nullptr; + x = 0; + y = 0; + }; + void init(int a1, void(*a2)(PLAYER*)); + void animateChoke(int x, int y, int smoothratio); + void reset() { time = 0; } + char* TotalKills; + QAV* qav; + int duration; + int time; + int x; + int y; + void(*callback)(PLAYER*); }; void sub_84230(PLAYER*); diff --git a/source/blood/src/d_menu.cpp b/source/blood/src/d_menu.cpp index 36e05073d..1c9ca4d6e 100644 --- a/source/blood/src/d_menu.cpp +++ b/source/blood/src/d_menu.cpp @@ -49,7 +49,7 @@ class CGameMenuItemQAV public: int m_nX, m_nY; TArray raw; - int at2c; + int duration; int lastTick; bool bWideScreen; bool bClearBackground; @@ -75,7 +75,7 @@ CGameMenuItemQAV::CGameMenuItemQAV(int a3, int a4, const char* name, bool widesc data->x = m_nX; data->y = m_nY; data->Preload(); - at2c = data->at10; + duration = data->duration; lastTick = I_GetBuildTime(); } } @@ -94,12 +94,12 @@ void CGameMenuItemQAV::Draw(void) gFrameClock = currentclock; int nTicks = currentclock - lastTick; lastTick = currentclock; - at2c -= nTicks; - if (at2c <= 0 || at2c > data->at10) + duration -= nTicks; + if (duration <= 0 || duration > data->duration) { - at2c = data->at10; + duration = data->duration; } - data->Play(data->at10 - at2c - nTicks, data->at10 - at2c, -1, NULL); + data->Play(data->duration - duration - nTicks, data->duration - duration, -1, NULL); if (bWideScreen) { @@ -108,13 +108,13 @@ void CGameMenuItemQAV::Draw(void) int backX = data->x; for (int i = 0; i < nCount; i++) { - data->Draw(data->at10 - at2c, 10 + kQavOrientationLeft, 0, 0, false); + data->Draw(data->duration - duration, 10 + kQavOrientationLeft, 0, 0, false); data->x += 320; } data->x = backX; } else - data->Draw(data->at10 - at2c, 10, 0, 0, false); + data->Draw(data->duration - duration, 10, 0, 0, false); gFrameClock = backFC; } diff --git a/source/blood/src/nnexts.cpp b/source/blood/src/nnexts.cpp index b69ddad14..2e5630940 100644 --- a/source/blood/src/nnexts.cpp +++ b/source/blood/src/nnexts.cpp @@ -1328,7 +1328,7 @@ void trPlayerCtrlStartScene(XSPRITE* pXSource, PLAYER* pPlayer, bool force) { if (nIndex < 0) WeaponLower(pPlayer); - pXSource->sysData1 = ClipLow((pQav->at10 * pXSource->waitTime) / 4, 0); // how many times animation should be played + pXSource->sysData1 = ClipLow((pQav->duration * pXSource->waitTime) / 4, 0); // how many times animation should be played pCtrl->qavScene.index = nSource; pCtrl->qavScene.qavResrc = pQav; @@ -1337,7 +1337,7 @@ void trPlayerCtrlStartScene(XSPRITE* pXSource, PLAYER* pPlayer, bool force) { pCtrl->qavScene.qavResrc->Preload(); pPlayer->sceneQav = pXSource->data2; - pPlayer->weaponTimer = pCtrl->qavScene.qavResrc->at10; + pPlayer->weaponTimer = pCtrl->qavScene.qavResrc->duration; pPlayer->qavCallback = (pXSource->data3 > 0) ? ClipRange(pXSource->data3 - 1, 0, 32) : -1; pPlayer->qavLoop = false; @@ -4843,7 +4843,7 @@ void playerQavSceneDraw(PLAYER* pPlayer, int a2, double a3, double a4, int a5, i if (pQavScene->qavResrc != NULL) { QAV* pQAV = pQavScene->qavResrc; - int v4 = (pPlayer->weaponTimer == 0) ? ((gFrameClock + mulscale16(4, smoothratio)) % pQAV->at10) : pQAV->at10 - pPlayer->weaponTimer; + int v4 = (pPlayer->weaponTimer == 0) ? ((gFrameClock + mulscale16(4, smoothratio)) % pQAV->duration) : pQAV->duration - pPlayer->weaponTimer; int flags = 2; int nInv = powerupCheck(pPlayer, kPwUpShadowCloak); if (nInv >= 120 * 8 || (nInv != 0 && (gFrameClock & 32))) { @@ -4877,7 +4877,7 @@ void playerQavScenePlay(PLAYER* pPlayer) { if (pQavScene->qavResrc != NULL) { QAV* pQAV = pQavScene->qavResrc; pQAV->nSprite = pPlayer->pSprite->index; - int nTicks = pQAV->at10 - pPlayer->weaponTimer; + int nTicks = pQAV->duration - pPlayer->weaponTimer; pQAV->Play(nTicks - 4, nTicks, pPlayer->qavCallback, pPlayer); } } diff --git a/source/blood/src/qav.cpp b/source/blood/src/qav.cpp index a55f11da2..1c3923a26 100644 --- a/source/blood/src/qav.cpp +++ b/source/blood/src/qav.cpp @@ -189,7 +189,7 @@ void ByteSwapQAV(void* p) QAV* qav = (QAV*)p; qav->nFrames = LittleLong(qav->nFrames); qav->ticksPerFrame = LittleLong(qav->ticksPerFrame); - qav->at10 = LittleLong(qav->at10); + qav->version = LittleLong(qav->version); qav->x = LittleLong(qav->x); qav->y = LittleLong(qav->y); qav->nSprite = LittleLong(qav->nSprite); diff --git a/source/blood/src/qav.h b/source/blood/src/qav.h index 6085b5c11..7e2e5a1bd 100644 --- a/source/blood/src/qav.h +++ b/source/blood/src/qav.h @@ -75,7 +75,7 @@ struct QAV char pad1[8]; // 0 int nFrames; // 8 int ticksPerFrame; // C - int at10; // 10 + int duration; // 10 int x; // 14 int y; // 18 int nSprite; // 1c diff --git a/source/blood/src/weapon.cpp b/source/blood/src/weapon.cpp index da6b6ba7b..0b7878034 100644 --- a/source/blood/src/weapon.cpp +++ b/source/blood/src/weapon.cpp @@ -240,9 +240,9 @@ void WeaponDraw(PLAYER *pPlayer, int a2, double a3, double a4, int a5, int smoot QAV * pQAV = weaponQAV[pPlayer->weaponQav]; int v4; if (pPlayer->weaponTimer == 0) - v4 = (gFrameClock + mulscale16(4, smoothratio)) % pQAV->at10; + v4 = (gFrameClock + mulscale16(4, smoothratio)) % pQAV->duration; else - v4 = pQAV->at10 - pPlayer->weaponTimer; + v4 = pQAV->duration - pPlayer->weaponTimer; pQAV->x = int(a3); pQAV->y = int(a4); int flags = 2; @@ -262,7 +262,7 @@ void WeaponPlay(PLAYER *pPlayer) return; QAV *pQAV = weaponQAV[pPlayer->weaponQav]; pQAV->nSprite = pPlayer->pSprite->index; - int nTicks = pQAV->at10 - pPlayer->weaponTimer; + int nTicks = pQAV->duration - pPlayer->weaponTimer; pQAV->Play(nTicks-4, nTicks, pPlayer->qavCallback, pPlayer); } @@ -270,7 +270,7 @@ void StartQAV(PLAYER *pPlayer, int nWeaponQAV, int a3, char a4) { assert(nWeaponQAV < kQAVEnd); pPlayer->weaponQav = nWeaponQAV; - pPlayer->weaponTimer = weaponQAV[nWeaponQAV]->at10; + pPlayer->weaponTimer = weaponQAV[nWeaponQAV]->duration; pPlayer->qavCallback = a3; pPlayer->qavLoop = a4; weaponQAV[nWeaponQAV]->Preload(); @@ -1977,7 +1977,7 @@ void WeaponProcess(PLAYER *pPlayer) { if (bShoot && CheckAmmo(pPlayer, pPlayer->weaponAmmo, 1)) { while (pPlayer->weaponTimer <= 0) - pPlayer->weaponTimer += weaponQAV[pPlayer->weaponQav]->at10; + pPlayer->weaponTimer += weaponQAV[pPlayer->weaponQav]->duration; } else {