Added filesafe player name function and updated generator functions in all worlds to use filesafe player name during output
Thanks Windows for your bad filesystem.
This commit is contained in:
parent
05e267a0bd
commit
37d9eb2752
|
@ -269,6 +269,9 @@ class MultiWorld():
|
||||||
def get_player_name(self, player: int) -> str:
|
def get_player_name(self, player: int) -> str:
|
||||||
return self.player_name[player]
|
return self.player_name[player]
|
||||||
|
|
||||||
|
def get_file_safe_player_name(self, player: int) -> str:
|
||||||
|
return ''.join(c for c in self.get_player_name(player) if c not in '<>:"/\\|?*')
|
||||||
|
|
||||||
def initialize_regions(self, regions=None):
|
def initialize_regions(self, regions=None):
|
||||||
for region in regions if regions else self.regions:
|
for region in regions if regions else self.regions:
|
||||||
region.world = self
|
region.world = self
|
||||||
|
|
|
@ -298,7 +298,7 @@ class ALTTPWorld(World):
|
||||||
deathlink=world.death_link[player])
|
deathlink=world.death_link[player])
|
||||||
|
|
||||||
outfilepname = f'_P{player}'
|
outfilepname = f'_P{player}'
|
||||||
outfilepname += f"_{world.player_name[player].replace(' ', '_')}" \
|
outfilepname += f"_{world.get_file_safe_player_name(player).replace(' ', '_')}" \
|
||||||
if world.player_name[player] != 'Player%d' % player else ''
|
if world.player_name[player] != 'Player%d' % player else ''
|
||||||
|
|
||||||
rompath = os.path.join(output_directory, f'AP_{world.seed_name}{outfilepname}.sfc')
|
rompath = os.path.join(output_directory, f'AP_{world.seed_name}{outfilepname}.sfc')
|
||||||
|
|
|
@ -91,7 +91,7 @@ def generate_mod(world, output_directory: str):
|
||||||
for location in multiworld.get_filled_locations(player):
|
for location in multiworld.get_filled_locations(player):
|
||||||
if location.address:
|
if location.address:
|
||||||
locations.append((location.name, location.item.name, location.item.player, location.item.advancement))
|
locations.append((location.name, location.item.name, location.item.player, location.item.advancement))
|
||||||
mod_name = f"AP-{multiworld.seed_name}-P{player}-{multiworld.player_name[player]}"
|
mod_name = f"AP-{multiworld.seed_name}-P{player}-{multiworld.get_file_safe_player_name(player)}"
|
||||||
tech_cost_scale = {0: 0.1,
|
tech_cost_scale = {0: 0.1,
|
||||||
1: 0.25,
|
1: 0.25,
|
||||||
2: 0.5,
|
2: 0.5,
|
||||||
|
|
|
@ -112,7 +112,7 @@ class MinecraftWorld(World):
|
||||||
|
|
||||||
def generate_output(self, output_directory: str):
|
def generate_output(self, output_directory: str):
|
||||||
data = self._get_mc_data()
|
data = self._get_mc_data()
|
||||||
filename = f"AP_{self.world.seed_name}_P{self.player}_{self.world.get_player_name(self.player)}.apmc"
|
filename = f"AP_{self.world.seed_name}_P{self.player}_{self.world.get_file_safe_player_name(self.player)}.apmc"
|
||||||
with open(os.path.join(output_directory, filename), 'wb') as f:
|
with open(os.path.join(output_directory, filename), 'wb') as f:
|
||||||
f.write(b64encode(bytes(json.dumps(data), 'utf-8')))
|
f.write(b64encode(bytes(json.dumps(data), 'utf-8')))
|
||||||
|
|
||||||
|
|
|
@ -773,7 +773,7 @@ class OOTWorld(World):
|
||||||
# Seed hint RNG, used for ganon text lines also
|
# Seed hint RNG, used for ganon text lines also
|
||||||
self.hint_rng = self.world.slot_seeds[self.player]
|
self.hint_rng = self.world.slot_seeds[self.player]
|
||||||
|
|
||||||
outfile_name = f"AP_{self.world.seed_name}_P{self.player}_{self.world.get_player_name(self.player)}"
|
outfile_name = f"AP_{self.world.seed_name}_P{self.player}_{self.world.get_file_safe_player_name(self.player)}"
|
||||||
rom = Rom(file=get_options()['oot_options']['rom_file'])
|
rom = Rom(file=get_options()['oot_options']['rom_file'])
|
||||||
if self.hints != 'none':
|
if self.hints != 'none':
|
||||||
buildWorldGossipHints(self)
|
buildWorldGossipHints(self)
|
||||||
|
|
|
@ -404,7 +404,7 @@ class SMWorld(World):
|
||||||
def generate_output(self, output_directory: str):
|
def generate_output(self, output_directory: str):
|
||||||
outfilebase = 'AP_' + self.world.seed_name
|
outfilebase = 'AP_' + self.world.seed_name
|
||||||
outfilepname = f'_P{self.player}'
|
outfilepname = f'_P{self.player}'
|
||||||
outfilepname += f"_{self.world.player_name[self.player].replace(' ', '_')}"
|
outfilepname += f"_{self.world.get_file_safe_player_name(self.player).replace(' ', '_')}"
|
||||||
outputFilename = os.path.join(output_directory, f'{outfilebase}{outfilepname}.sfc')
|
outputFilename = os.path.join(output_directory, f'{outfilebase}{outfilepname}.sfc')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -107,6 +107,6 @@ class SM64World(World):
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
filename = f"AP_{self.world.seed_name}_P{self.player}_{self.world.get_player_name(self.player)}.apsm64ex"
|
filename = f"AP_{self.world.seed_name}_P{self.player}_{self.world.get_file_safe_player_name(self.player)}.apsm64ex"
|
||||||
with open(os.path.join(output_directory, filename), 'w') as f:
|
with open(os.path.join(output_directory, filename), 'w') as f:
|
||||||
json.dump(data, f)
|
json.dump(data, f)
|
||||||
|
|
|
@ -257,7 +257,7 @@ class SMZ3World(World):
|
||||||
|
|
||||||
outfilebase = 'AP_' + self.world.seed_name
|
outfilebase = 'AP_' + self.world.seed_name
|
||||||
outfilepname = f'_P{self.player}'
|
outfilepname = f'_P{self.player}'
|
||||||
outfilepname += f"_{self.world.player_name[self.player].replace(' ', '_')}" \
|
outfilepname += f"_{self.world.get_file_safe_player_name(self.player).replace(' ', '_')}" \
|
||||||
|
|
||||||
filename = os.path.join(output_directory, f'{outfilebase}{outfilepname}.sfc')
|
filename = os.path.join(output_directory, f'{outfilebase}{outfilepname}.sfc')
|
||||||
with open(filename, "wb") as binary_file:
|
with open(filename, "wb") as binary_file:
|
||||||
|
|
|
@ -271,7 +271,8 @@ class SoEWorld(World):
|
||||||
if self.world.death_link[self.player].value:
|
if self.world.death_link[self.player].value:
|
||||||
switches.append("--death-link")
|
switches.append("--death-link")
|
||||||
rom_file = get_base_rom_path()
|
rom_file = get_base_rom_path()
|
||||||
out_base = output_path(output_directory, f'AP_{self.world.seed_name}_P{self.player}_{player_name}')
|
out_base = output_path(output_directory, f'AP_{self.world.seed_name}_P{self.player}_'
|
||||||
|
f'{self.world.get_file_safe_player_name(self.player)}')
|
||||||
out_file = out_base + '.sfc'
|
out_file = out_base + '.sfc'
|
||||||
placement_file = out_base + '.txt'
|
placement_file = out_base + '.txt'
|
||||||
patch_file = out_base + '.apsoe'
|
patch_file = out_base + '.apsoe'
|
||||||
|
|
|
@ -79,6 +79,6 @@ class V6World(World):
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
filename = f"AP_{self.world.seed_name}_P{self.player}_{self.world.get_player_name(self.player)}.apv6"
|
filename = f"AP_{self.world.seed_name}_P{self.player}_{self.world.get_file_safe_player_name(self.player)}.apv6"
|
||||||
with open(os.path.join(output_directory, filename), 'w') as f:
|
with open(os.path.join(output_directory, filename), 'w') as f:
|
||||||
json.dump(data, f)
|
json.dump(data, f)
|
||||||
|
|
Loading…
Reference in New Issue