t2-demo-parser 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +823 -0
- package/dist/BitStream.d.ts +143 -0
- package/dist/BitStream.d.ts.map +1 -0
- package/dist/BitStream.js +369 -0
- package/dist/BitStream.js.map +1 -0
- package/dist/BitStream.test.d.ts +2 -0
- package/dist/BitStream.test.d.ts.map +1 -0
- package/dist/BitStream.test.js +419 -0
- package/dist/BitStream.test.js.map +1 -0
- package/dist/ClassRegistry.d.ts +100 -0
- package/dist/ClassRegistry.d.ts.map +1 -0
- package/dist/ClassRegistry.js +118 -0
- package/dist/ClassRegistry.js.map +1 -0
- package/dist/ClassRegistry.test.d.ts +2 -0
- package/dist/ClassRegistry.test.d.ts.map +1 -0
- package/dist/ClassRegistry.test.js +83 -0
- package/dist/ClassRegistry.test.js.map +1 -0
- package/dist/DataBlockParsers.d.ts +3 -0
- package/dist/DataBlockParsers.d.ts.map +1 -0
- package/dist/DataBlockParsers.js +2041 -0
- package/dist/DataBlockParsers.js.map +1 -0
- package/dist/DemoParser.d.ts +155 -0
- package/dist/DemoParser.d.ts.map +1 -0
- package/dist/DemoParser.js +943 -0
- package/dist/DemoParser.js.map +1 -0
- package/dist/DemoParser.test.d.ts +2 -0
- package/dist/DemoParser.test.d.ts.map +1 -0
- package/dist/DemoParser.test.js +472 -0
- package/dist/DemoParser.test.js.map +1 -0
- package/dist/EventParsers.d.ts +3 -0
- package/dist/EventParsers.d.ts.map +1 -0
- package/dist/EventParsers.js +603 -0
- package/dist/EventParsers.js.map +1 -0
- package/dist/GhostManager.d.ts +13 -0
- package/dist/GhostManager.d.ts.map +1 -0
- package/dist/GhostManager.js +2002 -0
- package/dist/GhostManager.js.map +1 -0
- package/dist/GhostTracker.test.d.ts +2 -0
- package/dist/GhostTracker.test.d.ts.map +1 -0
- package/dist/GhostTracker.test.js +64 -0
- package/dist/GhostTracker.test.js.map +1 -0
- package/dist/HuffmanProcessor.d.ts +12 -0
- package/dist/HuffmanProcessor.d.ts.map +1 -0
- package/dist/HuffmanProcessor.js +163 -0
- package/dist/HuffmanProcessor.js.map +1 -0
- package/dist/LiveParser.d.ts +16 -0
- package/dist/LiveParser.d.ts.map +1 -0
- package/dist/LiveParser.js +29 -0
- package/dist/LiveParser.js.map +1 -0
- package/dist/PacketParser.d.ts +104 -0
- package/dist/PacketParser.d.ts.map +1 -0
- package/dist/PacketParser.js +713 -0
- package/dist/PacketParser.js.map +1 -0
- package/dist/Timeline.d.ts +101 -0
- package/dist/Timeline.d.ts.map +1 -0
- package/dist/Timeline.js +251 -0
- package/dist/Timeline.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +372 -0
- package/dist/cli.js.map +1 -0
- package/dist/dataBlockDataTypes.d.ts +877 -0
- package/dist/dataBlockDataTypes.d.ts.map +1 -0
- package/dist/dataBlockDataTypes.js +2 -0
- package/dist/dataBlockDataTypes.js.map +1 -0
- package/dist/dataTypes.d.ts +31 -0
- package/dist/dataTypes.d.ts.map +1 -0
- package/dist/dataTypes.js +5 -0
- package/dist/dataTypes.js.map +1 -0
- package/dist/dump.d.ts +3 -0
- package/dist/dump.d.ts.map +1 -0
- package/dist/dump.js +36 -0
- package/dist/dump.js.map +1 -0
- package/dist/eventDataTypes.d.ts +199 -0
- package/dist/eventDataTypes.d.ts.map +1 -0
- package/dist/eventDataTypes.js +2 -0
- package/dist/eventDataTypes.js.map +1 -0
- package/dist/ghostDataTypes.d.ts +573 -0
- package/dist/ghostDataTypes.d.ts.map +1 -0
- package/dist/ghostDataTypes.js +2 -0
- package/dist/ghostDataTypes.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +261 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +204 -0
- package/dist/types.js.map +1 -0
- package/package.json +46 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bit-level stream reader, ported from the V12 engine's BitStream class.
|
|
3
|
+
*
|
|
4
|
+
* Bits are read LSB-first within each byte:
|
|
5
|
+
* byte[bitNum >> 3] & (1 << (bitNum & 7))
|
|
6
|
+
*/
|
|
7
|
+
export declare class BitStream {
|
|
8
|
+
private data;
|
|
9
|
+
private bitNum;
|
|
10
|
+
private maxReadBitNum;
|
|
11
|
+
private error;
|
|
12
|
+
private stringBuffer;
|
|
13
|
+
constructor(data: Uint8Array, bitOffset?: number);
|
|
14
|
+
getCurPos(): number;
|
|
15
|
+
setCurPos(pos: number): void;
|
|
16
|
+
/** Byte position (rounded up), matching C++ getPosition() */
|
|
17
|
+
getBytePosition(): number;
|
|
18
|
+
isError(): boolean;
|
|
19
|
+
/** Returns true if we've read past the buffer */
|
|
20
|
+
isFull(): boolean;
|
|
21
|
+
getRemainingBits(): number;
|
|
22
|
+
getMaxPos(): number;
|
|
23
|
+
/** Read a single bit as a boolean. */
|
|
24
|
+
readFlag(): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Read N bits as an unsigned integer (up to 32 bits).
|
|
27
|
+
* Bits are read LSB-first, matching the C++ implementation.
|
|
28
|
+
*/
|
|
29
|
+
readInt(bitCount: number): number;
|
|
30
|
+
/** Read a signed integer: 1-bit sign flag + (bitCount-1) magnitude bits. */
|
|
31
|
+
readSignedInt(bitCount: number): number;
|
|
32
|
+
/** Read a float normalized to [0, 1]. */
|
|
33
|
+
readFloat(bitCount: number): number;
|
|
34
|
+
/** Read a float normalized to [-1, 1]. */
|
|
35
|
+
readSignedFloat(bitCount: number): number;
|
|
36
|
+
/** Read a ranged unsigned 32-bit integer. */
|
|
37
|
+
readRangedU32(rangeStart: number, rangeEnd: number): number;
|
|
38
|
+
/** Read raw bits into a new Uint8Array. */
|
|
39
|
+
readBitsBuffer(bitCount: number): Uint8Array;
|
|
40
|
+
/** Read N raw bytes. Returns an array of byte values. */
|
|
41
|
+
readBytes(count: number): number[];
|
|
42
|
+
/** Read a U8 (8 bits). */
|
|
43
|
+
readU8(): number;
|
|
44
|
+
/** Read a U16 (16 bits, little-endian). */
|
|
45
|
+
readU16(): number;
|
|
46
|
+
/** Read a U32 (32 bits, little-endian). */
|
|
47
|
+
readU32(): number;
|
|
48
|
+
/** Read a signed 32-bit integer (via stream.read in C++). */
|
|
49
|
+
readS32(): number;
|
|
50
|
+
/** Shared buffer for allocation-free F32 reads. */
|
|
51
|
+
private static readonly f32Buf;
|
|
52
|
+
private static readonly f32View;
|
|
53
|
+
private static readonly f32U8;
|
|
54
|
+
/** Read a 32-bit float (IEEE 754), allocation-free. */
|
|
55
|
+
readF32(): number;
|
|
56
|
+
/** Read a boolean value stored as a U8 (matches C++ Stream::read(bool*)). */
|
|
57
|
+
readBool(): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Read a compressed 3D normal vector.
|
|
60
|
+
* Uses phi (azimuth) and theta (elevation) angles.
|
|
61
|
+
*/
|
|
62
|
+
readNormalVector(bitCount: number): {
|
|
63
|
+
x: number;
|
|
64
|
+
y: number;
|
|
65
|
+
z: number;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Read an affine transform (position + quaternion rotation).
|
|
69
|
+
* Position: 3x F32
|
|
70
|
+
* Quaternion: 3x F32 (x,y,z) + 1-bit sign for w
|
|
71
|
+
*/
|
|
72
|
+
readAffineTransform(): {
|
|
73
|
+
position: {
|
|
74
|
+
x: number;
|
|
75
|
+
y: number;
|
|
76
|
+
z: number;
|
|
77
|
+
};
|
|
78
|
+
rotation: {
|
|
79
|
+
x: number;
|
|
80
|
+
y: number;
|
|
81
|
+
z: number;
|
|
82
|
+
w: number;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Read a Huffman-encoded string.
|
|
87
|
+
* Handles the stringBuffer optimization (shared prefix with previous string).
|
|
88
|
+
*/
|
|
89
|
+
readString(): string;
|
|
90
|
+
/** Enable/disable the string buffer for shared-prefix optimization. */
|
|
91
|
+
setStringBuffer(enable: boolean): void;
|
|
92
|
+
/** Skip N bits. */
|
|
93
|
+
skipBits(count: number): void;
|
|
94
|
+
/** Read 3x F32 as a Point3F. */
|
|
95
|
+
readPoint3F(): {
|
|
96
|
+
x: number;
|
|
97
|
+
y: number;
|
|
98
|
+
z: number;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Read a compressed 3D point relative to a compression point.
|
|
102
|
+
* Format: 2-bit type, then either absolute (3x F32) or relative delta.
|
|
103
|
+
* Used by Player MoveMask and Vehicle PositionMask.
|
|
104
|
+
*/
|
|
105
|
+
readCompressedPoint(compressionPoint: {
|
|
106
|
+
x: number;
|
|
107
|
+
y: number;
|
|
108
|
+
z: number;
|
|
109
|
+
}, scale?: number): {
|
|
110
|
+
x: number;
|
|
111
|
+
y: number;
|
|
112
|
+
z: number;
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Read a MatrixF written via mathWrite(MatrixF).
|
|
116
|
+
* Format: 16x F32 (row-major in Torque's MatrixF storage) = 512 bits.
|
|
117
|
+
*/
|
|
118
|
+
readMatrixF(): {
|
|
119
|
+
elements: number[];
|
|
120
|
+
position: {
|
|
121
|
+
x: number;
|
|
122
|
+
y: number;
|
|
123
|
+
z: number;
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Read a Torque "packed string" with 2-bit type code.
|
|
128
|
+
* Used by RemoteCommandEvent for script arguments.
|
|
129
|
+
* Tribes 2 binary (FUN_00588690) format:
|
|
130
|
+
* 0 = null/empty
|
|
131
|
+
* 1 = normal packed string
|
|
132
|
+
* 2 = tagged string id (10-bit), decoded to "\x01<decimalId>"
|
|
133
|
+
* 3 = integer string (sign + 7/15/31-bit magnitude)
|
|
134
|
+
*/
|
|
135
|
+
unpackNetString(): string;
|
|
136
|
+
/** Create a snapshot of the current position that can be restored. */
|
|
137
|
+
savePos(): number;
|
|
138
|
+
/** Restore a previously saved position. */
|
|
139
|
+
restorePos(pos: number): void;
|
|
140
|
+
/** Get the underlying data buffer. */
|
|
141
|
+
getBuffer(): Uint8Array;
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=BitStream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BitStream.d.ts","sourceRoot":"","sources":["../src/BitStream.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,KAAK,CAAU;IACvB,OAAO,CAAC,YAAY,CAAuB;gBAE/B,IAAI,EAAE,UAAU,EAAE,SAAS,SAAI;IAO3C,SAAS,IAAI,MAAM;IAInB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAI5B,6DAA6D;IAC7D,eAAe,IAAI,MAAM;IAIzB,OAAO,IAAI,OAAO;IAIlB,iDAAiD;IACjD,MAAM,IAAI,OAAO;IAIjB,gBAAgB,IAAI,MAAM;IAI1B,SAAS,IAAI,MAAM;IAInB,sCAAsC;IACtC,QAAQ,IAAI,OAAO;IAWnB;;;OAGG;IACH,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAyCjC,4EAA4E;IAC5E,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAOvC,yCAAyC;IACzC,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAInC,0CAA0C;IAC1C,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAIzC,6CAA6C;IAC7C,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM;IAM3D,2CAA2C;IAC3C,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU;IAkC5C,yDAAyD;I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AAE,MAAM,CAAA;KAAE;IAIlD;;;;OAIG;IACH,mBAAmB,CACjB,gBAAgB,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,EACrD,KAAK,GAAE,MAAa,GACnB;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE;IAmBtC;;;OAGG;IACH,WAAW,IAAI;QACb,QAAQ,EAAE,MAAM,EAAE,CAAC;QACnB,QAAQ,EAAE;YAAE,CAAC,EAAE,MAAM,CAAC;YAAC,CAAC,EAAE,MAAM,CAAC;YAAC,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;KAC/C;IAcD;;;;;;;;OAQG;IACH,eAAe,IAAI,MAAM;IAgCzB,sEAAsE;IACtE,OAAO,IAAI,MAAM;IAIjB,2CAA2C;IAC3C,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAK7B,sCAAsC;IACtC,SAAS,IAAI,UAAU;CAGxB"}
|
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
import { huffProcessor } from "./HuffmanProcessor.js";
|
|
2
|
+
/**
|
|
3
|
+
* Bit-level stream reader, ported from the V12 engine's BitStream class.
|
|
4
|
+
*
|
|
5
|
+
* Bits are read LSB-first within each byte:
|
|
6
|
+
* byte[bitNum >> 3] & (1 << (bitNum & 7))
|
|
7
|
+
*/
|
|
8
|
+
export class BitStream {
|
|
9
|
+
data;
|
|
10
|
+
bitNum;
|
|
11
|
+
maxReadBitNum;
|
|
12
|
+
error;
|
|
13
|
+
stringBuffer = null;
|
|
14
|
+
constructor(data, bitOffset = 0) {
|
|
15
|
+
this.data = data;
|
|
16
|
+
this.bitNum = bitOffset;
|
|
17
|
+
this.maxReadBitNum = data.length << 3;
|
|
18
|
+
this.error = false;
|
|
19
|
+
}
|
|
20
|
+
getCurPos() {
|
|
21
|
+
return this.bitNum;
|
|
22
|
+
}
|
|
23
|
+
setCurPos(pos) {
|
|
24
|
+
this.bitNum = pos;
|
|
25
|
+
}
|
|
26
|
+
/** Byte position (rounded up), matching C++ getPosition() */
|
|
27
|
+
getBytePosition() {
|
|
28
|
+
return (this.bitNum + 7) >> 3;
|
|
29
|
+
}
|
|
30
|
+
isError() {
|
|
31
|
+
return this.error;
|
|
32
|
+
}
|
|
33
|
+
/** Returns true if we've read past the buffer */
|
|
34
|
+
isFull() {
|
|
35
|
+
return this.bitNum > this.maxReadBitNum;
|
|
36
|
+
}
|
|
37
|
+
getRemainingBits() {
|
|
38
|
+
return this.maxReadBitNum - this.bitNum;
|
|
39
|
+
}
|
|
40
|
+
getMaxPos() {
|
|
41
|
+
return this.maxReadBitNum;
|
|
42
|
+
}
|
|
43
|
+
/** Read a single bit as a boolean. */
|
|
44
|
+
readFlag() {
|
|
45
|
+
if (this.bitNum >= this.maxReadBitNum) {
|
|
46
|
+
this.error = true;
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
const mask = 1 << (this.bitNum & 0x7);
|
|
50
|
+
const ret = (this.data[this.bitNum >> 3] & mask) !== 0;
|
|
51
|
+
this.bitNum++;
|
|
52
|
+
return ret;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Read N bits as an unsigned integer (up to 32 bits).
|
|
56
|
+
* Bits are read LSB-first, matching the C++ implementation.
|
|
57
|
+
*/
|
|
58
|
+
readInt(bitCount) {
|
|
59
|
+
if (bitCount === 0)
|
|
60
|
+
return 0;
|
|
61
|
+
if (this.bitNum + bitCount > this.maxReadBitNum) {
|
|
62
|
+
this.error = true;
|
|
63
|
+
return 0;
|
|
64
|
+
}
|
|
65
|
+
const startByte = this.bitNum >> 3;
|
|
66
|
+
const downShift = this.bitNum & 0x7;
|
|
67
|
+
this.bitNum += bitCount;
|
|
68
|
+
// When bitCount + downShift <= 32, everything fits in 32-bit operations
|
|
69
|
+
if (bitCount + downShift <= 32) {
|
|
70
|
+
let ret = 0;
|
|
71
|
+
const bytesNeeded = (bitCount + downShift + 7) >> 3;
|
|
72
|
+
for (let i = 0; i < bytesNeeded && startByte + i < this.data.length; i++) {
|
|
73
|
+
ret |= this.data[startByte + i] << (i * 8);
|
|
74
|
+
}
|
|
75
|
+
ret = ret >>> downShift;
|
|
76
|
+
if (bitCount === 32)
|
|
77
|
+
return ret >>> 0;
|
|
78
|
+
return ret & ((1 << bitCount) - 1);
|
|
79
|
+
}
|
|
80
|
+
// Slow path: bitCount + downShift > 32 (e.g., reading 32 bits at a
|
|
81
|
+
// non-byte-aligned position). Use float64 arithmetic to avoid the
|
|
82
|
+
// 32-bit limit of JavaScript bitwise operators.
|
|
83
|
+
let ret = 0;
|
|
84
|
+
const bytesNeeded = (bitCount + downShift + 7) >> 3;
|
|
85
|
+
for (let i = 0; i < bytesNeeded && startByte + i < this.data.length; i++) {
|
|
86
|
+
ret += this.data[startByte + i] * 2 ** (i * 8);
|
|
87
|
+
}
|
|
88
|
+
ret = Math.floor(ret / 2 ** downShift);
|
|
89
|
+
// Mask to bitCount bits using float64-safe operations
|
|
90
|
+
if (bitCount === 32)
|
|
91
|
+
return ret >>> 0;
|
|
92
|
+
return ret & ((1 << bitCount) - 1);
|
|
93
|
+
}
|
|
94
|
+
/** Read a signed integer: 1-bit sign flag + (bitCount-1) magnitude bits. */
|
|
95
|
+
readSignedInt(bitCount) {
|
|
96
|
+
if (this.readFlag()) {
|
|
97
|
+
return -this.readInt(bitCount - 1);
|
|
98
|
+
}
|
|
99
|
+
return this.readInt(bitCount - 1);
|
|
100
|
+
}
|
|
101
|
+
/** Read a float normalized to [0, 1]. */
|
|
102
|
+
readFloat(bitCount) {
|
|
103
|
+
return this.readInt(bitCount) / ((1 << bitCount) - 1);
|
|
104
|
+
}
|
|
105
|
+
/** Read a float normalized to [-1, 1]. */
|
|
106
|
+
readSignedFloat(bitCount) {
|
|
107
|
+
return (this.readInt(bitCount) * 2) / ((1 << bitCount) - 1) - 1.0;
|
|
108
|
+
}
|
|
109
|
+
/** Read a ranged unsigned 32-bit integer. */
|
|
110
|
+
readRangedU32(rangeStart, rangeEnd) {
|
|
111
|
+
const rangeSize = rangeEnd - rangeStart + 1;
|
|
112
|
+
const rangeBits = Math.ceil(Math.log2(rangeSize)) || 1;
|
|
113
|
+
return this.readInt(rangeBits) + rangeStart;
|
|
114
|
+
}
|
|
115
|
+
/** Read raw bits into a new Uint8Array. */
|
|
116
|
+
readBitsBuffer(bitCount) {
|
|
117
|
+
if (bitCount === 0)
|
|
118
|
+
return new Uint8Array(0);
|
|
119
|
+
const byteCount = (bitCount + 7) >> 3;
|
|
120
|
+
const result = new Uint8Array(byteCount);
|
|
121
|
+
const startByte = this.bitNum >> 3;
|
|
122
|
+
const downShift = this.bitNum & 0x7;
|
|
123
|
+
const upShift = 8 - downShift;
|
|
124
|
+
if (downShift === 0) {
|
|
125
|
+
// Byte-aligned, fast path
|
|
126
|
+
result.set(this.data.subarray(startByte, startByte + byteCount));
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
let curB = this.data[startByte];
|
|
130
|
+
for (let i = 0; i < byteCount; i++) {
|
|
131
|
+
const nextB = startByte + i + 1 < this.data.length
|
|
132
|
+
? this.data[startByte + i + 1]
|
|
133
|
+
: 0;
|
|
134
|
+
result[i] = ((curB >> downShift) | (nextB << upShift)) & 0xff;
|
|
135
|
+
curB = nextB;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
// Mask off extra bits in the last byte
|
|
139
|
+
const extraBits = bitCount & 0x7;
|
|
140
|
+
if (extraBits !== 0) {
|
|
141
|
+
result[byteCount - 1] &= (1 << extraBits) - 1;
|
|
142
|
+
}
|
|
143
|
+
this.bitNum += bitCount;
|
|
144
|
+
return result;
|
|
145
|
+
}
|
|
146
|
+
/** Read N raw bytes. Returns an array of byte values. */
|
|
147
|
+
readBytes(count) {
|
|
148
|
+
const buf = this.readBitsBuffer(count * 8);
|
|
149
|
+
return Array.from(buf);
|
|
150
|
+
}
|
|
151
|
+
/** Read a U8 (8 bits). */
|
|
152
|
+
readU8() {
|
|
153
|
+
return this.readInt(8);
|
|
154
|
+
}
|
|
155
|
+
/** Read a U16 (16 bits, little-endian). */
|
|
156
|
+
readU16() {
|
|
157
|
+
return this.readInt(16);
|
|
158
|
+
}
|
|
159
|
+
/** Read a U32 (32 bits, little-endian). */
|
|
160
|
+
readU32() {
|
|
161
|
+
return this.readInt(32);
|
|
162
|
+
}
|
|
163
|
+
/** Read a signed 32-bit integer (via stream.read in C++). */
|
|
164
|
+
readS32() {
|
|
165
|
+
const val = this.readU32();
|
|
166
|
+
return val | 0; // convert to signed
|
|
167
|
+
}
|
|
168
|
+
/** Shared buffer for allocation-free F32 reads. */
|
|
169
|
+
static f32Buf = new ArrayBuffer(4);
|
|
170
|
+
static f32View = new DataView(BitStream.f32Buf);
|
|
171
|
+
static f32U8 = new Uint8Array(BitStream.f32Buf);
|
|
172
|
+
/** Read a 32-bit float (IEEE 754), allocation-free. */
|
|
173
|
+
readF32() {
|
|
174
|
+
if (this.bitNum + 32 > this.maxReadBitNum) {
|
|
175
|
+
this.error = true;
|
|
176
|
+
return 0;
|
|
177
|
+
}
|
|
178
|
+
const startByte = this.bitNum >> 3;
|
|
179
|
+
const downShift = this.bitNum & 0x7;
|
|
180
|
+
const u8 = BitStream.f32U8;
|
|
181
|
+
if (downShift === 0) {
|
|
182
|
+
u8[0] = this.data[startByte];
|
|
183
|
+
u8[1] = this.data[startByte + 1];
|
|
184
|
+
u8[2] = this.data[startByte + 2];
|
|
185
|
+
u8[3] = this.data[startByte + 3];
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
const upShift = 8 - downShift;
|
|
189
|
+
for (let i = 0; i < 4; i++) {
|
|
190
|
+
const curB = this.data[startByte + i];
|
|
191
|
+
const nextB = startByte + i + 1 < this.data.length
|
|
192
|
+
? this.data[startByte + i + 1]
|
|
193
|
+
: 0;
|
|
194
|
+
u8[i] = ((curB >> downShift) | (nextB << upShift)) & 0xff;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
this.bitNum += 32;
|
|
198
|
+
return BitStream.f32View.getFloat32(0, true);
|
|
199
|
+
}
|
|
200
|
+
/** Read a boolean value stored as a U8 (matches C++ Stream::read(bool*)). */
|
|
201
|
+
readBool() {
|
|
202
|
+
return this.readU8() !== 0;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Read a compressed 3D normal vector.
|
|
206
|
+
* Uses phi (azimuth) and theta (elevation) angles.
|
|
207
|
+
*/
|
|
208
|
+
readNormalVector(bitCount) {
|
|
209
|
+
const phi = this.readSignedFloat(bitCount + 1) * Math.PI;
|
|
210
|
+
const theta = this.readSignedFloat(bitCount) * (Math.PI / 2.0);
|
|
211
|
+
return {
|
|
212
|
+
x: Math.sin(phi) * Math.cos(theta),
|
|
213
|
+
y: Math.cos(phi) * Math.cos(theta),
|
|
214
|
+
z: Math.sin(theta),
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Read an affine transform (position + quaternion rotation).
|
|
219
|
+
* Position: 3x F32
|
|
220
|
+
* Quaternion: 3x F32 (x,y,z) + 1-bit sign for w
|
|
221
|
+
*/
|
|
222
|
+
readAffineTransform() {
|
|
223
|
+
const position = {
|
|
224
|
+
x: this.readF32(),
|
|
225
|
+
y: this.readF32(),
|
|
226
|
+
z: this.readF32(),
|
|
227
|
+
};
|
|
228
|
+
const qx = this.readF32();
|
|
229
|
+
const qy = this.readF32();
|
|
230
|
+
const qz = this.readF32();
|
|
231
|
+
let qw = Math.sqrt(Math.max(0, 1.0 - (qx * qx + qy * qy + qz * qz)));
|
|
232
|
+
if (this.readFlag()) {
|
|
233
|
+
qw = -qw;
|
|
234
|
+
}
|
|
235
|
+
return {
|
|
236
|
+
position,
|
|
237
|
+
rotation: { x: qx, y: qy, z: qz, w: qw },
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Read a Huffman-encoded string.
|
|
242
|
+
* Handles the stringBuffer optimization (shared prefix with previous string).
|
|
243
|
+
*/
|
|
244
|
+
readString() {
|
|
245
|
+
if (this.stringBuffer !== null) {
|
|
246
|
+
if (this.readFlag()) {
|
|
247
|
+
// Shared prefix optimization: offset into previous string
|
|
248
|
+
const offset = this.readInt(8);
|
|
249
|
+
const suffix = huffProcessor.readHuffBuffer(this);
|
|
250
|
+
const result = this.stringBuffer.substring(0, offset) + suffix;
|
|
251
|
+
this.stringBuffer = result;
|
|
252
|
+
return result;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
const result = huffProcessor.readHuffBuffer(this);
|
|
256
|
+
if (this.stringBuffer !== null) {
|
|
257
|
+
this.stringBuffer = result;
|
|
258
|
+
}
|
|
259
|
+
return result;
|
|
260
|
+
}
|
|
261
|
+
/** Enable/disable the string buffer for shared-prefix optimization. */
|
|
262
|
+
setStringBuffer(enable) {
|
|
263
|
+
this.stringBuffer = enable ? "" : null;
|
|
264
|
+
}
|
|
265
|
+
/** Skip N bits. */
|
|
266
|
+
skipBits(count) {
|
|
267
|
+
this.bitNum += count;
|
|
268
|
+
}
|
|
269
|
+
/** Read 3x F32 as a Point3F. */
|
|
270
|
+
readPoint3F() {
|
|
271
|
+
return { x: this.readF32(), y: this.readF32(), z: this.readF32() };
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Read a compressed 3D point relative to a compression point.
|
|
275
|
+
* Format: 2-bit type, then either absolute (3x F32) or relative delta.
|
|
276
|
+
* Used by Player MoveMask and Vehicle PositionMask.
|
|
277
|
+
*/
|
|
278
|
+
readCompressedPoint(compressionPoint, scale = 0.01) {
|
|
279
|
+
const type = this.readInt(2);
|
|
280
|
+
if (type === 3) {
|
|
281
|
+
// Absolute position
|
|
282
|
+
return { x: this.readF32(), y: this.readF32(), z: this.readF32() };
|
|
283
|
+
}
|
|
284
|
+
// Relative to compression point
|
|
285
|
+
const bitCounts = [16, 18, 20];
|
|
286
|
+
const bits = bitCounts[type];
|
|
287
|
+
const dx = this.readSignedInt(bits);
|
|
288
|
+
const dy = this.readSignedInt(bits);
|
|
289
|
+
const dz = this.readSignedInt(bits);
|
|
290
|
+
return {
|
|
291
|
+
x: compressionPoint.x + dx * scale,
|
|
292
|
+
y: compressionPoint.y + dy * scale,
|
|
293
|
+
z: compressionPoint.z + dz * scale,
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Read a MatrixF written via mathWrite(MatrixF).
|
|
298
|
+
* Format: 16x F32 (row-major in Torque's MatrixF storage) = 512 bits.
|
|
299
|
+
*/
|
|
300
|
+
readMatrixF() {
|
|
301
|
+
const elements = new Array(16);
|
|
302
|
+
for (let i = 0; i < 16; i++) {
|
|
303
|
+
elements[i] = this.readF32();
|
|
304
|
+
}
|
|
305
|
+
// MatrixF is written row-major: each row is [r0, r1, r2, translation].
|
|
306
|
+
// Position (column 3) is at indices 3, 7, 11 (last element of each row).
|
|
307
|
+
return {
|
|
308
|
+
elements,
|
|
309
|
+
position: { x: elements[3], y: elements[7], z: elements[11] },
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Read a Torque "packed string" with 2-bit type code.
|
|
314
|
+
* Used by RemoteCommandEvent for script arguments.
|
|
315
|
+
* Tribes 2 binary (FUN_00588690) format:
|
|
316
|
+
* 0 = null/empty
|
|
317
|
+
* 1 = normal packed string
|
|
318
|
+
* 2 = tagged string id (10-bit), decoded to "\x01<decimalId>"
|
|
319
|
+
* 3 = integer string (sign + 7/15/31-bit magnitude)
|
|
320
|
+
*/
|
|
321
|
+
unpackNetString() {
|
|
322
|
+
const code = this.readInt(2);
|
|
323
|
+
switch (code) {
|
|
324
|
+
case 0:
|
|
325
|
+
return ""; // null string
|
|
326
|
+
case 1:
|
|
327
|
+
return this.readString(); // Huffman-encoded string
|
|
328
|
+
case 2: {
|
|
329
|
+
// Decompiled binary uses 10 bits here, not 12.
|
|
330
|
+
const tag = this.readInt(10);
|
|
331
|
+
// Keep Tribes 2 tagged-string wire representation.
|
|
332
|
+
return `\x01${tag}`;
|
|
333
|
+
}
|
|
334
|
+
case 3: {
|
|
335
|
+
// Integer encoding: sign + variable-size magnitude
|
|
336
|
+
const neg = this.readFlag();
|
|
337
|
+
let num;
|
|
338
|
+
if (this.readFlag()) {
|
|
339
|
+
num = this.readInt(7); // small
|
|
340
|
+
}
|
|
341
|
+
else if (this.readFlag()) {
|
|
342
|
+
num = this.readInt(15); // medium
|
|
343
|
+
}
|
|
344
|
+
else {
|
|
345
|
+
num = this.readInt(31); // large
|
|
346
|
+
}
|
|
347
|
+
if (neg)
|
|
348
|
+
num = -num;
|
|
349
|
+
return String(num);
|
|
350
|
+
}
|
|
351
|
+
default:
|
|
352
|
+
return "";
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
/** Create a snapshot of the current position that can be restored. */
|
|
356
|
+
savePos() {
|
|
357
|
+
return this.bitNum;
|
|
358
|
+
}
|
|
359
|
+
/** Restore a previously saved position. */
|
|
360
|
+
restorePos(pos) {
|
|
361
|
+
this.bitNum = pos;
|
|
362
|
+
this.error = false;
|
|
363
|
+
}
|
|
364
|
+
/** Get the underlying data buffer. */
|
|
365
|
+
getBuffer() {
|
|
366
|
+
return this.data;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
//# sourceMappingURL=BitStream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BitStream.js","sourceRoot":"","sources":["../src/BitStream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD;;;;;GAKG;AACH,MAAM,OAAO,SAAS;IACZ,IAAI,CAAa;IACjB,MAAM,CAAS;IACf,aAAa,CAAS;IACtB,KAAK,CAAU;IACf,YAAY,GAAkB,IAAI,CAAC;IAE3C,YAAY,IAAgB,EAAE,SAAS,GAAG,CAAC;QACzC,IAAI,CAAC,IA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