Skip to content

Commit b76f25c

Browse files
committed
log action/status names from lumina
1 parent 68bdc2a commit b76f25c

File tree

5 files changed

+79
-15
lines changed

5 files changed

+79
-15
lines changed

XIVComboVX/CustomCombo.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public bool TryInvoke(uint actionID, uint lastComboActionId, float comboTime, by
6666
return false;
6767
}
6868
if (this.affectedIDs.Count > 0 && !this.affectedIDs.Contains(actionID)) {
69-
Service.TickLogger.Error($"{LogTag.Combo} {this.ModuleName} does not affect action #{actionID} - this replacer should not have been invoked!");
69+
Service.TickLogger.Error($"{LogTag.Combo} {this.ModuleName} does not affect {Labels.Action(actionID)} - this replacer should not have been invoked!");
7070
return false;
7171
}
7272
if (!IsEnabled(this.Preset)) {
@@ -77,20 +77,20 @@ public bool TryInvoke(uint actionID, uint lastComboActionId, float comboTime, by
7777
if (comboTime <= 0)
7878
lastComboActionId = 0;
7979

80-
Service.TickLogger.Info($"{LogTag.Combo} {this.ModuleName}.Invoke({actionID}, {lastComboActionId}, {comboTime}, {level})");
80+
Service.TickLogger.Info($"{LogTag.Combo} {this.ModuleName}.Invoke({Labels.Action(actionID)}, {Labels.Action(lastComboActionId)}, {comboTime}, {level})");
8181
try {
8282
uint resultingActionID = this.Invoke(actionID, lastComboActionId, comboTime, level);
8383
if (resultingActionID == 0 || actionID == resultingActionID) {
8484
Service.TickLogger.Debug($"{LogTag.Combo} No replacement from {this.ModuleName}");
8585
return false;
8686
}
8787

88-
Service.TickLogger.Info($"{LogTag.Combo} Became #{resultingActionID}");
88+
Service.TickLogger.Info($"{LogTag.Combo} Became {Labels.Action(resultingActionID)}");
8989
newActionID = resultingActionID;
9090
return true;
9191
}
9292
catch (Exception ex) {
93-
Service.TickLogger.Error($"{LogTag.Combo} Error in {this.ModuleName}.Invoke({actionID}, {lastComboActionId}, {comboTime}, {level})", ex);
93+
Service.TickLogger.Error($"{LogTag.Combo} Error in {this.ModuleName}.Invoke({Labels.Action(actionID)}, {Labels.Action(lastComboActionId)}, {comboTime}, {level})", ex);
9494
return false;
9595
}
9696
}
@@ -204,15 +204,15 @@ protected static uint PickByCooldown(uint preference, params uint[] actions) {
204204
// And they've got a TTS-style voice just constantly repeating "PAIN. PAIN. PAIN. PAIN. PAIN." from it?
205205
// Yeah.
206206

207-
Service.TickLogger.Debug($"{LogTag.Combo} CDCMP: {a.ActionID}, {b.ActionID}: {choice.ActionID}\n{a.Data.DebugLabel}\n{b.Data.DebugLabel}");
207+
Service.TickLogger.Debug($"{LogTag.Combo} CDCMP: {Labels.Action(a.ActionID)}, {Labels.Action(b.ActionID)}: {Labels.Action(choice.ActionID)}\n{a.Data.DebugLabel}\n{b.Data.DebugLabel}");
208208
return choice;
209209
}
210210

211211
uint id = actions
212212
.Select(selector)
213213
.Aggregate((a1, a2) => compare(preference, a1, a2))
214214
.ActionID;
215-
Service.TickLogger.Info($"{LogTag.Combo} Final selection: {id}");
215+
Service.TickLogger.Info($"{LogTag.Combo} Final selection: {Labels.Action(id)}");
216216
return id;
217217
}
218218

@@ -323,7 +323,7 @@ protected static unsafe CooldownData GetCooldown(uint actionID) {
323323
cooldownPtr->ActionId = actionID;
324324

325325
CooldownData cd = cooldownCache[actionID] = *(CooldownData*)cooldownPtr;
326-
Service.TickLogger.Debug($"{LogTag.Combo} Retrieved cooldown data for action #{actionID}: {cd.DebugLabel}");
326+
Service.TickLogger.Debug($"{LogTag.Combo} Retrieved cooldown data for action {Labels.Action(actionID)}: {cd.DebugLabel}");
327327
return cd;
328328
}
329329

@@ -346,7 +346,7 @@ protected static unsafe CooldownData GetCooldown(uint actionID) {
346346
(uint statusID, uint? ObjectId, uint? sourceID) key = (statusID, actor?.EntityId, sourceID);
347347

348348
if (statusCache.TryGetValue(key, out Status? found)) {
349-
Service.TickLogger.Info($"{LogTag.StatusEffect} Found cached status data for #{statusID}: "
349+
Service.TickLogger.Info($"{LogTag.StatusEffect} Found cached status data for {Labels.Status(statusID)}: "
350350
+ (found is null
351351
? "not active"
352352
: $"{found.Param} stacks, {found.RemainingTime} seconds"
@@ -364,12 +364,12 @@ protected static unsafe CooldownData GetCooldown(uint actionID) {
364364
if (status is null)
365365
continue;
366366
if (status.StatusId == statusID && (!sourceID.HasValue || status.SourceId is 0 or InvalidObjectID || status.SourceId == sourceID)) {
367-
Service.TickLogger.Info($"{LogTag.StatusEffect} Caching status data for #{statusID}: {status.Param} stacks, {status.RemainingTime} seconds");
367+
Service.TickLogger.Info($"{LogTag.StatusEffect} Caching status data for {Labels.Status(statusID)}: {status.Param} stacks, {status.RemainingTime} seconds");
368368
return statusCache[key] = status;
369369
}
370370
}
371371

372-
Service.TickLogger.Info($"{LogTag.StatusEffect} Caching null status for #{statusID}");
372+
Service.TickLogger.Info($"{LogTag.StatusEffect} Caching null status for {Labels.Status(statusID)}");
373373
return statusCache[key] = null;
374374
}
375375

XIVComboVX/GameData/IconReplacer.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ private unsafe uint getIconDetour(nint actionManager, uint actionID) {
7373
return this.OriginalHook(actionID);
7474

7575
if (!this.customCombos.TryGetValue(actionID, out List<CustomCombo>? combos) && !this.customCombos.TryGetValue(0, out combos)) {
76-
Service.TickLogger.Info($"{LogTag.Combo} No replacers found for action #{actionID}");
76+
Service.TickLogger.Info($"{LogTag.Combo} No replacers found for action {Labels.Action(actionID)}");
7777
return this.OriginalHook(actionID);
7878
}
7979

8080
IPlayerCharacter? player = CustomCombo.CachedLocalPlayer;
8181
if (player is null) {
82-
Service.TickLogger.Warning($"{LogTag.Combo} Cannot replace action #{actionID} when player is null");
82+
Service.TickLogger.Warning($"{LogTag.Combo} Cannot replace action {Labels.Action(actionID)} when player is null");
8383
return this.OriginalHook(actionID);
8484
}
8585

@@ -88,13 +88,13 @@ private unsafe uint getIconDetour(nint actionManager, uint actionID) {
8888
byte level = player.Level;
8989
uint classJobID = player.ClassJob.RowId;
9090

91-
Service.TickLogger.Info($"{LogTag.Combo} Checking {combos.Count} replacer{(combos.Count == 1 ? "" : "s")} for action #{actionID}");
91+
Service.TickLogger.Info($"{LogTag.Combo} Checking {combos.Count} replacer{(combos.Count == 1 ? "" : "s")} for action {Labels.Action(actionID)}");
9292
foreach (CustomCombo combo in combos) {
9393
if (combo.TryInvoke(actionID, lastComboActionId, comboTime, level, classJobID, out uint newActionID))
9494
return this.OriginalHook(newActionID);
9595
}
9696

97-
Service.TickLogger.Info($"{LogTag.Combo} No replacement for action #{actionID}");
97+
Service.TickLogger.Info($"{LogTag.Combo} No replacement for {Labels.Action(actionID)}");
9898
return this.OriginalHook(actionID);
9999
}
100100
catch (Exception ex) {

XIVComboVX/GameData/Labels.cs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
using System.Collections.Generic;
2+
using System.Diagnostics;
3+
4+
using Lumina.Excel;
5+
6+
using GameAction = Lumina.Excel.Sheets.Action;
7+
using GameStatus = Lumina.Excel.Sheets.Status;
8+
9+
namespace VariableVixen.XIVComboVX.GameData;
10+
11+
internal static class Labels {
12+
private static readonly Dictionary<uint, string> actions = [];
13+
private static readonly Dictionary<uint, string> effects = [];
14+
15+
internal static string Action(uint actionID) {
16+
if (actionID is 0)
17+
return "(no action)#0";
18+
if (!actions.TryGetValue(actionID, out string? label) || string.IsNullOrWhiteSpace(label))
19+
return $"(unknown action)#{actionID}";
20+
return $"(action {label})#{actionID}";
21+
}
22+
internal static string Status(uint statusID) {
23+
if (statusID is 0)
24+
return "(no status)#0";
25+
if (!effects.TryGetValue(statusID, out string? label) || string.IsNullOrWhiteSpace(label))
26+
return $"(unknown status)#{statusID}";
27+
return $"(status {label})#{statusID}";
28+
}
29+
30+
internal static void Load() {
31+
Stopwatch timer = new();
32+
33+
Service.Log.Info($"{LogTag.CoreSetup} Indexing player action names");
34+
timer.Restart();
35+
ExcelSheet<GameAction> actionSheet = Service.DataManager.GetExcelSheet<GameAction>();
36+
foreach (GameAction row in actionSheet) {
37+
actions[row.RowId] = row.Name.ExtractText();
38+
}
39+
timer.Stop();
40+
Service.Log.Info($"{LogTag.CoreSetup} Indexed {actions.Count} player actions in {timer.ElapsedMilliseconds}ms");
41+
42+
Service.Log.Info($"{LogTag.CoreSetup} Indexing status effect names");
43+
timer.Restart();
44+
ExcelSheet<GameStatus> effectSheet = Service.DataManager.GetExcelSheet<GameStatus>();
45+
foreach (GameStatus row in effectSheet) {
46+
effects[row.RowId] = row.Name.ExtractText();
47+
}
48+
timer.Stop();
49+
Service.Log.Info($"{LogTag.CoreSetup} Indexed {effects.Count} status effects in {timer.ElapsedMilliseconds}ms");
50+
}
51+
}

XIVComboVX/Plugin.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,18 @@
1515

1616
using VariableVixen.XIVComboVX.Attributes;
1717
using VariableVixen.XIVComboVX.Config;
18+
using VariableVixen.XIVComboVX.GameData;
1819

1920
namespace VariableVixen.XIVComboVX;
2021

2122
public sealed class Plugin: IDalamudPlugin {
2223
public const string Name = "XIVComboVX";
2324

2425
private bool disposed = false;
25-
private readonly Thread finalSetupThread;
26+
private readonly Thread? finalSetupThread;
27+
#pragma warning disable CS0649 // Field is never assigned to - only happens in release builds
28+
private readonly Thread? luminaLoadingThread;
29+
#pragma warning restore CS0649
2630

2731
private static readonly HashSet<string> nonConflictingPluginIds = [];
2832
private static readonly HashSet<string> conflictingPluginNameSubstrings = [
@@ -96,12 +100,18 @@ public Plugin(IDalamudPluginInterface pluginInterface, IPluginLog log) {
96100
Service.Address.Setup();
97101

98102
this.finalSetupThread = new(this.deferredInit);
103+
#if DEBUG
104+
this.luminaLoadingThread = new(Labels.Load);
105+
#endif
99106

100107
log.Information($"{LogTag.CoreSetup} Preinitialisation complete, starting main setup");
101108
this.finalSetupThread.Start();
102109
}
103110

104111
private void deferredInit() {
112+
this.luminaLoadingThread?.Start();
113+
this.luminaLoadingThread?.Join();
114+
105115
if (Service.Address.LoadSuccessful) {
106116
Service.IconReplacer = new();
107117
Service.GameState = new();
@@ -283,6 +293,8 @@ private void dispose(bool disposing) {
283293
this.disposed = true;
284294

285295
if (disposing) {
296+
this.finalSetupThread?.Join();
297+
286298
Service.Framework.Update -= CustomCombo.ResetCacheEveryTick;
287299

288300
Service.Commands.RemoveHandler(CommandCustom);

XIVComboVX/Service.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ internal class Service {
2828

2929
public static Ipc Ipc { get; set; } = null!;
3030

31+
[PluginService] public static IDataManager DataManager { get; set; } = null!;
3132
[PluginService] public static IPluginLog Log { get; private set; } = null!;
3233
[PluginService] public static IDalamudPluginInterface Interface { get; private set; } = null!;
3334
[PluginService] public static ISigScanner SigScanner { get; private set; } = null!;

0 commit comments

Comments
 (0)