mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-15 14:52:35 +02:00
Add more tolerance for if player sessions are connected to dead entities (#1818)
* Add more tolerance for if some calamity causes a player session to be connected to a dead entity * Fix build issues w/ previous commit (oops)
This commit is contained in:
@@ -133,6 +133,17 @@ namespace Robust.Server.Player
|
||||
if (AttachedEntity == null)
|
||||
return;
|
||||
|
||||
#if EXCEPTION_TOLERANCE
|
||||
if (AttachedEntity.Deleted)
|
||||
{
|
||||
Logger.Warning($"Player \"{this}\" was attached to an entity that was deleted. THIS SHOULD NEVER HAPPEN, BUT DOES.");
|
||||
// We can't contact ActorSystem because trying to fire an entity event would crash.
|
||||
// Work around it.
|
||||
((IPlayerSession) this).SetAttachedEntity(null);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
var detachPlayer = new DetachPlayerEvent();
|
||||
AttachedEntity.EntityManager.EventBus.RaiseLocalEvent(AttachedEntity.Uid, detachPlayer, false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user