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.
@@ -6850,10 +6850,12 @@ var NetworkMessageParser = class {
6850
6850
  if (this.handler && this.handler.onLevelRestart) this.handler.onLevelRestart();
6851
6851
  break;
6852
6852
  case ServerCommand.damage:
6853
+ this.parseDamage();
6853
6854
  break;
6854
6855
  case ServerCommand.locprint:
6855
6856
  break;
6856
6857
  case ServerCommand.fog:
6858
+ this.parseFog();
6857
6859
  break;
6858
6860
  case ServerCommand.waitingforplayers:
6859
6861
  if (this.handler && this.handler.onWaitingForPlayers) this.handler.onWaitingForPlayers();
@@ -6990,6 +6992,80 @@ var NetworkMessageParser = class {
6990
6992
  const weapon = this.stream.readShort();
6991
6993
  if (this.handler && this.handler.onMuzzleFlash3) this.handler.onMuzzleFlash3(ent, weapon);
6992
6994
  }
6995
+ parseFog() {
6996
+ let bits = this.stream.readByte();
6997
+ if (bits & 128) {
6998
+ const high = this.stream.readByte();
6999
+ bits |= high << 8;
7000
+ }
7001
+ const fog = {};
7002
+ if (bits & 1) {
7003
+ fog.density = this.stream.readFloat();
7004
+ fog.skyfactor = this.stream.readByte();
7005
+ }
7006
+ if (bits & 2) {
7007
+ fog.red = this.stream.readByte();
7008
+ }
7009
+ if (bits & 4) {
7010
+ fog.green = this.stream.readByte();
7011
+ }
7012
+ if (bits & 8) {
7013
+ fog.blue = this.stream.readByte();
7014
+ }
7015
+ if (bits & 16) {
7016
+ fog.time = this.stream.readShort();
7017
+ }
7018
+ if (bits & 32) {
7019
+ fog.hf_falloff = this.stream.readFloat();
7020
+ }
7021
+ if (bits & 64) {
7022
+ fog.hf_density = this.stream.readFloat();
7023
+ }
7024
+ if (bits & 256) {
7025
+ fog.hf_start_r = this.stream.readByte();
7026
+ }
7027
+ if (bits & 512) {
7028
+ fog.hf_start_g = this.stream.readByte();
7029
+ }
7030
+ if (bits & 1024) {
7031
+ fog.hf_start_b = this.stream.readByte();
7032
+ }
7033
+ if (bits & 2048) {
7034
+ fog.hf_start_dist = this.stream.readLong();
7035
+ }
7036
+ if (bits & 4096) {
7037
+ fog.hf_end_r = this.stream.readByte();
7038
+ }
7039
+ if (bits & 8192) {
7040
+ fog.hf_end_g = this.stream.readByte();
7041
+ }
7042
+ if (bits & 16384) {
7043
+ fog.hf_end_b = this.stream.readByte();
7044
+ }
7045
+ if (bits & 32768) {
7046
+ fog.hf_end_dist = this.stream.readLong();
7047
+ }
7048
+ if (this.handler && this.handler.onFog) {
7049
+ this.handler.onFog(fog);
7050
+ }
7051
+ }
7052
+ parseDamage() {
7053
+ const num = this.stream.readByte();
7054
+ const indicators = [];
7055
+ for (let i = 0; i < num; i++) {
7056
+ const encoded = this.stream.readByte();
7057
+ const dir = { x: 0, y: 0, z: 0 };
7058
+ this.stream.readDir(dir);
7059
+ const damage = encoded & 31;
7060
+ const health = (encoded & 32) !== 0;
7061
+ const armor = (encoded & 64) !== 0;
7062
+ const power = (encoded & 128) !== 0;
7063
+ indicators.push({ damage, health, armor, power, dir });
7064
+ }
7065
+ if (this.handler && this.handler.onDamage) {
7066
+ this.handler.onDamage(indicators);
7067
+ }
7068
+ }
6993
7069
  parseTempEntity() {
6994
7070
  const type = this.stream.readByte();
6995
7071
  const pos = { x: 0, y: 0, z: 0 };