Skip to content

Commit

Permalink
Handle errors cause by item overflow gracefully
Browse files Browse the repository at this point in the history
-It's still possible to get too many clips by buying to 30 held while
also holding one in your gun
-Now when you load too many clips you get the excess deleted instead of
a game crash
  • Loading branch information
Joseph G authored and Joseph G committed Aug 28, 2016
1 parent 6c8466a commit b31e0b9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions main/src/org/destinationsol/game/item/ItemContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,13 @@ public void add(SolItem addedItem) {
List<SolItem> group = myGroups.get(i);
SolItem item = group.get(0);
if (item.isSame(addedItem)) {
if (group.size() >= MAX_GROUP_SZ) throw new AssertionError("reached group size limit");
group.add(addedItem);
mySize++;
if ((group.size() < MAX_GROUP_SZ))
{
group.add(addedItem);
mySize++;
}
return;

}
}
if (myGroups.size() >= MAX_GROUP_COUNT) throw new AssertionError("reached group count limit");
Expand Down

0 comments on commit b31e0b9

Please sign in to comment.