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