diff --git a/OpenRA.Game/Traits/Player/PlayerResources.cs b/OpenRA.Game/Traits/Player/PlayerResources.cs index 18c5467524..8a3b2f4c8f 100644 --- a/OpenRA.Game/Traits/Player/PlayerResources.cs +++ b/OpenRA.Game/Traits/Player/PlayerResources.cs @@ -79,8 +79,35 @@ namespace OpenRA.Traits public void GiveCash(int num) { - Cash += num; - Earned += 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)