Compare commits
2 Commits
4622f61057
...
ad6cf68969
Author | SHA1 | Date |
---|---|---|
magical | ad6cf68969 | |
magical | 1f2cba725d |
|
@ -2579,7 +2579,7 @@ def randomize_game(graph):
|
||||||
patch_game()
|
patch_game()
|
||||||
|
|
||||||
def patch_game():
|
def patch_game():
|
||||||
global FileName, BaseName
|
global FileName, BaseGame
|
||||||
CreditsOffsets = {
|
CreditsOffsets = {
|
||||||
'ChargeBeam': 7655617,
|
'ChargeBeam': 7655617,
|
||||||
'WideBeam': 7655725,
|
'WideBeam': 7655725,
|
||||||
|
@ -2616,20 +2616,22 @@ def patch_game():
|
||||||
os.system('.\\armips\\armips.exe "Metroid Fusion Open Randomizer.asm" -root ".\\data\\asm" -sym ".\\temp.sym"')
|
os.system('.\\armips\\armips.exe "Metroid Fusion Open Randomizer.asm" -root ".\\data\\asm" -sym ".\\temp.sym"')
|
||||||
os.replace('.\\data\\MFOR.gba', '.\\seeds\\{}.gba'.format(FileName))
|
os.replace('.\\data\\MFOR.gba', '.\\seeds\\{}.gba'.format(FileName))
|
||||||
else:
|
else:
|
||||||
source = open(BaseName, 'rb')
|
error = False
|
||||||
target = open(os.path.join('.', 'seeds', '{}.gba'.format(FileName)), 'wb')
|
with open(BaseGame, 'rb') as source:
|
||||||
patch = open(os.path.join('.', 'data', 'MFOR.bps'), 'rb')
|
with open(os.path.join('.', 'seeds', '{}.gba'.format(FileName)), 'wb') as target:
|
||||||
try:
|
with open(os.path.join('.', 'data', 'MFOR.bps'), 'rb') as patch:
|
||||||
apply_to_files(patch, source, target)
|
try:
|
||||||
except:
|
apply_to_files(patch, source, target)
|
||||||
target.close()
|
except Exception:
|
||||||
os.unlink(os.path.join('.', 'seeds', '{}.gba'.format(FileName)))
|
error = True
|
||||||
print('Error: failed to patch game with base patch!')
|
if error:
|
||||||
sys.exit(1)
|
os.remove(os.path.join('.', 'seeds', '{}.gba'.format(FileName)))
|
||||||
|
print('Error: failed to patch game with base patch!')
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
checksum = fileHash(os.path.join('.', 'seeds', '{}.gba'.format(FileName)))
|
checksum = fileHash(os.path.join('.', 'seeds', '{}.gba'.format(FileName)))
|
||||||
if checksum != 2455114263:
|
if checksum != 2455114263:
|
||||||
os.unlink(os.path.join('.', 'seeds', '{}.gba'.format(FileName)))
|
os.remove(os.path.join('.', 'seeds', '{}.gba'.format(FileName)))
|
||||||
print('Error: Base patch file has been modified. Please go to https://metroidconstruction.com/ and re-download MFOR.')
|
print('Error: Base patch file has been modified. Please go to https://metroidconstruction.com/ and re-download MFOR.')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
@ -2864,14 +2866,14 @@ def patch_game():
|
||||||
sourcedata = source.read()
|
sourcedata = source.read()
|
||||||
with open(os.path.join('.', 'seeds', '{}.gba'.format(FileName)), 'rb') as target:
|
with open(os.path.join('.', 'seeds', '{}.gba'.format(FileName)), 'rb') as target:
|
||||||
targetdata = target.read()
|
targetdata = target.read()
|
||||||
|
|
||||||
patch = open(os.path.join('.', 'seeds', '{}.bps'.format(FileName)), 'wb')
|
|
||||||
|
|
||||||
blocksize = (len(sourcedata) + len(targetdata)) // 1000000 + 1
|
blocksize = (len(sourcedata) + len(targetdata)) // 1000000 + 1
|
||||||
print("Using blocks of {0} bytes".format(blocksize))
|
print("Using blocks of {0} bytes".format(blocksize))
|
||||||
|
|
||||||
iterable = diff_bytearrays(blocksize, sourcedata, targetdata)
|
iterable = diff_bytearrays(blocksize, sourcedata, targetdata)
|
||||||
write_bps(bps_progress(iterable), patch)
|
with open(os.path.join('.', 'seeds', '{}.bps'.format(FileName)), 'wb') as patch:
|
||||||
|
write_bps(bps_progress(iterable), patch)
|
||||||
|
|
||||||
print('')
|
print('')
|
||||||
|
|
||||||
ItemNames = [
|
ItemNames = [
|
||||||
|
@ -3074,7 +3076,7 @@ def start_randomizer(rom, settings):
|
||||||
print('Debug generation enabled')
|
print('Debug generation enabled')
|
||||||
if loop > 0:
|
if loop > 0:
|
||||||
SeedValue = str(random.randrange(sys.maxsize))
|
SeedValue = str(random.randrange(sys.maxsize))
|
||||||
|
|
||||||
Difficulty = SeedSettings['Difficulty']
|
Difficulty = SeedSettings['Difficulty']
|
||||||
DamageRuns = SeedSettings['DamageRuns']
|
DamageRuns = SeedSettings['DamageRuns']
|
||||||
random.seed(SeedValue + str(SeedSettings))
|
random.seed(SeedValue + str(SeedSettings))
|
||||||
|
|
Loading…
Reference in New Issue