Skip to content

Commit

Permalink
Update for API9/patch6.5
Browse files Browse the repository at this point in the history
Signatures have NOT been checked and MAY be outdated, but it compiles without issues and they've lasted this long. I've got more plugins to update so I'll check if sigs broke later.
  • Loading branch information
PrincessRTFM committed Oct 5, 2023
1 parent 675c11d commit a4e9121
Show file tree
Hide file tree
Showing 15 changed files with 88 additions and 108 deletions.
4 changes: 2 additions & 2 deletions XIVComboVX/ChatUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ internal ChatUtil() {
[SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "Convention")]
internal void print(XivChatType type, params Payload[] payloads) {
if (payloads.Length > 0) {
Service.ChatGui.PrintChat(new XivChatEntry() {
Service.ChatGui.Print(new XivChatEntry() {
Type = type,
Message = new SeString(payloads),
});
Expand All @@ -41,7 +41,7 @@ private void onClickChatLink(uint id, SeString source) {
Service.Plugin.onPluginCommand("", "");
break;
default:
Service.ChatGui.PrintChat(new XivChatEntry() {
Service.ChatGui.Print(new XivChatEntry() {
Type = XivChatType.SystemError,
Message = new SeString(
new TextPayload($"An internal error has occured: no handler is registered for id {id}.")
Expand Down
8 changes: 4 additions & 4 deletions XIVComboVX/Config/ComboDetailSetting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,22 @@ internal ComboDetailSetting(PropertyInfo prop, ComboDetailSettingAttribute attr)
_ => 0,
};
if (attr.Min < typeMin) {
PluginLog.Warning($"{this.Combo}:{this.Property.Name} has minimum value {attr.Min} below {this.Type.Name}.MinValue, bounding to {typeMin}");
Service.Log.Warning($"{this.Combo}:{this.Property.Name} has minimum value {attr.Min} below {this.Type.Name}.MinValue, bounding to {typeMin}");
this.Min = typeMin;
}
else if (attr.Min > typeMax) {
PluginLog.Warning($"{this.Combo}:{this.Property.Name} has minimum value {attr.Min} above {this.Type.Name}.MaxValue, bounding to {typeMax}");
Service.Log.Warning($"{this.Combo}:{this.Property.Name} has minimum value {attr.Min} above {this.Type.Name}.MaxValue, bounding to {typeMax}");
this.Min = typeMax;
}
else {
this.Min = attr.Min;
}
if (attr.Max > typeMax) {
PluginLog.Warning($"{this.Combo}:{this.Property.Name} has maximum value {attr.Max} above {this.Type.Name}.MaxValue, bounding to {typeMax}");
Service.Log.Warning($"{this.Combo}:{this.Property.Name} has maximum value {attr.Max} above {this.Type.Name}.MaxValue, bounding to {typeMax}");
this.Max = typeMax;
}
else if (attr.Max < typeMin) {
PluginLog.Warning($"{this.Combo}:{this.Property.Name} has maximum value {attr.Max} below {this.Type.Name}.MinValue, bounding to {typeMin}");
Service.Log.Warning($"{this.Combo}:{this.Property.Name} has maximum value {attr.Max} below {this.Type.Name}.MinValue, bounding to {typeMin}");
this.Max = typeMin;
}
else {
Expand Down
8 changes: 4 additions & 4 deletions XIVComboVX/Config/ConfigWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public ConfigWindow() : base($"Custom Combo Setup - {Service.Plugin.ShortPluginS

this.presetOrdinals[preset] = ++ord;

PluginLog.Information($"Indexed {preset} as {ord}");
Service.Log.Information($"Indexed {preset} as {ord}");

// if this preset has children, iterate and index them immediately because they'll be grouped under it in the config window
if (this.parentToChildrenPresets.TryGetValue(preset, out List<(CustomComboPreset Preset, CustomComboInfoAttribute Info)>? children) && children?.Count > 0) {
Expand All @@ -122,7 +122,7 @@ public ConfigWindow() : base($"Custom Combo Setup - {Service.Plugin.ShortPluginS
if (!this.presetOrdinals.ContainsKey(next))
this.presetOrdinals[next] = ++ord;

PluginLog.Information($"Indexed {next} as {ord}");
Service.Log.Information($"Indexed {next} as {ord}");

// if the current preset being indexed has children, they need to be added to the FRONT of the queue (but still in the order they're presented)
if (this.parentToChildrenPresets.TryGetValue(next, out List<(CustomComboPreset Preset, CustomComboInfoAttribute Info)>? subchildren)) {
Expand Down Expand Up @@ -269,7 +269,7 @@ public override void Draw() {
ImGui.EndTooltip();
}
if (clickDebug) {
Service.Logger.EnableNextTick();
Service.TickLogger.EnableNextTick();
}

ImGui.EndMenu();
Expand Down Expand Up @@ -473,7 +473,7 @@ private void drawPreset(CustomComboPreset preset, CustomComboInfoAttribute info)
default:
throw new FormatException($"Invalid detail type {detail.ImGuiType}");
}
Service.Logger.debug(
Service.TickLogger.debug(
$"{detail.Label} ({detail.Type.Name}/{detail.ImGuiType}) {detail.Min} <= [{detail.Val}] <= {detail.Max} ({range})"
);
bool changed = useSlider
Expand Down
16 changes: 8 additions & 8 deletions XIVComboVX/Config/UpdateAlerter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,19 @@ internal UpdateAlerter(Version to, bool isFresh) {
}

internal void checkMessage() {
PluginLog.Information("Checking whether to display update message");
Service.Log.Information("Checking whether to display update message");
if (this.disposed) {
this.unregister();
PluginLog.Information("Update alerter already disposed");
Service.Log.Information("Update alerter already disposed");
return;
}
if (this.seenUpdateMessage) {
this.unregister();
PluginLog.Information("Message already displayed, unregistering");
Service.Log.Information("Message already displayed, unregistering");
return;
}

PluginLog.Information($"Checks passed, delaying message by {messageDelayMs}ms - may be reset if message is triggered again within that time");
Service.Log.Information($"Checks passed, delaying message by {messageDelayMs}ms - may be reset if message is triggered again within that time");

this.aborter = new();

Expand All @@ -73,7 +73,7 @@ internal void displayMessage() {
this.seenUpdateMessage = true;
this.unregister();

PluginLog.Information("Displaying update alert in game chat");
Service.Log.Information("Displaying update alert in game chat");

List<Payload> parts = new();
if (!(Plugin.Debug && Service.Interface.IsDev)) {
Expand All @@ -98,13 +98,13 @@ internal void displayMessage() {
}

internal void register() {
PluginLog.Information("Registering update alerter");
Service.Log.Information("Registering update alerter");
Service.ChatGui.ChatMessage += this.onChatMessage;
Service.Client.Login += this.onLogin;
}

internal void unregister() {
PluginLog.Information("Unregistering update alerter");
Service.Log.Information("Unregistering update alerter");
Service.ChatGui.ChatMessage -= this.onChatMessage;
Service.Client.Login -= this.onLogin;
}
Expand All @@ -113,7 +113,7 @@ private void onChatMessage(XivChatType type, uint senderId, ref SeString sender,
if (type is XivChatType.Urgent or XivChatType.Notice or XivChatType.SystemMessage)
this.checkMessage();
}
private async void onLogin(object? sender, EventArgs e) {
private async void onLogin() {
do {
await Task.Delay(loginDelayMs);
} while (!Service.Client.IsLoggedIn || Service.Client.LocalContentId == 0 || Service.Client.LocalPlayer is null);
Expand Down
16 changes: 8 additions & 8 deletions XIVComboVX/CustomCombo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,32 +70,32 @@ public bool TryInvoke(uint actionID, uint lastComboActionId, float comboTime, by
if (comboTime <= 0)
lastComboActionId = 0;

Service.Logger.debug($"{this.ModuleName}.Invoke({actionID}, {lastComboActionId}, {comboTime}, {level})");
Service.TickLogger.debug($"{this.ModuleName}.Invoke({actionID}, {lastComboActionId}, {comboTime}, {level})");
try {
uint resultingActionID = this.Invoke(actionID, lastComboActionId, comboTime, level);
if (resultingActionID == 0 || actionID == resultingActionID) {
Service.Logger.debug("NO REPLACEMENT");
Service.TickLogger.debug("NO REPLACEMENT");
return false;
}

Service.Logger.debug($"Became #{resultingActionID}");
Service.TickLogger.debug($"Became #{resultingActionID}");
newActionID = resultingActionID;
return true;
}
catch (Exception ex) {
Service.Logger.error($"Error in {this.ModuleName}.Invoke({actionID}, {lastComboActionId}, {comboTime}, {level})", ex);
Service.TickLogger.error($"Error in {this.ModuleName}.Invoke({actionID}, {lastComboActionId}, {comboTime}, {level})", ex);
return false;
}
}
protected abstract uint Invoke(uint actionID, uint lastComboActionId, float comboTime, byte level);

protected internal static bool IsEnabled(CustomComboPreset preset) {
if ((int)preset < 100) {
Service.Logger.debug($"Bypassing is-enabled check for preset #{(int)preset}");
Service.TickLogger.debug($"Bypassing is-enabled check for preset #{(int)preset}");
return true;
}
bool enabled = Service.Configuration.IsEnabled(preset);
Service.Logger.debug($"Checking status of preset #{(int)preset} - {enabled}");
Service.TickLogger.debug($"Checking status of preset #{(int)preset} - {enabled}");
return enabled;
}

Expand Down Expand Up @@ -149,15 +149,15 @@ protected static uint PickByCooldown(uint preference, params uint[] actions) {
// And they've got a TTS-style voice just constantly repeating "PAIN. PAIN. PAIN. PAIN. PAIN." from it?
// Yeah.

Service.Logger.debug($"CDCMP: {a.ActionID}, {b.ActionID}: {choice.ActionID}\n{a.Data.DebugLabel}\n{b.Data.DebugLabel}");
Service.TickLogger.debug($"CDCMP: {a.ActionID}, {b.ActionID}: {choice.ActionID}\n{a.Data.DebugLabel}\n{b.Data.DebugLabel}");
return choice;
}

uint id = actions
.Select(Selector)
.Aggregate((a1, a2) => Compare(preference, a1, a2))
.ActionID;
Service.Logger.debug($"Final selection: {id}");
Service.TickLogger.debug($"Final selection: {id}");
return id;
}

Expand Down
5 changes: 3 additions & 2 deletions XIVComboVX/GameData/ComboDataCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace PrincessRTFM.XIVComboVX.GameData;
using Dalamud.Game.ClientState.Objects.SubKinds;
using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.Game.ClientState.Statuses;
using Dalamud.Plugin.Services;

using XIVComboVX.Combos;

Expand Down Expand Up @@ -36,7 +37,7 @@ protected override void Dispose(bool disposing) {
this.jobGaugeCache?.Clear();
}

protected override unsafe void InvalidateCache(Framework framework) {
protected override unsafe void InvalidateCache(IFramework framework) {
this.statusCache.Clear();
this.cooldownCache.Clear();
this.canInterruptTarget = null;
Expand Down Expand Up @@ -106,7 +107,7 @@ public unsafe CooldownData GetCooldown(uint actionID) {
cooldownPtr->ActionID = actionID;

CooldownData cd = this.cooldownCache[actionID] = *(CooldownData*)cooldownPtr;
Service.Logger.debug($"Retrieved cooldown data for action #{actionID}: {cd.DebugLabel}");
Service.TickLogger.debug($"Retrieved cooldown data for action #{actionID}: {cd.DebugLabel}");
return cd;
}

Expand Down
2 changes: 1 addition & 1 deletion XIVComboVX/GameData/GameState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ internal GameState() {
Service.Client.Logout += this.clearCacheOnLogout;
}

private void clearCacheOnLogout(object? sender, EventArgs args) => this.chatLogPointer = null;
private void clearCacheOnLogout() => this.chatLogPointer = null;

public void Dispose() {
if (this.disposed)
Expand Down
14 changes: 7 additions & 7 deletions XIVComboVX/GameData/IconReplacer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ internal class IconReplacer: IDisposable {
private readonly List<CustomCombo> customCombos;

public IconReplacer() {
PluginLog.Information("Loading registered combos");
Service.Log.Information("Loading registered combos");
this.customCombos = Assembly.GetAssembly(this.GetType())!.GetTypes()
.Where(t => !t.IsAbstract && (t.BaseType == typeof(CustomCombo) || t.BaseType?.BaseType == typeof(CustomCombo)))
.Select(t => Activator.CreateInstance(t))
.Select(Activator.CreateInstance)
.Cast<CustomCombo>()
.ToList();
PluginLog.Information($"Loaded {this.customCombos.Count} replacers");
Service.Log.Information($"Loaded {this.customCombos.Count} replacers");
#if DEBUG
PluginLog.Information(string.Join(", ", this.customCombos.Select(combo => combo.GetType().Name)));
Service.Log.Information(string.Join(", ", this.customCombos.Select(combo => combo.GetType().Name)));
#endif

this.getIconHook = Hook<GetIconDelegate>.FromAddress(Service.Address.GetAdjustedActionId, this.getIconDetour);
this.isIconReplaceableHook = Hook<IsIconReplaceableDelegate>.FromAddress(Service.Address.IsActionIdReplaceable, this.isIconReplaceableDetour);
this.getIconHook = Service.Interop.HookFromAddress<GetIconDelegate>(Service.Address.GetAdjustedActionId, this.getIconDetour);
this.isIconReplaceableHook = Service.Interop.HookFromAddress<IsIconReplaceableDelegate>(Service.Address.IsActionIdReplaceable, this.isIconReplaceableDetour);

this.getIconHook.Enable();
this.isIconReplaceableHook.Enable();
Expand Down Expand Up @@ -81,7 +81,7 @@ private unsafe uint getIconDetour(IntPtr actionManager, uint actionID) {
return this.OriginalHook(actionID);
}
catch (Exception ex) {
Service.Logger.error("Don't crash the game", ex);
Service.TickLogger.error("Don't crash the game", ex);
return this.getIconHook.Original(actionManager, actionID);
}
}
Expand Down
28 changes: 14 additions & 14 deletions XIVComboVX/GameData/PluginAddressResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace PrincessRTFM.XIVComboVX.GameData;
using Dalamud.Game;
using Dalamud.Logging;

internal class PluginAddressResolver: BaseAddressResolver {
internal class PluginAddressResolver {
private const string addrFmtSpec = "X16";

public Exception? LoadFailReason { get; private set; }
Expand All @@ -25,16 +25,16 @@ internal class PluginAddressResolver: BaseAddressResolver {
public string IsActionIdReplaceableAddr => this.IsActionIdReplaceable.ToInt64().ToString(addrFmtSpec);


protected override void Setup64Bit(SigScanner scanner) {
internal void setup() {
try {
PluginLog.Information("Scanning for ComboTimer signature");
this.ComboTimer = scanner.GetStaticAddressFromSig("F3 0F 11 05 ?? ?? ?? ?? 48 83 C7 08");
Service.Log.Information("Scanning for ComboTimer signature");
this.ComboTimer = Service.SigScanner.GetStaticAddressFromSig("F3 0F 11 05 ?? ?? ?? ?? 48 83 C7 08");

PluginLog.Information("Scanning for GetAdjustedActionId signature");
this.GetAdjustedActionId = scanner.ScanText("E8 ?? ?? ?? ?? 89 03 8B 03"); // Client::Game::ActionManager.GetAdjustedActionId
Service.Log.Information("Scanning for GetAdjustedActionId signature");
this.GetAdjustedActionId = Service.SigScanner.ScanText("E8 ?? ?? ?? ?? 89 03 8B 03"); // Client::Game::ActionManager.GetAdjustedActionId

PluginLog.Information("Scanning for IsActionIdReplaceable signature");
this.IsActionIdReplaceable = scanner.ScanText("E8 ?? ?? ?? ?? 84 C0 74 4C 8B D3");
Service.Log.Information("Scanning for IsActionIdReplaceable signature");
this.IsActionIdReplaceable = Service.SigScanner.ScanText("E8 ?? ?? ?? ?? 84 C0 74 4C 8B D3");
}
catch (Exception ex) {
this.LoadFailReason = ex;
Expand All @@ -51,15 +51,15 @@ protected override void Setup64Bit(SigScanner scanner) {
msg.Append("IsActionIdReplaceable");
msg.AppendLine(":");
msg.Append(ex.ToString());
PluginLog.Fatal(msg.ToString());
Service.Log.Fatal(msg.ToString());
return;
}

PluginLog.Information("Address resolution successful");
Service.Log.Information("Address resolution successful");

PluginLog.Information($"GetAdjustedActionId 0x{this.GetAdjustedActionIdAddr}");
PluginLog.Information($"IsIconReplaceable 0x{this.IsActionIdReplaceableAddr}");
PluginLog.Information($"ComboTimer 0x{this.ComboTimerAddr}");
PluginLog.Information($"LastComboMove 0x{this.LastComboMoveAddr}");
Service.Log.Information($"GetAdjustedActionId 0x{this.GetAdjustedActionIdAddr}");
Service.Log.Information($"IsIconReplaceable 0x{this.IsActionIdReplaceableAddr}");
Service.Log.Information($"ComboTimer 0x{this.ComboTimerAddr}");
Service.Log.Information($"LastComboMove 0x{this.LastComboMoveAddr}");
}
}
4 changes: 2 additions & 2 deletions XIVComboVX/Ipc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private async void registrationLoop() {
this.addTips(tippyTip);
}
catch (IpcError ex) {
Service.Logger.error("Failed to register tip for Tippy's pool", ex);
Service.TickLogger.error("Failed to register tip for Tippy's pool", ex);
this.tippyRegistrationQueue.Clear();
}
}
Expand Down Expand Up @@ -97,7 +97,7 @@ internal bool showTippyMessage(string message) {
return false;
}
catch (IpcError ex) {
Service.Logger.error("Failed to register priority message for Tippy", ex);
Service.TickLogger.error("Failed to register priority message for Tippy", ex);
return false;
}
}
Expand Down
21 changes: 10 additions & 11 deletions XIVComboVX/LogUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ namespace PrincessRTFM.XIVComboVX;

using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;

using Dalamud.Game;
using Dalamud.Logging;
using Dalamud.Plugin.Services;

internal class LogUtil: IDisposable {
public const string STACK_TRACE_MSG = "autogenerated stack trace exception";
Expand All @@ -20,39 +19,39 @@ internal LogUtil() {

public void EnableNextTick() {
this.EnabledNextTick = true;
PluginLog.Information("Enabled logging snapshot for next tick");
Service.Log.Information("Enabled logging snapshot for next tick");
}

private void onTick(Framework framework) {
private void onTick(IFramework framework) {
if (this.Enabled)
PluginLog.Information("Logging snapshot complete");
Service.Log.Information("Logging snapshot complete");
if (this.EnabledNextTick)
PluginLog.Information("Beginning logging snapshot");
Service.Log.Information("Beginning logging snapshot");
this.Enabled = this.EnabledNextTick;
this.EnabledNextTick = false;
}

internal void fatal(string msg, Exception? cause = null) {
if (this.Enabled)
PluginLog.Fatal($"{msg}\n{cause ?? new Exception(STACK_TRACE_MSG)}");
Service.Log.Fatal($"{msg}\n{cause ?? new Exception(STACK_TRACE_MSG)}");
}
internal void error(string msg, Exception? cause = null) {
if (this.Enabled)
PluginLog.Error($"{msg}\n{cause ?? new Exception(STACK_TRACE_MSG)}");
Service.Log.Error($"{msg}\n{cause ?? new Exception(STACK_TRACE_MSG)}");
}
internal void warning(string msg, Exception? cause = null) {
if (this.Enabled)
PluginLog.Warning($"{msg}\n{cause ?? new Exception(STACK_TRACE_MSG)}");
Service.Log.Warning($"{msg}\n{cause ?? new Exception(STACK_TRACE_MSG)}");
}
[Conditional("DEBUG")]
internal void debug(string msg) {
if (this.Enabled)
PluginLog.Information(msg);
Service.Log.Information(msg);
}
[Conditional("DEBUG")]
internal void trace(string msg) {
if (this.Enabled) {
PluginLog.Information(
Service.Log.Information(
#if TRACE
$"{msg}\n{new StackTrace(true)}"
#else
Expand Down
Loading

0 comments on commit a4e9121

Please sign in to comment.