Skip to content

Commit

Permalink
General fixes
Browse files Browse the repository at this point in the history
+Fixed an exploit that permitted to starts other players' farm lists
+Fixed an exploit that permitted to save our raids to other players'
farm lists
+Fixed an exploit that permitted to edit other players' farm lists
+Fixed a rounding upkeep bug
+Moved the whole startRaid.tpl to a new method in Units.php
+A lot of clean-up
+Improoved indentation
+In the raid list, the "carry" image will now show to the left of an
attack
+Fixed a bug that displayed the wrong loot to returning troops released
by traps
+General minor bug fixing and improovements
-Deleted a lot of redundant code
iopietro committed May 4, 2018
1 parent 49bc3c5 commit cf74514
Showing 17 changed files with 763 additions and 1,275 deletions.
104 changes: 6 additions & 98 deletions GameEngine/Admin/database.php
Original file line number Diff line number Diff line change
@@ -648,10 +648,6 @@ public function returnTroops($wref) {
} else {
$enforce['hero']='0';
}

$artefact = count($database->getOwnUniqueArtefactInfo2($from['owner'],2,3,0));
$artefact1 = count($database->getOwnUniqueArtefactInfo2($enforce['from'],2,1,1));
$artefact2 = count($database->getOwnUniqueArtefactInfo2($from['owner'],2,2,0));

$troopsTime = $this->procDistanceTime($fromCor, $toCor, min($speeds), $enforce['from']);
$time = $database->getArtifactsValueInfluence($from['owner'], $enforce['from'], 2, $troopsTime);
@@ -663,27 +659,15 @@ public function returnTroops($wref) {
}


public function calculateProduction($wid,$uid,$b1,$b2,$b3,$b4,$fdata,$ocounter,$pop) {
global $technology,$database;
$normalA = $database->getOwnArtefactInfoByType($wid,4);
$largeA = $database->getOwnUniqueArtefactInfo($uid,4,2);
$uniqueA = $database->getOwnUniqueArtefactInfo($uid,4,3);
$upkeep = $this->getUpkeep($this->getAllUnits($wid),0,$wid,$uid);


$production=array();
public function calculateProduction($wid, $uid, $b1, $b2, $b3, $b4, $fdata, $ocounter, $pop) {
global $technology, $database;

$upkeep = $technology->getUpkeep($this->getAllUnits($wid), 0, $wid);
$production = [];
$production['wood'] = $this->getWoodProd($fdata, $ocounter,$b1);
$production['clay'] = $this->getClayProd($fdata, $ocounter,$b2);
$production['iron'] = $this->getIronProd($fdata, $ocounter,$b3);
if ($uniqueA['size']==3 && $uniqueA['owner']==$uid){
$production['crop'] = $this->getCropProd($fdata, $ocounter,$b4)-$pop-(($upkeep)-round($upkeep*0.50));
}elseif ($normalA['type']==4 && $normalA['size']==1 && $normalA['owner']==$uid){
$production['crop'] = $this->getCropProd($fdata, $ocounter,$b4)-$pop-(($upkeep)-round($upkeep*0.25));
}else if ($largeA['size']==2 && $largeA['owner']==$uid){
$production['crop'] = $this->getCropProd($fdata, $ocounter,$b4)-$pop-(($upkeep)-round($upkeep*0.25));
}else{
$production['crop'] = $this->getCropProd($fdata, $ocounter,$b4)-$pop-$upkeep;
}
$production['crop'] = $this->getCropProd($fdata, $ocounter,$b4) - $pop - $upkeep;
return $production;
}

@@ -852,82 +836,6 @@ function getAllUnits($base,$InVillageOnly=False,$mode=0) {
}
return $ownunit;
}

public function getUpkeep($array,$type,$vid,$uid,$prisoners=0) {
global $database;
$buildarray = array();
$buildarray = $database->getResourceLevel($vid);
$upkeep = 0;
switch($type) {
case 0:
$start = 1;
$end = 50;
break;
case 1:
$start = 1;
$end = 10;
break;
case 2:
$start = 11;
$end = 20;
break;
case 3:
$start = 21;
$end = 30;
break;
case 4:
$start = 31;
$end = 40;
break;
case 5:
$start = 41;
$end = 50;
break;
}
for($i=$start;$i<=$end;$i++) {
$k = $i-$start+1;
$unit = "u".$i;
$unit2 = "t".$k;
global $$unit;
$dataarray = $$unit;
for($j=19;$j<=38;$j++) {
if($buildarray['f'.$j.'t'] == 41) {
$horsedrinking = $j;
}
}
if($prisoners == 0){
if(isset($horsedrinking)){
if(($i==4 && $buildarray['f'.$horsedrinking] >= 10)
|| ($i==5 && $buildarray['f'.$horsedrinking] >= 15)
|| ($i==6 && $buildarray['f'.$horsedrinking] == 20)) {
$upkeep += ($dataarray['pop']-1) * $array[$unit];
} else {
$upkeep += $dataarray['pop'] * $array[$unit];
}}else{
$upkeep += $dataarray['pop'] * $array[$unit];
}
}else{
if(isset($horsedrinking)){
if(($i==4 && $buildarray['f'.$horsedrinking] >= 10)
|| ($i==5 && $buildarray['f'.$horsedrinking] >= 15)
|| ($i==6 && $buildarray['f'.$horsedrinking] == 20)) {
$upkeep += ($dataarray['pop']-1) * $array[$unit2];
} else {
$upkeep += $dataarray['pop'] * $array[$unit2];
}}else{
$upkeep += $dataarray['pop'] * $array[$unit2];
}
}
}

$unit = ($prisoners > 0) ? 't11' : 'hero';

if(!isset($array[$unit])) $array[$unit] = 0;
$upkeep += $array[$unit] * 6;

return $database->getArtifactsValueInfluence($uid, $vid, 4, $upkeep);
}

};

$admin = new adm_DB;
Loading

1 comment on commit cf74514

@prtwch
Copy link

@prtwch prtwch commented on cf74514 May 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow thanks
beautiful

Please sign in to comment.