API14 Updates - Migrate to IPlayerState (#113)
- use IPlayerState for DalamudUtilService and make things less async - make LocationInfo work with ContentFinderData Co-authored-by: Tsubasahane <wozaiha@gmail.com> Co-authored-by: defnotken <itsdefnotken@gmail.com> Reviewed-on: #113 Reviewed-by: cake <cake@noreply.git.lightless-sync.org> Co-authored-by: Tsubasa <tsubasa@noreply.git.lightless-sync.org> Co-committed-by: Tsubasa <tsubasa@noreply.git.lightless-sync.org>
This commit was merged in pull request #113.
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -348,3 +348,6 @@ MigrationBackup/
|
|||||||
|
|
||||||
# Ionide (cross platform F# VS Code tools) working folder
|
# Ionide (cross platform F# VS Code tools) working folder
|
||||||
.ionide/
|
.ionide/
|
||||||
|
|
||||||
|
# idea
|
||||||
|
/.idea
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ public sealed class TransientResourceManager : DisposableMediatorSubscriberBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string PlayerPersistentDataKey => _dalamudUtil.GetPlayerNameAsync().GetAwaiter().GetResult() + "_" + _dalamudUtil.GetHomeWorldIdAsync().GetAwaiter().GetResult();
|
private string PlayerPersistentDataKey => _dalamudUtil.GetPlayerName() + "_" + _dalamudUtil.GetHomeWorldId();
|
||||||
private ConcurrentDictionary<ObjectKind, HashSet<string>> SemiTransientResources
|
private ConcurrentDictionary<ObjectKind, HashSet<string>> SemiTransientResources
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public sealed class Plugin : IDalamudPlugin
|
|||||||
IFramework framework, IObjectTable objectTable, IClientState clientState, ICondition condition, IChatGui chatGui,
|
IFramework framework, IObjectTable objectTable, IClientState clientState, ICondition condition, IChatGui chatGui,
|
||||||
IGameGui gameGui, IDtrBar dtrBar, IPluginLog pluginLog, ITargetManager targetManager, INotificationManager notificationManager,
|
IGameGui gameGui, IDtrBar dtrBar, IPluginLog pluginLog, ITargetManager targetManager, INotificationManager notificationManager,
|
||||||
ITextureProvider textureProvider, IContextMenu contextMenu, IGameInteropProvider gameInteropProvider, IGameConfig gameConfig,
|
ITextureProvider textureProvider, IContextMenu contextMenu, IGameInteropProvider gameInteropProvider, IGameConfig gameConfig,
|
||||||
ISigScanner sigScanner, INamePlateGui namePlateGui, IAddonLifecycle addonLifecycle)
|
ISigScanner sigScanner, INamePlateGui namePlateGui, IAddonLifecycle addonLifecycle, IPlayerState playerState)
|
||||||
{
|
{
|
||||||
NativeDll.Initialize(pluginInterface.AssemblyLocation.DirectoryName);
|
NativeDll.Initialize(pluginInterface.AssemblyLocation.DirectoryName);
|
||||||
if (!Directory.Exists(pluginInterface.ConfigDirectory.FullName))
|
if (!Directory.Exists(pluginInterface.ConfigDirectory.FullName))
|
||||||
@@ -219,6 +219,7 @@ public sealed class Plugin : IDalamudPlugin
|
|||||||
gameData,
|
gameData,
|
||||||
targetManager,
|
targetManager,
|
||||||
gameConfig,
|
gameConfig,
|
||||||
|
playerState,
|
||||||
sp.GetRequiredService<ActorObjectService>(),
|
sp.GetRequiredService<ActorObjectService>(),
|
||||||
sp.GetRequiredService<BlockedCharacterHandler>(),
|
sp.GetRequiredService<BlockedCharacterHandler>(),
|
||||||
sp.GetRequiredService<LightlessMediator>(),
|
sp.GetRequiredService<LightlessMediator>(),
|
||||||
|
|||||||
@@ -450,7 +450,7 @@ public class CharaDataGposeTogetherManager : DisposableMediatorSubscriberBase
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
var loc = await _dalamudUtil.GetMapDataAsync().ConfigureAwait(false);
|
var loc = _dalamudUtil.GetMapData();
|
||||||
worldData.LocationInfo = loc;
|
worldData.LocationInfo = loc;
|
||||||
|
|
||||||
if (_forceResendWorldData || worldData != _lastWorldData)
|
if (_forceResendWorldData || worldData != _lastWorldData)
|
||||||
|
|||||||
@@ -254,7 +254,7 @@ public sealed partial class CharaDataManager : DisposableMediatorSubscriberBase
|
|||||||
|
|
||||||
Logger.LogTrace("Attaching World data {data}", worldData);
|
Logger.LogTrace("Attaching World data {data}", worldData);
|
||||||
|
|
||||||
worldData.LocationInfo = await _dalamudUtilService.GetMapDataAsync().ConfigureAwait(false);
|
worldData.LocationInfo = _dalamudUtilService.GetMapData();
|
||||||
|
|
||||||
Logger.LogTrace("World data serialized: {data}", worldData);
|
Logger.LogTrace("World data serialized: {data}", worldData);
|
||||||
|
|
||||||
|
|||||||
@@ -186,8 +186,8 @@ public sealed class CharaDataNearbyManager : DisposableMediatorSubscriberBase
|
|||||||
var previousPoses = _nearbyData.Keys.ToList();
|
var previousPoses = _nearbyData.Keys.ToList();
|
||||||
_nearbyData.Clear();
|
_nearbyData.Clear();
|
||||||
|
|
||||||
var ownLocation = await _dalamudUtilService.RunOnFrameworkThread(() => _dalamudUtilService.GetMapData()).ConfigureAwait(false);
|
var ownLocation = _dalamudUtilService.GetMapData();
|
||||||
var player = await _dalamudUtilService.RunOnFrameworkThread(() => _dalamudUtilService.GetPlayerCharacter()).ConfigureAwait(false);
|
var player = await _dalamudUtilService.GetPlayerCharacterAsync().ConfigureAwait(false);
|
||||||
var currentServer = player.CurrentWorld;
|
var currentServer = player.CurrentWorld;
|
||||||
var playerPos = player.Position;
|
var playerPos = player.Position;
|
||||||
|
|
||||||
|
|||||||
@@ -576,7 +576,7 @@ public sealed class ZoneChatService : DisposableMediatorSubscriberBase, IHostedS
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var location = await _dalamudUtilService.GetMapDataAsync().ConfigureAwait(false);
|
var location = _dalamudUtilService.GetMapData();
|
||||||
var territoryId = (ushort)location.TerritoryId;
|
var territoryId = (ushort)location.TerritoryId;
|
||||||
var worldId = (ushort)location.ServerId;
|
var worldId = (ushort)location.ServerId;
|
||||||
|
|
||||||
@@ -702,7 +702,7 @@ public sealed class ZoneChatService : DisposableMediatorSubscriberBase, IHostedS
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var worldId = (ushort)await _dalamudUtilService.GetWorldIdAsync().ConfigureAwait(false);
|
var worldId = (ushort)_dalamudUtilService.GetWorldId();
|
||||||
return definition.Descriptor with { WorldId = worldId };
|
return definition.Descriptor with { WorldId = worldId };
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -1161,7 +1161,7 @@ public sealed class ZoneChatService : DisposableMediatorSubscriberBase, IHostedS
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return _dalamudUtilService.GetPlayerNameAsync().ConfigureAwait(false).GetAwaiter().GetResult();
|
return _dalamudUtilService.GetPlayerName();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -241,7 +241,7 @@ internal class ContextMenuService : IHostedService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var senderCid = (await _dalamudUtil.GetCIDAsync().ConfigureAwait(false)).ToString().GetHash256();
|
var senderCid = _dalamudUtil.GetCID().ToString().GetHash256();
|
||||||
var receiverCid = DalamudUtilService.GetHashedCIDFromPlayerPointer(targetData.Address);
|
var receiverCid = DalamudUtilService.GetHashedCIDFromPlayerPointer(targetData.Address);
|
||||||
|
|
||||||
_logger.LogInformation("Sending pair request: sender {SenderCid}, receiver {ReceiverCid}", senderCid, receiverCid);
|
_logger.LogInformation("Sending pair request: sender {SenderCid}, receiver {ReceiverCid}", senderCid, receiverCid);
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
|||||||
private readonly ICondition _condition;
|
private readonly ICondition _condition;
|
||||||
private readonly IDataManager _gameData;
|
private readonly IDataManager _gameData;
|
||||||
private readonly IGameConfig _gameConfig;
|
private readonly IGameConfig _gameConfig;
|
||||||
|
private readonly IPlayerState _playerState;
|
||||||
private readonly BlockedCharacterHandler _blockedCharacterHandler;
|
private readonly BlockedCharacterHandler _blockedCharacterHandler;
|
||||||
private readonly IFramework _framework;
|
private readonly IFramework _framework;
|
||||||
private readonly IGameGui _gameGui;
|
private readonly IGameGui _gameGui;
|
||||||
@@ -60,7 +61,7 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
|||||||
private Lazy<ulong> _cid;
|
private Lazy<ulong> _cid;
|
||||||
|
|
||||||
public DalamudUtilService(ILogger<DalamudUtilService> logger, IClientState clientState, IObjectTable objectTable, IFramework framework,
|
public DalamudUtilService(ILogger<DalamudUtilService> logger, IClientState clientState, IObjectTable objectTable, IFramework framework,
|
||||||
IGameGui gameGui, ICondition condition, IDataManager gameData, ITargetManager targetManager, IGameConfig gameConfig,
|
IGameGui gameGui, ICondition condition, IDataManager gameData, ITargetManager targetManager, IGameConfig gameConfig, IPlayerState playerState,
|
||||||
ActorObjectService actorObjectService, BlockedCharacterHandler blockedCharacterHandler, LightlessMediator mediator, PerformanceCollectorService performanceCollector,
|
ActorObjectService actorObjectService, BlockedCharacterHandler blockedCharacterHandler, LightlessMediator mediator, PerformanceCollectorService performanceCollector,
|
||||||
LightlessConfigService configService, PlayerPerformanceConfigService playerPerformanceConfigService, Lazy<PairFactory> pairFactory)
|
LightlessConfigService configService, PlayerPerformanceConfigService playerPerformanceConfigService, Lazy<PairFactory> pairFactory)
|
||||||
{
|
{
|
||||||
@@ -72,6 +73,7 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
|||||||
_condition = condition;
|
_condition = condition;
|
||||||
_gameData = gameData;
|
_gameData = gameData;
|
||||||
_gameConfig = gameConfig;
|
_gameConfig = gameConfig;
|
||||||
|
_playerState = playerState;
|
||||||
_actorObjectService = actorObjectService;
|
_actorObjectService = actorObjectService;
|
||||||
_targetManager = targetManager;
|
_targetManager = targetManager;
|
||||||
_blockedCharacterHandler = blockedCharacterHandler;
|
_blockedCharacterHandler = blockedCharacterHandler;
|
||||||
@@ -95,6 +97,12 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
|||||||
TerritoryData = new(() => BuildTerritoryData(clientLanguage));
|
TerritoryData = new(() => BuildTerritoryData(clientLanguage));
|
||||||
TerritoryDataEnglish = new(() => BuildTerritoryData(Dalamud.Game.ClientLanguage.English));
|
TerritoryDataEnglish = new(() => BuildTerritoryData(Dalamud.Game.ClientLanguage.English));
|
||||||
MapData = new(() => BuildMapData(clientLanguage));
|
MapData = new(() => BuildMapData(clientLanguage));
|
||||||
|
ContentFinderData = new Lazy<Dictionary<uint, string>>(() =>
|
||||||
|
{
|
||||||
|
return _gameData.GetExcelSheet<TerritoryType>()!
|
||||||
|
.Where(w => w.RowId != 0 && !string.IsNullOrEmpty(w.ContentFinderCondition.ValueNullable?.Name.ToString()))
|
||||||
|
.ToDictionary(w => w.RowId, w => w.ContentFinderCondition.Value.Name.ToString());
|
||||||
|
});
|
||||||
mediator.Subscribe<TargetPairMessage>(this, (msg) =>
|
mediator.Subscribe<TargetPairMessage>(this, (msg) =>
|
||||||
{
|
{
|
||||||
if (clientState.IsPvP) return;
|
if (clientState.IsPvP) return;
|
||||||
@@ -280,6 +288,7 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
|||||||
public Lazy<Dictionary<uint, string>> TerritoryData { get; private set; }
|
public Lazy<Dictionary<uint, string>> TerritoryData { get; private set; }
|
||||||
public Lazy<Dictionary<uint, string>> TerritoryDataEnglish { get; private set; }
|
public Lazy<Dictionary<uint, string>> TerritoryDataEnglish { get; private set; }
|
||||||
public Lazy<Dictionary<uint, (Map Map, string MapName)>> MapData { get; private set; }
|
public Lazy<Dictionary<uint, (Map Map, string MapName)>> MapData { get; private set; }
|
||||||
|
public Lazy<Dictionary<uint, string>> ContentFinderData { get; private set; }
|
||||||
public bool IsLodEnabled { get; private set; }
|
public bool IsLodEnabled { get; private set; }
|
||||||
public LightlessMediator Mediator { get; }
|
public LightlessMediator Mediator { get; }
|
||||||
|
|
||||||
@@ -373,7 +382,7 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
|||||||
public bool GetIsPlayerPresent()
|
public bool GetIsPlayerPresent()
|
||||||
{
|
{
|
||||||
EnsureIsOnFramework();
|
EnsureIsOnFramework();
|
||||||
return _objectTable.LocalPlayer != null && _objectTable.LocalPlayer.IsValid();
|
return _objectTable.LocalPlayer != null && _objectTable.LocalPlayer.IsValid() && _playerState.IsLoaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> GetIsPlayerPresentAsync()
|
public async Task<bool> GetIsPlayerPresentAsync()
|
||||||
@@ -587,34 +596,17 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
|||||||
|
|
||||||
public string GetPlayerName()
|
public string GetPlayerName()
|
||||||
{
|
{
|
||||||
EnsureIsOnFramework();
|
return _playerState.CharacterName;
|
||||||
return _objectTable.LocalPlayer?.Name.ToString() ?? "--";
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<string> GetPlayerNameAsync()
|
|
||||||
{
|
|
||||||
return await RunOnFrameworkThread(GetPlayerName).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<ulong> GetCIDAsync()
|
|
||||||
{
|
|
||||||
return await RunOnFrameworkThread(GetCID).ConfigureAwait(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public unsafe ulong GetCID()
|
public unsafe ulong GetCID()
|
||||||
{
|
{
|
||||||
EnsureIsOnFramework();
|
return _playerState.ContentId;
|
||||||
var playerChar = GetPlayerCharacter();
|
|
||||||
|
|
||||||
if (playerChar == null || playerChar.Address == IntPtr.Zero)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return ((BattleChara*)playerChar.Address)->Character.ContentId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<string> GetPlayerNameHashedAsync()
|
public string GetPlayerNameHashed()
|
||||||
{
|
{
|
||||||
return await RunOnFrameworkThread(() => _cid.Value.ToString().GetHash256()).ConfigureAwait(false);
|
return _cid.Value.ToString().GetHash256();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static unsafe bool TryGetHashedCID(IPlayerCharacter? playerCharacter, out string hashedCid)
|
public static unsafe bool TryGetHashedCID(IPlayerCharacter? playerCharacter, out string hashedCid)
|
||||||
@@ -653,54 +645,100 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
|||||||
|
|
||||||
public uint GetHomeWorldId()
|
public uint GetHomeWorldId()
|
||||||
{
|
{
|
||||||
EnsureIsOnFramework();
|
return _playerState.HomeWorld.RowId;
|
||||||
return _objectTable.LocalPlayer?.HomeWorld.RowId ?? 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public uint GetWorldId()
|
public uint GetWorldId()
|
||||||
{
|
{
|
||||||
EnsureIsOnFramework();
|
return _playerState.CurrentWorld.RowId;
|
||||||
return _objectTable.LocalPlayer!.CurrentWorld.RowId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public unsafe LocationInfo GetMapData()
|
public unsafe LocationInfo GetMapData()
|
||||||
{
|
{
|
||||||
EnsureIsOnFramework();
|
|
||||||
var agentMap = AgentMap.Instance();
|
|
||||||
var houseMan = HousingManager.Instance();
|
var houseMan = HousingManager.Instance();
|
||||||
uint serverId = 0;
|
|
||||||
if (_objectTable.LocalPlayer == null) serverId = 0;
|
|
||||||
else serverId = _objectTable.LocalPlayer.CurrentWorld.RowId;
|
|
||||||
uint mapId = agentMap == null ? 0 : agentMap->CurrentMapId;
|
|
||||||
uint territoryId = agentMap == null ? 0 : agentMap->CurrentTerritoryId;
|
|
||||||
uint divisionId = houseMan == null ? 0 : (uint)(houseMan->GetCurrentDivision());
|
|
||||||
uint wardId = houseMan == null ? 0 : (uint)(houseMan->GetCurrentWard() + 1);
|
|
||||||
uint houseId = 0;
|
|
||||||
var tempHouseId = houseMan == null ? 0 : (houseMan->GetCurrentPlot());
|
|
||||||
if (!houseMan->IsInside()) tempHouseId = 0;
|
|
||||||
if (tempHouseId < -1)
|
|
||||||
{
|
|
||||||
divisionId = tempHouseId == -127 ? 2 : (uint)1;
|
|
||||||
tempHouseId = 100;
|
|
||||||
}
|
|
||||||
if (tempHouseId == -1) tempHouseId = 0;
|
|
||||||
houseId = (uint)tempHouseId;
|
|
||||||
if (houseId != 0)
|
|
||||||
{
|
|
||||||
territoryId = HousingManager.GetOriginalHouseTerritoryTypeId();
|
|
||||||
}
|
|
||||||
uint roomId = houseMan == null ? 0 : (uint)(houseMan->GetCurrentRoom());
|
|
||||||
|
|
||||||
return new LocationInfo()
|
var location = new LocationInfo();
|
||||||
|
location.ServerId = _playerState.CurrentWorld.RowId;
|
||||||
|
//location.InstanceId = UIState.Instance()->PublicInstance.InstanceId; //TODO:Need API update first
|
||||||
|
location.TerritoryId = _clientState.TerritoryType;
|
||||||
|
location.MapId = _clientState.MapId;
|
||||||
|
if (houseMan != null)
|
||||||
{
|
{
|
||||||
ServerId = serverId,
|
if (houseMan->IsInside())
|
||||||
MapId = mapId,
|
{
|
||||||
TerritoryId = territoryId,
|
location.TerritoryId = HousingManager.GetOriginalHouseTerritoryTypeId();
|
||||||
DivisionId = divisionId,
|
var house = houseMan->GetCurrentIndoorHouseId();
|
||||||
WardId = wardId,
|
location.WardId = house.WardIndex + 1u;
|
||||||
HouseId = houseId,
|
location.HouseId = house.IsApartment ? 100 : house.PlotIndex + 1u;
|
||||||
RoomId = roomId
|
location.RoomId = (uint)house.RoomNumber;
|
||||||
};
|
location.DivisionId = house.IsApartment ? house.ApartmentDivision + 1u : houseMan->GetCurrentDivision();
|
||||||
|
}
|
||||||
|
else if (houseMan->IsInWorkshop())
|
||||||
|
{
|
||||||
|
var workShop = houseMan->WorkshopTerritory;
|
||||||
|
var house = workShop->HouseId;
|
||||||
|
location.WardId = house.WardIndex + 1u;
|
||||||
|
location.HouseId = house.PlotIndex + 1u;
|
||||||
|
}
|
||||||
|
else if (houseMan->IsOutside())
|
||||||
|
{
|
||||||
|
var outside = houseMan->OutdoorTerritory;
|
||||||
|
var house = outside->HouseId;
|
||||||
|
location.WardId = house.WardIndex + 1u;
|
||||||
|
location.HouseId = (uint)houseMan->GetCurrentPlot() + 1;
|
||||||
|
location.DivisionId = houseMan->GetCurrentDivision();
|
||||||
|
}
|
||||||
|
//_logger.LogWarning(LocationToString(location));
|
||||||
|
}
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string LocationToString(LocationInfo location)
|
||||||
|
{
|
||||||
|
if (location.ServerId is 0 || location.TerritoryId is 0) return String.Empty;
|
||||||
|
var str = WorldData.Value[(ushort)location.ServerId];
|
||||||
|
|
||||||
|
if (ContentFinderData.Value.TryGetValue(location.TerritoryId , out var dutyName))
|
||||||
|
{
|
||||||
|
str += $" - [In Duty]{dutyName}";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (location.HouseId is not 0 || location.MapId is 0) // Dont show mapName when in house/no map available
|
||||||
|
{
|
||||||
|
str += $" - {TerritoryData.Value[(ushort)location.TerritoryId]}";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
str += $" - {MapData.Value[(ushort)location.MapId].MapName}";
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (location.InstanceId is not 0)
|
||||||
|
// {
|
||||||
|
// str += ((SeIconChar)(57520 + location.InstanceId)).ToIconString();
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (location.WardId is not 0)
|
||||||
|
{
|
||||||
|
str += $" Ward #{location.WardId}";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (location.HouseId is not 0 and not 100)
|
||||||
|
{
|
||||||
|
str += $" House #{location.HouseId}";
|
||||||
|
}
|
||||||
|
else if (location.HouseId is 100)
|
||||||
|
{
|
||||||
|
str += $" {(location.DivisionId == 2 ? "[Subdivision]" : "")} Apartment";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (location.RoomId is not 0)
|
||||||
|
{
|
||||||
|
str += $" Room #{location.RoomId}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
public unsafe void SetMarkerAndOpenMap(Vector3 position, Map map)
|
public unsafe void SetMarkerAndOpenMap(Vector3 position, Map map)
|
||||||
@@ -712,21 +750,6 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
|||||||
agentMap->SetFlagMapMarker(map.TerritoryType.RowId, map.RowId, position);
|
agentMap->SetFlagMapMarker(map.TerritoryType.RowId, map.RowId, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<LocationInfo> GetMapDataAsync()
|
|
||||||
{
|
|
||||||
return await RunOnFrameworkThread(GetMapData).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<uint> GetWorldIdAsync()
|
|
||||||
{
|
|
||||||
return await RunOnFrameworkThread(GetWorldId).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<uint> GetHomeWorldIdAsync()
|
|
||||||
{
|
|
||||||
return await RunOnFrameworkThread(GetHomeWorldId).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public unsafe bool IsGameObjectPresent(IntPtr key)
|
public unsafe bool IsGameObjectPresent(IntPtr key)
|
||||||
{
|
{
|
||||||
return _objectTable.Any(f => f.Address == key);
|
return _objectTable.Any(f => f.Address == key);
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ public class LightFinderService : IHostedService, IMediatorSubscriber
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var cid = await _dalamudUtil.GetCIDAsync().ConfigureAwait(false);
|
var cid = _dalamudUtil.GetCID();
|
||||||
return cid.ToString().GetHash256();
|
return cid.ToString().GetHash256();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
@@ -101,9 +101,9 @@ public class ServerConfigurationManager
|
|||||||
}
|
}
|
||||||
hasMulti = false;
|
hasMulti = false;
|
||||||
|
|
||||||
var charaName = _dalamudUtil.GetPlayerNameAsync().GetAwaiter().GetResult();
|
var charaName = _dalamudUtil.GetPlayerName();
|
||||||
var worldId = _dalamudUtil.GetHomeWorldIdAsync().GetAwaiter().GetResult();
|
var worldId = _dalamudUtil.GetHomeWorldId();
|
||||||
var cid = _dalamudUtil.GetCIDAsync().GetAwaiter().GetResult();
|
var cid = _dalamudUtil.GetCID();
|
||||||
|
|
||||||
var auth = currentServer.Authentications.FindAll(f => string.Equals(f.CharacterName, charaName) && f.WorldId == worldId);
|
var auth = currentServer.Authentications.FindAll(f => string.Equals(f.CharacterName, charaName) && f.WorldId == worldId);
|
||||||
if (auth.Count >= 2)
|
if (auth.Count >= 2)
|
||||||
@@ -148,9 +148,9 @@ public class ServerConfigurationManager
|
|||||||
}
|
}
|
||||||
hasMulti = false;
|
hasMulti = false;
|
||||||
|
|
||||||
var charaName = _dalamudUtil.GetPlayerNameAsync().GetAwaiter().GetResult();
|
var charaName = _dalamudUtil.GetPlayerName();
|
||||||
var worldId = _dalamudUtil.GetHomeWorldIdAsync().GetAwaiter().GetResult();
|
var worldId = _dalamudUtil.GetHomeWorldId();
|
||||||
var cid = _dalamudUtil.GetCIDAsync().GetAwaiter().GetResult();
|
var cid = _dalamudUtil.GetCID();
|
||||||
if (!currentServer.Authentications.Any() && currentServer.SecretKeys.Any())
|
if (!currentServer.Authentications.Any() && currentServer.SecretKeys.Any())
|
||||||
{
|
{
|
||||||
currentServer.Authentications.Add(new Authentication()
|
currentServer.Authentications.Add(new Authentication()
|
||||||
@@ -268,16 +268,16 @@ public class ServerConfigurationManager
|
|||||||
{
|
{
|
||||||
if (serverSelectionIndex == -1) serverSelectionIndex = CurrentServerIndex;
|
if (serverSelectionIndex == -1) serverSelectionIndex = CurrentServerIndex;
|
||||||
var server = GetServerByIndex(serverSelectionIndex);
|
var server = GetServerByIndex(serverSelectionIndex);
|
||||||
if (server.Authentications.Exists(c => string.Equals(c.CharacterName, _dalamudUtil.GetPlayerNameAsync().GetAwaiter().GetResult(), StringComparison.Ordinal)
|
if (server.Authentications.Exists(c => string.Equals(c.CharacterName, _dalamudUtil.GetPlayerName(), StringComparison.Ordinal)
|
||||||
&& c.WorldId == _dalamudUtil.GetHomeWorldIdAsync().GetAwaiter().GetResult()))
|
&& c.WorldId == _dalamudUtil.GetHomeWorldId()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
server.Authentications.Add(new Authentication()
|
server.Authentications.Add(new Authentication()
|
||||||
{
|
{
|
||||||
CharacterName = _dalamudUtil.GetPlayerNameAsync().GetAwaiter().GetResult(),
|
CharacterName = _dalamudUtil.GetPlayerName(),
|
||||||
WorldId = _dalamudUtil.GetHomeWorldIdAsync().GetAwaiter().GetResult(),
|
WorldId = _dalamudUtil.GetHomeWorldId(),
|
||||||
SecretKeyIdx = !server.UseOAuth2 ? server.SecretKeys.Last().Key : -1,
|
SecretKeyIdx = !server.UseOAuth2 ? server.SecretKeys.Last().Key : -1,
|
||||||
LastSeenCID = _dalamudUtil.GetCIDAsync().GetAwaiter().GetResult()
|
LastSeenCID = _dalamudUtil.GetCID()
|
||||||
});
|
});
|
||||||
Save();
|
Save();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -368,8 +368,8 @@ public sealed class DtrEntry : IDisposable, IHostedService
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var cid = await _dalamudUtilService.GetCIDAsync().ConfigureAwait(false);
|
var cid = _dalamudUtilService.GetCID();
|
||||||
var hashedCid = cid.ToString().GetHash256();
|
var hashedCid = cid.ToString().GetHash256();
|
||||||
lock (_localHashedCidLock)
|
lock (_localHashedCidLock)
|
||||||
{
|
{
|
||||||
_localHashedCid = hashedCid;
|
_localHashedCid = hashedCid;
|
||||||
|
|||||||
@@ -440,7 +440,7 @@ public class TopTabMenu
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var myCidHash = (await _dalamudUtilService.GetCIDAsync().ConfigureAwait(false)).ToString().GetHash256();
|
var myCidHash = _dalamudUtilService.GetCID().ToString().GetHash256();
|
||||||
await _apiController.TryPairWithContentId(request.HashedCid).ConfigureAwait(false);
|
await _apiController.TryPairWithContentId(request.HashedCid).ConfigureAwait(false);
|
||||||
_pairRequestService.RemoveRequest(request.HashedCid);
|
_pairRequestService.RemoveRequest(request.HashedCid);
|
||||||
|
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ public partial class ApiController
|
|||||||
CensusDataDto? censusDto = null;
|
CensusDataDto? censusDto = null;
|
||||||
if (_serverManager.SendCensusData && _lastCensus != null)
|
if (_serverManager.SendCensusData && _lastCensus != null)
|
||||||
{
|
{
|
||||||
var world = await _dalamudUtil.GetWorldIdAsync().ConfigureAwait(false);
|
var world = _dalamudUtil.GetWorldId();
|
||||||
censusDto = new((ushort)world, _lastCensus.RaceId, _lastCensus.TribeId, _lastCensus.Gender);
|
censusDto = new((ushort)world, _lastCensus.RaceId, _lastCensus.TribeId, _lastCensus.Gender);
|
||||||
Logger.LogDebug("Attaching Census Data: {data}", censusDto);
|
Logger.LogDebug("Attaching Census Data: {data}", censusDto);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -544,8 +544,8 @@ public sealed partial class ApiController : DisposableMediatorSubscriberBase, IL
|
|||||||
|
|
||||||
private void DalamudUtilOnLogIn()
|
private void DalamudUtilOnLogIn()
|
||||||
{
|
{
|
||||||
var charaName = _dalamudUtil.GetPlayerNameAsync().GetAwaiter().GetResult();
|
var charaName = _dalamudUtil.GetPlayerName();
|
||||||
var worldId = _dalamudUtil.GetHomeWorldIdAsync().GetAwaiter().GetResult();
|
var worldId = _dalamudUtil.GetHomeWorldId();
|
||||||
var auth = _serverManager.CurrentServer.Authentications.Find(f => string.Equals(f.CharacterName, charaName, StringComparison.Ordinal) && f.WorldId == worldId);
|
var auth = _serverManager.CurrentServer.Authentications.Find(f => string.Equals(f.CharacterName, charaName, StringComparison.Ordinal) && f.WorldId == worldId);
|
||||||
if (auth?.AutoLogin ?? false)
|
if (auth?.AutoLogin ?? false)
|
||||||
{
|
{
|
||||||
@@ -653,7 +653,7 @@ public sealed partial class ApiController : DisposableMediatorSubscriberBase, IL
|
|||||||
CensusDataDto? dto = null;
|
CensusDataDto? dto = null;
|
||||||
if (_serverManager.SendCensusData && _lastCensus != null)
|
if (_serverManager.SendCensusData && _lastCensus != null)
|
||||||
{
|
{
|
||||||
var world = await _dalamudUtil.GetWorldIdAsync().ConfigureAwait(false);
|
var world = _dalamudUtil.GetWorldId();
|
||||||
dto = new((ushort)world, _lastCensus.RaceId, _lastCensus.TribeId, _lastCensus.Gender);
|
dto = new((ushort)world, _lastCensus.RaceId, _lastCensus.TribeId, _lastCensus.Gender);
|
||||||
Logger.LogDebug("Attaching Census Data: {data}", dto);
|
Logger.LogDebug("Attaching Census Data: {data}", dto);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public sealed class TokenProvider : IDisposable, IMediatorSubscriber
|
|||||||
result = await _httpClient.PostAsync(tokenUri, new FormUrlEncodedContent(
|
result = await _httpClient.PostAsync(tokenUri, new FormUrlEncodedContent(
|
||||||
[
|
[
|
||||||
new KeyValuePair<string, string>("auth", auth),
|
new KeyValuePair<string, string>("auth", auth),
|
||||||
new KeyValuePair<string, string>("charaIdent", await _dalamudUtil.GetPlayerNameHashedAsync().ConfigureAwait(false)),
|
new KeyValuePair<string, string>("charaIdent", _dalamudUtil.GetPlayerNameHashed()),
|
||||||
]), ct).ConfigureAwait(false);
|
]), ct).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -152,7 +152,7 @@ public sealed class TokenProvider : IDisposable, IMediatorSubscriber
|
|||||||
JwtIdentifier jwtIdentifier;
|
JwtIdentifier jwtIdentifier;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var playerIdentifier = await _dalamudUtil.GetPlayerNameHashedAsync().ConfigureAwait(false);
|
var playerIdentifier = _dalamudUtil.GetPlayerNameHashed();
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(playerIdentifier))
|
if (string.IsNullOrEmpty(playerIdentifier))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user