Skip to content

Commit

Permalink
GH-90 Fix dev dump creation when iterating over element categories & …
Browse files Browse the repository at this point in the history
…simplify it
  • Loading branch information
mdziekon committed Jul 26, 2020
1 parent 27f27d8 commit d8d9925
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions admin/scripts/script.createUserDevDump.php
Expand Up @@ -56,42 +56,42 @@
$Point['planets'][$PlanetData['id']]['lu'] = $PlanetData['last_update'];
$Point['planets'][$PlanetData['id']]['res'] = floor($PlanetData['metal']).','.floor($PlanetData['crystal']).','.floor($PlanetData['deuterium']);

$planetEntryRef = &$Point['planets'][$PlanetData['id']];

foreach($_Vars_ElementCategories as $Key => $Array)
{
if(in_array($Key, array('tech', 'buildOn', 'units')))
{
foreach ($_Vars_ElementCategories as $categoryKey => $categoryElementIDs) {
if (!in_array($categoryKey, [ 'build', 'prod', 'fleet', 'defense', 'rockets' ])) {
continue;
}
if($Key != 'build')
{
if($Key != 'prod')
{
foreach($Array as $ElementID)
{
if(isset($PlanetData[$_Vars_GameElements[$ElementID]]) && $PlanetData[$_Vars_GameElements[$ElementID]] > 0)
{
$Point['planets'][$PlanetData['id']]['f'][] = "{$ElementID},{$PlanetData[$_Vars_GameElements[$ElementID]]}";
}
}
}
else
{
foreach($Array as $ElementID)
{
$Point['planets'][$PlanetData['id']]['p'][] = $ElementID.','.$PlanetData[$_Vars_GameElements[$ElementID].'_workpercent'];
}

if ($categoryKey == 'prod') {
foreach ($categoryElementIDs as $elementID) {
$planetEntryRef['p'][] = $elementID.','.$PlanetData[$_Vars_GameElements[$elementID].'_workpercent'];
}

continue;
}
else
{
foreach($Array as $BuildID)
{
if(isset($PlanetData[$_Vars_GameElements[$BuildID]]) && $PlanetData[$_Vars_GameElements[$BuildID]] > 0)
{
$Point['planets'][$PlanetData['id']]['b'][] = "{$BuildID},{$PlanetData[$_Vars_GameElements[$BuildID]]}";
}

$inserter = function () {};

if ($categoryKey == 'build') {
$inserter = function ($value) use (&$planetEntryRef) {
$planetEntryRef['b'][] = $value;
};
} else {
$inserter = function ($value) use (&$planetEntryRef) {
$planetEntryRef['f'][] = $value;
};
}

foreach ($categoryElementIDs as $elementID) {
if (
!isset($PlanetData[$_Vars_GameElements[$elementID]]) ||
$PlanetData[$_Vars_GameElements[$elementID]] <= 0
) {
continue;
}

$inserter("{$elementID},{$PlanetData[$_Vars_GameElements[$elementID]]}");
}
}
}
Expand Down

0 comments on commit d8d9925

Please sign in to comment.