Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fix: the crashing.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Feb 16, 2024
1 parent 60542c3 commit a93fff8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 19 deletions.
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Actions/ActionTargetInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private static bool NoAOE

return Service.Config.ChooseAttackMark
&& !Service.Config.CanAttackMarkAoe
&& MarkingHelper.HaveAttackChara(DataCenter.AllHostileTargets);
&& MarkingHelper.HaveAttackChara;
}
}

Expand Down
37 changes: 20 additions & 17 deletions RotationSolver.Basic/Helpers/MarkingHelper.cs
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
using FFXIVClientStructs.FFXIV.Client.Game.UI;
using System;

namespace RotationSolver.Basic.Helpers;

internal class MarkingHelper
{
private unsafe static long GetMarker(uint index) => MarkingController.Instance()->MarkerArray[index];
internal unsafe static long GetMarker(uint index) => MarkingController.Instance()->MarkerArray[index];

internal static bool HaveAttackChara(IEnumerable<BattleChara> charas) => GetAttackMarkChara(charas) != null;
internal static bool HaveAttackChara => AttackSignTargets.Any(id => id != GameObject.InvalidGameObjectId);

internal static BattleChara? GetAttackMarkChara(IEnumerable<BattleChara> charas)
{
for (uint i = 0; i < 5; i++)
{
var b = GetChara(charas, GetMarker(i));
if (b?.IsEnemy() ?? false) return b;
}
return null;
}
internal static long[] AttackSignTargets =>
[
GetMarker(0),
GetMarker(1),
GetMarker(2),
GetMarker(3),
GetMarker(4),
GetMarker(14),
GetMarker(15),
GetMarker(16),
];

private static BattleChara? GetChara(IEnumerable<BattleChara> charas, long id)
{
if (id == GameObject.InvalidGameObjectId) return null;
return charas.FirstOrDefault(item => item.ObjectId == id);
}
internal static long[] StopTargets =>
[
GetMarker(8),
GetMarker(9),
];

internal unsafe static IEnumerable<BattleChara> FilterStopCharaes(IEnumerable<BattleChara> charas)
{
var ids = new List<long>() { GetMarker(8), GetMarker(9) }.Where(id => id != 0xE0000000);
var ids = StopTargets.Where(id => id != GameObject.InvalidGameObjectId);
return charas.Where(b => !ids.Contains(b.ObjectId));
}
}
3 changes: 2 additions & 1 deletion RotationSolver.Basic/Helpers/ObjectHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using Lumina.Excel.GeneratedSheets;
using RotationSolver.Basic.Configuration;
using System.Text.RegularExpressions;
using static Dalamud.Interface.Utility.Raii.ImRaii;

namespace RotationSolver.Basic.Helpers;

Expand Down Expand Up @@ -253,6 +252,8 @@ or 71344 //Major Quest

if (obj is BattleChara b && b.StatusList.Any(StatusHelper.IsPriority)) return true;

if (Service.Config.ChooseAttackMark && MarkingHelper.AttackSignTargets.Contains(obj.ObjectId)) return true;

return false;
}

Expand Down

0 comments on commit a93fff8

Please sign in to comment.