Skip to content

Allow Quit to Main Menu#2659

Open
MistaOmega wants to merge 67 commits into
SubnauticaNitrox:masterfrom
MistaOmega:2545/quit_game
Open

Allow Quit to Main Menu#2659
MistaOmega wants to merge 67 commits into
SubnauticaNitrox:masterfrom
MistaOmega:2545/quit_game

Conversation

@MistaOmega
Copy link
Copy Markdown
Contributor

Draft whilst I keep looking for bugs and broken stuff that has come from this

added some event cleanups for PlayerCinematics.cs and StoryGoalInitialSyncProcessor.cs
removed application.quit from IngameMenu_QuitGame_Patch.cs
- Properly unhook events for multiplayer session lifecycle.
- Add `OnSessionEnd` handling to session-scoped behaviours for automatic cleanup.
- Clear registries and caches on session end.
- Fix issues w/ stale references in service lifetimes.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 25, 2026

Test Results

251 tests  +11   250 ✅ +11   8s ⏱️ ±0s
  1 suites ± 0     1 💤 ± 0 
  1 files   ± 0     0 ❌ ± 0 

Results for commit 8882e18. ± Comparison against base commit b98858a.

This pull request removes 2 and adds 13 tests. Note that renamed tests count towards both.
Nitrox.Model.Packets.Processors.PacketProcessorTest ‑ SameAmountOfServerPacketProcessors
Nitrox.Test.Server.Helper.XORRandomTest ‑ TestMeanGeneration
Nitrox.Model.DataStructures.NitroxIdTest ‑ CompareToReturnsOneForNull
Nitrox.Model.DataStructures.NitroxIdTest ‑ CompareToReturnsZeroForEqualIds
Nitrox.Model.DataStructures.NitroxIdTest ‑ CompareToUsesUnderlyingGuidOrdering
Nitrox.Model.DataStructures.NitroxIdTest ‑ DifferentGuidEquality
Nitrox.Model.DataStructures.NitroxIdTest ‑ EqualIdsHaveSameHashCode
Nitrox.Model.DataStructures.NitroxIdTest ‑ EqualsObjectReturnsFalseForDifferentType
Nitrox.Model.DataStructures.NitroxIdTest ‑ IncrementAdvancesId
Nitrox.Model.DataStructures.NitroxIdTest ‑ IncrementWrapsAroundFromMaxValue
Nitrox.Model.DataStructures.NitroxIdTest ‑ SameReferenceEquality
Nitrox.Server.Subnautica.Models.GameLogic.Entities.SubnauticaUwePrefabFactoryTest ‑ TryGetPossiblePrefabsAsync_ConcurrentCallsSameBiome_LoadsDistributionOnce
…

♻️ This comment has been updated with latest results.

@MistaOmega
Copy link
Copy Markdown
Contributor Author

MistaOmega commented Jan 25, 2026

Cleanups are as follows at the moment:

Non-destroyed Monos

components added in Multiplayer.InitMonoBehaviours():

  • UnderwaterStateTracker
  • PrecursorTracker
  • PlayerMovementBroadcaster
  • PlayerDeathBroadcaster
  • PlayerStatsBroadcaster
  • EntityPositionBroadcaster
  • BuildingHandler
  • MovementBroadcaster

Static Collections

  • NitroxEntity.gameObjectsById
  • EntityPositionBroadcaster.watchingEntityIds / splineUpdatesById
  • VirtualCyclops.cacheColliderCopy
  • CyclopsPawn.controllers

Lambda Event Subs

  • StoryGoalInitialSyncProcessor.cs:155: Multiplayer.OnLoadingComplete += () => ...
  • PlayerCinematics.cs:71: Multiplayer.OnLoadingComplete += () => ...

Couple Singletons with State

  • BuildingHandler.Main - holds queues and operations
  • MovementBroadcaster.Instance - holds replicator dictionary

Random Stuff I've Tested

  • Leave Server 1, Join Server 2: Good, no shared state, pos, stats, etc.
  • Leave and rejoin piloting cyclops: bugged (fixed)
  • Leave and rejoin inside cyclops: good
  • Leave and rejoin in seamoth: good
  • Leave and rejoin, have story event play: both synced
  • Leave and rejoin and build base pieces: good
  • Leave and rejoin a base built prior: good
  • Leave and rejoin within a base: good

Bug Tracking

Cyclops Rejoin Handling

  • Be driving the cyclops, leave and rejoin
  • Throws NPE within CyclopsPawn
  • Due to the Controllers not being cleared
  • Sln: Write designated cleanup code into VirtualCyclops.cs

@MistaOmega MistaOmega marked this pull request as ready for review January 27, 2026 20:43
weblate and others added 24 commits January 30, 2026 14:17
…trox#2644)

Co-authored-by: dartasen <10561268+dartasen@users.noreply.github.com>
This caused proton to be launched without a proper Steam exe.
Co-authored-by: Coding-Hen <8798074+Coding-Hen@users.noreply.github.com>
Previously this caused user to require deleting the cache file in order to start the server successfully.
Co-authored-by: misterbubb <106004257+misterbubb@users.noreply.github.com>
namespace NitroxClient.MonoBehaviours;

public class PlayerMovementBroadcaster : MonoBehaviour
public class PlayerMovementBroadcaster : NitroxSessionBehaviour
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we need NitroxSessionBehaviour if don't implement OnSessionEnd()?

NitroxEntity.ClearAll();

// clear remote players
PlayerManager remotePlayerManager = NitroxServiceLocator.LocateService<PlayerManager>();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
PlayerManager remotePlayerManager = NitroxServiceLocator.LocateService<PlayerManager>();
PlayerManager remotePlayerManager = Resolve<PlayerManager>();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I can't seem to call resolve in a static context. So I think current impl is the best currently

@MistaOmega
Copy link
Copy Markdown
Contributor Author

Seen these, will work through soon <3

@CherrieTheShifter

This comment was marked as spam.

added some event cleanups for PlayerCinematics.cs and StoryGoalInitialSyncProcessor.cs
removed application.quit from IngameMenu_QuitGame_Patch.cs
- Properly unhook events for multiplayer session lifecycle.
- Add `OnSessionEnd` handling to session-scoped behaviours for automatic cleanup.
- Clear registries and caches on session end.
- Fix issues w/ stale references in service lifetimes.
# Conflicts:
#	NitroxClient/GameLogic/PlayerManager.cs
@dartasen dartasen added the Status: Waiting for reviews Pull Request is waiting for code review label May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status: Waiting for reviews Pull Request is waiting for code review

Projects

None yet

Development

Successfully merging this pull request may close these issues.