General fixes

+Fixed a bug that didn't permit to destroy the capital if the player had
more than 1 village. The capital is now destroyable (if the player has
more than 1 village)
+Fixed a bug that updated the hero wref wrongly when reinforcing their
own villages
+Fixed a bug that didn't kill the hero if his village was destroyed
while he was sent to another village as a reinforcement
+Better indentation
+General improovements
This commit is contained in:
iopietro
2018-05-06 00:00:27 +02:00
parent f7e05c9802
commit 89bebaee1f
3 changed files with 158 additions and 127 deletions
+15 -17
View File
@@ -73,8 +73,8 @@ class Units {
private function loadUnits($post) {
global $database,$village,$session,$generator,$logging,$form;
// Search by town name
// Coordinates and look confirm name people
// Search by town name
// Coordinates and look confirm name people
if(isset($post['x']) && isset($post['y']) && !empty($post['x']) && !empty($post['y'])) {
$vid = $database->getVilWref($post['x'], $post['y']);
unset($post['dname'], $post['dname']);
@@ -224,25 +224,23 @@ class Units {
public function returnTroops($wref, $mode = 0) {
global $database;
if (!$mode) {
$getenforce=$database->getEnforceVillage($wref,0);
foreach($getenforce as $enforce) {
$this->processReturnTroops($enforce);
}
}
//check oasis
$getenforce1=$database->getOasisEnforce($wref,1);
foreach($getenforce1 as $enforce) {
$this->processReturnTroops($enforce);
}
//set oasis to default
if (count($getenforce1)>0) {
$database->regenerateOasisUnits($getenforce1[0]['vref']);
}
if(!$mode){
$getenforce = $database->getEnforceVillage($wref, 0);
foreach($getenforce as $enforce) $this->processReturnTroops($enforce);
}
// check oasis
$getenforce1 = $database->getOasisEnforce($wref, 1);
foreach($getenforce1 as $enforce) $this->processReturnTroops($enforce);
// set oasis to default
if(count($getenforce1) > 0) $database->regenerateOasisUnits($getenforce1[0]['vref']);
}
private function processReturnTroops($enforce) {
global $database, $generator;
$to = $database->getVillage($enforce['from']);
$tribe = $database->getUserField($to['owner'], 'tribe', 0);