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:
20kdc
2021-06-10 09:29:25 +02:00
committed by GitHub
parent a8ee7be844
commit 796f1480a8
+11
View File
@@ -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);