From 718b37fb2c8bbe97214ec74b2b44f357493f400d Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Thu, 28 May 2020 20:09:14 +0200 Subject: [PATCH] Fixes ServerPortalComponent spamming exceptions and crashing server if spawned manually. Also makes the prototype abstract because it doesn't work straight up. --- .../Movement/ServerPortalComponent.cs | 35 ++++++++++--------- .../Prototypes/Entities/Items/teleporters.yml | 1 + 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/Content.Server/GameObjects/Components/Movement/ServerPortalComponent.cs b/Content.Server/GameObjects/Components/Movement/ServerPortalComponent.cs index 9e1955decf..4426355aee 100644 --- a/Content.Server/GameObjects/Components/Movement/ServerPortalComponent.cs +++ b/Content.Server/GameObjects/Components/Movement/ServerPortalComponent.cs @@ -193,25 +193,26 @@ namespace Content.Server.GameObjects.Components.Movement public void TryPortalEntity(IEntity entity) { - - if (!immuneEntities.Contains(entity)) + if (immuneEntities.Contains(entity) || _connectingTeleporter == null) { - var position = _connectingTeleporter.Transform.GridPosition; - var soundPlayer = EntitySystem.Get(); - - // Departure - // Do we need to rate-limit sounds to stop ear BLAST? - soundPlayer.Play(_departureSound, entity.Transform.GridPosition); - entity.Transform.DetachParent(); - entity.Transform.GridPosition = position; - soundPlayer.Play(_arrivalSound, entity.Transform.GridPosition); - TryChangeState(PortalState.RecentlyTeleported); - // To stop spam teleporting. Could potentially look at adding a timer to flush this from the portal - immuneEntities.Add(entity); - _connectingTeleporter.GetComponent().immuneEntities.Add(entity); - Timer.Spawn(TimeSpan.FromSeconds(_individualPortalCooldown), () => releaseCooldown(entity)); - StartCooldown(); + return; } + + var position = _connectingTeleporter.Transform.GridPosition; + var soundPlayer = EntitySystem.Get(); + + // Departure + // Do we need to rate-limit sounds to stop ear BLAST? + soundPlayer.Play(_departureSound, entity.Transform.GridPosition); + entity.Transform.DetachParent(); + entity.Transform.GridPosition = position; + soundPlayer.Play(_arrivalSound, entity.Transform.GridPosition); + TryChangeState(PortalState.RecentlyTeleported); + // To stop spam teleporting. Could potentially look at adding a timer to flush this from the portal + immuneEntities.Add(entity); + _connectingTeleporter.GetComponent().immuneEntities.Add(entity); + Timer.Spawn(TimeSpan.FromSeconds(_individualPortalCooldown), () => releaseCooldown(entity)); + StartCooldown(); } } } diff --git a/Resources/Prototypes/Entities/Items/teleporters.yml b/Resources/Prototypes/Entities/Items/teleporters.yml index fe1feb1a91..72852fae7a 100644 --- a/Resources/Prototypes/Entities/Items/teleporters.yml +++ b/Resources/Prototypes/Entities/Items/teleporters.yml @@ -48,6 +48,7 @@ - type: entity name: Portal id: Portal + abstract: true description: "Portal to another location" components: - type: Collidable