Skip to content

Commit

Permalink
Economics UI fix and cargolist fix
Browse files Browse the repository at this point in the history
infrastructure display is rounded, and cargolists now don't add items of
0 tons to cargo ships.
  • Loading branch information
NathanH- committed Apr 2, 2016
1 parent 9d3470b commit 6cab857
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
15 changes: 15 additions & 0 deletions Pulsar4X/Pulsar4X.Lib/Entities/StarSystem/TaskGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3681,6 +3681,7 @@ public bool LoadCargo(Population Pop, Installation.InstallationType InstType, in
if (Ships[loop].ShipClass.TotalCargoCapacity != 0 && RemainingShipTonnage != 0)
{
int ShipMassToLoad = Math.Min(MassToLoad, RemainingShipTonnage);


/// <summary>
/// Load the mass onto the taskgroup as a whole for display purposes.
Expand All @@ -3701,6 +3702,8 @@ public bool LoadCargo(Population Pop, Installation.InstallationType InstType, in
MassToLoad = MassToLoad - ShipMassToLoad;
Ships[loop].CurrentCargoTonnage = ShipMassToLoad;
}
if (MassToLoad == 0)
break;
}
return true;
}
Expand Down Expand Up @@ -3740,6 +3743,14 @@ public void UnloadCargo(Population Pop, Installation.InstallationType InstType,
CurrentCargoTonnage = CurrentCargoTonnage - ShipMassToUnload;
Ships[loop].CurrentCargoTonnage = Ships[loop].CurrentCargoTonnage - ShipMassToUnload;

/// <summary>
/// Extra sanity check
/// </summary>
if (CLE.tons == 0 && Ships[loop].CargoList.ContainsKey(InstType) == true)
{
Ships[loop].CargoList.Remove(InstType);
}

Pop.UnloadInstallation(InstType, ShipMassToUnload);
}
}
Expand Down Expand Up @@ -3817,6 +3828,8 @@ public bool LoadMineral(Population Pop, Constants.Minerals.MinerialNames MinType
MassToLoad = MassToLoad - ShipMassToLoad;
Ships[loop].CurrentCargoTonnage = ShipMassToLoad;
}
if (MassToLoad == 0)
break;
}
return true;
}
Expand Down Expand Up @@ -4026,6 +4039,8 @@ public bool LoadComponents(Population Pop, int ComponentIndex, int Limit)

MassToLoad = MassToLoad - ShipMassToLoad;
}
if (MassToLoad == 0)
break;
}

return true;
Expand Down
3 changes: 2 additions & 1 deletion Pulsar4X/Pulsar4X.UI/Handlers/Economics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2264,7 +2264,8 @@ public void RefreshSummaryCells()
{
m_oSummaryPanel.SummaryDataGrid.Rows[8 + Adjust1].Cells[1].Value = "Underground Infra not implemented";
}
m_oSummaryPanel.SummaryDataGrid.Rows[9 + Adjust1].Cells[1].Value = CurrentPopulation.Installations[(int)Installation.InstallationType.Infrastructure].Number.ToString();
Entry = String.Format("{0:N2}", CurrentPopulation.Installations[(int)Installation.InstallationType.Infrastructure].Number);
m_oSummaryPanel.SummaryDataGrid.Rows[9 + Adjust1].Cells[1].Value = Entry;

if (ColCost > 0.0f)
{
Expand Down

0 comments on commit 6cab857

Please sign in to comment.