Skip to content

Commit d6f24d9

Browse files
espeon65536FlySniper
authored andcommitted
Core: guard against plandoing items onto event locations (ArchipelagoMW#2284)
1 parent dbfa58d commit d6f24d9

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

Fill.py

+13-10
Original file line numberDiff line numberDiff line change
@@ -897,19 +897,22 @@ def failed(warning: str, force: typing.Union[bool, str]) -> None:
897897
for item_name in items:
898898
item = world.worlds[player].create_item(item_name)
899899
for location in reversed(candidates):
900-
if not location.item:
901-
if location.item_rule(item):
902-
if location.can_fill(world.state, item, False):
903-
successful_pairs.append((item, location))
904-
candidates.remove(location)
905-
count = count + 1
906-
break
900+
if (location.address is None) == (item.code is None): # either both None or both not None
901+
if not location.item:
902+
if location.item_rule(item):
903+
if location.can_fill(world.state, item, False):
904+
successful_pairs.append((item, location))
905+
candidates.remove(location)
906+
count = count + 1
907+
break
908+
else:
909+
err.append(f"Can't place item at {location} due to fill condition not met.")
907910
else:
908-
err.append(f"Can't place item at {location} due to fill condition not met.")
911+
err.append(f"{item_name} not allowed at {location}.")
909912
else:
910-
err.append(f"{item_name} not allowed at {location}.")
913+
err.append(f"Cannot place {item_name} into already filled location {location}.")
911914
else:
912-
err.append(f"Cannot place {item_name} into already filled location {location}.")
915+
err.append(f"Mismatch between {item_name} and {location}, only one is an event.")
913916
if count == maxcount:
914917
break
915918
if count < placement['count']['min']:

0 commit comments

Comments
 (0)