From 9630f0f21fa96fd7d75bf7ed14b520518df54fce Mon Sep 17 00:00:00 2001 From: Wanne Date: Thu, 21 Jul 2011 13:58:50 +0000 Subject: [PATCH] BUGZILLA #548: Fixed crash (division to 0) when finishing training of mobile militia git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@4582 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Strategic/MilitiaSquads.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Strategic/MilitiaSquads.cpp b/Strategic/MilitiaSquads.cpp index ac54e9eb..111ebdde 100644 --- a/Strategic/MilitiaSquads.cpp +++ b/Strategic/MilitiaSquads.cpp @@ -203,7 +203,11 @@ void GenerateMilitiaSquad(INT16 sMapX, INT16 sMapY, INT16 sTMapX, INT16 sTMapY, ubBestLeadership = __min(ubBestLeadership, gGameExternalOptions.ubReqLeadershipForFullMobileTraining); ubBestLeadership -= gGameExternalOptions.ubMinimumLeadershipToTrainMobileMilitia; - UINT8 ubBestLeadershipPercentage = (ubBestLeadership * 100) / bRange; + UINT8 ubBestLeadershipPercentage = 0; + if (bRange > 0) + ubBestLeadershipPercentage = (ubBestLeadership * 100) / bRange; + else + bRange = 0; // There are five "grades", which in practice actually give a smooth transition from All-Green to All-Elite. // Please note that if elite training is disabled, all elites will later be converted to Regulars. In that case,