Skip to content

Accept UTF-8 where UTF-16 strings are expected (Witcher 3 5.0) - #12

Open
alex19EP wants to merge 1 commit into
SpontanCombust:masterfrom
alex19EP:accept-utf8-strings
Open

alex19EP wants to merge 1 commit into
SpontanCombust:masterfrom
alex19EP:accept-utf8-strings

Conversation

@alex19EP

Copy link
Copy Markdown

Problem

In the 5.0 update of The Witcher 3 (Steam build 5.0.0.1041720), the debug protocol replies send every string as UTF-8. Older builds sent some of them as UTF-16. rw3d reads those with WitcherPacketDisassembler::string_utf16(), which rejects a StringUTF8 item, so any command whose reply contains text fails against 5.0:

  • rootpath / modlist: the reply comes back (visible with -v, e.g. ScriptCompiler / RootPathConfirm / the path as StringUTF8), but it's dropped and the command ends with Waited too long for the response.
  • reload: the game starts compiling, then the client fails on the first compiler log line with log::message: Type mismatch.

Change

string_utf16() now accepts a StringUTF16 or a StringUTF8 item, and fixed_string_utf16() goes through it. Older builds send UTF-16, which is decoded exactly as before. Outgoing requests are unchanged, since the 5.0 game accepts them as they are. There's a unit test for the new behaviour, and all 28 rw3d_net tests pass.

Tested

Against the 5.0 game on Windows, started with -net -debugscripts:

  • rootpath and modlist return their results.
  • reload streams the full compiler output and ends with Script compilation finished successfully.
  • exec runs an exec function and streams its script log output.

I haven't tested against a pre-5.0 build, but those replies still go through the old UTF-16 path.

AI Usage Disclosure

This change was developed with assistance from Claude (Anthropic). All code
was reviewed and tested by the author before submission.

🤖 Generated with Claude Code

The Witcher 3 5.0 update (build 5.0.0.1041720) sends every string in
its debug protocol replies as UTF-8. Older builds sent some of them as
UTF-16. rw3d decoded those with string_utf16(), which failed with
"Type mismatch", so every command that returns text broke against 5.0:
rootpath timed out, and reload stopped at the first compiler log line.

string_utf16() and fixed_string_utf16() now accept either encoding, so
older builds keep working unchanged. Requests are still sent as before;
the 5.0 game accepts them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings September 30, 2026 17:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The localized change preserves the UTF-16 path and tests the new UTF-8 path.

Review effort: Balanced
Findings: None

What changed in this PR

This PR makes rw3d compatible with Witcher 3 5.0 debug replies that send UTF-8 strings where earlier builds sent UTF-16.

Changes:

  • Accept either string type when reading UTF-16-expected fields, including fixed strings.
  • Add a test for both formats and rejection of an unrelated type.
File Description
crates/​net/​src/​protocol/​packet_assembly.rs Adds compatible string decoding and a unit test.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants