From e32f577e98709d007de7f8c7d98a549d99bd0dcf Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 4 Oct 2012 00:05:37 +0200 Subject: [PATCH] more updates --- GameEngine/Alliance.php | 34 +++++++++++++++++++++++++++++- GameEngine/Automation.php | 44 ++++++++++++++++++++++++++++++--------- 2 files changed, 67 insertions(+), 11 deletions(-) diff --git a/GameEngine/Alliance.php b/GameEngine/Alliance.php index 1db9c47c..013e2ba0 100644 --- a/GameEngine/Alliance.php +++ b/GameEngine/Alliance.php @@ -362,7 +362,15 @@ $database->deleteAlliPermissions($post['a_user']); $database->deleteAlliance($session->alliance); // log the notice - $database->insertAlliNotice($session->alliance, '' . $UserData['username'] . ' has quit the alliance.'); + $database->insertAlliNotice($session->alliance, '' . addslashes($post['a_user']) . ' has quit the alliance.'); + if($database->isAllianceOwner($UserData['id'])){ + $newowner = $database->getAllMember2($session->alliance); + $newleader = $newowner['id']; + $q = "UPDATE " . TB_PREFIX . "alidata set leader = ".$newleader." where id = ".$session->alliance.""; + $database->query($q); + $database->updateAlliPermissions($newleader, 1, 1, 1, 1, 1, 1, 1, 1, 1); + $this->updateMax($newleader); + } } }else{ header("Location: banned.php"); @@ -400,6 +408,7 @@ $q = "UPDATE " . TB_PREFIX . "alidata set leader = ".$newleader." where id = ".$session->alliance.""; $database->query($q); $database->updateAlliPermissions($newleader, 1, 1, 1, 1, 1, 1, 1, 1, 1); + $this->updateMax($newleader); } $database->deleteAlliPermissions($session->uid); // log the notice @@ -448,6 +457,29 @@ header("Location: banned.php"); } } + + private function updateMax($leader) { + global $bid18, $database; + $q = mysql_query("SELECT * FROM " . TB_PREFIX . "alidata where leader = $leader"); + if(mysql_num_rows($q) > 0){ + $villages = $database->getVillagesID2($leader); + $max = 0; + foreach($villages as $village){ + $field = $database->getResourceLevel($village['wref']); + for($i=19;$i<=40;$i++){ + if($field['f'.$i.'t'] == 18){ + $level = $field['f'.$i]; + $attri = $bid18[$level]['attri']; + } + } + if($attri > $max){ + $max = $attri; + } + } + $q = "UPDATE ".TB_PREFIX."alidata set max = $max where leader = $leader"; + $database->query($q); + } + } } $alliance = new Alliance; diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php index ab4bf603..7a307283 100644 --- a/GameEngine/Automation.php +++ b/GameEngine/Automation.php @@ -208,7 +208,7 @@ class Automation { $this->updateStore(); $this->CheckBan(); $this->regenerateOasisTroops(); - $this->updateMax(); + $this->artefactOfTheFool(); } @@ -413,6 +413,7 @@ class Automation { $q = "UPDATE " . TB_PREFIX . "alidata set leader = ".$newleader." where id = ".$alliance.""; $database->query($q); $database->updateAlliPermissions($newleader, $alliance, "Leader", 1, 1, 1, 1, 1, 1, 1); + $this->updateMax($newleader); } $database->deleteAlliance($alliance); $q = "DELETE FROM ".TB_PREFIX."hero where uid = ".$need['uid']; @@ -660,7 +661,11 @@ class Automation { } $database->setVillageField($indi['wid'],"maxcrop",$max); } - + + if($indi['type'] == 18){ + $this->updateMax($database->getVillageField($indi['wid'],"owner")); + } + if($indi['type'] == 38) { $max=$database->getVillageField($indi['wid'],"maxstore"); if($level=='1' && $max==STORAGE_BASE){ $max=STORAGE_BASE; } @@ -1915,6 +1920,9 @@ class Automation { $q = "UPDATE ".TB_PREFIX."vdata SET `maxcrop`='".$tmaxcrop."'*32 WHERE wref=".$data['to']; $database->query($q); } + if ($tbgid==18){ + $this->updateMax($database->getVillageField($data['to'],'owner')); + } $pop=$this->recountPop($data['to']); $capital = $database->getVillage($data['to']); if($pop=='0' && $capital['capital']=='0') @@ -1952,6 +1960,9 @@ class Automation { $q = "UPDATE ".TB_PREFIX."vdata SET `maxcrop`='".$tmaxcrop."' WHERE wref=".$data['to']; $database->query($q); } + if ($tbgid==18){ + $this->updateMax($database->getVillageField($data['to'],'owner')); + } $pop=$this->recountPop($data['to']); } $info_cat = "".$catp_pic.",".$this->procResType($tbgid).$info_cata; @@ -2040,6 +2051,9 @@ class Automation { $q = "UPDATE ".TB_PREFIX."vdata SET `maxcrop`='".$tmaxcrop."' WHERE wref=".$data['to']; $database->query($q); } + if ($tbgid==18){ + $this->updateMax($database->getVillageField($data['to'],'owner')); + } $pop=$this->recountPop($data['to']); if($pop=='0') { @@ -2079,6 +2093,9 @@ class Automation { $q = "UPDATE ".TB_PREFIX."vdata SET `maxcrop`='".$tmaxcrop."' WHERE wref=".$data['to']; $database->query($q); } + if ($tbgid==18){ + $this->updateMax($database->getVillageField($data['to'],'owner')); + } $pop=$this->recountPop($data['to']); } $info_cat = "".$catp_pic.",".$this->procResType($tbgid).$info_cata; @@ -2165,6 +2182,9 @@ class Automation { $q = "UPDATE ".TB_PREFIX."vdata SET `maxcrop`='".$tmaxcrop."' WHERE wref=".$data['to']; $database->query($q); } + if ($tbgid==18){ + $this->updateMax($database->getVillageField($data['to'],'owner')); + } $pop=$this->recountPop($data['to']); if($pop=='0') { @@ -2205,6 +2225,9 @@ class Automation { $q = "UPDATE ".TB_PREFIX."vdata SET `maxcrop`='".$tmaxcrop."' WHERE wref=".$data['to']; $database->query($q); } + if ($tbgid==18){ + $this->updateMax($database->getVillageField($data['to'],'owner')); + } $pop=$this->recountPop($data['to']); } @@ -3800,6 +3823,9 @@ $crannyimg = "query_return($q); - foreach($array as $ally) { - $owner = $ally['leader']; - $villages = $database->getVillagesID2($owner); + $q = mysql_query("SELECT * FROM " . TB_PREFIX . "alidata where leader = $leader"); + if(mysql_num_rows($q) > 0){ + $villages = $database->getVillagesID2($leader); $max = 0; foreach($villages as $village){ $field = $database->getResourceLevel($village['wref']); @@ -4276,11 +4300,11 @@ $crannyimg = " $max){ $max = $attri; } - $q = "UPDATE ".TB_PREFIX."alidata set max = $max where leader = $owner"; + } + $q = "UPDATE ".TB_PREFIX."alidata set max = $max where leader = $leader"; $database->query($q); } }