Skip to content

Commit

Permalink
Bug Fixes
Browse files Browse the repository at this point in the history
+Fixed culture points wrong calculation
  • Loading branch information
iopietro authored Feb 22, 2019
1 parent c560e9b commit d3b420b
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion GameEngine/Building.php
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,6 @@ public function finishAll($redirect_url = '') {

if (!isset($exclude_master) && $database->query($q) && ($enought_res == 1 || $jobs['master'] == 0)) {
$database->modifyPop($jobs['wid'],$resource['pop'],0);
$database->addCP($jobs['wid'],$resource['cp']);
$deletIDs[] = (int) $jobs['id'];
if($jobs['type'] == 18) {
$owner = $database->getVillageField($jobs['wid'],"owner");
Expand Down Expand Up @@ -796,10 +795,40 @@ public function finishAll($redirect_url = '') {
}
}

self::recountCP($database, $village->wid);

header("Location: ".($redirect_url ? $redirect_url : $session->referrer));
exit;
}

public static function recountCP($database, $vid){
$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 += self::buildingCP($building,$lvl);
}
}

$q = "UPDATE ".TB_PREFIX."vdata set cp = $cpTot where wref = $vid";
mysqli_query($database->dblink,$q);

return $cpTot;
}

public static function buildingCP($f, $lvl){
$name = "bid".$f;
global $$name;

$dataarray = $$name;

return ((isset($dataarray[$lvl]) && isset($dataarray[$lvl]['cp'])) ? $dataarray[$lvl]['cp'] : 0);
}

public function resourceRequired($id, $tid, $plus = 1) {
$name = "bid".$tid;
global $$name, $village, $bid15, $database;
Expand Down

0 comments on commit d3b420b

Please sign in to comment.