From 9b773dc6a6a2a81badd96f2f609e1e305ebe833d Mon Sep 17 00:00:00 2001 From: alwaysintreble Date: Thu, 15 Feb 2024 21:26:29 -0600 Subject: [PATCH 1/8] Fill: crash if we have unfilled locations --- Fill.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Fill.py b/Fill.py index ae44710469e4..fdf59eba3b65 100644 --- a/Fill.py +++ b/Fill.py @@ -487,6 +487,8 @@ def mark_for_locking(location: Location): locations_counter.update(location.player for location in unfilled) print_data = {"items": items_counter, "locations": locations_counter} logging.info(f'Per-Player counts: {print_data})') + if unfilled: + raise FillError(f"Not enough items to fill all locations.") def flood_items(multiworld: MultiWorld) -> None: From 1d9298bd038d291659803e13ab6943e18f2d3a36 Mon Sep 17 00:00:00 2001 From: alwaysintreble Date: Fri, 17 May 2024 23:55:25 -0500 Subject: [PATCH 2/8] if the counts are different per player, log those --- Fill.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Fill.py b/Fill.py index 48fd007d20e9..641698423770 100644 --- a/Fill.py +++ b/Fill.py @@ -501,7 +501,25 @@ def mark_for_locking(location: Location): print_data = {"items": items_counter, "locations": locations_counter} logging.info(f"Per-Player counts: {print_data})") if unfilled: - raise FillError(f"Not enough items to fill all locations.") + for player in multiworld.player_ids: + locs_diff = locations_counter[player] - items_counter[player] + if locs_diff: + logging.warning( + f"Player {multiworld.get_player_name(player)} had {locs_diff} more locations than items.") + raise FillError( + f"Unable to fill all locations.\n" + + f"Unfilled Locations({len(unfilled)}): {unfilled}" + ) + else: + for player in multiworld.player_ids: + items_diff = items_counter[player] - locations_counter[player] + if items_diff: + logging.warning( + f"Player {multiworld.get_player_name(player)} had {items_diff} more items than locations.") + logging.warning( + f"Unable to place all items.\n" + + f"Unplaced items({len(unplaced)}): {unplaced}" + ) def flood_items(multiworld: MultiWorld) -> None: From 1191c8d250d0070222296d36a3f045bb12011a3b Mon Sep 17 00:00:00 2001 From: Aaron Wagener Date: Tue, 9 Jul 2024 10:41:22 -0500 Subject: [PATCH 3/8] only raise for unfilled locations if there are actually more locs than items Co-authored-by: Exempt-Medic <60412657+Exempt-Medic@users.noreply.github.com> --- Fill.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Fill.py b/Fill.py index 641698423770..4419f2ba67b3 100644 --- a/Fill.py +++ b/Fill.py @@ -503,7 +503,7 @@ def mark_for_locking(location: Location): if unfilled: for player in multiworld.player_ids: locs_diff = locations_counter[player] - items_counter[player] - if locs_diff: + if locs_diff > 0: logging.warning( f"Player {multiworld.get_player_name(player)} had {locs_diff} more locations than items.") raise FillError( From 3b41124d1c25032e6c5f754dd41dcdfbbed2b3ff Mon Sep 17 00:00:00 2001 From: alwaysintreble Date: Wed, 10 Jul 2024 11:46:52 -0500 Subject: [PATCH 4/8] only do the subtraction once --- Fill.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Fill.py b/Fill.py index 21fe9e5e72a3..44b0e04552d2 100644 --- a/Fill.py +++ b/Fill.py @@ -542,22 +542,23 @@ def mark_for_locking(location: Location): items_counter.update(item.player for item in unplaced) print_data = {"items": items_counter, "locations": locations_counter} logging.info(f"Per-Player counts: {print_data})") + player_diffs = locations_counter - items_counter if unfilled: for player in multiworld.player_ids: - locs_diff = locations_counter[player] - items_counter[player] - if locs_diff > 0: + player_diff = player_diffs[player] + if player_diff > 0: logging.warning( - f"Player {multiworld.get_player_name(player)} had {locs_diff} more locations than items.") + f"Player {multiworld.get_player_name(player)} had {player_diff} more locations than items.") raise FillError( f"Unable to fill all locations.\n" + f"Unfilled Locations({len(unfilled)}): {unfilled}" ) else: for player in multiworld.player_ids: - items_diff = items_counter[player] - locations_counter[player] - if items_diff: + player_diff = player_diffs[player] + if player_diff > 0: logging.warning( - f"Player {multiworld.get_player_name(player)} had {items_diff} more items than locations.") + f"Player {multiworld.get_player_name(player)} had {player_diff} more items than locations.") logging.warning( f"Unable to place all items.\n" + f"Unplaced items({len(unplaced)}): {unplaced}" From ae35da52cd36ae77cf322d5ea391115f6500c6e2 Mon Sep 17 00:00:00 2001 From: alwaysintreble Date: Wed, 10 Jul 2024 11:48:17 -0500 Subject: [PATCH 5/8] reduce nesting by a level --- Fill.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/Fill.py b/Fill.py index 44b0e04552d2..7afc688e6c19 100644 --- a/Fill.py +++ b/Fill.py @@ -543,22 +543,20 @@ def mark_for_locking(location: Location): print_data = {"items": items_counter, "locations": locations_counter} logging.info(f"Per-Player counts: {print_data})") player_diffs = locations_counter - items_counter + for player in multiworld.player_ids: + player_diff = player_diffs[player] + if player_diff > 0: + logging.warning( + f"Player {multiworld.get_player_name(player)} had {player_diff} more locations than items.") + elif player_diff < 0: + logging.warning( + f"Player {multiworld.get_player_name(player)} had {player_diff} more items than locations.") if unfilled: - for player in multiworld.player_ids: - player_diff = player_diffs[player] - if player_diff > 0: - logging.warning( - f"Player {multiworld.get_player_name(player)} had {player_diff} more locations than items.") raise FillError( f"Unable to fill all locations.\n" + f"Unfilled Locations({len(unfilled)}): {unfilled}" ) else: - for player in multiworld.player_ids: - player_diff = player_diffs[player] - if player_diff > 0: - logging.warning( - f"Player {multiworld.get_player_name(player)} had {player_diff} more items than locations.") logging.warning( f"Unable to place all items.\n" + f"Unplaced items({len(unplaced)}): {unplaced}" From e0d173b920c499b146a07096f6a7135176b9c603 Mon Sep 17 00:00:00 2001 From: alwaysintreble Date: Sat, 4 Jan 2025 19:53:07 -0600 Subject: [PATCH 6/8] make two separate diff counters because counter - counter doesn't create a counter with negative numbers for some reason --- Fill.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Fill.py b/Fill.py index bc83a130b3f6..4a69a3530745 100644 --- a/Fill.py +++ b/Fill.py @@ -569,15 +569,16 @@ def mark_for_locking(location: Location): items_counter.update(item.player for item in unplaced) print_data = {"items": items_counter, "locations": locations_counter} logging.info(f"Per-Player counts: {print_data})") - player_diffs = locations_counter - items_counter + + more_locations = locations_counter - items_counter + more_items = items_counter - locations_counter for player in multiworld.player_ids: - player_diff = player_diffs[player] - if player_diff > 0: + if more_locations[player]: logging.warning( - f"Player {multiworld.get_player_name(player)} had {player_diff} more locations than items.") - elif player_diff < 0: + f"Player {multiworld.get_player_name(player)} had {more_locations[player]} more locations than items.") + elif more_items[player]: logging.warning( - f"Player {multiworld.get_player_name(player)} had {player_diff} more items than locations.") + f"Player {multiworld.get_player_name(player)} had {more_items[player]} more items than locations.") if unfilled: raise FillError( f"Unable to fill all locations.\n" + From e4c6f67255ef816ea929cfb511c06d095eb64173 Mon Sep 17 00:00:00 2001 From: alwaysintreble Date: Sat, 4 Jan 2025 19:54:19 -0600 Subject: [PATCH 7/8] change the logging for more locations to error instead of warning since that one crashes --- Fill.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Fill.py b/Fill.py index 4a69a3530745..7ec7e73ec688 100644 --- a/Fill.py +++ b/Fill.py @@ -574,7 +574,7 @@ def mark_for_locking(location: Location): more_items = items_counter - locations_counter for player in multiworld.player_ids: if more_locations[player]: - logging.warning( + logging.error( f"Player {multiworld.get_player_name(player)} had {more_locations[player]} more locations than items.") elif more_items[player]: logging.warning( From 19a3366537cbc88a9fff6154c0e918fc20ad3f61 Mon Sep 17 00:00:00 2001 From: Aaron Wagener Date: Sun, 5 Jan 2025 20:51:52 -0600 Subject: [PATCH 8/8] Update Fill.py Co-authored-by: Exempt-Medic <60412657+Exempt-Medic@users.noreply.github.com> --- Fill.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Fill.py b/Fill.py index 7ec7e73ec688..d6aff096f78d 100644 --- a/Fill.py +++ b/Fill.py @@ -582,7 +582,7 @@ def mark_for_locking(location: Location): if unfilled: raise FillError( f"Unable to fill all locations.\n" + - f"Unfilled Locations({len(unfilled)}): {unfilled}" + f"Unfilled locations({len(unfilled)}): {unfilled}" ) else: logging.warning(