Support NPC identities in GetGridOwnerName

This commit is contained in:
John Gross
2019-12-07 14:11:27 -08:00
parent 23b0318591
commit 21fd997554

View File

@@ -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));
}
}
}
}
}