@quake2ts/shared 0.0.869 → 0.0.873
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/cjs/index.cjs
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
5
|
var __export = (target, all) => {
|
|
5
6
|
for (var name in all)
|
|
6
7
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
7
8
|
};
|
|
9
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
8
10
|
|
|
9
11
|
// src/math/vec3.ts
|
|
10
12
|
var ZERO_VEC3 = { x: 0, y: 0, z: 0 };
|
|
@@ -559,8 +561,8 @@ var LOWER_MASK = 2147483647;
|
|
|
559
561
|
var TWO_POW_32 = 4294967296;
|
|
560
562
|
var MersenneTwister19937 = class {
|
|
561
563
|
constructor(seed = 5489) {
|
|
562
|
-
this
|
|
563
|
-
this
|
|
564
|
+
__publicField(this, "state", new Uint32Array(STATE_SIZE));
|
|
565
|
+
__publicField(this, "index", STATE_SIZE);
|
|
564
566
|
this.seed(seed);
|
|
565
567
|
}
|
|
566
568
|
seed(seed) {
|
|
@@ -610,6 +612,7 @@ var MersenneTwister19937 = class {
|
|
|
610
612
|
};
|
|
611
613
|
var RandomGenerator = class {
|
|
612
614
|
constructor(options = {}) {
|
|
615
|
+
__publicField(this, "mt");
|
|
613
616
|
this.mt = new MersenneTwister19937(options.seed);
|
|
614
617
|
}
|
|
615
618
|
seed(seed) {
|
|
@@ -1553,9 +1556,9 @@ function pickBetterTrace(best, candidate) {
|
|
|
1553
1556
|
}
|
|
1554
1557
|
var CollisionEntityIndex = class {
|
|
1555
1558
|
constructor() {
|
|
1556
|
-
this
|
|
1557
|
-
this
|
|
1558
|
-
this
|
|
1559
|
+
__publicField(this, "entities", /* @__PURE__ */ new Map());
|
|
1560
|
+
__publicField(this, "entityNodes", /* @__PURE__ */ new Map());
|
|
1561
|
+
__publicField(this, "rootNode", createSpatialTree());
|
|
1559
1562
|
}
|
|
1560
1563
|
link(entity) {
|
|
1561
1564
|
const state = makeEntityState(entity);
|
|
@@ -4969,6 +4972,9 @@ var applyPmove = (state, cmd, trace, pointContents2) => {
|
|
|
4969
4972
|
// src/io/binaryStream.ts
|
|
4970
4973
|
var BinaryStream = class {
|
|
4971
4974
|
constructor(buffer) {
|
|
4975
|
+
__publicField(this, "view");
|
|
4976
|
+
__publicField(this, "offset");
|
|
4977
|
+
__publicField(this, "length");
|
|
4972
4978
|
if (buffer instanceof Uint8Array) {
|
|
4973
4979
|
this.view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
4974
4980
|
} else {
|
|
@@ -5101,6 +5107,10 @@ var BinaryStream = class {
|
|
|
5101
5107
|
// src/io/binaryWriter.ts
|
|
5102
5108
|
var BinaryWriter = class {
|
|
5103
5109
|
constructor(sizeOrBuffer = 1400) {
|
|
5110
|
+
__publicField(this, "buffer");
|
|
5111
|
+
__publicField(this, "view");
|
|
5112
|
+
__publicField(this, "offset");
|
|
5113
|
+
__publicField(this, "fixed");
|
|
5104
5114
|
if (typeof sizeOrBuffer === "number") {
|
|
5105
5115
|
this.buffer = new Uint8Array(sizeOrBuffer);
|
|
5106
5116
|
this.fixed = false;
|
|
@@ -5210,6 +5220,9 @@ var BinaryWriter = class {
|
|
|
5210
5220
|
// src/io/messageBuilder.ts
|
|
5211
5221
|
var NetworkMessageBuilder = class {
|
|
5212
5222
|
constructor(initialSize = 1024) {
|
|
5223
|
+
__publicField(this, "buffer");
|
|
5224
|
+
__publicField(this, "view");
|
|
5225
|
+
__publicField(this, "offset");
|
|
5213
5226
|
this.buffer = new Uint8Array(initialSize);
|
|
5214
5227
|
this.view = new DataView(this.buffer.buffer);
|
|
5215
5228
|
this.offset = 0;
|
|
@@ -5304,29 +5317,31 @@ var _NetChan = class _NetChan {
|
|
|
5304
5317
|
constructor() {
|
|
5305
5318
|
// 256KB
|
|
5306
5319
|
// Public state
|
|
5307
|
-
this
|
|
5320
|
+
__publicField(this, "qport", 0);
|
|
5308
5321
|
// qport value to distinguish multiple clients from same IP
|
|
5309
5322
|
// Sequencing
|
|
5310
|
-
this
|
|
5311
|
-
this
|
|
5312
|
-
this
|
|
5323
|
+
__publicField(this, "incomingSequence", 0);
|
|
5324
|
+
__publicField(this, "outgoingSequence", 0);
|
|
5325
|
+
__publicField(this, "incomingAcknowledged", 0);
|
|
5313
5326
|
// Reliable messaging
|
|
5314
|
-
this
|
|
5327
|
+
__publicField(this, "incomingReliableAcknowledged", false);
|
|
5315
5328
|
// single bit
|
|
5316
|
-
this
|
|
5329
|
+
__publicField(this, "incomingReliableSequence", 0);
|
|
5317
5330
|
// last reliable message sequence received
|
|
5318
|
-
this
|
|
5319
|
-
|
|
5331
|
+
__publicField(this, "outgoingReliableSequence", 0);
|
|
5332
|
+
// reliable message sequence number to send
|
|
5333
|
+
__publicField(this, "reliableMessage");
|
|
5334
|
+
__publicField(this, "reliableLength", 0);
|
|
5320
5335
|
// Fragmentation State (Sending)
|
|
5321
|
-
this
|
|
5336
|
+
__publicField(this, "fragmentSendOffset", 0);
|
|
5322
5337
|
// Fragmentation State (Receiving)
|
|
5323
|
-
this
|
|
5324
|
-
this
|
|
5325
|
-
this
|
|
5338
|
+
__publicField(this, "fragmentBuffer", null);
|
|
5339
|
+
__publicField(this, "fragmentLength", 0);
|
|
5340
|
+
__publicField(this, "fragmentReceived", 0);
|
|
5326
5341
|
// Timing
|
|
5327
|
-
this
|
|
5328
|
-
this
|
|
5329
|
-
this
|
|
5342
|
+
__publicField(this, "lastReceived", 0);
|
|
5343
|
+
__publicField(this, "lastSent", 0);
|
|
5344
|
+
__publicField(this, "remoteAddress", null);
|
|
5330
5345
|
this.reliableMessage = new BinaryWriter(_NetChan.MAX_RELIABLE_BUFFER);
|
|
5331
5346
|
const now = Date.now();
|
|
5332
5347
|
this.lastReceived = now;
|
|
@@ -5609,16 +5624,16 @@ var _NetChan = class _NetChan {
|
|
|
5609
5624
|
}
|
|
5610
5625
|
};
|
|
5611
5626
|
// Constants from net_chan.c
|
|
5612
|
-
_NetChan
|
|
5613
|
-
_NetChan
|
|
5614
|
-
_NetChan
|
|
5627
|
+
__publicField(_NetChan, "MAX_MSGLEN", 1400);
|
|
5628
|
+
__publicField(_NetChan, "FRAGMENT_SIZE", 1024);
|
|
5629
|
+
__publicField(_NetChan, "PACKET_HEADER", 10);
|
|
5615
5630
|
// sequence(4) + ack(4) + qport(2)
|
|
5616
|
-
_NetChan
|
|
5631
|
+
__publicField(_NetChan, "HEADER_OVERHEAD", _NetChan.PACKET_HEADER + 2);
|
|
5617
5632
|
// +2 for reliable length prefix
|
|
5618
5633
|
// Increase internal reliable buffer to support large messages (fragmentation)
|
|
5619
5634
|
// Quake 2 uses MAX_MSGLEN for the reliable buffer, limiting single messages to ~1400 bytes.
|
|
5620
5635
|
// We expand this to allow larger messages (e.g. snapshots, downloads) which are then fragmented.
|
|
5621
|
-
_NetChan
|
|
5636
|
+
__publicField(_NetChan, "MAX_RELIABLE_BUFFER", 262144);
|
|
5622
5637
|
var NetChan = _NetChan;
|
|
5623
5638
|
|
|
5624
5639
|
// src/items/weapons.ts
|