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
|
@@ -93,6 +93,29 @@ __export(index_exports, {
|
|
|
93
93
|
Texture2D: () => Texture2D,
|
|
94
94
|
TextureCache: () => TextureCache,
|
|
95
95
|
TextureCubeMap: () => TextureCubeMap,
|
|
96
|
+
U_ANGLE1: () => U_ANGLE1,
|
|
97
|
+
U_ANGLE2: () => U_ANGLE2,
|
|
98
|
+
U_ANGLE3: () => U_ANGLE3,
|
|
99
|
+
U_EFFECTS16: () => U_EFFECTS16,
|
|
100
|
+
U_EFFECTS8: () => U_EFFECTS8,
|
|
101
|
+
U_EVENT: () => U_EVENT,
|
|
102
|
+
U_FRAME16: () => U_FRAME16,
|
|
103
|
+
U_FRAME8: () => U_FRAME8,
|
|
104
|
+
U_MODEL: () => U_MODEL,
|
|
105
|
+
U_MODEL2: () => U_MODEL2,
|
|
106
|
+
U_MODEL3: () => U_MODEL3,
|
|
107
|
+
U_MODEL4: () => U_MODEL4,
|
|
108
|
+
U_OLDORIGIN: () => U_OLDORIGIN,
|
|
109
|
+
U_ORIGIN1: () => U_ORIGIN1,
|
|
110
|
+
U_ORIGIN2: () => U_ORIGIN2,
|
|
111
|
+
U_ORIGIN3: () => U_ORIGIN3,
|
|
112
|
+
U_REMOVE: () => U_REMOVE,
|
|
113
|
+
U_RENDERFX16: () => U_RENDERFX16,
|
|
114
|
+
U_RENDERFX8: () => U_RENDERFX8,
|
|
115
|
+
U_SKIN16: () => U_SKIN16,
|
|
116
|
+
U_SKIN8: () => U_SKIN8,
|
|
117
|
+
U_SOLID: () => U_SOLID,
|
|
118
|
+
U_SOUND: () => U_SOUND,
|
|
96
119
|
VertexArray: () => VertexArray,
|
|
97
120
|
VertexBuffer: () => VertexBuffer,
|
|
98
121
|
VirtualFileSystem: () => VirtualFileSystem,
|
|
@@ -112,6 +135,8 @@ __export(index_exports, {
|
|
|
112
135
|
createAnimationState: () => createAnimationState,
|
|
113
136
|
createAudioGraph: () => createAudioGraph,
|
|
114
137
|
createBspSurfaces: () => createBspSurfaces,
|
|
138
|
+
createEmptyEntityState: () => createEmptyEntityState,
|
|
139
|
+
createEmptyProtocolPlayerState: () => createEmptyProtocolPlayerState,
|
|
115
140
|
createEngine: () => createEngine,
|
|
116
141
|
createEngineRuntime: () => createEngineRuntime,
|
|
117
142
|
createFaceLightmap: () => createFaceLightmap,
|
|
@@ -5896,11 +5921,33 @@ var createEmptyEntityState = () => ({
|
|
|
5896
5921
|
angles: { x: 0, y: 0, z: 0 },
|
|
5897
5922
|
sound: 0,
|
|
5898
5923
|
event: 0,
|
|
5899
|
-
solid: 0
|
|
5924
|
+
solid: 0,
|
|
5925
|
+
bits: 0
|
|
5926
|
+
});
|
|
5927
|
+
var createEmptyProtocolPlayerState = () => ({
|
|
5928
|
+
pm_type: 0,
|
|
5929
|
+
origin: { x: 0, y: 0, z: 0 },
|
|
5930
|
+
velocity: { x: 0, y: 0, z: 0 },
|
|
5931
|
+
pm_time: 0,
|
|
5932
|
+
pm_flags: 0,
|
|
5933
|
+
gravity: 0,
|
|
5934
|
+
delta_angles: { x: 0, y: 0, z: 0 },
|
|
5935
|
+
viewoffset: { x: 0, y: 0, z: 0 },
|
|
5936
|
+
viewangles: { x: 0, y: 0, z: 0 },
|
|
5937
|
+
kick_angles: { x: 0, y: 0, z: 0 },
|
|
5938
|
+
gun_index: 0,
|
|
5939
|
+
gun_frame: 0,
|
|
5940
|
+
gun_offset: { x: 0, y: 0, z: 0 },
|
|
5941
|
+
gun_angles: { x: 0, y: 0, z: 0 },
|
|
5942
|
+
blend: [0, 0, 0, 0],
|
|
5943
|
+
fov: 0,
|
|
5944
|
+
rdflags: 0,
|
|
5945
|
+
stats: new Array(32).fill(0)
|
|
5900
5946
|
});
|
|
5901
5947
|
var NetworkMessageParser = class {
|
|
5902
|
-
constructor(stream) {
|
|
5948
|
+
constructor(stream, handler) {
|
|
5903
5949
|
this.stream = stream;
|
|
5950
|
+
this.handler = handler;
|
|
5904
5951
|
}
|
|
5905
5952
|
parseMessage() {
|
|
5906
5953
|
while (this.stream.hasMore()) {
|
|
@@ -5912,15 +5959,18 @@ var NetworkMessageParser = class {
|
|
|
5912
5959
|
case ServerCommand.nop:
|
|
5913
5960
|
break;
|
|
5914
5961
|
case ServerCommand.disconnect:
|
|
5915
|
-
|
|
5962
|
+
if (this.handler) this.handler.onDisconnect();
|
|
5963
|
+
else console.log("Server disconnected");
|
|
5916
5964
|
break;
|
|
5917
5965
|
case ServerCommand.reconnect:
|
|
5918
|
-
|
|
5966
|
+
if (this.handler) this.handler.onReconnect();
|
|
5967
|
+
else console.log("Server reconnect");
|
|
5919
5968
|
break;
|
|
5920
5969
|
case ServerCommand.print:
|
|
5921
5970
|
const printId = this.stream.readByte();
|
|
5922
5971
|
const printMsg = this.stream.readString();
|
|
5923
|
-
|
|
5972
|
+
if (this.handler) this.handler.onPrint(printId, printMsg);
|
|
5973
|
+
else console.log(`[Server Print ${printId}]: ${printMsg}`);
|
|
5924
5974
|
break;
|
|
5925
5975
|
case ServerCommand.serverdata:
|
|
5926
5976
|
this.parseServerData();
|
|
@@ -5933,7 +5983,8 @@ var NetworkMessageParser = class {
|
|
|
5933
5983
|
break;
|
|
5934
5984
|
case ServerCommand.centerprint:
|
|
5935
5985
|
const centerMsg = this.stream.readString();
|
|
5936
|
-
|
|
5986
|
+
if (this.handler) this.handler.onCenterPrint(centerMsg);
|
|
5987
|
+
else console.log(`[Center Print]: ${centerMsg}`);
|
|
5937
5988
|
break;
|
|
5938
5989
|
case ServerCommand.download:
|
|
5939
5990
|
this.parseDownload();
|
|
@@ -5949,10 +6000,12 @@ var NetworkMessageParser = class {
|
|
|
5949
6000
|
break;
|
|
5950
6001
|
case ServerCommand.stufftext:
|
|
5951
6002
|
const text = this.stream.readString();
|
|
5952
|
-
|
|
6003
|
+
if (this.handler) this.handler.onStuffText(text);
|
|
6004
|
+
else console.log(`[StuffText]: ${text}`);
|
|
5953
6005
|
break;
|
|
5954
6006
|
case ServerCommand.layout:
|
|
5955
6007
|
const layout = this.stream.readString();
|
|
6008
|
+
if (this.handler) this.handler.onLayout(layout);
|
|
5956
6009
|
break;
|
|
5957
6010
|
case ServerCommand.inventory:
|
|
5958
6011
|
this.parseInventory();
|
|
@@ -5982,58 +6035,89 @@ var NetworkMessageParser = class {
|
|
|
5982
6035
|
const gameDir = this.stream.readString();
|
|
5983
6036
|
const playerNum = this.stream.readShort();
|
|
5984
6037
|
const levelName = this.stream.readString();
|
|
5985
|
-
|
|
6038
|
+
if (this.handler) {
|
|
6039
|
+
this.handler.onServerData(protocol, serverCount, attractLoop, gameDir, playerNum, levelName);
|
|
6040
|
+
} else {
|
|
6041
|
+
console.log(`Server Data: Protocol ${protocol}, Level ${levelName}, GameDir ${gameDir}`);
|
|
6042
|
+
}
|
|
5986
6043
|
}
|
|
5987
6044
|
parseConfigString() {
|
|
5988
6045
|
const index = this.stream.readShort();
|
|
5989
6046
|
const str = this.stream.readString();
|
|
6047
|
+
if (this.handler) {
|
|
6048
|
+
this.handler.onConfigString(index, str);
|
|
6049
|
+
}
|
|
5990
6050
|
}
|
|
5991
6051
|
parseDownload() {
|
|
5992
6052
|
const size = this.stream.readShort();
|
|
5993
6053
|
const percent = this.stream.readByte();
|
|
6054
|
+
let data;
|
|
5994
6055
|
if (size > 0) {
|
|
5995
|
-
this.stream.readData(size);
|
|
6056
|
+
data = this.stream.readData(size);
|
|
6057
|
+
}
|
|
6058
|
+
if (this.handler) {
|
|
6059
|
+
this.handler.onDownload(size, percent, data);
|
|
5996
6060
|
}
|
|
5997
6061
|
}
|
|
5998
6062
|
parseInventory() {
|
|
5999
6063
|
const MAX_ITEMS2 = 256;
|
|
6064
|
+
const inventory = new Array(MAX_ITEMS2);
|
|
6000
6065
|
for (let i = 0; i < MAX_ITEMS2; i++) {
|
|
6001
|
-
this.stream.readShort();
|
|
6066
|
+
inventory[i] = this.stream.readShort();
|
|
6067
|
+
}
|
|
6068
|
+
if (this.handler) {
|
|
6069
|
+
this.handler.onInventory(inventory);
|
|
6002
6070
|
}
|
|
6003
6071
|
}
|
|
6004
6072
|
parseSound() {
|
|
6005
6073
|
const flags = this.stream.readByte();
|
|
6006
6074
|
const soundNum = this.stream.readByte();
|
|
6075
|
+
let volume;
|
|
6076
|
+
let attenuation;
|
|
6077
|
+
let offset;
|
|
6078
|
+
let ent;
|
|
6079
|
+
let pos;
|
|
6007
6080
|
if (flags & 1) {
|
|
6008
|
-
this.stream.readByte();
|
|
6081
|
+
volume = this.stream.readByte();
|
|
6009
6082
|
}
|
|
6010
6083
|
if (flags & 2) {
|
|
6011
|
-
this.stream.readByte();
|
|
6084
|
+
attenuation = this.stream.readByte();
|
|
6012
6085
|
}
|
|
6013
6086
|
if (flags & 16) {
|
|
6014
|
-
this.stream.readByte();
|
|
6087
|
+
offset = this.stream.readByte();
|
|
6015
6088
|
}
|
|
6016
6089
|
if (flags & 8) {
|
|
6017
|
-
this.stream.readShort();
|
|
6090
|
+
ent = this.stream.readShort();
|
|
6018
6091
|
}
|
|
6019
6092
|
if (flags & 4) {
|
|
6020
|
-
const
|
|
6021
|
-
this.stream.readPos(
|
|
6093
|
+
const p = { x: 0, y: 0, z: 0 };
|
|
6094
|
+
this.stream.readPos(p);
|
|
6095
|
+
pos = p;
|
|
6096
|
+
}
|
|
6097
|
+
if (this.handler) {
|
|
6098
|
+
this.handler.onSound(flags, soundNum, volume, attenuation, offset, ent, pos);
|
|
6022
6099
|
}
|
|
6023
6100
|
}
|
|
6024
6101
|
parseMuzzleFlash() {
|
|
6025
6102
|
const ent = this.stream.readShort();
|
|
6026
6103
|
const weapon = this.stream.readByte();
|
|
6104
|
+
if (this.handler) this.handler.onMuzzleFlash(ent, weapon);
|
|
6027
6105
|
}
|
|
6028
6106
|
parseMuzzleFlash2() {
|
|
6029
6107
|
const ent = this.stream.readShort();
|
|
6030
6108
|
const weapon = this.stream.readByte();
|
|
6109
|
+
if (this.handler) this.handler.onMuzzleFlash2(ent, weapon);
|
|
6031
6110
|
}
|
|
6032
6111
|
parseTempEntity() {
|
|
6033
6112
|
const type = this.stream.readByte();
|
|
6034
6113
|
const pos = { x: 0, y: 0, z: 0 };
|
|
6035
6114
|
const pos2 = { x: 0, y: 0, z: 0 };
|
|
6036
6115
|
const dir = { x: 0, y: 0, z: 0 };
|
|
6116
|
+
let cnt;
|
|
6117
|
+
let color;
|
|
6118
|
+
let ent;
|
|
6119
|
+
let srcEnt;
|
|
6120
|
+
let destEnt;
|
|
6037
6121
|
switch (type) {
|
|
6038
6122
|
case TempEntity.BLOOD:
|
|
6039
6123
|
this.stream.readPos(pos);
|
|
@@ -6042,29 +6126,23 @@ var NetworkMessageParser = class {
|
|
|
6042
6126
|
case TempEntity.GUNSHOT:
|
|
6043
6127
|
case TempEntity.SPARKS:
|
|
6044
6128
|
case TempEntity.BULLET_SPARKS:
|
|
6045
|
-
this.stream.readPos(pos);
|
|
6046
|
-
this.stream.readDir(dir);
|
|
6047
|
-
break;
|
|
6048
6129
|
case TempEntity.SCREEN_SPARKS:
|
|
6049
6130
|
case TempEntity.SHIELD_SPARKS:
|
|
6050
|
-
this.stream.readPos(pos);
|
|
6051
|
-
this.stream.readDir(dir);
|
|
6052
|
-
break;
|
|
6053
6131
|
case TempEntity.SHOTGUN:
|
|
6054
6132
|
this.stream.readPos(pos);
|
|
6055
6133
|
this.stream.readDir(dir);
|
|
6056
6134
|
break;
|
|
6057
6135
|
case TempEntity.SPLASH:
|
|
6058
|
-
this.stream.readByte();
|
|
6136
|
+
cnt = this.stream.readByte();
|
|
6059
6137
|
this.stream.readPos(pos);
|
|
6060
6138
|
this.stream.readDir(dir);
|
|
6061
|
-
this.stream.readByte();
|
|
6139
|
+
color = this.stream.readByte();
|
|
6062
6140
|
break;
|
|
6063
6141
|
case TempEntity.LASER_SPARKS:
|
|
6064
|
-
this.stream.readByte();
|
|
6142
|
+
cnt = this.stream.readByte();
|
|
6065
6143
|
this.stream.readPos(pos);
|
|
6066
6144
|
this.stream.readDir(dir);
|
|
6067
|
-
this.stream.readByte();
|
|
6145
|
+
color = this.stream.readByte();
|
|
6068
6146
|
break;
|
|
6069
6147
|
case TempEntity.BLUEHYPERBLASTER:
|
|
6070
6148
|
this.stream.readPos(pos);
|
|
@@ -6081,21 +6159,13 @@ var NetworkMessageParser = class {
|
|
|
6081
6159
|
case TempEntity.EXPLOSION2:
|
|
6082
6160
|
case TempEntity.GRENADE_EXPLOSION:
|
|
6083
6161
|
case TempEntity.GRENADE_EXPLOSION_WATER:
|
|
6084
|
-
this.stream.readPos(pos);
|
|
6085
|
-
break;
|
|
6086
6162
|
case TempEntity.PLASMA_EXPLOSION:
|
|
6087
|
-
this.stream.readPos(pos);
|
|
6088
|
-
break;
|
|
6089
6163
|
case TempEntity.EXPLOSION1:
|
|
6090
6164
|
case TempEntity.EXPLOSION1_BIG:
|
|
6091
6165
|
case TempEntity.ROCKET_EXPLOSION:
|
|
6092
6166
|
case TempEntity.ROCKET_EXPLOSION_WATER:
|
|
6093
6167
|
case TempEntity.EXPLOSION1_NP:
|
|
6094
|
-
this.stream.readPos(pos);
|
|
6095
|
-
break;
|
|
6096
6168
|
case TempEntity.BFG_EXPLOSION:
|
|
6097
|
-
this.stream.readPos(pos);
|
|
6098
|
-
break;
|
|
6099
6169
|
case TempEntity.BFG_BIGEXPLOSION:
|
|
6100
6170
|
this.stream.readPos(pos);
|
|
6101
6171
|
break;
|
|
@@ -6109,7 +6179,7 @@ var NetworkMessageParser = class {
|
|
|
6109
6179
|
break;
|
|
6110
6180
|
case TempEntity.PARASITE_ATTACK:
|
|
6111
6181
|
case TempEntity.MEDIC_CABLE_ATTACK:
|
|
6112
|
-
this.stream.readShort();
|
|
6182
|
+
ent = this.stream.readShort();
|
|
6113
6183
|
this.stream.readPos(pos);
|
|
6114
6184
|
this.stream.readPos(pos2);
|
|
6115
6185
|
break;
|
|
@@ -6117,26 +6187,26 @@ var NetworkMessageParser = class {
|
|
|
6117
6187
|
this.stream.readPos(pos);
|
|
6118
6188
|
break;
|
|
6119
6189
|
case TempEntity.GRAPPLE_CABLE:
|
|
6120
|
-
this.stream.readShort();
|
|
6190
|
+
ent = this.stream.readShort();
|
|
6121
6191
|
this.stream.readPos(pos);
|
|
6122
6192
|
this.stream.readPos(pos2);
|
|
6123
6193
|
this.stream.readPos(dir);
|
|
6124
6194
|
break;
|
|
6125
6195
|
case TempEntity.WELDING_SPARKS:
|
|
6126
|
-
this.stream.readByte();
|
|
6196
|
+
cnt = this.stream.readByte();
|
|
6127
6197
|
this.stream.readPos(pos);
|
|
6128
6198
|
this.stream.readDir(dir);
|
|
6129
|
-
this.stream.readByte();
|
|
6199
|
+
color = this.stream.readByte();
|
|
6130
6200
|
break;
|
|
6131
6201
|
case TempEntity.GREENBLOOD:
|
|
6132
6202
|
this.stream.readPos(pos);
|
|
6133
6203
|
this.stream.readDir(dir);
|
|
6134
6204
|
break;
|
|
6135
6205
|
case TempEntity.TUNNEL_SPARKS:
|
|
6136
|
-
this.stream.readByte();
|
|
6206
|
+
cnt = this.stream.readByte();
|
|
6137
6207
|
this.stream.readPos(pos);
|
|
6138
6208
|
this.stream.readDir(dir);
|
|
6139
|
-
this.stream.readByte();
|
|
6209
|
+
color = this.stream.readByte();
|
|
6140
6210
|
break;
|
|
6141
6211
|
case TempEntity.BLASTER2:
|
|
6142
6212
|
case TempEntity.FLECHETTE:
|
|
@@ -6144,8 +6214,8 @@ var NetworkMessageParser = class {
|
|
|
6144
6214
|
this.stream.readDir(dir);
|
|
6145
6215
|
break;
|
|
6146
6216
|
case TempEntity.LIGHTNING:
|
|
6147
|
-
this.stream.readShort();
|
|
6148
|
-
this.stream.readShort();
|
|
6217
|
+
srcEnt = this.stream.readShort();
|
|
6218
|
+
destEnt = this.stream.readShort();
|
|
6149
6219
|
this.stream.readPos(pos);
|
|
6150
6220
|
this.stream.readPos(pos2);
|
|
6151
6221
|
break;
|
|
@@ -6158,29 +6228,26 @@ var NetworkMessageParser = class {
|
|
|
6158
6228
|
break;
|
|
6159
6229
|
case TempEntity.FLASHLIGHT:
|
|
6160
6230
|
this.stream.readPos(pos);
|
|
6161
|
-
this.stream.readShort();
|
|
6231
|
+
ent = this.stream.readShort();
|
|
6162
6232
|
break;
|
|
6163
6233
|
case TempEntity.FORCEWALL:
|
|
6164
6234
|
this.stream.readPos(pos);
|
|
6165
6235
|
this.stream.readPos(pos2);
|
|
6166
|
-
this.stream.readByte();
|
|
6236
|
+
color = this.stream.readByte();
|
|
6167
6237
|
break;
|
|
6168
6238
|
case TempEntity.HEATBEAM:
|
|
6169
|
-
this.stream.readShort();
|
|
6239
|
+
ent = this.stream.readShort();
|
|
6170
6240
|
this.stream.readPos(pos);
|
|
6171
6241
|
this.stream.readPos(pos2);
|
|
6172
6242
|
this.stream.readPos(dir);
|
|
6173
6243
|
break;
|
|
6174
6244
|
case TempEntity.MONSTER_HEATBEAM:
|
|
6175
|
-
this.stream.readShort();
|
|
6245
|
+
ent = this.stream.readShort();
|
|
6176
6246
|
this.stream.readPos(pos);
|
|
6177
6247
|
this.stream.readPos(pos2);
|
|
6178
6248
|
this.stream.readPos(dir);
|
|
6179
6249
|
break;
|
|
6180
6250
|
case TempEntity.HEATBEAM_SPARKS:
|
|
6181
|
-
this.stream.readPos(pos);
|
|
6182
|
-
this.stream.readDir(dir);
|
|
6183
|
-
break;
|
|
6184
6251
|
case TempEntity.HEATBEAM_STEAM:
|
|
6185
6252
|
this.stream.readPos(pos);
|
|
6186
6253
|
this.stream.readDir(dir);
|
|
@@ -6188,17 +6255,17 @@ var NetworkMessageParser = class {
|
|
|
6188
6255
|
case TempEntity.STEAM:
|
|
6189
6256
|
const steamId = this.stream.readShort();
|
|
6190
6257
|
if (steamId !== -1) {
|
|
6191
|
-
this.stream.readByte();
|
|
6258
|
+
cnt = this.stream.readByte();
|
|
6192
6259
|
this.stream.readPos(pos);
|
|
6193
6260
|
this.stream.readDir(dir);
|
|
6194
|
-
this.stream.readByte();
|
|
6261
|
+
color = this.stream.readByte();
|
|
6195
6262
|
this.stream.readShort();
|
|
6196
6263
|
this.stream.readLong();
|
|
6197
6264
|
} else {
|
|
6198
|
-
this.stream.readByte();
|
|
6265
|
+
cnt = this.stream.readByte();
|
|
6199
6266
|
this.stream.readPos(pos);
|
|
6200
6267
|
this.stream.readDir(dir);
|
|
6201
|
-
this.stream.readByte();
|
|
6268
|
+
color = this.stream.readByte();
|
|
6202
6269
|
this.stream.readShort();
|
|
6203
6270
|
}
|
|
6204
6271
|
break;
|
|
@@ -6225,7 +6292,7 @@ var NetworkMessageParser = class {
|
|
|
6225
6292
|
this.stream.readPos(pos);
|
|
6226
6293
|
break;
|
|
6227
6294
|
case TempEntity.WIDOWBEAMOUT:
|
|
6228
|
-
|
|
6295
|
+
this.stream.readShort();
|
|
6229
6296
|
this.stream.readPos(pos);
|
|
6230
6297
|
break;
|
|
6231
6298
|
case TempEntity.NUKEBLAST:
|
|
@@ -6238,97 +6305,139 @@ var NetworkMessageParser = class {
|
|
|
6238
6305
|
console.warn(`CL_ParseTEnt: bad type ${type}`);
|
|
6239
6306
|
break;
|
|
6240
6307
|
}
|
|
6308
|
+
if (this.handler) {
|
|
6309
|
+
this.handler.onTempEntity(type, pos, pos2, dir, cnt, color, ent, srcEnt, destEnt);
|
|
6310
|
+
}
|
|
6241
6311
|
}
|
|
6242
6312
|
parseSpawnBaseline() {
|
|
6243
6313
|
const bits = this.parseEntityBits();
|
|
6244
|
-
|
|
6314
|
+
const entity = createEmptyEntityState();
|
|
6315
|
+
this.parseDelta(createEmptyEntityState(), entity, bits.number, bits.bits);
|
|
6316
|
+
if (this.handler) {
|
|
6317
|
+
this.handler.onSpawnBaseline(entity);
|
|
6318
|
+
}
|
|
6245
6319
|
}
|
|
6246
6320
|
parseFrame() {
|
|
6247
6321
|
const serverFrame = this.stream.readLong();
|
|
6248
6322
|
const deltaFrame = this.stream.readLong();
|
|
6249
6323
|
const surpressCount = this.stream.readByte();
|
|
6250
6324
|
const areaBytes = this.stream.readByte();
|
|
6251
|
-
this.stream.readData(areaBytes);
|
|
6325
|
+
const areaBits = this.stream.readData(areaBytes);
|
|
6252
6326
|
const piCmd = this.stream.readByte();
|
|
6253
6327
|
if (piCmd !== ServerCommand.playerinfo) {
|
|
6254
6328
|
throw new Error(`Expected svc_playerinfo after svc_frame, got ${piCmd}`);
|
|
6255
6329
|
}
|
|
6256
|
-
this.parsePlayerState();
|
|
6330
|
+
const playerState = this.parsePlayerState();
|
|
6257
6331
|
const peCmd = this.stream.readByte();
|
|
6258
6332
|
if (peCmd !== ServerCommand.packetentities && peCmd !== ServerCommand.deltapacketentities) {
|
|
6259
6333
|
throw new Error(`Expected svc_packetentities after svc_playerinfo, got ${peCmd}`);
|
|
6260
6334
|
}
|
|
6261
|
-
|
|
6335
|
+
const isDelta = peCmd === ServerCommand.deltapacketentities;
|
|
6336
|
+
const entities = this.collectPacketEntities();
|
|
6337
|
+
if (this.handler) {
|
|
6338
|
+
this.handler.onFrame({
|
|
6339
|
+
serverFrame,
|
|
6340
|
+
deltaFrame,
|
|
6341
|
+
surpressCount,
|
|
6342
|
+
areaBytes,
|
|
6343
|
+
areaBits,
|
|
6344
|
+
playerState,
|
|
6345
|
+
packetEntities: {
|
|
6346
|
+
delta: isDelta,
|
|
6347
|
+
entities
|
|
6348
|
+
}
|
|
6349
|
+
});
|
|
6350
|
+
}
|
|
6262
6351
|
}
|
|
6263
6352
|
parsePlayerState() {
|
|
6353
|
+
const ps = createEmptyProtocolPlayerState();
|
|
6264
6354
|
const flags = this.stream.readShort();
|
|
6265
|
-
if (flags & 1) this.stream.readByte();
|
|
6355
|
+
if (flags & 1) ps.pm_type = this.stream.readByte();
|
|
6266
6356
|
if (flags & 2) {
|
|
6267
|
-
this.stream.readShort();
|
|
6268
|
-
this.stream.readShort();
|
|
6269
|
-
this.stream.readShort();
|
|
6357
|
+
ps.origin.x = this.stream.readShort() * 0.125;
|
|
6358
|
+
ps.origin.y = this.stream.readShort() * 0.125;
|
|
6359
|
+
ps.origin.z = this.stream.readShort() * 0.125;
|
|
6270
6360
|
}
|
|
6271
6361
|
if (flags & 4) {
|
|
6272
|
-
this.stream.readShort();
|
|
6273
|
-
this.stream.readShort();
|
|
6274
|
-
this.stream.readShort();
|
|
6362
|
+
ps.velocity.x = this.stream.readShort() * 0.125;
|
|
6363
|
+
ps.velocity.y = this.stream.readShort() * 0.125;
|
|
6364
|
+
ps.velocity.z = this.stream.readShort() * 0.125;
|
|
6275
6365
|
}
|
|
6276
|
-
if (flags & 8) this.stream.readByte();
|
|
6277
|
-
if (flags & 16) this.stream.readByte();
|
|
6278
|
-
if (flags & 32) this.stream.readShort();
|
|
6366
|
+
if (flags & 8) ps.pm_time = this.stream.readByte();
|
|
6367
|
+
if (flags & 16) ps.pm_flags = this.stream.readByte();
|
|
6368
|
+
if (flags & 32) ps.gravity = this.stream.readShort();
|
|
6279
6369
|
if (flags & 64) {
|
|
6280
|
-
this.stream.readShort();
|
|
6281
|
-
this.stream.readShort();
|
|
6282
|
-
this.stream.readShort();
|
|
6370
|
+
ps.delta_angles.x = this.stream.readShort() * (180 / 32768);
|
|
6371
|
+
ps.delta_angles.y = this.stream.readShort() * (180 / 32768);
|
|
6372
|
+
ps.delta_angles.z = this.stream.readShort() * (180 / 32768);
|
|
6283
6373
|
}
|
|
6284
6374
|
if (flags & 128) {
|
|
6285
|
-
this.stream.readChar();
|
|
6286
|
-
this.stream.readChar();
|
|
6287
|
-
this.stream.readChar();
|
|
6375
|
+
ps.viewoffset.x = this.stream.readChar() * 0.25;
|
|
6376
|
+
ps.viewoffset.y = this.stream.readChar() * 0.25;
|
|
6377
|
+
ps.viewoffset.z = this.stream.readChar() * 0.25;
|
|
6288
6378
|
}
|
|
6289
6379
|
if (flags & 256) {
|
|
6290
|
-
this.stream.readAngle16();
|
|
6291
|
-
this.stream.readAngle16();
|
|
6292
|
-
this.stream.readAngle16();
|
|
6380
|
+
ps.viewangles.x = this.stream.readAngle16();
|
|
6381
|
+
ps.viewangles.y = this.stream.readAngle16();
|
|
6382
|
+
ps.viewangles.z = this.stream.readAngle16();
|
|
6293
6383
|
}
|
|
6294
6384
|
if (flags & 512) {
|
|
6295
|
-
this.stream.readChar();
|
|
6296
|
-
this.stream.readChar();
|
|
6297
|
-
this.stream.readChar();
|
|
6385
|
+
ps.kick_angles.x = this.stream.readChar() * 0.25;
|
|
6386
|
+
ps.kick_angles.y = this.stream.readChar() * 0.25;
|
|
6387
|
+
ps.kick_angles.z = this.stream.readChar() * 0.25;
|
|
6298
6388
|
}
|
|
6299
|
-
if (flags & 4096) this.stream.readByte();
|
|
6389
|
+
if (flags & 4096) ps.gun_index = this.stream.readByte();
|
|
6300
6390
|
if (flags & 8192) {
|
|
6301
|
-
this.stream.readByte();
|
|
6302
|
-
this.stream.readChar();
|
|
6303
|
-
this.stream.readChar();
|
|
6304
|
-
this.stream.readChar();
|
|
6305
|
-
this.stream.readChar();
|
|
6306
|
-
this.stream.readChar();
|
|
6307
|
-
this.stream.readChar();
|
|
6391
|
+
ps.gun_frame = this.stream.readByte();
|
|
6392
|
+
ps.gun_offset.x = this.stream.readChar() * 0.25;
|
|
6393
|
+
ps.gun_offset.y = this.stream.readChar() * 0.25;
|
|
6394
|
+
ps.gun_offset.z = this.stream.readChar() * 0.25;
|
|
6395
|
+
ps.gun_angles.x = this.stream.readChar() * 0.25;
|
|
6396
|
+
ps.gun_angles.y = this.stream.readChar() * 0.25;
|
|
6397
|
+
ps.gun_angles.z = this.stream.readChar() * 0.25;
|
|
6308
6398
|
}
|
|
6309
6399
|
if (flags & 1024) {
|
|
6310
|
-
this.stream.readByte();
|
|
6311
|
-
this.stream.readByte();
|
|
6312
|
-
this.stream.readByte();
|
|
6313
|
-
this.stream.readByte();
|
|
6400
|
+
ps.blend[0] = this.stream.readByte();
|
|
6401
|
+
ps.blend[1] = this.stream.readByte();
|
|
6402
|
+
ps.blend[2] = this.stream.readByte();
|
|
6403
|
+
ps.blend[3] = this.stream.readByte();
|
|
6314
6404
|
}
|
|
6315
|
-
if (flags & 2048) this.stream.readByte();
|
|
6316
|
-
if (flags & 16384) this.stream.readByte();
|
|
6405
|
+
if (flags & 2048) ps.fov = this.stream.readByte();
|
|
6406
|
+
if (flags & 16384) ps.rdflags = this.stream.readByte();
|
|
6317
6407
|
const statbits = this.stream.readLong();
|
|
6318
6408
|
for (let i = 0; i < 32; i++) {
|
|
6319
6409
|
if (statbits & 1 << i) {
|
|
6320
|
-
this.stream.readShort();
|
|
6410
|
+
ps.stats[i] = this.stream.readShort();
|
|
6321
6411
|
}
|
|
6322
6412
|
}
|
|
6413
|
+
return ps;
|
|
6323
6414
|
}
|
|
6324
6415
|
parsePacketEntities(delta) {
|
|
6416
|
+
const entities = this.collectPacketEntities();
|
|
6417
|
+
if (this.handler) {
|
|
6418
|
+
this.handler.onFrame({
|
|
6419
|
+
serverFrame: 0,
|
|
6420
|
+
deltaFrame: 0,
|
|
6421
|
+
surpressCount: 0,
|
|
6422
|
+
areaBytes: 0,
|
|
6423
|
+
areaBits: new Uint8Array(),
|
|
6424
|
+
playerState: createEmptyProtocolPlayerState(),
|
|
6425
|
+
packetEntities: { delta, entities }
|
|
6426
|
+
});
|
|
6427
|
+
}
|
|
6428
|
+
}
|
|
6429
|
+
collectPacketEntities() {
|
|
6430
|
+
const entities = [];
|
|
6325
6431
|
while (true) {
|
|
6326
6432
|
const bits = this.parseEntityBits();
|
|
6327
6433
|
if (bits.number === 0) {
|
|
6328
6434
|
break;
|
|
6329
6435
|
}
|
|
6330
|
-
|
|
6436
|
+
const entity = createEmptyEntityState();
|
|
6437
|
+
this.parseDelta(createEmptyEntityState(), entity, bits.number, bits.bits);
|
|
6438
|
+
entities.push(entity);
|
|
6331
6439
|
}
|
|
6440
|
+
return entities;
|
|
6332
6441
|
}
|
|
6333
6442
|
parseEntityBits() {
|
|
6334
6443
|
let total = this.stream.readByte();
|
|
@@ -6372,6 +6481,7 @@ var NetworkMessageParser = class {
|
|
|
6372
6481
|
to.event = from.event;
|
|
6373
6482
|
to.solid = from.solid;
|
|
6374
6483
|
to.number = number;
|
|
6484
|
+
to.bits = bits;
|
|
6375
6485
|
if (bits & U_MODEL) to.modelindex = this.stream.readByte();
|
|
6376
6486
|
if (bits & U_MODEL2) to.modelindex2 = this.stream.readByte();
|
|
6377
6487
|
if (bits & U_MODEL3) to.modelindex3 = this.stream.readByte();
|
|
@@ -6436,6 +6546,9 @@ var DemoPlaybackController = class {
|
|
|
6436
6546
|
this.accumulatedTime = 0;
|
|
6437
6547
|
this.frameDuration = 100;
|
|
6438
6548
|
}
|
|
6549
|
+
setHandler(handler) {
|
|
6550
|
+
this.handler = handler;
|
|
6551
|
+
}
|
|
6439
6552
|
loadDemo(buffer) {
|
|
6440
6553
|
this.reader = new DemoReader(buffer);
|
|
6441
6554
|
this.state = 0 /* Stopped */;
|
|
@@ -6473,7 +6586,7 @@ var DemoPlaybackController = class {
|
|
|
6473
6586
|
this.state = 3 /* Finished */;
|
|
6474
6587
|
return;
|
|
6475
6588
|
}
|
|
6476
|
-
const parser = new NetworkMessageParser(block.data);
|
|
6589
|
+
const parser = new NetworkMessageParser(block.data, this.handler);
|
|
6477
6590
|
parser.parseMessage();
|
|
6478
6591
|
this.accumulatedTime -= this.frameDuration;
|
|
6479
6592
|
}
|
|
@@ -6571,6 +6684,29 @@ function createEngine(imports) {
|
|
|
6571
6684
|
Texture2D,
|
|
6572
6685
|
TextureCache,
|
|
6573
6686
|
TextureCubeMap,
|
|
6687
|
+
U_ANGLE1,
|
|
6688
|
+
U_ANGLE2,
|
|
6689
|
+
U_ANGLE3,
|
|
6690
|
+
U_EFFECTS16,
|
|
6691
|
+
U_EFFECTS8,
|
|
6692
|
+
U_EVENT,
|
|
6693
|
+
U_FRAME16,
|
|
6694
|
+
U_FRAME8,
|
|
6695
|
+
U_MODEL,
|
|
6696
|
+
U_MODEL2,
|
|
6697
|
+
U_MODEL3,
|
|
6698
|
+
U_MODEL4,
|
|
6699
|
+
U_OLDORIGIN,
|
|
6700
|
+
U_ORIGIN1,
|
|
6701
|
+
U_ORIGIN2,
|
|
6702
|
+
U_ORIGIN3,
|
|
6703
|
+
U_REMOVE,
|
|
6704
|
+
U_RENDERFX16,
|
|
6705
|
+
U_RENDERFX8,
|
|
6706
|
+
U_SKIN16,
|
|
6707
|
+
U_SKIN8,
|
|
6708
|
+
U_SOLID,
|
|
6709
|
+
U_SOUND,
|
|
6574
6710
|
VertexArray,
|
|
6575
6711
|
VertexBuffer,
|
|
6576
6712
|
VirtualFileSystem,
|
|
@@ -6590,6 +6726,8 @@ function createEngine(imports) {
|
|
|
6590
6726
|
createAnimationState,
|
|
6591
6727
|
createAudioGraph,
|
|
6592
6728
|
createBspSurfaces,
|
|
6729
|
+
createEmptyEntityState,
|
|
6730
|
+
createEmptyProtocolPlayerState,
|
|
6593
6731
|
createEngine,
|
|
6594
6732
|
createEngineRuntime,
|
|
6595
6733
|
createFaceLightmap,
|