quake2ts 0.0.231 → 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.
@@ -2811,6 +2811,7 @@ var DemoReader = class {
2811
2811
  return this.offset;
2812
2812
  }
2813
2813
  };
2814
+ var PROTOCOL_VERSION_RERELEASE = 2023;
2814
2815
  var U_ORIGIN12 = 1 << 0;
2815
2816
  var U_ORIGIN22 = 1 << 1;
2816
2817
  var U_ANGLE22 = 1 << 2;
@@ -2913,6 +2914,9 @@ var NetworkMessageParser = class {
2913
2914
  if (cmd === 6) return ServerCommand.reconnect;
2914
2915
  if (cmd === 16) return ServerCommand.temp_entity;
2915
2916
  }
2917
+ if (this.protocolVersion === PROTOCOL_VERSION_RERELEASE) {
2918
+ return cmd;
2919
+ }
2916
2920
  return cmd;
2917
2921
  }
2918
2922
  parseMessage() {
@@ -2995,10 +2999,12 @@ var NetworkMessageParser = class {
2995
2999
  if (this.handler && this.handler.onLevelRestart) this.handler.onLevelRestart();
2996
3000
  break;
2997
3001
  case ServerCommand.damage:
3002
+ this.parseDamage();
2998
3003
  break;
2999
3004
  case ServerCommand.locprint:
3000
3005
  break;
3001
3006
  case ServerCommand.fog:
3007
+ this.parseFog();
3002
3008
  break;
3003
3009
  case ServerCommand.waitingforplayers:
3004
3010
  if (this.handler && this.handler.onWaitingForPlayers) this.handler.onWaitingForPlayers();
@@ -3135,6 +3141,80 @@ var NetworkMessageParser = class {
3135
3141
  const weapon = this.stream.readShort();
3136
3142
  if (this.handler && this.handler.onMuzzleFlash3) this.handler.onMuzzleFlash3(ent, weapon);
3137
3143
  }
3144
+ parseFog() {
3145
+ let bits = this.stream.readByte();
3146
+ if (bits & 128) {
3147
+ const high = this.stream.readByte();
3148
+ bits |= high << 8;
3149
+ }
3150
+ const fog = {};
3151
+ if (bits & 1) {
3152
+ fog.density = this.stream.readFloat();
3153
+ fog.skyfactor = this.stream.readByte();
3154
+ }
3155
+ if (bits & 2) {
3156
+ fog.red = this.stream.readByte();
3157
+ }
3158
+ if (bits & 4) {
3159
+ fog.green = this.stream.readByte();
3160
+ }
3161
+ if (bits & 8) {
3162
+ fog.blue = this.stream.readByte();
3163
+ }
3164
+ if (bits & 16) {
3165
+ fog.time = this.stream.readShort();
3166
+ }
3167
+ if (bits & 32) {
3168
+ fog.hf_falloff = this.stream.readFloat();
3169
+ }
3170
+ if (bits & 64) {
3171
+ fog.hf_density = this.stream.readFloat();
3172
+ }
3173
+ if (bits & 256) {
3174
+ fog.hf_start_r = this.stream.readByte();
3175
+ }
3176
+ if (bits & 512) {
3177
+ fog.hf_start_g = this.stream.readByte();
3178
+ }
3179
+ if (bits & 1024) {
3180
+ fog.hf_start_b = this.stream.readByte();
3181
+ }
3182
+ if (bits & 2048) {
3183
+ fog.hf_start_dist = this.stream.readLong();
3184
+ }
3185
+ if (bits & 4096) {
3186
+ fog.hf_end_r = this.stream.readByte();
3187
+ }
3188
+ if (bits & 8192) {
3189
+ fog.hf_end_g = this.stream.readByte();
3190
+ }
3191
+ if (bits & 16384) {
3192
+ fog.hf_end_b = this.stream.readByte();
3193
+ }
3194
+ if (bits & 32768) {
3195
+ fog.hf_end_dist = this.stream.readLong();
3196
+ }
3197
+ if (this.handler && this.handler.onFog) {
3198
+ this.handler.onFog(fog);
3199
+ }
3200
+ }
3201
+ parseDamage() {
3202
+ const num = this.stream.readByte();
3203
+ const indicators = [];
3204
+ for (let i = 0; i < num; i++) {
3205
+ const encoded = this.stream.readByte();
3206
+ const dir = { x: 0, y: 0, z: 0 };
3207
+ this.stream.readDir(dir);
3208
+ const damage = encoded & 31;
3209
+ const health = (encoded & 32) !== 0;
3210
+ const armor = (encoded & 64) !== 0;
3211
+ const power = (encoded & 128) !== 0;
3212
+ indicators.push({ damage, health, armor, power, dir });
3213
+ }
3214
+ if (this.handler && this.handler.onDamage) {
3215
+ this.handler.onDamage(indicators);
3216
+ }
3217
+ }
3138
3218
  parseTempEntity() {
3139
3219
  const type = this.stream.readByte();
3140
3220
  const pos = { x: 0, y: 0, z: 0 };
@@ -4565,6 +4645,16 @@ var ClientNetworkHandler = class {
4565
4645
  this.callbacks.onMuzzleFlash3(ent, weapon);
4566
4646
  }
4567
4647
  }
4648
+ onFog(data) {
4649
+ if (this.callbacks?.onFog) {
4650
+ this.callbacks.onFog(data);
4651
+ }
4652
+ }
4653
+ onDamage(indicators) {
4654
+ if (this.callbacks?.onDamage) {
4655
+ this.callbacks.onDamage(indicators);
4656
+ }
4657
+ }
4568
4658
  // New Rerelease Handlers (Stubbed)
4569
4659
  onLevelRestart() {
4570
4660
  if (this.callbacks?.onLevelRestart) this.callbacks.onLevelRestart();