Support NPC identities in GetGridOwnerName
This commit is contained in:
@@ -1,17 +1,12 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Text;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Sandbox;
|
|
||||||
using Sandbox.Engine.Multiplayer;
|
using Sandbox.Engine.Multiplayer;
|
||||||
using Sandbox.Game.Entities;
|
using Sandbox.Game.Entities;
|
||||||
using Sandbox.Game.World;
|
using Sandbox.Game.World;
|
||||||
using Steamworks;
|
using Steamworks;
|
||||||
using VRage.Game.ModAPI;
|
|
||||||
|
|
||||||
namespace Torch.Utils
|
namespace Torch.Utils
|
||||||
{
|
{
|
||||||
@@ -49,8 +44,10 @@ namespace Torch.Utils
|
|||||||
int count = stream.Read(buffer, streamPosition, buffer.Length - streamPosition);
|
int count = stream.Read(buffer, streamPosition, buffer.Length - streamPosition);
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
streamPosition += count;
|
streamPosition += count;
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = new byte[streamPosition];
|
var result = new byte[streamPosition];
|
||||||
Array.Copy(buffer, 0, result, 0, result.Length);
|
Array.Copy(buffer, 0, result, 0, result.Length);
|
||||||
_streamBuffer.Value.SetTarget(buffer);
|
_streamBuffer.Value.SetTarget(buffer);
|
||||||
@@ -67,7 +64,18 @@ namespace Torch.Utils
|
|||||||
{
|
{
|
||||||
if (grid.BigOwners.Count == 0 || grid.BigOwners[0] == 0)
|
if (grid.BigOwners.Count == 0 || grid.BigOwners[0] == 0)
|
||||||
return "nobody";
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user