diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php index 58190563..a0b1cf03 100644 --- a/GameEngine/Automation.php +++ b/GameEngine/Automation.php @@ -104,7 +104,7 @@ function recountPop($vid, $use_cache = true){ if($building) $popTot += $this->buildingPOP($building, $lvl); } - $this->recountCP($vid); + Building::recountCP($database, $vid); $q = "UPDATE ".TB_PREFIX."vdata set pop = $popTot where wref = $vid"; mysqli_query($database->dblink, $q); $owner = $database->getVillageField($vid, "owner"); @@ -113,27 +113,6 @@ function recountPop($vid, $use_cache = true){ return $popTot; } - function recountCP($vid){ - global $database; - - $vid = (int) $vid; - $fdata = $database->getResourceLevel($vid); - $cpTot = 0; - - for ($i = 1; $i <= 40; $i++) { - $lvl = $fdata["f".$i]; - $building = $fdata["f".$i."t"]; - if($building){ - $cpTot += $this->buildingCP($building,$lvl); - } - } - - $q = "UPDATE ".TB_PREFIX."vdata set cp = $cpTot where wref = $vid"; - mysqli_query($database->dblink,$q); - - return $cpTot; - } - function buildingPOP($f, $lvl){ $name = "bid".$f; global $$name; @@ -147,15 +126,6 @@ function buildingPOP($f, $lvl){ return $popT; } - function buildingCP($f, $lvl){ - $name = "bid".$f; - global $$name; - - $dataarray = $$name; - - return ((isset($dataarray[$lvl]) && isset($dataarray[$lvl]['cp'])) ? $dataarray[$lvl]['cp'] : 0); - } - private function loyaltyRegeneration() { global $database;