From ce09144261724a6c058ba8f2b3f680a522364548 Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Wed, 8 Jan 2025 00:30:03 +0100 Subject: [PATCH] Core: add creation reason to filler --- Fill.py | 4 ++-- Main.py | 3 ++- worlds/AutoWorld.py | 6 +++++- worlds/subnautica/__init__.py | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Fill.py b/Fill.py index a040794fd1..9fb190784f 100644 --- a/Fill.py +++ b/Fill.py @@ -316,7 +316,7 @@ def remaining_fill(multiworld: MultiWorld, for item in unplaced_items: logging.debug(f"Moved {item} to start_inventory to prevent fill failure.") multiworld.push_precollected(item) - last_batch.append(multiworld.worlds[item.player].create_filler()) + last_batch.append(multiworld.worlds[item.player].create_filler("panic_fill")) remaining_fill(multiworld, locations, unplaced_items, name + " Start Inventory Retry") else: raise FillError(f"No more spots to place {len(unplaced_items)} items. Remaining locations are invalid.\n" @@ -521,7 +521,7 @@ def distribute_items_restrictive(multiworld: MultiWorld, for item in progitempool: logging.debug(f"Moved {item} to start_inventory to prevent fill failure.") multiworld.push_precollected(item) - filleritempool.append(multiworld.worlds[item.player].create_filler()) + filleritempool.append(multiworld.worlds[item.player].create_filler("panic_fill")) logging.warning(f"{len(progitempool)} items moved to start inventory," f" due to failure in Progression fill step.") progitempool[:] = [] diff --git a/Main.py b/Main.py index d105bd4ad0..087dfef408 100644 --- a/Main.py +++ b/Main.py @@ -181,7 +181,8 @@ def main(args, seed=None, baked_server_options: Optional[Dict[str, object]] = No logger.warning(f"{player_name} tried to remove items from their pool that don't exist: {unfound_items}") needed_items = target_per_player[player] - sum(unfound_items.values()) - new_itempool += [multiworld.worlds[player].create_filler() for _ in range(needed_items)] + new_itempool += [multiworld.worlds[player].create_filler("start_inventory_from_pool") + for _ in range(needed_items)] assert len(multiworld.itempool) == len(new_itempool), "Item Pool amounts should not change." multiworld.itempool[:] = new_itempool diff --git a/worlds/AutoWorld.py b/worlds/AutoWorld.py index a510717920..bfd5e479c3 100644 --- a/worlds/AutoWorld.py +++ b/worlds/AutoWorld.py @@ -17,6 +17,10 @@ if TYPE_CHECKING: from BaseClasses import MultiWorld, Item, Location, Tutorial, Region, Entrance from . import GamesPackage from settings import Group + from typing import Literal + reason_type = Optional[Literal["item_link", "panic_fill", "start_inventory_from_pool", "world"]] +else: + reason_type = Optional[str] perf_logger = logging.getLogger("performance") @@ -527,7 +531,7 @@ class World(metaclass=AutoWorldRegister): return False # following methods should not need to be overridden. - def create_filler(self) -> "Item": + def create_filler(self, reason: reason_type = None) -> "Item": return self.create_item(self.get_filler_item_name()) # convenience methods diff --git a/worlds/subnautica/__init__.py b/worlds/subnautica/__init__.py index c3cf40a7c0..8e7decb6fc 100644 --- a/worlds/subnautica/__init__.py +++ b/worlds/subnautica/__init__.py @@ -142,7 +142,7 @@ class SubnauticaWorld(World): # resource bundle filler for _ in range(extras): - item = self.create_filler() + item = self.create_filler("world") item = cast(SubnauticaItem, item) pool.append(item)