update Automation.php (should to optimize the server speed, especially when server have big map)

This commit is contained in:
unknown
2013-04-11 15:12:06 +03:00
parent 95cda9be2d
commit 4d89393077
+18 -31
View File
@@ -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 = "<img src=\"".GP_LOCATE."img/g/g23.gif\" height=\"20\" width=\"15\"
$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']);
}
}