Skip to content

Commit

Permalink
Merge pull request #446 from FFXIV-CombatReborn/unnamed-status-fix
Browse files Browse the repository at this point in the history
Update ECommons submodule and add null checks to prevent bricking due to statuses without names
  • Loading branch information
LTS-FFXIV authored Nov 17, 2024
2 parents c8bae17 + 484efaf commit c530fe4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ECommons
7 changes: 4 additions & 3 deletions RotationSolver.Basic/DataCenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using RotationSolver.Basic.Configuration.Conditions;
using RotationSolver.Basic.Rotations.Duties;
using Svg.FilterEffects;
using System.Linq;
using Action = Lumina.Excel.Sheets.Action;
using CharacterManager = FFXIVClientStructs.FFXIV.Client.Game.Character.CharacterManager;

Expand Down Expand Up @@ -471,11 +472,11 @@ public static IBattleChara? DispelTarget
get
{
var weakenPeople = DataCenter.PartyMembers?
.Where(o => o is IBattleChara b && b.StatusList != null && b.StatusList.Any(StatusHelper.CanDispel)) ?? Enumerable.Empty<IBattleChara>();
.Where(o => o is IBattleChara b && b.StatusList != null && b.StatusList.Any(status => status != null && StatusHelper.CanDispel(status))) ?? Enumerable.Empty<IBattleChara>();
var weakenNPC = DataCenter.FriendlyNPCMembers?
.Where(o => o is IBattleChara b && b.StatusList != null && b.StatusList.Any(StatusHelper.CanDispel)) ?? Enumerable.Empty<IBattleChara>();
.Where(o => o is IBattleChara b && b.StatusList != null && b.StatusList.Any(status => status != null && StatusHelper.CanDispel(status))) ?? Enumerable.Empty<IBattleChara>();
var dyingPeople = weakenPeople
.Where(o => o is IBattleChara b && b.StatusList != null && b.StatusList.Any(StatusHelper.IsDangerous));
.Where(o => o is IBattleChara b && b.StatusList != null && b.StatusList.Any(status => status != null && StatusHelper.IsDangerous(status)));

return dyingPeople.OrderBy(ObjectHelper.DistanceToPlayer).FirstOrDefault()
?? weakenPeople.OrderBy(ObjectHelper.DistanceToPlayer).FirstOrDefault()
Expand Down
3 changes: 3 additions & 0 deletions RotationSolver.Basic/Helpers/StatusHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ public static bool IsInvincible(this Status status)
/// <returns>True if the status is a priority, otherwise false.</returns>
public static bool IsPriority(this Status status)
{
if (status == null) return false;
return OtherConfiguration.PriorityStatus.Any(id => (uint)id == status.StatusId);
}

Expand All @@ -374,6 +375,7 @@ public static bool IsPriority(this Status status)
/// <returns>True if the status needs to be dispelled, otherwise false.</returns>
public static bool IsDangerous(this Status status)
{
if (status == null) return false;
if (!status.CanDispel()) return false;
if (status.StackCount > 2) return true;
if (status.RemainingTime > 20) return true;
Expand All @@ -387,6 +389,7 @@ public static bool IsDangerous(this Status status)
/// <returns>True if the status can be dispelled, otherwise false.</returns>
public static bool CanDispel(this Status status)
{
if (status == null) return false;
return status.GameData.Value.CanDispel && status.RemainingTime > 1 + DataCenter.DefaultGCDRemain;
}
}

0 comments on commit c530fe4

Please sign in to comment.