mirror of
https://github.com/motajs/template.git
synced 2026-10-17 20:00:18 +08:00
feat: 调整录像参数类型的参数类型,10 ~ 31 留空,32 ~ 255 分配给短字符串
This commit is contained in:
parent
1fb92c3976
commit
9247a8886c
@ -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 {
|
||||
|
||||
@ -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.",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user