Skip to content

Commit 873b267

Browse files
Antag Selection Logging (#5847)
## Short description Adds more robust logging to antag selection. (Aka, late joins, and round number) As I always say when I use AI, I used AI to help me, because I had no clue what coderabbit was talking about on that second comment but I figured "yeah I probably shouldn't flood the database". ## Why we need to add this So we can group Grafana entries by round and track latejoin selections <img width="1143" height="258" alt="image" src="https://github.com/user-attachments/assets/246ac900-5a5f-406e-8428-add38b7e458d" /> ## Checks - [X] I do not require assistance to complete the PR. - [X] Before posting/requesting review of a PR, I have verified that the changes work. - [X] I have added screenshots/videos of the changes, or this PR does not change in-game mechanics. - [X] I affirm that my changes are licensed under the [MIT License](https://github.com/ss14Starlight/space-station-14/blob/Starlight/LICENSE.TXT) and grant permission for use in this repository under its conditions. Nothing player facing here
1 parent e6a1e85 commit 873b267

3 files changed

Lines changed: 513 additions & 435 deletions

File tree

Content.Server/Antag/AntagSelectionSystem.API.Assignment.cs

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,18 @@ public bool TryAssignNextAvailableAntag(Entity<AntagSelectionComponent> gameRule
338338
ICommonSession session,
339339
int players)
340340
{
341+
#region Starlight
342+
return TryAssignNextAvailableAntag(gameRule, session, players, out _);
343+
}
344+
345+
/// <summary>
346+
/// Tries to find an open antag slot for a given player and returns the definition that was assigned.
347+
/// </summary>
348+
private bool TryAssignNextAvailableAntag(Entity<AntagSelectionComponent> gameRule, ICommonSession session, int players, [NotNullWhen(true)] out AntagSpecifierPrototype? assignedAntag)
349+
{
350+
assignedAntag = null;
351+
#endregion
352+
341353
foreach (var selector in gameRule.Comp.Antags)
342354
{
343355
if (!Proto.Resolve(selector.Proto, out var antag))
@@ -348,8 +360,13 @@ public bool TryAssignNextAvailableAntag(Entity<AntagSelectionComponent> gameRule
348360
continue;
349361

350362
// Try and assign this antag, if we fail, then try the next definition!
351-
if (TryMakeAntag(gameRule, antag, session))
352-
return true;
363+
#region Starlight
364+
if (!TryMakeAntag(gameRule, antag, session))
365+
continue;
366+
367+
assignedAntag = antag;
368+
return true;
369+
#endregion
353370
}
354371

355372
return false;
@@ -385,8 +402,13 @@ public bool TryMakeLateJoinAntag(ICommonSession session)
385402

386403
foreach (var (uid, antag) in rules)
387404
{
388-
if (TryAssignNextAvailableAntag((uid, antag), session, players))
389-
return true;
405+
#region Starlight
406+
if (!TryAssignNextAvailableAntag((uid, antag), session, players, out var assignedAntag))
407+
continue;
408+
409+
RecordLateJoinAntagAssignment((uid, antag), assignedAntag); // logging
410+
return true;
411+
#endregion
390412
}
391413

392414
return false;

0 commit comments

Comments
 (0)