Skip to content

Commit

Permalink
GH-139 Early return when checking planet's fuel amount
Browse files Browse the repository at this point in the history
  • Loading branch information
mdziekon committed Dec 21, 2020
1 parent 6562e9a commit 66ad162
Showing 1 changed file with 43 additions and 46 deletions.
89 changes: 43 additions & 46 deletions ajax/galaxyfleet.php
Original file line number Diff line number Diff line change
Expand Up @@ -481,66 +481,63 @@ function CreateReturn($ReturnCode)
$fleet['start_time'] = $duration + $Time;
$fleet['end_time'] = (2 * $duration) + $Time;

if($CurrentPlanet['deuterium'] >= $consumption)
if ($CurrentPlanet['deuterium'] < $consumption) {
CreateReturn('607');
}

$FleetStorage = $_Vars_Prices[$ShipID]['capacity'] * $ShipCount;
if($Mission == 6)
{
$FleetStorage = $_Vars_Prices[$ShipID]['capacity'] * $ShipCount;
if($Mission == 6)
// Try to SlowDown fleet only if it's Espionage Mission
while($FleetStorage < $consumption)
{
// Try to SlowDown fleet only if it's Espionage Mission
while($FleetStorage < $consumption)
$GenFleetSpeed = next($availableSpeeds);
if($GenFleetSpeed !== false)
{
$GenFleetSpeed = next($availableSpeeds);
if($GenFleetSpeed !== false)
{
$duration = getFlightDuration([
'speedFactor' => $GenFleetSpeed,
'distance' => $distance,
'maxShipsSpeed' => $MaxFleetSpeed
]);
$consumption = getFlightTotalConsumption(
[
'ships' => [
$ShipID => $ShipCount
],
'distance' => $distance,
'duration' => $duration,
$duration = getFlightDuration([
'speedFactor' => $GenFleetSpeed,
'distance' => $distance,
'maxShipsSpeed' => $MaxFleetSpeed
]);
$consumption = getFlightTotalConsumption(
[
'ships' => [
$ShipID => $ShipCount
],
$_User
);
'distance' => $distance,
'duration' => $duration,
],
$_User
);

$fleet['start_time'] = $duration + $Time;
$fleet['end_time'] = (2 * $duration) + $Time;
}
else
{
break;
}
$fleet['start_time'] = $duration + $Time;
$fleet['end_time'] = (2 * $duration) + $Time;
}
}

if($FleetStorage >= $consumption)
{
switch($Mission)
else
{
case 6: //Spy
$TargetOwner = $TargetUser;
break;
case 8: //Recycling
$TargetOwner = 0;
break;
case 7: //Colonization
$TargetOwner = 0;
break;
break;
}
}
else
}

if($FleetStorage >= $consumption)
{
switch($Mission)
{
CreateReturn('608');
case 6: //Spy
$TargetOwner = $TargetUser;
break;
case 8: //Recycling
$TargetOwner = 0;
break;
case 7: //Colonization
$TargetOwner = 0;
break;
}
}
else
{
CreateReturn('607');
CreateReturn('608');
}

if(!isset($TargetID) || $TargetID <= 0)
Expand Down

0 comments on commit 66ad162

Please sign in to comment.