Create basepatch in proper directory if required.
This commit is contained in:
parent
95742ddb98
commit
e1bfa8780c
4
Patch.py
4
Patch.py
|
@ -49,11 +49,11 @@ def generate_patch(rom: bytes, metadata: Optional[dict] = None) -> bytes:
|
||||||
return generate_yaml(patch, metadata)
|
return generate_yaml(patch, metadata)
|
||||||
|
|
||||||
|
|
||||||
def create_patch_file(rom_file_to_patch: str, server: str = "") -> str:
|
def create_patch_file(rom_file_to_patch: str, server: str = "", destination: str = None) -> str:
|
||||||
bytes = generate_patch(load_bytes(rom_file_to_patch),
|
bytes = generate_patch(load_bytes(rom_file_to_patch),
|
||||||
{
|
{
|
||||||
"server": server}) # allow immediate connection to server in multiworld. Empty string otherwise
|
"server": server}) # allow immediate connection to server in multiworld. Empty string otherwise
|
||||||
target = os.path.splitext(rom_file_to_patch)[0] + ".bmbp"
|
target = destination if destination else os.path.splitext(rom_file_to_patch)[0] + ".bmbp"
|
||||||
write_lzma(bytes, target)
|
write_lzma(bytes, target)
|
||||||
return target
|
return target
|
||||||
|
|
||||||
|
|
3
Rom.py
3
Rom.py
|
@ -105,8 +105,7 @@ class LocalRom(object):
|
||||||
if self.verify(self.buffer):
|
if self.verify(self.buffer):
|
||||||
with open(local_path('basepatch.sfc'), 'wb') as stream:
|
with open(local_path('basepatch.sfc'), 'wb') as stream:
|
||||||
stream.write(self.buffer)
|
stream.write(self.buffer)
|
||||||
create_patch_file(local_path('basepatch.sfc'))
|
create_patch_file(local_path('basepatch.sfc'), destination=local_path(os.path.join('data', 'basepatch.bmbp')))
|
||||||
os.rename(local_path('basepatch.bmbp'), os.path.join('data', 'basepatch.bmbp'))
|
|
||||||
os.remove(local_path('data/base2current.json'))
|
os.remove(local_path('data/base2current.json'))
|
||||||
else:
|
else:
|
||||||
raise RuntimeError(
|
raise RuntimeError(
|
||||||
|
|
Loading…
Reference in New Issue