diff --git a/Content.Server/Administration/Commands/AGhost.cs b/Content.Server/Administration/Commands/AGhost.cs index e0f19fe5d3..f48c7a3372 100644 --- a/Content.Server/Administration/Commands/AGhost.cs +++ b/Content.Server/Administration/Commands/AGhost.cs @@ -47,7 +47,12 @@ namespace Content.Server.Administration.Commands if (canReturn) { - ghost.Name = mind.CharacterName ?? string.Empty; + // TODO: Remove duplication between all this and "GamePreset.OnGhostAttempt()"... + if(!string.IsNullOrWhiteSpace(mind.CharacterName)) + ghost.Name = mind.CharacterName; + else if (!string.IsNullOrWhiteSpace(mind.Session?.Name)) + ghost.Name = mind.Session.Name; + mind.Visit(ghost); } else diff --git a/Content.Server/GameTicking/Presets/GamePreset.cs b/Content.Server/GameTicking/Presets/GamePreset.cs index ae2c61cb2d..b1cb93b771 100644 --- a/Content.Server/GameTicking/Presets/GamePreset.cs +++ b/Content.Server/GameTicking/Presets/GamePreset.cs @@ -73,7 +73,14 @@ namespace Content.Server.GameTicking.Presets var entityManager = IoCManager.Resolve(); var ghost = entityManager.SpawnEntity("MobObserver", position.ToMap(entityManager)); - ghost.Name = mind.CharacterName ?? string.Empty; + + // Try setting the ghost entity name to either the character name or the player name. + // If all else fails, it'll default to the default entity prototype name, "observer". + // However, that should rarely happen. + if(!string.IsNullOrWhiteSpace(mind.CharacterName)) + ghost.Name = mind.CharacterName; + else if (!string.IsNullOrWhiteSpace(mind.Session?.Name)) + ghost.Name = mind.Session.Name; var ghostComponent = ghost.GetComponent(); EntitySystem.Get().SetCanReturnToBody(ghostComponent, canReturn); diff --git a/Content.Shared/Ghost/SharedGhostSystem.cs b/Content.Shared/Ghost/SharedGhostSystem.cs index 7b54432150..a7e5d23fa1 100644 --- a/Content.Shared/Ghost/SharedGhostSystem.cs +++ b/Content.Shared/Ghost/SharedGhostSystem.cs @@ -7,11 +7,6 @@ namespace Content.Shared.Ghost { public abstract class SharedGhostSystem : EntitySystem { - public override void Initialize() - { - base.Initialize(); - } - public void SetCanReturnToBody(SharedGhostComponent component, bool canReturn) { if (component.CanReturnToBody == canReturn) diff --git a/Resources/Changelog/Parts/ghost.yml b/Resources/Changelog/Parts/ghost.yml new file mode 100644 index 0000000000..768cc83c74 --- /dev/null +++ b/Resources/Changelog/Parts/ghost.yml @@ -0,0 +1,4 @@ +author: Zumorica +changes: + - type: Fix # One of the following: Add, Remove, Tweak, Fix + message: Fix ghosts having empty names under certain conditions.