Skip to content

Commit

Permalink
GH-139 Simplify fleet array unpacking in fleet2
Browse files Browse the repository at this point in the history
  • Loading branch information
mdziekon committed Dec 7, 2020
1 parent ad44398 commit d60fcce
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions fleet2.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,19 +227,21 @@
$Fleet['storage'] = 0;
$Fleet['FuelStorage'] = 0;

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

if (
!empty($Fleet['array']) &&
is_array($Fleet['array'])
) {
foreach($Fleet['array'] as $ShipID => $ShipCount)
{
$ShipData = explode(',', $ShipData);
$ShipID = intval($ShipData[0]);
$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 d60fcce

Please sign in to comment.