quake2ts 0.0.84 → 0.0.85
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 +382 -127
- package/packages/client/dist/cjs/index.cjs.map +1 -1
- package/packages/client/dist/esm/index.js +382 -127
- package/packages/client/dist/esm/index.js.map +1 -1
- package/packages/client/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/client/dist/types/demo/handler.d.ts +30 -0
- package/packages/client/dist/types/demo/handler.d.ts.map +1 -0
- package/packages/client/dist/types/index.d.ts +2 -0
- 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 +235 -97
- package/packages/engine/dist/cjs/index.cjs.map +1 -1
- package/packages/engine/dist/esm/index.js +210 -97
- package/packages/engine/dist/esm/index.js.map +1 -1
- package/packages/engine/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/engine/dist/types/demo/index.d.ts +1 -1
- package/packages/engine/dist/types/demo/index.d.ts.map +1 -1
- package/packages/engine/dist/types/demo/parser.d.ts +84 -3
- package/packages/engine/dist/types/demo/parser.d.ts.map +1 -1
- package/packages/engine/dist/types/demo/playback.d.ts +3 -0
- package/packages/engine/dist/types/demo/playback.d.ts.map +1 -1
- package/packages/engine/dist/types/index.d.ts +2 -0
- package/packages/engine/dist/types/index.d.ts.map +1 -1
- package/packages/game/dist/tsconfig.tsbuildinfo +1 -1
|
@@ -5739,11 +5739,33 @@ var createEmptyEntityState = () => ({
|
|
|
5739
5739
|
angles: { x: 0, y: 0, z: 0 },
|
|
5740
5740
|
sound: 0,
|
|
5741
5741
|
event: 0,
|
|
5742
|
-
solid: 0
|
|
5742
|
+
solid: 0,
|
|
5743
|
+
bits: 0
|
|
5744
|
+
});
|
|
5745
|
+
var createEmptyProtocolPlayerState = () => ({
|
|
5746
|
+
pm_type: 0,
|
|
5747
|
+
origin: { x: 0, y: 0, z: 0 },
|
|
5748
|
+
velocity: { x: 0, y: 0, z: 0 },
|
|
5749
|
+
pm_time: 0,
|
|
5750
|
+
pm_flags: 0,
|
|
5751
|
+
gravity: 0,
|
|
5752
|
+
delta_angles: { x: 0, y: 0, z: 0 },
|
|
5753
|
+
viewoffset: { x: 0, y: 0, z: 0 },
|
|
5754
|
+
viewangles: { x: 0, y: 0, z: 0 },
|
|
5755
|
+
kick_angles: { x: 0, y: 0, z: 0 },
|
|
5756
|
+
gun_index: 0,
|
|
5757
|
+
gun_frame: 0,
|
|
5758
|
+
gun_offset: { x: 0, y: 0, z: 0 },
|
|
5759
|
+
gun_angles: { x: 0, y: 0, z: 0 },
|
|
5760
|
+
blend: [0, 0, 0, 0],
|
|
5761
|
+
fov: 0,
|
|
5762
|
+
rdflags: 0,
|
|
5763
|
+
stats: new Array(32).fill(0)
|
|
5743
5764
|
});
|
|
5744
5765
|
var NetworkMessageParser = class {
|
|
5745
|
-
constructor(stream) {
|
|
5766
|
+
constructor(stream, handler) {
|
|
5746
5767
|
this.stream = stream;
|
|
5768
|
+
this.handler = handler;
|
|
5747
5769
|
}
|
|
5748
5770
|
parseMessage() {
|
|
5749
5771
|
while (this.stream.hasMore()) {
|
|
@@ -5755,15 +5777,18 @@ var NetworkMessageParser = class {
|
|
|
5755
5777
|
case ServerCommand.nop:
|
|
5756
5778
|
break;
|
|
5757
5779
|
case ServerCommand.disconnect:
|
|
5758
|
-
|
|
5780
|
+
if (this.handler) this.handler.onDisconnect();
|
|
5781
|
+
else console.log("Server disconnected");
|
|
5759
5782
|
break;
|
|
5760
5783
|
case ServerCommand.reconnect:
|
|
5761
|
-
|
|
5784
|
+
if (this.handler) this.handler.onReconnect();
|
|
5785
|
+
else console.log("Server reconnect");
|
|
5762
5786
|
break;
|
|
5763
5787
|
case ServerCommand.print:
|
|
5764
5788
|
const printId = this.stream.readByte();
|
|
5765
5789
|
const printMsg = this.stream.readString();
|
|
5766
|
-
|
|
5790
|
+
if (this.handler) this.handler.onPrint(printId, printMsg);
|
|
5791
|
+
else console.log(`[Server Print ${printId}]: ${printMsg}`);
|
|
5767
5792
|
break;
|
|
5768
5793
|
case ServerCommand.serverdata:
|
|
5769
5794
|
this.parseServerData();
|
|
@@ -5776,7 +5801,8 @@ var NetworkMessageParser = class {
|
|
|
5776
5801
|
break;
|
|
5777
5802
|
case ServerCommand.centerprint:
|
|
5778
5803
|
const centerMsg = this.stream.readString();
|
|
5779
|
-
|
|
5804
|
+
if (this.handler) this.handler.onCenterPrint(centerMsg);
|
|
5805
|
+
else console.log(`[Center Print]: ${centerMsg}`);
|
|
5780
5806
|
break;
|
|
5781
5807
|
case ServerCommand.download:
|
|
5782
5808
|
this.parseDownload();
|
|
@@ -5792,10 +5818,12 @@ var NetworkMessageParser = class {
|
|
|
5792
5818
|
break;
|
|
5793
5819
|
case ServerCommand.stufftext:
|
|
5794
5820
|
const text = this.stream.readString();
|
|
5795
|
-
|
|
5821
|
+
if (this.handler) this.handler.onStuffText(text);
|
|
5822
|
+
else console.log(`[StuffText]: ${text}`);
|
|
5796
5823
|
break;
|
|
5797
5824
|
case ServerCommand.layout:
|
|
5798
5825
|
const layout = this.stream.readString();
|
|
5826
|
+
if (this.handler) this.handler.onLayout(layout);
|
|
5799
5827
|
break;
|
|
5800
5828
|
case ServerCommand.inventory:
|
|
5801
5829
|
this.parseInventory();
|
|
@@ -5825,58 +5853,89 @@ var NetworkMessageParser = class {
|
|
|
5825
5853
|
const gameDir = this.stream.readString();
|
|
5826
5854
|
const playerNum = this.stream.readShort();
|
|
5827
5855
|
const levelName = this.stream.readString();
|
|
5828
|
-
|
|
5856
|
+
if (this.handler) {
|
|
5857
|
+
this.handler.onServerData(protocol, serverCount, attractLoop, gameDir, playerNum, levelName);
|
|
5858
|
+
} else {
|
|
5859
|
+
console.log(`Server Data: Protocol ${protocol}, Level ${levelName}, GameDir ${gameDir}`);
|
|
5860
|
+
}
|
|
5829
5861
|
}
|
|
5830
5862
|
parseConfigString() {
|
|
5831
5863
|
const index = this.stream.readShort();
|
|
5832
5864
|
const str = this.stream.readString();
|
|
5865
|
+
if (this.handler) {
|
|
5866
|
+
this.handler.onConfigString(index, str);
|
|
5867
|
+
}
|
|
5833
5868
|
}
|
|
5834
5869
|
parseDownload() {
|
|
5835
5870
|
const size = this.stream.readShort();
|
|
5836
5871
|
const percent = this.stream.readByte();
|
|
5872
|
+
let data;
|
|
5837
5873
|
if (size > 0) {
|
|
5838
|
-
this.stream.readData(size);
|
|
5874
|
+
data = this.stream.readData(size);
|
|
5875
|
+
}
|
|
5876
|
+
if (this.handler) {
|
|
5877
|
+
this.handler.onDownload(size, percent, data);
|
|
5839
5878
|
}
|
|
5840
5879
|
}
|
|
5841
5880
|
parseInventory() {
|
|
5842
5881
|
const MAX_ITEMS2 = 256;
|
|
5882
|
+
const inventory = new Array(MAX_ITEMS2);
|
|
5843
5883
|
for (let i = 0; i < MAX_ITEMS2; i++) {
|
|
5844
|
-
this.stream.readShort();
|
|
5884
|
+
inventory[i] = this.stream.readShort();
|
|
5885
|
+
}
|
|
5886
|
+
if (this.handler) {
|
|
5887
|
+
this.handler.onInventory(inventory);
|
|
5845
5888
|
}
|
|
5846
5889
|
}
|
|
5847
5890
|
parseSound() {
|
|
5848
5891
|
const flags = this.stream.readByte();
|
|
5849
5892
|
const soundNum = this.stream.readByte();
|
|
5893
|
+
let volume;
|
|
5894
|
+
let attenuation;
|
|
5895
|
+
let offset;
|
|
5896
|
+
let ent;
|
|
5897
|
+
let pos;
|
|
5850
5898
|
if (flags & 1) {
|
|
5851
|
-
this.stream.readByte();
|
|
5899
|
+
volume = this.stream.readByte();
|
|
5852
5900
|
}
|
|
5853
5901
|
if (flags & 2) {
|
|
5854
|
-
this.stream.readByte();
|
|
5902
|
+
attenuation = this.stream.readByte();
|
|
5855
5903
|
}
|
|
5856
5904
|
if (flags & 16) {
|
|
5857
|
-
this.stream.readByte();
|
|
5905
|
+
offset = this.stream.readByte();
|
|
5858
5906
|
}
|
|
5859
5907
|
if (flags & 8) {
|
|
5860
|
-
this.stream.readShort();
|
|
5908
|
+
ent = this.stream.readShort();
|
|
5861
5909
|
}
|
|
5862
5910
|
if (flags & 4) {
|
|
5863
|
-
const
|
|
5864
|
-
this.stream.readPos(
|
|
5911
|
+
const p = { x: 0, y: 0, z: 0 };
|
|
5912
|
+
this.stream.readPos(p);
|
|
5913
|
+
pos = p;
|
|
5914
|
+
}
|
|
5915
|
+
if (this.handler) {
|
|
5916
|
+
this.handler.onSound(flags, soundNum, volume, attenuation, offset, ent, pos);
|
|
5865
5917
|
}
|
|
5866
5918
|
}
|
|
5867
5919
|
parseMuzzleFlash() {
|
|
5868
5920
|
const ent = this.stream.readShort();
|
|
5869
5921
|
const weapon = this.stream.readByte();
|
|
5922
|
+
if (this.handler) this.handler.onMuzzleFlash(ent, weapon);
|
|
5870
5923
|
}
|
|
5871
5924
|
parseMuzzleFlash2() {
|
|
5872
5925
|
const ent = this.stream.readShort();
|
|
5873
5926
|
const weapon = this.stream.readByte();
|
|
5927
|
+
if (this.handler) this.handler.onMuzzleFlash2(ent, weapon);
|
|
5874
5928
|
}
|
|
5875
5929
|
parseTempEntity() {
|
|
5876
5930
|
const type = this.stream.readByte();
|
|
5877
5931
|
const pos = { x: 0, y: 0, z: 0 };
|
|
5878
5932
|
const pos2 = { x: 0, y: 0, z: 0 };
|
|
5879
5933
|
const dir = { x: 0, y: 0, z: 0 };
|
|
5934
|
+
let cnt;
|
|
5935
|
+
let color;
|
|
5936
|
+
let ent;
|
|
5937
|
+
let srcEnt;
|
|
5938
|
+
let destEnt;
|
|
5880
5939
|
switch (type) {
|
|
5881
5940
|
case TempEntity.BLOOD:
|
|
5882
5941
|
this.stream.readPos(pos);
|
|
@@ -5885,29 +5944,23 @@ var NetworkMessageParser = class {
|
|
|
5885
5944
|
case TempEntity.GUNSHOT:
|
|
5886
5945
|
case TempEntity.SPARKS:
|
|
5887
5946
|
case TempEntity.BULLET_SPARKS:
|
|
5888
|
-
this.stream.readPos(pos);
|
|
5889
|
-
this.stream.readDir(dir);
|
|
5890
|
-
break;
|
|
5891
5947
|
case TempEntity.SCREEN_SPARKS:
|
|
5892
5948
|
case TempEntity.SHIELD_SPARKS:
|
|
5893
|
-
this.stream.readPos(pos);
|
|
5894
|
-
this.stream.readDir(dir);
|
|
5895
|
-
break;
|
|
5896
5949
|
case TempEntity.SHOTGUN:
|
|
5897
5950
|
this.stream.readPos(pos);
|
|
5898
5951
|
this.stream.readDir(dir);
|
|
5899
5952
|
break;
|
|
5900
5953
|
case TempEntity.SPLASH:
|
|
5901
|
-
this.stream.readByte();
|
|
5954
|
+
cnt = this.stream.readByte();
|
|
5902
5955
|
this.stream.readPos(pos);
|
|
5903
5956
|
this.stream.readDir(dir);
|
|
5904
|
-
this.stream.readByte();
|
|
5957
|
+
color = this.stream.readByte();
|
|
5905
5958
|
break;
|
|
5906
5959
|
case TempEntity.LASER_SPARKS:
|
|
5907
|
-
this.stream.readByte();
|
|
5960
|
+
cnt = this.stream.readByte();
|
|
5908
5961
|
this.stream.readPos(pos);
|
|
5909
5962
|
this.stream.readDir(dir);
|
|
5910
|
-
this.stream.readByte();
|
|
5963
|
+
color = this.stream.readByte();
|
|
5911
5964
|
break;
|
|
5912
5965
|
case TempEntity.BLUEHYPERBLASTER:
|
|
5913
5966
|
this.stream.readPos(pos);
|
|
@@ -5924,21 +5977,13 @@ var NetworkMessageParser = class {
|
|
|
5924
5977
|
case TempEntity.EXPLOSION2:
|
|
5925
5978
|
case TempEntity.GRENADE_EXPLOSION:
|
|
5926
5979
|
case TempEntity.GRENADE_EXPLOSION_WATER:
|
|
5927
|
-
this.stream.readPos(pos);
|
|
5928
|
-
break;
|
|
5929
5980
|
case TempEntity.PLASMA_EXPLOSION:
|
|
5930
|
-
this.stream.readPos(pos);
|
|
5931
|
-
break;
|
|
5932
5981
|
case TempEntity.EXPLOSION1:
|
|
5933
5982
|
case TempEntity.EXPLOSION1_BIG:
|
|
5934
5983
|
case TempEntity.ROCKET_EXPLOSION:
|
|
5935
5984
|
case TempEntity.ROCKET_EXPLOSION_WATER:
|
|
5936
5985
|
case TempEntity.EXPLOSION1_NP:
|
|
5937
|
-
this.stream.readPos(pos);
|
|
5938
|
-
break;
|
|
5939
5986
|
case TempEntity.BFG_EXPLOSION:
|
|
5940
|
-
this.stream.readPos(pos);
|
|
5941
|
-
break;
|
|
5942
5987
|
case TempEntity.BFG_BIGEXPLOSION:
|
|
5943
5988
|
this.stream.readPos(pos);
|
|
5944
5989
|
break;
|
|
@@ -5952,7 +5997,7 @@ var NetworkMessageParser = class {
|
|
|
5952
5997
|
break;
|
|
5953
5998
|
case TempEntity.PARASITE_ATTACK:
|
|
5954
5999
|
case TempEntity.MEDIC_CABLE_ATTACK:
|
|
5955
|
-
this.stream.readShort();
|
|
6000
|
+
ent = this.stream.readShort();
|
|
5956
6001
|
this.stream.readPos(pos);
|
|
5957
6002
|
this.stream.readPos(pos2);
|
|
5958
6003
|
break;
|
|
@@ -5960,26 +6005,26 @@ var NetworkMessageParser = class {
|
|
|
5960
6005
|
this.stream.readPos(pos);
|
|
5961
6006
|
break;
|
|
5962
6007
|
case TempEntity.GRAPPLE_CABLE:
|
|
5963
|
-
this.stream.readShort();
|
|
6008
|
+
ent = this.stream.readShort();
|
|
5964
6009
|
this.stream.readPos(pos);
|
|
5965
6010
|
this.stream.readPos(pos2);
|
|
5966
6011
|
this.stream.readPos(dir);
|
|
5967
6012
|
break;
|
|
5968
6013
|
case TempEntity.WELDING_SPARKS:
|
|
5969
|
-
this.stream.readByte();
|
|
6014
|
+
cnt = this.stream.readByte();
|
|
5970
6015
|
this.stream.readPos(pos);
|
|
5971
6016
|
this.stream.readDir(dir);
|
|
5972
|
-
this.stream.readByte();
|
|
6017
|
+
color = this.stream.readByte();
|
|
5973
6018
|
break;
|
|
5974
6019
|
case TempEntity.GREENBLOOD:
|
|
5975
6020
|
this.stream.readPos(pos);
|
|
5976
6021
|
this.stream.readDir(dir);
|
|
5977
6022
|
break;
|
|
5978
6023
|
case TempEntity.TUNNEL_SPARKS:
|
|
5979
|
-
this.stream.readByte();
|
|
6024
|
+
cnt = this.stream.readByte();
|
|
5980
6025
|
this.stream.readPos(pos);
|
|
5981
6026
|
this.stream.readDir(dir);
|
|
5982
|
-
this.stream.readByte();
|
|
6027
|
+
color = this.stream.readByte();
|
|
5983
6028
|
break;
|
|
5984
6029
|
case TempEntity.BLASTER2:
|
|
5985
6030
|
case TempEntity.FLECHETTE:
|
|
@@ -5987,8 +6032,8 @@ var NetworkMessageParser = class {
|
|
|
5987
6032
|
this.stream.readDir(dir);
|
|
5988
6033
|
break;
|
|
5989
6034
|
case TempEntity.LIGHTNING:
|
|
5990
|
-
this.stream.readShort();
|
|
5991
|
-
this.stream.readShort();
|
|
6035
|
+
srcEnt = this.stream.readShort();
|
|
6036
|
+
destEnt = this.stream.readShort();
|
|
5992
6037
|
this.stream.readPos(pos);
|
|
5993
6038
|
this.stream.readPos(pos2);
|
|
5994
6039
|
break;
|
|
@@ -6001,29 +6046,26 @@ var NetworkMessageParser = class {
|
|
|
6001
6046
|
break;
|
|
6002
6047
|
case TempEntity.FLASHLIGHT:
|
|
6003
6048
|
this.stream.readPos(pos);
|
|
6004
|
-
this.stream.readShort();
|
|
6049
|
+
ent = this.stream.readShort();
|
|
6005
6050
|
break;
|
|
6006
6051
|
case TempEntity.FORCEWALL:
|
|
6007
6052
|
this.stream.readPos(pos);
|
|
6008
6053
|
this.stream.readPos(pos2);
|
|
6009
|
-
this.stream.readByte();
|
|
6054
|
+
color = this.stream.readByte();
|
|
6010
6055
|
break;
|
|
6011
6056
|
case TempEntity.HEATBEAM:
|
|
6012
|
-
this.stream.readShort();
|
|
6057
|
+
ent = this.stream.readShort();
|
|
6013
6058
|
this.stream.readPos(pos);
|
|
6014
6059
|
this.stream.readPos(pos2);
|
|
6015
6060
|
this.stream.readPos(dir);
|
|
6016
6061
|
break;
|
|
6017
6062
|
case TempEntity.MONSTER_HEATBEAM:
|
|
6018
|
-
this.stream.readShort();
|
|
6063
|
+
ent = this.stream.readShort();
|
|
6019
6064
|
this.stream.readPos(pos);
|
|
6020
6065
|
this.stream.readPos(pos2);
|
|
6021
6066
|
this.stream.readPos(dir);
|
|
6022
6067
|
break;
|
|
6023
6068
|
case TempEntity.HEATBEAM_SPARKS:
|
|
6024
|
-
this.stream.readPos(pos);
|
|
6025
|
-
this.stream.readDir(dir);
|
|
6026
|
-
break;
|
|
6027
6069
|
case TempEntity.HEATBEAM_STEAM:
|
|
6028
6070
|
this.stream.readPos(pos);
|
|
6029
6071
|
this.stream.readDir(dir);
|
|
@@ -6031,17 +6073,17 @@ var NetworkMessageParser = class {
|
|
|
6031
6073
|
case TempEntity.STEAM:
|
|
6032
6074
|
const steamId = this.stream.readShort();
|
|
6033
6075
|
if (steamId !== -1) {
|
|
6034
|
-
this.stream.readByte();
|
|
6076
|
+
cnt = this.stream.readByte();
|
|
6035
6077
|
this.stream.readPos(pos);
|
|
6036
6078
|
this.stream.readDir(dir);
|
|
6037
|
-
this.stream.readByte();
|
|
6079
|
+
color = this.stream.readByte();
|
|
6038
6080
|
this.stream.readShort();
|
|
6039
6081
|
this.stream.readLong();
|
|
6040
6082
|
} else {
|
|
6041
|
-
this.stream.readByte();
|
|
6083
|
+
cnt = this.stream.readByte();
|
|
6042
6084
|
this.stream.readPos(pos);
|
|
6043
6085
|
this.stream.readDir(dir);
|
|
6044
|
-
this.stream.readByte();
|
|
6086
|
+
color = this.stream.readByte();
|
|
6045
6087
|
this.stream.readShort();
|
|
6046
6088
|
}
|
|
6047
6089
|
break;
|
|
@@ -6068,7 +6110,7 @@ var NetworkMessageParser = class {
|
|
|
6068
6110
|
this.stream.readPos(pos);
|
|
6069
6111
|
break;
|
|
6070
6112
|
case TempEntity.WIDOWBEAMOUT:
|
|
6071
|
-
|
|
6113
|
+
this.stream.readShort();
|
|
6072
6114
|
this.stream.readPos(pos);
|
|
6073
6115
|
break;
|
|
6074
6116
|
case TempEntity.NUKEBLAST:
|
|
@@ -6081,97 +6123,139 @@ var NetworkMessageParser = class {
|
|
|
6081
6123
|
console.warn(`CL_ParseTEnt: bad type ${type}`);
|
|
6082
6124
|
break;
|
|
6083
6125
|
}
|
|
6126
|
+
if (this.handler) {
|
|
6127
|
+
this.handler.onTempEntity(type, pos, pos2, dir, cnt, color, ent, srcEnt, destEnt);
|
|
6128
|
+
}
|
|
6084
6129
|
}
|
|
6085
6130
|
parseSpawnBaseline() {
|
|
6086
6131
|
const bits = this.parseEntityBits();
|
|
6087
|
-
|
|
6132
|
+
const entity = createEmptyEntityState();
|
|
6133
|
+
this.parseDelta(createEmptyEntityState(), entity, bits.number, bits.bits);
|
|
6134
|
+
if (this.handler) {
|
|
6135
|
+
this.handler.onSpawnBaseline(entity);
|
|
6136
|
+
}
|
|
6088
6137
|
}
|
|
6089
6138
|
parseFrame() {
|
|
6090
6139
|
const serverFrame = this.stream.readLong();
|
|
6091
6140
|
const deltaFrame = this.stream.readLong();
|
|
6092
6141
|
const surpressCount = this.stream.readByte();
|
|
6093
6142
|
const areaBytes = this.stream.readByte();
|
|
6094
|
-
this.stream.readData(areaBytes);
|
|
6143
|
+
const areaBits = this.stream.readData(areaBytes);
|
|
6095
6144
|
const piCmd = this.stream.readByte();
|
|
6096
6145
|
if (piCmd !== ServerCommand.playerinfo) {
|
|
6097
6146
|
throw new Error(`Expected svc_playerinfo after svc_frame, got ${piCmd}`);
|
|
6098
6147
|
}
|
|
6099
|
-
this.parsePlayerState();
|
|
6148
|
+
const playerState = this.parsePlayerState();
|
|
6100
6149
|
const peCmd = this.stream.readByte();
|
|
6101
6150
|
if (peCmd !== ServerCommand.packetentities && peCmd !== ServerCommand.deltapacketentities) {
|
|
6102
6151
|
throw new Error(`Expected svc_packetentities after svc_playerinfo, got ${peCmd}`);
|
|
6103
6152
|
}
|
|
6104
|
-
|
|
6153
|
+
const isDelta = peCmd === ServerCommand.deltapacketentities;
|
|
6154
|
+
const entities = this.collectPacketEntities();
|
|
6155
|
+
if (this.handler) {
|
|
6156
|
+
this.handler.onFrame({
|
|
6157
|
+
serverFrame,
|
|
6158
|
+
deltaFrame,
|
|
6159
|
+
surpressCount,
|
|
6160
|
+
areaBytes,
|
|
6161
|
+
areaBits,
|
|
6162
|
+
playerState,
|
|
6163
|
+
packetEntities: {
|
|
6164
|
+
delta: isDelta,
|
|
6165
|
+
entities
|
|
6166
|
+
}
|
|
6167
|
+
});
|
|
6168
|
+
}
|
|
6105
6169
|
}
|
|
6106
6170
|
parsePlayerState() {
|
|
6171
|
+
const ps = createEmptyProtocolPlayerState();
|
|
6107
6172
|
const flags = this.stream.readShort();
|
|
6108
|
-
if (flags & 1) this.stream.readByte();
|
|
6173
|
+
if (flags & 1) ps.pm_type = this.stream.readByte();
|
|
6109
6174
|
if (flags & 2) {
|
|
6110
|
-
this.stream.readShort();
|
|
6111
|
-
this.stream.readShort();
|
|
6112
|
-
this.stream.readShort();
|
|
6175
|
+
ps.origin.x = this.stream.readShort() * 0.125;
|
|
6176
|
+
ps.origin.y = this.stream.readShort() * 0.125;
|
|
6177
|
+
ps.origin.z = this.stream.readShort() * 0.125;
|
|
6113
6178
|
}
|
|
6114
6179
|
if (flags & 4) {
|
|
6115
|
-
this.stream.readShort();
|
|
6116
|
-
this.stream.readShort();
|
|
6117
|
-
this.stream.readShort();
|
|
6180
|
+
ps.velocity.x = this.stream.readShort() * 0.125;
|
|
6181
|
+
ps.velocity.y = this.stream.readShort() * 0.125;
|
|
6182
|
+
ps.velocity.z = this.stream.readShort() * 0.125;
|
|
6118
6183
|
}
|
|
6119
|
-
if (flags & 8) this.stream.readByte();
|
|
6120
|
-
if (flags & 16) this.stream.readByte();
|
|
6121
|
-
if (flags & 32) this.stream.readShort();
|
|
6184
|
+
if (flags & 8) ps.pm_time = this.stream.readByte();
|
|
6185
|
+
if (flags & 16) ps.pm_flags = this.stream.readByte();
|
|
6186
|
+
if (flags & 32) ps.gravity = this.stream.readShort();
|
|
6122
6187
|
if (flags & 64) {
|
|
6123
|
-
this.stream.readShort();
|
|
6124
|
-
this.stream.readShort();
|
|
6125
|
-
this.stream.readShort();
|
|
6188
|
+
ps.delta_angles.x = this.stream.readShort() * (180 / 32768);
|
|
6189
|
+
ps.delta_angles.y = this.stream.readShort() * (180 / 32768);
|
|
6190
|
+
ps.delta_angles.z = this.stream.readShort() * (180 / 32768);
|
|
6126
6191
|
}
|
|
6127
6192
|
if (flags & 128) {
|
|
6128
|
-
this.stream.readChar();
|
|
6129
|
-
this.stream.readChar();
|
|
6130
|
-
this.stream.readChar();
|
|
6193
|
+
ps.viewoffset.x = this.stream.readChar() * 0.25;
|
|
6194
|
+
ps.viewoffset.y = this.stream.readChar() * 0.25;
|
|
6195
|
+
ps.viewoffset.z = this.stream.readChar() * 0.25;
|
|
6131
6196
|
}
|
|
6132
6197
|
if (flags & 256) {
|
|
6133
|
-
this.stream.readAngle16();
|
|
6134
|
-
this.stream.readAngle16();
|
|
6135
|
-
this.stream.readAngle16();
|
|
6198
|
+
ps.viewangles.x = this.stream.readAngle16();
|
|
6199
|
+
ps.viewangles.y = this.stream.readAngle16();
|
|
6200
|
+
ps.viewangles.z = this.stream.readAngle16();
|
|
6136
6201
|
}
|
|
6137
6202
|
if (flags & 512) {
|
|
6138
|
-
this.stream.readChar();
|
|
6139
|
-
this.stream.readChar();
|
|
6140
|
-
this.stream.readChar();
|
|
6203
|
+
ps.kick_angles.x = this.stream.readChar() * 0.25;
|
|
6204
|
+
ps.kick_angles.y = this.stream.readChar() * 0.25;
|
|
6205
|
+
ps.kick_angles.z = this.stream.readChar() * 0.25;
|
|
6141
6206
|
}
|
|
6142
|
-
if (flags & 4096) this.stream.readByte();
|
|
6207
|
+
if (flags & 4096) ps.gun_index = this.stream.readByte();
|
|
6143
6208
|
if (flags & 8192) {
|
|
6144
|
-
this.stream.readByte();
|
|
6145
|
-
this.stream.readChar();
|
|
6146
|
-
this.stream.readChar();
|
|
6147
|
-
this.stream.readChar();
|
|
6148
|
-
this.stream.readChar();
|
|
6149
|
-
this.stream.readChar();
|
|
6150
|
-
this.stream.readChar();
|
|
6209
|
+
ps.gun_frame = this.stream.readByte();
|
|
6210
|
+
ps.gun_offset.x = this.stream.readChar() * 0.25;
|
|
6211
|
+
ps.gun_offset.y = this.stream.readChar() * 0.25;
|
|
6212
|
+
ps.gun_offset.z = this.stream.readChar() * 0.25;
|
|
6213
|
+
ps.gun_angles.x = this.stream.readChar() * 0.25;
|
|
6214
|
+
ps.gun_angles.y = this.stream.readChar() * 0.25;
|
|
6215
|
+
ps.gun_angles.z = this.stream.readChar() * 0.25;
|
|
6151
6216
|
}
|
|
6152
6217
|
if (flags & 1024) {
|
|
6153
|
-
this.stream.readByte();
|
|
6154
|
-
this.stream.readByte();
|
|
6155
|
-
this.stream.readByte();
|
|
6156
|
-
this.stream.readByte();
|
|
6218
|
+
ps.blend[0] = this.stream.readByte();
|
|
6219
|
+
ps.blend[1] = this.stream.readByte();
|
|
6220
|
+
ps.blend[2] = this.stream.readByte();
|
|
6221
|
+
ps.blend[3] = this.stream.readByte();
|
|
6157
6222
|
}
|
|
6158
|
-
if (flags & 2048) this.stream.readByte();
|
|
6159
|
-
if (flags & 16384) this.stream.readByte();
|
|
6223
|
+
if (flags & 2048) ps.fov = this.stream.readByte();
|
|
6224
|
+
if (flags & 16384) ps.rdflags = this.stream.readByte();
|
|
6160
6225
|
const statbits = this.stream.readLong();
|
|
6161
6226
|
for (let i = 0; i < 32; i++) {
|
|
6162
6227
|
if (statbits & 1 << i) {
|
|
6163
|
-
this.stream.readShort();
|
|
6228
|
+
ps.stats[i] = this.stream.readShort();
|
|
6164
6229
|
}
|
|
6165
6230
|
}
|
|
6231
|
+
return ps;
|
|
6166
6232
|
}
|
|
6167
6233
|
parsePacketEntities(delta) {
|
|
6234
|
+
const entities = this.collectPacketEntities();
|
|
6235
|
+
if (this.handler) {
|
|
6236
|
+
this.handler.onFrame({
|
|
6237
|
+
serverFrame: 0,
|
|
6238
|
+
deltaFrame: 0,
|
|
6239
|
+
surpressCount: 0,
|
|
6240
|
+
areaBytes: 0,
|
|
6241
|
+
areaBits: new Uint8Array(),
|
|
6242
|
+
playerState: createEmptyProtocolPlayerState(),
|
|
6243
|
+
packetEntities: { delta, entities }
|
|
6244
|
+
});
|
|
6245
|
+
}
|
|
6246
|
+
}
|
|
6247
|
+
collectPacketEntities() {
|
|
6248
|
+
const entities = [];
|
|
6168
6249
|
while (true) {
|
|
6169
6250
|
const bits = this.parseEntityBits();
|
|
6170
6251
|
if (bits.number === 0) {
|
|
6171
6252
|
break;
|
|
6172
6253
|
}
|
|
6173
|
-
|
|
6254
|
+
const entity = createEmptyEntityState();
|
|
6255
|
+
this.parseDelta(createEmptyEntityState(), entity, bits.number, bits.bits);
|
|
6256
|
+
entities.push(entity);
|
|
6174
6257
|
}
|
|
6258
|
+
return entities;
|
|
6175
6259
|
}
|
|
6176
6260
|
parseEntityBits() {
|
|
6177
6261
|
let total = this.stream.readByte();
|
|
@@ -6215,6 +6299,7 @@ var NetworkMessageParser = class {
|
|
|
6215
6299
|
to.event = from.event;
|
|
6216
6300
|
to.solid = from.solid;
|
|
6217
6301
|
to.number = number;
|
|
6302
|
+
to.bits = bits;
|
|
6218
6303
|
if (bits & U_MODEL) to.modelindex = this.stream.readByte();
|
|
6219
6304
|
if (bits & U_MODEL2) to.modelindex2 = this.stream.readByte();
|
|
6220
6305
|
if (bits & U_MODEL3) to.modelindex3 = this.stream.readByte();
|
|
@@ -6279,6 +6364,9 @@ var DemoPlaybackController = class {
|
|
|
6279
6364
|
this.accumulatedTime = 0;
|
|
6280
6365
|
this.frameDuration = 100;
|
|
6281
6366
|
}
|
|
6367
|
+
setHandler(handler) {
|
|
6368
|
+
this.handler = handler;
|
|
6369
|
+
}
|
|
6282
6370
|
loadDemo(buffer) {
|
|
6283
6371
|
this.reader = new DemoReader(buffer);
|
|
6284
6372
|
this.state = 0 /* Stopped */;
|
|
@@ -6316,7 +6404,7 @@ var DemoPlaybackController = class {
|
|
|
6316
6404
|
this.state = 3 /* Finished */;
|
|
6317
6405
|
return;
|
|
6318
6406
|
}
|
|
6319
|
-
const parser = new NetworkMessageParser(block.data);
|
|
6407
|
+
const parser = new NetworkMessageParser(block.data, this.handler);
|
|
6320
6408
|
parser.parseMessage();
|
|
6321
6409
|
this.accumulatedTime -= this.frameDuration;
|
|
6322
6410
|
}
|
|
@@ -6413,6 +6501,29 @@ export {
|
|
|
6413
6501
|
Texture2D,
|
|
6414
6502
|
TextureCache,
|
|
6415
6503
|
TextureCubeMap,
|
|
6504
|
+
U_ANGLE1,
|
|
6505
|
+
U_ANGLE2,
|
|
6506
|
+
U_ANGLE3,
|
|
6507
|
+
U_EFFECTS16,
|
|
6508
|
+
U_EFFECTS8,
|
|
6509
|
+
U_EVENT,
|
|
6510
|
+
U_FRAME16,
|
|
6511
|
+
U_FRAME8,
|
|
6512
|
+
U_MODEL,
|
|
6513
|
+
U_MODEL2,
|
|
6514
|
+
U_MODEL3,
|
|
6515
|
+
U_MODEL4,
|
|
6516
|
+
U_OLDORIGIN,
|
|
6517
|
+
U_ORIGIN1,
|
|
6518
|
+
U_ORIGIN2,
|
|
6519
|
+
U_ORIGIN3,
|
|
6520
|
+
U_REMOVE,
|
|
6521
|
+
U_RENDERFX16,
|
|
6522
|
+
U_RENDERFX8,
|
|
6523
|
+
U_SKIN16,
|
|
6524
|
+
U_SKIN8,
|
|
6525
|
+
U_SOLID,
|
|
6526
|
+
U_SOUND,
|
|
6416
6527
|
VertexArray,
|
|
6417
6528
|
VertexBuffer,
|
|
6418
6529
|
VirtualFileSystem,
|
|
@@ -6432,6 +6543,8 @@ export {
|
|
|
6432
6543
|
createAnimationState,
|
|
6433
6544
|
createAudioGraph,
|
|
6434
6545
|
createBspSurfaces,
|
|
6546
|
+
createEmptyEntityState,
|
|
6547
|
+
createEmptyProtocolPlayerState,
|
|
6435
6548
|
createEngine,
|
|
6436
6549
|
createEngineRuntime,
|
|
6437
6550
|
createFaceLightmap,
|