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.
@@ -2999,10 +2999,12 @@ var NetworkMessageParser = class {
2999
2999
  if (this.handler && this.handler.onLevelRestart) this.handler.onLevelRestart();
3000
3000
  break;
3001
3001
  case ServerCommand.damage:
3002
+ this.parseDamage();
3002
3003
  break;
3003
3004
  case ServerCommand.locprint:
3004
3005
  break;
3005
3006
  case ServerCommand.fog:
3007
+ this.parseFog();
3006
3008
  break;
3007
3009
  case ServerCommand.waitingforplayers:
3008
3010
  if (this.handler && this.handler.onWaitingForPlayers) this.handler.onWaitingForPlayers();
@@ -3139,6 +3141,80 @@ var NetworkMessageParser = class {
3139
3141
  const weapon = this.stream.readShort();
3140
3142
  if (this.handler && this.handler.onMuzzleFlash3) this.handler.onMuzzleFlash3(ent, weapon);
3141
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
+ }
3142
3218
  parseTempEntity() {
3143
3219
  const type = this.stream.readByte();
3144
3220
  const pos = { x: 0, y: 0, z: 0 };
@@ -4569,6 +4645,16 @@ var ClientNetworkHandler = class {
4569
4645
  this.callbacks.onMuzzleFlash3(ent, weapon);
4570
4646
  }
4571
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
+ }
4572
4658
  // New Rerelease Handlers (Stubbed)
4573
4659
  onLevelRestart() {
4574
4660
  if (this.callbacks?.onLevelRestart) this.callbacks.onLevelRestart();