From b36d22128a904fad18626428ffdce49b4110d751 Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Mon, 11 Jan 2021 02:21:38 +0100 Subject: [PATCH] Fix ghosts throwing exception on round restart. Done by re-organizing the cleanup sequence so that players are moved back to lobby and have their mind wiped *before* entities are deleted. The mind system always tries to ensure players have a ghost even in the most wacky circumstances like entity deletion. This goes contrary to the fact that we need to delete all entities to clean the game state. So cleaning all the minds should be done first. --- Content.Server/GameTicking/GameTicker.cs | 26 ++++++++++++------------ 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Content.Server/GameTicking/GameTicker.cs b/Content.Server/GameTicking/GameTicker.cs index e4229c43f5..58434232e0 100644 --- a/Content.Server/GameTicking/GameTicker.cs +++ b/Content.Server/GameTicking/GameTicker.cs @@ -684,6 +684,19 @@ namespace Content.Server.GameTicking /// private void _resettingCleanup() { + // Move everybody currently in the server to lobby. + foreach (var player in PlayerManager.GetAllPlayers()) + { + _playerJoinLobby(player); + } + + // Delete the minds of everybody. + // TODO: Maybe move this into a separate manager? + foreach (var unCastData in PlayerManager.GetAllPlayerData()) + { + unCastData.ContentData()?.WipeMind(); + } + // Delete all entities. foreach (var entity in _entityManager.GetEntities().ToList()) { @@ -694,13 +707,6 @@ namespace Content.Server.GameTicking _mapManager.Restart(); - // Delete the minds of everybody. - // TODO: Maybe move this into a separate manager? - foreach (var unCastData in PlayerManager.GetAllPlayerData()) - { - unCastData.ContentData()?.WipeMind(); - } - // Clear up any game rules. foreach (var rule in _gameRules) { @@ -709,12 +715,6 @@ namespace Content.Server.GameTicking _gameRules.Clear(); - // Move everybody currently in the server to lobby. - foreach (var player in PlayerManager.GetAllPlayers()) - { - _playerJoinLobby(player); - } - foreach (var system in _entitySystemManager.AllSystems) { if (system is IResettingEntitySystem resetting)