Fix server crashing when portal is deleted (#2157)
-Fix server crashing when using the teleporter
This commit is contained in:
@@ -87,7 +87,7 @@ namespace Content.Server.GameObjects.Components.Movement
|
||||
|
||||
public void TryChangeState(PortalState targetState)
|
||||
{
|
||||
if (Owner == null)
|
||||
if (Owner == null || Deleted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -102,6 +102,9 @@ namespace Content.Server.GameObjects.Components.Movement
|
||||
|
||||
private void ReleaseCooldown(IEntity entity)
|
||||
{
|
||||
if (Owner == null || Deleted)
|
||||
return;
|
||||
|
||||
if (ImmuneEntities.Contains(entity))
|
||||
{
|
||||
ImmuneEntities.Remove(entity);
|
||||
@@ -189,7 +192,6 @@ namespace Content.Server.GameObjects.Components.Movement
|
||||
// Departure
|
||||
// Do we need to rate-limit sounds to stop ear BLAST?
|
||||
soundPlayer.PlayAtCoords(_departureSound, entity.Transform.Coordinates);
|
||||
entity.Transform.AttachToGridOrMap();
|
||||
entity.Transform.Coordinates = position;
|
||||
soundPlayer.PlayAtCoords(_arrivalSound, entity.Transform.Coordinates);
|
||||
TryChangeState(PortalState.RecentlyTeleported);
|
||||
|
||||
@@ -222,7 +222,7 @@ namespace Content.Server.GameObjects.Components.Movement
|
||||
public void Teleport(IEntity user, Vector2 vector)
|
||||
{
|
||||
// Messy maybe?
|
||||
var targetGrid = user.ToCoordinates(vector);
|
||||
var targetGrid = user.Transform.Coordinates.WithPosition(vector);
|
||||
var soundPlayer = EntitySystem.Get<AudioSystem>();
|
||||
|
||||
// If portals use those, otherwise just move em over
|
||||
|
||||
Reference in New Issue
Block a user