From 51d05a3523fe560845b58df485c02b0e54e3e792 Mon Sep 17 00:00:00 2001 From: ephphatha Date: Mon, 5 Jul 2021 21:07:48 +1000 Subject: [PATCH] Reorder monster damage calculations to avoid warnings This was giving type conversion warnings for the forced int > double > int conversion. The int + int operation in the middle was also flagged as it gets upcast during the multiplication (despite the values always being well within the range of an int) so using long constants there to avoid it. --- Source/monster.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/monster.cpp b/Source/monster.cpp index a4d5c4e94..b55351515 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -2066,7 +2066,7 @@ void M_TryH2HHit(int i, int pnum, int hit, int minDam, int maxDam) dam += plr[pnum]._pIGetHit << 6; if (dam < 64) dam = 64; - int mdam = dam * (0.01 * (GenerateRnd(10) + 20)); + int mdam = dam * (GenerateRnd(10) + 20L) / 100; monster[i]._mhitpoints -= mdam; dam -= mdam; if (dam < 0) @@ -2111,7 +2111,7 @@ void M_TryH2HHit(int i, int pnum, int hit, int minDam, int maxDam) if (pnum == myplr) { if (plr[pnum].wReflections > 0) { plr[pnum].wReflections--; - int mdam = dam * (0.01 * (GenerateRnd(10) + 20)); + int mdam = dam * (GenerateRnd(10) + 20L) / 100; monster[i]._mhitpoints -= mdam; dam -= mdam; if (dam < 0)