refactor: preparation to vdata queries consolidation

#313
This commit is contained in:
Martin Ambrus
2017-11-20 00:52:24 +01:00
parent 66132a7cdf
commit c27b397016
2 changed files with 10 additions and 10 deletions
+1 -1
View File
@@ -4242,7 +4242,7 @@ class Automation {
}
$crop = $database->getCropProdstarv($train['vref'], false);
$unitarrays = $this->getAllUnits($train['vref'], false);
$village = $database->getVillage($train['vref'], false);
$village = $database->getVillage($train['vref'], 0, false);
$upkeep = $village['pop'] + $this->getUpkeep($unitarrays, 0);
$starv = $database->getVillageField($train['vref'],"starv");
if ($crop < $upkeep){
+9 -9
View File
@@ -1001,7 +1001,7 @@ class MYSQLi_DB implements IDbConnection {
}
function getVrefField($ref, $field, $use_cache = true) {
return $this->getVillage($ref, $use_cache)[$field];
return $this->getVillage($ref, 0, $use_cache)[$field];
}
// no need to cache this method
@@ -1685,7 +1685,7 @@ class MYSQLi_DB implements IDbConnection {
return self::$villageIDsCacheSimple[$uid];
}
function getVillage($vid, $use_cache = true) {
function getVillage($vid, $mode = 0, $use_cache = true) {
list($vid) = $this->escape_input((int) $vid);
// first of all, check if we should be using cache and whether the field
@@ -1803,7 +1803,7 @@ class MYSQLi_DB implements IDbConnection {
function getVillageField($ref, $field, $use_cache = true) {
// return all data, don't waste time by selecting fields one by one
$villageArray = $this->getVillage($ref, $use_cache);
$villageArray = $this->getVillage($ref, 0, $use_cache);
$result = (isset($villageArray[$field]) ? $villageArray[$field] : null);
if($result){
@@ -1828,7 +1828,7 @@ class MYSQLi_DB implements IDbConnection {
function getVillageFields($ref, $fields, $use_cache = true) {
// return all data, don't waste time by selecting fields one by one
return $this->getVillage($ref, $use_cache);
return $this->getVillage($ref, 0, $use_cache);
/*list($ref, $field) = $this->escape_input((int) $ref, $fields);
@@ -6068,27 +6068,27 @@ References: User ID/Message ID, Mode
//MARKET FIXES
function getWoodAvailable($wref, $use_cache = true) {
// return from cache
return $this->getVillage($wref, $use_cache)['wood'];
return $this->getVillage($wref, 0, $use_cache)['wood'];
}
function getClayAvailable($wref, $use_cache = true) {
// return from cache
return $this->getVillage($wref, $use_cache)['clay'];
return $this->getVillage($wref, 0, $use_cache)['clay'];
}
function getIronAvailable($wref, $use_cache = true) {
// return from cache
return $this->getVillage($wref, $use_cache)['iron'];
return $this->getVillage($wref, 0, $use_cache)['iron'];
}
function getCropAvailable($wref, $use_cache = true) {
// return from cache
return $this->getVillage($wref, $use_cache)['crop'];
return $this->getVillage($wref, 0, $use_cache)['crop'];
}
function Getowner($vid) {
// return from cache
return $this->getVillage($vid, $use_cache)['owner'];
return $this->getVillage($vid, 0, $use_cache)['owner'];
}
/**