Skip to content

Commit

Permalink
Cap at max instead of full preventing overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruling-0 committed Jan 17, 2025
1 parent 43715af commit 6e14d1b
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,11 @@ public static int addCurrentEssenceToMaximum(String ownerName, int addedEssence,

int currEss = data.currentEssence;

if (currEss >= event.maximum || Integer.MAX_VALUE - event.addedAmount < currEss) {
if (currEss >= event.maximum) {
return 0;
}

int newEss = Math.min(event.maximum, currEss + event.addedAmount);
int newEss = (int) Math.min(Integer.MAX_VALUE, Math.min(event.maximum, (long) currEss + event.addedAmount));
if (event.getResult() != Event.Result.DENY) {
data.currentEssence = newEss;
}
Expand Down

0 comments on commit 6e14d1b

Please sign in to comment.