quake2ts 0.0.290 → 0.0.291
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/client/dist/browser/index.global.js +11 -11
- package/packages/client/dist/browser/index.global.js.map +1 -1
- package/packages/client/dist/cjs/index.cjs +22 -12
- package/packages/client/dist/cjs/index.cjs.map +1 -1
- package/packages/client/dist/esm/index.js +22 -12
- package/packages/client/dist/esm/index.js.map +1 -1
- package/packages/client/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/client/dist/types/net/connection.d.ts +1 -0
- package/packages/client/dist/types/net/connection.d.ts.map +1 -1
|
@@ -9603,6 +9603,7 @@ _NetChan3.MAX_MSGLEN = 1400;
|
|
|
9603
9603
|
_NetChan3.FRAGMENT_SIZE = 1024;
|
|
9604
9604
|
_NetChan3.PACKET_HEADER = 10;
|
|
9605
9605
|
_NetChan3.HEADER_OVERHEAD = _NetChan3.PACKET_HEADER + 2;
|
|
9606
|
+
var NetChan = _NetChan3;
|
|
9606
9607
|
var AmmoType2 = /* @__PURE__ */ ((AmmoType22) => {
|
|
9607
9608
|
AmmoType22[AmmoType22["Bullets"] = 0] = "Bullets";
|
|
9608
9609
|
AmmoType22[AmmoType22["Shells"] = 1] = "Shells";
|
|
@@ -11630,6 +11631,7 @@ var MultiplayerConnection = class {
|
|
|
11630
11631
|
this.commandHistory = [];
|
|
11631
11632
|
this.driver = new BrowserWebSocketNetDriver();
|
|
11632
11633
|
this.options = options;
|
|
11634
|
+
this.netchan = new NetChan();
|
|
11633
11635
|
this.driver.onMessage((data) => this.handleMessage(data));
|
|
11634
11636
|
this.driver.onClose(() => this.handleDisconnect());
|
|
11635
11637
|
this.driver.onError((err2) => console.error("Network Error:", err2));
|
|
@@ -11640,6 +11642,7 @@ var MultiplayerConnection = class {
|
|
|
11640
11642
|
}
|
|
11641
11643
|
console.log(`Connecting to ${url}...`);
|
|
11642
11644
|
this.state = 1 /* Connecting */;
|
|
11645
|
+
this.netchan.reset();
|
|
11643
11646
|
try {
|
|
11644
11647
|
await this.driver.connect(url);
|
|
11645
11648
|
console.log("WebSocket connected.");
|
|
@@ -11671,13 +11674,12 @@ var MultiplayerConnection = class {
|
|
|
11671
11674
|
this.commandHistory.shift();
|
|
11672
11675
|
}
|
|
11673
11676
|
const writer = new BinaryWriter2();
|
|
11674
|
-
writer.writeLong(0);
|
|
11675
|
-
writer.writeLong(0);
|
|
11676
11677
|
writer.writeByte(ClientCommand.move);
|
|
11677
11678
|
writer.writeByte(0);
|
|
11678
11679
|
writer.writeLong(this.latestServerFrame);
|
|
11679
11680
|
writeUserCommand(writer, commandWithFrame);
|
|
11680
|
-
this.
|
|
11681
|
+
const packet = this.netchan.transmit(writer.getData());
|
|
11682
|
+
this.driver.send(packet);
|
|
11681
11683
|
}
|
|
11682
11684
|
handleMessage(data) {
|
|
11683
11685
|
let buffer = data.buffer;
|
|
@@ -11686,11 +11688,15 @@ var MultiplayerConnection = class {
|
|
|
11686
11688
|
new Uint8Array(newBuffer).set(data);
|
|
11687
11689
|
buffer = newBuffer;
|
|
11688
11690
|
}
|
|
11689
|
-
const
|
|
11690
|
-
|
|
11691
|
-
|
|
11692
|
-
|
|
11693
|
-
|
|
11691
|
+
const processedData = this.netchan.process(new Uint8Array(buffer));
|
|
11692
|
+
if (!processedData) {
|
|
11693
|
+
return;
|
|
11694
|
+
}
|
|
11695
|
+
if (processedData.byteLength > 0) {
|
|
11696
|
+
const stream = new BinaryStream2(processedData.buffer);
|
|
11697
|
+
this.parser = new NetworkMessageParser(stream, this);
|
|
11698
|
+
this.parser.parseMessage();
|
|
11699
|
+
}
|
|
11694
11700
|
}
|
|
11695
11701
|
handleDisconnect() {
|
|
11696
11702
|
console.log("Disconnected from server.");
|
|
@@ -11700,14 +11706,16 @@ var MultiplayerConnection = class {
|
|
|
11700
11706
|
const builder = new NetworkMessageBuilder();
|
|
11701
11707
|
builder.writeByte(ClientCommand.stringcmd);
|
|
11702
11708
|
builder.writeString("getchallenge");
|
|
11703
|
-
this.
|
|
11709
|
+
const packet = this.netchan.transmit(builder.getData());
|
|
11710
|
+
this.driver.send(packet);
|
|
11704
11711
|
}
|
|
11705
11712
|
sendConnect(challenge) {
|
|
11706
11713
|
const builder = new NetworkMessageBuilder();
|
|
11707
11714
|
builder.writeByte(ClientCommand.stringcmd);
|
|
11708
11715
|
const userinfo = `\\name\\${this.options.username}\\model\\${this.options.model}\\skin\\${this.options.skin}\\hand\\${this.options.hand ?? 0}\\fov\\${this.options.fov ?? 90}`;
|
|
11709
11716
|
builder.writeString(`connect ${PROTOCOL_VERSION_RERELEASE} ${challenge} ${userinfo}`);
|
|
11710
|
-
this.
|
|
11717
|
+
const packet = this.netchan.transmit(builder.getData());
|
|
11718
|
+
this.driver.send(packet);
|
|
11711
11719
|
}
|
|
11712
11720
|
isConnected() {
|
|
11713
11721
|
return this.state === 5 /* Active */;
|
|
@@ -11726,7 +11734,8 @@ var MultiplayerConnection = class {
|
|
|
11726
11734
|
const builder = new NetworkMessageBuilder();
|
|
11727
11735
|
builder.writeByte(ClientCommand.stringcmd);
|
|
11728
11736
|
builder.writeString("new");
|
|
11729
|
-
this.
|
|
11737
|
+
const packet = this.netchan.transmit(builder.getData());
|
|
11738
|
+
this.driver.send(packet);
|
|
11730
11739
|
this.state = 4 /* Loading */;
|
|
11731
11740
|
}
|
|
11732
11741
|
onConfigString(index, str3) {
|
|
@@ -11753,7 +11762,8 @@ var MultiplayerConnection = class {
|
|
|
11753
11762
|
const builder = new NetworkMessageBuilder();
|
|
11754
11763
|
builder.writeByte(ClientCommand.stringcmd);
|
|
11755
11764
|
builder.writeString("begin");
|
|
11756
|
-
this.
|
|
11765
|
+
const packet = this.netchan.transmit(builder.getData());
|
|
11766
|
+
this.driver.send(packet);
|
|
11757
11767
|
this.state = 5 /* Active */;
|
|
11758
11768
|
}
|
|
11759
11769
|
onFrame(frame) {
|