quake2ts 0.0.298 → 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 +52 -1
- 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 +53 -2
- 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 +67 -10
- package/packages/client/dist/cjs/index.cjs.map +1 -1
- package/packages/client/dist/esm/index.js +62 -5
- 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.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.map +1 -1
- package/packages/game/dist/cjs/index.cjs.map +1 -1
- package/packages/game/dist/esm/index.js.map +1 -1
- package/packages/game/dist/tsconfig.tsbuildinfo +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.map +1 -1
- package/packages/shared/dist/cjs/index.cjs.map +1 -1
- package/packages/shared/dist/esm/index.js.map +1 -1
- package/packages/shared/dist/tsconfig.tsbuildinfo +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
|
@@ -9623,7 +9623,7 @@ var AmmoType2 = /* @__PURE__ */ ((AmmoType22) => {
|
|
|
9623
9623
|
var AMMO_TYPE_COUNT2 = Object.keys(AmmoType2).length / 2;
|
|
9624
9624
|
|
|
9625
9625
|
// src/index.ts
|
|
9626
|
-
import { ClientPrediction, interpolatePredictionState as interpolatePredictionState2, GetCGameAPI } from "@quake2ts/cgame";
|
|
9626
|
+
import { ClientPrediction as ClientPrediction2, interpolatePredictionState as interpolatePredictionState2, GetCGameAPI } from "@quake2ts/cgame";
|
|
9627
9627
|
import { ViewEffects as ViewEffects2 } from "@quake2ts/cgame";
|
|
9628
9628
|
|
|
9629
9629
|
// src/cgameBridge.ts
|
|
@@ -9674,6 +9674,24 @@ function createCGameImport(imports, state) {
|
|
|
9674
9674
|
flags
|
|
9675
9675
|
});
|
|
9676
9676
|
},
|
|
9677
|
+
Cvar_Get: (name, value, flags) => {
|
|
9678
|
+
if (!imports.host || !imports.host.cvars) {
|
|
9679
|
+
return { value: parseInt(value) || 0 };
|
|
9680
|
+
}
|
|
9681
|
+
let existing = imports.host.cvars.get(name);
|
|
9682
|
+
if (!existing) {
|
|
9683
|
+
existing = imports.host.cvars.register({
|
|
9684
|
+
name,
|
|
9685
|
+
defaultValue: value,
|
|
9686
|
+
flags
|
|
9687
|
+
});
|
|
9688
|
+
}
|
|
9689
|
+
return {
|
|
9690
|
+
get value() {
|
|
9691
|
+
return existing.number;
|
|
9692
|
+
}
|
|
9693
|
+
};
|
|
9694
|
+
},
|
|
9677
9695
|
cvar_set: (name, value) => {
|
|
9678
9696
|
imports.host?.cvars?.setValue(name, value);
|
|
9679
9697
|
},
|
|
@@ -11611,6 +11629,7 @@ var BrowserWebSocketNetDriver = class {
|
|
|
11611
11629
|
};
|
|
11612
11630
|
|
|
11613
11631
|
// src/net/connection.ts
|
|
11632
|
+
import { defaultPredictionState as defaultPredictionState2 } from "@quake2ts/cgame";
|
|
11614
11633
|
var MultiplayerConnection = class {
|
|
11615
11634
|
constructor(options) {
|
|
11616
11635
|
this.state = 0 /* Disconnected */;
|
|
@@ -11628,6 +11647,8 @@ var MultiplayerConnection = class {
|
|
|
11628
11647
|
this.connectPacketTime = 0;
|
|
11629
11648
|
this.latestServerFrame = 0;
|
|
11630
11649
|
this.commandHistory = [];
|
|
11650
|
+
// Prediction
|
|
11651
|
+
this.prediction = null;
|
|
11631
11652
|
this.driver = new BrowserWebSocketNetDriver();
|
|
11632
11653
|
this.options = options;
|
|
11633
11654
|
this.netchan = new NetChan();
|
|
@@ -11635,6 +11656,9 @@ var MultiplayerConnection = class {
|
|
|
11635
11656
|
this.driver.onClose(() => this.handleDisconnect());
|
|
11636
11657
|
this.driver.onError((err2) => console.error("Network Error:", err2));
|
|
11637
11658
|
}
|
|
11659
|
+
setPrediction(prediction) {
|
|
11660
|
+
this.prediction = prediction;
|
|
11661
|
+
}
|
|
11638
11662
|
async connect(url) {
|
|
11639
11663
|
if (this.state !== 0 /* Disconnected */) {
|
|
11640
11664
|
this.disconnect();
|
|
@@ -11672,6 +11696,9 @@ var MultiplayerConnection = class {
|
|
|
11672
11696
|
if (this.commandHistory.length > CMD_BACKUP) {
|
|
11673
11697
|
this.commandHistory.shift();
|
|
11674
11698
|
}
|
|
11699
|
+
if (this.prediction) {
|
|
11700
|
+
this.prediction.enqueueCommand(commandWithFrame);
|
|
11701
|
+
}
|
|
11675
11702
|
const writer = new BinaryWriter2();
|
|
11676
11703
|
writer.writeByte(ClientCommand.move);
|
|
11677
11704
|
writer.writeByte(0);
|
|
@@ -11769,6 +11796,31 @@ var MultiplayerConnection = class {
|
|
|
11769
11796
|
if (frame.serverFrame > this.latestServerFrame) {
|
|
11770
11797
|
this.latestServerFrame = frame.serverFrame;
|
|
11771
11798
|
}
|
|
11799
|
+
if (this.prediction && frame.playerState) {
|
|
11800
|
+
const ps = frame.playerState;
|
|
11801
|
+
const predState = {
|
|
11802
|
+
...defaultPredictionState2(),
|
|
11803
|
+
// Manual mapping due to type mismatch (MutableVec3 vs Vec3, and property names)
|
|
11804
|
+
origin: { x: ps.origin.x, y: ps.origin.y, z: ps.origin.z },
|
|
11805
|
+
velocity: { x: ps.velocity.x, y: ps.velocity.y, z: ps.velocity.z },
|
|
11806
|
+
viewAngles: { x: ps.viewangles.x, y: ps.viewangles.y, z: ps.viewangles.z },
|
|
11807
|
+
deltaAngles: { x: ps.delta_angles.x, y: ps.delta_angles.y, z: ps.delta_angles.z },
|
|
11808
|
+
pmFlags: ps.pm_flags,
|
|
11809
|
+
pmType: ps.pm_type,
|
|
11810
|
+
gravity: ps.gravity,
|
|
11811
|
+
// Copy other matching fields
|
|
11812
|
+
health: ps.stats[0]
|
|
11813
|
+
// Assuming stat 0 is health? Or generic copy
|
|
11814
|
+
// ...
|
|
11815
|
+
};
|
|
11816
|
+
const gameFrame = {
|
|
11817
|
+
frame: frame.serverFrame,
|
|
11818
|
+
timeMs: 0,
|
|
11819
|
+
// Should be server time, but frame doesn't always have it explicitly?
|
|
11820
|
+
state: predState
|
|
11821
|
+
};
|
|
11822
|
+
this.prediction.setAuthoritative(gameFrame);
|
|
11823
|
+
}
|
|
11772
11824
|
}
|
|
11773
11825
|
// Stubs for other handlers
|
|
11774
11826
|
onCenterPrint(msg) {
|
|
@@ -11960,6 +12012,7 @@ var InputController = class {
|
|
|
11960
12012
|
this.touchButtons = /* @__PURE__ */ new Map();
|
|
11961
12013
|
this.touchMove = { x: 0, y: 0 };
|
|
11962
12014
|
this.touchLook = { x: 0, y: 0 };
|
|
12015
|
+
this.sequence = 0;
|
|
11963
12016
|
this.bindings = bindings;
|
|
11964
12017
|
this.forwardSpeed = options.forwardSpeed ?? DEFAULT_FORWARD_SPEED;
|
|
11965
12018
|
this.sideSpeed = options.sideSpeed ?? DEFAULT_SIDE_SPEED;
|
|
@@ -12098,6 +12151,7 @@ var InputController = class {
|
|
|
12098
12151
|
buttons |= PlayerButton.Any;
|
|
12099
12152
|
}
|
|
12100
12153
|
this.anyPressed = false;
|
|
12154
|
+
this.sequence++;
|
|
12101
12155
|
return {
|
|
12102
12156
|
msec,
|
|
12103
12157
|
buttons,
|
|
@@ -12105,7 +12159,10 @@ var InputController = class {
|
|
|
12105
12159
|
forwardmove,
|
|
12106
12160
|
sidemove,
|
|
12107
12161
|
upmove,
|
|
12108
|
-
serverFrame
|
|
12162
|
+
serverFrame,
|
|
12163
|
+
sequence: this.sequence,
|
|
12164
|
+
lightlevel: 0,
|
|
12165
|
+
impulse: 0
|
|
12109
12166
|
};
|
|
12110
12167
|
}
|
|
12111
12168
|
consumeConsoleCommands() {
|
|
@@ -12286,7 +12343,7 @@ var InputCommandBuffer = class {
|
|
|
12286
12343
|
|
|
12287
12344
|
// src/index.ts
|
|
12288
12345
|
import {
|
|
12289
|
-
ClientPrediction as
|
|
12346
|
+
ClientPrediction as ClientPrediction3,
|
|
12290
12347
|
interpolatePredictionState as interpolatePredictionState3
|
|
12291
12348
|
} from "@quake2ts/cgame";
|
|
12292
12349
|
import { ViewEffects as ViewEffects3 } from "@quake2ts/cgame";
|
|
@@ -12303,7 +12360,7 @@ function createClient(imports) {
|
|
|
12303
12360
|
const tr = imports.engine.trace(point, point, zero3, zero3);
|
|
12304
12361
|
return tr.contents || 0;
|
|
12305
12362
|
};
|
|
12306
|
-
const prediction = new
|
|
12363
|
+
const prediction = new ClientPrediction2(imports.engine.trace, pointContents);
|
|
12307
12364
|
const view = new ViewEffects2();
|
|
12308
12365
|
const demoPlayback = new DemoPlaybackController();
|
|
12309
12366
|
const demoHandler = new ClientNetworkHandler(imports);
|
|
@@ -12803,7 +12860,7 @@ function createClient(imports) {
|
|
|
12803
12860
|
export {
|
|
12804
12861
|
ClientConfigStrings,
|
|
12805
12862
|
ClientMode,
|
|
12806
|
-
|
|
12863
|
+
ClientPrediction3 as ClientPrediction,
|
|
12807
12864
|
InputAction,
|
|
12808
12865
|
InputBindings,
|
|
12809
12866
|
InputCommandBuffer,
|