quake2ts 0.0.256 → 0.0.261
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 +23 -0
- package/packages/cgame/dist/index.cjs.map +1 -1
- package/packages/cgame/dist/index.js +24 -1
- 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 +155 -6
- package/packages/client/dist/cjs/index.cjs.map +1 -1
- package/packages/client/dist/esm/index.js +174 -25
- package/packages/client/dist/esm/index.js.map +1 -1
- package/packages/client/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/client/dist/types/hud/icons.d.ts.map +1 -1
- package/packages/client/dist/types/hud/statusbar.d.ts.map +1 -1
- package/packages/client/dist/types/net/connection.d.ts +2 -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 +2 -2
- package/packages/game/dist/browser/index.global.js.map +1 -1
- package/packages/game/dist/cjs/index.cjs +4118 -2942
- package/packages/game/dist/cjs/index.cjs.map +1 -1
- package/packages/game/dist/esm/index.js +4117 -2940
- package/packages/game/dist/esm/index.js.map +1 -1
- package/packages/game/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/game/dist/types/combat/weapons/animation.d.ts +20 -0
- package/packages/game/dist/types/combat/weapons/animation.d.ts.map +1 -0
- package/packages/game/dist/types/combat/weapons/firing.d.ts.map +1 -1
- package/packages/game/dist/types/combat/weapons/frames.d.ts +8 -0
- package/packages/game/dist/types/combat/weapons/frames.d.ts.map +1 -0
- package/packages/game/dist/types/combat/weapons/projectSource.d.ts +17 -0
- package/packages/game/dist/types/combat/weapons/projectSource.d.ts.map +1 -0
- package/packages/game/dist/types/combat/weapons/rogue.d.ts +4 -4
- package/packages/game/dist/types/combat/weapons/rogue.d.ts.map +1 -1
- package/packages/game/dist/types/combat/weapons/state.d.ts +6 -0
- package/packages/game/dist/types/combat/weapons/state.d.ts.map +1 -1
- package/packages/game/dist/types/combat/weapons/switching.d.ts +11 -0
- package/packages/game/dist/types/combat/weapons/switching.d.ts.map +1 -1
- package/packages/game/dist/types/entities/entity.d.ts +1 -0
- package/packages/game/dist/types/entities/entity.d.ts.map +1 -1
- package/packages/game/dist/types/entities/funcs.d.ts +2 -1
- package/packages/game/dist/types/entities/funcs.d.ts.map +1 -1
- package/packages/game/dist/types/entities/misc.d.ts.map +1 -1
- package/packages/game/dist/types/entities/monsters/index.d.ts.map +1 -1
- package/packages/game/dist/types/entities/monsters/insane.d.ts +5 -0
- package/packages/game/dist/types/entities/monsters/insane.d.ts.map +1 -0
- package/packages/game/dist/types/entities/playerStats.d.ts.map +1 -1
- package/packages/game/dist/types/entities/projectiles.d.ts +1 -1
- package/packages/game/dist/types/entities/projectiles.d.ts.map +1 -1
- package/packages/game/dist/types/entities/targets.d.ts.map +1 -1
- package/packages/game/dist/types/inventory/ammo.d.ts.map +1 -1
- package/packages/game/dist/types/inventory/playerInventory.d.ts +91 -38
- package/packages/game/dist/types/inventory/playerInventory.d.ts.map +1 -1
- package/packages/server/dist/index.cjs +15 -0
- package/packages/server/dist/index.d.cts +1 -0
- package/packages/server/dist/index.d.ts +1 -0
- package/packages/server/dist/index.js +15 -0
- 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 +28 -4
- package/packages/shared/dist/cjs/index.cjs.map +1 -1
- package/packages/shared/dist/esm/index.js +25 -3
- package/packages/shared/dist/esm/index.js.map +1 -1
- package/packages/shared/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/shared/dist/types/protocol/constants.d.ts +1 -0
- package/packages/shared/dist/types/protocol/constants.d.ts.map +1 -1
- package/packages/shared/dist/types/protocol/index.d.ts +1 -0
- package/packages/shared/dist/types/protocol/index.d.ts.map +1 -1
- package/packages/shared/dist/types/protocol/stats.d.ts.map +1 -1
- package/packages/shared/dist/types/protocol/writeUserCmd.d.ts +4 -0
- package/packages/shared/dist/types/protocol/writeUserCmd.d.ts.map +1 -0
- package/packages/tools/dist/tsconfig.tsbuildinfo +1 -1
|
@@ -8418,6 +8418,7 @@ var ClientCommand = /* @__PURE__ */ ((ClientCommand2) => {
|
|
|
8418
8418
|
ClientCommand2[ClientCommand2["stringcmd"] = 4] = "stringcmd";
|
|
8419
8419
|
return ClientCommand2;
|
|
8420
8420
|
})(ClientCommand || {});
|
|
8421
|
+
var CMD_BACKUP = 64;
|
|
8421
8422
|
var MZ_BLASTER = 0;
|
|
8422
8423
|
var MZ_MACHINEGUN = 1;
|
|
8423
8424
|
var MZ_SHOTGUN = 2;
|
|
@@ -8573,7 +8574,16 @@ var POWERUP_STAT_MAP = {
|
|
|
8573
8574
|
"enviro_suit"
|
|
8574
8575
|
/* EnviroSuit */
|
|
8575
8576
|
]: 9,
|
|
8576
|
-
|
|
8577
|
+
[
|
|
8578
|
+
"bandolier"
|
|
8579
|
+
/* Bandolier */
|
|
8580
|
+
]: 10,
|
|
8581
|
+
// Placeholder/Map mismatch handling?
|
|
8582
|
+
[
|
|
8583
|
+
"ammo_pack"
|
|
8584
|
+
/* AmmoPack */
|
|
8585
|
+
]: 10,
|
|
8586
|
+
// Original reused indices or had gaps?
|
|
8577
8587
|
[
|
|
8578
8588
|
"ir_goggles"
|
|
8579
8589
|
/* IRGoggles */
|
|
@@ -8621,7 +8631,12 @@ var POWERUP_STAT_MAP = {
|
|
|
8621
8631
|
[
|
|
8622
8632
|
"tech_regeneration"
|
|
8623
8633
|
/* TechRegeneration */
|
|
8624
|
-
]: 22
|
|
8634
|
+
]: 22,
|
|
8635
|
+
// Add missing mappings to avoid runtime lookups failing for new types
|
|
8636
|
+
[
|
|
8637
|
+
"tag_token"
|
|
8638
|
+
/* TagToken */
|
|
8639
|
+
]: -1
|
|
8625
8640
|
};
|
|
8626
8641
|
function G_GetPowerupStat(stats, powerupId) {
|
|
8627
8642
|
let index;
|
|
@@ -8633,6 +8648,18 @@ function G_GetPowerupStat(stats, powerupId) {
|
|
|
8633
8648
|
if (index === void 0 || index < 0 || index >= POWERUP_MAX2) return 0;
|
|
8634
8649
|
return getCompressedInteger(stats, 41, index, NUM_BITS_FOR_POWERUP2);
|
|
8635
8650
|
}
|
|
8651
|
+
function writeUserCommand(writer, cmd) {
|
|
8652
|
+
writer.writeByte(cmd.msec);
|
|
8653
|
+
writer.writeByte(cmd.buttons);
|
|
8654
|
+
writer.writeAngle16(cmd.angles.x);
|
|
8655
|
+
writer.writeAngle16(cmd.angles.y);
|
|
8656
|
+
writer.writeAngle16(cmd.angles.z);
|
|
8657
|
+
writer.writeShort(cmd.forwardmove);
|
|
8658
|
+
writer.writeShort(cmd.sidemove);
|
|
8659
|
+
writer.writeShort(cmd.upmove);
|
|
8660
|
+
writer.writeByte(0);
|
|
8661
|
+
writer.writeByte(0);
|
|
8662
|
+
}
|
|
8636
8663
|
var entityFlags_exports2 = {};
|
|
8637
8664
|
__export3(entityFlags_exports2, {
|
|
8638
8665
|
U_ANGLE1: () => U_ANGLE13,
|
|
@@ -8791,6 +8818,108 @@ var BinaryStream2 = class {
|
|
|
8791
8818
|
out.z = norm[2];
|
|
8792
8819
|
}
|
|
8793
8820
|
};
|
|
8821
|
+
var BinaryWriter = class {
|
|
8822
|
+
constructor(sizeOrBuffer = 1400) {
|
|
8823
|
+
if (typeof sizeOrBuffer === "number") {
|
|
8824
|
+
this.buffer = new Uint8Array(sizeOrBuffer);
|
|
8825
|
+
this.fixed = false;
|
|
8826
|
+
} else {
|
|
8827
|
+
this.buffer = sizeOrBuffer;
|
|
8828
|
+
this.fixed = true;
|
|
8829
|
+
}
|
|
8830
|
+
this.view = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
|
|
8831
|
+
this.offset = 0;
|
|
8832
|
+
}
|
|
8833
|
+
ensureSpace(bytes) {
|
|
8834
|
+
if (this.offset + bytes > this.buffer.byteLength) {
|
|
8835
|
+
if (this.fixed) {
|
|
8836
|
+
throw new Error(`Buffer overflow: capacity ${this.buffer.byteLength}, needed ${this.offset + bytes}`);
|
|
8837
|
+
}
|
|
8838
|
+
const newSize = Math.max(this.buffer.byteLength * 2, this.offset + bytes);
|
|
8839
|
+
const newBuffer = new Uint8Array(newSize);
|
|
8840
|
+
newBuffer.set(this.buffer);
|
|
8841
|
+
this.buffer = newBuffer;
|
|
8842
|
+
this.view = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
|
|
8843
|
+
}
|
|
8844
|
+
}
|
|
8845
|
+
writeByte(value) {
|
|
8846
|
+
this.ensureSpace(1);
|
|
8847
|
+
this.view.setUint8(this.offset, value);
|
|
8848
|
+
this.offset += 1;
|
|
8849
|
+
}
|
|
8850
|
+
writeChar(value) {
|
|
8851
|
+
this.ensureSpace(1);
|
|
8852
|
+
this.view.setInt8(this.offset, value);
|
|
8853
|
+
this.offset += 1;
|
|
8854
|
+
}
|
|
8855
|
+
writeShort(value) {
|
|
8856
|
+
this.ensureSpace(2);
|
|
8857
|
+
this.view.setInt16(this.offset, value, true);
|
|
8858
|
+
this.offset += 2;
|
|
8859
|
+
}
|
|
8860
|
+
writeLong(value) {
|
|
8861
|
+
this.ensureSpace(4);
|
|
8862
|
+
this.view.setInt32(this.offset, value, true);
|
|
8863
|
+
this.offset += 4;
|
|
8864
|
+
}
|
|
8865
|
+
writeFloat(value) {
|
|
8866
|
+
this.ensureSpace(4);
|
|
8867
|
+
this.view.setFloat32(this.offset, value, true);
|
|
8868
|
+
this.offset += 4;
|
|
8869
|
+
}
|
|
8870
|
+
writeString(value) {
|
|
8871
|
+
const len2 = value.length;
|
|
8872
|
+
this.ensureSpace(len2 + 1);
|
|
8873
|
+
for (let i = 0; i < len2; i++) {
|
|
8874
|
+
this.view.setUint8(this.offset + i, value.charCodeAt(i));
|
|
8875
|
+
}
|
|
8876
|
+
this.view.setUint8(this.offset + len2, 0);
|
|
8877
|
+
this.offset += len2 + 1;
|
|
8878
|
+
}
|
|
8879
|
+
writeCoord(value) {
|
|
8880
|
+
this.writeShort(Math.trunc(value * 8));
|
|
8881
|
+
}
|
|
8882
|
+
writeAngle(value) {
|
|
8883
|
+
this.writeByte(Math.trunc(value * 256 / 360) & 255);
|
|
8884
|
+
}
|
|
8885
|
+
writeAngle16(value) {
|
|
8886
|
+
this.writeShort(Math.trunc(value * 65536 / 360) & 65535);
|
|
8887
|
+
}
|
|
8888
|
+
writePos(pos) {
|
|
8889
|
+
this.writeCoord(pos.x);
|
|
8890
|
+
this.writeCoord(pos.y);
|
|
8891
|
+
this.writeCoord(pos.z);
|
|
8892
|
+
}
|
|
8893
|
+
writeDir(dir) {
|
|
8894
|
+
let maxDot = -1;
|
|
8895
|
+
let bestIndex = 0;
|
|
8896
|
+
if (dir.x === 0 && dir.y === 0 && dir.z === 0) {
|
|
8897
|
+
this.writeByte(0);
|
|
8898
|
+
return;
|
|
8899
|
+
}
|
|
8900
|
+
for (let i = 0; i < ANORMS2.length; i++) {
|
|
8901
|
+
const norm = ANORMS2[i];
|
|
8902
|
+
const dot2 = dir.x * norm[0] + dir.y * norm[1] + dir.z * norm[2];
|
|
8903
|
+
if (dot2 > maxDot) {
|
|
8904
|
+
maxDot = dot2;
|
|
8905
|
+
bestIndex = i;
|
|
8906
|
+
}
|
|
8907
|
+
}
|
|
8908
|
+
this.writeByte(bestIndex);
|
|
8909
|
+
}
|
|
8910
|
+
getData() {
|
|
8911
|
+
return this.buffer.slice(0, this.offset);
|
|
8912
|
+
}
|
|
8913
|
+
getBuffer() {
|
|
8914
|
+
return this.buffer;
|
|
8915
|
+
}
|
|
8916
|
+
getOffset() {
|
|
8917
|
+
return this.offset;
|
|
8918
|
+
}
|
|
8919
|
+
reset() {
|
|
8920
|
+
this.offset = 0;
|
|
8921
|
+
}
|
|
8922
|
+
};
|
|
8794
8923
|
var NetworkMessageBuilder = class {
|
|
8795
8924
|
constructor(initialSize = 1024) {
|
|
8796
8925
|
this.buffer = new Uint8Array(initialSize);
|
|
@@ -9132,7 +9261,7 @@ var Cycle_Crosshair = () => {
|
|
|
9132
9261
|
};
|
|
9133
9262
|
|
|
9134
9263
|
// src/hud/icons.ts
|
|
9135
|
-
import { WEAPON_ITEMS } from "@quake2ts/game";
|
|
9264
|
+
import { WEAPON_ITEMS, KeyId } from "@quake2ts/game";
|
|
9136
9265
|
var iconPics = /* @__PURE__ */ new Map();
|
|
9137
9266
|
var ICON_NAMES = [
|
|
9138
9267
|
// Weapons
|
|
@@ -9234,7 +9363,7 @@ var Init_Hud = async (renderer, assets) => {
|
|
|
9234
9363
|
import { defaultPredictionState, interpolatePredictionState } from "@quake2ts/cgame";
|
|
9235
9364
|
|
|
9236
9365
|
// src/demo/itemMapping.ts
|
|
9237
|
-
import { WeaponId, PowerupId as PowerupId3, KeyId } from "@quake2ts/game";
|
|
9366
|
+
import { WeaponId, PowerupId as PowerupId3, KeyId as KeyId2 } from "@quake2ts/game";
|
|
9238
9367
|
import { AmmoType as AmmoType3 } from "@quake2ts/game";
|
|
9239
9368
|
import { ArmorType } from "@quake2ts/game";
|
|
9240
9369
|
var DEMO_ITEM_MAPPING = [
|
|
@@ -9360,35 +9489,35 @@ var DEMO_ITEM_MAPPING = [
|
|
|
9360
9489
|
{ type: "powerup", id: PowerupId3.TagToken },
|
|
9361
9490
|
// IT_ITEM_TAG_TOKEN
|
|
9362
9491
|
// Keys
|
|
9363
|
-
{ type: "key", id:
|
|
9492
|
+
{ type: "key", id: KeyId2.DataCD },
|
|
9364
9493
|
// IT_KEY_DATA_CD
|
|
9365
|
-
{ type: "key", id:
|
|
9494
|
+
{ type: "key", id: KeyId2.PowerCube },
|
|
9366
9495
|
// IT_KEY_POWER_CUBE
|
|
9367
|
-
{ type: "key", id:
|
|
9496
|
+
{ type: "key", id: KeyId2.ExplosiveCharges },
|
|
9368
9497
|
// IT_KEY_EXPLOSIVE_CHARGES
|
|
9369
|
-
{ type: "key", id:
|
|
9498
|
+
{ type: "key", id: KeyId2.Yellow },
|
|
9370
9499
|
// IT_KEY_YELLOW
|
|
9371
|
-
{ type: "key", id:
|
|
9500
|
+
{ type: "key", id: KeyId2.PowerCore },
|
|
9372
9501
|
// IT_KEY_POWER_CORE
|
|
9373
|
-
{ type: "key", id:
|
|
9502
|
+
{ type: "key", id: KeyId2.Pyramid },
|
|
9374
9503
|
// IT_KEY_PYRAMID
|
|
9375
|
-
{ type: "key", id:
|
|
9504
|
+
{ type: "key", id: KeyId2.DataSpinner },
|
|
9376
9505
|
// IT_KEY_DATA_SPINNER
|
|
9377
|
-
{ type: "key", id:
|
|
9506
|
+
{ type: "key", id: KeyId2.Pass },
|
|
9378
9507
|
// IT_KEY_PASS
|
|
9379
|
-
{ type: "key", id:
|
|
9508
|
+
{ type: "key", id: KeyId2.Blue },
|
|
9380
9509
|
// IT_KEY_BLUE_KEY
|
|
9381
|
-
{ type: "key", id:
|
|
9510
|
+
{ type: "key", id: KeyId2.Red },
|
|
9382
9511
|
// IT_KEY_RED_KEY
|
|
9383
|
-
{ type: "key", id:
|
|
9512
|
+
{ type: "key", id: KeyId2.Green },
|
|
9384
9513
|
// IT_KEY_GREEN_KEY
|
|
9385
|
-
{ type: "key", id:
|
|
9514
|
+
{ type: "key", id: KeyId2.CommanderHead },
|
|
9386
9515
|
// IT_KEY_COMMANDER_HEAD
|
|
9387
|
-
{ type: "key", id:
|
|
9516
|
+
{ type: "key", id: KeyId2.Airstrike },
|
|
9388
9517
|
// IT_KEY_AIRSTRIKE
|
|
9389
|
-
{ type: "key", id:
|
|
9518
|
+
{ type: "key", id: KeyId2.NukeContainer },
|
|
9390
9519
|
// IT_KEY_NUKE_CONTAINER
|
|
9391
|
-
{ type: "key", id:
|
|
9520
|
+
{ type: "key", id: KeyId2.Nuke },
|
|
9392
9521
|
// IT_KEY_NUKE
|
|
9393
9522
|
// Health
|
|
9394
9523
|
{ type: "health", id: "health_small" },
|
|
@@ -9400,9 +9529,9 @@ var DEMO_ITEM_MAPPING = [
|
|
|
9400
9529
|
{ type: "health", id: "health_mega" },
|
|
9401
9530
|
// IT_HEALTH_MEGA
|
|
9402
9531
|
// CTF
|
|
9403
|
-
{ type: "key", id:
|
|
9532
|
+
{ type: "key", id: KeyId2.RedFlag },
|
|
9404
9533
|
// IT_FLAG1
|
|
9405
|
-
{ type: "key", id:
|
|
9534
|
+
{ type: "key", id: KeyId2.BlueFlag },
|
|
9406
9535
|
// IT_FLAG2
|
|
9407
9536
|
// Tech
|
|
9408
9537
|
{ type: "powerup", id: PowerupId3.TechResistance },
|
|
@@ -10866,6 +10995,8 @@ var MultiplayerConnection = class {
|
|
|
10866
10995
|
this.challenge = 0;
|
|
10867
10996
|
this.connectPacketCount = 0;
|
|
10868
10997
|
this.connectPacketTime = 0;
|
|
10998
|
+
this.latestServerFrame = 0;
|
|
10999
|
+
this.commandHistory = [];
|
|
10869
11000
|
this.driver = new BrowserWebSocketNetDriver();
|
|
10870
11001
|
this.options = options;
|
|
10871
11002
|
this.driver.onMessage((data) => this.handleMessage(data));
|
|
@@ -10895,12 +11026,27 @@ var MultiplayerConnection = class {
|
|
|
10895
11026
|
this.state = 0 /* Disconnected */;
|
|
10896
11027
|
this.configStrings.clear();
|
|
10897
11028
|
this.baselines.clear();
|
|
11029
|
+
this.commandHistory = [];
|
|
11030
|
+
this.latestServerFrame = 0;
|
|
10898
11031
|
}
|
|
10899
11032
|
sendCommand(cmd) {
|
|
10900
11033
|
if (this.state !== 5 /* Active */) return;
|
|
10901
|
-
const
|
|
10902
|
-
|
|
10903
|
-
|
|
11034
|
+
const commandWithFrame = {
|
|
11035
|
+
...cmd,
|
|
11036
|
+
serverFrame: cmd.serverFrame ?? this.latestServerFrame
|
|
11037
|
+
};
|
|
11038
|
+
this.commandHistory.push(commandWithFrame);
|
|
11039
|
+
if (this.commandHistory.length > CMD_BACKUP) {
|
|
11040
|
+
this.commandHistory.shift();
|
|
11041
|
+
}
|
|
11042
|
+
const writer = new BinaryWriter();
|
|
11043
|
+
writer.writeLong(0);
|
|
11044
|
+
writer.writeLong(0);
|
|
11045
|
+
writer.writeByte(ClientCommand.move);
|
|
11046
|
+
writer.writeByte(0);
|
|
11047
|
+
writer.writeLong(this.latestServerFrame);
|
|
11048
|
+
writeUserCommand(writer, commandWithFrame);
|
|
11049
|
+
this.driver.send(writer.getData());
|
|
10904
11050
|
}
|
|
10905
11051
|
handleMessage(data) {
|
|
10906
11052
|
let buffer = data.buffer;
|
|
@@ -10979,9 +11125,12 @@ var MultiplayerConnection = class {
|
|
|
10979
11125
|
this.driver.send(builder.getData());
|
|
10980
11126
|
this.state = 5 /* Active */;
|
|
10981
11127
|
}
|
|
10982
|
-
// Stubs for other handlers
|
|
10983
11128
|
onFrame(frame) {
|
|
11129
|
+
if (frame.serverFrame > this.latestServerFrame) {
|
|
11130
|
+
this.latestServerFrame = frame.serverFrame;
|
|
11131
|
+
}
|
|
10984
11132
|
}
|
|
11133
|
+
// Stubs for other handlers
|
|
10985
11134
|
onCenterPrint(msg) {
|
|
10986
11135
|
}
|
|
10987
11136
|
onPrint(level, msg) {
|