Skip to content

Commit

Permalink
Expand preset ID space, fix potential bug
Browse files Browse the repository at this point in the history
Preset IDs now have a thousand IDs within the job space, and negative IDs are considered disabled and hidden. Additionally, a potential bug with universal presets using the job pseudo-ID of `0` has been fixed.
  • Loading branch information
PrincessRTFM committed Aug 3, 2024
1 parent 0d0ecb5 commit fc5ee79
Show file tree
Hide file tree
Showing 6 changed files with 515 additions and 469 deletions.
2 changes: 1 addition & 1 deletion XIVComboVX/Combos/DOH.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace PrincessRTFM.XIVComboVX.Combos;

internal static class DOH {
public const byte JobID = 97;
public const byte JobID = 98;

public const uint
Placeholder = 0;
Expand Down
5 changes: 3 additions & 2 deletions XIVComboVX/Combos/DOL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace PrincessRTFM.XIVComboVX.Combos;

internal static class DOL {
public const byte JobID = 98,
public const byte JobID = 99,
MinID = 16,
BtnID = 17,
FshID = 18;
Expand Down Expand Up @@ -325,6 +325,7 @@ protected override uint Invoke(uint actionID, uint lastComboMove, float comboTim
return thaliak(actionID, level);
}
}

internal class PrimedMetFeature: CustomCombo {

public override CustomComboPreset Preset { get; } = CustomComboPreset.PrimedMetFeature;
Expand All @@ -336,7 +337,7 @@ protected override uint Invoke(uint actionID, uint lastComboActionId, float comb
if (level >= DOL.Levels.PrimingTouch) {
if (LocalPlayer.CurrentGp >= 400) {
if (SelfHasEffect(DOL.Buffs.CollectorsStandard) || SelfHasEffect(DOL.Buffs.CollectorsHighStandard)) {
if (!SelfHasEffect(DOL.Buffs.PrimingTouch))
if (!SelfHasEffect(DOL.Buffs.PrimingTouch))
return IsJob(DOL.MinID) ? MIN.PrimingTouch : BTN.PrimingTouch;
}
}
Expand Down
41 changes: 39 additions & 2 deletions XIVComboVX/Config/PluginConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;

using Dalamud.Configuration;
using Dalamud.Interface.ImGuiNotification;
Expand All @@ -25,7 +26,7 @@ public class PluginConfiguration: IPluginConfiguration {
UserDismissable = true,
};

public int Version { get; set; } = 6;
public int Version { get; set; } = 7;

public PluginConfiguration() { }
public PluginConfiguration(bool firstRun) => this.IsFirstRun = firstRun;
Expand Down Expand Up @@ -443,6 +444,9 @@ public bool Active {
public bool ShowUpdateMessage { get; set; } = true;

[JsonProperty("EnabledActionsV5")]
public HashSet<CustomComboPreset> EnabledActionsSmallIdSpace { get; set; } = [];

[JsonProperty("EnabledActionsV7")]
public HashSet<CustomComboPreset> EnabledActions { get; set; } = [];

[Obsolete("Use the explicit 'Dancer*ActionID' ushorts instead")]
Expand All @@ -456,17 +460,50 @@ public bool Active {

public void Save() => Service.Interface.SavePluginConfig(this);

public void CleanRemovedPresetIds() {
int cleaned = this.EnabledActions.RemoveWhere(p => {
bool valid = Enum.IsDefined(p);
if (!valid)
Service.Log.Info($"Removing invalid preset ID {p}");
return !valid;
});
if (cleaned > 0) {
Service.Log.Info($"{cleaned} invalid preset{(cleaned == 1 ? string.Empty : "s")} removed");
this.Save();
}
}

public void UpgradeIfNeeded() {
#pragma warning disable CS0618 // Type or member is obsolete
bool changed = false;
if (this.Version == 5) {
this.DancerEmboiteRedActionID = this.DancerDanceCompatActionIDs[0];
this.DancerEntrechatBlueActionID = this.DancerDanceCompatActionIDs[1];
this.DancerJeteGreenActionID = this.DancerDanceCompatActionIDs[2];
this.DancerPirouetteYellowActionID = this.DancerDanceCompatActionIDs[3];
this.DancerDanceCompatActionIDs = [];
this.Version++;
++this.Version;
changed = true;
}
#pragma warning restore CS0618 // Type or member is obsolete
if (this.Version == 6) {
this.EnabledActions = this.EnabledActionsSmallIdSpace
.Select(p => {
int v = (int)p;
int job = v / 100;
int id = v - (job * 100);
int n = (job * 1000) + id;
Service.Log.Info($"Updating old preset {p} ({id} for job {job}) to {n}");
return (CustomComboPreset)n;
})
.ToHashSet();
this.EnabledActionsSmallIdSpace.Clear();
++this.Version;
changed = true;
}

if (changed)
this.Save();
}

#endregion
Expand Down
6 changes: 3 additions & 3 deletions XIVComboVX/CustomCombo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public bool TryInvoke(uint actionID, uint lastComboActionId, float comboTime, by
if (classJobID is >= 16 and <= 18)
classJobID = DOL.JobID;

if (this.JobID != classJobID && this.ClassID != classJobID)
if (this.JobID > 0 && this.JobID != classJobID && this.ClassID != classJobID)
return false;
if (this.AffectedIDs.Count > 0 && !this.AffectedIDs.Contains(actionID))
return false;
Expand Down Expand Up @@ -83,8 +83,8 @@ public bool TryInvoke(uint actionID, uint lastComboActionId, float comboTime, by
protected abstract uint Invoke(uint actionID, uint lastComboActionId, float comboTime, byte level);

protected internal static bool IsEnabled(CustomComboPreset preset) {
if ((int)preset == 99) {
Service.TickLogger.Debug($"Aborting is-enabled check, this preset is forcibly disabled");
if ((int)preset < 0) {
Service.TickLogger.Debug($"Aborting is-enabled check, {preset}#{(int)preset} is forcibly disabled");
return false;
}
if ((int)preset < 100) {
Expand Down
Loading

0 comments on commit fc5ee79

Please sign in to comment.