diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php
index cef28072..39d48cf5 100644
--- a/GameEngine/Automation.php
+++ b/GameEngine/Automation.php
@@ -233,54 +233,53 @@ class Automation {
$this->artefactOfTheFool();
}
- private function loyaltyRegeneration() {
- if(file_exists("GameEngine/Prevention/loyalty.txt")) {
+ private function loyaltyRegeneration() {
+ if(file_exists("GameEngine/Prevention/loyalty.txt")) {
unlink("GameEngine/Prevention/loyalty.txt");
}
+ //fix by ronix
//create new file to check filetime
//not every click regenerate but 1 minute or after
- $ourFileHandle = fopen("GameEngine/Prevention/loyalty.txt", 'w');
- fclose($ourFileHandle);
- global $database;
- $array = array();
- $q = "SELECT * FROM ".TB_PREFIX."vdata WHERE loyalty<>100";
- $array = $database->query_return($q);
- if(!empty($array)) {
- foreach($array as $loyalty) {
- if($this->getTypeLevel(25,$loyalty['wref']) >= 1){
- $value = $this->getTypeLevel(25,$loyalty['wref']);
- }elseif($this->getTypeLevel(26,$loyalty['wref']) >= 1){
- $value = $this->getTypeLevel(26,$loyalty['wref']);
- } else {
- $value = 0;
- }
- $newloyalty = min(100,$loyalty['loyalty']+$value*(time()-$loyalty['lastupdated'])/(60*60));
- $q = "UPDATE ".TB_PREFIX."odata SET loyalty = $newloyalty, lastupdated=".time()." WHERE wref = '".$loyalty['wref']."'";
- $database->query($q);
- }
- }
- $array = array();
- $q = "SELECT * FROM ".TB_PREFIX."odata WHERE loyalty<>100";
- $array = $database->query_return($q);
- if(!empty($array)) {
- foreach($array as $loyalty) {
- if($this->getTypeLevel(25,$loyalty['conqured']) >= 1){
- $value = $this->getTypeLevel(25,$loyalty['conqured']);
- }elseif($this->getTypeLevel(26,$loyalty['conqured']) >= 1){
- $value = $this->getTypeLevel(26,$loyalty['conqured']);
- } else {
- $value = 0;
- }
- $newloyalty = min(100,$loyalty['loyalty']+$value*(time()-$loyalty['lastupdate'])/(60*60));
- $q = "UPDATE ".TB_PREFIX."odata SET loyalty = $newloyalty WHERE wref = '".$loyalty['wref']."'";
- $database->query($q);
- }
- }
- //if(file_exists("GameEngine/Prevention/loyalty.txt")) {
- // unlink("GameEngine/Prevention/loyalty.txt");
- //}
- }
+
+ $ourFileHandle = fopen("GameEngine/Prevention/loyalty.txt", 'w');
+ fclose($ourFileHandle);
+ global $database;
+ $array = array();
+ $q = "SELECT * FROM ".TB_PREFIX."vdata WHERE loyalty<>100";
+ $array = $database->query_return($q);
+ if(!empty($array)) {
+ foreach($array as $loyalty) {
+ if($this->getTypeLevel(25,$loyalty['wref']) >= 1){
+ $value = $this->getTypeLevel(25,$loyalty['wref']);
+ }elseif($this->getTypeLevel(26,$loyalty['wref']) >= 1){
+ $value = $this->getTypeLevel(26,$loyalty['wref']);
+ } else {
+ $value = 0;
+ }
+ $newloyalty = min(100,$loyalty['loyalty']+$value*(time()-$loyalty['lastupdate2'])/(60*60));
+ $q = "UPDATE ".TB_PREFIX."vdata SET loyalty = $newloyalty, lastupdate2=".time()." WHERE wref = '".$loyalty['wref']."'";
+ $database->query($q);
+ }
+ }
+ $array = array();
+ $q = "SELECT * FROM ".TB_PREFIX."odata WHERE loyalty<>100";
+ $array = $database->query_return($q);
+ if(!empty($array)) {
+ foreach($array as $loyalty) {
+ if($this->getTypeLevel(25,$loyalty['conqured']) >= 1){
+ $value = $this->getTypeLevel(25,$loyalty['conqured']);
+ }elseif($this->getTypeLevel(26,$loyalty['conqured']) >= 1){
+ $value = $this->getTypeLevel(26,$loyalty['conqured']);
+ } else {
+ $value = 0;
+ }
+ $newloyalty = min(100,$loyalty['loyalty']+$value*(time()-$loyalty['lastupdated'])/(60*60));
+ $q = "UPDATE ".TB_PREFIX."odata SET loyalty = $newloyalty, lastupdated=".time()." WHERE wref = '".$loyalty['wref']."'";
+ $database->query($q);
+ }
+ }
+ }
private function getfieldDistance($coorx1, $coory1, $coorx2, $coory2) {
$max = 2 * WORLD_MAX + 1;
@@ -357,7 +356,7 @@ class Automation {
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."bdata where wid = ".$village;
$database->query($q);
- $q = "DELETE FROM ".TB_PREFIX."enforcement where from = ".$village;
+ $q = "DELETE FROM ".TB_PREFIX."enforcement where `from` = ".$village;
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."fdata where vref = ".$village;
$database->query($q);
@@ -388,7 +387,7 @@ class Automation {
$database->addMovement(4,$movedata['to'],$movedata['from'],$movedata['ref'],$time,$time+$time2);
$database->setMovementProc($movedata['moveid']);
}
- $q = "DELETE FROM ".TB_PREFIX."movement where from = ".$village;
+ $q = "DELETE FROM ".TB_PREFIX."movement where `from` = ".$village;
$database->query($q);
$getprisoners = $database->getPrisoners($village);
foreach($getprisoners as $pris) {
@@ -1017,7 +1016,7 @@ class Automation {
if(file_exists("GameEngine/Prevention/sendunits.txt")) {
unlink("GameEngine/Prevention/sendunits.txt");
}
- global $bid23,$bid34,$database,$battle,$village,$technology,$logging,$generator,$session;
+ global $bid23,$bid34,$database,$battle,$village,$technology,$logging,$generator,$session,$units;
$reload=false;
$ourFileHandle = fopen("GameEngine/Prevention/sendunits.txt", 'w');
fclose($ourFileHandle);
@@ -1060,8 +1059,8 @@ class Automation {
$cannotsend = 0;
$movements = $database->getMovement("34",$data['to'],1);
for($y=0;$y < count($movements);$y++){
- $returntime = $units[$y]['endtime']-time();
- if($units[$y]['sort_type'] == 4 && $units[$y]['from'] != 0 && $returntime <= 10){
+ $returntime = $unit[$y]['endtime']-time();
+ if($unit[$y]['sort_type'] == 4 && $unit[$y]['from'] != 0 && $returntime <= 10){
$cannotsend = 1;
}
}
@@ -2384,7 +2383,7 @@ class Automation {
$database->query($q);
$database->addTech($data['to']);
//delete reinforcement
- $q = "DELETE FROM ".TB_PREFIX."enforcement WHERE from = ".$data['to']."";
+ $q = "DELETE FROM ".TB_PREFIX."enforcement WHERE `from` = ".$data['to']."";
$database->query($q);
// check buildings
$pop1 = $database->getVillageField($data['from'],"pop");
@@ -2430,6 +2429,8 @@ class Automation {
$value = $data['to'];
}
$database->setVillageField($data['from'],$exp,$value);
+ //remove oasis related to village
+ $units->returnTroops($data['to'],1);
$chiefing_village = 1;
}
@@ -2565,9 +2566,9 @@ $wallimg = "![]()