fix off-by-one error in slot unassignment logic

This commit is contained in:
FalsePattern committed 2025-05-29 16:26:56 +02:00
1 parent 9ab489d3a1
commit 43002e4d5a
1 file changed
+2 -2
@@ -110,7 +110,7 @@ public class BaubleExpandedSlots {
if(total > maximumOfType) {
total -= maximumOfType;
for(int i = 0; i < total; i++) {
for(int slotToCheck = slotsCurrentlyUsed(); slotToCheck > 0; slotToCheck--) {
for(int slotToCheck = slotsCurrentlyUsed(); slotToCheck >= 0; slotToCheck--) {
if(assignedSlots[slotToCheck].equals(type)) {
for(int slotToMove = slotToCheck + 1; slotToMove < slotLimit; slotToMove++) {
assignedSlots[slotToMove - 1] = assignedSlots[slotToMove];
@@ -156,7 +156,7 @@ public class BaubleExpandedSlots {
*/
public static boolean tryUnassignSlotOfType(String type) {
if(newSlotsRemaining < slotLimit && type != null && !type.equals(unknownType) && Loader.instance().getLoaderState() == LoaderState.PREINITIALIZATION) {
for(int slotToCheck = slotsCurrentlyUsed(); slotToCheck > 0; slotToCheck--) {
for(int slotToCheck = slotsCurrentlyUsed(); slotToCheck >= 0; slotToCheck--) {
if(assignedSlots[slotToCheck].equals(type)) {
for(int slotToMove = slotToCheck + 1; slotToMove < slotLimit; slotToMove++) {
assignedSlots[slotToMove - 1] = assignedSlots[slotToMove];