From 4d00b4ad1c1d5615c5bf4e4d51d6ca774025ea2b Mon Sep 17 00:00:00 2001 From: AL-Kateb Date: Wed, 27 Dec 2017 10:23:57 +0000 Subject: [PATCH 1/4] Fixed units doubling when evasion is active --- GameEngine/Automation.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php index b5fe9c1b..50d3d7f9 100755 --- a/GameEngine/Automation.php +++ b/GameEngine/Automation.php @@ -1357,6 +1357,15 @@ class Automation { } // modify units in DB + + + + + + + + + $database->modifyUnit($data['to'], $evasionUnitModifications_units, $evasionUnitModifications_amounts, $evasionUnitModifications_modes); } //get defence units @@ -2915,6 +2924,7 @@ class Automation { ['99', '99o'], [$newtraps, $mytroops+$anothertroops], [0, 0] + ); $trapper_pic = "\"Trap\""; $p_username = $database->getUserField($from['owner'],"username",0); @@ -3120,15 +3130,19 @@ class Automation { } unset($crop,$unitarrays,$getvillage,$village_upkeep); } - + + //Returning units back to village is not necessary because it will be taken care when processing movement + // Fix by AL-Kateb // if evasion was active, return units back to base - if (isset($evaded)) { + /* + if (isset($evaded)) { foreach ($evasionUnitModifications_modes as $index => $mode) { $evasionUnitModifications_modes[$index] = 1; } $database->modifyUnit($data['to'], $evasionUnitModifications_units, $evasionUnitModifications_amounts, $evasionUnitModifications_modes); } + */ ################################################# ################FIXED BY SONGER################ @@ -3687,6 +3701,7 @@ class Automation { array($u."1",$u."2",$u."3",$u."4",$u."5",$u."6",$u."7",$u."8",$u."9",$tribe."0","hero"), array($data['t1'],$data['t2'],$data['t3'],$data['t4'],$data['t5'],$data['t6'],$data['t7'],$data['t8'],$data['t9'],$data['t10'],$data['t11']), array(1,1,1,1,1,1,1,1,1,1,1) + ); $movementProcIDs[] = $data['moveid']; $crop = $database->getCropProdstarv($data['to']); From be8f683417fa1d92e6ccb4b636cbf7df4739f55e Mon Sep 17 00:00:00 2001 From: AL-Kateb Date: Wed, 27 Dec 2017 10:59:01 +0000 Subject: [PATCH 2/4] Cleanup --- GameEngine/Automation.php | 9 --------- 1 file changed, 9 deletions(-) diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php index 50d3d7f9..8ee6d63f 100755 --- a/GameEngine/Automation.php +++ b/GameEngine/Automation.php @@ -1357,15 +1357,6 @@ class Automation { } // modify units in DB - - - - - - - - - $database->modifyUnit($data['to'], $evasionUnitModifications_units, $evasionUnitModifications_amounts, $evasionUnitModifications_modes); } //get defence units From ddc2e624727eda90cf08b8e595a45d7f15e999d3 Mon Sep 17 00:00:00 2001 From: AL-Kateb Date: Wed, 27 Dec 2017 14:38:40 +0000 Subject: [PATCH 3/4] Fixed loosing 1 level when there are only few catapults --- GameEngine/Automation.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php index 8ee6d63f..137385c2 100755 --- a/GameEngine/Automation.php +++ b/GameEngine/Automation.php @@ -1068,7 +1068,6 @@ class Automation { $stonemasonEffect = 1; } $battlepart[3] = round((($battlepart[5] * (pow($tblevel,2) + $tblevel + 1)) / (8 * (round(200 * pow(1.0205,$battlepart[9]))/200) / $stonemasonEffect / $battlepart[10])) + 0.5); - // building/field destroyed if ($battlepart[4]>$battlepart[3]) { @@ -1148,8 +1147,7 @@ class Automation { { //TODO: MUST TO BE FIX This part goes also below 0 if u have a lot of catapults // TODO: this whole math seems incorrect, it needs a revision, and potentially a rewrite - $totallvl = round( sqrt( pow( ( $tblevel + 0.5 ), 2 ) - ( ( !$twoRowsCatapultSetup ? (int) $battlepart[4] : (int) $battlepart[4] / 2 ) * 8 ) ) ); - + $totallvl = round( sqrt( pow( ( $tblevel + 0.5 ), 2 ) - ( ( !$twoRowsCatapultSetup ? (float) $battlepart[4] : (float) $battlepart[4] / 2 ) * 8 ) ) ); // sometimes this goes above the actual level, so in that case we just reverse everything // and take the buiding down so many levels if ($totallvl > $tblevel) { From a254572a43ae614b361191c6c6ed3d3a9a82269d Mon Sep 17 00:00:00 2001 From: AL-Kateb Date: Thu, 28 Dec 2017 15:21:07 +0000 Subject: [PATCH 4/4] Fixed deleting trade routes after village is conquered --- GameEngine/Automation.php | 5 ++++- GameEngine/Database.php | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php index 137385c2..f1443145 100755 --- a/GameEngine/Automation.php +++ b/GameEngine/Automation.php @@ -2654,7 +2654,10 @@ class Automation { //remove oasis related to village $units->returnTroops($data['to'],1); $chiefing_village = 1; - + + //Remove trade routes related to village + $database->deleteTradeRoutesByVillage($data['to']); + // update data in the database $database->clearExpansionSlot($data['to']); $database->setVillageLevel($data['to'], $newLevels_fieldNames, $newLevels_fieldValues); diff --git a/GameEngine/Database.php b/GameEngine/Database.php index 8c9583b7..1175b2dc 100755 --- a/GameEngine/Database.php +++ b/GameEngine/Database.php @@ -4367,7 +4367,14 @@ References: User ID/Message ID, Mode $q = "DELETE FROM " . TB_PREFIX . "route where id = $id"; return mysqli_query($this->dblink,$q); } + + function deleteTradeRoutesByVillage($id) { + list($id) = $this->escape_input((int) $id); + $q = "DELETE FROM " . TB_PREFIX . "route where `from` = $id"; + return mysqli_query($this->dblink,$q); + } + function addBuilding($wid, $field, $type, $loop, $time, $master, $level) { list($wid, $field, $type, $loop, $time, $master, $level) = $this->escape_input((int) $wid, $field, (int) $type, (int) $loop, (int) $time, (int) $master, (int) $level);