Skip to content

Commit

Permalink
LADX: Added some resilience to non-ASCII player names (#2642)
Browse files Browse the repository at this point in the history
* Added some resilience to non-ASCII player names or items

* Also the client, not even sure if switching to ascii is useful here

* Split a long line in two
  • Loading branch information
Ishigh1 authored Feb 13, 2024
1 parent 5545591 commit 3ca3417
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion LinksAwakeningClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,8 @@ async def wait_for_retroarch_connection(self):
await asyncio.sleep(1.0)
continue
self.stop_bizhawk_spam = False
logger.info(f"Connected to Retroarch {version.decode('ascii')} running {rom_name.decode('ascii')}")
logger.info(f"Connected to Retroarch {version.decode('ascii', errors='replace')} "
f"running {rom_name.decode('ascii', errors='replace')}")
return
except (BlockingIOError, TimeoutError, ConnectionResetError):
await asyncio.sleep(1.0)
Expand Down
4 changes: 2 additions & 2 deletions worlds/ladx/LADXR/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def setReplacementName(key: str, value: str) -> None:

def formatText(instr: str, *, center: bool = False, ask: Optional[str] = None) -> bytes:
instr = instr.format(**_NAMES)
s = instr.encode("ascii")
s = instr.encode("ascii", errors="replace")
s = s.replace(b"'", b"^")

def padLine(line: bytes) -> bytes:
Expand All @@ -169,7 +169,7 @@ def padLine(line: bytes) -> bytes:
if result_line:
result += padLine(result_line)
if ask is not None:
askbytes = ask.encode("ascii")
askbytes = ask.encode("ascii", errors="replace")
result = result.rstrip()
while len(result) % 32 != 16:
result += b' '
Expand Down

0 comments on commit 3ca3417

Please sign in to comment.