quake2ts 0.0.217 → 0.0.219
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quake2ts",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.219",
|
|
4
4
|
"description": "Quake II re-release port to TypeScript with WebGL renderer - A complete game engine with physics, networking, and BSP rendering",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"packageManager": "pnpm@8.15.7",
|
|
@@ -684,7 +684,7 @@ var DedicatedServer = class {
|
|
|
684
684
|
this.port = port;
|
|
685
685
|
this.wss = null;
|
|
686
686
|
this.game = null;
|
|
687
|
-
this.
|
|
687
|
+
this.frameTimeout = null;
|
|
688
688
|
this.entityIndex = null;
|
|
689
689
|
this.svs = {
|
|
690
690
|
initialized: false,
|
|
@@ -817,7 +817,7 @@ var DedicatedServer = class {
|
|
|
817
817
|
this.game.spawnWorld();
|
|
818
818
|
this.populateBaselines();
|
|
819
819
|
this.sv.state = 2 /* Game */;
|
|
820
|
-
this.
|
|
820
|
+
this.runFrame();
|
|
821
821
|
console.log("Server started.");
|
|
822
822
|
}
|
|
823
823
|
populateBaselines() {
|
|
@@ -843,7 +843,7 @@ var DedicatedServer = class {
|
|
|
843
843
|
});
|
|
844
844
|
}
|
|
845
845
|
stop() {
|
|
846
|
-
if (this.
|
|
846
|
+
if (this.frameTimeout) clearTimeout(this.frameTimeout);
|
|
847
847
|
if (this.wss) this.wss.close();
|
|
848
848
|
this.game?.shutdown();
|
|
849
849
|
this.sv.state = 0 /* Dead */;
|
|
@@ -1000,6 +1000,7 @@ var DedicatedServer = class {
|
|
|
1000
1000
|
}
|
|
1001
1001
|
runFrame() {
|
|
1002
1002
|
if (!this.game) return;
|
|
1003
|
+
const startTime = Date.now();
|
|
1003
1004
|
this.sv.frame++;
|
|
1004
1005
|
this.sv.time += 100;
|
|
1005
1006
|
this.SV_ReadPackets();
|
|
@@ -1016,6 +1017,12 @@ var DedicatedServer = class {
|
|
|
1016
1017
|
if (snapshot && snapshot.state) {
|
|
1017
1018
|
this.SV_SendClientMessages(snapshot.state);
|
|
1018
1019
|
}
|
|
1020
|
+
const endTime = Date.now();
|
|
1021
|
+
const elapsed = endTime - startTime;
|
|
1022
|
+
const sleepTime = Math.max(0, FRAME_TIME_MS - elapsed);
|
|
1023
|
+
if (this.sv.state === 2 /* Game */) {
|
|
1024
|
+
this.frameTimeout = setTimeout(() => this.runFrame(), sleepTime);
|
|
1025
|
+
}
|
|
1019
1026
|
}
|
|
1020
1027
|
SV_SendClientMessages(snapshot) {
|
|
1021
1028
|
for (const client of this.svs.clients) {
|
|
@@ -1025,7 +1032,8 @@ var DedicatedServer = class {
|
|
|
1025
1032
|
}
|
|
1026
1033
|
}
|
|
1027
1034
|
SV_SendClientFrame(client, snapshot) {
|
|
1028
|
-
const
|
|
1035
|
+
const MTU = 1400;
|
|
1036
|
+
const writer = new import_shared4.BinaryWriter(MTU);
|
|
1029
1037
|
writer.writeByte(import_shared4.ServerCommand.frame);
|
|
1030
1038
|
writer.writeLong(this.sv.frame);
|
|
1031
1039
|
writer.writeLong(0);
|
|
@@ -1063,10 +1071,18 @@ var DedicatedServer = class {
|
|
|
1063
1071
|
const entities = snapshot.packetEntities || [];
|
|
1064
1072
|
const currentEntityIds = [];
|
|
1065
1073
|
for (const entity of entities) {
|
|
1074
|
+
if (writer.getOffset() > MTU - 200) {
|
|
1075
|
+
console.warn("Packet MTU limit reached, dropping remaining entities");
|
|
1076
|
+
break;
|
|
1077
|
+
}
|
|
1066
1078
|
currentEntityIds.push(entity.number);
|
|
1067
1079
|
writeDeltaEntity({}, entity, writer, false, true);
|
|
1068
1080
|
}
|
|
1069
1081
|
for (const oldId of client.lastPacketEntities) {
|
|
1082
|
+
if (writer.getOffset() > MTU - 10) {
|
|
1083
|
+
console.warn("Packet MTU limit reached, dropping remaining removals");
|
|
1084
|
+
break;
|
|
1085
|
+
}
|
|
1070
1086
|
if (!currentEntityIds.includes(oldId)) {
|
|
1071
1087
|
writeRemoveEntity(oldId, writer);
|
|
1072
1088
|
}
|
|
@@ -644,7 +644,7 @@ var DedicatedServer = class {
|
|
|
644
644
|
this.port = port;
|
|
645
645
|
this.wss = null;
|
|
646
646
|
this.game = null;
|
|
647
|
-
this.
|
|
647
|
+
this.frameTimeout = null;
|
|
648
648
|
this.entityIndex = null;
|
|
649
649
|
this.svs = {
|
|
650
650
|
initialized: false,
|
|
@@ -777,7 +777,7 @@ var DedicatedServer = class {
|
|
|
777
777
|
this.game.spawnWorld();
|
|
778
778
|
this.populateBaselines();
|
|
779
779
|
this.sv.state = 2 /* Game */;
|
|
780
|
-
this.
|
|
780
|
+
this.runFrame();
|
|
781
781
|
console.log("Server started.");
|
|
782
782
|
}
|
|
783
783
|
populateBaselines() {
|
|
@@ -803,7 +803,7 @@ var DedicatedServer = class {
|
|
|
803
803
|
});
|
|
804
804
|
}
|
|
805
805
|
stop() {
|
|
806
|
-
if (this.
|
|
806
|
+
if (this.frameTimeout) clearTimeout(this.frameTimeout);
|
|
807
807
|
if (this.wss) this.wss.close();
|
|
808
808
|
this.game?.shutdown();
|
|
809
809
|
this.sv.state = 0 /* Dead */;
|
|
@@ -960,6 +960,7 @@ var DedicatedServer = class {
|
|
|
960
960
|
}
|
|
961
961
|
runFrame() {
|
|
962
962
|
if (!this.game) return;
|
|
963
|
+
const startTime = Date.now();
|
|
963
964
|
this.sv.frame++;
|
|
964
965
|
this.sv.time += 100;
|
|
965
966
|
this.SV_ReadPackets();
|
|
@@ -976,6 +977,12 @@ var DedicatedServer = class {
|
|
|
976
977
|
if (snapshot && snapshot.state) {
|
|
977
978
|
this.SV_SendClientMessages(snapshot.state);
|
|
978
979
|
}
|
|
980
|
+
const endTime = Date.now();
|
|
981
|
+
const elapsed = endTime - startTime;
|
|
982
|
+
const sleepTime = Math.max(0, FRAME_TIME_MS - elapsed);
|
|
983
|
+
if (this.sv.state === 2 /* Game */) {
|
|
984
|
+
this.frameTimeout = setTimeout(() => this.runFrame(), sleepTime);
|
|
985
|
+
}
|
|
979
986
|
}
|
|
980
987
|
SV_SendClientMessages(snapshot) {
|
|
981
988
|
for (const client of this.svs.clients) {
|
|
@@ -985,7 +992,8 @@ var DedicatedServer = class {
|
|
|
985
992
|
}
|
|
986
993
|
}
|
|
987
994
|
SV_SendClientFrame(client, snapshot) {
|
|
988
|
-
const
|
|
995
|
+
const MTU = 1400;
|
|
996
|
+
const writer = new BinaryWriter2(MTU);
|
|
989
997
|
writer.writeByte(ServerCommand2.frame);
|
|
990
998
|
writer.writeLong(this.sv.frame);
|
|
991
999
|
writer.writeLong(0);
|
|
@@ -1023,10 +1031,18 @@ var DedicatedServer = class {
|
|
|
1023
1031
|
const entities = snapshot.packetEntities || [];
|
|
1024
1032
|
const currentEntityIds = [];
|
|
1025
1033
|
for (const entity of entities) {
|
|
1034
|
+
if (writer.getOffset() > MTU - 200) {
|
|
1035
|
+
console.warn("Packet MTU limit reached, dropping remaining entities");
|
|
1036
|
+
break;
|
|
1037
|
+
}
|
|
1026
1038
|
currentEntityIds.push(entity.number);
|
|
1027
1039
|
writeDeltaEntity({}, entity, writer, false, true);
|
|
1028
1040
|
}
|
|
1029
1041
|
for (const oldId of client.lastPacketEntities) {
|
|
1042
|
+
if (writer.getOffset() > MTU - 10) {
|
|
1043
|
+
console.warn("Packet MTU limit reached, dropping remaining removals");
|
|
1044
|
+
break;
|
|
1045
|
+
}
|
|
1030
1046
|
if (!currentEntityIds.includes(oldId)) {
|
|
1031
1047
|
writeRemoveEntity(oldId, writer);
|
|
1032
1048
|
}
|