Merge pull request #7374 from DeadlySurprise/cashOverflowFix
Added a check for overflowing player credits
This commit is contained in:
@@ -78,10 +78,37 @@ namespace OpenRA.Traits
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void GiveCash(int num)
|
public void GiveCash(int num)
|
||||||
|
{
|
||||||
|
if (Cash < int.MaxValue)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
checked
|
||||||
{
|
{
|
||||||
Cash += num;
|
Cash += num;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (OverflowException)
|
||||||
|
{
|
||||||
|
Cash = int.MaxValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Earned < int.MaxValue)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
checked
|
||||||
|
{
|
||||||
Earned += num;
|
Earned += num;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (OverflowException)
|
||||||
|
{
|
||||||
|
Earned = int.MaxValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public bool TakeCash(int num)
|
public bool TakeCash(int num)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user