quake2ts 0.0.173 → 0.0.175

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.
@@ -12916,6 +12916,45 @@ function createGame({ trace, pointcontents, multicast, unicast }, engine, option
12916
12916
  entities.beginFrame(startTimeMs / 1e3);
12917
12917
  entities.runFrame();
12918
12918
  };
12919
+ const runPlayerMove = (player, command) => {
12920
+ const pcmd = {
12921
+ forwardmove: command.forwardmove,
12922
+ sidemove: command.sidemove,
12923
+ upmove: command.upmove,
12924
+ buttons: command.buttons,
12925
+ msec: command.msec,
12926
+ angles: command.angles
12927
+ };
12928
+ const playerState = {
12929
+ origin: player.origin,
12930
+ velocity: player.velocity,
12931
+ onGround: false,
12932
+ // This will be calculated by pmove
12933
+ waterLevel: player.waterlevel,
12934
+ // Pass waterlevel
12935
+ mins: player.mins,
12936
+ maxs: player.maxs,
12937
+ damageAlpha: 0,
12938
+ damageIndicators: [],
12939
+ viewAngles: player.angles,
12940
+ blend: [0, 0, 0, 0]
12941
+ };
12942
+ const traceAdapter = (start, end) => {
12943
+ const result = trace(start, player.mins, player.maxs, end, player, 268435457);
12944
+ return {
12945
+ fraction: result.fraction,
12946
+ endpos: result.endpos,
12947
+ allsolid: result.allsolid,
12948
+ startsolid: result.startsolid,
12949
+ planeNormal: result.plane?.normal
12950
+ };
12951
+ };
12952
+ const pointContentsAdapter = (point) => pointcontents(point);
12953
+ const newState = applyPmove(playerState, pcmd, traceAdapter, pointContentsAdapter);
12954
+ player.origin = newState.origin;
12955
+ player.velocity = newState.velocity;
12956
+ player.angles = newState.viewAngles;
12957
+ };
12919
12958
  return {
12920
12959
  init(startTimeMs) {
12921
12960
  resetState(startTimeMs);
@@ -12955,45 +12994,14 @@ function createGame({ trace, pointcontents, multicast, unicast }, engine, option
12955
12994
  origin = { ...player.origin };
12956
12995
  return player;
12957
12996
  },
12997
+ clientThink(ent, cmd) {
12998
+ runPlayerMove(ent, cmd);
12999
+ },
12958
13000
  frame(step, command) {
12959
13001
  const context = frameLoop.advance(step);
12960
13002
  const player = entities.find((e) => e.classname === "player");
12961
13003
  if (command && player) {
12962
- const pcmd = {
12963
- forwardmove: command.forwardmove,
12964
- sidemove: command.sidemove,
12965
- upmove: command.upmove,
12966
- buttons: command.buttons,
12967
- msec: command.msec,
12968
- angles: command.angles
12969
- };
12970
- const playerState = {
12971
- origin: player.origin,
12972
- velocity: player.velocity,
12973
- onGround: false,
12974
- waterLevel: 0,
12975
- mins: player.mins,
12976
- maxs: player.maxs,
12977
- damageAlpha: 0,
12978
- damageIndicators: [],
12979
- viewAngles: player.angles,
12980
- blend: [0, 0, 0, 0]
12981
- };
12982
- const traceAdapter = (start, end) => {
12983
- const result = trace(start, player.mins, player.maxs, end, player, 268435457);
12984
- return {
12985
- fraction: result.fraction,
12986
- endpos: result.endpos,
12987
- allsolid: result.allsolid,
12988
- startsolid: result.startsolid,
12989
- planeNormal: result.plane?.normal
12990
- };
12991
- };
12992
- const pointContentsAdapter = (point) => pointcontents(point);
12993
- const newState = applyPmove(playerState, pcmd, traceAdapter, pointContentsAdapter);
12994
- player.origin = newState.origin;
12995
- player.velocity = newState.velocity;
12996
- player.angles = newState.viewAngles;
13004
+ runPlayerMove(player, command);
12997
13005
  }
12998
13006
  return snapshot(context.frame);
12999
13007
  },
@@ -13015,6 +13023,7 @@ function createGame({ trace, pointcontents, multicast, unicast }, engine, option
13015
13023
  get time() {
13016
13024
  return levelClock.current.timeSeconds;
13017
13025
  },
13026
+ random: rng,
13018
13027
  createSave(mapName, difficulty, playtimeSeconds) {
13019
13028
  const player = entities.find((e) => e.classname === "player");
13020
13029
  return createSaveFile({