From 7b288c5c838981a061ac02bc4fe88a6ac67f8060 Mon Sep 17 00:00:00 2001 From: silversurfer Date: Fri, 27 May 2016 11:08:22 +0000 Subject: [PATCH] Fix (by Sevenfm): - Armor search routine could crash if EffectiveArmour returns 0 git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8241 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- GameVersion.cpp | 16 ++++++++-------- Tactical/Weapons.cpp | 2 +- TacticalAI/FindLocations.cpp | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/GameVersion.cpp b/GameVersion.cpp index 62338eb2..1025cf6b 100644 --- a/GameVersion.cpp +++ b/GameVersion.cpp @@ -15,9 +15,9 @@ #ifdef JA2EDITOR #ifdef JA2UB - CHAR16 zVersionLabel[256] = { L"Unfinished Business - Map Editor v1.13.8240 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Unfinished Business - Map Editor v1.13.8241 (Development Build)" }; #else - CHAR16 zVersionLabel[256] = { L"Map Editor v1.13.8240 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Map Editor v1.13.8241 (Development Build)" }; #endif // ------------------------------ @@ -27,11 +27,11 @@ //DEBUG BUILD VERSION #ifdef JA2UB - CHAR16 zVersionLabel[256] = { L"Debug: Unfinished Business - v1.13.8240 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Debug: Unfinished Business - v1.13.8241 (Development Build)" }; #elif defined (JA113DEMO) - CHAR16 zVersionLabel[256] = { L"Debug: JA2 Demo - v1.13.8240 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Debug: JA2 Demo - v1.13.8241 (Development Build)" }; #else - CHAR16 zVersionLabel[256] = { L"Debug: v1.13.8240 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Debug: v1.13.8241 (Development Build)" }; #endif #elif defined CRIPPLED_VERSION @@ -46,11 +46,11 @@ //RELEASE BUILD VERSION #ifdef JA2UB - CHAR16 zVersionLabel[256] = { L"Release Unfinished Business - v1.13.8240 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Release Unfinished Business - v1.13.8241 (Development Build)" }; #elif defined (JA113DEMO) - CHAR16 zVersionLabel[256] = { L"Release JA2 Demo - v1.13.8240 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Release JA2 Demo - v1.13.8241 (Development Build)" }; #else - CHAR16 zVersionLabel[256] = { L"Release v1.13.8240 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Release v1.13.8241 (Development Build)" }; #endif #endif diff --git a/Tactical/Weapons.cpp b/Tactical/Weapons.cpp index 9eb294c0..fd334143 100644 --- a/Tactical/Weapons.cpp +++ b/Tactical/Weapons.cpp @@ -1011,7 +1011,7 @@ INT32 EffectiveArmour( OBJECTTYPE * pObj ) iValue += iValue2; } } - return( max(iValue,1) ); + return( max(iValue,0) ); } //zwwooooo - IoV: Lbe can be bulletproof after adding bulletproof plate into it.(Like CRIAS, MBSS, HSGI WASATCH...) diff --git a/TacticalAI/FindLocations.cpp b/TacticalAI/FindLocations.cpp index b0f84500..aba17996 100644 --- a/TacticalAI/FindLocations.cpp +++ b/TacticalAI/FindLocations.cpp @@ -1992,7 +1992,7 @@ INT8 SearchForItems( SOLDIERTYPE * pSoldier, INT8 bReason, UINT16 usItem ) } else if ( EffectiveArmour( &(pSoldier->inv[HELMETPOS]) ) < EffectiveArmour( pObj ) ) { - iTempValue = 100 * EffectiveArmour( pObj ) / EffectiveArmour( &(pSoldier->inv[HELMETPOS]) ); + iTempValue = 100 * EffectiveArmour( pObj ) / (EffectiveArmour( &(pSoldier->inv[HELMETPOS]) ) + 1); } break; case ARMOURCLASS_VEST: @@ -2002,7 +2002,7 @@ INT8 SearchForItems( SOLDIERTYPE * pSoldier, INT8 bReason, UINT16 usItem ) } else if ( EffectiveArmour( &(pSoldier->inv[VESTPOS]) ) < EffectiveArmour( pObj ) ) { - iTempValue = 100 * EffectiveArmour( pObj ) / EffectiveArmour( &(pSoldier->inv[VESTPOS]) ); + iTempValue = 100 * EffectiveArmour( pObj ) / (EffectiveArmour( &(pSoldier->inv[VESTPOS]) ) + 1); } break; case ARMOURCLASS_LEGGINGS: @@ -2012,7 +2012,7 @@ INT8 SearchForItems( SOLDIERTYPE * pSoldier, INT8 bReason, UINT16 usItem ) } else if ( EffectiveArmour( &(pSoldier->inv[LEGPOS]) ) < EffectiveArmour( pObj ) ) { - iTempValue = 100 * EffectiveArmour( pObj ) / EffectiveArmour( &(pSoldier->inv[LEGPOS]) ); + iTempValue = 100 * EffectiveArmour( pObj ) / (EffectiveArmour( &(pSoldier->inv[LEGPOS]) ) + 1); } break; default: