Compare commits

..

No commits in common. "master" and "v4.1" have entirely different histories.
master ... v4.1

5 changed files with 25 additions and 91 deletions

View File

@ -990,7 +990,7 @@ csharp_space_around_binary_operators = before_and_after
csharp_using_directive_placement = outside_namespace:silent
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_braces = true:silent
csharp_style_namespace_declarations = file_scoped:suggestion
csharp_style_namespace_declarations = block_scoped:silent
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_style_prefer_primary_constructors = true:suggestion

View File

@ -1,62 +0,0 @@
using System;
using Dalamud.Game.ClientState.Objects;
using Dalamud.Game.ClientState.Objects.Enums;
using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.Game.Command;
using Dalamud.Plugin.Services;
using FFXIVClientStructs.FFXIV.Client.Game.Character;
using RetainerTrack.Handlers;
namespace RetainerTrack.Commands
{
internal sealed class AccountIdCommand : IDisposable
{
private readonly ICommandManager _commandManager;
private readonly IClientState _clientState;
private readonly ITargetManager _targetManager;
private readonly IChatGui _chatGui;
private readonly PersistenceContext _persistenceContext;
public AccountIdCommand(ICommandManager commandManager, IClientState clientState, ITargetManager targetManager,
IChatGui chatGui, PersistenceContext persistenceContext)
{
_commandManager = commandManager;
_clientState = clientState;
_targetManager = targetManager;
_chatGui = chatGui;
_persistenceContext = persistenceContext;
_commandManager.AddHandler("/accountid", new CommandInfo(ProcessCommand)
{
HelpMessage = "Shows the accountid of your target (or if no target, yourself)"
});
}
private void ProcessCommand(string command, string arguments)
{
IGameObject? character = _targetManager.Target ?? _clientState.LocalPlayer;
if (character == null || character.ObjectKind != ObjectKind.Player)
return;
unsafe
{
var bc = (BattleChara*)character.Address;
_chatGui.Print($"{character.Name} has Account Id: {bc->AccountId}, Content Id: {bc->ContentId}");
_persistenceContext.HandleContentIdMapping([
new PlayerMapping
{
ContentId = bc->ContentId,
AccountId = bc->AccountId,
PlayerName = bc->NameString,
}
]);
}
}
public void Dispose()
{
_commandManager.RemoveHandler("/accountid");
}
}
}

View File

@ -46,13 +46,15 @@ internal sealed class ObjectTableHandler : IDisposable
if (obj.ObjectKind == ObjectKind.Player)
{
var bc = (BattleChara*)obj.Address;
if (bc->ContentId == 0 || bc->AccountId == 0)
var ep = (ExtendedPlayer*)obj.Address;
if (ep->ContentId == 0 || ep->AccountId == 0)
continue;
playerMappings.Add(new PlayerMapping
{
ContentId = bc->ContentId,
AccountId = bc->AccountId,
ContentId = ep->ContentId,
AccountId = ep->AccountId,
PlayerName = bc->NameString,
});
}
@ -68,4 +70,11 @@ internal sealed class ObjectTableHandler : IDisposable
{
_framework.Update -= FrameworkUpdate;
}
[StructLayout(LayoutKind.Explicit, Size = 0x2280)]
public struct ExtendedPlayer
{
[FieldOffset(0x2258)] public ulong AccountId;
[FieldOffset(0x2260)] public ulong ContentId;
}
}

View File

@ -1,6 +1,6 @@
<Project Sdk="Dalamud.NET.Sdk/9.0.2">
<PropertyGroup>
<Version>4.3</Version>
<Version>4.1</Version>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SatelliteResourceLanguages>none</SatelliteResourceLanguages>
<OutputPath Condition="'$(Configuration)' != 'EF'">dist</OutputPath>

View File

@ -1,7 +1,6 @@
using System;
using System.IO;
using Dalamud.Extensions.MicrosoftLogging;
using Dalamud.Game.ClientState.Objects;
using Dalamud.Plugin;
using Dalamud.Plugin.Services;
using Microsoft.Data.Sqlite;
@ -32,7 +31,6 @@ internal sealed class RetainerTrackPlugin : IDalamudPlugin
IAddonLifecycle addonLifecycle,
ICommandManager commandManager,
IDataManager dataManager,
ITargetManager targetManager,
IObjectTable objectTable,
IMarketBoard marketBoard,
IPluginLog pluginLog)
@ -52,7 +50,6 @@ internal sealed class RetainerTrackPlugin : IDalamudPlugin
serviceCollection.AddSingleton(addonLifecycle);
serviceCollection.AddSingleton(commandManager);
serviceCollection.AddSingleton(dataManager);
serviceCollection.AddSingleton(targetManager);
serviceCollection.AddSingleton(objectTable);
serviceCollection.AddSingleton(marketBoard);
@ -61,24 +58,24 @@ internal sealed class RetainerTrackPlugin : IDalamudPlugin
serviceCollection.AddSingleton<MarketBoardUiHandler>();
serviceCollection.AddSingleton<ObjectTableHandler>();
serviceCollection.AddSingleton<GameHooks>();
serviceCollection.AddSingleton<AccountIdCommand>();
serviceCollection.AddSingleton<WhoCommand>();
_sqliteConnectionString = PrepareSqliteDb(serviceCollection, pluginInterface.GetPluginConfigDirectory());
_sqliteConnectionString =
$"Data Source={Path.Join(pluginInterface.GetPluginConfigDirectory(), DatabaseFileName)}";
serviceCollection.AddDbContext<RetainerTrackContext>(o => o
.UseSqlite(_sqliteConnectionString)
.UseModel(RetainerTrackContextModel.Instance));
_serviceProvider = serviceCollection.BuildServiceProvider();
RunMigrations(_serviceProvider);
InitializeRequiredServices(_serviceProvider);
}
private static string PrepareSqliteDb(IServiceCollection serviceCollection, string getPluginConfigDirectory)
{
string connectionString = $"Data Source={Path.Join(getPluginConfigDirectory, DatabaseFileName)}";
serviceCollection.AddDbContext<RetainerTrackContext>(o => o
.UseSqlite(connectionString)
.UseModel(RetainerTrackContextModel.Instance));
return connectionString;
_serviceProvider.GetRequiredService<MarketBoardOfferingsHandler>();
_serviceProvider.GetRequiredService<MarketBoardUiHandler>();
_serviceProvider.GetRequiredService<ObjectTableHandler>();
_serviceProvider.GetRequiredService<GameHooks>();
_serviceProvider.GetRequiredService<WhoCommand>();
}
private static void RunMigrations(IServiceProvider serviceProvider)
@ -88,16 +85,6 @@ internal sealed class RetainerTrackPlugin : IDalamudPlugin
dbContext.Database.Migrate();
}
private static void InitializeRequiredServices(ServiceProvider serviceProvider)
{
serviceProvider.GetRequiredService<MarketBoardOfferingsHandler>();
serviceProvider.GetRequiredService<MarketBoardUiHandler>();
serviceProvider.GetRequiredService<ObjectTableHandler>();
serviceProvider.GetRequiredService<GameHooks>();
serviceProvider.GetRequiredService<AccountIdCommand>();
serviceProvider.GetRequiredService<WhoCommand>();
}
public void Dispose()
{
_serviceProvider?.Dispose();