From d41dccd7058a3e006cd17ae7303e18496aca9a5c Mon Sep 17 00:00:00 2001 From: Shadow Date: Thu, 21 Nov 2013 08:07:43 +0200 Subject: [PATCH] Update Village.php --- GameEngine/Village.php | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/GameEngine/Village.php b/GameEngine/Village.php index 1440bddb..8c9a678f 100644 --- a/GameEngine/Village.php +++ b/GameEngine/Village.php @@ -28,15 +28,22 @@ class Village { private $production = array(); private $oasisowned,$ocounter = array(); - function Village() { - global $session; - if(isset($_SESSION['wid'])) { - $this->wid = $_SESSION['wid']; - } - else { - $this->wid = $session->villages[0]; - } - $this->LoadTown(); + function Village() { + global $session, $database; + if(isset($_SESSION['wid'])) { + $this->wid = $_SESSION['wid']; + + } + else { + $this->wid = $session->villages[0]; + } + //add new line code + //check exist village if from village destroy to avoid error msg. + if (!$database-> checkVilExist($this->wid)) { + $this->wid=$database->getVillageID($session->uid); + $_SESSION['wid']=$this->wid; + } + $this->LoadTown(); $this->calculateProduction(); $this->processProduction(); $this->ActionControl();