From b31e0b9e7c33a8492e3f5f8ee3ae84011861a1af Mon Sep 17 00:00:00 2001 From: Joseph G Date: Sun, 28 Aug 2016 09:34:00 -0600 Subject: [PATCH] Handle errors cause by item overflow gracefully -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 --- main/src/org/destinationsol/game/item/ItemContainer.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/main/src/org/destinationsol/game/item/ItemContainer.java b/main/src/org/destinationsol/game/item/ItemContainer.java index d8f058fce..02689af1e 100644 --- a/main/src/org/destinationsol/game/item/ItemContainer.java +++ b/main/src/org/destinationsol/game/item/ItemContainer.java @@ -69,10 +69,13 @@ public void add(SolItem addedItem) { List 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");