Skip to content

Commit

Permalink
Subpulse and PD list bug fixes
Browse files Browse the repository at this point in the history
these were breaking under certain circumstances.
  • Loading branch information
NathanH- committed Nov 11, 2014
1 parent abb4232 commit d491a66
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
3 changes: 3 additions & 0 deletions Pulsar4X/Pulsar4X.Lib/Entities/SimEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,9 @@ public int SubpulseHandler(BindingList<Faction> P, Random RNG, int tickValue)
int FiveSecondIncrements = (int)Math.Floor((float)MissileTimeToHit / 5.0f);
desiredTime = FiveSecondIncrements * 5;

if (desiredTime == 0)
desiredTime = (int)Constants.TimeInSeconds.FiveSeconds;

/// <summary>
/// I want to pause right before the missile hits.
/// </summary>
Expand Down
26 changes: 17 additions & 9 deletions Pulsar4X/Pulsar4X.UI/Handlers/Ships.cs
Original file line number Diff line number Diff line change
Expand Up @@ -520,18 +520,26 @@ private void SetPDModeButton_Click(object sender, EventArgs e)
/// <summary>
/// Remove the FC from the point defense FC list.
/// </summary>
if (_CurrnetFaction.PointDefense[CurrentSystem].PointDefenseFC.ContainsKey(_CurrnetShip.ShipMFC[_CurrnetFC.componentIndex]) == true)
if (_CurrnetFaction.PointDefense.Count != 0)
{
_CurrnetFaction.PointDefense[CurrentSystem].RemoveComponent(_CurrnetShip.ShipMFC[_CurrnetFC.componentIndex]);
}
if(_CurrnetFaction.PointDefense.ContainsKey(CurrentSystem) == true)
{
if (_CurrnetFaction.PointDefense[CurrentSystem].PointDefenseFC.ContainsKey(_CurrnetShip.ShipMFC[_CurrnetFC.componentIndex]) == true)
{
_CurrnetFaction.PointDefense[CurrentSystem].RemoveComponent(_CurrnetShip.ShipMFC[_CurrnetFC.componentIndex]);
}

/// <summary>
/// cleanup the starsystem so that the point defense list isn't cluttered.
/// </summary>
if (_CurrnetFaction.PointDefense[CurrentSystem].PointDefenseFC.Count == 0)
{
_CurrnetFaction.PointDefense.Remove(CurrentSystem);
/// <summary>
/// Cleanup the starsystem so that the point defense list isn't cluttered.
/// </summary>
if (_CurrnetFaction.PointDefense[CurrentSystem].PointDefenseFC.Count == 0)
{
_CurrnetFaction.PointDefense.Remove(CurrentSystem);
}
}
}


}
}
else
Expand Down

0 comments on commit d491a66

Please sign in to comment.