@quake2ts/client 0.0.753 → 0.0.756

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/dist/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { EngineHost, DemoPlaybackController, DemoRecorder, DynamicLightManager, Camera, U_REMOVE, createEmptyEntityState, applyEntityDelta, spawnMuzzleFlash, spawnSparks, spawnBlasterImpact, spawnRailTrail, spawnSteam, spawnSplash, spawnBfgExplosion, spawnExplosion, spawnBlood, spawnBulletImpact, NetworkMessageParser, PROTOCOL_VERSION_RERELEASE, PlaybackState, DemoValidator } from '@quake2ts/engine';
2
- import { PlayerButton, ConfigStringIndex, MAX_MODELS, MAX_SOUNDS, MAX_IMAGES, MAX_CLIENTS, DEFAULT_FORWARD_SPEED, DEFAULT_SIDE_SPEED, DEFAULT_UP_SPEED, DEFAULT_YAW_SPEED, DEFAULT_PITCH_SPEED, DEFAULT_MOUSE_SENSITIVITY, mouseDeltaToViewDelta, addViewAngles, CvarFlags, vectorToAngles, hasPmFlag, PmFlag, PlayerStat, angleVectors, RenderFx, CONTENTS_WATER, CONTENTS_SLIME, CONTENTS_LAVA, G_GetPowerupStat, PowerupId as PowerupId$1, ZERO_VEC3, dotVec3, WaterLevel, TempEntity, NetChan, CMD_BACKUP, BinaryWriter, ClientCommand, writeUserCommand, crc8, BinaryStream, NetworkMessageBuilder, EntityEffects, MZ_BLASTER, MZ_HYPERBLASTER, MZ_BFG, MZ_GRENADE, MZ_ROCKET, MZ_RAILGUN, MZ_CHAINGUN3, MZ_CHAINGUN2, MZ_CHAINGUN1, MZ_MACHINEGUN, MZ_SSHOTGUN, MZ_SHOTGUN, MZ_BLUEHYPERBLASTER, MZ_HEATBEAM, MZ_ETF_RIFLE, MZ_IONRIPPER, MZ_PHALANX } from '@quake2ts/shared';
2
+ import { PlayerButton, ConfigStringIndex, MAX_MODELS, MAX_SOUNDS, MAX_IMAGES, MAX_CLIENTS, DEFAULT_FORWARD_SPEED, DEFAULT_SIDE_SPEED, DEFAULT_UP_SPEED, DEFAULT_YAW_SPEED, DEFAULT_PITCH_SPEED, DEFAULT_MOUSE_SENSITIVITY, mouseDeltaToViewDelta, addViewAngles, NetChan, CvarFlags, vectorToAngles, hasPmFlag, PmFlag, PlayerStat, angleVectors, RenderFx, CONTENTS_WATER, CONTENTS_SLIME, CONTENTS_LAVA, G_GetPowerupStat, PowerupId as PowerupId$1, ZERO_VEC3, dotVec3, WaterLevel, TempEntity, CMD_BACKUP, BinaryWriter, ClientCommand, writeUserCommand, crc8, BinaryStream, NetworkMessageBuilder, EntityEffects, MZ_BLASTER, MZ_HYPERBLASTER, MZ_BFG, MZ_GRENADE, MZ_ROCKET, MZ_RAILGUN, MZ_CHAINGUN3, MZ_CHAINGUN2, MZ_CHAINGUN1, MZ_MACHINEGUN, MZ_SSHOTGUN, MZ_SHOTGUN, MZ_BLUEHYPERBLASTER, MZ_HEATBEAM, MZ_ETF_RIFLE, MZ_IONRIPPER, MZ_PHALANX } from '@quake2ts/shared';
3
3
  import { vec3, mat4 } from 'gl-matrix';
4
4
  import { ClientPrediction, ViewEffects, GetCGameAPI, interpolatePredictionState, defaultPredictionState } from '@quake2ts/cgame';
5
5
  export { ClientPrediction, ViewEffects, defaultPredictionState, interpolatePredictionState } from '@quake2ts/cgame';
@@ -572,7 +572,9 @@ function buildRenderableEntities(latestEntities, previousEntities, alpha, config
572
572
  }
573
573
  const camVec = cameraPosition ? vec3.fromValues(cameraPosition.x, cameraPosition.y, cameraPosition.z) : null;
574
574
  for (const ent of latestEntities) {
575
+ console.log(`Processing Entity: ${ent.number} (frame: ${ent.frame})`);
575
576
  const prev = prevMap.get(ent.number) ?? ent;
577
+ console.log(`Matched Previous: ${prev === ent ? "SAME AS CURRENT" : "FOUND PREVIOUS"} (frame: ${prev.frame})`);
576
578
  const modelIndex = ent.modelIndex ?? ent.modelindex;
577
579
  const skinNum = ent.skinNum ?? ent.skinnum;
578
580
  if (modelIndex === void 0) continue;
@@ -713,12 +715,15 @@ var ClientNetworkHandler = class {
713
715
  }
714
716
  }
715
717
  onSpawnBaseline(entity) {
716
- this.baselines.set(entity.number, structuredClone(entity));
718
+ this.baselines.set(entity.number, JSON.parse(JSON.stringify(entity)));
717
719
  }
718
720
  onFrame(frame) {
719
721
  if (this.latestFrame) {
720
722
  this.previousFrame = this.latestFrame;
721
- this.previousEntities = this.entities;
723
+ this.previousEntities = /* @__PURE__ */ new Map();
724
+ for (const [k, v] of this.entities) {
725
+ this.previousEntities.set(k, JSON.parse(JSON.stringify(v)));
726
+ }
722
727
  }
723
728
  this.latestFrame = frame;
724
729
  this.stats = [...frame.playerState.stats];
@@ -726,7 +731,7 @@ var ClientNetworkHandler = class {
726
731
  const newEntities = /* @__PURE__ */ new Map();
727
732
  if (packetEntities.delta) {
728
733
  for (const [num, ent] of this.entities) {
729
- newEntities.set(num, structuredClone(ent));
734
+ newEntities.set(num, JSON.parse(JSON.stringify(ent)));
730
735
  }
731
736
  }
732
737
  for (const partial of packetEntities.entities) {
@@ -743,7 +748,7 @@ var ClientNetworkHandler = class {
743
748
  } else {
744
749
  source = createEmptyEntityState();
745
750
  }
746
- const final = structuredClone(source);
751
+ const final = JSON.parse(JSON.stringify(source));
747
752
  applyEntityDelta(final, partial);
748
753
  newEntities.set(number, final);
749
754
  }
@@ -2529,7 +2534,6 @@ var MultiplayerConnection = class {
2529
2534
  this.baselines.set(entity.number, entity);
2530
2535
  }
2531
2536
  onStuffText(msg) {
2532
- console.log(`Server StuffText: ${msg}`);
2533
2537
  if (msg.startsWith("precache")) {
2534
2538
  this.finishLoading();
2535
2539
  }
@@ -4543,6 +4547,12 @@ function createClient(imports) {
4543
4547
  chatManager.addMessage(0, msg);
4544
4548
  });
4545
4549
  const cg = GetCGameAPI(cgameImport);
4550
+ let netchan;
4551
+ const qportCvar = imports.host?.cvars?.get("net_qport");
4552
+ if (qportCvar && !isNaN(qportCvar.number)) {
4553
+ netchan = new NetChan();
4554
+ netchan.setup(qportCvar.number);
4555
+ }
4546
4556
  const multiplayer = new MultiplayerConnection({
4547
4557
  get username() {
4548
4558
  return imports.host?.cvars?.get("name")?.string || "Player";
@@ -4555,7 +4565,8 @@ function createClient(imports) {
4555
4565
  },
4556
4566
  get fov() {
4557
4567
  return fovValue;
4558
- }
4568
+ },
4569
+ netchan
4559
4570
  });
4560
4571
  multiplayer.setDemoRecorder(demoRecorder);
4561
4572
  multiplayer.setEffectSystem(effectSystem);