diff --git a/Toby Doom Launcher.py b/Toby Doom Launcher.py index 1e28b35..d3fc3da 100755 --- a/Toby Doom Launcher.py +++ b/Toby Doom Launcher.py @@ -225,12 +225,26 @@ class SpeechHandler: while True: try: - line = process.stdout.readline() - # Keep gzdoom's existing functionality of lines being printed to the console. - print(line, end='') - if not line: + # Read raw bytes from stdout + rawLine = process.stdout.buffer.readline() + if not rawLine: break + # Try different encodings + for encoding in ['utf-8', 'latin1', 'cp1252']: + try: + line = rawLine.decode(encoding) + break + except UnicodeDecodeError: + continue + else: + # If all encodings fail, skip this line + print(f"Warning: Could not decode line: {rawLine}", file=sys.stderr) + continue + + # Keep gzdoom's existing functionality of lines being printed to the console + print(line, end='') + lineStr = line.strip() # Wait for the initial separator before starting speech @@ -245,7 +259,7 @@ class SpeechHandler: except Exception as e: print(f"Error processing game output: {e}", file=sys.stderr) - break + continue # Continue processing instead of breaking class MenuDialog(QDialog): @@ -1675,7 +1689,6 @@ class DoomLauncher(QMainWindow): stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=1, - text=True, env=dict(os.environ, PYTHONUNBUFFERED="1"), startupinfo=startupinfo )