Core: add creation reason to filler

This commit is contained in:
Fabian Dill
2025-01-08 00:30:03 +01:00
parent a29ba4a6c4
commit ce09144261
4 changed files with 10 additions and 5 deletions

View File

@@ -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[:] = []

View File

@@ -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

View File

@@ -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

View File

@@ -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)