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
|
@@ -12193,6 +12193,9 @@ var ClientNetworkHandler = class {
|
|
|
12193
12193
|
}
|
|
12194
12194
|
}
|
|
12195
12195
|
onLayout(layout) {
|
|
12196
|
+
if (this.callbacks?.onLayout) {
|
|
12197
|
+
this.callbacks.onLayout(layout);
|
|
12198
|
+
}
|
|
12196
12199
|
}
|
|
12197
12200
|
onInventory(inventory) {
|
|
12198
12201
|
this.inventory = [...inventory];
|
|
@@ -14409,6 +14412,7 @@ var ScoreboardManager = class {
|
|
|
14409
14412
|
entry.frags = existing.frags;
|
|
14410
14413
|
entry.deaths = existing.deaths;
|
|
14411
14414
|
entry.ping = existing.ping;
|
|
14415
|
+
entry.team = existing.team;
|
|
14412
14416
|
}
|
|
14413
14417
|
this.players.set(id, entry);
|
|
14414
14418
|
}
|
|
@@ -14455,7 +14459,8 @@ var ScoreboardManager = class {
|
|
|
14455
14459
|
deaths: 0,
|
|
14456
14460
|
ping: 0,
|
|
14457
14461
|
skin: info.skin,
|
|
14458
|
-
model: info.model
|
|
14462
|
+
model: info.model,
|
|
14463
|
+
team: void 0
|
|
14459
14464
|
};
|
|
14460
14465
|
}
|
|
14461
14466
|
// Method to update scores explicitly
|
|
@@ -14468,6 +14473,105 @@ var ScoreboardManager = class {
|
|
|
14468
14473
|
this.notifyUpdate();
|
|
14469
14474
|
}
|
|
14470
14475
|
}
|
|
14476
|
+
/**
|
|
14477
|
+
* Parses the layout string from svc_layout and updates player scores.
|
|
14478
|
+
* Expected format example:
|
|
14479
|
+
* xv 32 yv 32 string "%4i %4i %-12.12s %4i"
|
|
14480
|
+
* followed by values? No, the string command draws text.
|
|
14481
|
+
* In Q2, the layout message sends a series of drawing commands.
|
|
14482
|
+
* The server formats the string:
|
|
14483
|
+
* "xv 32 yv %i string \"%4i %4i %-12.12s %4i\" "
|
|
14484
|
+
* The client receives the formatting commands AND the string data.
|
|
14485
|
+
* Wait, svc_layout in Q2 sends a single string that the client parses and draws.
|
|
14486
|
+
* The string contains tokens.
|
|
14487
|
+
* Example:
|
|
14488
|
+
* "xv 32 yv 32 string \" 10 50 PlayerName 10\""
|
|
14489
|
+
* We need to regex this.
|
|
14490
|
+
*/
|
|
14491
|
+
processScoreboardMessage(layout) {
|
|
14492
|
+
const stringCmdRegex = /string\s+"([^"]+)"/g;
|
|
14493
|
+
let match;
|
|
14494
|
+
while ((match = stringCmdRegex.exec(layout)) !== null) {
|
|
14495
|
+
const content = match[1];
|
|
14496
|
+
if (content.length > 20) {
|
|
14497
|
+
const fragsStr = content.substring(0, 4).trim();
|
|
14498
|
+
const pingStr = content.substring(5, 9).trim();
|
|
14499
|
+
const nameStr = content.substring(10, 22).trim();
|
|
14500
|
+
const frags = parseInt(fragsStr, 10);
|
|
14501
|
+
const ping = parseInt(pingStr, 10);
|
|
14502
|
+
if (!isNaN(frags) && !isNaN(ping) && nameStr.length > 0) {
|
|
14503
|
+
for (const player of this.players.values()) {
|
|
14504
|
+
if (player.name === nameStr) {
|
|
14505
|
+
player.frags = frags;
|
|
14506
|
+
player.ping = ping;
|
|
14507
|
+
}
|
|
14508
|
+
}
|
|
14509
|
+
}
|
|
14510
|
+
}
|
|
14511
|
+
}
|
|
14512
|
+
this.notifyUpdate();
|
|
14513
|
+
}
|
|
14514
|
+
};
|
|
14515
|
+
|
|
14516
|
+
// src/chat.ts
|
|
14517
|
+
var ChatManager = class {
|
|
14518
|
+
constructor(sendCommand) {
|
|
14519
|
+
this.history = [];
|
|
14520
|
+
this.maxHistory = 100;
|
|
14521
|
+
this.listeners = [];
|
|
14522
|
+
this.sendCommand = sendCommand;
|
|
14523
|
+
}
|
|
14524
|
+
addListener(listener) {
|
|
14525
|
+
this.listeners.push(listener);
|
|
14526
|
+
}
|
|
14527
|
+
removeListener(listener) {
|
|
14528
|
+
const index = this.listeners.indexOf(listener);
|
|
14529
|
+
if (index !== -1) {
|
|
14530
|
+
this.listeners.splice(index, 1);
|
|
14531
|
+
}
|
|
14532
|
+
}
|
|
14533
|
+
sendChatMessage(message, team = false) {
|
|
14534
|
+
const escaped = message.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
14535
|
+
const cmd = team ? `say_team "${escaped}"` : `say "${escaped}"`;
|
|
14536
|
+
this.sendCommand(cmd);
|
|
14537
|
+
}
|
|
14538
|
+
addMessage(level, text) {
|
|
14539
|
+
let sender;
|
|
14540
|
+
let content = text;
|
|
14541
|
+
let team = false;
|
|
14542
|
+
const match = text.match(/^([^:]+):\s(.*)$/);
|
|
14543
|
+
const teamMatch = text.match(/^\(([^)]+)\):\s(.*)$/);
|
|
14544
|
+
if (teamMatch) {
|
|
14545
|
+
sender = teamMatch[1];
|
|
14546
|
+
content = teamMatch[2];
|
|
14547
|
+
team = true;
|
|
14548
|
+
} else if (match) {
|
|
14549
|
+
sender = match[1];
|
|
14550
|
+
content = match[2];
|
|
14551
|
+
team = false;
|
|
14552
|
+
}
|
|
14553
|
+
const message = {
|
|
14554
|
+
timestamp: Date.now(),
|
|
14555
|
+
sender,
|
|
14556
|
+
text: content,
|
|
14557
|
+
team
|
|
14558
|
+
};
|
|
14559
|
+
this.history.push(message);
|
|
14560
|
+
if (this.history.length > this.maxHistory) {
|
|
14561
|
+
this.history.shift();
|
|
14562
|
+
}
|
|
14563
|
+
if (sender) {
|
|
14564
|
+
this.notifyListeners(sender, content, team);
|
|
14565
|
+
}
|
|
14566
|
+
}
|
|
14567
|
+
getHistory() {
|
|
14568
|
+
return [...this.history];
|
|
14569
|
+
}
|
|
14570
|
+
notifyListeners(sender, message, team) {
|
|
14571
|
+
for (const listener of this.listeners) {
|
|
14572
|
+
listener(sender, message, team);
|
|
14573
|
+
}
|
|
14574
|
+
}
|
|
14471
14575
|
};
|
|
14472
14576
|
|
|
14473
14577
|
// src/input/bindings.ts
|
|
@@ -15396,6 +15500,11 @@ function createClient(imports) {
|
|
|
15396
15500
|
let optionsFactory;
|
|
15397
15501
|
const configStrings = new ClientConfigStrings();
|
|
15398
15502
|
const scoreboardManager = new ScoreboardManager(configStrings);
|
|
15503
|
+
const chatManager = new ChatManager((cmd) => {
|
|
15504
|
+
if (imports.engine.cmd) {
|
|
15505
|
+
imports.engine.cmd.executeText(cmd);
|
|
15506
|
+
}
|
|
15507
|
+
});
|
|
15399
15508
|
const blendState = createBlendState();
|
|
15400
15509
|
let currentBlend = [0, 0, 0, 0];
|
|
15401
15510
|
let pendingDamage = 0;
|
|
@@ -15446,7 +15555,10 @@ function createClient(imports) {
|
|
|
15446
15555
|
const multiplayerFactory = new MultiplayerMenuFactory(menuSystem, multiplayer);
|
|
15447
15556
|
demoHandler.setCallbacks({
|
|
15448
15557
|
onCenterPrint: (msg) => cg.ParseCenterPrint(msg, 0, false),
|
|
15449
|
-
onPrint: (level, msg) =>
|
|
15558
|
+
onPrint: (level, msg) => {
|
|
15559
|
+
cg.NotifyMessage(0, msg, false);
|
|
15560
|
+
chatManager.addMessage(level, msg);
|
|
15561
|
+
},
|
|
15450
15562
|
onConfigString: (index, str3) => {
|
|
15451
15563
|
configStrings.set(index, str3);
|
|
15452
15564
|
cg.ParseConfigString(index, str3);
|
|
@@ -15477,6 +15589,10 @@ function createClient(imports) {
|
|
|
15477
15589
|
},
|
|
15478
15590
|
onDamage: (indicators) => {
|
|
15479
15591
|
pendingDamage = 0.5;
|
|
15592
|
+
},
|
|
15593
|
+
onLayout: (layout) => {
|
|
15594
|
+
scoreboardManager.processScoreboardMessage(layout);
|
|
15595
|
+
scoreboardManager.notifyUpdate();
|
|
15480
15596
|
}
|
|
15481
15597
|
});
|
|
15482
15598
|
demoPlayback.setHandler(demoHandler);
|
|
@@ -16173,6 +16289,13 @@ function createClient(imports) {
|
|
|
16173
16289
|
// Scoreboard API
|
|
16174
16290
|
getScoreboard() {
|
|
16175
16291
|
return scoreboardManager.getScoreboard();
|
|
16292
|
+
},
|
|
16293
|
+
// Chat API
|
|
16294
|
+
sendChatMessage(message, team = false) {
|
|
16295
|
+
chatManager.sendChatMessage(message, team);
|
|
16296
|
+
},
|
|
16297
|
+
getChatHistory() {
|
|
16298
|
+
return chatManager.getHistory();
|
|
16176
16299
|
}
|
|
16177
16300
|
};
|
|
16178
16301
|
scoreboardManager.addListener((data) => {
|
|
@@ -16180,6 +16303,11 @@ function createClient(imports) {
|
|
|
16180
16303
|
clientExports.onScoreboardUpdate(data);
|
|
16181
16304
|
}
|
|
16182
16305
|
});
|
|
16306
|
+
chatManager.addListener((sender, message, team) => {
|
|
16307
|
+
if (clientExports.onChatMessage) {
|
|
16308
|
+
clientExports.onChatMessage(sender, message, team);
|
|
16309
|
+
}
|
|
16310
|
+
});
|
|
16183
16311
|
return clientExports;
|
|
16184
16312
|
}
|
|
16185
16313
|
export {
|