From 4f4e6234d01e51345ef42de2ce806454e2173ff4 Mon Sep 17 00:00:00 2001 From: arafarn12 Date: Fri, 12 Jul 2019 04:15:48 +0700 Subject: [PATCH] fix bug calculate training settlers/chiefs when the village send settlers or chiefs as reinforcement more than 2 village, it Incorrect calculation --- GameEngine/Database.php | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/GameEngine/Database.php b/GameEngine/Database.php index e244372e..93f8869a 100755 --- a/GameEngine/Database.php +++ b/GameEngine/Database.php @@ -7164,22 +7164,16 @@ public function getAvailableExpansionTraining() { } } - $q = "SELECT (u10+u20+u30) FROM " . TB_PREFIX . "enforcement WHERE `from` = ".(int) $village->wid; + $q = "SELECT (u10+u20+u30) as sumsettlers FROM " . TB_PREFIX . "enforcement WHERE `from` = ".(int) $village->wid; $result = mysqli_query($this->dblink,$q); - $row = mysqli_fetch_row($result); - if(!empty($row)) { - foreach($row as $reinf) { - $settlers += $reinf[0]; - } + while($settlersrow = mysqli_fetch_array($result)) { + $settlers += $settlersrow["sumsettlers"]; } - $q = "SELECT (u9+u19+u29) FROM " . TB_PREFIX . "enforcement WHERE `from` = ".(int) $village->wid; + $q = "SELECT (u9+u19+u29) as sumchiefs FROM " . TB_PREFIX . "enforcement WHERE `from` = ".(int) $village->wid; $result = mysqli_query($this->dblink,$q); - $row = mysqli_fetch_row($result); - if(!empty($row)) { - foreach($row as $reinf) { - $chiefs += $reinf[0]; - } + while($chiefsrow = mysqli_fetch_array($result)) { + $chiefs += $chiefsrow["sumchiefs"]; } $trainlist = $technology->getTrainingList(4);