quake2ts 0.0.232 → 0.0.233

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.
@@ -7037,10 +7037,12 @@ var NetworkMessageParser = class {
7037
7037
  if (this.handler && this.handler.onLevelRestart) this.handler.onLevelRestart();
7038
7038
  break;
7039
7039
  case ServerCommand.damage:
7040
+ this.parseDamage();
7040
7041
  break;
7041
7042
  case ServerCommand.locprint:
7042
7043
  break;
7043
7044
  case ServerCommand.fog:
7045
+ this.parseFog();
7044
7046
  break;
7045
7047
  case ServerCommand.waitingforplayers:
7046
7048
  if (this.handler && this.handler.onWaitingForPlayers) this.handler.onWaitingForPlayers();
@@ -7177,6 +7179,80 @@ var NetworkMessageParser = class {
7177
7179
  const weapon = this.stream.readShort();
7178
7180
  if (this.handler && this.handler.onMuzzleFlash3) this.handler.onMuzzleFlash3(ent, weapon);
7179
7181
  }
7182
+ parseFog() {
7183
+ let bits = this.stream.readByte();
7184
+ if (bits & 128) {
7185
+ const high = this.stream.readByte();
7186
+ bits |= high << 8;
7187
+ }
7188
+ const fog = {};
7189
+ if (bits & 1) {
7190
+ fog.density = this.stream.readFloat();
7191
+ fog.skyfactor = this.stream.readByte();
7192
+ }
7193
+ if (bits & 2) {
7194
+ fog.red = this.stream.readByte();
7195
+ }
7196
+ if (bits & 4) {
7197
+ fog.green = this.stream.readByte();
7198
+ }
7199
+ if (bits & 8) {
7200
+ fog.blue = this.stream.readByte();
7201
+ }
7202
+ if (bits & 16) {
7203
+ fog.time = this.stream.readShort();
7204
+ }
7205
+ if (bits & 32) {
7206
+ fog.hf_falloff = this.stream.readFloat();
7207
+ }
7208
+ if (bits & 64) {
7209
+ fog.hf_density = this.stream.readFloat();
7210
+ }
7211
+ if (bits & 256) {
7212
+ fog.hf_start_r = this.stream.readByte();
7213
+ }
7214
+ if (bits & 512) {
7215
+ fog.hf_start_g = this.stream.readByte();
7216
+ }
7217
+ if (bits & 1024) {
7218
+ fog.hf_start_b = this.stream.readByte();
7219
+ }
7220
+ if (bits & 2048) {
7221
+ fog.hf_start_dist = this.stream.readLong();
7222
+ }
7223
+ if (bits & 4096) {
7224
+ fog.hf_end_r = this.stream.readByte();
7225
+ }
7226
+ if (bits & 8192) {
7227
+ fog.hf_end_g = this.stream.readByte();
7228
+ }
7229
+ if (bits & 16384) {
7230
+ fog.hf_end_b = this.stream.readByte();
7231
+ }
7232
+ if (bits & 32768) {
7233
+ fog.hf_end_dist = this.stream.readLong();
7234
+ }
7235
+ if (this.handler && this.handler.onFog) {
7236
+ this.handler.onFog(fog);
7237
+ }
7238
+ }
7239
+ parseDamage() {
7240
+ const num = this.stream.readByte();
7241
+ const indicators = [];
7242
+ for (let i = 0; i < num; i++) {
7243
+ const encoded = this.stream.readByte();
7244
+ const dir = { x: 0, y: 0, z: 0 };
7245
+ this.stream.readDir(dir);
7246
+ const damage = encoded & 31;
7247
+ const health = (encoded & 32) !== 0;
7248
+ const armor = (encoded & 64) !== 0;
7249
+ const power = (encoded & 128) !== 0;
7250
+ indicators.push({ damage, health, armor, power, dir });
7251
+ }
7252
+ if (this.handler && this.handler.onDamage) {
7253
+ this.handler.onDamage(indicators);
7254
+ }
7255
+ }
7180
7256
  parseTempEntity() {
7181
7257
  const type = this.stream.readByte();
7182
7258
  const pos = { x: 0, y: 0, z: 0 };