mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-08-30 15:17:13 +00:00
@@ -1223,8 +1223,9 @@ class Automation {
|
|||||||
}
|
}
|
||||||
$vilIDs = array_keys($vilIDs);
|
$vilIDs = array_keys($vilIDs);
|
||||||
$database->getProfileVillages($vilIDs, 5);
|
$database->getProfileVillages($vilIDs, 5);
|
||||||
$database->$
|
$database->getUnit($vilIDs);
|
||||||
$database->getEnforceVillage($vilIDs, 0);
|
$database->getEnforceVillage($vilIDs, 0);
|
||||||
|
$database->getMovement(34, $vilIDs, 1);
|
||||||
|
|
||||||
// calculate battles
|
// calculate battles
|
||||||
foreach($dataarray as $data) {
|
foreach($dataarray as $data) {
|
||||||
@@ -2451,10 +2452,14 @@ class Automation {
|
|||||||
// note: at this point, we can use cache, since we've cleared it above
|
// note: at this point, we can use cache, since we've cleared it above
|
||||||
if($this->getTypeLevel(35,$data['from']) == 0){
|
if($this->getTypeLevel(35,$data['from']) == 0){
|
||||||
for ($i=0; $i<($data['t9']-$dead9); $i++){
|
for ($i=0; $i<($data['t9']-$dead9); $i++){
|
||||||
|
if (!isset($rand)) {
|
||||||
|
$rand = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if($owntribe == 1){
|
if($owntribe == 1){
|
||||||
$rand+=rand(20,30);
|
$rand += rand(20,30);
|
||||||
}else{
|
}else{
|
||||||
$rand+=rand(20,25);
|
$rand += rand(20,25);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
@@ -4271,7 +4276,10 @@ class Automation {
|
|||||||
$database->getProfileVillages($vilIDs, 5);
|
$database->getProfileVillages($vilIDs, 5);
|
||||||
$database->cacheResourceLevels($vilIDs);
|
$database->cacheResourceLevels($vilIDs);
|
||||||
$database->getUnit($vilIDs);
|
$database->getUnit($vilIDs);
|
||||||
$database->getEnforceVillage($vilIDs, 0);
|
$database->getEnforceVillage($vilIDs, 0 );
|
||||||
|
$database->getMovement(3, $vilIDs, 0);
|
||||||
|
$database->getMovement(4, $vilIDs, 1);
|
||||||
|
$database->getMovement(5, $vilIDs, 0);
|
||||||
|
|
||||||
// calculate training updates
|
// calculate training updates
|
||||||
foreach($trainlist as $train){
|
foreach($trainlist as $train){
|
||||||
|
|||||||
+68
-21
@@ -5199,11 +5199,42 @@ References: User ID/Message ID, Mode
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getMovement($type, $village, $mode, $use_cache = true) {
|
function getMovement($type, $village, $mode, $use_cache = true) {
|
||||||
list($type, $village, $mode) = $this->escape_input($type, $village, $mode);
|
$array_passed = is_array($village);
|
||||||
|
|
||||||
|
if (!$array_passed) {
|
||||||
|
$village = [(int) $village];
|
||||||
|
} else {
|
||||||
|
foreach ($village as $index => $villageValue) {
|
||||||
|
$village[$index] = (int) $villageValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!count($village)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
// first of all, check if we should be using cache and whether the field
|
// first of all, check if we should be using cache and whether the field
|
||||||
// required is already cached
|
// required is already cached
|
||||||
if ($use_cache && ($cachedValue = self::returnCachedContent(self::$marketMovementCache, $type.$village.$mode)) && !is_null($cachedValue)) {
|
if ($use_cache && !$array_passed && isset(self::$marketMovementCache[$type.$village[0].$mode]) && is_array(self::$marketMovementCache[$type.$village[0].$mode]) && !count(self::$marketMovementCache[$type.$village[0].$mode])) {
|
||||||
|
return self::$marketMovementCache[$type.$village[0].$mode];
|
||||||
|
} else if ($use_cache && $array_passed) {
|
||||||
|
// check what we can return from cache
|
||||||
|
$newIDs = [];
|
||||||
|
foreach ($village as $key) {
|
||||||
|
if (!isset(self::$marketMovementCache[$type.$key.$mode])) {
|
||||||
|
$newIDs [] = $key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// everything's cached, just return the cache
|
||||||
|
if (!count($newIDs)) {
|
||||||
|
return self::$marketMovementCache;
|
||||||
|
} else {
|
||||||
|
// update remaining IDs to select and cache
|
||||||
|
$village = $newIDs;
|
||||||
|
}
|
||||||
|
} else if ($use_cache && !$array_passed && ($cachedValue = self::returnCachedContent(self::$marketMovementCache, $type.$village[0].$mode)) && !is_null($cachedValue)) {
|
||||||
|
// special case when we have empty arrays cached for this cache only
|
||||||
return $cachedValue;
|
return $cachedValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5215,44 +5246,60 @@ References: User ID/Message ID, Mode
|
|||||||
}
|
}
|
||||||
switch($type) {
|
switch($type) {
|
||||||
case 0:
|
case 0:
|
||||||
$q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "send where " . TB_PREFIX . "movement." . $where . " = '$village' and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "send.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 0 ORDER BY endtime ASC";
|
$q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "send where " . TB_PREFIX . "movement.`" . $where . "` IN(".implode(', ', $village).") and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "send.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 0 ORDER BY endtime ASC";
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
$q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "send where " . TB_PREFIX . "movement." . $where . " = '$village' and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "send.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 6 ORDER BY endtime ASC";
|
$q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "send where " . TB_PREFIX . "movement.`" . $where . "` IN(".implode(', ', $village).") and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "send.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 6 ORDER BY endtime ASC";
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
$q = "SELECT * FROM " . TB_PREFIX . "movement where " . TB_PREFIX . "movement." . $where . " = '$village' and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 2 ORDER BY endtime ASC";
|
$q = "SELECT * FROM " . TB_PREFIX . "movement where " . TB_PREFIX . "movement.`" . $where . "` IN(".implode(', ', $village).") and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 2 ORDER BY endtime ASC";
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
$q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement." . $where . " = '$village' and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 ORDER BY endtime ASC";
|
$q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement.`" . $where . "` IN(".implode(', ', $village).") and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 ORDER BY endtime ASC";
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
$q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement." . $where . " = '$village' and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 4 ORDER BY endtime ASC";
|
$q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement.`" . $where . "` IN(".implode(', ', $village).") and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 4 ORDER BY endtime ASC";
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
$q = "SELECT * FROM " . TB_PREFIX . "movement where " . TB_PREFIX . "movement." . $where . " = '$village' and sort_type = 5 and proc = 0 ORDER BY endtime ASC";
|
$q = "SELECT * FROM " . TB_PREFIX . "movement where " . TB_PREFIX . "movement.`" . $where . "` IN(".implode(', ', $village).") and sort_type = 5 and proc = 0 ORDER BY endtime ASC";
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
$q = "SELECT * FROM " . TB_PREFIX . "movement," . TB_PREFIX . "odata, " . TB_PREFIX . "attacks where " . TB_PREFIX . "odata.wref = '$village' and " . TB_PREFIX . "movement.to = $village and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "attacks.attack_type != 1 and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 ORDER BY endtime ASC";
|
$q = "SELECT * FROM " . TB_PREFIX . "movement," . TB_PREFIX . "odata, " . TB_PREFIX . "attacks where " . TB_PREFIX . "odata.wref IN(".implode(', ', $village).") and " . TB_PREFIX . "movement.to IN(".implode(', ', $village).") and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "attacks.attack_type != 1 and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 ORDER BY endtime ASC";
|
||||||
//$q = "SELECT * FROM " . TB_PREFIX . "movement," . TB_PREFIX . "odata, " . TB_PREFIX . "attacks where " . TB_PREFIX . "odata.conqured = $village and " . TB_PREFIX . "movement.to = " . TB_PREFIX . "odata.wref and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 ORDER BY endtime ASC";
|
//$q = "SELECT * FROM " . TB_PREFIX . "movement," . TB_PREFIX . "odata, " . TB_PREFIX . "attacks where " . TB_PREFIX . "odata.conqured IN(".implode(', ', $village).") and " . TB_PREFIX . "movement.to = " . TB_PREFIX . "odata.wref and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 ORDER BY endtime ASC";
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
$q = "SELECT * FROM " . TB_PREFIX . "movement where " . TB_PREFIX . "movement." . $where . " = '$village' and sort_type = 4 and ref = 0 and proc = 0 ORDER BY endtime ASC";
|
$q = "SELECT * FROM " . TB_PREFIX . "movement where " . TB_PREFIX . "movement.`" . $where . "` IN(".implode(', ', $village).") and sort_type = 4 and ref = 0 and proc = 0 ORDER BY endtime ASC";
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
$q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement." . $where . " = '$village' and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 and " . TB_PREFIX . "attacks.attack_type = 1 ORDER BY endtime ASC";
|
$q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement.`" . $where . "` IN(".implode(', ', $village).") and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 and " . TB_PREFIX . "attacks.attack_type = 1 ORDER BY endtime ASC";
|
||||||
break;
|
break;
|
||||||
case 34:
|
case 34:
|
||||||
$q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement." . $where . " = '$village' and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 or " . TB_PREFIX . "movement." . $where . " = '$village' and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 4 ORDER BY endtime ASC";
|
$q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement.`" . $where . "` IN(".implode(', ', $village).") and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 or " . TB_PREFIX . "movement.`" . $where . "` = IN(".implode(', ', $village).") and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 4 ORDER BY endtime ASC";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$result = mysqli_query($this->dblink,$q);
|
|
||||||
$array = $this->mysqli_fetch_all($result);
|
|
||||||
|
|
||||||
self::$marketMovementCache[$type.$village.$mode] = $array;
|
$result = $this->mysqli_fetch_all(mysqli_query($this->dblink,$q));
|
||||||
return self::$marketMovementCache[$type.$village.$mode];
|
|
||||||
|
// return a single value
|
||||||
|
if (!$array_passed) {
|
||||||
|
self::$marketMovementCache[$type.$village[0].$mode] = $result;
|
||||||
|
} else {
|
||||||
|
foreach ( $result as $record ) {
|
||||||
|
self::$marketMovementCache[$type.$record[$where].$mode] = $record;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check for any missing IDs and fill them in with blanks,
|
||||||
|
// since no movements were found for these villages
|
||||||
|
foreach ($village as $key) {
|
||||||
|
if (!isset(self::$marketMovementCache[$type.$key.$mode])) {
|
||||||
|
self::$marketMovementCache[$type.$key.$mode] = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ($array_passed ? self::$marketMovementCache : self::$marketMovementCache[$type.$village[0].$mode]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addA2b($ckey, $timestamp, $to, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10, $t11, $type) {
|
function addA2b($ckey, $timestamp, $to, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10, $t11, $type) {
|
||||||
@@ -6062,8 +6109,8 @@ References: User ID/Message ID, Mode
|
|||||||
|
|
||||||
// first of all, check if we should be using cache and whether the field
|
// first of all, check if we should be using cache and whether the field
|
||||||
// required is already cached
|
// required is already cached
|
||||||
if ($use_cache && !$array_passed && ($cachedValue = self::returnCachedContent(self::$villageReinforcementsCache, $id[0].$mode)) && !is_null($cachedValue)) {
|
if ($use_cache && !$array_passed && isset(self::$villageReinforcementsCache[$id[0].$mode]) && is_array(self::$villageReinforcementsCache[$id[0].$mode]) && !count(self::$villageReinforcementsCache[$id[0].$mode])) {
|
||||||
return $cachedValue;
|
return self::$villageReinforcementsCache[$id[0].$mode];
|
||||||
} else if ($use_cache && $array_passed) {
|
} else if ($use_cache && $array_passed) {
|
||||||
// check what we can return from cache
|
// check what we can return from cache
|
||||||
$newIDs = [];
|
$newIDs = [];
|
||||||
@@ -6080,9 +6127,9 @@ References: User ID/Message ID, Mode
|
|||||||
// update remaining IDs to select and cache
|
// update remaining IDs to select and cache
|
||||||
$id = $newIDs;
|
$id = $newIDs;
|
||||||
}
|
}
|
||||||
} else if ($use_cache && !$array_passed && is_array(self::$villageReinforcementsCache[$id[0].$mode]) && !count(self::$villageReinforcementsCache[$id[0].$mode])) {
|
} else if ($use_cache && !$array_passed && ($cachedValue = self::returnCachedContent(self::$villageReinforcementsCache, $id[0].$mode)) && !is_null($cachedValue)) {
|
||||||
// special case when we have empty arrays cached for this cache only
|
// special case when we have empty arrays cached for this cache only
|
||||||
return self::$villageReinforcementsCache[$id[0].$mode];
|
return $cachedValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$mode) {
|
if(!$mode) {
|
||||||
|
|||||||
Reference in New Issue
Block a user