Skip to content

Commit

Permalink
Bug Fixes
Browse files Browse the repository at this point in the history
+Fixed a bug that permitted to queue three buildings at the same time,
without the waiting loop constraint
  • Loading branch information
iopietro authored Feb 21, 2019
1 parent 80e5b73 commit f26d335
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions GameEngine/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -4731,12 +4731,12 @@ function removeBuilding($d, $tribe, $wid, $fieldsArray = []) {
$time = time();
$newTime = $loopTime = 0;
if(empty($fieldsArray)) $fieldsArray = $this->getResourceLevel($wid);
$jobs = $this->getJobs($wid);
$jobs = $this->getJobsOrderByID($wid);

//Search the job which needs to be deleted
foreach($jobs as $job){
//We need to modify waiting loop orders
if(!empty($jobToDelete) && $job['loopcon'] == 1 && ($tribe != 1 || $tribe == 1 && (($jobToDelete['field'] <= 18 && $job['field'] <= 18) || ($jobToDelete['field'] >= 19 && $job['field'] >= 19)))){
if(!empty($jobToDelete) && $job['loopcon'] == 1 && ($tribe != 1 || ($tribe == 1 && (($jobToDelete['field'] <= 18 && $job['field'] <= 18) || ($jobToDelete['field'] >= 19 && $job['field'] >= 19))))){

//Does this job have the same field of the deleted one?
$sameBuilding = $jobToDelete['field'] == $job['field'] ? 1 : 0;
Expand Down Expand Up @@ -5265,7 +5265,7 @@ function modifyBData($wid, $field, $levels, $tribe){
else mysqli_query($this->dblink, $q = "UPDATE " .TB_PREFIX. "bdata SET level = level - $levels[1] + $levels[0] WHERE wid = $wid AND field = $field");
}

private function getBData($wid, $use_cache = true) {
private function getBData($wid, $use_cache = true, $orderByID = false) {
$wid = (int) $wid;

// first of all, check if we should be using cache and whether the field
Expand All @@ -5276,7 +5276,7 @@ private function getBData($wid, $use_cache = true) {
return self::$buildingsUnderConstructionCache[$wid];
}

$q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid order by master,timestamp ASC";
$q = "SELECT * FROM " . TB_PREFIX . "bdata where wid = $wid order by ".(!$orderByID ? "master,timestamp" : "id")." ASC";
$result = $this->mysqli_fetch_all(mysqli_query($this->dblink,$q));

self::$buildingsUnderConstructionCache[$wid] = $result;
Expand All @@ -5287,6 +5287,10 @@ private function getBData($wid, $use_cache = true) {
function getJobs($wid) {
return $this->getBData($wid, false);
}

function getJobsOrderByID($wid) {
return $this->getBData($wid, false, true);
}

function FinishWoodcutter($wid) {
$bdata = $this->getBData($wid);
Expand Down

0 comments on commit f26d335

Please sign in to comment.