LttP: fix multithreading racing condition resulting in Ganon giving the wrong prog bow hint, also have one less world.find_items() which is quite cpu expensive
This commit is contained in:
parent
061cc69a6a
commit
111e11924f
|
@ -354,6 +354,12 @@ def generate_itempool(world):
|
||||||
world.get_location(location, player).place_locked_item(ItemFactory(item, player))
|
world.get_location(location, player).place_locked_item(ItemFactory(item, player))
|
||||||
|
|
||||||
items = ItemFactory(pool, player)
|
items = ItemFactory(pool, player)
|
||||||
|
# convert one Progressive Bow into Progressive Bow (Alt), in ID only, for ganon silvers hint text
|
||||||
|
if world.worlds[player].has_progressive_bows:
|
||||||
|
for item in items:
|
||||||
|
if item.code == 0x64: # Progressive Bow
|
||||||
|
item.code = 0x65 # Progressive Bow (Alt)
|
||||||
|
break
|
||||||
|
|
||||||
if clock_mode is not None:
|
if clock_mode is not None:
|
||||||
world.clock_mode[player] = clock_mode
|
world.clock_mode[player] = clock_mode
|
||||||
|
@ -584,6 +590,7 @@ def get_pool_core(world, player: int):
|
||||||
|
|
||||||
if want_progressives(world.random):
|
if want_progressives(world.random):
|
||||||
pool.extend(diff.progressivebow)
|
pool.extend(diff.progressivebow)
|
||||||
|
world.worlds[player].has_progressive_bows = True
|
||||||
elif (swordless or logic == 'noglitches') and goal != 'icerodhunt':
|
elif (swordless or logic == 'noglitches') and goal != 'icerodhunt':
|
||||||
swordless_bows = ['Bow', 'Silver Bow']
|
swordless_bows = ['Bow', 'Silver Bow']
|
||||||
if difficulty == "easy":
|
if difficulty == "easy":
|
||||||
|
|
|
@ -754,13 +754,6 @@ def get_nonnative_item_sprite(item: str) -> int:
|
||||||
def patch_rom(world, rom, player, enemized):
|
def patch_rom(world, rom, player, enemized):
|
||||||
local_random = world.slot_seeds[player]
|
local_random = world.slot_seeds[player]
|
||||||
|
|
||||||
# progressive bow silver arrow hint hack
|
|
||||||
prog_bow_locs = world.find_items('Progressive Bow', player)
|
|
||||||
if len(prog_bow_locs) > 1:
|
|
||||||
# only pick a distingushed bow if we have at least two
|
|
||||||
distinguished_prog_bow_loc = local_random.choice(prog_bow_locs)
|
|
||||||
distinguished_prog_bow_loc.item.code = 0x65
|
|
||||||
|
|
||||||
# patch items
|
# patch items
|
||||||
|
|
||||||
for location in world.get_locations():
|
for location in world.get_locations():
|
||||||
|
@ -2283,21 +2276,22 @@ def write_strings(rom, world, player):
|
||||||
' %s?' % hint_text(silverarrows[0]).replace('Ganon\'s', 'my')) if silverarrows else '?\nI think not!'
|
' %s?' % hint_text(silverarrows[0]).replace('Ganon\'s', 'my')) if silverarrows else '?\nI think not!'
|
||||||
tt['ganon_phase_3_no_silvers'] = 'Did you find the silver arrows%s' % silverarrow_hint
|
tt['ganon_phase_3_no_silvers'] = 'Did you find the silver arrows%s' % silverarrow_hint
|
||||||
tt['ganon_phase_3_no_silvers_alt'] = 'Did you find the silver arrows%s' % silverarrow_hint
|
tt['ganon_phase_3_no_silvers_alt'] = 'Did you find the silver arrows%s' % silverarrow_hint
|
||||||
|
if world.worlds[player].has_progressive_bows and (world.difficulty_requirements[player].progressive_bow_limit >= 2 or (
|
||||||
prog_bow_locs = world.find_items('Progressive Bow', player)
|
world.swordless[player] or world.logic[player] == 'noglitches')):
|
||||||
distinguished_prog_bow_loc = next((location for location in prog_bow_locs if location.item.code == 0x65), None)
|
prog_bow_locs = world.find_items('Progressive Bow', player)
|
||||||
progressive_silvers = world.difficulty_requirements[player].progressive_bow_limit >= 2 or (
|
world.slot_seeds[player].shuffle(prog_bow_locs)
|
||||||
world.swordless[player] or world.logic[player] == 'noglitches')
|
found_bow = False
|
||||||
if distinguished_prog_bow_loc:
|
found_bow_alt = False
|
||||||
prog_bow_locs.remove(distinguished_prog_bow_loc)
|
while prog_bow_locs and not (found_bow and found_bow_alt):
|
||||||
silverarrow_hint = (' %s?' % hint_text(distinguished_prog_bow_loc).replace('Ganon\'s',
|
bow_loc = prog_bow_locs.pop()
|
||||||
'my')) if progressive_silvers else '?\nI think not!'
|
if bow_loc.item.code == 0x65:
|
||||||
tt['ganon_phase_3_no_silvers'] = 'Did you find the silver arrows%s' % silverarrow_hint
|
found_bow_alt = True
|
||||||
|
target = 'ganon_phase_3_no_silvers'
|
||||||
if any(prog_bow_locs):
|
else:
|
||||||
silverarrow_hint = (' %s?' % hint_text(local_random.choice(prog_bow_locs)).replace('Ganon\'s',
|
found_bow = True
|
||||||
'my')) if progressive_silvers else '?\nI think not!'
|
target = 'ganon_phase_3_no_silvers_alt'
|
||||||
tt['ganon_phase_3_no_silvers_alt'] = 'Did you find the silver arrows%s' % silverarrow_hint
|
silverarrow_hint = (' %s?' % hint_text(bow_loc).replace('Ganon\'s', 'my'))
|
||||||
|
tt[target] = 'Did you find the silver arrows%s' % silverarrow_hint
|
||||||
|
|
||||||
crystal5 = world.find_item('Crystal 5', player)
|
crystal5 = world.find_item('Crystal 5', player)
|
||||||
crystal6 = world.find_item('Crystal 6', player)
|
crystal6 = world.find_item('Crystal 6', player)
|
||||||
|
|
|
@ -51,6 +51,7 @@ class ALTTPWorld(World):
|
||||||
self.dungeon_local_item_names = set()
|
self.dungeon_local_item_names = set()
|
||||||
self.dungeon_specific_item_names = set()
|
self.dungeon_specific_item_names = set()
|
||||||
self.rom_name_available_event = threading.Event()
|
self.rom_name_available_event = threading.Event()
|
||||||
|
self.has_progressive_bows = False
|
||||||
super(ALTTPWorld, self).__init__(*args, **kwargs)
|
super(ALTTPWorld, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
def generate_early(self):
|
def generate_early(self):
|
||||||
|
|
Loading…
Reference in New Issue