Skip to content

Commit

Permalink
GH-139 Simplify fleet array unpacking in fleet3
Browse files Browse the repository at this point in the history
  • Loading branch information
mdziekon committed Dec 7, 2020
1 parent 1af17ed commit dc6f66b
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions fleet3.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ function messageRed($Text, $Title)
$Target['planet'] = intval($_POST['planet']);
$Target['type'] = intval($_POST['planettype']);
$Fleet['Speed'] = floatval($_POST['speed']);
$Fleet['array'] = explode(';', $_POST['FleetArray']);
$Fleet['UseQuantum'] = (isset($_POST['usequantumgate']) && $_POST['usequantumgate'] == 'on' ? true : false);
$Fleet['resources'] = array('metal' => $_POST['resource1'], 'crystal' => $_POST['resource2'], 'deuterium' => $_POST['resource3']);
$Fleet['ExpeTime'] = intval($_POST['expeditiontime']);
Expand Down Expand Up @@ -405,18 +404,20 @@ function messageRed($Text, $Title)
$Fleet['FuelStorage'] = 0;
$Fleet['TotalResStorage'] = 0;

$Fleet['array'] = String2Array($_POST['FleetArray']);
$FleetArray = array();
if(!empty($Fleet['array']) AND (array)$Fleet['array'] === $Fleet['array'])
{
foreach($Fleet['array'] as $ShipData)
{
$ShipData = explode(',', $ShipData);
$ShipID = intval($ShipData[0]);

if (
!empty($Fleet['array']) &&
is_array($Fleet['array'])
) {
foreach ($Fleet['array'] as $ShipID => $ShipCount) {
$ShipID = intval($ShipID);
if(in_array($ShipID, $_Vars_ElementCategories['fleet']))
{
if(!empty($_Vars_Prices[$ShipID]['engine']))
{
$ShipCount = floor($ShipData[1]);
$ShipCount = floor($ShipCount);
if($ShipCount > 0)
{
if($_Planet[$_Vars_GameElements[$ShipID]] >= $ShipCount)
Expand Down

0 comments on commit dc6f66b

Please sign in to comment.