mirror of
https://github.com/exogen/t2-mapper.git
synced 2026-04-20 20:05:37 +00:00
begin live server support
This commit is contained in:
parent
0c9ddb476a
commit
e4ae265184
368 changed files with 17756 additions and 7738 deletions
69
scripts/t2-server-list.ts
Normal file
69
scripts/t2-server-list.ts
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
/**
|
||||
* Queries the TribesNext master server for active game servers and prints
|
||||
* their details to the console. Useful for testing the master query protocol
|
||||
* without going through the browser.
|
||||
*
|
||||
* Usage:
|
||||
* npm run server-list
|
||||
*/
|
||||
|
||||
import { queryServerList } from "../relay/masterQuery.js";
|
||||
|
||||
const MASTER_SERVER =
|
||||
process.env.T2_MASTER_SERVER || "master.tribesnext.com";
|
||||
|
||||
async function main() {
|
||||
console.log(`Master server: ${MASTER_SERVER}`);
|
||||
console.log("Querying server list...\n");
|
||||
|
||||
try {
|
||||
const servers = await queryServerList(MASTER_SERVER);
|
||||
|
||||
if (servers.length === 0) {
|
||||
console.log("No servers found.");
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`Found ${servers.length} server(s):\n`);
|
||||
|
||||
// Print as a table
|
||||
const nameWidth = Math.max(
|
||||
11,
|
||||
...servers.map((s) => s.name.length),
|
||||
);
|
||||
const header = [
|
||||
"Server Name".padEnd(nameWidth),
|
||||
"Map".padEnd(20),
|
||||
"Type".padEnd(18),
|
||||
"Mod".padEnd(12),
|
||||
"Players".padEnd(9),
|
||||
"Ping".padEnd(6),
|
||||
"Address",
|
||||
].join(" ");
|
||||
|
||||
console.log(header);
|
||||
console.log("-".repeat(header.length));
|
||||
|
||||
for (const server of servers) {
|
||||
console.log(
|
||||
[
|
||||
server.name.padEnd(nameWidth),
|
||||
server.mapName.padEnd(20),
|
||||
server.gameType.padEnd(18),
|
||||
server.mod.padEnd(12),
|
||||
`${server.playerCount}/${server.maxPlayers}`.padEnd(9),
|
||||
`${server.ping}ms`.padEnd(6),
|
||||
server.address,
|
||||
].join(" "),
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Query failed:", e);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
main().catch((e) => {
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue