General fixes

+Fixed an exploit that permit to maintain the crop level constant if the
page was refreshed every second, with a negative production
This commit is contained in:
iopietro
2018-05-06 15:20:58 +02:00
parent bd033334c4
commit ec63b04587
3 changed files with 11 additions and 13 deletions
+1 -2
View File
@@ -3974,7 +3974,6 @@ class Automation {
$unitArrays = $this->getAllUnits($wref, false);
$villageUpkeep = $getVillage['pop'] + $technology->getUpkeep($unitArrays, 0, $wref);
$starv = $getVillage['starv'];
if ($crop < $villageUpkeep){
//Add starvation data
$database->setVillageFields($wref, ['starv', 'starvupdate'], [$villageUpkeep, time()]);
@@ -4156,7 +4155,7 @@ class Automation {
break;
}
$database->modifyResource($starv['wref'], 0, 0, 0, max(intval($newCrop), 0), 1);
$database->modifyResource($starv['wref'], 0, 0, 0, max($newCrop, 0), 1);
$database->setVillageField($starv['wref'], ['starv', 'starvupdate'], [$upkeep, $time]);
}
}
+8 -9
View File
@@ -3274,7 +3274,7 @@ class MYSQLi_DB implements IDbConnection {
/////////////ADDED BY BRAINIAC - THANK YOU
function modifyResource($vid, $wood, $clay, $iron, $crop, $mode) {
list($vid, $wood, $clay, $iron, $crop, $mode) = $this->escape_input((int) $vid, (int) $wood, (int) $clay, (int) $iron, (int) $crop, $mode);
list($vid, $wood, $clay, $iron, $crop, $mode) = $this->escape_input((int) $vid, $wood, $clay, $iron, $crop, $mode);
$sign = (!$mode ? '-' : '+');
$q = "
@@ -7407,17 +7407,16 @@ References: User ID/Message ID, Mode
return $cachedValue;
}
$wood = $cropo = $clay = $iron = 0;
$basecrop = $grainmill = $bakery = 0;
$basecrop = $grainmill = $bakery = $cropo = 0;
$owner = $this->getVrefField($wref, 'owner', $use_cache);
$bonus = $this->getUserField($owner, 'b4', 0);
$buildarray = $this->getResourceLevel($wref);
$cropholder = [];
for($i = 1; $i <= 38; $i++){
if($buildarray['f'.$i.'t'] == 4) array_push($cropholder, 'f' . $i);
if($buildarray['f'.$i.'t'] == 8) $grainmill = $buildarray['f' . $i];
if($buildarray['f'.$i.'t'] == 9) $bakery = $buildarray['f' . $i];
if($buildarray['f'.$i.'t'] == 4) array_push($cropholder, 'f'.$i);
if($buildarray['f'.$i.'t'] == 8) $grainmill = $buildarray['f'.$i];
if($buildarray['f'.$i.'t'] == 9) $bakery = $buildarray['f'.$i];
}
$q = "SELECT type FROM `" . TB_PREFIX . "odata` WHERE conqured = ".(int) $wref;
@@ -7440,14 +7439,14 @@ References: User ID/Message ID, Mode
for($i = 0; $i <= count($cropholder) - 1; $i++){
$basecrop += $bid4[$buildarray[$cropholder[$i]]]['prod'];
}
$crop = $basecrop + $basecrop * 0.25 * $cropo;
if($grainmill >= 1 || $bakery >= 1){
$crop += $basecrop / 100 * ((isset($bid8[$grainmill]['attri']) ? $bid8[$grainmill]['attri'] : 0) + (isset($bid9[$bakery]['attri']) ? $bid9[$bakery]['attri'] : 0));
}
if($bonus > time()){
$crop *= 1.25;
}
if($bonus > time()) $crop *= 1.25;
$crop *= SPEED;
self::$cropProductionStarvationValueCache[$wref] = $crop;
+2 -2
View File
@@ -37,9 +37,9 @@ class Village {
//add new line code
//check exist village if from village destroy to avoid error msg.
if ( !$database->checkVilExist($this->wid) ) {
if(!$database->checkVilExist($this->wid)){
$this->wid=$database->getVillageID($session->uid);
$_SESSION['wid']=$this->wid;
$_SESSION['wid'] = $this->wid;
}
$this->LoadTown();