Remove name fallback from RCON ping matching

This commit is contained in:
2026-10-06 21:31:13 -04:00
parent a9059754fb
commit baee64a067
4 changed files with 12 additions and 53 deletions
-26
View File
@@ -47,11 +47,6 @@ export function freshTelemetry(report: GameTelemetry | undefined, now: number, a
try { parseGameEvent(report); return true; } catch { return false; }
}
// RCON strips CoD display colors and surrounding column padding from names.
function playerMatchName(name: string): string {
return name.replace(/\^\d/g, '').trim();
}
function playerMatchGuid(guid: string, game: string | null | undefined, source: 'rcon' | 'telemetry'): string {
if (game !== 't6') return guid;
// T6 status prints hexadecimal account IDs; telemetry sends decimal IDs.
@@ -81,34 +76,13 @@ export function selectServerObservation<T extends ServerObservation>(server: T,
const pings = new Map<string, number | null>();
const guidKey = (guid: string, source: 'rcon' | 'telemetry') => playerMatchGuid(guid, server.game, source);
if (fresh && raw.last_map === report.map) {
const byName = new Map<string, StatusPlayer | null>();
const nameCounts = new Map<string, number>();
const telemetryGuids = new Set(report.players.map(player => guidKey(player.guid, 'telemetry')));
for (const player of report.players) {
const name = playerMatchName(player.name);
nameCounts.set(name, (nameCounts.get(name) ?? 0) + 1);
}
for (const player of raw.roster ?? []) {
const name = playerMatchName(player.name);
if (name) byName.set(name, byName.has(name) ? null : player);
const ping = player.ping;
if (player.guid) {
const guid = guidKey(player.guid, 'rcon');
pings.set(guid, pings.has(guid) || ping === null || !Number.isSafeInteger(ping) || ping < 0 ? null : ping);
}
}
for (const player of report.players) {
// A GUID match always wins, including ambiguous/invalid readings.
const guid = guidKey(player.guid, 'telemetry');
if (pings.has(guid)) continue;
const name = playerMatchName(player.name);
const match = byName.get(name);
// Names must be unique in both rosters. Never borrow a player
// already identified by another telemetry player's GUID.
if (!match || nameCounts.get(name) !== 1 || (match.guid && telemetryGuids.has(guidKey(match.guid, 'rcon')))) continue;
const ping = match.ping;
if (ping !== null && Number.isSafeInteger(ping) && ping >= 0) pings.set(guid, ping);
}
}
// New reports carry persisted anchors through both SSE and HTTP. Keep
// the fallback for telemetry saved before server timing was included.