Merge pull request #7374 from DeadlySurprise/cashOverflowFix

Added a check for overflowing player credits
This commit is contained in:
Paul Chote
2015-02-20 17:24:57 +00:00

View File

@@ -78,10 +78,37 @@ namespace OpenRA.Traits
}
public void GiveCash(int num)
{
if (Cash < int.MaxValue)
{
try
{
checked
{
Cash += num;
}
}
catch (OverflowException)
{
Cash = int.MaxValue;
}
}
if (Earned < int.MaxValue)
{
try
{
checked
{
Earned += num;
}
}
catch (OverflowException)
{
Earned = int.MaxValue;
}
}
}
public bool TakeCash(int num)
{