quake2ts 0.0.217 → 0.0.218
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.218",
|
|
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) {
|
|
@@ -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) {
|