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.
This commit is contained in:
@@ -684,6 +684,19 @@ namespace Content.Server.GameTicking
|
||||
/// </summary>
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user