Skip to content

Commit

Permalink
Merge pull request #544 from FFXIV-CombatReborn/mergeWIP
Browse files Browse the repository at this point in the history
code analyzer fix
  • Loading branch information
CarnifexOptimus authored Jan 5, 2025
2 parents 74b8c96 + c149726 commit 0376f88
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 30 deletions.
2 changes: 1 addition & 1 deletion BossMod/Autorotation/xan/Healers/WHM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public override void Exec(StrategyValues strategy, Actor? primaryTarget)
// TODO make a track for this
if (Lily == 3 || !CanFitGCD(NextLily, 2) && Lily == 2)
{
if (World.Party.WithoutSlot(excludeAlliance: true).Average(PredictedHPRatio) < 0.8 && NumSolaceTargets == World.Party.WithoutSlot(excludeAlliance: true).Count())
if (World.Party.WithoutSlot(excludeAlliance: true).Average(PredictedHPRatio) < 0.8 && NumSolaceTargets == World.Party.WithoutSlot(excludeAlliance: true).Length)
PushGCD(AID.AfflatusRapture, Player, 1);

PushGCD(AID.AfflatusSolace, World.Party.WithoutSlot(excludeAlliance: true).MinBy(PredictedHPRatio), 1);
Expand Down
16 changes: 8 additions & 8 deletions BossMod/BossModule/AOEShapes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public enum OperandType
// shapes1 for unions, shapes 2 for shapes for XOR/intersection with shapes1, differences for shapes that get subtracted after previous operations
// always create a new instance of AOEShapeCustom if something other than the invertforbiddenzone changes
// if the origin of the AOE can change, edit the origin default value to prevent cache issues
public sealed record class AOEShapeCustom(Shape[] Shapes1, Shape[]? DifferenceShapes = null, Shape[]? Shapes2 = null, bool InvertForbiddenZone = false, OperandType Operand = OperandType.Union, WPos Origin = default) : AOEShape
public sealed record class AOEShapeCustom(IReadOnlyList<Shape> Shapes1, IReadOnlyList<Shape>? DifferenceShapes = null, IReadOnlyList<Shape>? Shapes2 = null, bool InvertForbiddenZone = false, OperandType Operand = OperandType.Union, WPos Origin = default) : AOEShape
{
public RelSimplifiedComplexPolygon? Polygon;
private PolygonWithHolesDistanceFunction? shapeDistance;
Expand Down Expand Up @@ -247,7 +247,7 @@ public RelSimplifiedComplexPolygon GetCombinedPolygon(WPos origin)
if (Shapes2 != null)
{
Polygon = clipper.Simplify(shapes1);
for (var i = 0; i < Shapes2.Length; ++i)
for (var i = 0; i < Shapes2.Count; ++i)
{
var shape = Shapes2[i];
var singleShapeOperand = CreateOperandFromShape(shape, origin);
Expand Down Expand Up @@ -276,11 +276,11 @@ private static PolygonClipper.Operand CreateOperandFromShape(Shape shape, WPos o
return operand;
}

private static PolygonClipper.Operand CreateOperandFromShapes(Shape[]? shapes, WPos origin)
private static PolygonClipper.Operand CreateOperandFromShapes(IReadOnlyList<Shape>? shapes, WPos origin)
{
var operand = new PolygonClipper.Operand();
if (shapes != null)
for (var i = 0; i < shapes.Length; ++i)
for (var i = 0; i < shapes.Count; ++i)
operand.AddPolygon(shapes[i].ToPolygon(origin));
return operand;
}
Expand All @@ -290,14 +290,14 @@ public override bool Check(WPos position, WPos origin, Angle rotation)
return (Polygon ?? GetCombinedPolygon(origin)).Contains(position - origin);
}

private static int CreateCacheKey(Shape[] shapes1, Shape[] shapes2, Shape[] differenceShapes, OperandType operand, WPos origin)
private static int CreateCacheKey(IReadOnlyList<Shape> shapes1, IReadOnlyList<Shape> shapes2, IReadOnlyList<Shape> differenceShapes, OperandType operand, WPos origin)
{
var hashCode = new HashCode();
for (var i = 0; i < shapes1.Length; ++i)
for (var i = 0; i < shapes1.Count; ++i)
hashCode.Add(shapes1[i].GetHashCode());
for (var i = 0; i < shapes2.Length; ++i)
for (var i = 0; i < shapes2.Count; ++i)
hashCode.Add(shapes2[i].GetHashCode());
for (var i = 0; i < differenceShapes.Length; ++i)
for (var i = 0; i < differenceShapes.Count; ++i)
hashCode.Add(differenceShapes[i].GetHashCode());
hashCode.Add(operand);
hashCode.Add(origin);
Expand Down
2 changes: 1 addition & 1 deletion BossMod/Components/StackSpread.cs
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ public override void OnEventCast(Actor caster, ActorCastEvent spell)

public override void AddAIHints(int slot, Actor actor, PartyRolesConfig.Assignment assignment, AIHints hints)
{
if (!ActiveStacks.Any())
if (ActiveStacks.Count == 0)
return;
var forbidden = new List<Func<WPos, float>>();
foreach (var c in Raid.WithoutSlot().Where(x => ActiveStacks.Any(y => y.Target == x)).Exclude(actor))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class WindShotStack(BossModule module) : Components.DonutStack(module, ActionID.
{
public override void AddAIHints(int slot, Actor actor, PartyRolesConfig.Assignment assignment, AIHints hints)
{
if (!ActiveStacks.Any())
if (ActiveStacks.Count == 0)
return;
var comp = Module.FindComponent<WindEarthShot>()!.ActiveAOEs(slot, actor).ToList();
var forbidden = new List<Func<WPos, float>>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class DestructiveHeat(BossModule module) : Components.SpreadFromCastTargets(modu

public override void AddAIHints(int slot, Actor actor, PartyRolesConfig.Assignment assignment, AIHints hints)
{
if (ActiveSpreads.Any())
if (ActiveSpreads.Count != 0)
{
var source1 = _kb1.Sources(slot, actor).FirstOrDefault();
var source2 = _kb2.Sources(slot, actor).FirstOrDefault();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class Quarantine(BossModule module) : Components.StackWithIcon(module, (uint)Ico

public override void Update()
{
if (!ActiveStacks.Any())
if (ActiveStacks.Count == 0)
return;
var forbidden = Raid.WithSlot().WhereActor(p => _tb.ActiveBaits.Any(x => x.Target == p)).Mask();
foreach (ref var t in Stacks.AsSpan())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public override void AddAIHints(int slot, Actor actor, PartyRolesConfig.Assignme
else
{
base.AddAIHints(slot, actor, assignment, hints);
if (ActiveSpreads.Any())
if (ActiveSpreads.Count != 0)
hints.AddForbiddenZone(ShapeDistance.Circle(Arena.Center - new WDir(0, 15), 15), ActiveSpreads.FirstOrDefault().Activation);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public override IEnumerable<AOEInstance> ActiveAOEs(int slot, Actor actor)
var shape = circlesAvoid;
DateTime activation = default;

if (_avoid.ActiveSpreads.Any())
if (_avoid.ActiveSpreads.Count != 0)
{
shape = IsGhostly(actor) ? circlesInverted : circlesAvoid;
activation = _avoid.ActiveSpreads.First().Activation;
Expand Down Expand Up @@ -132,7 +132,7 @@ public override void AddHints(int slot, Actor actor, TextHints hints)
var isGhostly = IsGhostly(actor);
if (fleshbuster.isActive || _seek.ActiveBaits.Any())
hints.Add(GhostHint, !isGhostly);
else if (_avoid.ActiveSpreads.Any())
else if (_avoid.ActiveSpreads.Count != 0)
hints.Add(FleshHint, isGhostly);
}
}
Expand Down
11 changes: 7 additions & 4 deletions BossMod/Modules/Dawntrail/Quest/RoleQuests/DreamsOfANewDay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,15 @@ class Conviction(BossModule module) : Components.CastTowers(module, ActionID.Mak

public override void Update()
{
if (Towers.Count == 0)
var count = Towers.Count;
if (count == 0)
return;

var stack = _stack.ActiveStacks.Any();
for (var i = 0; i < Towers.Count; ++i)
Towers[i] = new(Towers[i].Position, Towers[i].Radius, stack ? 0 : 1, stack ? 0 : 1, default, Towers[i].Activation);
var stack = _stack.ActiveStacks.Count != 0;
for (var i = 0; i < count; ++i)
{
Towers[i] = Towers[i] with { MinSoakers = stack ? 0 : 1, MaxSoakers = stack ? 0 : 1 };
}
}
}

Expand Down
1 change: 0 additions & 1 deletion BossMod/Modules/Dawntrail/Ultimate/FRU/P2MirrorMirror.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ public override void AddAIHints(int slot, Actor actor, PartyRolesConfig.Assignme
if (dirVec.Dot(boss.Position - origin.source.Position) > 2 && (origin.source.Position - 4 * dirVec - boss.Position).Length() > boss.HitboxRadius + 3)
dir += 180.Degrees();
}

}
hints.AddForbiddenZone(ShapeDistance.InvertedCone(origin.source.Position, 4, dir, 15.Degrees()), origin.activation);
}
Expand Down
6 changes: 3 additions & 3 deletions BossMod/Modules/Heavensward/Dungeon/D02SohmAl/D022Myath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@ public enum AID : uint

public override void AddHints(int slot, Actor actor, TextHints hints)
{
if (!_stack.ActiveStacks.Any())
if (_stack.ActiveStacks.Count == 0)
base.AddHints(slot, actor, hints);
}

public override void AddAIHints(int slot, Actor actor, PartyRolesConfig.Assignment assignment, AIHints hints)
{
if (!_stack.ActiveStacks.Any())
if (_stack.ActiveStacks.Count == 0)
base.AddAIHints(slot, actor, assignment, hints);
}

public override void DrawArenaForeground(int pcSlot, Actor pc)
{
if (!_stack.ActiveStacks.Any())
if (_stack.ActiveStacks.Count == 0)
base.DrawArenaForeground(pcSlot, pc);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,19 @@ public override void OnEventCast(Actor caster, ActorCastEvent spell)

public override void AddHints(int slot, Actor actor, TextHints hints)
{
if (!_stack1.ActiveStacks.Any() && !_stack2.ActiveStacks.Any())
if (_stack1.ActiveStacks.Count == 0 && _stack2.ActiveStacks.Count == 0)
base.AddHints(slot, actor, hints);
}

public override void AddAIHints(int slot, Actor actor, PartyRolesConfig.Assignment assignment, AIHints hints)
{
if (!_stack1.ActiveStacks.Any() && !_stack2.ActiveStacks.Any())
if (_stack1.ActiveStacks.Count == 0 && _stack2.ActiveStacks.Count == 0)
base.AddAIHints(slot, actor, assignment, hints);
}

public override void DrawArenaForeground(int pcSlot, Actor pc)
{
if (!_stack1.ActiveStacks.Any() && !_stack2.ActiveStacks.Any())
if (_stack1.ActiveStacks.Count == 0 && _stack2.ActiveStacks.Count == 0)
base.DrawArenaForeground(pcSlot, pc);
}
}
Expand Down
4 changes: 2 additions & 2 deletions BossMod/Modules/Stormblood/Extreme/Ex7Suzaku/Ex7Suzaku.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public override void AddAIHints(int slot, Actor actor, PartyRolesConfig.Assignme
base.AddAIHints(slot, actor, assignment, hints);
foreach (var scarletLady in Module.Enemies(OID.ScarletLady))
{
if (_firstSpread && ActiveSpreads.Any() && scarletLady.IsDead)
if (_firstSpread && ActiveStacks.Count != 0 && scarletLady.IsDead)
hints.AddForbiddenZone(ShapeDistance.Circle(scarletLady.Position, 6));
}
}
Expand All @@ -143,7 +143,7 @@ public override void DrawArenaBackground(int pcSlot, Actor pc)
base.DrawArenaBackground(pcSlot, pc);
foreach (var scarletLady in Module.Enemies(OID.ScarletLady))
{
if (_firstSpread && ActiveSpreads.Any() && scarletLady.IsDead)
if (_firstSpread && ActiveStacks.Count != 0 && scarletLady.IsDead)
Arena.AddCircle(scarletLady.Position, 6, Colors.Vulnerable);
}
}
Expand Down
2 changes: 1 addition & 1 deletion BossMod/Modules/Stormblood/Ultimate/UCOB/UCOBStates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private void P1DeathSentence(uint id, float delay)

private void P1FireballResolve(uint id, float delay)
{
ComponentCondition<P1Fireball>(id, delay, comp => !comp.ActiveStacks.Any(), "Stack", 1, delay - 0.2f) // note that if target dies, fireball won't happen
ComponentCondition<P1Fireball>(id, delay, comp => comp.ActiveStacks.Count == 0, "Stack", 1, delay - 0.2f) // note that if target dies, fireball won't happen
.DeactivateOnExit<P1Fireball>();
}

Expand Down

0 comments on commit 0376f88

Please sign in to comment.