From c560e9bb08cbf4d8324c91a0a5d856f2de3c69f2 Mon Sep 17 00:00:00 2001 From: Pietro Date: Fri, 22 Feb 2019 12:57:09 +0100 Subject: [PATCH] Bug Fixes +Fixed culture points wrong calculation --- GameEngine/Automation.php | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php index fa6c5a7b..58190563 100644 --- a/GameEngine/Automation.php +++ b/GameEngine/Automation.php @@ -118,20 +118,20 @@ function recountCP($vid){ $vid = (int) $vid; $fdata = $database->getResourceLevel($vid); - $popTot = 0; + $cpTot = 0; for ($i = 1; $i <= 40; $i++) { $lvl = $fdata["f".$i]; $building = $fdata["f".$i."t"]; if($building){ - $popTot += $this->buildingCP($building,$lvl); + $cpTot += $this->buildingCP($building,$lvl); } } - $q = "UPDATE ".TB_PREFIX."vdata set cp = $popTot where wref = $vid"; + $q = "UPDATE ".TB_PREFIX."vdata set cp = $cpTot where wref = $vid"; mysqli_query($database->dblink,$q); - return $popTot; + return $cpTot; } function buildingPOP($f, $lvl){ @@ -150,14 +150,10 @@ function buildingPOP($f, $lvl){ function buildingCP($f, $lvl){ $name = "bid".$f; global $$name; - - $popT = 0; + $dataarray = $$name; - for ($i = 0; $i <= $lvl; $i++) { - $popT += ((isset($dataarray[$i]) && isset($dataarray[$i]['cp'])) ? $dataarray[$i]['cp'] : 0); - } - return $popT; + return ((isset($dataarray[$lvl]) && isset($dataarray[$lvl]['cp'])) ? $dataarray[$lvl]['cp'] : 0); } private function loyaltyRegeneration() {