From 72545d12f1f4ae0eaa9c3d6feeb6486189e87844 Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Thu, 20 Aug 2020 04:03:49 +0200 Subject: [PATCH] prevent most cases of duplicate player names * in theory dupes are still possible due to later filtering of characters, but this should catch most instances of it. --- Utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Utils.py b/Utils.py index ee85fbae..ba859a82 100644 --- a/Utils.py +++ b/Utils.py @@ -43,10 +43,12 @@ def snes_to_pc(value): def parse_player_names(names, players, teams): names = tuple(n for n in (n.strip() for n in names.split(",")) if n) + if len(names) != len(set(names)): + raise ValueError("Duplicate Player names is not supported.") ret = [] while names or len(ret) < teams: team = [n[:16] for n in names[:players]] - # where does the 16 character limit come from? + # 16 bytes in rom per player, which will map to more in unicode, but those characters later get filtered while len(team) != players: team.append(f"Player{len(team) + 1}") ret.append(team)