Reimplement --securerandom

Seeds should be reproducable without the flag passed, and unreproducable with the flag passed.
With --securerandom, generate a 9-char alphanumeric string to use to make filenames differ.
This commit is contained in:
2021-06-29 10:36:53 -07:00
parent 11dcc719fb
commit 3896066193
16 changed files with 23 additions and 21 deletions

5
Rom.py
View File

@@ -5,7 +5,7 @@ import json
import hashlib
import logging
import os
import random
import RaceRandom as random
import struct
import sys
import subprocess
@@ -1542,8 +1542,9 @@ def patch_rom(world, rom, player, team, enemized, is_mystery=False):
# set rom name
# 21 bytes
from Main import __version__
seedstring = f'{world.seed:09}' if isinstance(world.seed, int) else world.seed
# todo: change to DR when Enemizer is okay with DR
rom.name = bytearray(f'ER{__version__.split("-")[0].replace(".","")[0:3]}_{team+1}_{player}_{world.seed:09}\0', 'utf8')[:21]
rom.name = bytearray(f'ER{__version__.split("-")[0].replace(".","")[0:3]}_{team+1}_{player}_{seedstring}\0', 'utf8')[:21]
rom.name.extend([0] * (21 - len(rom.name)))
rom.write_bytes(0x7FC0, rom.name)