Skip to content

Fix/Restricted Restart#7

Open
Arkmind wants to merge 2 commits intomainfrom
fix/restricted-restart
Open

Fix/Restricted Restart#7
Arkmind wants to merge 2 commits intomainfrom
fix/restricted-restart

Conversation

@Arkmind
Copy link
Collaborator

@Arkmind Arkmind commented Feb 21, 2026

Fix/Restricted Restart

Players in restricted areas or in combat being kicked by the server (restart, crash, admin) should not be handled by the SwarmObserver

Copilot

(technical)

This pull request introduces a new mechanism to filter which players should be observed by the SwarmObserver system in the MissionServer class. The changes ensure that only relevant players are processed, improving efficiency and reducing unnecessary logging.

Player observation filtering:

  • Added the shouldClientBeObserved method to determine if a player should be observed based on their status and kick-off reason, skipping players who are not alive or were disconnected for specific reasons. (src/SwarmObserver/scripts/5_Mission/MissionServer.c)
  • Updated the PlayerDisconnected logic to use the new filtering method, skipping observation and logging when a player does not meet the criteria. (src/SwarmObserver/scripts/5_Mission/MissionServer.c)

@Arkmind Arkmind requested a review from Swarm-log February 21, 2026 20:48
@Arkmind Arkmind self-assigned this Feb 21, 2026
Copilot AI review requested due to automatic review settings February 21, 2026 20:49
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to prevent SwarmObserver from processing restricted-area/combat-logout handling when players disconnect due to server/admin mass-kicks or shutdown/restart scenarios.

Changes:

  • Adds a new shouldClientBeObserved helper to decide whether SwarmObserver should process a disconnect.
  • Updates MissionServer.PlayerDisconnected to skip SwarmObserver handling when the helper returns false.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


if (!shouldClientBeObserved(player))
{
Print("[SwarmObserver] Player " + (data ? data.PlayerName : "unknown") + " is not subject to observation, skipping");
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the early-return path, the method calls super.PlayerDisconnected(...) and returns without cleaning up SwarmObserverLogoutManager data (and without the combat state cleanup below). This leaves per-uid logout entries around after a restart/kick-all event and can cause memory growth / stale data on later disconnects. Consider removing stored logout data (and any combat state) before returning, or moving cleanup into a finally-style block that runs for both observed and skipped disconnects.

Suggested change
Print("[SwarmObserver] Player " + (data ? data.PlayerName : "unknown") + " is not subject to observation, skipping");
Print("[SwarmObserver] Player " + (data ? data.PlayerName : "unknown") + " is not subject to observation, skipping");
// Even if the player is not observed, ensure we clean up any stored logout data and combat state
if (data)
SwarmObserverLogoutManager.RemoveLogoutData(uid);
if (player)
GetCombatStateManager().RemoveCombatState(player);

Copilot uses AI. Check for mistakes.
else
Print("[SwarmObserver] No logout data found for uid: " + uid);

if (!shouldClientBeObserved(player))
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldClientBeObserved returns false when player is null, but this file’s existing disconnect flow explicitly accounts for PlayerDisconnected often being invoked without a valid player/identity (hence storing logout data in OnClientDisconnectedEvent). With the new check, a null player will cause SwarmObserver processing to be skipped even for normal voluntary disconnects, preventing restricted-area grace periods/combat notifications from ever running. To keep the intended behavior, base the decision on stored logout data (e.g., store the kickoff reason/flag in SwarmObserverLogoutData during OnClientDisconnectedEvent) or treat player == null as observable when data exists.

Suggested change
if (!shouldClientBeObserved(player))
// Determine whether this client should be observed.
// If the player entity is missing but we have stored logout data, we still want to process it.
bool observeClient;
if (!player && data)
observeClient = true;
else
observeClient = shouldClientBeObserved(player);
if (!observeClient)

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants