From e84a0f3245160674e35aaee6a449a7471d7329bb Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Wed, 7 Sep 2022 17:58:41 +1000 Subject: [PATCH] - Exhumed: Floatify `nQuake[]` array. --- source/games/exhumed/src/gun.cpp | 4 ++-- source/games/exhumed/src/move.cpp | 34 +++++++---------------------- source/games/exhumed/src/object.cpp | 2 +- source/games/exhumed/src/player.cpp | 4 ++-- source/games/exhumed/src/view.cpp | 6 ++--- source/games/exhumed/src/view.h | 2 +- 6 files changed, 17 insertions(+), 35 deletions(-) diff --git a/source/games/exhumed/src/gun.cpp b/source/games/exhumed/src/gun.cpp index c6303c987..b123c68ee 100644 --- a/source/games/exhumed/src/gun.cpp +++ b/source/games/exhumed/src/gun.cpp @@ -775,7 +775,7 @@ loc_flag: case kWeaponM60: { if (nWeapon == kWeaponM60) { // hack(?) to do fallthrough from kWeapon3 into kWeaponPistol without doing the nQuake[] change - nQuake[nPlayer] = 128; + nQuake[nPlayer] = 0.5; } // fall through [[fallthrough]]; @@ -812,7 +812,7 @@ loc_flag: case kWeaponStaff: { BuildSnake(nPlayer, nHeight); - nQuake[nPlayer] = 512; + nQuake[nPlayer] = 2.; PlayerList[nPlayer].nDamage.X -= bcos(pPlayerActor->int_ang(), 9); PlayerList[nPlayer].nDamage.Y -= bsin(pPlayerActor->int_ang(), 9); diff --git a/source/games/exhumed/src/move.cpp b/source/games/exhumed/src/move.cpp index cb377998f..5859d730a 100644 --- a/source/games/exhumed/src/move.cpp +++ b/source/games/exhumed/src/move.cpp @@ -1047,39 +1047,20 @@ void MoveSector(sectortype* pSector, int nAngle, int *nXVel, int *nYVel) void SetQuake(DExhumedActor* pActor, int nVal) { - int x = pActor->int_pos().X; - int y = pActor->int_pos().Y; - - nVal *= 256; - for (int i = 0; i < nTotalPlayers; i++) { - auto pPlayerActor = PlayerList[i].pActor; - - - uint32_t xDiff = abs((int32_t)((pPlayerActor->int_pos().X - x) >> 8)); - uint32_t yDiff = abs((int32_t)((pPlayerActor->int_pos().Y - y) >> 8)); - - uint32_t sqrtNum = xDiff * xDiff + yDiff * yDiff; - - if (sqrtNum > INT_MAX) - { - DPrintf(DMSG_WARNING, "%s %d: overflow\n", __func__, __LINE__); - sqrtNum = INT_MAX; - } - - int nSqrt = ksqrt(sqrtNum); - - int eax = nVal; + auto nSqrt = ((PlayerList[i].pActor->spr.pos.XY() - pActor->spr.pos.XY()) * (1. / 16.)).Length(); + double eax = nVal; if (nSqrt) { eax = eax / nSqrt; - if (eax >= 256) + if (eax >= 1) { - if (eax > 3840) { - eax = 3840; + if (eax > 15) + { + eax = 15; } } else @@ -1088,7 +1069,8 @@ void SetQuake(DExhumedActor* pActor, int nVal) } } - if (eax > nQuake[i]) { + if (eax > nQuake[i]) + { nQuake[i] = eax; } } diff --git a/source/games/exhumed/src/object.cpp b/source/games/exhumed/src/object.cpp index 6b255cd2b..e9b51a835 100644 --- a/source/games/exhumed/src/object.cpp +++ b/source/games/exhumed/src/object.cpp @@ -1509,7 +1509,7 @@ void DoFinale() PlayFX2(StaticSound[kSound78] | 0x2000, pFinaleSpr); for (int i = 0; i < nTotalPlayers; i++) { - nQuake[i] = 1280; + nQuake[i] = 5.; } } } diff --git a/source/games/exhumed/src/player.cpp b/source/games/exhumed/src/player.cpp index b4359614c..510932883 100644 --- a/source/games/exhumed/src/player.cpp +++ b/source/games/exhumed/src/player.cpp @@ -815,7 +815,7 @@ void AIPlayer::Tick(RunListEvent* ev) nQuake[nPlayer] = -nQuake[nPlayer]; if (nQuake[nPlayer] > 0) { - nQuake[nPlayer] -= 512; + nQuake[nPlayer] -= 2.; if (nQuake[nPlayer] < 0) nQuake[nPlayer] = 0; } @@ -1080,7 +1080,7 @@ sectdone: auto pViewSect = pPlayerActor->sector(); - double EyeZ = PlayerList[nPlayer].eyelevel + pPlayerActor->spr.pos.Z + nQuake[nPlayer] * zinttoworld; + double EyeZ = PlayerList[nPlayer].eyelevel + pPlayerActor->spr.pos.Z + nQuake[nPlayer]; while (1) { diff --git a/source/games/exhumed/src/view.cpp b/source/games/exhumed/src/view.cpp index 3c7cc0d91..d8ec734cf 100644 --- a/source/games/exhumed/src/view.cpp +++ b/source/games/exhumed/src/view.cpp @@ -40,7 +40,7 @@ int16_t dVertPan[kMaxPlayers]; DVector3 nCamerapos; bool bTouchFloor; -int16_t nQuake[kMaxPlayers] = { 0 }; +double nQuake[kMaxPlayers] = { 0 }; int nChunkTotal = 0; @@ -252,8 +252,8 @@ void DrawView(double interpfrac, bool sceneonly) } else { - nCamerapos.Z = min(nCamerapos.Z + nQuake[nLocalPlayer] * zinttoworld, pPlayerActor->sector()->floorz); - nCameraang += DAngle::fromBam((nQuake[nLocalPlayer] % 4095) << 14); + nCamerapos.Z = min(nCamerapos.Z + nQuake[nLocalPlayer], pPlayerActor->sector()->floorz); + nCameraang += DAngle::fromDeg(fmod(nQuake[nLocalPlayer], 16.) * (45. / 128.)); if (bCamera) { diff --git a/source/games/exhumed/src/view.h b/source/games/exhumed/src/view.h index 4b4caafb1..d3f6c303e 100644 --- a/source/games/exhumed/src/view.h +++ b/source/games/exhumed/src/view.h @@ -32,7 +32,7 @@ void NoClip(); void Clip(); extern int16_t dVertPan[]; -extern int16_t nQuake[]; +extern double nQuake[]; extern DVector3 nCamerapos; extern bool bTouchFloor; extern int nChunkTotal;