From 9247a8886cb651b3a7d764b43fb33e171af21b6b Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Wed, 23 Sep 2026 16:26:17 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=B0=83=E6=95=B4=E5=BD=95=E5=83=8F?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E7=B1=BB=E5=9E=8B=E7=9A=84=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=EF=BC=8C10=20~=2031=20=E7=95=99=E7=A9=BA?= =?UTF-8?q?=EF=BC=8C32=20~=20255=20=E5=88=86=E9=85=8D=E7=BB=99=E7=9F=AD?= =?UTF-8?q?=E5=AD=97=E7=AC=A6=E4=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages-user/data-common/src/replay/array.ts | 24 ++++++++++++------- packages/common/src/logger.json | 1 + 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/packages-user/data-common/src/replay/array.ts b/packages-user/data-common/src/replay/array.ts index 9b0736e..1896d3b 100644 --- a/packages-user/data-common/src/replay/array.ts +++ b/packages-user/data-common/src/replay/array.ts @@ -22,7 +22,8 @@ interface INormalizedParam { * - 7: 非负 bigint,载荷为幅值 * - 8: 负 bigint,载荷为幅值 * - 9: string,带 int32 长度前缀 - * - 10 ~ 255: n - 9 长度的字符串 + * - 10 ~ 31: 留空,以备后续新增类型 + * - 32 ~ 255: n - 32 长度的字符串 * * 该类型码表属于录像参数编解码格式的一部分,遵循只增不改的约定:新语义必须分配 * 新的类型码,禁止复用既有类型码。历史上 5/6/7/8 与短字符串基址(长度 + 9)曾 @@ -291,10 +292,11 @@ export class ReplayArray implements IReplayArray { }; } else if (typeof param === 'string') { const arr = this.textEncoder.encode(param); - if (arr.length > 0 && arr.length <= 246) { - // 10 ~ 255 - string + // 223 = 255 - 32 + if (arr.length >= 0 && arr.length <= 223) { + // 32 ~ 255 - string return { - paramType: arr.length + 9, + paramType: arr.length + 32, paramValue: arr, byteLength: arr.length + 1 }; @@ -400,9 +402,11 @@ export class ReplayArray implements IReplayArray { // 9 - string this.paramView.setInt32(index + 1, arr.length); this.paramArray.set(arr, index + 5); - } else { - // 10 ~ 255 - string + } else if (param.paramType >= 32) { + // 32 ~ 255 - string this.paramArray.set(arr, index + 1); + } else { + logger.error(70, 'encode', param.paramType.toString()); } index += param.byteLength; }); @@ -717,13 +721,15 @@ export class ReplayArray implements IReplayArray { const arr = this.paramArray.slice(startIndex + 5, endIndex); byte = length + 5; value = this.textDecoder.decode(arr); - } else { - // 10 ~ 255 - string - const length = type - 9; + } else if (type >= 32) { + // 32 ~ 255 - string + const length = type - 32; const endIndex = startIndex + 1 + length; const arr = this.paramArray.slice(startIndex + 1, endIndex); byte = length + 1; value = this.textDecoder.decode(arr); + } else { + logger.error(70, 'decode', type.toString()); } return { diff --git a/packages/common/src/logger.json b/packages/common/src/logger.json index 4e27c77..c2da690 100644 --- a/packages/common/src/logger.json +++ b/packages/common/src/logger.json @@ -69,6 +69,7 @@ "67": "Load url '$1' error since the raw json string splitted by prefix split string cannot be parsed to a valid JavaScript object. Parse error info: $2", "68": "Extra config identifier '$1' has conflicts. More than one extra config use this identifier, and the final load result is unpredictable since network decides which one to be loaded fast.", "69": "$1 core config not loaded for the next loading phase.", + "70": "Cannot $1 replay param type $2 since they are not defined in this engine version.", "2001": "Replay($1): Replay parameter count mismatch: expected $2, got $3.", "2002": "Replay($1): Replay parameter type mismatch: index $2, expected $3, got $4.", "2003": "Replay(move): Expected hero to be stopped before execute moving step.",