From d5bcc64206b06fb3aac5b47f6e8667d5101f614c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 20 Aug 2022 16:19:07 +0200 Subject: [PATCH] - Exhumed: AddFlash floatified --- source/games/exhumed/src/aistuff.h | 2 +- source/games/exhumed/src/bullet.cpp | 4 ++-- source/games/exhumed/src/exhumed.cpp | 2 +- source/games/exhumed/src/grenade.cpp | 2 +- source/games/exhumed/src/gun.cpp | 4 +--- source/games/exhumed/src/items.cpp | 2 +- source/games/exhumed/src/lighting.cpp | 19 ++++++------------- source/games/exhumed/src/object.cpp | 2 +- source/games/exhumed/src/player.cpp | 5 +---- source/games/exhumed/src/ramses.cpp | 2 +- source/games/exhumed/src/snake.cpp | 2 +- 11 files changed, 17 insertions(+), 29 deletions(-) diff --git a/source/games/exhumed/src/aistuff.h b/source/games/exhumed/src/aistuff.h index c5dead0c1..844c37b87 100644 --- a/source/games/exhumed/src/aistuff.h +++ b/source/games/exhumed/src/aistuff.h @@ -177,7 +177,7 @@ void FuncLava(int, int, int, int); void InitLights(); -void AddFlash(sectortype* pSector, int x, int y, int z, int val); +void AddFlash(sectortype* pSector, const DVector3& pos, int val); void SetTorch(int nPlayer, int bTorchOnOff); void UndoFlashes(); void DoLights(); diff --git a/source/games/exhumed/src/bullet.cpp b/source/games/exhumed/src/bullet.cpp index f52d7af94..9eecb3366 100644 --- a/source/games/exhumed/src/bullet.cpp +++ b/source/games/exhumed/src/bullet.cpp @@ -408,7 +408,7 @@ MOVEEND: if (nVal == 0 && nType != 15 && nType != 3) { - AddFlash(pActor->sector(), pActor->int_pos().X, pActor->int_pos().Y, pActor->int_pos().Z, 0); + AddFlash(pActor->sector(), pActor->spr.pos, 0); if (pActor->spr.pal != 5) { pActor->spr.pal = 1; @@ -534,7 +534,7 @@ HITSPRITE: nRadialBullet = -1; - AddFlash(pActor->sector(), pActor->int_pos().X, pActor->int_pos().Y, pActor->int_pos().Z, 128); + AddFlash(pActor->sector(), pActor->spr.pos, 128); } } } diff --git a/source/games/exhumed/src/exhumed.cpp b/source/games/exhumed/src/exhumed.cpp index d104574d2..103e57bc9 100644 --- a/source/games/exhumed/src/exhumed.cpp +++ b/source/games/exhumed/src/exhumed.cpp @@ -209,7 +209,7 @@ void DoRedAlert(int nVal) if (nVal) { PlayFXAtXYZ(StaticSound[kSoundAlarm], ac->int_pos().X, ac->int_pos().Y, ac->int_pos().Z); - AddFlash(ac->sector(), ac->int_pos().X, ac->int_pos().Y, ac->int_pos().Z, 192); + AddFlash(ac->sector(), ac->spr.pos, 192); } } } diff --git a/source/games/exhumed/src/grenade.cpp b/source/games/exhumed/src/grenade.cpp index 61194f690..d4477a4ae 100644 --- a/source/games/exhumed/src/grenade.cpp +++ b/source/games/exhumed/src/grenade.cpp @@ -191,7 +191,7 @@ void ExplodeGrenade(DExhumedActor* pActor) runlist_RadialDamageEnemy(pActor, nDamage, BulletInfo[kWeaponGrenade].nRadius); BuildAnim(nullptr, var_28, 0, pActor->spr.pos, pActor->sector(), var_20, 4); - AddFlash(pActor->sector(), pActor->int_pos().X, pActor->int_pos().Y, pActor->int_pos().Z, 128); + AddFlash(pActor->sector(), pActor->spr.pos, 128); DestroyGrenade(pActor); } diff --git a/source/games/exhumed/src/gun.cpp b/source/games/exhumed/src/gun.cpp index 3a51c7417..f8ab4a1f5 100644 --- a/source/games/exhumed/src/gun.cpp +++ b/source/games/exhumed/src/gun.cpp @@ -601,9 +601,7 @@ loc_flag: BuildFlash(nPlayer, 512); AddFlash( pPlayerActor->sector(), - pPlayerActor->int_pos().X, - pPlayerActor->int_pos().Y, - pPlayerActor->int_pos().Z, + pPlayerActor->spr.pos, 0); } diff --git a/source/games/exhumed/src/items.cpp b/source/games/exhumed/src/items.cpp index b23d8770e..239d88055 100644 --- a/source/games/exhumed/src/items.cpp +++ b/source/games/exhumed/src/items.cpp @@ -345,7 +345,7 @@ void DropMagic(DExhumedActor* pActor) if (pAnimActor) { - AddFlash(pAnimActor->sector(), pAnimActor->int_pos().X, pAnimActor->int_pos().Y, pAnimActor->int_pos().Z, 128); + AddFlash(pAnimActor->sector(), pAnimActor->spr.pos, 128); ChangeActorStat(pAnimActor, 950); } nMagicCount = RandomSize(2); diff --git a/source/games/exhumed/src/lighting.cpp b/source/games/exhumed/src/lighting.cpp index 361430231..b87cb9b27 100644 --- a/source/games/exhumed/src/lighting.cpp +++ b/source/games/exhumed/src/lighting.cpp @@ -226,7 +226,7 @@ void InitLights() nLastFlash = -1; } -void AddFlash(sectortype* pSector, int x, int y, int z, int val) +void AddFlash(sectortype* pSector, const DVector3& pos, int val) { int var_28 = 0; int var_1C = val >> 8; @@ -254,7 +254,7 @@ void AddFlash(sectortype* pSector, int x, int y, int z, int val) if (!var_18) { - walldist = (int)sqrt(SquareDistToWall(x * inttoworld, y * inttoworld, &wal)) - 255; + walldist = (int)sqrt(SquareDistToWall(pos.X, pos.Y, &wal)) - 255; } if (walldist < 0) @@ -281,7 +281,7 @@ void AddFlash(sectortype* pSector, int x, int y, int z, int val) if (!var_1C && !wal.overpicnum && pNextSector) { - AddFlash(pNextSector, x, y, z, val); + AddFlash(pNextSector, pos, val); } } } @@ -353,17 +353,10 @@ void AddFlash(sectortype* pSector, int x, int y, int z, int val) if (!var_18) { - int xDiff = x - pActor->int_pos().X; - if (xDiff < 0) { - xDiff = -xDiff; - } + double xDiff = fabs(pos.X - pActor->spr.pos.X); + double yDiff = fabs(pos.Y - pActor->spr.pos.Y); - int yDiff = y - pActor->int_pos().Y; - if (yDiff < 0) { - yDiff = -yDiff; - } - - eax = ((xDiff + yDiff) >> 4) - 255; + eax += int(xDiff + yDiff); } if (eax < 0) diff --git a/source/games/exhumed/src/object.cpp b/source/games/exhumed/src/object.cpp index 4433f0c34..4b9e0a1a4 100644 --- a/source/games/exhumed/src/object.cpp +++ b/source/games/exhumed/src/object.cpp @@ -1930,7 +1930,7 @@ void AIObject::Tick(RunListEvent* ev) var_18 = 34; } - AddFlash(pActor->sector(), pActor->int_pos().X, pActor->int_pos().Y, pActor->int_pos().Z, 128); + AddFlash(pActor->sector(), pActor->spr.pos, 128); BuildAnim(nullptr, var_18, 0, DVector3(pActor->spr.pos.XY(), pActor->sector()->floorz), pActor->sector(), 240, 4); // int edi = nSprite | 0x4000; diff --git a/source/games/exhumed/src/player.cpp b/source/games/exhumed/src/player.cpp index 57c7cc9ea..e59bfbf08 100644 --- a/source/games/exhumed/src/player.cpp +++ b/source/games/exhumed/src/player.cpp @@ -772,10 +772,7 @@ void AIPlayer::Tick(RunListEvent* ev) if (nPlayer != nLocalPlayer) { nFlashDepth = 5; - AddFlash(pPlayerActor->sector(), - pPlayerActor->int_pos().X, - pPlayerActor->int_pos().Y, - pPlayerActor->int_pos().Z, 0); + AddFlash(pPlayerActor->sector(), pPlayerActor->spr.pos, 0); } } } diff --git a/source/games/exhumed/src/ramses.cpp b/source/games/exhumed/src/ramses.cpp index 7ca4e7fe2..adf3b2c50 100644 --- a/source/games/exhumed/src/ramses.cpp +++ b/source/games/exhumed/src/ramses.cpp @@ -426,7 +426,7 @@ void DoSpiritHead() if (nCount < (15 * nPixels) / 16) { SoundBigEntrance(); AddGlow(pSpiritSpr->sector(), 20); - AddFlash(pSpiritSpr->sector(), pSpiritSpr->int_pos().X, pSpiritSpr->int_pos().Y, pSpiritSpr->int_pos().Z, 128); + AddFlash(pSpiritSpr->sector(), pSpiritSpr->spr.pos, 128); nHeadStage = 3; TintPalette(255, 255, 255); CopyHeadToWorkTile(kTileRamsesNormal); diff --git a/source/games/exhumed/src/snake.cpp b/source/games/exhumed/src/snake.cpp index 56d0877f9..98b3a67e4 100644 --- a/source/games/exhumed/src/snake.cpp +++ b/source/games/exhumed/src/snake.cpp @@ -119,7 +119,7 @@ void ExplodeSnakeSprite(DExhumedActor* pActor, int nPlayer) BuildAnim(nullptr, 23, 0, pActor->spr.pos, pActor->sector(), 40, 4); - AddFlash(pActor->sector(), pActor->int_pos().X, pActor->int_pos().Y, pActor->int_pos().Z, 128); + AddFlash(pActor->sector(), pActor->spr.pos, 128); StopActorSound(pActor); }