Skip to content

Commit 93010bf

Browse files
authored
Merge pull request #637 from FFXIV-CombatReborn/moreBase
SMN Base fixes, core system fixes and cleanup
2 parents a2cdde3 + 0e08f7d commit 93010bf

File tree

4 files changed

+119
-20
lines changed

4 files changed

+119
-20
lines changed

RotationSolver.Basic/Configuration/OtherConfiguration.cs

+22-9
Original file line numberDiff line numberDiff line change
@@ -220,17 +220,30 @@ private static void Save<T>(T value, string name)
220220

221221
private static void SavePath<T>(T value, string path)
222222
{
223-
try
223+
int retryCount = 3;
224+
int delay = 1000; // 1 second delay
225+
226+
for (int i = 0; i < retryCount; i++)
224227
{
225-
File.WriteAllText(path,
226-
JsonConvert.SerializeObject(value, Formatting.Indented, new JsonSerializerSettings()
228+
try
227229
{
228-
TypeNameHandling = TypeNameHandling.None,
229-
}));
230-
}
231-
catch (Exception ex)
232-
{
233-
Svc.Log.Warning(ex, $"Failed to save the file to {path}");
230+
File.WriteAllText(path,
231+
JsonConvert.SerializeObject(value, Formatting.Indented, new JsonSerializerSettings()
232+
{
233+
TypeNameHandling = TypeNameHandling.None,
234+
}));
235+
return; // Exit the method if successful
236+
}
237+
catch (IOException ex) when (i < retryCount - 1)
238+
{
239+
Svc.Log.Warning(ex, $"Failed to save the file to {path}. Retrying in {delay}ms...");
240+
Thread.Sleep(delay); // Wait before retrying
241+
}
242+
catch (Exception ex)
243+
{
244+
Svc.Log.Warning(ex, $"Failed to save the file to {path}");
245+
return; // Exit the method if an unexpected exception occurs
246+
}
234247
}
235248
}
236249

RotationSolver.Basic/Helpers/PriorityTargetHelper.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace RotationSolver.Basic.Helpers
55
{
66
internal class PriorityTargetHelper
77
{
8-
private static readonly string FilePath = "PriorityId.json";
8+
private static readonly string FilePath = "PrioTargetId.json";
99

1010
// List of OIDs (DataId)
1111
private static HashSet<uint> priorityOids = LoadPriorityOids();

RotationSolver.Basic/Helpers/ReflectionHelper.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@ internal static PropertyInfo[] GetStaticProperties<T>(this Type? type)
1515
{
1616
if (type == null) return Array.Empty<PropertyInfo>();
1717

18-
var properties = type.GetRuntimeProperties()
18+
var properties = type.GetProperties(BindingFlags.Static | BindingFlags.Public)
1919
.Where(prop => typeof(T).IsAssignableFrom(prop.PropertyType)
20-
&& prop.GetMethod is MethodInfo methodInfo
21-
&& methodInfo.IsPublic && methodInfo.IsStatic
2220
&& prop.GetCustomAttribute<ObsoleteAttribute>() == null)
2321
.ToArray();
2422

@@ -35,7 +33,7 @@ internal static IEnumerable<MethodInfo> GetAllMethodInfo(this Type? type)
3533
{
3634
if (type == null) return Enumerable.Empty<MethodInfo>();
3735

38-
var methods = type.GetRuntimeMethods()
36+
var methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)
3937
.Where(method => !method.IsConstructor)
4038
.ToArray();
4139

@@ -51,8 +49,10 @@ internal static IEnumerable<MethodInfo> GetAllMethodInfo(this Type? type)
5149
/// <returns>The property information if found, otherwise null.</returns>
5250
internal static PropertyInfo? GetPropertyInfo(this Type type, string name)
5351
{
54-
var property = type.GetRuntimeProperties()
55-
.FirstOrDefault(prop => prop.Name == name && prop.GetMethod is MethodInfo methodInfo && methodInfo.IsStatic);
52+
if (type == null) throw new ArgumentNullException(nameof(type));
53+
if (string.IsNullOrEmpty(name)) throw new ArgumentException("Property name cannot be null or empty", nameof(name));
54+
55+
var property = type.GetProperty(name, BindingFlags.Static | BindingFlags.Public);
5656

5757
return property ?? type.BaseType?.GetPropertyInfo(name);
5858
}
@@ -66,9 +66,9 @@ internal static IEnumerable<MethodInfo> GetAllMethodInfo(this Type? type)
6666
internal static MethodInfo? GetMethodInfo(this Type? type, string name)
6767
{
6868
if (type == null) return null;
69+
if (string.IsNullOrEmpty(name)) throw new ArgumentException("Method name cannot be null or empty", nameof(name));
6970

70-
var method = type.GetRuntimeMethods()
71-
.FirstOrDefault(m => m.Name == name && m.IsStatic && !m.IsConstructor && m.ReturnType == typeof(bool));
71+
var method = type.GetMethod(name, BindingFlags.Static | BindingFlags.Public);
7272

7373
return method ?? type.BaseType?.GetMethodInfo(name);
7474
}

RotationSolver.Basic/Rotations/Basic/SummonerRotation.cs

+88-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Dalamud.Interface.Colors;
1+
using Dalamud.Interface.Colors;
22

33
namespace RotationSolver.Basic.Rotations.Basic;
44

@@ -128,7 +128,7 @@ protected static bool AttunmentTimeEndAfterGCD(uint gcdCount = 0, float offset =
128128
private static bool HasSummon => DataCenter.HasPet && SummonTimeEndAfterGCD();
129129
#endregion
130130

131-
#region PvE Actions Unassignable
131+
#region PvE Actions Unassignable Status
132132

133133
/// <summary>
134134
///
@@ -457,6 +457,10 @@ static partial void ModifyNecrotizePvE(ref ActionSetting setting)
457457
static partial void ModifySearingFlashPvE(ref ActionSetting setting)
458458
{
459459
setting.StatusNeed = [StatusID.RubysGlimmer];
460+
setting.CreateConfig = () => new ActionConfig()
461+
{
462+
AoeCount = 1,
463+
};
460464
}
461465

462466
static partial void ModifyLuxSolarisPvE(ref ActionSetting setting)
@@ -474,11 +478,32 @@ static partial void ModifyAstralImpulsePvE(ref ActionSetting setting)
474478
static partial void ModifyAstralFlarePvE(ref ActionSetting setting)
475479
{
476480
setting.ActionCheck = () => AstralFlarePvEReady;
481+
setting.CreateConfig = () => new ActionConfig()
482+
{
483+
AoeCount = 3,
484+
};
477485
}
478486

479487
static partial void ModifyDeathflarePvE(ref ActionSetting setting)
480488
{
481489
setting.ActionCheck = () => InBahamut;
490+
setting.CreateConfig = () => new ActionConfig()
491+
{
492+
AoeCount = 1,
493+
};
494+
}
495+
496+
static partial void ModifyWyrmwavePvE(ref ActionSetting setting)
497+
{
498+
499+
}
500+
501+
static partial void ModifyAkhMornPvE(ref ActionSetting setting)
502+
{
503+
setting.CreateConfig = () => new ActionConfig()
504+
{
505+
AoeCount = 1,
506+
};
482507
}
483508

484509
static partial void ModifyRubyRitePvE(ref ActionSetting setting)
@@ -521,6 +546,24 @@ static partial void ModifyEnkindlePhoenixPvE(ref ActionSetting setting)
521546
setting.ActionCheck = () => EnkindlePhoenixPvEReady;
522547
}
523548

549+
static partial void ModifyEverlastingFlightPvE(ref ActionSetting setting)
550+
{
551+
552+
}
553+
554+
static partial void ModifyScarletFlamePvE(ref ActionSetting setting)
555+
{
556+
557+
}
558+
559+
static partial void ModifyRevelationPvE(ref ActionSetting setting)
560+
{
561+
setting.CreateConfig = () => new ActionConfig()
562+
{
563+
AoeCount = 1,
564+
};
565+
}
566+
524567
static partial void ModifyRubyCatastrophePvE(ref ActionSetting setting)
525568
{
526569
setting.ActionCheck = () => RubyCatastrophePvEReady;
@@ -540,21 +583,37 @@ static partial void ModifyCrimsonCyclonePvE(ref ActionSetting setting)
540583
{
541584
setting.StatusProvide = [StatusID.CrimsonStrikeReady_4403];
542585
setting.ActionCheck = () => CrimsonCyclonePvEReady;
586+
setting.CreateConfig = () => new ActionConfig()
587+
{
588+
AoeCount = 1,
589+
};
543590
}
544591

545592
static partial void ModifyCrimsonStrikePvE(ref ActionSetting setting)
546593
{
547594
setting.ActionCheck = () => CrimsonStrikePvEReady;
595+
setting.CreateConfig = () => new ActionConfig()
596+
{
597+
AoeCount = 1,
598+
};
548599
}
549600

550601
static partial void ModifyMountainBusterPvE(ref ActionSetting setting)
551602
{
552603
setting.ActionCheck = () => MountainBusterPvEReady;
604+
setting.CreateConfig = () => new ActionConfig()
605+
{
606+
AoeCount = 1,
607+
};
553608
}
554609

555610
static partial void ModifySlipstreamPvE(ref ActionSetting setting)
556611
{
557612
setting.ActionCheck = () => SlipstreamPvEReady;
613+
setting.CreateConfig = () => new ActionConfig()
614+
{
615+
AoeCount = 1,
616+
};
558617
}
559618

560619
static partial void ModifySummonSolarBahamutPvE(ref ActionSetting setting)
@@ -569,15 +628,42 @@ static partial void ModifyUmbralImpulsePvE(ref ActionSetting setting)
569628
setting.ActionCheck = () => UmbralImpulsePvEReady;
570629
}
571630

631+
static partial void ModifyUmbralFlarePvE(ref ActionSetting setting)
632+
{
633+
setting.ActionCheck = () => UmbralFlarePvEReady;
634+
setting.CreateConfig = () => new ActionConfig()
635+
{
636+
AoeCount = 3,
637+
};
638+
}
639+
572640
static partial void ModifySunflarePvE(ref ActionSetting setting)
573641
{
574642
setting.ActionCheck = () => InSolarBahamut;
643+
setting.CreateConfig = () => new ActionConfig()
644+
{
645+
AoeCount = 1,
646+
};
575647
}
576648

577649
static partial void ModifyEnkindleSolarBahamutPvE(ref ActionSetting setting)
578650
{
579651
setting.ActionCheck = () => EnkindleSolarBahamutPvEReady;
580652
}
653+
654+
static partial void ModifyLuxwavePvE(ref ActionSetting setting)
655+
{
656+
657+
}
658+
659+
static partial void ModifyExodusPvE(ref ActionSetting setting)
660+
{
661+
setting.ActionCheck = () => InSolarBahamut;
662+
setting.CreateConfig = () => new ActionConfig()
663+
{
664+
AoeCount = 1,
665+
};
666+
}
581667
#endregion
582668

583669
#region PvP Actions

0 commit comments

Comments
 (0)