From 69187353b9992dc703821f6834c981818ceab6ef Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Fri, 4 Aug 2017 06:48:48 -0700 Subject: [PATCH] Various fmadds related fixes (may be more) --- Runtime/CRandom16.hpp | 8 +++--- Runtime/MP1/MP1.cpp | 1 - Runtime/World/CFluidUVMotion.cpp | 42 ++++++++++++++++-------------- Runtime/World/CPlayerCameraBob.cpp | 23 ++++++++-------- Runtime/World/CScriptTimer.cpp | 2 +- 5 files changed, 39 insertions(+), 37 deletions(-) diff --git a/Runtime/CRandom16.hpp b/Runtime/CRandom16.hpp index a0f3851e3..aa055ac38 100644 --- a/Runtime/CRandom16.hpp +++ b/Runtime/CRandom16.hpp @@ -43,11 +43,9 @@ public: inline s32 Range(s32 min, s32 max) { - s32 diff = max - min; - s32 rand = -1; - while (rand < 0) - rand = s32((Next() << 16) | Next()); - return rand % diff + min; + s32 rnd = Next(); + s32 diff = (max - min) + 1; + return min + (rnd - ((rnd / diff) * diff)); } static CRandom16* GetRandomNumber() {return g_randomNumber;} diff --git a/Runtime/MP1/MP1.cpp b/Runtime/MP1/MP1.cpp index 4e308b0f4..a44dda42d 100644 --- a/Runtime/MP1/MP1.cpp +++ b/Runtime/MP1/MP1.cpp @@ -275,7 +275,6 @@ bool CMain::LoadAudio() void CMain::EnsureWorldPaksReady() { - } void CMain::EnsureWorldPakReady(ResId mlvl) diff --git a/Runtime/World/CFluidUVMotion.cpp b/Runtime/World/CFluidUVMotion.cpp index 9ee8968ff..3d824f70a 100644 --- a/Runtime/World/CFluidUVMotion.cpp +++ b/Runtime/World/CFluidUVMotion.cpp @@ -20,38 +20,42 @@ CFluidUVMotion::CFluidUVMotion(float, float) void CFluidUVMotion::CalculateFluidTextureOffset(float f31, float offsets[3][2]) { - float f29 = f31 * x4c_; - float f28 = f29 * zeus::fastCosF(x50_); - f29 = f29 / zeus::fastSinF(x50_); + float f28 = (f31 * x4c_) * zeus::fastCosF(x50_); + float f29 = (f31 * x4c_) / zeus::fastSinF(x50_); for (u32 i = 0 ; iFloat(); - x34_time = (x3c_maxRandDelay + x38_startTime) * rDt; + x34_time = (x3c_maxRandDelay * rDt) + x38_startTime; } void CScriptTimer::ApplyTime(float dt, CStateManager& mgr)