From 4d89393077113215f3570ec8231ffb60e5afcd9c Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 11 Apr 2013 15:12:06 +0300 Subject: [PATCH] update Automation.php (should to optimize the server speed, especially when server have big map) --- GameEngine/Automation.php | 49 ++++++++++++++------------------------- 1 file changed, 18 insertions(+), 31 deletions(-) diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php index 27ecab5b..f3b3a025 100644 --- a/GameEngine/Automation.php +++ b/GameEngine/Automation.php @@ -473,32 +473,6 @@ class Automation { $q = "UPDATE " . TB_PREFIX . "odata set maxstore = $maxstore, maxcrop = $maxcrop where wref = ".$getoasis['wref'].""; $database->query($q); } - $q = "SELECT * FROM ".TB_PREFIX."odata WHERE wood > maxstore OR clay > maxstore OR iron > maxstore OR crop > maxcrop"; - $array = $database->query_return($q); - foreach($array as $getoasis) { - if($getoasis['wood'] > $getoasis['maxstore']){ - $wood = $getoasis['maxstore']; - }else{ - $wood = $getoasis['wood']; - } - if($getoasis['clay'] > $getoasis['maxstore']){ - $clay = $getoasis['maxstore']; - }else{ - $clay = $getoasis['clay']; - } - if($getoasis['iron'] > $getoasis['maxstore']){ - $iron = $getoasis['maxstore']; - }else{ - $iron = $getoasis['iron']; - } - if($getoasis['crop'] > $getoasis['maxstore']){ - $crop = $getoasis['maxstore']; - }else{ - $crop = $getoasis['crop']; - } - $q = "UPDATE " . TB_PREFIX . "odata set wood = $wood, clay = $clay, iron = $iron, crop = $crop where wref = ".$getoasis['wref'].""; - $database->query($q); - } $q = "SELECT * FROM ".TB_PREFIX."odata WHERE wood < 0 OR clay < 0 OR iron < 0 OR crop < 0"; $array = $database->query_return($q); foreach($array as $getoasis) { @@ -3930,11 +3904,24 @@ $crannyimg = "query_return($q); foreach($array as $getoasis) { - $oasiswood = (8*SPEED/3600)*(time()-$getoasis['lastupdated']); - $oasisclay = (8*SPEED/3600)*(time()-$getoasis['lastupdated']); - $oasisiron = (8*SPEED/3600)*(time()-$getoasis['lastupdated']); - $oasiscrop = (8*SPEED/3600)*(time()-$getoasis['lastupdated']); - $database->modifyOasisResource($getoasis['wref'],$oasiswood,$oasisclay,$oasisiron,$oasiscrop,1); + $oasiswood = $getoasis['wood'] + (8*SPEED/3600)*(time()-$getoasis['lastupdated']); + $oasisclay = $getoasis['clay'] + (8*SPEED/3600)*(time()-$getoasis['lastupdated']); + $oasisiron = $getoasis['iron'] + (8*SPEED/3600)*(time()-$getoasis['lastupdated']); + $oasiscrop = $getoasis['crop'] + (8*SPEED/3600)*(time()-$getoasis['lastupdated']); + if($oasiswood > $getoasis['maxstore']){ + $oasiswood = $getoasis['maxstore']; + } + if($oasisclay > $getoasis['maxstore']){ + $oasisclay = $getoasis['maxstore']; + } + if($oasisiron > $getoasis['maxstore']){ + $oasisiron = $getoasis['maxstore']; + } + if($oasiscrop > $getoasis['maxcrop']){ + $oasiscrop = $getoasis['maxcrop']; + } + $q = "UPDATE " . TB_PREFIX . "odata set wood = $oasiswood, clay = $oasisclay, iron = $oasisiron, crop = $oasiscrop where wref = ".$getoasis['wref'].""; + $database->query($q); $database->updateOasis($getoasis['wref']); } }