From 07fe950c91aedb5ca2454ae79c540487cd031089 Mon Sep 17 00:00:00 2001
From: Flipp Syder <76629141+vulppine@users.noreply.github.com>
Date: Sat, 24 Sep 2022 02:51:02 -0700
Subject: [PATCH] fix crash on devicenet address adding (#11457)
---
Content.Server/DeviceNetwork/Systems/DeviceListSystem.cs | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/Content.Server/DeviceNetwork/Systems/DeviceListSystem.cs b/Content.Server/DeviceNetwork/Systems/DeviceListSystem.cs
index 18e9b7a46c..a5ea2d5bf0 100644
--- a/Content.Server/DeviceNetwork/Systems/DeviceListSystem.cs
+++ b/Content.Server/DeviceNetwork/Systems/DeviceListSystem.cs
@@ -25,6 +25,9 @@ public sealed class DeviceListSystem : SharedDeviceListSystem
///
/// Gets the given device list as a dictionary
///
+ ///
+ /// If any entity in the device list is pre-map init, it will show the entity UID of the device instead.
+ ///
public Dictionary GetDeviceList(EntityUid uid, DeviceListComponent? deviceList = null)
{
if (!Resolve(uid, ref deviceList))
@@ -37,7 +40,11 @@ public sealed class DeviceListSystem : SharedDeviceListSystem
if (!TryComp(deviceUid, out DeviceNetworkComponent? deviceNet))
continue;
- devices.Add(deviceNet.Address, deviceUid);
+ var address = MetaData(deviceUid).EntityLifeStage == EntityLifeStage.MapInitialized
+ ? deviceNet.Address
+ : $"UID: {deviceUid.ToString()}";
+
+ devices.Add(address, deviceUid);
}