fix multithreaded import racing condition when frozen
This commit is contained in:
parent
d190fe65c6
commit
f27d9e904f
2
Main.py
2
Main.py
|
@ -20,6 +20,7 @@ from Fill import distribute_items_cutoff, distribute_items_staleness, distribute
|
|||
balance_multiworld_progression
|
||||
from ItemList import generate_itempool, difficulties, fill_prizes
|
||||
from Utils import output_path, parse_player_names, get_options, __version__
|
||||
import Patch
|
||||
|
||||
seeddigits = 20
|
||||
|
||||
|
@ -226,7 +227,6 @@ def main(args, seed=None):
|
|||
rompath = output_path(f'{outfilebase}{outfilepname}{outfilesuffix}.sfc')
|
||||
rom.write_to_file(rompath)
|
||||
if args.create_diff:
|
||||
import Patch
|
||||
Patch.create_patch_file(rompath)
|
||||
return (player, team, list(rom.name))
|
||||
|
||||
|
|
4
Patch.py
4
Patch.py
|
@ -10,7 +10,7 @@ import sys
|
|||
from typing import Tuple, Optional
|
||||
|
||||
import Utils
|
||||
from Rom import JAP10HASH, read_rom
|
||||
from Rom import JAP10HASH
|
||||
|
||||
|
||||
def get_base_rom_path(file_name: str = "") -> str:
|
||||
|
@ -23,6 +23,7 @@ def get_base_rom_path(file_name: str = "") -> str:
|
|||
|
||||
|
||||
def get_base_rom_bytes(file_name: str = "") -> bytes:
|
||||
from Rom import read_rom
|
||||
base_rom_bytes = getattr(get_base_rom_bytes, "base_rom_bytes", None)
|
||||
if not base_rom_bytes:
|
||||
file_name = get_base_rom_path(file_name)
|
||||
|
@ -160,3 +161,4 @@ if __name__ == "__main__":
|
|||
import traceback
|
||||
traceback.print_exc()
|
||||
input("Press enter to close.")
|
||||
|
||||
|
|
16
Rom.py
16
Rom.py
|
@ -1,4 +1,6 @@
|
|||
import bisect
|
||||
JAP10HASH = '03a63945398191337e896e5771f77173'
|
||||
RANDOMIZERBASEHASH = 'a567da86e8bd499256da4bba2209a3fd'
|
||||
|
||||
import io
|
||||
import json
|
||||
import hashlib
|
||||
|
@ -19,10 +21,9 @@ from Text import KingsReturn_texts, Sanctuary_texts, Kakariko_texts, Blacksmiths
|
|||
from Utils import output_path, local_path, int16_as_bytes, int32_as_bytes, snes_to_pc
|
||||
from Items import ItemFactory
|
||||
from EntranceShuffle import door_addresses
|
||||
import Patch
|
||||
|
||||
|
||||
JAP10HASH = '03a63945398191337e896e5771f77173'
|
||||
RANDOMIZERBASEHASH = 'a567da86e8bd499256da4bba2209a3fd'
|
||||
|
||||
class LocalRom(object):
|
||||
|
||||
|
@ -65,7 +66,7 @@ class LocalRom(object):
|
|||
return expected == buffermd5.hexdigest()
|
||||
|
||||
def patch_base_rom(self):
|
||||
from Patch import create_patch_file, create_rom_bytes
|
||||
|
||||
|
||||
if os.path.isfile(local_path('basepatch.sfc')):
|
||||
with open(local_path('basepatch.sfc'), 'rb') as stream:
|
||||
|
@ -74,11 +75,11 @@ class LocalRom(object):
|
|||
if self.verify(buffer):
|
||||
self.buffer = buffer
|
||||
if not os.path.exists(local_path(os.path.join('data', 'basepatch.bmbp'))):
|
||||
create_patch_file(local_path('basepatch.sfc'))
|
||||
Patch.create_patch_file(local_path('basepatch.sfc'))
|
||||
return
|
||||
|
||||
if os.path.isfile(local_path(os.path.join('data', 'basepatch.bmbp'))):
|
||||
_, target, buffer = create_rom_bytes(local_path(os.path.join('data', 'basepatch.bmbp')))
|
||||
_, target, buffer = Patch.create_rom_bytes(local_path(os.path.join('data', 'basepatch.bmbp')))
|
||||
if self.verify(buffer):
|
||||
self.buffer = bytearray(buffer)
|
||||
with open(local_path('basepatch.sfc'), 'wb') as stream:
|
||||
|
@ -105,7 +106,8 @@ class LocalRom(object):
|
|||
if self.verify(self.buffer):
|
||||
with open(local_path('basepatch.sfc'), 'wb') as stream:
|
||||
stream.write(self.buffer)
|
||||
create_patch_file(local_path('basepatch.sfc'), destination=local_path(os.path.join('data', 'basepatch.bmbp')))
|
||||
Patch.create_patch_file(local_path('basepatch.sfc'),
|
||||
destination=local_path(os.path.join('data', 'basepatch.bmbp')))
|
||||
os.remove(local_path('data/base2current.json'))
|
||||
else:
|
||||
raise RuntimeError(
|
||||
|
|
Loading…
Reference in New Issue