mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-08-30 23:27:14 +00:00
improve the speed of the script
This commit is contained in:
+138
-40
@@ -381,50 +381,148 @@ class Automation {
|
|||||||
}
|
}
|
||||||
private function pruneOResource() {
|
private function pruneOResource() {
|
||||||
global $database;
|
global $database;
|
||||||
if(!ALLOW_BURST) {
|
if(!ALLOW_BURST) {
|
||||||
$q = "UPDATE ".TB_PREFIX."odata set `wood` = `maxstore` WHERE `wood` > `maxstore`";
|
$q = "SELECT * FROM ".TB_PREFIX."odata WHERE maxstore < 800 OR maxcrop < 800";
|
||||||
$database->query($q);
|
$array = $database->query_return($q);
|
||||||
$q = "UPDATE ".TB_PREFIX."odata set `clay` = `maxstore` WHERE `clay` > `maxstore`";
|
foreach($array as $getoasis) {
|
||||||
$database->query($q);
|
if($getoasis['maxstore'] < 800){
|
||||||
$q = "UPDATE ".TB_PREFIX."odata set `iron` = `maxstore` WHERE `iron` > `maxstore`";
|
$maxstore = 800;
|
||||||
$database->query($q);
|
}else{
|
||||||
$q = "UPDATE ".TB_PREFIX."odata set `crop` = `maxcrop` WHERE `crop` > `maxcrop`";
|
$maxstore = $getoasis['maxstore'];
|
||||||
$database->query($q);
|
}
|
||||||
$q = "UPDATE ".TB_PREFIX."odata set `crop` = 0 WHERE `crop` < 0";
|
if($getoasis['maxcrop'] < 800){
|
||||||
$database->query($q);
|
$maxcrop = 800;
|
||||||
$q = "UPDATE ".TB_PREFIX."odata set `wood` = 0 WHERE `wood` < 0";
|
}else{
|
||||||
$database->query($q);
|
$maxcrop = $getoasis['maxcrop'];
|
||||||
$q = "UPDATE ".TB_PREFIX."odata set `clay` = 0 WHERE `clay` < 0";
|
}
|
||||||
$database->query($q);
|
$q = "UPDATE " . TB_PREFIX . "odata set maxstore = $maxstore, maxcrop = $maxcrop where wref = ".$getoasis['wref']."";
|
||||||
$q = "UPDATE ".TB_PREFIX."odata set `iron` = 0 WHERE `iron` < 0";
|
$database->query($q);
|
||||||
$database->query($q);
|
}
|
||||||
$q = "UPDATE ".TB_PREFIX."odata set `maxstore` = 800 WHERE `maxstore` <= 800";
|
$q = "SELECT * FROM ".TB_PREFIX."odata WHERE wood > maxstore OR clay > maxstore OR iron > maxstore OR crop > maxstore";
|
||||||
$database->query($q);
|
$array = $database->query_return($q);
|
||||||
$q = "UPDATE ".TB_PREFIX."odata set `maxcrop` = 800 WHERE `maxcrop` <= 800";
|
foreach($array as $getoasis) {
|
||||||
$database->query($q);
|
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) {
|
||||||
|
if($getoasis['wood'] < 0){
|
||||||
|
$wood = 0;
|
||||||
|
}else{
|
||||||
|
$wood = $getoasis['wood'];
|
||||||
|
}
|
||||||
|
if($getoasis['clay'] < 0){
|
||||||
|
$clay = 0;
|
||||||
|
}else{
|
||||||
|
$clay = $getoasis['clay'];
|
||||||
|
}
|
||||||
|
if($getoasis['iron'] < 0){
|
||||||
|
$iron = 0;
|
||||||
|
}else{
|
||||||
|
$iron = $getoasis['iron'];
|
||||||
|
}
|
||||||
|
if($getoasis['crop'] < 0){
|
||||||
|
$crop = 0;
|
||||||
|
}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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private function pruneResource() {
|
private function pruneResource() {
|
||||||
global $database;
|
global $database;
|
||||||
if(!ALLOW_BURST) {
|
if(!ALLOW_BURST) {
|
||||||
$q = "UPDATE ".TB_PREFIX."vdata set `wood` = `maxstore` WHERE `wood` > `maxstore`";
|
$q = "SELECT * FROM ".TB_PREFIX."vdata WHERE maxstore < 800 OR maxcrop < 800";
|
||||||
$database->query($q);
|
$array = $database->query_return($q);
|
||||||
$q = "UPDATE ".TB_PREFIX."vdata set `clay` = `maxstore` WHERE `clay` > `maxstore`";
|
foreach($array as $getvillage) {
|
||||||
$database->query($q);
|
if($getvillage['maxstore'] < 800){
|
||||||
$q = "UPDATE ".TB_PREFIX."vdata set `iron` = `maxstore` WHERE `iron` > `maxstore`";
|
$maxstore = 800;
|
||||||
$database->query($q);
|
}else{
|
||||||
$q = "UPDATE ".TB_PREFIX."vdata set `crop` = `maxcrop` WHERE `crop` > `maxcrop`";
|
$maxstore = $getvillage['maxstore'];
|
||||||
$database->query($q);
|
}
|
||||||
$q = "UPDATE ".TB_PREFIX."vdata set `wood` = 0 WHERE `wood` < 0";
|
if($getvillage['maxcrop'] < 800){
|
||||||
$database->query($q);
|
$maxcrop = 800;
|
||||||
$q = "UPDATE ".TB_PREFIX."vdata set `clay` = 0 WHERE `clay` < 0";
|
}else{
|
||||||
$database->query($q);
|
$maxcrop = $getvillage['maxcrop'];
|
||||||
$q = "UPDATE ".TB_PREFIX."vdata set `iron` = 0 WHERE `iron` < 0";
|
}
|
||||||
$database->query($q);
|
$q = "UPDATE " . TB_PREFIX . "vdata set maxstore = $maxstore, maxcrop = $maxcrop where wref = ".$getvillage['wref']."";
|
||||||
$q = "UPDATE ".TB_PREFIX."vdata set `maxstore` = 800 WHERE `maxstore` <= 800";
|
$database->query($q);
|
||||||
$database->query($q);
|
}
|
||||||
$q = "UPDATE ".TB_PREFIX."vdata set `maxcrop` = 800 WHERE `maxcrop` <= 800";
|
$q = "SELECT * FROM ".TB_PREFIX."vdata WHERE wood > maxstore OR clay > maxstore OR iron > maxstore OR crop > maxstore";
|
||||||
$database->query($q);
|
$array = $database->query_return($q);
|
||||||
|
foreach($array as $getvillage) {
|
||||||
|
if($getvillage['wood'] > $getvillage['maxstore']){
|
||||||
|
$wood = $getvillage['maxstore'];
|
||||||
|
}else{
|
||||||
|
$wood = $getvillage['wood'];
|
||||||
|
}
|
||||||
|
if($getvillage['clay'] > $getvillage['maxstore']){
|
||||||
|
$clay = $getvillage['maxstore'];
|
||||||
|
}else{
|
||||||
|
$clay = $getvillage['clay'];
|
||||||
|
}
|
||||||
|
if($getvillage['iron'] > $getvillage['maxstore']){
|
||||||
|
$iron = $getvillage['maxstore'];
|
||||||
|
}else{
|
||||||
|
$iron = $getvillage['iron'];
|
||||||
|
}
|
||||||
|
if($getvillage['crop'] > $getvillage['maxstore']){
|
||||||
|
$crop = $getvillage['maxstore'];
|
||||||
|
}else{
|
||||||
|
$crop = $getvillage['crop'];
|
||||||
|
}
|
||||||
|
$q = "UPDATE " . TB_PREFIX . "vdata set wood = $wood, clay = $clay, iron = $iron, crop = $crop where wref = ".$getvillage['wref']."";
|
||||||
|
$database->query($q);
|
||||||
|
}
|
||||||
|
$q = "SELECT * FROM ".TB_PREFIX."vdata WHERE wood < 0 OR clay < 0 OR iron < 0 OR crop < 0";
|
||||||
|
$array = $database->query_return($q);
|
||||||
|
foreach($array as $getvillage) {
|
||||||
|
if($getvillage['wood'] < 0){
|
||||||
|
$wood = 0;
|
||||||
|
}else{
|
||||||
|
$wood = $getvillage['wood'];
|
||||||
|
}
|
||||||
|
if($getvillage['clay'] < 0){
|
||||||
|
$clay = 0;
|
||||||
|
}else{
|
||||||
|
$clay = $getvillage['clay'];
|
||||||
|
}
|
||||||
|
if($getvillage['iron'] < 0){
|
||||||
|
$iron = 0;
|
||||||
|
}else{
|
||||||
|
$iron = $getvillage['iron'];
|
||||||
|
}
|
||||||
|
if($getvillage['crop'] < 0){
|
||||||
|
$crop = 0;
|
||||||
|
}else{
|
||||||
|
$crop = $getvillage['crop'];
|
||||||
|
}
|
||||||
|
$q = "UPDATE " . TB_PREFIX . "vdata set wood = $wood, clay = $clay, iron = $iron, crop = $crop where wref = ".$getvillage['wref']."";
|
||||||
|
$database->query($q);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user