quake2ts 0.0.469 → 0.0.472
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 +16 -16
- package/packages/client/dist/browser/index.global.js.map +1 -1
- package/packages/client/dist/cjs/index.cjs +130 -2
- package/packages/client/dist/cjs/index.cjs.map +1 -1
- package/packages/client/dist/esm/index.js +130 -2
- package/packages/client/dist/esm/index.js.map +1 -1
- package/packages/client/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/client/dist/types/chat.d.ts +20 -0
- package/packages/client/dist/types/chat.d.ts.map +1 -0
- package/packages/client/dist/types/chat.test.d.ts +2 -0
- package/packages/client/dist/types/chat.test.d.ts.map +1 -0
- package/packages/client/dist/types/demo/handler.d.ts +1 -0
- package/packages/client/dist/types/demo/handler.d.ts.map +1 -1
- package/packages/client/dist/types/index.d.ts +3 -0
- package/packages/client/dist/types/index.d.ts.map +1 -1
- package/packages/client/dist/types/scoreboard.d.ts +17 -0
- package/packages/client/dist/types/scoreboard.d.ts.map +1 -1
- package/packages/client/dist/types/scoreboard.test.d.ts +2 -0
- package/packages/client/dist/types/scoreboard.test.d.ts.map +1 -0
- package/packages/game/dist/browser/index.global.js +4 -4
- package/packages/game/dist/browser/index.global.js.map +1 -1
- package/packages/game/dist/cjs/index.cjs +130 -73
- package/packages/game/dist/cjs/index.cjs.map +1 -1
- package/packages/game/dist/esm/index.js +129 -73
- package/packages/game/dist/esm/index.js.map +1 -1
- package/packages/game/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/game/dist/types/ai/noise.d.ts +1 -0
- package/packages/game/dist/types/ai/noise.d.ts.map +1 -1
- package/packages/game/dist/types/ai/targeting.d.ts.map +1 -1
- package/packages/game/dist/types/inventory/playerInventory.d.ts +8 -0
- package/packages/game/dist/types/inventory/playerInventory.d.ts.map +1 -1
- package/packages/game/dist/types/physics/fluid.d.ts +5 -0
- package/packages/game/dist/types/physics/fluid.d.ts.map +1 -1
- package/packages/game/dist/types/physics/movement.d.ts.map +1 -1
- package/packages/server/dist/index.cjs +175 -34
- package/packages/server/dist/index.d.cts +37 -5
- package/packages/server/dist/index.d.ts +37 -5
- package/packages/server/dist/index.js +173 -33
|
@@ -3,6 +3,7 @@ import type { EntitySystem } from '../entities/system.js';
|
|
|
3
3
|
export declare const PNOISE_SELF = 0;
|
|
4
4
|
export declare const PNOISE_WEAPON = 1;
|
|
5
5
|
export declare const PNOISE_IMPACT = 2;
|
|
6
|
+
export declare function player_noise(ent: Entity, context: EntitySystem): void;
|
|
6
7
|
export declare function PlayerNoise(who: Entity, where: {
|
|
7
8
|
x: number;
|
|
8
9
|
y: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noise.d.ts","sourceRoot":"","sources":["../../../src/ai/noise.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"noise.d.ts","sourceRoot":"","sources":["../../../src/ai/noise.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAA6C,MAAM,uBAAuB,CAAC;AAC1F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,eAAO,MAAM,WAAW,IAAI,CAAC;AAC7B,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,eAAO,MAAM,aAAa,IAAI,CAAC;AAU/B,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,QAQ9D;AAUD,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI,CAyC9H"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"targeting.d.ts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C;CAC3D;AAeD,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,oBAAoB,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI,CAWjG;AAED,MAAM,WAAW,kBAAkB;IACjC,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;CAC9C;AAED,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,oBAAoB,EAC3B,OAAO,EAAE,YAAY,EACrB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,IAAI,CAqDN;AA0BD,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,YAAY,EACrB,KAAK,EAAE,aAAa,GACnB,MAAM,GAAG,IAAI,CAmBf;AAmED,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,oBAAoB,EAC3B,OAAO,EAAE,YAAY,EACrB,KAAK,EAAE,aAAa,EACpB,WAAW,GAAE,gBAAqB,GACjC,OAAO,CAuCT;AAID,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAazF"}
|
|
@@ -5,6 +5,7 @@ import { WeaponItem, ArmorItem, PowerupItem, PowerArmorItem, KeyItem, HealthItem
|
|
|
5
5
|
import { PlayerWeaponStates } from '../combat/weapons/state.js';
|
|
6
6
|
import { Vec3 } from '@quake2ts/shared';
|
|
7
7
|
import { WeaponStateEnum } from '../combat/weapons/state.js';
|
|
8
|
+
import type { Entity } from '../entities/entity.js';
|
|
8
9
|
export { WeaponId, PowerupId };
|
|
9
10
|
export interface PlayerInventoryOptions {
|
|
10
11
|
readonly weapons?: readonly WeaponId[];
|
|
@@ -116,6 +117,13 @@ export interface PlayerClient {
|
|
|
116
117
|
owned_sphere?: any;
|
|
117
118
|
score?: number;
|
|
118
119
|
ping?: number;
|
|
120
|
+
player_noise_entity?: Entity;
|
|
121
|
+
sight_entity?: Entity;
|
|
122
|
+
sight_entity_time?: number;
|
|
123
|
+
sound_entity?: Entity;
|
|
124
|
+
sound_entity_time?: number;
|
|
125
|
+
sound2_entity?: Entity;
|
|
126
|
+
sound2_entity_time?: number;
|
|
119
127
|
}
|
|
120
128
|
export declare function createPlayerInventory(init?: PlayerInventoryOptions): PlayerInventory;
|
|
121
129
|
export declare function resetInventory(inventory: PlayerInventory): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playerInventory.d.ts","sourceRoot":"","sources":["../../../src/inventory/playerInventory.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,UAAU,EAEf,UAAU,EACV,KAAK,oBAAoB,EAE1B,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,QAAQ,EACR,SAAS,EACV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAc,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACnF,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC/G,OAAO,EAAE,kBAAkB,EAA4B,MAAM,4BAA4B,CAAC;AAC1F,OAAO,EAAE,IAAI,EAAa,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"playerInventory.d.ts","sourceRoot":"","sources":["../../../src/inventory/playerInventory.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,UAAU,EAEf,UAAU,EACV,KAAK,oBAAoB,EAE1B,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,QAAQ,EACR,SAAS,EACV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAc,KAAK,iBAAiB,EAA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,GAAG,OAAO,CA8B1F;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CA6BtF;AAED,wBAAgB,YAAY,CAAC,SAAS,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAuBtG;AAED,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,QAAQ,CAAC,YAAY,EAAE,SAAS,QAAQ,EAAE,CAAC;IAC3C,QAAQ,CAAC,aAAa,CAAC,EAAE,QAAQ,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACzC,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IACzD,QAAQ,CAAC,IAAI,EAAE,SAAS,KAAK,EAAE,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC;AAED,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,eAAe,GAAG,yBAAyB,CAU9F;AAED,wBAAgB,0BAA0B,CACxC,UAAU,EAAE,yBAAyB,EACrC,OAAO,GAAE,sBAA2B,GACnC,eAAe,CAgBjB"}
|
|
@@ -2,4 +2,9 @@ import { Entity } from '../entities/entity.js';
|
|
|
2
2
|
import { GameImports } from '../imports.js';
|
|
3
3
|
import { EntitySystem } from '../entities/system.js';
|
|
4
4
|
export declare function checkWater(ent: Entity, system: EntitySystem, imports: GameImports): void;
|
|
5
|
+
/**
|
|
6
|
+
* Applies current forces to an entity's velocity.
|
|
7
|
+
* @see PM_AddCurrents in p_move.c (Quake 2)
|
|
8
|
+
*/
|
|
9
|
+
export declare function SV_AddCurrents(ent: Entity, currentSpeed?: number): void;
|
|
5
10
|
//# sourceMappingURL=fluid.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fluid.d.ts","sourceRoot":"","sources":["../../../src/physics/fluid.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fluid.d.ts","sourceRoot":"","sources":["../../../src/physics/fluid.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,MAAM,EAAe,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAGrD,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI,CAwExF;AAsBD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,GAAE,MAAc,GAAG,IAAI,CA4B9E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"movement.d.ts","sourceRoot":"","sources":["../../../src/physics/movement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAgC,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAIL,IAAI,
|
|
1
|
+
{"version":3,"file":"movement.d.ts","sourceRoot":"","sources":["../../../src/physics/movement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAgC,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAIL,IAAI,EAML,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAa1D;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAyB9E;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAuC5G;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CACrB,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,IAAI,EACb,SAAS,EAAE,MAAM,GAChB,IAAI,CAoFN;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAYhG;AAWD;;;GAGG;AACH,wBAAgB,OAAO,CACrB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,MAAM,GAChB,OAAO,CAmLT"}
|
|
@@ -34,7 +34,8 @@ __export(index_exports, {
|
|
|
34
34
|
ClientState: () => ClientState,
|
|
35
35
|
DedicatedServer: () => DedicatedServer,
|
|
36
36
|
WebSocketNetDriver: () => WebSocketNetDriver,
|
|
37
|
-
createClient: () => createClient
|
|
37
|
+
createClient: () => createClient,
|
|
38
|
+
createServer: () => createServer
|
|
38
39
|
});
|
|
39
40
|
module.exports = __toCommonJS(index_exports);
|
|
40
41
|
|
|
@@ -151,7 +152,6 @@ var WebSocketNetDriver = class {
|
|
|
151
152
|
};
|
|
152
153
|
|
|
153
154
|
// src/dedicated.ts
|
|
154
|
-
var import_ws2 = require("ws");
|
|
155
155
|
var import_game = require("@quake2ts/game");
|
|
156
156
|
|
|
157
157
|
// src/client.ts
|
|
@@ -809,25 +809,71 @@ function writeTempEntity(writer, type, args) {
|
|
|
809
809
|
|
|
810
810
|
// src/dedicated.ts
|
|
811
811
|
var import_shared5 = require("@quake2ts/shared");
|
|
812
|
-
|
|
812
|
+
|
|
813
|
+
// src/transports/websocket.ts
|
|
814
|
+
var import_ws2 = require("ws");
|
|
815
|
+
var WebSocketTransport = class {
|
|
816
|
+
constructor() {
|
|
817
|
+
this.wss = null;
|
|
818
|
+
this.connectionCallback = null;
|
|
819
|
+
this.errorCallback = null;
|
|
820
|
+
}
|
|
821
|
+
async listen(port) {
|
|
822
|
+
return new Promise((resolve) => {
|
|
823
|
+
this.wss = new import_ws2.WebSocketServer({ port });
|
|
824
|
+
this.wss.on("listening", () => resolve());
|
|
825
|
+
this.wss.on("connection", (ws, req) => {
|
|
826
|
+
const driver = new WebSocketNetDriver();
|
|
827
|
+
driver.attach(ws);
|
|
828
|
+
if (this.connectionCallback) {
|
|
829
|
+
this.connectionCallback(driver, req);
|
|
830
|
+
}
|
|
831
|
+
});
|
|
832
|
+
this.wss.on("error", (err) => {
|
|
833
|
+
if (this.errorCallback) this.errorCallback(err);
|
|
834
|
+
});
|
|
835
|
+
});
|
|
836
|
+
}
|
|
837
|
+
close() {
|
|
838
|
+
if (this.wss) {
|
|
839
|
+
this.wss.close();
|
|
840
|
+
this.wss = null;
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
onConnection(callback) {
|
|
844
|
+
this.connectionCallback = callback;
|
|
845
|
+
}
|
|
846
|
+
onError(callback) {
|
|
847
|
+
this.errorCallback = callback;
|
|
848
|
+
}
|
|
849
|
+
};
|
|
850
|
+
|
|
851
|
+
// src/dedicated.ts
|
|
852
|
+
var DEFAULT_MAX_CLIENTS = 16;
|
|
813
853
|
var FRAME_RATE = 10;
|
|
814
854
|
var FRAME_TIME_MS = 1e3 / FRAME_RATE;
|
|
815
855
|
var DedicatedServer = class {
|
|
816
|
-
constructor(
|
|
817
|
-
this.port = port;
|
|
818
|
-
this.wss = null;
|
|
856
|
+
constructor(optionsOrPort = {}) {
|
|
819
857
|
this.game = null;
|
|
820
858
|
this.frameTimeout = null;
|
|
821
859
|
this.entityIndex = null;
|
|
822
860
|
// History buffer: Map<EntityIndex, HistoryArray>
|
|
823
861
|
this.history = /* @__PURE__ */ new Map();
|
|
824
862
|
this.backup = /* @__PURE__ */ new Map();
|
|
863
|
+
const options = typeof optionsOrPort === "number" ? { port: optionsOrPort } : optionsOrPort;
|
|
864
|
+
this.options = {
|
|
865
|
+
port: 27910,
|
|
866
|
+
maxPlayers: DEFAULT_MAX_CLIENTS,
|
|
867
|
+
deathmatch: true,
|
|
868
|
+
...options
|
|
869
|
+
};
|
|
870
|
+
this.transport = this.options.transport || new WebSocketTransport();
|
|
825
871
|
this.svs = {
|
|
826
872
|
initialized: false,
|
|
827
873
|
realTime: 0,
|
|
828
874
|
mapCmd: "",
|
|
829
875
|
spawnCount: 0,
|
|
830
|
-
clients: new Array(
|
|
876
|
+
clients: new Array(this.options.maxPlayers).fill(null),
|
|
831
877
|
lastHeartbeat: 0,
|
|
832
878
|
challenges: []
|
|
833
879
|
};
|
|
@@ -847,20 +893,114 @@ var DedicatedServer = class {
|
|
|
847
893
|
};
|
|
848
894
|
this.entityIndex = new import_shared4.CollisionEntityIndex();
|
|
849
895
|
}
|
|
896
|
+
setTransport(transport) {
|
|
897
|
+
if (this.svs.initialized) {
|
|
898
|
+
throw new Error("Cannot set transport after server started");
|
|
899
|
+
}
|
|
900
|
+
this.transport = transport;
|
|
901
|
+
}
|
|
902
|
+
async startServer(mapName) {
|
|
903
|
+
const map = mapName || this.options.mapName;
|
|
904
|
+
if (!map) {
|
|
905
|
+
throw new Error("No map specified");
|
|
906
|
+
}
|
|
907
|
+
await this.start(map);
|
|
908
|
+
}
|
|
909
|
+
stopServer() {
|
|
910
|
+
this.stop();
|
|
911
|
+
}
|
|
912
|
+
kickPlayer(clientId) {
|
|
913
|
+
if (clientId < 0 || clientId >= this.svs.clients.length) return;
|
|
914
|
+
const client = this.svs.clients[clientId];
|
|
915
|
+
if (client && client.state >= 2 /* Connected */) {
|
|
916
|
+
console.log(`Kicking client ${clientId}`);
|
|
917
|
+
if (client.netchan) {
|
|
918
|
+
const writer = new import_shared4.BinaryWriter();
|
|
919
|
+
writer.writeByte(import_shared4.ServerCommand.print);
|
|
920
|
+
writer.writeByte(2);
|
|
921
|
+
writer.writeString("Kicked by server.\n");
|
|
922
|
+
try {
|
|
923
|
+
const packet = client.netchan.transmit(writer.getData());
|
|
924
|
+
client.net.send(packet);
|
|
925
|
+
} catch (e) {
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
this.dropClient(client);
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
async changeMap(mapName) {
|
|
932
|
+
console.log(`Changing map to ${mapName}`);
|
|
933
|
+
this.multicast(
|
|
934
|
+
{ x: 0, y: 0, z: 0 },
|
|
935
|
+
import_game.MulticastType.All,
|
|
936
|
+
import_shared4.ServerCommand.print,
|
|
937
|
+
2,
|
|
938
|
+
`Changing map to ${mapName}...
|
|
939
|
+
`
|
|
940
|
+
);
|
|
941
|
+
if (this.frameTimeout) clearTimeout(this.frameTimeout);
|
|
942
|
+
this.sv.state = 1 /* Loading */;
|
|
943
|
+
this.sv.collisionModel = null;
|
|
944
|
+
this.sv.time = 0;
|
|
945
|
+
this.sv.frame = 0;
|
|
946
|
+
this.sv.configStrings.fill("");
|
|
947
|
+
this.sv.baselines.fill(null);
|
|
948
|
+
this.history.clear();
|
|
949
|
+
this.entityIndex = new import_shared4.CollisionEntityIndex();
|
|
950
|
+
await this.loadMap(mapName);
|
|
951
|
+
this.initGame();
|
|
952
|
+
for (const client of this.svs.clients) {
|
|
953
|
+
if (client && client.state >= 2 /* Connected */) {
|
|
954
|
+
client.edict = null;
|
|
955
|
+
client.state = 2 /* Connected */;
|
|
956
|
+
this.sendServerData(client);
|
|
957
|
+
client.netchan.writeReliableByte(import_shared4.ServerCommand.stufftext);
|
|
958
|
+
client.netchan.writeReliableString(`map ${mapName}
|
|
959
|
+
`);
|
|
960
|
+
this.handleBegin(client);
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
this.runFrame();
|
|
964
|
+
}
|
|
965
|
+
getConnectedClients() {
|
|
966
|
+
const list = [];
|
|
967
|
+
for (const client of this.svs.clients) {
|
|
968
|
+
if (client && client.state >= 2 /* Connected */) {
|
|
969
|
+
list.push({
|
|
970
|
+
id: client.index,
|
|
971
|
+
name: "Player",
|
|
972
|
+
// TODO: Parse userinfo for name
|
|
973
|
+
ping: client.ping,
|
|
974
|
+
address: "unknown"
|
|
975
|
+
});
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
return list;
|
|
979
|
+
}
|
|
850
980
|
async start(mapName) {
|
|
851
|
-
console.log(`Starting Dedicated Server on port ${this.port}...`);
|
|
981
|
+
console.log(`Starting Dedicated Server on port ${this.options.port}...`);
|
|
852
982
|
this.sv.name = mapName;
|
|
853
983
|
this.svs.initialized = true;
|
|
854
984
|
this.svs.spawnCount++;
|
|
855
|
-
this.
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
985
|
+
this.transport.onConnection((driver, info) => {
|
|
986
|
+
console.log("New connection", info ? `from ${info.socket?.remoteAddress}` : "");
|
|
987
|
+
this.handleConnection(driver, info);
|
|
988
|
+
});
|
|
989
|
+
this.transport.onError((err) => {
|
|
990
|
+
if (this.onServerError) this.onServerError(err);
|
|
859
991
|
});
|
|
992
|
+
await this.transport.listen(this.options.port);
|
|
993
|
+
await this.loadMap(mapName);
|
|
994
|
+
this.initGame();
|
|
995
|
+
this.runFrame();
|
|
996
|
+
console.log("Server started.");
|
|
997
|
+
}
|
|
998
|
+
async loadMap(mapName) {
|
|
860
999
|
try {
|
|
861
|
-
console.log(`Loading map ${
|
|
1000
|
+
console.log(`Loading map ${mapName}...`);
|
|
862
1001
|
this.sv.state = 1 /* Loading */;
|
|
863
|
-
|
|
1002
|
+
this.sv.name = mapName;
|
|
1003
|
+
const mapData = await import_promises.default.readFile(mapName);
|
|
864
1004
|
const arrayBuffer = mapData.buffer.slice(mapData.byteOffset, mapData.byteOffset + mapData.byteLength);
|
|
865
1005
|
const bspMap = (0, import_engine.parseBsp)(arrayBuffer);
|
|
866
1006
|
const planes = bspMap.planes.map((p) => {
|
|
@@ -937,7 +1077,10 @@ var DedicatedServer = class {
|
|
|
937
1077
|
console.log(`Map loaded successfully.`);
|
|
938
1078
|
} catch (e) {
|
|
939
1079
|
console.warn("Failed to load map:", e);
|
|
1080
|
+
if (this.onServerError) this.onServerError(e);
|
|
940
1081
|
}
|
|
1082
|
+
}
|
|
1083
|
+
initGame() {
|
|
941
1084
|
this.sv.startTime = Date.now();
|
|
942
1085
|
const imports = {
|
|
943
1086
|
trace: (start, mins, maxs, end, passent, contentmask) => {
|
|
@@ -994,7 +1137,6 @@ var DedicatedServer = class {
|
|
|
994
1137
|
};
|
|
995
1138
|
},
|
|
996
1139
|
pointcontents: (p) => 0,
|
|
997
|
-
// Empty
|
|
998
1140
|
linkentity: (ent) => {
|
|
999
1141
|
if (!this.entityIndex) return;
|
|
1000
1142
|
this.entityIndex.link({
|
|
@@ -1003,7 +1145,6 @@ var DedicatedServer = class {
|
|
|
1003
1145
|
mins: ent.mins,
|
|
1004
1146
|
maxs: ent.maxs,
|
|
1005
1147
|
contents: ent.solid === 0 ? 0 : 1,
|
|
1006
|
-
// Simplified contents
|
|
1007
1148
|
surfaceFlags: 0
|
|
1008
1149
|
});
|
|
1009
1150
|
},
|
|
@@ -1021,14 +1162,12 @@ var DedicatedServer = class {
|
|
|
1021
1162
|
};
|
|
1022
1163
|
this.game = (0, import_game.createGame)(imports, this, {
|
|
1023
1164
|
gravity: { x: 0, y: 0, z: -800 },
|
|
1024
|
-
deathmatch:
|
|
1165
|
+
deathmatch: this.options.deathmatch !== false
|
|
1025
1166
|
});
|
|
1026
1167
|
this.game.init(0);
|
|
1027
1168
|
this.game.spawnWorld();
|
|
1028
1169
|
this.populateBaselines();
|
|
1029
1170
|
this.sv.state = 2 /* Game */;
|
|
1030
|
-
this.runFrame();
|
|
1031
|
-
console.log("Server started.");
|
|
1032
1171
|
}
|
|
1033
1172
|
populateBaselines() {
|
|
1034
1173
|
if (!this.game) return;
|
|
@@ -1051,21 +1190,18 @@ var DedicatedServer = class {
|
|
|
1051
1190
|
renderfx: ent.renderfx,
|
|
1052
1191
|
solid: ent.solid,
|
|
1053
1192
|
sound: ent.sounds,
|
|
1054
|
-
// Assuming ent.sounds maps to 'sound' field in EntityState
|
|
1055
1193
|
event: 0
|
|
1056
1194
|
};
|
|
1057
1195
|
}
|
|
1058
1196
|
stop() {
|
|
1059
1197
|
if (this.frameTimeout) clearTimeout(this.frameTimeout);
|
|
1060
|
-
|
|
1198
|
+
this.transport.close();
|
|
1061
1199
|
this.game?.shutdown();
|
|
1062
1200
|
this.sv.state = 0 /* Dead */;
|
|
1063
1201
|
}
|
|
1064
|
-
handleConnection(
|
|
1065
|
-
const driver = new WebSocketNetDriver();
|
|
1066
|
-
driver.attach(ws);
|
|
1202
|
+
handleConnection(driver, info) {
|
|
1067
1203
|
let clientIndex = -1;
|
|
1068
|
-
for (let i = 0; i <
|
|
1204
|
+
for (let i = 0; i < this.options.maxPlayers; i++) {
|
|
1069
1205
|
if (this.svs.clients[i] === null || this.svs.clients[i].state === 0 /* Free */) {
|
|
1070
1206
|
clientIndex = i;
|
|
1071
1207
|
break;
|
|
@@ -1073,14 +1209,14 @@ var DedicatedServer = class {
|
|
|
1073
1209
|
}
|
|
1074
1210
|
if (clientIndex === -1) {
|
|
1075
1211
|
console.log("Server full, rejecting connection");
|
|
1076
|
-
|
|
1212
|
+
driver.disconnect();
|
|
1077
1213
|
return;
|
|
1078
1214
|
}
|
|
1079
1215
|
const client = createClient(clientIndex, driver);
|
|
1080
1216
|
client.lastMessage = this.sv.frame;
|
|
1081
1217
|
client.lastCommandTime = Date.now();
|
|
1082
1218
|
this.svs.clients[clientIndex] = client;
|
|
1083
|
-
console.log(`Client ${clientIndex} attached to slot from ${
|
|
1219
|
+
console.log(`Client ${clientIndex} attached to slot from ${info?.socket?.remoteAddress || "unknown"}`);
|
|
1084
1220
|
driver.onMessage((data) => this.onClientMessage(client, data));
|
|
1085
1221
|
driver.onClose(() => this.onClientDisconnect(client));
|
|
1086
1222
|
}
|
|
@@ -1093,6 +1229,9 @@ var DedicatedServer = class {
|
|
|
1093
1229
|
if (client.edict && this.game) {
|
|
1094
1230
|
this.game.clientDisconnect(client.edict);
|
|
1095
1231
|
}
|
|
1232
|
+
if (this.onClientDisconnected) {
|
|
1233
|
+
this.onClientDisconnected(client.index);
|
|
1234
|
+
}
|
|
1096
1235
|
client.state = 0 /* Free */;
|
|
1097
1236
|
this.svs.clients[client.index] = null;
|
|
1098
1237
|
if (this.entityIndex && client.edict) {
|
|
@@ -1141,7 +1280,7 @@ var DedicatedServer = class {
|
|
|
1141
1280
|
}
|
|
1142
1281
|
let status = `map: ${this.sv.name}
|
|
1143
1282
|
`;
|
|
1144
|
-
status += `players: ${activeClients} active (${
|
|
1283
|
+
status += `players: ${activeClients} active (${this.options.maxPlayers} max)
|
|
1145
1284
|
|
|
1146
1285
|
`;
|
|
1147
1286
|
status += `num score ping name lastmsg address qport rate
|
|
@@ -1182,6 +1321,9 @@ var DedicatedServer = class {
|
|
|
1182
1321
|
client.state = 2 /* Connected */;
|
|
1183
1322
|
client.userInfo = userInfo;
|
|
1184
1323
|
console.log(`Client ${client.index} connected: ${userInfo}`);
|
|
1324
|
+
if (this.onClientConnected) {
|
|
1325
|
+
this.onClientConnected(client.index, "Player");
|
|
1326
|
+
}
|
|
1185
1327
|
try {
|
|
1186
1328
|
this.sendServerData(client);
|
|
1187
1329
|
client.netchan.writeReliableByte(import_shared4.ServerCommand.stufftext);
|
|
@@ -1401,10 +1543,8 @@ var DedicatedServer = class {
|
|
|
1401
1543
|
pm_time: snapshot.pm_time,
|
|
1402
1544
|
pm_flags: snapshot.pmFlags,
|
|
1403
1545
|
gravity: Math.abs(snapshot.gravity.z),
|
|
1404
|
-
// Usually only Z is relevant for gravity value
|
|
1405
1546
|
delta_angles: snapshot.deltaAngles,
|
|
1406
1547
|
viewoffset: { x: 0, y: 0, z: 22 },
|
|
1407
|
-
// Default view offset if not in snapshot
|
|
1408
1548
|
viewangles: snapshot.viewangles,
|
|
1409
1549
|
kick_angles: snapshot.kick_angles,
|
|
1410
1550
|
gun_index: snapshot.gunindex,
|
|
@@ -1573,7 +1713,6 @@ var DedicatedServer = class {
|
|
|
1573
1713
|
}
|
|
1574
1714
|
if (i < 0) {
|
|
1575
1715
|
i = 0;
|
|
1576
|
-
} else if (i >= hist.length - 1) {
|
|
1577
1716
|
}
|
|
1578
1717
|
const s1 = hist[i];
|
|
1579
1718
|
const s2 = i + 1 < hist.length ? hist[i + 1] : s1;
|
|
@@ -1599,7 +1738,6 @@ var DedicatedServer = class {
|
|
|
1599
1738
|
maxs: { ...ent.maxs },
|
|
1600
1739
|
angles: { ...ent.angles },
|
|
1601
1740
|
link: true
|
|
1602
|
-
// assume linked if we are tracking it
|
|
1603
1741
|
});
|
|
1604
1742
|
ent.origin = origin;
|
|
1605
1743
|
ent.angles = angles;
|
|
@@ -1619,7 +1757,6 @@ var DedicatedServer = class {
|
|
|
1619
1757
|
mins: ent.mins,
|
|
1620
1758
|
maxs: ent.maxs,
|
|
1621
1759
|
contents: ent.solid === 0 ? 0 : 1,
|
|
1622
|
-
// Simplified
|
|
1623
1760
|
surfaceFlags: 0
|
|
1624
1761
|
});
|
|
1625
1762
|
});
|
|
@@ -1645,11 +1782,15 @@ var DedicatedServer = class {
|
|
|
1645
1782
|
}
|
|
1646
1783
|
}
|
|
1647
1784
|
};
|
|
1785
|
+
function createServer(options = {}) {
|
|
1786
|
+
return new DedicatedServer(options);
|
|
1787
|
+
}
|
|
1648
1788
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1649
1789
|
0 && (module.exports = {
|
|
1650
1790
|
ClientMessageParser,
|
|
1651
1791
|
ClientState,
|
|
1652
1792
|
DedicatedServer,
|
|
1653
1793
|
WebSocketNetDriver,
|
|
1654
|
-
createClient
|
|
1794
|
+
createClient,
|
|
1795
|
+
createServer
|
|
1655
1796
|
});
|
|
@@ -17,9 +17,28 @@ declare class WebSocketNetDriver implements NetDriver {
|
|
|
17
17
|
isConnected(): boolean;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
interface NetworkTransport {
|
|
21
|
+
listen(port: number): Promise<void>;
|
|
22
|
+
close(): void;
|
|
23
|
+
onConnection(callback: (driver: NetDriver, info?: any) => void): void;
|
|
24
|
+
onError(callback: (error: Error) => void): void;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface ClientInfo {
|
|
28
|
+
id: number;
|
|
29
|
+
name: string;
|
|
30
|
+
ping: number;
|
|
31
|
+
address: string;
|
|
32
|
+
}
|
|
33
|
+
interface ServerOptions {
|
|
34
|
+
mapName?: string;
|
|
35
|
+
maxPlayers?: number;
|
|
36
|
+
deathmatch?: boolean;
|
|
37
|
+
port?: number;
|
|
38
|
+
transport?: NetworkTransport;
|
|
39
|
+
}
|
|
20
40
|
declare class DedicatedServer implements GameEngine {
|
|
21
|
-
private
|
|
22
|
-
private wss;
|
|
41
|
+
private transport;
|
|
23
42
|
private svs;
|
|
24
43
|
private sv;
|
|
25
44
|
private game;
|
|
@@ -27,8 +46,20 @@ declare class DedicatedServer implements GameEngine {
|
|
|
27
46
|
private entityIndex;
|
|
28
47
|
private history;
|
|
29
48
|
private backup;
|
|
30
|
-
|
|
31
|
-
|
|
49
|
+
onClientConnected?: (clientId: number, name: string) => void;
|
|
50
|
+
onClientDisconnected?: (clientId: number) => void;
|
|
51
|
+
onServerError?: (error: Error) => void;
|
|
52
|
+
private options;
|
|
53
|
+
constructor(optionsOrPort?: ServerOptions | number);
|
|
54
|
+
setTransport(transport: NetworkTransport): void;
|
|
55
|
+
startServer(mapName?: string): Promise<void>;
|
|
56
|
+
stopServer(): void;
|
|
57
|
+
kickPlayer(clientId: number): void;
|
|
58
|
+
changeMap(mapName: string): Promise<void>;
|
|
59
|
+
getConnectedClients(): ClientInfo[];
|
|
60
|
+
private start;
|
|
61
|
+
private loadMap;
|
|
62
|
+
private initGame;
|
|
32
63
|
private populateBaselines;
|
|
33
64
|
private entityToState;
|
|
34
65
|
stop(): void;
|
|
@@ -58,6 +89,7 @@ declare class DedicatedServer implements GameEngine {
|
|
|
58
89
|
private recordHistory;
|
|
59
90
|
setLagCompensation(active: boolean, client?: Entity, lagMs?: number): void;
|
|
60
91
|
}
|
|
92
|
+
declare function createServer(options?: ServerOptions): DedicatedServer;
|
|
61
93
|
|
|
62
94
|
declare enum ClientState {
|
|
63
95
|
Free = 0,
|
|
@@ -126,4 +158,4 @@ declare class ClientMessageParser {
|
|
|
126
158
|
private parseStringCmd;
|
|
127
159
|
}
|
|
128
160
|
|
|
129
|
-
export { type Client, type ClientFrame, type ClientMessageHandler, ClientMessageParser, ClientState, DedicatedServer, WebSocketNetDriver, createClient };
|
|
161
|
+
export { type Client, type ClientFrame, type ClientInfo, type ClientMessageHandler, ClientMessageParser, ClientState, DedicatedServer, type NetworkTransport, type ServerOptions, WebSocketNetDriver, createClient, createServer };
|
|
@@ -17,9 +17,28 @@ declare class WebSocketNetDriver implements NetDriver {
|
|
|
17
17
|
isConnected(): boolean;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
interface NetworkTransport {
|
|
21
|
+
listen(port: number): Promise<void>;
|
|
22
|
+
close(): void;
|
|
23
|
+
onConnection(callback: (driver: NetDriver, info?: any) => void): void;
|
|
24
|
+
onError(callback: (error: Error) => void): void;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface ClientInfo {
|
|
28
|
+
id: number;
|
|
29
|
+
name: string;
|
|
30
|
+
ping: number;
|
|
31
|
+
address: string;
|
|
32
|
+
}
|
|
33
|
+
interface ServerOptions {
|
|
34
|
+
mapName?: string;
|
|
35
|
+
maxPlayers?: number;
|
|
36
|
+
deathmatch?: boolean;
|
|
37
|
+
port?: number;
|
|
38
|
+
transport?: NetworkTransport;
|
|
39
|
+
}
|
|
20
40
|
declare class DedicatedServer implements GameEngine {
|
|
21
|
-
private
|
|
22
|
-
private wss;
|
|
41
|
+
private transport;
|
|
23
42
|
private svs;
|
|
24
43
|
private sv;
|
|
25
44
|
private game;
|
|
@@ -27,8 +46,20 @@ declare class DedicatedServer implements GameEngine {
|
|
|
27
46
|
private entityIndex;
|
|
28
47
|
private history;
|
|
29
48
|
private backup;
|
|
30
|
-
|
|
31
|
-
|
|
49
|
+
onClientConnected?: (clientId: number, name: string) => void;
|
|
50
|
+
onClientDisconnected?: (clientId: number) => void;
|
|
51
|
+
onServerError?: (error: Error) => void;
|
|
52
|
+
private options;
|
|
53
|
+
constructor(optionsOrPort?: ServerOptions | number);
|
|
54
|
+
setTransport(transport: NetworkTransport): void;
|
|
55
|
+
startServer(mapName?: string): Promise<void>;
|
|
56
|
+
stopServer(): void;
|
|
57
|
+
kickPlayer(clientId: number): void;
|
|
58
|
+
changeMap(mapName: string): Promise<void>;
|
|
59
|
+
getConnectedClients(): ClientInfo[];
|
|
60
|
+
private start;
|
|
61
|
+
private loadMap;
|
|
62
|
+
private initGame;
|
|
32
63
|
private populateBaselines;
|
|
33
64
|
private entityToState;
|
|
34
65
|
stop(): void;
|
|
@@ -58,6 +89,7 @@ declare class DedicatedServer implements GameEngine {
|
|
|
58
89
|
private recordHistory;
|
|
59
90
|
setLagCompensation(active: boolean, client?: Entity, lagMs?: number): void;
|
|
60
91
|
}
|
|
92
|
+
declare function createServer(options?: ServerOptions): DedicatedServer;
|
|
61
93
|
|
|
62
94
|
declare enum ClientState {
|
|
63
95
|
Free = 0,
|
|
@@ -126,4 +158,4 @@ declare class ClientMessageParser {
|
|
|
126
158
|
private parseStringCmd;
|
|
127
159
|
}
|
|
128
160
|
|
|
129
|
-
export { type Client, type ClientFrame, type ClientMessageHandler, ClientMessageParser, ClientState, DedicatedServer, WebSocketNetDriver, createClient };
|
|
161
|
+
export { type Client, type ClientFrame, type ClientInfo, type ClientMessageHandler, ClientMessageParser, ClientState, DedicatedServer, type NetworkTransport, type ServerOptions, WebSocketNetDriver, createClient, createServer };
|