Distance calculation optimization and bug fixing

-Removed a lot of redundant code and put into a function
+Fixed a bug that permitted to found a new village in already founded
village
+Fixed a bug that permitted to found in an oasis
+Fixed a bug that permitted to hack the time you need to found a new
village
+Fixed a bug that permitted to found a new village to an inexistent one
This commit is contained in:
iopietro
2018-04-29 00:49:24 +02:00
parent 48410e960b
commit a40accc101
11 changed files with 201 additions and 454 deletions
+2 -29
View File
@@ -283,35 +283,8 @@ $end = $tribe * 10;
<?php
$speeds = [];
$scout = 1;
//find slowest unit.
for($i = 1; $i <= 11; $i++)
{
if (isset($process['t'.$i]))
{
if(!empty($process['t'.$i]) && $process['t'.$i] > 0)
{
if ($i < 11) $speeds[] = ${'u'.(($session->tribe-1) * 10 + $i)}['speed'];
else
{
$hero_unit = $database->getHeroField($uid, 'unit');
$speeds[] = ${'u'.$hero_unit}['speed'];
}
if($i != 4) $scout = 0;
}
}
}
if($scout) $process['c'] = 1;
$ownVillage = $database->getCoor($village->wid);
$from = ['x' => $ownVillage['x'], 'y' => $ownVillage['y']];
$to = ['x' => $coor['x'], 'y' => $coor['y']];
$troopsTime = $generator->procDistanceTime($from, $to, min($speeds), 1);
<?php
$troopsTime = $units->getWalkingTroopsTime($village->wid, $process[0], $session->uid, $session->tribe, $process, 1, 't');
$time = $database->getArtifactsValueInfluence($session->uid, $village->wid, 2, $troopsTime);
?>