quake2ts 0.0.297 → 0.0.299
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/package.json +1 -1
- package/packages/cgame/dist/index.cjs +55 -2
- package/packages/cgame/dist/index.cjs.map +1 -1
- package/packages/cgame/dist/index.d.cts +7 -0
- package/packages/cgame/dist/index.d.ts +7 -0
- package/packages/cgame/dist/index.js +56 -3
- package/packages/cgame/dist/index.js.map +1 -1
- package/packages/client/dist/browser/index.global.js +13 -13
- package/packages/client/dist/browser/index.global.js.map +1 -1
- package/packages/client/dist/cjs/index.cjs +76 -19
- package/packages/client/dist/cjs/index.cjs.map +1 -1
- package/packages/client/dist/esm/index.js +71 -14
- package/packages/client/dist/esm/index.js.map +1 -1
- package/packages/client/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/client/dist/types/cgameBridge.d.ts.map +1 -1
- package/packages/client/dist/types/input/controller.d.ts +1 -0
- package/packages/client/dist/types/input/controller.d.ts.map +1 -1
- package/packages/client/dist/types/net/connection.d.ts +3 -0
- package/packages/client/dist/types/net/connection.d.ts.map +1 -1
- package/packages/engine/dist/browser/index.global.js +8 -8
- package/packages/engine/dist/browser/index.global.js.map +1 -1
- package/packages/engine/dist/cjs/index.cjs.map +1 -1
- package/packages/engine/dist/esm/index.js.map +1 -1
- package/packages/engine/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/game/dist/browser/index.global.js +4 -4
- package/packages/game/dist/browser/index.global.js.map +1 -1
- package/packages/game/dist/cjs/index.cjs +67 -20
- package/packages/game/dist/cjs/index.cjs.map +1 -1
- package/packages/game/dist/esm/index.js +67 -20
- package/packages/game/dist/esm/index.js.map +1 -1
- package/packages/game/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/game/dist/types/ai/movement.d.ts.map +1 -1
- package/packages/server/dist/index.cjs +9 -2
- package/packages/server/dist/index.js +9 -2
- package/packages/shared/dist/browser/index.global.js +1 -1
- package/packages/shared/dist/browser/index.global.js.map +1 -1
- package/packages/shared/dist/cjs/index.cjs +1342 -1038
- package/packages/shared/dist/cjs/index.cjs.map +1 -1
- package/packages/shared/dist/esm/index.js +1340 -1038
- package/packages/shared/dist/esm/index.js.map +1 -1
- package/packages/shared/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/shared/dist/types/pmove/jump.d.ts +2 -0
- package/packages/shared/dist/types/pmove/jump.d.ts.map +1 -1
- package/packages/shared/dist/types/pmove/move.d.ts +20 -0
- package/packages/shared/dist/types/pmove/move.d.ts.map +1 -1
- package/packages/shared/dist/types/pmove/pmove.d.ts +5 -1
- package/packages/shared/dist/types/pmove/pmove.d.ts.map +1 -1
- package/packages/shared/dist/types/pmove/types.d.ts +25 -1
- package/packages/shared/dist/types/pmove/types.d.ts.map +1 -1
- package/packages/shared/dist/types/protocol/usercmd.d.ts +3 -0
- package/packages/shared/dist/types/protocol/usercmd.d.ts.map +1 -1
- package/packages/tools/dist/tsconfig.tsbuildinfo +1 -1
|
@@ -22,15 +22,15 @@ var index_exports = {};
|
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
ClientConfigStrings: () => ClientConfigStrings,
|
|
24
24
|
ClientMode: () => ClientMode,
|
|
25
|
-
ClientPrediction: () =>
|
|
25
|
+
ClientPrediction: () => import_cgame5.ClientPrediction,
|
|
26
26
|
InputAction: () => InputAction,
|
|
27
27
|
InputBindings: () => InputBindings,
|
|
28
28
|
InputCommandBuffer: () => InputCommandBuffer,
|
|
29
29
|
InputController: () => InputController,
|
|
30
|
-
ViewEffects: () =>
|
|
30
|
+
ViewEffects: () => import_cgame6.ViewEffects,
|
|
31
31
|
createClient: () => createClient,
|
|
32
32
|
createDefaultBindings: () => createDefaultBindings,
|
|
33
|
-
interpolatePredictionState: () =>
|
|
33
|
+
interpolatePredictionState: () => import_cgame5.interpolatePredictionState,
|
|
34
34
|
normalizeCommand: () => normalizeCommand,
|
|
35
35
|
normalizeInputCode: () => normalizeInputCode
|
|
36
36
|
});
|
|
@@ -8770,15 +8770,15 @@ var PmFlag = /* @__PURE__ */ ((PmFlag22) => {
|
|
|
8770
8770
|
function hasPmFlag(flags, flag) {
|
|
8771
8771
|
return (flags & flag) !== 0;
|
|
8772
8772
|
}
|
|
8773
|
-
var PlayerButton = /* @__PURE__ */ ((
|
|
8774
|
-
|
|
8775
|
-
|
|
8776
|
-
|
|
8777
|
-
|
|
8778
|
-
|
|
8779
|
-
|
|
8780
|
-
|
|
8781
|
-
return
|
|
8773
|
+
var PlayerButton = /* @__PURE__ */ ((PlayerButton3) => {
|
|
8774
|
+
PlayerButton3[PlayerButton3["None"] = 0] = "None";
|
|
8775
|
+
PlayerButton3[PlayerButton3["Attack"] = 1] = "Attack";
|
|
8776
|
+
PlayerButton3[PlayerButton3["Use"] = 2] = "Use";
|
|
8777
|
+
PlayerButton3[PlayerButton3["Holster"] = 4] = "Holster";
|
|
8778
|
+
PlayerButton3[PlayerButton3["Jump"] = 8] = "Jump";
|
|
8779
|
+
PlayerButton3[PlayerButton3["Crouch"] = 16] = "Crouch";
|
|
8780
|
+
PlayerButton3[PlayerButton3["Any"] = 128] = "Any";
|
|
8781
|
+
return PlayerButton3;
|
|
8782
8782
|
})(PlayerButton || {});
|
|
8783
8783
|
var WATERJUMP_CLEAR2 = 8 | 16 | 32 | 1024;
|
|
8784
8784
|
var DEFAULT_FORWARD_SPEED = 200;
|
|
@@ -9655,8 +9655,8 @@ var AmmoType2 = /* @__PURE__ */ ((AmmoType22) => {
|
|
|
9655
9655
|
var AMMO_TYPE_COUNT2 = Object.keys(AmmoType2).length / 2;
|
|
9656
9656
|
|
|
9657
9657
|
// src/index.ts
|
|
9658
|
-
var import_cgame2 = require("@quake2ts/cgame");
|
|
9659
9658
|
var import_cgame3 = require("@quake2ts/cgame");
|
|
9659
|
+
var import_cgame4 = require("@quake2ts/cgame");
|
|
9660
9660
|
|
|
9661
9661
|
// src/cgameBridge.ts
|
|
9662
9662
|
function createCGameImport(imports, state) {
|
|
@@ -9706,6 +9706,24 @@ function createCGameImport(imports, state) {
|
|
|
9706
9706
|
flags
|
|
9707
9707
|
});
|
|
9708
9708
|
},
|
|
9709
|
+
Cvar_Get: (name, value, flags) => {
|
|
9710
|
+
if (!imports.host || !imports.host.cvars) {
|
|
9711
|
+
return { value: parseInt(value) || 0 };
|
|
9712
|
+
}
|
|
9713
|
+
let existing = imports.host.cvars.get(name);
|
|
9714
|
+
if (!existing) {
|
|
9715
|
+
existing = imports.host.cvars.register({
|
|
9716
|
+
name,
|
|
9717
|
+
defaultValue: value,
|
|
9718
|
+
flags
|
|
9719
|
+
});
|
|
9720
|
+
}
|
|
9721
|
+
return {
|
|
9722
|
+
get value() {
|
|
9723
|
+
return existing.number;
|
|
9724
|
+
}
|
|
9725
|
+
};
|
|
9726
|
+
},
|
|
9709
9727
|
cvar_set: (name, value) => {
|
|
9710
9728
|
imports.host?.cvars?.setValue(name, value);
|
|
9711
9729
|
},
|
|
@@ -11643,6 +11661,7 @@ var BrowserWebSocketNetDriver = class {
|
|
|
11643
11661
|
};
|
|
11644
11662
|
|
|
11645
11663
|
// src/net/connection.ts
|
|
11664
|
+
var import_cgame2 = require("@quake2ts/cgame");
|
|
11646
11665
|
var MultiplayerConnection = class {
|
|
11647
11666
|
constructor(options) {
|
|
11648
11667
|
this.state = 0 /* Disconnected */;
|
|
@@ -11660,6 +11679,8 @@ var MultiplayerConnection = class {
|
|
|
11660
11679
|
this.connectPacketTime = 0;
|
|
11661
11680
|
this.latestServerFrame = 0;
|
|
11662
11681
|
this.commandHistory = [];
|
|
11682
|
+
// Prediction
|
|
11683
|
+
this.prediction = null;
|
|
11663
11684
|
this.driver = new BrowserWebSocketNetDriver();
|
|
11664
11685
|
this.options = options;
|
|
11665
11686
|
this.netchan = new NetChan();
|
|
@@ -11667,6 +11688,9 @@ var MultiplayerConnection = class {
|
|
|
11667
11688
|
this.driver.onClose(() => this.handleDisconnect());
|
|
11668
11689
|
this.driver.onError((err2) => console.error("Network Error:", err2));
|
|
11669
11690
|
}
|
|
11691
|
+
setPrediction(prediction) {
|
|
11692
|
+
this.prediction = prediction;
|
|
11693
|
+
}
|
|
11670
11694
|
async connect(url) {
|
|
11671
11695
|
if (this.state !== 0 /* Disconnected */) {
|
|
11672
11696
|
this.disconnect();
|
|
@@ -11704,6 +11728,9 @@ var MultiplayerConnection = class {
|
|
|
11704
11728
|
if (this.commandHistory.length > CMD_BACKUP) {
|
|
11705
11729
|
this.commandHistory.shift();
|
|
11706
11730
|
}
|
|
11731
|
+
if (this.prediction) {
|
|
11732
|
+
this.prediction.enqueueCommand(commandWithFrame);
|
|
11733
|
+
}
|
|
11707
11734
|
const writer = new BinaryWriter2();
|
|
11708
11735
|
writer.writeByte(ClientCommand.move);
|
|
11709
11736
|
writer.writeByte(0);
|
|
@@ -11801,6 +11828,31 @@ var MultiplayerConnection = class {
|
|
|
11801
11828
|
if (frame.serverFrame > this.latestServerFrame) {
|
|
11802
11829
|
this.latestServerFrame = frame.serverFrame;
|
|
11803
11830
|
}
|
|
11831
|
+
if (this.prediction && frame.playerState) {
|
|
11832
|
+
const ps = frame.playerState;
|
|
11833
|
+
const predState = {
|
|
11834
|
+
...(0, import_cgame2.defaultPredictionState)(),
|
|
11835
|
+
// Manual mapping due to type mismatch (MutableVec3 vs Vec3, and property names)
|
|
11836
|
+
origin: { x: ps.origin.x, y: ps.origin.y, z: ps.origin.z },
|
|
11837
|
+
velocity: { x: ps.velocity.x, y: ps.velocity.y, z: ps.velocity.z },
|
|
11838
|
+
viewAngles: { x: ps.viewangles.x, y: ps.viewangles.y, z: ps.viewangles.z },
|
|
11839
|
+
deltaAngles: { x: ps.delta_angles.x, y: ps.delta_angles.y, z: ps.delta_angles.z },
|
|
11840
|
+
pmFlags: ps.pm_flags,
|
|
11841
|
+
pmType: ps.pm_type,
|
|
11842
|
+
gravity: ps.gravity,
|
|
11843
|
+
// Copy other matching fields
|
|
11844
|
+
health: ps.stats[0]
|
|
11845
|
+
// Assuming stat 0 is health? Or generic copy
|
|
11846
|
+
// ...
|
|
11847
|
+
};
|
|
11848
|
+
const gameFrame = {
|
|
11849
|
+
frame: frame.serverFrame,
|
|
11850
|
+
timeMs: 0,
|
|
11851
|
+
// Should be server time, but frame doesn't always have it explicitly?
|
|
11852
|
+
state: predState
|
|
11853
|
+
};
|
|
11854
|
+
this.prediction.setAuthoritative(gameFrame);
|
|
11855
|
+
}
|
|
11804
11856
|
}
|
|
11805
11857
|
// Stubs for other handlers
|
|
11806
11858
|
onCenterPrint(msg) {
|
|
@@ -11992,6 +12044,7 @@ var InputController = class {
|
|
|
11992
12044
|
this.touchButtons = /* @__PURE__ */ new Map();
|
|
11993
12045
|
this.touchMove = { x: 0, y: 0 };
|
|
11994
12046
|
this.touchLook = { x: 0, y: 0 };
|
|
12047
|
+
this.sequence = 0;
|
|
11995
12048
|
this.bindings = bindings;
|
|
11996
12049
|
this.forwardSpeed = options.forwardSpeed ?? DEFAULT_FORWARD_SPEED;
|
|
11997
12050
|
this.sideSpeed = options.sideSpeed ?? DEFAULT_SIDE_SPEED;
|
|
@@ -12130,6 +12183,7 @@ var InputController = class {
|
|
|
12130
12183
|
buttons |= PlayerButton.Any;
|
|
12131
12184
|
}
|
|
12132
12185
|
this.anyPressed = false;
|
|
12186
|
+
this.sequence++;
|
|
12133
12187
|
return {
|
|
12134
12188
|
msec,
|
|
12135
12189
|
buttons,
|
|
@@ -12137,7 +12191,10 @@ var InputController = class {
|
|
|
12137
12191
|
forwardmove,
|
|
12138
12192
|
sidemove,
|
|
12139
12193
|
upmove,
|
|
12140
|
-
serverFrame
|
|
12194
|
+
serverFrame,
|
|
12195
|
+
sequence: this.sequence,
|
|
12196
|
+
lightlevel: 0,
|
|
12197
|
+
impulse: 0
|
|
12141
12198
|
};
|
|
12142
12199
|
}
|
|
12143
12200
|
consumeConsoleCommands() {
|
|
@@ -12317,8 +12374,8 @@ var InputCommandBuffer = class {
|
|
|
12317
12374
|
};
|
|
12318
12375
|
|
|
12319
12376
|
// src/index.ts
|
|
12320
|
-
var import_cgame4 = require("@quake2ts/cgame");
|
|
12321
12377
|
var import_cgame5 = require("@quake2ts/cgame");
|
|
12378
|
+
var import_cgame6 = require("@quake2ts/cgame");
|
|
12322
12379
|
var ZERO_VEC32 = { x: 0, y: 0, z: 0 };
|
|
12323
12380
|
var ClientMode = /* @__PURE__ */ ((ClientMode2) => {
|
|
12324
12381
|
ClientMode2[ClientMode2["Normal"] = 0] = "Normal";
|
|
@@ -12332,8 +12389,8 @@ function createClient(imports) {
|
|
|
12332
12389
|
const tr = imports.engine.trace(point, point, zero3, zero3);
|
|
12333
12390
|
return tr.contents || 0;
|
|
12334
12391
|
};
|
|
12335
|
-
const prediction = new
|
|
12336
|
-
const view = new
|
|
12392
|
+
const prediction = new import_cgame3.ClientPrediction(imports.engine.trace, pointContents);
|
|
12393
|
+
const view = new import_cgame4.ViewEffects();
|
|
12337
12394
|
const demoPlayback = new DemoPlaybackController();
|
|
12338
12395
|
const demoHandler = new ClientNetworkHandler(imports);
|
|
12339
12396
|
demoHandler.setView(view);
|
|
@@ -12375,7 +12432,7 @@ function createClient(imports) {
|
|
|
12375
12432
|
}
|
|
12376
12433
|
};
|
|
12377
12434
|
const cgameImport = createCGameImport(imports, stateProvider);
|
|
12378
|
-
const cg = (0,
|
|
12435
|
+
const cg = (0, import_cgame3.GetCGameAPI)(cgameImport);
|
|
12379
12436
|
const multiplayer = new MultiplayerConnection({
|
|
12380
12437
|
get username() {
|
|
12381
12438
|
return imports.host?.cvars?.get("name")?.string || "Player";
|
|
@@ -12614,7 +12671,7 @@ function createClient(imports) {
|
|
|
12614
12671
|
latestFrame = sample.latest;
|
|
12615
12672
|
}
|
|
12616
12673
|
if (sample.previous?.state && sample.latest?.state) {
|
|
12617
|
-
lastRendered = (0,
|
|
12674
|
+
lastRendered = (0, import_cgame3.interpolatePredictionState)(sample.previous.state, sample.latest.state, sample.alpha);
|
|
12618
12675
|
if (sample.latest.state.packetEntities && sample.previous.state.packetEntities) {
|
|
12619
12676
|
renderEntities = buildRenderableEntities(
|
|
12620
12677
|
sample.latest.state.packetEntities,
|