From 21fd997554969ad915026ba4b5aecc6ebee2ff06 Mon Sep 17 00:00:00 2001 From: John Gross Date: Sat, 7 Dec 2019 14:11:27 -0800 Subject: [PATCH] Support NPC identities in GetGridOwnerName --- Torch/Utils/MiscExtensions.cs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/Torch/Utils/MiscExtensions.cs b/Torch/Utils/MiscExtensions.cs index 2ab227e..46078dc 100644 --- a/Torch/Utils/MiscExtensions.cs +++ b/Torch/Utils/MiscExtensions.cs @@ -1,17 +1,12 @@ using System; -using System.Collections.Generic; using System.IO; using System.Linq; using System.Net; -using System.Text; using System.Threading; -using System.Threading.Tasks; -using Sandbox; using Sandbox.Engine.Multiplayer; using Sandbox.Game.Entities; using Sandbox.Game.World; using Steamworks; -using VRage.Game.ModAPI; namespace Torch.Utils { @@ -49,8 +44,10 @@ namespace Torch.Utils int count = stream.Read(buffer, streamPosition, buffer.Length - streamPosition); if (count == 0) break; + streamPosition += count; } + var result = new byte[streamPosition]; Array.Copy(buffer, 0, result, 0, result.Length); _streamBuffer.Value.SetTarget(buffer); @@ -67,7 +64,18 @@ namespace Torch.Utils { if (grid.BigOwners.Count == 0 || grid.BigOwners[0] == 0) return "nobody"; - return MyMultiplayer.Static.GetMemberName(MySession.Static.Players.TryGetSteamId(grid.BigOwners[0])); + + var identityId = grid.BigOwners[0]; + + if (MySession.Static.Players.IdentityIsNpc(identityId)) + { + var identity = MySession.Static.Players.TryGetIdentity(identityId); + return identity.DisplayName; + } + else + { + return MyMultiplayer.Static.GetMemberName(MySession.Static.Players.TryGetSteamId(identityId)); + } } } -} +} \ No newline at end of file