Core: Fix incorrect default state checked in MultiWorld.can_beat_game (#3813)

`MultiWorld.can_beat_game()` with no arguments would initially check if
`self.state` is beatable, but then would create an empty state,
`state = CollectionState(self)`, to sweep spheres from to determine if
the game is beatable. The issue was that `self.state` and the new empty
state could be different.

Currently, it seems that everywhere in Archipelago's codebase that calls
`MultiWorld.can_beat_game()` with no arguments or `starting_state=None`
has a `self.state` that only contains precollected items, so the new
empty state happens to result in an equivalent state, but this should
not be relied upon to always be the case.

This patch changes `can_beat_game()` to initially check if the new empty
state is beatable instead of `self.state`.

This appears to be a bug introduced way back in 27b6dd8bd7

Fixes #3742
This commit is contained in:
Mysteryem 2024-08-19 05:44:06 +01:00 committed by GitHub
parent 28a9709516
commit 9277cb39ef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 2 deletions

View File

@ -541,9 +541,9 @@ class MultiWorld():
return True
state = starting_state.copy()
else:
if self.has_beaten_game(self.state):
return True
state = CollectionState(self)
if self.has_beaten_game(state):
return True
prog_locations = {location for location in self.get_locations() if location.item
and location.item.advancement and location not in state.locations_checked}