From 6c445969bf1d07541e6fc3dfaa4b693fba0a260f Mon Sep 17 00:00:00 2001 From: Martin Palko Date: Sun, 7 Jun 2020 16:51:59 -0400 Subject: [PATCH] Fixed reading of Punch and Kick damage values - Randomized reading of infantry punch and kick damage arrays provided a max value that one too high, and was our of the range of the array. --- TIBERIANDAWN/INFANTRY.CPP | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TIBERIANDAWN/INFANTRY.CPP b/TIBERIANDAWN/INFANTRY.CPP index 44f46a0..10f5064 100644 --- a/TIBERIANDAWN/INFANTRY.CPP +++ b/TIBERIANDAWN/INFANTRY.CPP @@ -2786,7 +2786,7 @@ RadioMessageType InfantryClass::Receive_Message(RadioClass * from, RadioMessageT ** Just received a kick! Take some damage. */ case RADIO_KICK: - damage = Infantry_Kick_Damage[Random_Pick(0, (int)(sizeof(Infantry_Kick_Damage) / sizeof(Infantry_Kick_Damage[0])))]; + damage = Infantry_Kick_Damage[Random_Pick(0, (int)(sizeof(Infantry_Kick_Damage) / sizeof(Infantry_Kick_Damage[0])) - 1)]; if (Take_Damage(damage, 0, WARHEAD_FOOT, this) == RESULT_DESTROYED) return(RADIO_STATIC); return(RADIO_ROGER); @@ -2794,7 +2794,7 @@ RadioMessageType InfantryClass::Receive_Message(RadioClass * from, RadioMessageT ** Just recieved a punch! Take some damage. */ case RADIO_PUNCH: - damage = Infantry_Punch_Damage[Random_Pick(0, (int)(sizeof(Infantry_Punch_Damage) / sizeof(Infantry_Punch_Damage[0])))]; + damage = Infantry_Punch_Damage[Random_Pick(0, (int)(sizeof(Infantry_Punch_Damage) / sizeof(Infantry_Punch_Damage[0])) - 1)]; if (Take_Damage(damage, 0, WARHEAD_FIST, this) == RESULT_DESTROYED) return(RADIO_STATIC); return(RADIO_ROGER);