diff --git a/Content.Server/Teleportation/HandTeleporterSystem.cs b/Content.Server/Teleportation/HandTeleporterSystem.cs
index 29cde5d741d6..d7c7ea0cf23f 100644
--- a/Content.Server/Teleportation/HandTeleporterSystem.cs
+++ b/Content.Server/Teleportation/HandTeleporterSystem.cs
@@ -6,6 +6,7 @@
using Content.Shared.Teleportation.Systems;
using Robust.Server.Audio;
using Robust.Server.GameObjects;
+using Content.Server.Popups;
namespace Content.Server.Teleportation;
@@ -18,6 +19,7 @@ public sealed class HandTeleporterSystem : EntitySystem
[Dependency] private readonly LinkedEntitySystem _link = default!;
[Dependency] private readonly AudioSystem _audio = default!;
[Dependency] private readonly SharedDoAfterSystem _doafter = default!;
+ [Dependency] private readonly PopupSystem _popupSystem = default!;
///
public override void Initialize()
@@ -55,6 +57,18 @@ private void OnUseInHand(EntityUid uid, HandTeleporterComponent component, UseIn
if (xform.ParentUid != xform.GridUid)
return;
+ //SS220 teleport_grid_resrtictions start
+ if (component.FirstPortalsGrid == null)
+ component.FirstPortalsGrid = xform.GridUid;
+ /*
+ if (component.FirstPortalsGrid != xform.GridUid)
+ {
+ HandlePortalUpdating(uid, component, args.User);
+ return;
+ }
+ */
+ //SS220 teleport_grid_resrtictions end
+
var doafterArgs = new DoAfterArgs(EntityManager, args.User, component.PortalCreationDelay, new TeleporterDoAfterEvent(), uid, used: uid)
{
BreakOnDamage = true,
@@ -90,6 +104,25 @@ private void HandlePortalUpdating(EntityUid uid, HandTeleporterComponent compone
_adminLogger.Add(LogType.EntitySpawn, LogImpact.Low, $"{ToPrettyString(user):player} opened {ToPrettyString(component.FirstPortal.Value)} at {Transform(component.FirstPortal.Value).Coordinates} using {ToPrettyString(uid)}");
_audio.PlayPvs(component.NewPortalSound, uid);
}
+ //SS220 teleport_grid_resrtictions start
+ else if (component.FirstPortalsGrid != xform.GridUid)
+ {
+ // Logging
+ var portalStrings = "";
+ portalStrings += ToPrettyString(component.FirstPortal!.Value);
+ if (portalStrings != "")
+ _adminLogger.Add(LogType.EntityDelete, LogImpact.Low, $"{ToPrettyString(user):player} closed {portalStrings} with {ToPrettyString(uid)}, not the same grid");
+
+ // Clear first portal
+ QueueDel(component.FirstPortal!.Value);
+
+ _popupSystem.PopupEntity(Loc.GetString("hand-teleporter-component-not-the-same-grid-message"), uid, Shared.Popups.PopupType.Medium);
+
+ component.FirstPortalsGrid = null;
+ component.FirstPortal = null;
+ _audio.PlayPvs(component.ClearPortalsSound, uid);
+ }
+ //SS220 teleport_grid_resrtictions end
else if (Deleted(component.SecondPortal))
{
var timeout = EnsureComp(user);
@@ -114,6 +147,8 @@ private void HandlePortalUpdating(EntityUid uid, HandTeleporterComponent compone
QueueDel(component.FirstPortal!.Value);
QueueDel(component.SecondPortal!.Value);
+ component.FirstPortalsGrid = null;//SS220 teleport_grid_resrtictions
+
component.FirstPortal = null;
component.SecondPortal = null;
_audio.PlayPvs(component.ClearPortalsSound, uid);
diff --git a/Content.Shared/Teleportation/Components/HandTeleporterComponent.cs b/Content.Shared/Teleportation/Components/HandTeleporterComponent.cs
index 6abd4a7d2114..5b6baefe3109 100644
--- a/Content.Shared/Teleportation/Components/HandTeleporterComponent.cs
+++ b/Content.Shared/Teleportation/Components/HandTeleporterComponent.cs
@@ -1,4 +1,4 @@
-using Content.Shared.DoAfter;
+using Content.Shared.DoAfter;
using Robust.Shared.Audio;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
@@ -40,6 +40,9 @@ public sealed partial class HandTeleporterComponent : Component
///
[DataField("portalCreationDelay")]
public float PortalCreationDelay = 1.0f;
+
+ [ViewVariables]
+ public EntityUid? FirstPortalsGrid = null;//SS220 teleport_grid_resrtictions
}
[Serializable, NetSerializable]
diff --git a/Resources/Locale/ru-RU/ss220/hand-teleporter-component.ftl b/Resources/Locale/ru-RU/ss220/hand-teleporter-component.ftl
new file mode 100644
index 000000000000..03ac388c63e9
--- /dev/null
+++ b/Resources/Locale/ru-RU/ss220/hand-teleporter-component.ftl
@@ -0,0 +1 @@
+hand-teleporter-component-not-the-same-grid-message = Неизвестное пространство, сброс портала.