Skip to content

Commit

Permalink
Merge pull request #604 from FFXIV-CombatReborn/mergeWIP
Browse files Browse the repository at this point in the history
code analyzer fixes
  • Loading branch information
CarnifexOptimus authored Feb 13, 2025
2 parents 92fb71b + 82d7395 commit 15041ff
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 34 deletions.
2 changes: 1 addition & 1 deletion BossMod/Autorotation/MiscAI/AutoPull.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public override void Execute(StrategyValues strategy, Actor? primaryTarget, floa
enabled |= Bossmods.ActiveModule?.Info?.Category == BossModuleInfo.Category.Quest;

if (strategy.Enabled(Track.DeepDungeon))
enabled |= Bossmods.ActiveModule?.Info?.Category == BossModuleInfo.Category.DeepDungeon && World.Party.WithoutSlot().Count() == 1;
enabled |= Bossmods.ActiveModule?.Info?.Category == BossModuleInfo.Category.DeepDungeon && World.Party.WithoutSlot().Length == 1;

if (strategy.Enabled(Track.EpicEcho))
enabled |= Player.Statuses.Any(s => s.ID == 2734);
Expand Down
1 change: 0 additions & 1 deletion BossMod/Autorotation/Standard/xan/Melee/MNK.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ public static RotationModuleDefinition Definition()
.AddOption(WRStrategy.PreDowntime, "Ensure usage at least 2 GCDs before next downtime", minLevel: 96)
.AddAssociatedActions(AID.WindsReply);


// PB-related settings
def.Define(Track.PB).As<PBStrategy>("PB", uiPriority: 89)
.AddOption(PBStrategy.Automatic, "Automatically use after Opo before or during Riddle of Fire", minLevel: 50)
Expand Down
4 changes: 2 additions & 2 deletions BossMod/Debug/DebugQuests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public DebugQuests()
foreach (var quests in _dailyQuests.Values)
{
quests.AllQuests.SortBy(q => (q.Unknown11 == 3, q.RowId));
var rankMin = (int)quests.AllQuests.Select(q => q.BeastReputationRank.RowId).Min();
var rankMax = (int)quests.AllQuests.Select(q => q.BeastReputationRank.RowId).Max();
var rankMin = (int)quests.AllQuests.Min(q => q.BeastReputationRank.RowId);
var rankMax = (int)quests.AllQuests.Max(q => q.BeastReputationRank.RowId);
var rankCur = RankForQuest(quests.AllQuests[0], out var rankedUp);
quests.OutrankAll = quests.AllQuests.All(q => RankForQuest(q, out _) > q.BeastReputationRank.RowId);
quests.AvailableQuests = CalculateAvailable(quests.AllQuests, QuestManager.Instance()->DailyQuestSeed, quests.OutrankAll, rankCur, rankedUp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public override void Update()
foreach ((var i, var player) in Raid.WithSlot(false, true, true))
{
_playerDeathTollStacks[i] = player.FindStatus((uint)SID.DeathsToll)?.Extra ?? 0; // TODO: use status events here...
_playerAOECount[i] = _sources.Where(srcRot => player.Position.InCone(srcRot.Item1.Position, srcRot.Item2, _coneHalfAngle)).Count();
_playerAOECount[i] = _sources.Count(srcRot => player.Position.InCone(srcRot.Item1.Position, srcRot.Item2, _coneHalfAngle));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ private WPos DetermineWaterSafeSpot(Actor source)
{
var ccw = Service.Config.Get<P4S2Config>().Act4DarkSoakCCW;
var pos = RotateCW(source.Position, (ccw ? -1 : 1) * 45.Degrees(), 18);
return _playerTetherSource.Where(x => x != null && x.Position.InCircle(pos, 4)).FirstOrDefault();
return _playerTetherSource.FirstOrDefault(x => x != null && x.Position.InCircle(pos, 4));
}

private Actor? NextAOE()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ class ArchaicRockbreakerShockwave(BossModule module) : Components.Knockback(modu
private readonly DateTime _activation = module.WorldState.FutureTime(6.5f);
private static readonly List<SafeWall> Walls0 = [new(new(93, 117.5f), new(108, 117.5f)), new(new(82.5f, 93), new(82.5f, 108)),
new(new(117.5f, 93), new(117.5f, 108)), new(new(93, 82.5f), new(108, 82.5f))];
private static readonly List<SafeWall> Walls45 = Walls0.Select(wall => RotatedSafeWall(wall.Vertex1, wall.Vertex2)).ToList();
private static readonly List<SafeWall> Walls45 = [.. Walls0.Select(wall => RotatedSafeWall(wall.Vertex1, wall.Vertex2))];

public override IEnumerable<Source> Sources(int slot, Actor actor)
{
if (Arena.Bounds == P9SKokytos.arenaUplift0)
yield return new(Arena.Center, 21, _activation, SafeWalls: Walls0);
if (Arena.Bounds == P9SKokytos.arenaUplift45)
else if (Arena.Bounds == P9SKokytos.arenaUplift45)
yield return new(Arena.Center, 21, _activation, SafeWalls: Walls45);
}

Expand Down
37 changes: 18 additions & 19 deletions BossMod/Modules/Global/DeepDungeon/AutoClear.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public abstract class AutoClear : ZoneModule

public record class Gaze(Actor Source, AOEShape Shape);

protected static readonly AutoDDConfig _config = Service.Config.Get<AutoDDConfig>();
protected static readonly AutoDDConfig Config = Service.Config.Get<AutoDDConfig>();
private readonly EventSubscriptions _subscriptions;
private readonly List<WPos> _trapsCurrentZone = [];

Expand Down Expand Up @@ -254,19 +254,19 @@ private void ClearState()

protected void AddLOS(Actor Source, float Range)
{
if (_config.AutoLOS)
if (Config.AutoLOS)
AddLOSFromTerrain(Source, Range);
else
Circles.Add((Source, Range));
}

private bool OpenGold => _config.GoldCoffer;
private bool OpenGold => Config.GoldCoffer;
private bool OpenSilver
{
get
{
// disabled
if (!_config.SilverCoffer)
if (!Config.SilverCoffer)
return false;

// sanity check
Expand All @@ -289,9 +289,9 @@ private bool OpenSilver
}
}

private bool OpenBronze => _config.BronzeCoffer;
private bool OpenBronze => Config.BronzeCoffer;

public override bool WantDrawExtra() => _config.EnableMinimap && !Palace.IsBossFloor;
public override bool WantDrawExtra() => Config.EnableMinimap && !Palace.IsBossFloor;

public sealed override string WindowName() => "BMR DD minimap###Zone module";

Expand All @@ -304,12 +304,12 @@ public override void DrawExtra()

ImGui.Text($"Kills: {Kills}");

var navInCombat = _config.NavigateInCombat;
var navInCombat = Config.NavigateInCombat;

if (ImGui.Checkbox("Allow navigation in combat", ref navInCombat))
{
_config.NavigateInCombat = navInCombat;
_config.Modified.Fire();
Config.NavigateInCombat = navInCombat;
Config.Modified.Fire();
}

if (ImGui.Button("Reload obstacles"))
Expand Down Expand Up @@ -389,7 +389,7 @@ protected virtual void CalculateExtraHints(int playerSlot, Actor player, AIHints

public override void CalculateAIHints(int playerSlot, Actor player, AIHints hints)
{
if (!_config.Enable || Palace.IsBossFloor || BetweenFloors)
if (!Config.Enable || Palace.IsBossFloor || BetweenFloors)
return;

foreach (var (w, rot) in Walls)
Expand Down Expand Up @@ -448,7 +448,7 @@ public override void CalculateAIHints(int playerSlot, Actor player, AIHints hint
}

var fullClear = false;
if (_config.FullClear)
if (Config.FullClear)
{
var unexplored = Array.FindIndex(Palace.Rooms, d => (byte)d > 0 && !d.HasFlag(RoomFlags.Revealed));
if (unexplored > 0)
Expand All @@ -458,8 +458,7 @@ public override void CalculateAIHints(int playerSlot, Actor player, AIHints hint
}
}


if (_config.TrapHints && _trapsHidden)
if (Config.TrapHints && _trapsHidden)
{
var count = _trapsCurrentZone.Count;
var traps = new List<Func<WPos, float>>(count);
Expand Down Expand Up @@ -512,10 +511,10 @@ public override void CalculateAIHints(int playerSlot, Actor player, AIHints hint
hints.ActionsToExecute.Push(new ActionID(ActionType.Pomander, (uint)p2), null, ActionQueue.Priority.VeryHigh);

Actor? wantCoffer = null;
if (coffer is Actor t && !IsPlayerTransformed(player) && (_config.AutoMoveTreasure && (!player.InCombat || _config.NavigateInCombat) || player.DistanceToHitbox(t) < 3.5f))
if (coffer is Actor t && !IsPlayerTransformed(player) && (Config.AutoMoveTreasure && (!player.InCombat || Config.NavigateInCombat) || player.DistanceToHitbox(t) < 3.5f))
wantCoffer = t;

if (!player.InCombat && _config.AutoPassage && Palace.PassageActive)
if (!player.InCombat && Config.AutoPassage && Palace.PassageActive)
{
if (DesiredRoom == 0)
DesiredRoom = Array.FindIndex(Palace.Rooms, d => d.HasFlag(RoomFlags.Passage));
Expand All @@ -525,7 +524,7 @@ public override void CalculateAIHints(int playerSlot, Actor player, AIHints hint
hints.GoalZones.Add(hints.GoalSingleTarget(c.Position, 2f, 0.5f));
// give pathfinder a little help lmao
hints.GoalZones.Add(hints.GoalSingleTarget(c.Position, 25f, 0.25f));
if (player.DistanceToHitbox(c) < player.DistanceToHitbox(coffer) && !_config.OpenChestsFirst)
if (player.DistanceToHitbox(c) < player.DistanceToHitbox(coffer) && !Config.OpenChestsFirst)
wantCoffer = null;
}
}
Expand All @@ -540,10 +539,10 @@ public override void CalculateAIHints(int playerSlot, Actor player, AIHints hint
if (revealedTraps.Count > 0)
hints.AddForbiddenZone(ShapeDistance.Union(revealedTraps));

if (!IsPlayerTransformed(player) && (!player.InCombat || _config.NavigateInCombat) && _config.AutoMoveTreasure && hoardLight is Actor h && Palace.GetPomanderState(PomanderID.Intuition).Active)
if (!IsPlayerTransformed(player) && (!player.InCombat || Config.NavigateInCombat) && Config.AutoMoveTreasure && hoardLight is Actor h && Palace.GetPomanderState(PomanderID.Intuition).Active)
hints.GoalZones.Add(hints.GoalSingleTarget(h.Position, 2f, 10f));

var shouldTargetMobs = _config.AutoClear switch
var shouldTargetMobs = Config.AutoClear switch
{
AutoDDConfig.ClearBehavior.Passage => !Palace.PassageActive,
AutoDDConfig.ClearBehavior.Leveling => player.Level < LevelCap || !Palace.PassageActive,
Expand Down Expand Up @@ -681,7 +680,7 @@ private void DrawAOEs(int playerSlot, Actor player, AIHints hints)

private void HandleFloorPathfind(Actor player, AIHints hints)
{
if (player.InCombat && !_config.NavigateInCombat)
if (player.InCombat && !Config.NavigateInCombat)
return;

var playerRoom = Palace.Party[0].Room;
Expand Down
2 changes: 1 addition & 1 deletion BossMod/Modules/Global/DeepDungeon/LevelData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Tileset<T> RoomsB
[Serializable]
public record class Tileset<T>(List<RoomData<T>> Rooms)
{
public Tileset<M> Map<M>(Func<T, M> Mapping) => new(Rooms.Select(m => m.Map(Mapping)).ToList());
public Tileset<M> Map<M>(Func<T, M> Mapping) => new([.. Rooms.Select(m => m.Map(Mapping))]);

public RoomData<T> this[int index] => Rooms[index];

Expand Down
4 changes: 2 additions & 2 deletions BossMod/Modules/Global/Quest/FF16Collab/InfernalShadow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public override void OnCastStarted(Actor caster, ActorCastInfo spell)
if ((AID)spell.Action.ID is AID.FieryRampageCleaveReal or AID.FieryRampageCleaveReal2)
{
_castersunsorted.Add((caster.Position, spell.Rotation, Module.CastFinishAt(spell), spell.Action.ID)); // casters appear in random order in raw ops
_casters = _castersunsorted.OrderBy(x => x.AID).Select(x => (x.position, x.rotation, x.activation)).ToList();
_casters = [.. _castersunsorted.OrderBy(x => x.AID).Select(x => (x.position, x.rotation, x.activation))];
}
}

Expand Down Expand Up @@ -135,7 +135,7 @@ public override void OnCastStarted(Actor caster, ActorCastInfo spell)
if ((AID)spell.Action.ID is AID.EruptionReal2 or AID.EruptionReal3 or AID.EruptionReal4)
{
_castersunsorted.Add((spell.LocXZ, Module.CastFinishAt(spell), spell.Action.ID));
_casters = _castersunsorted.OrderBy(x => x.AID).Select(x => (x.position, x.activation)).ToList();
_casters = [.. _castersunsorted.OrderBy(x => x.AID).Select(x => (x.position, x.activation))];
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class SeduceOld(BossModule module) : Components.GenericAOEs(module)
private static readonly AOEShapeCircle circle = new(2.5f);
private bool active;
private bool addedCircles;
private readonly HashSet<Actor> chests = module.Enemies(OID.Helper).Where(x => x.NameID == 6274).ToHashSet();
private readonly HashSet<Actor> chests = [.. module.Enemies(OID.Helper).Where(x => x.NameID == 6274)];
private readonly HashSet<Circle> closedChests = [];
private readonly HashSet<Circle> openChests = [];

Expand Down
2 changes: 1 addition & 1 deletion BossMod/QuestBattle/QuestBattle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ private async Task<List<NavigationWaypoint>> TryPathfind(IEnumerable<Waypoint> c
ptVecs.RemoveAt(ptVecs.Count - 1);

Log(string.Join(", ", ptVecs.Select(Utils.Vec3String)));
thesePoints = ptVecs.Take(ptVecs.Count - 1).Select(p => new NavigationWaypoint(p, false)).ToList();
thesePoints = [.. ptVecs.Take(ptVecs.Count - 1).Select(p => new NavigationWaypoint(p, false))];
thesePoints.Add(new NavigationWaypoint(ptVecs.Last(), true));
}
else
Expand Down
2 changes: 1 addition & 1 deletion BossMod/Replay/Analysis/ArenaBounds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private static List<WPos> FilterClosePoints(IEnumerable<WPos> points, double eps
}

private static Path64 ConvertToPath64(List<WPos> points) => [.. points.Select(p => new Point64((long)(p.X * PolygonClipper.Scale), (long)(p.Z * PolygonClipper.Scale))).ToList()];
private static List<WPos> ConvertToPoints(Path64 path) => path.Select(p => new WPos((float)(p.X * PolygonClipper.InvScale), (float)(p.Y * PolygonClipper.InvScale))).ToList();
private static List<WPos> ConvertToPoints(Path64 path) => [.. path.Select(p => new WPos((float)(p.X * PolygonClipper.InvScale), (float)(p.Y * PolygonClipper.InvScale)))];

public static List<WPos> GenerateConcaveHull(List<WPos> points, float alpha, float epsilon)
{
Expand Down
2 changes: 1 addition & 1 deletion BossMod/Replay/Visualization/ColumnEnemiesCastEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public ColumnEnemiesCastEvents(Timeline timeline, StateMachineTree tree, List<in
_phaseBranches = phaseBranches;
_encounter = enc;
_moduleInfo = BossModuleRegistry.FindByOID(enc.OID);
_actions = replay.EncounterActions(enc).Where(a => a.Source.Type is not (ActorType.Player or ActorType.Pet or ActorType.Chocobo or ActorType.Buddy)).ToList();
_actions = [.. replay.EncounterActions(enc).Where(a => a.Source.Type is not (ActorType.Player or ActorType.Pet or ActorType.Chocobo or ActorType.Buddy))];
foreach (var a in _actions)
{
var f = _filters.GetOrAdd(a.ID);
Expand Down

0 comments on commit 15041ff

Please sign in to comment.