quake2ts 0.0.78 → 0.0.80
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/package.json +1 -1
- package/packages/client/dist/browser/index.global.js +1 -1
- package/packages/client/dist/browser/index.global.js.map +1 -1
- package/packages/client/dist/cjs/index.cjs +856 -1
- package/packages/client/dist/cjs/index.cjs.map +1 -1
- package/packages/client/dist/esm/index.js +856 -1
- package/packages/client/dist/esm/index.js.map +1 -1
- package/packages/client/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/client/dist/types/index.d.ts +2 -1
- package/packages/client/dist/types/index.d.ts.map +1 -1
- package/packages/engine/dist/browser/index.global.js +14 -14
- package/packages/engine/dist/browser/index.global.js.map +1 -1
- package/packages/engine/dist/cjs/index.cjs +875 -0
- package/packages/engine/dist/cjs/index.cjs.map +1 -1
- package/packages/engine/dist/esm/index.js +871 -0
- package/packages/engine/dist/esm/index.js.map +1 -1
- package/packages/engine/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/engine/dist/types/demo/demoReader.d.ts +27 -0
- package/packages/engine/dist/types/demo/demoReader.d.ts.map +1 -0
- package/packages/engine/dist/types/demo/index.d.ts +4 -0
- package/packages/engine/dist/types/demo/index.d.ts.map +1 -0
- package/packages/engine/dist/types/demo/playback.d.ts +3 -4
- package/packages/engine/dist/types/demo/playback.d.ts.map +1 -1
- package/packages/engine/dist/types/index.d.ts +1 -0
- package/packages/engine/dist/types/index.d.ts.map +1 -1
- package/packages/game/dist/browser/index.global.js +1 -1
- package/packages/game/dist/browser/index.global.js.map +1 -1
- package/packages/game/dist/cjs/index.cjs +88 -0
- package/packages/game/dist/cjs/index.cjs.map +1 -1
- package/packages/game/dist/esm/index.js +88 -0
- package/packages/game/dist/esm/index.js.map +1 -1
- package/packages/game/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/game/dist/types/physics/movement.d.ts.map +1 -1
|
@@ -1822,6 +1822,193 @@ var ConfigStringIndex = ((ConfigStringIndex22) => {
|
|
|
1822
1822
|
})(ConfigStringIndex || {});
|
|
1823
1823
|
var MAX_CONFIGSTRINGS = ConfigStringIndex.MaxConfigStrings;
|
|
1824
1824
|
var WATERJUMP_CLEAR = 8 | 16 | 32 | 1024;
|
|
1825
|
+
var ServerCommand = /* @__PURE__ */ ((ServerCommand2) => {
|
|
1826
|
+
ServerCommand2[ServerCommand2["bad"] = 0] = "bad";
|
|
1827
|
+
ServerCommand2[ServerCommand2["muzzleflash"] = 1] = "muzzleflash";
|
|
1828
|
+
ServerCommand2[ServerCommand2["muzzleflash2"] = 2] = "muzzleflash2";
|
|
1829
|
+
ServerCommand2[ServerCommand2["temp_entity"] = 3] = "temp_entity";
|
|
1830
|
+
ServerCommand2[ServerCommand2["layout"] = 4] = "layout";
|
|
1831
|
+
ServerCommand2[ServerCommand2["inventory"] = 5] = "inventory";
|
|
1832
|
+
ServerCommand2[ServerCommand2["nop"] = 6] = "nop";
|
|
1833
|
+
ServerCommand2[ServerCommand2["disconnect"] = 7] = "disconnect";
|
|
1834
|
+
ServerCommand2[ServerCommand2["reconnect"] = 8] = "reconnect";
|
|
1835
|
+
ServerCommand2[ServerCommand2["sound"] = 9] = "sound";
|
|
1836
|
+
ServerCommand2[ServerCommand2["print"] = 10] = "print";
|
|
1837
|
+
ServerCommand2[ServerCommand2["stufftext"] = 11] = "stufftext";
|
|
1838
|
+
ServerCommand2[ServerCommand2["serverdata"] = 12] = "serverdata";
|
|
1839
|
+
ServerCommand2[ServerCommand2["configstring"] = 13] = "configstring";
|
|
1840
|
+
ServerCommand2[ServerCommand2["spawnbaseline"] = 14] = "spawnbaseline";
|
|
1841
|
+
ServerCommand2[ServerCommand2["centerprint"] = 15] = "centerprint";
|
|
1842
|
+
ServerCommand2[ServerCommand2["download"] = 16] = "download";
|
|
1843
|
+
ServerCommand2[ServerCommand2["playerinfo"] = 17] = "playerinfo";
|
|
1844
|
+
ServerCommand2[ServerCommand2["packetentities"] = 18] = "packetentities";
|
|
1845
|
+
ServerCommand2[ServerCommand2["deltapacketentities"] = 19] = "deltapacketentities";
|
|
1846
|
+
ServerCommand2[ServerCommand2["frame"] = 20] = "frame";
|
|
1847
|
+
return ServerCommand2;
|
|
1848
|
+
})(ServerCommand || {});
|
|
1849
|
+
var TempEntity = /* @__PURE__ */ ((TempEntity2) => {
|
|
1850
|
+
TempEntity2[TempEntity2["GUNSHOT"] = 0] = "GUNSHOT";
|
|
1851
|
+
TempEntity2[TempEntity2["BLOOD"] = 1] = "BLOOD";
|
|
1852
|
+
TempEntity2[TempEntity2["BLASTER"] = 2] = "BLASTER";
|
|
1853
|
+
TempEntity2[TempEntity2["RAILTRAIL"] = 3] = "RAILTRAIL";
|
|
1854
|
+
TempEntity2[TempEntity2["SHOTGUN"] = 4] = "SHOTGUN";
|
|
1855
|
+
TempEntity2[TempEntity2["EXPLOSION1"] = 5] = "EXPLOSION1";
|
|
1856
|
+
TempEntity2[TempEntity2["EXPLOSION2"] = 6] = "EXPLOSION2";
|
|
1857
|
+
TempEntity2[TempEntity2["ROCKET_EXPLOSION"] = 7] = "ROCKET_EXPLOSION";
|
|
1858
|
+
TempEntity2[TempEntity2["GRENADE_EXPLOSION"] = 8] = "GRENADE_EXPLOSION";
|
|
1859
|
+
TempEntity2[TempEntity2["SPARKS"] = 9] = "SPARKS";
|
|
1860
|
+
TempEntity2[TempEntity2["SPLASH"] = 10] = "SPLASH";
|
|
1861
|
+
TempEntity2[TempEntity2["BUBBLETRAIL"] = 11] = "BUBBLETRAIL";
|
|
1862
|
+
TempEntity2[TempEntity2["SCREEN_SPARKS"] = 12] = "SCREEN_SPARKS";
|
|
1863
|
+
TempEntity2[TempEntity2["SHIELD_SPARKS"] = 13] = "SHIELD_SPARKS";
|
|
1864
|
+
TempEntity2[TempEntity2["BULLET_SPARKS"] = 14] = "BULLET_SPARKS";
|
|
1865
|
+
TempEntity2[TempEntity2["LASER_SPARKS"] = 15] = "LASER_SPARKS";
|
|
1866
|
+
TempEntity2[TempEntity2["PARASITE_ATTACK"] = 16] = "PARASITE_ATTACK";
|
|
1867
|
+
TempEntity2[TempEntity2["ROCKET_EXPLOSION_WATER"] = 17] = "ROCKET_EXPLOSION_WATER";
|
|
1868
|
+
TempEntity2[TempEntity2["GRENADE_EXPLOSION_WATER"] = 18] = "GRENADE_EXPLOSION_WATER";
|
|
1869
|
+
TempEntity2[TempEntity2["MEDIC_CABLE_ATTACK"] = 19] = "MEDIC_CABLE_ATTACK";
|
|
1870
|
+
TempEntity2[TempEntity2["BFG_EXPLOSION"] = 20] = "BFG_EXPLOSION";
|
|
1871
|
+
TempEntity2[TempEntity2["BFG_BIGEXPLOSION"] = 21] = "BFG_BIGEXPLOSION";
|
|
1872
|
+
TempEntity2[TempEntity2["BOSSTPORT"] = 22] = "BOSSTPORT";
|
|
1873
|
+
TempEntity2[TempEntity2["BFG_LASER"] = 23] = "BFG_LASER";
|
|
1874
|
+
TempEntity2[TempEntity2["GRAPPLE_CABLE"] = 24] = "GRAPPLE_CABLE";
|
|
1875
|
+
TempEntity2[TempEntity2["WELDING_SPARKS"] = 25] = "WELDING_SPARKS";
|
|
1876
|
+
TempEntity2[TempEntity2["GREENBLOOD"] = 26] = "GREENBLOOD";
|
|
1877
|
+
TempEntity2[TempEntity2["BLUEHYPERBLASTER"] = 27] = "BLUEHYPERBLASTER";
|
|
1878
|
+
TempEntity2[TempEntity2["PLASMA_EXPLOSION"] = 28] = "PLASMA_EXPLOSION";
|
|
1879
|
+
TempEntity2[TempEntity2["TUNNEL_SPARKS"] = 29] = "TUNNEL_SPARKS";
|
|
1880
|
+
TempEntity2[TempEntity2["BLASTER2"] = 30] = "BLASTER2";
|
|
1881
|
+
TempEntity2[TempEntity2["RAILTRAIL2"] = 31] = "RAILTRAIL2";
|
|
1882
|
+
TempEntity2[TempEntity2["FLAME"] = 32] = "FLAME";
|
|
1883
|
+
TempEntity2[TempEntity2["LIGHTNING"] = 33] = "LIGHTNING";
|
|
1884
|
+
TempEntity2[TempEntity2["DEBUGTRAIL"] = 34] = "DEBUGTRAIL";
|
|
1885
|
+
TempEntity2[TempEntity2["PLAIN_EXPLOSION"] = 35] = "PLAIN_EXPLOSION";
|
|
1886
|
+
TempEntity2[TempEntity2["FLASHLIGHT"] = 36] = "FLASHLIGHT";
|
|
1887
|
+
TempEntity2[TempEntity2["FORCEWALL"] = 37] = "FORCEWALL";
|
|
1888
|
+
TempEntity2[TempEntity2["HEATBEAM"] = 38] = "HEATBEAM";
|
|
1889
|
+
TempEntity2[TempEntity2["MONSTER_HEATBEAM"] = 39] = "MONSTER_HEATBEAM";
|
|
1890
|
+
TempEntity2[TempEntity2["STEAM"] = 40] = "STEAM";
|
|
1891
|
+
TempEntity2[TempEntity2["BUBBLETRAIL2"] = 41] = "BUBBLETRAIL2";
|
|
1892
|
+
TempEntity2[TempEntity2["MOREBLOOD"] = 42] = "MOREBLOOD";
|
|
1893
|
+
TempEntity2[TempEntity2["HEATBEAM_SPARKS"] = 43] = "HEATBEAM_SPARKS";
|
|
1894
|
+
TempEntity2[TempEntity2["HEATBEAM_STEAM"] = 44] = "HEATBEAM_STEAM";
|
|
1895
|
+
TempEntity2[TempEntity2["CHAINFIST_SMOKE"] = 45] = "CHAINFIST_SMOKE";
|
|
1896
|
+
TempEntity2[TempEntity2["ELECTRIC_SPARKS"] = 46] = "ELECTRIC_SPARKS";
|
|
1897
|
+
TempEntity2[TempEntity2["TRACKER_EXPLOSION"] = 47] = "TRACKER_EXPLOSION";
|
|
1898
|
+
TempEntity2[TempEntity2["TELEPORT_EFFECT"] = 48] = "TELEPORT_EFFECT";
|
|
1899
|
+
TempEntity2[TempEntity2["DBALL_GOAL"] = 49] = "DBALL_GOAL";
|
|
1900
|
+
TempEntity2[TempEntity2["WIDOWBEAMOUT"] = 50] = "WIDOWBEAMOUT";
|
|
1901
|
+
TempEntity2[TempEntity2["NUKEBLAST"] = 51] = "NUKEBLAST";
|
|
1902
|
+
TempEntity2[TempEntity2["WIDOWSPLASH"] = 52] = "WIDOWSPLASH";
|
|
1903
|
+
TempEntity2[TempEntity2["EXPLOSION1_BIG"] = 53] = "EXPLOSION1_BIG";
|
|
1904
|
+
TempEntity2[TempEntity2["EXPLOSION1_NP"] = 54] = "EXPLOSION1_NP";
|
|
1905
|
+
TempEntity2[TempEntity2["FLECHETTE"] = 55] = "FLECHETTE";
|
|
1906
|
+
return TempEntity2;
|
|
1907
|
+
})(TempEntity || {});
|
|
1908
|
+
var BinaryStream = class {
|
|
1909
|
+
constructor(buffer) {
|
|
1910
|
+
if (buffer instanceof Uint8Array) {
|
|
1911
|
+
this.view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
1912
|
+
} else {
|
|
1913
|
+
this.view = new DataView(buffer);
|
|
1914
|
+
}
|
|
1915
|
+
this.offset = 0;
|
|
1916
|
+
this.length = this.view.byteLength;
|
|
1917
|
+
}
|
|
1918
|
+
getPosition() {
|
|
1919
|
+
return this.offset;
|
|
1920
|
+
}
|
|
1921
|
+
seek(position) {
|
|
1922
|
+
if (position < 0 || position > this.length) {
|
|
1923
|
+
throw new Error(`Seek out of bounds: ${position} (length: ${this.length})`);
|
|
1924
|
+
}
|
|
1925
|
+
this.offset = position;
|
|
1926
|
+
}
|
|
1927
|
+
hasMore() {
|
|
1928
|
+
return this.offset < this.length;
|
|
1929
|
+
}
|
|
1930
|
+
readChar() {
|
|
1931
|
+
const value = this.view.getInt8(this.offset);
|
|
1932
|
+
this.offset += 1;
|
|
1933
|
+
return value;
|
|
1934
|
+
}
|
|
1935
|
+
readByte() {
|
|
1936
|
+
const value = this.view.getUint8(this.offset);
|
|
1937
|
+
this.offset += 1;
|
|
1938
|
+
return value;
|
|
1939
|
+
}
|
|
1940
|
+
readShort() {
|
|
1941
|
+
const value = this.view.getInt16(this.offset, true);
|
|
1942
|
+
this.offset += 2;
|
|
1943
|
+
return value;
|
|
1944
|
+
}
|
|
1945
|
+
readLong() {
|
|
1946
|
+
const value = this.view.getInt32(this.offset, true);
|
|
1947
|
+
this.offset += 4;
|
|
1948
|
+
return value;
|
|
1949
|
+
}
|
|
1950
|
+
readFloat() {
|
|
1951
|
+
const value = this.view.getFloat32(this.offset, true);
|
|
1952
|
+
this.offset += 4;
|
|
1953
|
+
return value;
|
|
1954
|
+
}
|
|
1955
|
+
readString() {
|
|
1956
|
+
let str3 = "";
|
|
1957
|
+
while (this.offset < this.length) {
|
|
1958
|
+
const charCode = this.readChar();
|
|
1959
|
+
if (charCode === -1 || charCode === 0) {
|
|
1960
|
+
break;
|
|
1961
|
+
}
|
|
1962
|
+
str3 += String.fromCharCode(charCode);
|
|
1963
|
+
}
|
|
1964
|
+
return str3;
|
|
1965
|
+
}
|
|
1966
|
+
readStringLine() {
|
|
1967
|
+
let str3 = "";
|
|
1968
|
+
while (this.offset < this.length) {
|
|
1969
|
+
const charCode = this.readChar();
|
|
1970
|
+
if (charCode === -1 || charCode === 0 || charCode === 10) {
|
|
1971
|
+
break;
|
|
1972
|
+
}
|
|
1973
|
+
str3 += String.fromCharCode(charCode);
|
|
1974
|
+
}
|
|
1975
|
+
return str3;
|
|
1976
|
+
}
|
|
1977
|
+
readCoord() {
|
|
1978
|
+
return this.readShort() * (1 / 8);
|
|
1979
|
+
}
|
|
1980
|
+
readAngle() {
|
|
1981
|
+
return this.readChar() * (360 / 256);
|
|
1982
|
+
}
|
|
1983
|
+
readAngle16() {
|
|
1984
|
+
return this.readShort() * 360 / 65536;
|
|
1985
|
+
}
|
|
1986
|
+
readData(length2) {
|
|
1987
|
+
if (this.offset + length2 > this.length) {
|
|
1988
|
+
throw new Error(`Read out of bounds: ${this.offset + length2} (length: ${this.length})`);
|
|
1989
|
+
}
|
|
1990
|
+
const data = new Uint8Array(this.view.buffer, this.view.byteOffset + this.offset, length2);
|
|
1991
|
+
this.offset += length2;
|
|
1992
|
+
return new Uint8Array(data);
|
|
1993
|
+
}
|
|
1994
|
+
readPos(out) {
|
|
1995
|
+
out.x = this.readCoord();
|
|
1996
|
+
out.y = this.readCoord();
|
|
1997
|
+
out.z = this.readCoord();
|
|
1998
|
+
}
|
|
1999
|
+
readDir(out) {
|
|
2000
|
+
const b = this.readByte();
|
|
2001
|
+
if (b >= 162) {
|
|
2002
|
+
out.x = 0;
|
|
2003
|
+
out.y = 0;
|
|
2004
|
+
out.z = 0;
|
|
2005
|
+
return;
|
|
2006
|
+
}
|
|
2007
|
+
out.x = 0;
|
|
2008
|
+
out.y = 0;
|
|
2009
|
+
out.z = 0;
|
|
2010
|
+
}
|
|
2011
|
+
};
|
|
1825
2012
|
function createCrcTable() {
|
|
1826
2013
|
const table = new Uint32Array(256);
|
|
1827
2014
|
for (let i = 0; i < 256; i += 1) {
|
|
@@ -2137,6 +2324,672 @@ var Camera = class {
|
|
|
2137
2324
|
this._dirty = false;
|
|
2138
2325
|
}
|
|
2139
2326
|
};
|
|
2327
|
+
var DemoReader = class {
|
|
2328
|
+
constructor(buffer) {
|
|
2329
|
+
this.buffer = buffer;
|
|
2330
|
+
this.view = new DataView(buffer);
|
|
2331
|
+
this.offset = 0;
|
|
2332
|
+
}
|
|
2333
|
+
/**
|
|
2334
|
+
* Checks if there are more blocks to read.
|
|
2335
|
+
*/
|
|
2336
|
+
hasMore() {
|
|
2337
|
+
return this.offset < this.buffer.byteLength;
|
|
2338
|
+
}
|
|
2339
|
+
/**
|
|
2340
|
+
* Reads the next message block from the demo file.
|
|
2341
|
+
* Format is [Length (4 bytes)] + [Message Block (Length bytes)].
|
|
2342
|
+
* Returns null if end of file or incomplete block.
|
|
2343
|
+
*/
|
|
2344
|
+
readNextBlock() {
|
|
2345
|
+
if (this.offset + 4 > this.buffer.byteLength) {
|
|
2346
|
+
return null;
|
|
2347
|
+
}
|
|
2348
|
+
const length2 = this.view.getInt32(this.offset, true);
|
|
2349
|
+
this.offset += 4;
|
|
2350
|
+
if (length2 < 0 || length2 > 262144) {
|
|
2351
|
+
console.warn(`DemoReader: Invalid block length ${length2} at offset ${this.offset - 4}`);
|
|
2352
|
+
return null;
|
|
2353
|
+
}
|
|
2354
|
+
if (this.offset + length2 > this.buffer.byteLength) {
|
|
2355
|
+
console.warn(`DemoReader: Incomplete block. Expected ${length2} bytes, but only ${this.buffer.byteLength - this.offset} remain.`);
|
|
2356
|
+
return null;
|
|
2357
|
+
}
|
|
2358
|
+
const blockData = this.buffer.slice(this.offset, this.offset + length2);
|
|
2359
|
+
this.offset += length2;
|
|
2360
|
+
return {
|
|
2361
|
+
length: length2,
|
|
2362
|
+
data: new BinaryStream(blockData)
|
|
2363
|
+
};
|
|
2364
|
+
}
|
|
2365
|
+
/**
|
|
2366
|
+
* Resets the reader to the beginning.
|
|
2367
|
+
*/
|
|
2368
|
+
reset() {
|
|
2369
|
+
this.offset = 0;
|
|
2370
|
+
}
|
|
2371
|
+
getOffset() {
|
|
2372
|
+
return this.offset;
|
|
2373
|
+
}
|
|
2374
|
+
};
|
|
2375
|
+
var U_ORIGIN1 = 1 << 0;
|
|
2376
|
+
var U_ORIGIN2 = 1 << 1;
|
|
2377
|
+
var U_ANGLE2 = 1 << 2;
|
|
2378
|
+
var U_ANGLE3 = 1 << 3;
|
|
2379
|
+
var U_FRAME8 = 1 << 4;
|
|
2380
|
+
var U_EVENT = 1 << 5;
|
|
2381
|
+
var U_REMOVE = 1 << 6;
|
|
2382
|
+
var U_MOREBITS1 = 1 << 7;
|
|
2383
|
+
var U_NUMBER16 = 1 << 8;
|
|
2384
|
+
var U_ORIGIN3 = 1 << 9;
|
|
2385
|
+
var U_ANGLE1 = 1 << 10;
|
|
2386
|
+
var U_MODEL = 1 << 11;
|
|
2387
|
+
var U_RENDERFX8 = 1 << 12;
|
|
2388
|
+
var U_EFFECTS8 = 1 << 14;
|
|
2389
|
+
var U_MOREBITS2 = 1 << 15;
|
|
2390
|
+
var U_SKIN8 = 1 << 16;
|
|
2391
|
+
var U_FRAME16 = 1 << 17;
|
|
2392
|
+
var U_RENDERFX16 = 1 << 18;
|
|
2393
|
+
var U_EFFECTS16 = 1 << 19;
|
|
2394
|
+
var U_MODEL2 = 1 << 20;
|
|
2395
|
+
var U_MODEL3 = 1 << 21;
|
|
2396
|
+
var U_MODEL4 = 1 << 22;
|
|
2397
|
+
var U_MOREBITS3 = 1 << 23;
|
|
2398
|
+
var U_OLDORIGIN = 1 << 24;
|
|
2399
|
+
var U_SKIN16 = 1 << 25;
|
|
2400
|
+
var U_SOUND = 1 << 26;
|
|
2401
|
+
var U_SOLID = 1 << 27;
|
|
2402
|
+
var createEmptyEntityState = () => ({
|
|
2403
|
+
number: 0,
|
|
2404
|
+
modelindex: 0,
|
|
2405
|
+
modelindex2: 0,
|
|
2406
|
+
modelindex3: 0,
|
|
2407
|
+
modelindex4: 0,
|
|
2408
|
+
frame: 0,
|
|
2409
|
+
skinnum: 0,
|
|
2410
|
+
effects: 0,
|
|
2411
|
+
renderfx: 0,
|
|
2412
|
+
origin: { x: 0, y: 0, z: 0 },
|
|
2413
|
+
old_origin: { x: 0, y: 0, z: 0 },
|
|
2414
|
+
angles: { x: 0, y: 0, z: 0 },
|
|
2415
|
+
sound: 0,
|
|
2416
|
+
event: 0,
|
|
2417
|
+
solid: 0
|
|
2418
|
+
});
|
|
2419
|
+
var NetworkMessageParser = class {
|
|
2420
|
+
constructor(stream) {
|
|
2421
|
+
this.stream = stream;
|
|
2422
|
+
}
|
|
2423
|
+
parseMessage() {
|
|
2424
|
+
while (this.stream.hasMore()) {
|
|
2425
|
+
const cmd = this.stream.readByte();
|
|
2426
|
+
if (cmd === -1) {
|
|
2427
|
+
break;
|
|
2428
|
+
}
|
|
2429
|
+
switch (cmd) {
|
|
2430
|
+
case ServerCommand.nop:
|
|
2431
|
+
break;
|
|
2432
|
+
case ServerCommand.disconnect:
|
|
2433
|
+
console.log("Server disconnected");
|
|
2434
|
+
break;
|
|
2435
|
+
case ServerCommand.reconnect:
|
|
2436
|
+
console.log("Server reconnect");
|
|
2437
|
+
break;
|
|
2438
|
+
case ServerCommand.print:
|
|
2439
|
+
const printId = this.stream.readByte();
|
|
2440
|
+
const printMsg = this.stream.readString();
|
|
2441
|
+
console.log(`[Server Print ${printId}]: ${printMsg}`);
|
|
2442
|
+
break;
|
|
2443
|
+
case ServerCommand.serverdata:
|
|
2444
|
+
this.parseServerData();
|
|
2445
|
+
break;
|
|
2446
|
+
case ServerCommand.configstring:
|
|
2447
|
+
this.parseConfigString();
|
|
2448
|
+
break;
|
|
2449
|
+
case ServerCommand.spawnbaseline:
|
|
2450
|
+
this.parseSpawnBaseline();
|
|
2451
|
+
break;
|
|
2452
|
+
case ServerCommand.centerprint:
|
|
2453
|
+
const centerMsg = this.stream.readString();
|
|
2454
|
+
console.log(`[Center Print]: ${centerMsg}`);
|
|
2455
|
+
break;
|
|
2456
|
+
case ServerCommand.download:
|
|
2457
|
+
this.parseDownload();
|
|
2458
|
+
break;
|
|
2459
|
+
case ServerCommand.frame:
|
|
2460
|
+
this.parseFrame();
|
|
2461
|
+
break;
|
|
2462
|
+
case ServerCommand.packetentities:
|
|
2463
|
+
this.parsePacketEntities(false);
|
|
2464
|
+
break;
|
|
2465
|
+
case ServerCommand.deltapacketentities:
|
|
2466
|
+
this.parsePacketEntities(true);
|
|
2467
|
+
break;
|
|
2468
|
+
case ServerCommand.stufftext:
|
|
2469
|
+
const text = this.stream.readString();
|
|
2470
|
+
console.log(`[StuffText]: ${text}`);
|
|
2471
|
+
break;
|
|
2472
|
+
case ServerCommand.layout:
|
|
2473
|
+
const layout = this.stream.readString();
|
|
2474
|
+
break;
|
|
2475
|
+
case ServerCommand.inventory:
|
|
2476
|
+
this.parseInventory();
|
|
2477
|
+
break;
|
|
2478
|
+
case ServerCommand.sound:
|
|
2479
|
+
this.parseSound();
|
|
2480
|
+
break;
|
|
2481
|
+
case ServerCommand.muzzleflash:
|
|
2482
|
+
this.parseMuzzleFlash();
|
|
2483
|
+
break;
|
|
2484
|
+
case ServerCommand.muzzleflash2:
|
|
2485
|
+
this.parseMuzzleFlash2();
|
|
2486
|
+
break;
|
|
2487
|
+
case ServerCommand.temp_entity:
|
|
2488
|
+
this.parseTempEntity();
|
|
2489
|
+
break;
|
|
2490
|
+
default:
|
|
2491
|
+
console.warn(`Unknown server command: ${cmd}`);
|
|
2492
|
+
return;
|
|
2493
|
+
}
|
|
2494
|
+
}
|
|
2495
|
+
}
|
|
2496
|
+
parseServerData() {
|
|
2497
|
+
const protocol = this.stream.readLong();
|
|
2498
|
+
const serverCount = this.stream.readLong();
|
|
2499
|
+
const attractLoop = this.stream.readByte();
|
|
2500
|
+
const gameDir = this.stream.readString();
|
|
2501
|
+
const playerNum = this.stream.readShort();
|
|
2502
|
+
const levelName = this.stream.readString();
|
|
2503
|
+
console.log(`Server Data: Protocol ${protocol}, Level ${levelName}, GameDir ${gameDir}`);
|
|
2504
|
+
}
|
|
2505
|
+
parseConfigString() {
|
|
2506
|
+
const index = this.stream.readShort();
|
|
2507
|
+
const str3 = this.stream.readString();
|
|
2508
|
+
}
|
|
2509
|
+
parseDownload() {
|
|
2510
|
+
const size = this.stream.readShort();
|
|
2511
|
+
const percent = this.stream.readByte();
|
|
2512
|
+
if (size > 0) {
|
|
2513
|
+
this.stream.readData(size);
|
|
2514
|
+
}
|
|
2515
|
+
}
|
|
2516
|
+
parseInventory() {
|
|
2517
|
+
const MAX_ITEMS22 = 256;
|
|
2518
|
+
for (let i = 0; i < MAX_ITEMS22; i++) {
|
|
2519
|
+
this.stream.readShort();
|
|
2520
|
+
}
|
|
2521
|
+
}
|
|
2522
|
+
parseSound() {
|
|
2523
|
+
const flags = this.stream.readByte();
|
|
2524
|
+
const soundNum = this.stream.readByte();
|
|
2525
|
+
if (flags & 1) {
|
|
2526
|
+
this.stream.readByte();
|
|
2527
|
+
}
|
|
2528
|
+
if (flags & 2) {
|
|
2529
|
+
this.stream.readByte();
|
|
2530
|
+
}
|
|
2531
|
+
if (flags & 16) {
|
|
2532
|
+
this.stream.readByte();
|
|
2533
|
+
}
|
|
2534
|
+
if (flags & 8) {
|
|
2535
|
+
this.stream.readShort();
|
|
2536
|
+
}
|
|
2537
|
+
if (flags & 4) {
|
|
2538
|
+
const pos = { x: 0, y: 0, z: 0 };
|
|
2539
|
+
this.stream.readPos(pos);
|
|
2540
|
+
}
|
|
2541
|
+
}
|
|
2542
|
+
parseMuzzleFlash() {
|
|
2543
|
+
const ent = this.stream.readShort();
|
|
2544
|
+
const weapon = this.stream.readByte();
|
|
2545
|
+
}
|
|
2546
|
+
parseMuzzleFlash2() {
|
|
2547
|
+
const ent = this.stream.readShort();
|
|
2548
|
+
const weapon = this.stream.readByte();
|
|
2549
|
+
}
|
|
2550
|
+
parseTempEntity() {
|
|
2551
|
+
const type = this.stream.readByte();
|
|
2552
|
+
const pos = { x: 0, y: 0, z: 0 };
|
|
2553
|
+
const pos2 = { x: 0, y: 0, z: 0 };
|
|
2554
|
+
const dir = { x: 0, y: 0, z: 0 };
|
|
2555
|
+
switch (type) {
|
|
2556
|
+
case TempEntity.BLOOD:
|
|
2557
|
+
this.stream.readPos(pos);
|
|
2558
|
+
this.stream.readDir(dir);
|
|
2559
|
+
break;
|
|
2560
|
+
case TempEntity.GUNSHOT:
|
|
2561
|
+
case TempEntity.SPARKS:
|
|
2562
|
+
case TempEntity.BULLET_SPARKS:
|
|
2563
|
+
this.stream.readPos(pos);
|
|
2564
|
+
this.stream.readDir(dir);
|
|
2565
|
+
break;
|
|
2566
|
+
case TempEntity.SCREEN_SPARKS:
|
|
2567
|
+
case TempEntity.SHIELD_SPARKS:
|
|
2568
|
+
this.stream.readPos(pos);
|
|
2569
|
+
this.stream.readDir(dir);
|
|
2570
|
+
break;
|
|
2571
|
+
case TempEntity.SHOTGUN:
|
|
2572
|
+
this.stream.readPos(pos);
|
|
2573
|
+
this.stream.readDir(dir);
|
|
2574
|
+
break;
|
|
2575
|
+
case TempEntity.SPLASH:
|
|
2576
|
+
this.stream.readByte();
|
|
2577
|
+
this.stream.readPos(pos);
|
|
2578
|
+
this.stream.readDir(dir);
|
|
2579
|
+
this.stream.readByte();
|
|
2580
|
+
break;
|
|
2581
|
+
case TempEntity.LASER_SPARKS:
|
|
2582
|
+
this.stream.readByte();
|
|
2583
|
+
this.stream.readPos(pos);
|
|
2584
|
+
this.stream.readDir(dir);
|
|
2585
|
+
this.stream.readByte();
|
|
2586
|
+
break;
|
|
2587
|
+
case TempEntity.BLUEHYPERBLASTER:
|
|
2588
|
+
this.stream.readPos(pos);
|
|
2589
|
+
this.stream.readPos(dir);
|
|
2590
|
+
break;
|
|
2591
|
+
case TempEntity.BLASTER:
|
|
2592
|
+
this.stream.readPos(pos);
|
|
2593
|
+
this.stream.readDir(dir);
|
|
2594
|
+
break;
|
|
2595
|
+
case TempEntity.RAILTRAIL:
|
|
2596
|
+
this.stream.readPos(pos);
|
|
2597
|
+
this.stream.readPos(pos2);
|
|
2598
|
+
break;
|
|
2599
|
+
case TempEntity.EXPLOSION2:
|
|
2600
|
+
case TempEntity.GRENADE_EXPLOSION:
|
|
2601
|
+
case TempEntity.GRENADE_EXPLOSION_WATER:
|
|
2602
|
+
this.stream.readPos(pos);
|
|
2603
|
+
break;
|
|
2604
|
+
case TempEntity.PLASMA_EXPLOSION:
|
|
2605
|
+
this.stream.readPos(pos);
|
|
2606
|
+
break;
|
|
2607
|
+
case TempEntity.EXPLOSION1:
|
|
2608
|
+
case TempEntity.EXPLOSION1_BIG:
|
|
2609
|
+
case TempEntity.ROCKET_EXPLOSION:
|
|
2610
|
+
case TempEntity.ROCKET_EXPLOSION_WATER:
|
|
2611
|
+
case TempEntity.EXPLOSION1_NP:
|
|
2612
|
+
this.stream.readPos(pos);
|
|
2613
|
+
break;
|
|
2614
|
+
case TempEntity.BFG_EXPLOSION:
|
|
2615
|
+
this.stream.readPos(pos);
|
|
2616
|
+
break;
|
|
2617
|
+
case TempEntity.BFG_BIGEXPLOSION:
|
|
2618
|
+
this.stream.readPos(pos);
|
|
2619
|
+
break;
|
|
2620
|
+
case TempEntity.BFG_LASER:
|
|
2621
|
+
this.stream.readPos(pos);
|
|
2622
|
+
this.stream.readPos(pos2);
|
|
2623
|
+
break;
|
|
2624
|
+
case TempEntity.BUBBLETRAIL:
|
|
2625
|
+
this.stream.readPos(pos);
|
|
2626
|
+
this.stream.readPos(pos2);
|
|
2627
|
+
break;
|
|
2628
|
+
case TempEntity.PARASITE_ATTACK:
|
|
2629
|
+
case TempEntity.MEDIC_CABLE_ATTACK:
|
|
2630
|
+
this.stream.readShort();
|
|
2631
|
+
this.stream.readPos(pos);
|
|
2632
|
+
this.stream.readPos(pos2);
|
|
2633
|
+
break;
|
|
2634
|
+
case TempEntity.BOSSTPORT:
|
|
2635
|
+
this.stream.readPos(pos);
|
|
2636
|
+
break;
|
|
2637
|
+
case TempEntity.GRAPPLE_CABLE:
|
|
2638
|
+
this.stream.readShort();
|
|
2639
|
+
this.stream.readPos(pos);
|
|
2640
|
+
this.stream.readPos(pos2);
|
|
2641
|
+
this.stream.readPos(dir);
|
|
2642
|
+
break;
|
|
2643
|
+
case TempEntity.WELDING_SPARKS:
|
|
2644
|
+
this.stream.readByte();
|
|
2645
|
+
this.stream.readPos(pos);
|
|
2646
|
+
this.stream.readDir(dir);
|
|
2647
|
+
this.stream.readByte();
|
|
2648
|
+
break;
|
|
2649
|
+
case TempEntity.GREENBLOOD:
|
|
2650
|
+
this.stream.readPos(pos);
|
|
2651
|
+
this.stream.readDir(dir);
|
|
2652
|
+
break;
|
|
2653
|
+
case TempEntity.TUNNEL_SPARKS:
|
|
2654
|
+
this.stream.readByte();
|
|
2655
|
+
this.stream.readPos(pos);
|
|
2656
|
+
this.stream.readDir(dir);
|
|
2657
|
+
this.stream.readByte();
|
|
2658
|
+
break;
|
|
2659
|
+
case TempEntity.BLASTER2:
|
|
2660
|
+
case TempEntity.FLECHETTE:
|
|
2661
|
+
this.stream.readPos(pos);
|
|
2662
|
+
this.stream.readDir(dir);
|
|
2663
|
+
break;
|
|
2664
|
+
case TempEntity.LIGHTNING:
|
|
2665
|
+
this.stream.readShort();
|
|
2666
|
+
this.stream.readShort();
|
|
2667
|
+
this.stream.readPos(pos);
|
|
2668
|
+
this.stream.readPos(pos2);
|
|
2669
|
+
break;
|
|
2670
|
+
case TempEntity.DEBUGTRAIL:
|
|
2671
|
+
this.stream.readPos(pos);
|
|
2672
|
+
this.stream.readPos(pos2);
|
|
2673
|
+
break;
|
|
2674
|
+
case TempEntity.PLAIN_EXPLOSION:
|
|
2675
|
+
this.stream.readPos(pos);
|
|
2676
|
+
break;
|
|
2677
|
+
case TempEntity.FLASHLIGHT:
|
|
2678
|
+
this.stream.readPos(pos);
|
|
2679
|
+
this.stream.readShort();
|
|
2680
|
+
break;
|
|
2681
|
+
case TempEntity.FORCEWALL:
|
|
2682
|
+
this.stream.readPos(pos);
|
|
2683
|
+
this.stream.readPos(pos2);
|
|
2684
|
+
this.stream.readByte();
|
|
2685
|
+
break;
|
|
2686
|
+
case TempEntity.HEATBEAM:
|
|
2687
|
+
this.stream.readShort();
|
|
2688
|
+
this.stream.readPos(pos);
|
|
2689
|
+
this.stream.readPos(pos2);
|
|
2690
|
+
this.stream.readPos(dir);
|
|
2691
|
+
break;
|
|
2692
|
+
case TempEntity.MONSTER_HEATBEAM:
|
|
2693
|
+
this.stream.readShort();
|
|
2694
|
+
this.stream.readPos(pos);
|
|
2695
|
+
this.stream.readPos(pos2);
|
|
2696
|
+
this.stream.readPos(dir);
|
|
2697
|
+
break;
|
|
2698
|
+
case TempEntity.HEATBEAM_SPARKS:
|
|
2699
|
+
this.stream.readPos(pos);
|
|
2700
|
+
this.stream.readDir(dir);
|
|
2701
|
+
break;
|
|
2702
|
+
case TempEntity.HEATBEAM_STEAM:
|
|
2703
|
+
this.stream.readPos(pos);
|
|
2704
|
+
this.stream.readDir(dir);
|
|
2705
|
+
break;
|
|
2706
|
+
case TempEntity.STEAM:
|
|
2707
|
+
const steamId = this.stream.readShort();
|
|
2708
|
+
if (steamId !== -1) {
|
|
2709
|
+
this.stream.readByte();
|
|
2710
|
+
this.stream.readPos(pos);
|
|
2711
|
+
this.stream.readDir(dir);
|
|
2712
|
+
this.stream.readByte();
|
|
2713
|
+
this.stream.readShort();
|
|
2714
|
+
this.stream.readLong();
|
|
2715
|
+
} else {
|
|
2716
|
+
this.stream.readByte();
|
|
2717
|
+
this.stream.readPos(pos);
|
|
2718
|
+
this.stream.readDir(dir);
|
|
2719
|
+
this.stream.readByte();
|
|
2720
|
+
this.stream.readShort();
|
|
2721
|
+
}
|
|
2722
|
+
break;
|
|
2723
|
+
case TempEntity.BUBBLETRAIL2:
|
|
2724
|
+
this.stream.readPos(pos);
|
|
2725
|
+
this.stream.readPos(pos2);
|
|
2726
|
+
break;
|
|
2727
|
+
case TempEntity.MOREBLOOD:
|
|
2728
|
+
this.stream.readPos(pos);
|
|
2729
|
+
this.stream.readDir(dir);
|
|
2730
|
+
break;
|
|
2731
|
+
case TempEntity.CHAINFIST_SMOKE:
|
|
2732
|
+
this.stream.readPos(pos);
|
|
2733
|
+
break;
|
|
2734
|
+
case TempEntity.ELECTRIC_SPARKS:
|
|
2735
|
+
this.stream.readPos(pos);
|
|
2736
|
+
this.stream.readDir(dir);
|
|
2737
|
+
break;
|
|
2738
|
+
case TempEntity.TRACKER_EXPLOSION:
|
|
2739
|
+
this.stream.readPos(pos);
|
|
2740
|
+
break;
|
|
2741
|
+
case TempEntity.TELEPORT_EFFECT:
|
|
2742
|
+
case TempEntity.DBALL_GOAL:
|
|
2743
|
+
this.stream.readPos(pos);
|
|
2744
|
+
break;
|
|
2745
|
+
case TempEntity.WIDOWBEAMOUT:
|
|
2746
|
+
const wbId = this.stream.readShort();
|
|
2747
|
+
this.stream.readPos(pos);
|
|
2748
|
+
break;
|
|
2749
|
+
case TempEntity.NUKEBLAST:
|
|
2750
|
+
this.stream.readPos(pos);
|
|
2751
|
+
break;
|
|
2752
|
+
case TempEntity.WIDOWSPLASH:
|
|
2753
|
+
this.stream.readPos(pos);
|
|
2754
|
+
break;
|
|
2755
|
+
default:
|
|
2756
|
+
console.warn(`CL_ParseTEnt: bad type ${type}`);
|
|
2757
|
+
break;
|
|
2758
|
+
}
|
|
2759
|
+
}
|
|
2760
|
+
parseSpawnBaseline() {
|
|
2761
|
+
const bits = this.parseEntityBits();
|
|
2762
|
+
this.parseDelta(createEmptyEntityState(), createEmptyEntityState(), bits.number, bits.bits);
|
|
2763
|
+
}
|
|
2764
|
+
parseFrame() {
|
|
2765
|
+
const serverFrame = this.stream.readLong();
|
|
2766
|
+
const deltaFrame = this.stream.readLong();
|
|
2767
|
+
const surpressCount = this.stream.readByte();
|
|
2768
|
+
const areaBytes = this.stream.readByte();
|
|
2769
|
+
this.stream.readData(areaBytes);
|
|
2770
|
+
const piCmd = this.stream.readByte();
|
|
2771
|
+
if (piCmd !== ServerCommand.playerinfo) {
|
|
2772
|
+
throw new Error(`Expected svc_playerinfo after svc_frame, got ${piCmd}`);
|
|
2773
|
+
}
|
|
2774
|
+
this.parsePlayerState();
|
|
2775
|
+
const peCmd = this.stream.readByte();
|
|
2776
|
+
if (peCmd !== ServerCommand.packetentities && peCmd !== ServerCommand.deltapacketentities) {
|
|
2777
|
+
throw new Error(`Expected svc_packetentities after svc_playerinfo, got ${peCmd}`);
|
|
2778
|
+
}
|
|
2779
|
+
this.parsePacketEntities(peCmd === ServerCommand.deltapacketentities);
|
|
2780
|
+
}
|
|
2781
|
+
parsePlayerState() {
|
|
2782
|
+
const flags = this.stream.readShort();
|
|
2783
|
+
if (flags & 1) this.stream.readByte();
|
|
2784
|
+
if (flags & 2) {
|
|
2785
|
+
this.stream.readShort();
|
|
2786
|
+
this.stream.readShort();
|
|
2787
|
+
this.stream.readShort();
|
|
2788
|
+
}
|
|
2789
|
+
if (flags & 4) {
|
|
2790
|
+
this.stream.readShort();
|
|
2791
|
+
this.stream.readShort();
|
|
2792
|
+
this.stream.readShort();
|
|
2793
|
+
}
|
|
2794
|
+
if (flags & 8) this.stream.readByte();
|
|
2795
|
+
if (flags & 16) this.stream.readByte();
|
|
2796
|
+
if (flags & 32) this.stream.readShort();
|
|
2797
|
+
if (flags & 64) {
|
|
2798
|
+
this.stream.readShort();
|
|
2799
|
+
this.stream.readShort();
|
|
2800
|
+
this.stream.readShort();
|
|
2801
|
+
}
|
|
2802
|
+
if (flags & 128) {
|
|
2803
|
+
this.stream.readChar();
|
|
2804
|
+
this.stream.readChar();
|
|
2805
|
+
this.stream.readChar();
|
|
2806
|
+
}
|
|
2807
|
+
if (flags & 256) {
|
|
2808
|
+
this.stream.readAngle16();
|
|
2809
|
+
this.stream.readAngle16();
|
|
2810
|
+
this.stream.readAngle16();
|
|
2811
|
+
}
|
|
2812
|
+
if (flags & 512) {
|
|
2813
|
+
this.stream.readChar();
|
|
2814
|
+
this.stream.readChar();
|
|
2815
|
+
this.stream.readChar();
|
|
2816
|
+
}
|
|
2817
|
+
if (flags & 4096) this.stream.readByte();
|
|
2818
|
+
if (flags & 8192) {
|
|
2819
|
+
this.stream.readByte();
|
|
2820
|
+
this.stream.readChar();
|
|
2821
|
+
this.stream.readChar();
|
|
2822
|
+
this.stream.readChar();
|
|
2823
|
+
this.stream.readChar();
|
|
2824
|
+
this.stream.readChar();
|
|
2825
|
+
this.stream.readChar();
|
|
2826
|
+
}
|
|
2827
|
+
if (flags & 1024) {
|
|
2828
|
+
this.stream.readByte();
|
|
2829
|
+
this.stream.readByte();
|
|
2830
|
+
this.stream.readByte();
|
|
2831
|
+
this.stream.readByte();
|
|
2832
|
+
}
|
|
2833
|
+
if (flags & 2048) this.stream.readByte();
|
|
2834
|
+
if (flags & 16384) this.stream.readByte();
|
|
2835
|
+
const statbits = this.stream.readLong();
|
|
2836
|
+
for (let i = 0; i < 32; i++) {
|
|
2837
|
+
if (statbits & 1 << i) {
|
|
2838
|
+
this.stream.readShort();
|
|
2839
|
+
}
|
|
2840
|
+
}
|
|
2841
|
+
}
|
|
2842
|
+
parsePacketEntities(delta) {
|
|
2843
|
+
while (true) {
|
|
2844
|
+
const bits = this.parseEntityBits();
|
|
2845
|
+
if (bits.number === 0) {
|
|
2846
|
+
break;
|
|
2847
|
+
}
|
|
2848
|
+
this.parseDelta(createEmptyEntityState(), createEmptyEntityState(), bits.number, bits.bits);
|
|
2849
|
+
}
|
|
2850
|
+
}
|
|
2851
|
+
parseEntityBits() {
|
|
2852
|
+
let total = this.stream.readByte();
|
|
2853
|
+
if (total & U_MOREBITS1) {
|
|
2854
|
+
total |= this.stream.readByte() << 8;
|
|
2855
|
+
}
|
|
2856
|
+
if (total & U_MOREBITS2) {
|
|
2857
|
+
total |= this.stream.readByte() << 16;
|
|
2858
|
+
}
|
|
2859
|
+
if (total & U_MOREBITS3) {
|
|
2860
|
+
total |= this.stream.readByte() << 24;
|
|
2861
|
+
}
|
|
2862
|
+
let number;
|
|
2863
|
+
if (total & U_NUMBER16) {
|
|
2864
|
+
number = this.stream.readShort();
|
|
2865
|
+
} else {
|
|
2866
|
+
number = this.stream.readByte();
|
|
2867
|
+
}
|
|
2868
|
+
return { number, bits: total };
|
|
2869
|
+
}
|
|
2870
|
+
parseDelta(from, to, number, bits) {
|
|
2871
|
+
to.number = from.number;
|
|
2872
|
+
to.modelindex = from.modelindex;
|
|
2873
|
+
to.modelindex2 = from.modelindex2;
|
|
2874
|
+
to.modelindex3 = from.modelindex3;
|
|
2875
|
+
to.modelindex4 = from.modelindex4;
|
|
2876
|
+
to.frame = from.frame;
|
|
2877
|
+
to.skinnum = from.skinnum;
|
|
2878
|
+
to.effects = from.effects;
|
|
2879
|
+
to.renderfx = from.renderfx;
|
|
2880
|
+
to.origin.x = from.origin.x;
|
|
2881
|
+
to.origin.y = from.origin.y;
|
|
2882
|
+
to.origin.z = from.origin.z;
|
|
2883
|
+
to.old_origin.x = from.origin.x;
|
|
2884
|
+
to.old_origin.y = from.origin.y;
|
|
2885
|
+
to.old_origin.z = from.origin.z;
|
|
2886
|
+
to.angles.x = from.angles.x;
|
|
2887
|
+
to.angles.y = from.angles.y;
|
|
2888
|
+
to.angles.z = from.angles.z;
|
|
2889
|
+
to.sound = from.sound;
|
|
2890
|
+
to.event = from.event;
|
|
2891
|
+
to.solid = from.solid;
|
|
2892
|
+
to.number = number;
|
|
2893
|
+
if (bits & U_MODEL) to.modelindex = this.stream.readByte();
|
|
2894
|
+
if (bits & U_MODEL2) to.modelindex2 = this.stream.readByte();
|
|
2895
|
+
if (bits & U_MODEL3) to.modelindex3 = this.stream.readByte();
|
|
2896
|
+
if (bits & U_MODEL4) to.modelindex4 = this.stream.readByte();
|
|
2897
|
+
if (bits & U_FRAME8) to.frame = this.stream.readByte();
|
|
2898
|
+
if (bits & U_FRAME16) to.frame = this.stream.readShort();
|
|
2899
|
+
if (bits & U_SKIN8 && bits & U_SKIN16) {
|
|
2900
|
+
to.skinnum = this.stream.readLong();
|
|
2901
|
+
} else if (bits & U_SKIN8) {
|
|
2902
|
+
to.skinnum = this.stream.readByte();
|
|
2903
|
+
} else if (bits & U_SKIN16) {
|
|
2904
|
+
to.skinnum = this.stream.readShort();
|
|
2905
|
+
}
|
|
2906
|
+
if (bits & U_EFFECTS8 && bits & U_EFFECTS16) {
|
|
2907
|
+
to.effects = this.stream.readLong();
|
|
2908
|
+
} else if (bits & U_EFFECTS8) {
|
|
2909
|
+
to.effects = this.stream.readByte();
|
|
2910
|
+
} else if (bits & U_EFFECTS16) {
|
|
2911
|
+
to.effects = this.stream.readShort();
|
|
2912
|
+
}
|
|
2913
|
+
if (bits & U_RENDERFX8 && bits & U_RENDERFX16) {
|
|
2914
|
+
to.renderfx = this.stream.readLong();
|
|
2915
|
+
} else if (bits & U_RENDERFX8) {
|
|
2916
|
+
to.renderfx = this.stream.readByte();
|
|
2917
|
+
} else if (bits & U_RENDERFX16) {
|
|
2918
|
+
to.renderfx = this.stream.readShort();
|
|
2919
|
+
}
|
|
2920
|
+
if (bits & U_ORIGIN1) to.origin.x = this.stream.readCoord();
|
|
2921
|
+
if (bits & U_ORIGIN2) to.origin.y = this.stream.readCoord();
|
|
2922
|
+
if (bits & U_ORIGIN3) to.origin.z = this.stream.readCoord();
|
|
2923
|
+
if (bits & U_ANGLE1) to.angles.x = this.stream.readAngle();
|
|
2924
|
+
if (bits & U_ANGLE2) to.angles.y = this.stream.readAngle();
|
|
2925
|
+
if (bits & U_ANGLE3) to.angles.z = this.stream.readAngle();
|
|
2926
|
+
if (bits & U_OLDORIGIN) {
|
|
2927
|
+
this.stream.readPos(to.old_origin);
|
|
2928
|
+
}
|
|
2929
|
+
if (bits & U_SOUND) to.sound = this.stream.readByte();
|
|
2930
|
+
if (bits & U_EVENT) {
|
|
2931
|
+
to.event = this.stream.readByte();
|
|
2932
|
+
} else {
|
|
2933
|
+
to.event = 0;
|
|
2934
|
+
}
|
|
2935
|
+
if (bits & U_SOLID) to.solid = this.stream.readShort();
|
|
2936
|
+
}
|
|
2937
|
+
};
|
|
2938
|
+
var DemoPlaybackController = class {
|
|
2939
|
+
// ms (10Hz default)
|
|
2940
|
+
constructor() {
|
|
2941
|
+
this.reader = null;
|
|
2942
|
+
this.state = 0;
|
|
2943
|
+
this.playbackSpeed = 1;
|
|
2944
|
+
this.accumulatedTime = 0;
|
|
2945
|
+
this.frameDuration = 100;
|
|
2946
|
+
}
|
|
2947
|
+
loadDemo(buffer) {
|
|
2948
|
+
this.reader = new DemoReader(buffer);
|
|
2949
|
+
this.state = 0;
|
|
2950
|
+
this.accumulatedTime = 0;
|
|
2951
|
+
}
|
|
2952
|
+
play() {
|
|
2953
|
+
if (this.reader) {
|
|
2954
|
+
this.state = 1;
|
|
2955
|
+
}
|
|
2956
|
+
}
|
|
2957
|
+
pause() {
|
|
2958
|
+
if (this.state === 1) {
|
|
2959
|
+
this.state = 2;
|
|
2960
|
+
}
|
|
2961
|
+
}
|
|
2962
|
+
stop() {
|
|
2963
|
+
this.state = 0;
|
|
2964
|
+
if (this.reader) {
|
|
2965
|
+
this.reader.reset();
|
|
2966
|
+
}
|
|
2967
|
+
this.accumulatedTime = 0;
|
|
2968
|
+
}
|
|
2969
|
+
update(dt) {
|
|
2970
|
+
if (this.state !== 1 || !this.reader) {
|
|
2971
|
+
return;
|
|
2972
|
+
}
|
|
2973
|
+
this.accumulatedTime += dt * 1e3 * this.playbackSpeed;
|
|
2974
|
+
while (this.accumulatedTime >= this.frameDuration) {
|
|
2975
|
+
if (!this.reader.hasMore()) {
|
|
2976
|
+
this.state = 3;
|
|
2977
|
+
return;
|
|
2978
|
+
}
|
|
2979
|
+
const block = this.reader.readNextBlock();
|
|
2980
|
+
if (!block) {
|
|
2981
|
+
this.state = 3;
|
|
2982
|
+
return;
|
|
2983
|
+
}
|
|
2984
|
+
const parser = new NetworkMessageParser(block.data);
|
|
2985
|
+
parser.parseMessage();
|
|
2986
|
+
this.accumulatedTime -= this.frameDuration;
|
|
2987
|
+
}
|
|
2988
|
+
}
|
|
2989
|
+
getState() {
|
|
2990
|
+
return this.state;
|
|
2991
|
+
}
|
|
2992
|
+
};
|
|
2140
2993
|
|
|
2141
2994
|
// ../shared/dist/esm/index.js
|
|
2142
2995
|
var ZERO_VEC3 = { x: 0, y: 0, z: 0 };
|
|
@@ -3445,6 +4298,7 @@ var InputCommandBuffer = class {
|
|
|
3445
4298
|
function createClient(imports) {
|
|
3446
4299
|
const prediction = new ClientPrediction(imports.engine.trace);
|
|
3447
4300
|
const view = new ViewEffects();
|
|
4301
|
+
const demoPlayback = new DemoPlaybackController();
|
|
3448
4302
|
let latestFrame;
|
|
3449
4303
|
let lastRendered;
|
|
3450
4304
|
let lastView;
|
|
@@ -3526,7 +4380,8 @@ function createClient(imports) {
|
|
|
3526
4380
|
},
|
|
3527
4381
|
get camera() {
|
|
3528
4382
|
return camera;
|
|
3529
|
-
}
|
|
4383
|
+
},
|
|
4384
|
+
demoPlayback
|
|
3530
4385
|
};
|
|
3531
4386
|
}
|
|
3532
4387
|
export {
|