From 19f3f697ae68c75bfbf479a4b1878e0a72500d0e Mon Sep 17 00:00:00 2001 From: YesntSoup Date: Sun, 8 Sep 2024 18:56:03 -0400 Subject: [PATCH] Change AddAchievementPoints to account for overflow and underflow This is for minisaurs in WoJ, but I think it would be a good idea in general, so I didn't limit it to WoJ. The issue happens because if you buy medicine for minisaurs. It takes away one coin, and so if you already have 0 coins, the server currently returns your coin count as int.MaxValue. This is tested in WoJ 1.1.0 and 1.21.0. I tested buying, overflowing, underflowing, using commands with big and negative values and playing games. --- src/Services/AchievementService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Services/AchievementService.cs b/src/Services/AchievementService.cs index 0a58d6e..1d38e98 100644 --- a/src/Services/AchievementService.cs +++ b/src/Services/AchievementService.cs @@ -82,7 +82,7 @@ namespace sodoff.Services { viking.AchievementPoints.Add(xpPoints); } - int initialPoints = xpPoints.Value; + int initialPoints = xpPoints.Value; xpPoints.Value += value ?? 0; if (value > 0 && initialPoints > xpPoints.Value) {