Skip to content
Browse files

update Automation.php (should to optimize the server speed, especiall…

…y when server have big map)
  • Loading branch information...
1 parent 95cda9b commit 4d89393077113215f3570ec8231ffb60e5afcd9c unknown committed
Showing with 18 additions and 31 deletions.
  1. +18 −31 GameEngine/Automation.php
View
49 GameEngine/Automation.php
@@ -473,32 +473,6 @@ private function pruneOResource() {
$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 @@ private function oasisResoucesProduce() {
$q = "SELECT * FROM ".TB_PREFIX."odata WHERE wood < 800 OR clay < 800 OR iron < 800 OR crop < 800";
$array = $database->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']);
}
}

0 comments on commit 4d89393

Please sign in to comment.
Something went wrong with that request. Please try again.