Add HYTALE_PATCH_MODE env var to test different string formats

HYTALE_PATCH_MODE=utf16le - Use pure UTF-16LE (no length prefix)
HYTALE_PATCH_MODE=length-prefixed - Use length-prefixed format (default)

This helps debug if the length-prefixed format is causing crashes.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
sanasol
2026-01-27 03:00:29 +01:00
parent d8f90bd1ff
commit 81d1e7c113

View File

@@ -291,12 +291,29 @@ class ClientPatcher {
} }
// 2. Patch main domain (hytale.com -> mainDomain) // 2. Patch main domain (hytale.com -> mainDomain)
// Try length-prefixed format first, then fall back to pure UTF-16LE
console.log(` Patching domain: ${ORIGINAL_DOMAIN} -> ${strategy.mainDomain}`); console.log(` Patching domain: ${ORIGINAL_DOMAIN} -> ${strategy.mainDomain}`);
const domainResult = this.replaceBytes(
// Check for HYTALE_PATCH_MODE env var to test different formats
const patchMode = process.env.HYTALE_PATCH_MODE || 'length-prefixed';
console.log(` Patch mode: ${patchMode}`);
let domainResult;
if (patchMode === 'utf16le') {
// Pure UTF-16LE replacement (no length prefix)
const oldUtf16 = this.stringToUtf16LE(ORIGINAL_DOMAIN);
const newUtf16 = this.stringToUtf16LE(strategy.mainDomain);
console.log(` UTF-16LE: old=${oldUtf16.length} bytes, new=${newUtf16.length} bytes`);
domainResult = this.replaceBytes(result, oldUtf16, newUtf16);
} else {
// Length-prefixed format (default)
domainResult = this.replaceBytes(
result, result,
this.stringToLengthPrefixed(ORIGINAL_DOMAIN), this.stringToLengthPrefixed(ORIGINAL_DOMAIN),
this.stringToLengthPrefixed(strategy.mainDomain) this.stringToLengthPrefixed(strategy.mainDomain)
); );
}
result = domainResult.buffer; result = domainResult.buffer;
if (domainResult.count > 0) { if (domainResult.count > 0) {
console.log(` Replaced ${domainResult.count} domain occurrence(s)`); console.log(` Replaced ${domainResult.count} domain occurrence(s)`);