Browse Source

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.
pull/2307/head
ephphatha 5 years ago committed by Anders Jenbo
parent
commit
51d05a3523
  1. 4
      Source/monster.cpp

4
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)

Loading…
Cancel
Save