Skip to content

Commit

Permalink
Merge pull request #383 from FFXIV-CombatReborn/healfix
Browse files Browse the repository at this point in the history
Revert "another round of changes"
  • Loading branch information
LTS-FFXIV authored Sep 20, 2024
2 parents 6e5d488 + cfee6bb commit 50848ef
Show file tree
Hide file tree
Showing 16 changed files with 48 additions and 46 deletions.
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Actions/ActionBasicInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ private bool NeedsCasting(bool skipCastingCheck)
{
var player = Player.Object;
return CastTime > 0 && !player.HasStatus(true, new[] { StatusID.Swiftcast, StatusID.Triplecast, StatusID.Dualcast }) && !ActionsNoNeedCasting.Contains(ID) &&
(DataCenter.SpecialType == SpecialCommandType.NoCasting || (DateTime.UtcNow > DataCenter.KnockbackStart && DateTime.UtcNow < DataCenter.KnockbackFinished) ||
(DataCenter.SpecialType == SpecialCommandType.NoCasting || (DateTime.Now > DataCenter.KnockbackStart && DateTime.Now < DataCenter.KnockbackFinished) ||
(DataCenter.NoPoslock && DataCenter.IsMoving && !skipCastingCheck));
}

Expand Down
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Actions/ActionTargetInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1116,7 +1116,7 @@ private readonly bool CanGetTarget(IGameObject target, IGameObject subTarget)
private static IBattleChara? RandomObject(IEnumerable<IBattleChara> objs)
{
return objs.FirstOrDefault();
//Random ran = new(DateTime.UtcNow.Millisecond);
//Random ran = new(DateTime.Now.Millisecond);
//var count = objs.Count();
//if (count == 0) return null;
//return objs.ElementAt(ran.Next(count));
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Configuration/Configs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ public const string

[UI("The minimum time between updating RSR information. (Setting too low will negatively effect framerate, setting too high will lead to poor performance)",
Filter = BasicTimer)]
[JobConfig, Range(0.001f, 0.3f, ConfigUnitType.Seconds, 0.001f)]
[JobConfig, Range(0, 0.3f, ConfigUnitType.Seconds, 0.002f)]
public float MinUpdatingTime { get; set; } = 0.01f;

[UI("The HP for using Guard.",
Expand Down
4 changes: 2 additions & 2 deletions RotationSolver.Basic/Data/ObjectListDelay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class ObjectListDelay<T> : IEnumerable<T> where T : IGameObject
private IEnumerable<T> _list = new List<T>();
private readonly Func<(float min, float max)> _getRange;
private SortedList<ulong, DateTime> _revealTime = new();
private readonly Random _ran = new(DateTime.UtcNow.Millisecond);
private readonly Random _ran = new(DateTime.Now.Millisecond);

/// <summary>
/// Initializes a new instance of the <see cref="ObjectListDelay{T}"/> class.
Expand Down Expand Up @@ -43,7 +43,7 @@ public void Delay(IEnumerable<T> originData)
{
var outList = new List<T>(originData.Count());
var revealTime = new SortedList<ulong, DateTime>();
var now = DateTime.UtcNow;
var now = DateTime.Now;

foreach (var item in originData)
{
Expand Down
4 changes: 2 additions & 2 deletions RotationSolver.Basic/Data/OffsetDelay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ public bool Delay(bool originData)
if (originData != _lastValue)
{
_lastValue = originData;
_changeTimes.Enqueue(DateTime.UtcNow + TimeSpan.FromSeconds(GetDelay()));
_changeTimes.Enqueue(DateTime.Now + TimeSpan.FromSeconds(GetDelay()));
}

if (_changeTimes.TryPeek(out var time) && time < DateTime.UtcNow)
if (_changeTimes.TryPeek(out var time) && time < DateTime.Now)
{
_changeTimes.Dequeue();
_nowValue = !_nowValue;
Expand Down
8 changes: 4 additions & 4 deletions RotationSolver.Basic/Data/RandomDelay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public struct RandomDelay
/// <param name="getRange">A function that returns the range of delay times.</param>
public RandomDelay(Func<(float min, float max)> getRange)
{
_startDelayTime = DateTime.UtcNow;
_startDelayTime = DateTime.Now;
_delayTime = -1;
_ran = new Random(DateTime.UtcNow.Millisecond);
_ran = new Random(DateTime.Now.Millisecond);
_lastValue = false;
GetRange = getRange ?? throw new ArgumentNullException(nameof(getRange));
}
Expand Down Expand Up @@ -62,11 +62,11 @@ public bool Delay(bool originData)
if (_delayTime < 0 && !_lastValue)
{
_lastValue = true;
_startDelayTime = DateTime.UtcNow;
_startDelayTime = DateTime.Now;
_delayTime = min + (float)_ran.NextDouble() * (max - min);
}
// Time's up
else if ((DateTime.UtcNow - _startDelayTime).TotalSeconds >= _delayTime)
else if ((DateTime.Now - _startDelayTime).TotalSeconds >= _delayTime)
{
_delayTime = -1;
return true;
Expand Down
4 changes: 2 additions & 2 deletions RotationSolver.Basic/Data/VfxNewData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ public VfxNewData(ulong objectId, string path)
{
ObjectId = objectId;
Path = path;
Time = DateTime.UtcNow;
Time = DateTime.Now;
}

/// <summary>
/// Gets the duration since the VFX data was created.
/// </summary>
public TimeSpan TimeDuration => DateTime.UtcNow - Time;
public TimeSpan TimeDuration => DateTime.Now - Time;

/// <summary>
/// Returns a string that represents the current object.
Expand Down
34 changes: 17 additions & 17 deletions RotationSolver.Basic/DataCenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ public static MajorConditionSet RightSet
|| Svc.GamepadState.Raw(Dalamud.Game.ClientState.GamePad.GamepadButtons.R1) >=
0.5f;

internal static DateTime EffectTime { private get; set; } = DateTime.UtcNow;
internal static DateTime EffectEndTime { private get; set; } = DateTime.UtcNow;
internal static DateTime EffectTime { private get; set; } = DateTime.Now;
internal static DateTime EffectEndTime { private get; set; } = DateTime.Now;

internal const int ATTACKED_TARGETS_COUNT = 48;
internal static Queue<(ulong id, DateTime time)> AttackedTargets { get; } = new(ATTACKED_TARGETS_COUNT);

internal static bool InEffectTime => DateTime.UtcNow >= EffectTime && DateTime.UtcNow <= EffectEndTime;
internal static bool InEffectTime => DateTime.Now >= EffectTime && DateTime.Now <= EffectEndTime;
internal static Dictionary<ulong, uint> HealHP { get; set; } = [];
internal static Dictionary<ulong, uint> ApplyStatus { get; set; } = [];
internal static uint MPGain { get; set; }
Expand Down Expand Up @@ -139,7 +139,7 @@ public static IAction? CommandNextAction
var next = NextActs.FirstOrDefault();

while (next != null && NextActs.Count > 0 &&
(next.DeadTime < DateTime.UtcNow || IActionHelper.IsLastAction(true, next.Act)))
(next.DeadTime < DateTime.Now || IActionHelper.IsLastAction(true, next.Act)))
{
NextActs.RemoveAt(0);
next = NextActs.FirstOrDefault();
Expand All @@ -156,7 +156,7 @@ public static IAction? CommandNextAction
internal static void AddCommandAction(IAction act, double time)
{
var index = NextActs.FindIndex(i => i.Act.ID == act.ID);
var newItem = new NextAct(act, DateTime.UtcNow.AddSeconds(time));
var newItem = new NextAct(act, DateTime.Now.AddSeconds(time));
if (index < 0)
{
NextActs.Add(newItem);
Expand Down Expand Up @@ -251,7 +251,7 @@ public static float GCDTime(uint gcdCount = 0, float offset = 0)
public static uint[] DutyActions { get; internal set; } = new uint[2];

static DateTime _specialStateStartTime = DateTime.MinValue;
private static double SpecialTimeElapsed => (DateTime.UtcNow - _specialStateStartTime).TotalSeconds;
private static double SpecialTimeElapsed => (DateTime.Now - _specialStateStartTime).TotalSeconds;
public static double SpecialTimeLeft => Service.Config.SpecialDuration - SpecialTimeElapsed;

static SpecialCommandType _specialType = SpecialCommandType.EndSpecial;
Expand All @@ -262,7 +262,7 @@ internal static SpecialCommandType SpecialType
set
{
_specialType = value;
_specialStateStartTime = value == SpecialCommandType.EndSpecial ? DateTime.MinValue : DateTime.UtcNow;
_specialStateStartTime = value == SpecialCommandType.EndSpecial ? DateTime.MinValue : DateTime.Now;
}
}

Expand Down Expand Up @@ -290,7 +290,7 @@ internal static float RaidTimeRaw
if (_startRaidTime == DateTime.MinValue) return 0;

// Calculate and return the total seconds elapsed since the raid started.
return (float)(DateTime.UtcNow - _startRaidTime).TotalSeconds;
return (float)(DateTime.Now - _startRaidTime).TotalSeconds;
}
set
{
Expand All @@ -302,7 +302,7 @@ internal static float RaidTimeRaw
else
{
// Set the raid start time to the current time minus the provided value in seconds.
_startRaidTime = DateTime.UtcNow - TimeSpan.FromSeconds(value);
_startRaidTime = DateTime.Now - TimeSpan.FromSeconds(value);
}
}
}
Expand Down Expand Up @@ -516,11 +516,11 @@ public static bool HasPet
Svc.Condition[ConditionFlag.OccupiedInCutSceneEvent] ||
Svc.Condition[ConditionFlag.Jumping61])
{
_petLastSeen = DateTime.UtcNow;
_petLastSeen = DateTime.Now;
return true;
}

if (!hasPet && _petLastSeen.AddSeconds(3) < DateTime.UtcNow)
if (!hasPet && _petLastSeen.AddSeconds(3) < DateTime.Now)
{
return false;
}
Expand Down Expand Up @@ -621,7 +621,7 @@ public static float DPSTaken
{
try
{
var recs = _damages.Where(r => DateTime.UtcNow - r.ReceiveTime < TimeSpan.FromMilliseconds(5));
var recs = _damages.Where(r => DateTime.Now - r.ReceiveTime < TimeSpan.FromMilliseconds(5));

if (!recs.Any()) return 0;

Expand All @@ -639,8 +639,8 @@ public static float DPSTaken
}

public static ActionRec[] RecordActions => _actions.Reverse().ToArray();
private static DateTime _timeLastActionUsed = DateTime.UtcNow;
public static TimeSpan TimeSinceLastAction => DateTime.UtcNow - _timeLastActionUsed;
private static DateTime _timeLastActionUsed = DateTime.Now;
public static TimeSpan TimeSinceLastAction => DateTime.Now - _timeLastActionUsed;

public static ActionID LastAction { get; private set; } = 0;

Expand Down Expand Up @@ -673,7 +673,7 @@ internal static unsafe void AddActionRec(Action act)
_actions.Dequeue();
}

_timeLastActionUsed = DateTime.UtcNow;
_timeLastActionUsed = DateTime.Now;
_actions.Enqueue(new ActionRec(_timeLastActionUsed, act));
}

Expand All @@ -682,7 +682,7 @@ internal static void ResetAllRecords()
LastAction = 0;
LastGCD = 0;
LastAbility = 0;
_timeLastActionUsed = DateTime.UtcNow;
_timeLastActionUsed = DateTime.Now;
_actions.Clear();

MapEffects.Clear();
Expand All @@ -697,7 +697,7 @@ internal static void AddDamageRec(float damageRatio)
_damages.Dequeue();
}

_damages.Enqueue(new DamageRec(DateTime.UtcNow, damageRatio));
_damages.Enqueue(new DamageRec(DateTime.Now, damageRatio));
}

internal static DateTime KnockbackFinished { get; set; } = DateTime.MinValue;
Expand Down
8 changes: 4 additions & 4 deletions RotationSolver.Basic/Rotations/CustomRotation_GCD.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ partial class CustomRotation
if (Service.Config.HealWhenNothingTodo && InCombat)
{
// Please don't tell me someone's fps is less than 1!!
if (DateTime.UtcNow - _nextTimeToHeal > TimeSpan.FromSeconds(1))
if (DateTime.Now - _nextTimeToHeal > TimeSpan.FromSeconds(1))
{
var min = Service.Config.HealWhenNothingTodoDelay.X;
var max = Service.Config.HealWhenNothingTodoDelay.Y;
_nextTimeToHeal = DateTime.UtcNow + TimeSpan.FromSeconds(new Random().NextDouble() * (max - min) + min);
_nextTimeToHeal = DateTime.Now + TimeSpan.FromSeconds(new Random().NextDouble() * (max - min) + min);
}
else if (_nextTimeToHeal < DateTime.UtcNow)
else if (_nextTimeToHeal < DateTime.Now)
{
_nextTimeToHeal = DateTime.UtcNow;
_nextTimeToHeal = DateTime.Now;

if (PartyMembersMinHP < Service.Config.HealWhenNothingTodoBelow)
{
Expand Down
4 changes: 2 additions & 2 deletions RotationSolver/Helpers/RotationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static AssemblyInfo GetInfo(this Assembly assembly)
var name = assembly.GetName().Name;
var location = assembly.Location;
var company = assembly.GetCustomAttribute<AssemblyCompanyAttribute>()?.Company;
var assemblyInfo = new AssemblyInfo(name, company, location, string.Empty, company, name, DateTime.UtcNow);
var assemblyInfo = new AssemblyInfo(name, company, location, string.Empty, company, name, DateTime.Now);

_assemblyInfos[assembly] = assemblyInfo;

Expand Down Expand Up @@ -70,7 +70,7 @@ public static Assembly LoadCustomRotationAssembly(string filePath)
link?.Donate,
link?.UserName,
link?.Repository,
DateTime.UtcNow);
DateTime.Now);

var existingAssembly = GetAssemblyFromPath(filePath);
if (existingAssembly != null)
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver/Helpers/WarningHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public static void AddSystemWarning(string message)
}
if (!DataCenter.SystemWarnings.ContainsKey(message))
{
DataCenter.SystemWarnings.Add(message, DateTime.UtcNow);
DataCenter.SystemWarnings.Add(message, DateTime.Now);
}
}
}
2 changes: 2 additions & 0 deletions RotationSolver/Updaters/MajorUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ public static void Enable()
Svc.Framework.Update += FrameworkUpdate;
}

private static Exception? _innerException;

Check warning on line 226 in RotationSolver/Updaters/MajorUpdater.cs

View workflow job for this annotation

GitHub Actions / Build

The field 'MajorUpdater._innerException' is never used

Check warning on line 226 in RotationSolver/Updaters/MajorUpdater.cs

View workflow job for this annotation

GitHub Actions / Build

The field 'MajorUpdater._innerException' is never used

Check warning on line 226 in RotationSolver/Updaters/MajorUpdater.cs

View workflow job for this annotation

GitHub Actions / Build

The field 'MajorUpdater._innerException' is never used

Check warning on line 226 in RotationSolver/Updaters/MajorUpdater.cs

View workflow job for this annotation

GitHub Actions / Build

The field 'MajorUpdater._innerException' is never used

static DateTime _closeWindowTime = DateTime.Now;
private unsafe static void CloseWindow()
{
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver/Updaters/MovingUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ internal unsafe static void UpdateCanMove(bool doNextAction)
}

//Action
var action = DateTime.UtcNow - RSCommands._lastUsedTime < TimeSpan.FromMilliseconds(100)
var action = DateTime.Now - RSCommands._lastUsedTime < TimeSpan.FromMilliseconds(100)
? (ActionID)RSCommands._lastActionID
: doNextAction ? (ActionID)(ActionUpdater.NextAction?.AdjustedID ?? 0) : 0;

Expand Down
4 changes: 2 additions & 2 deletions RotationSolver/Updaters/RotationUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ private static void PrintLoadedAssemblies(IEnumerable<string>? assemblies)
// It also has a check to ensure it's not running too frequently, to avoid hurting the FPS of the game.
public static void LocalRotationWatcher()
{
if (DateTime.UtcNow < LastRunTime.AddSeconds(2))
if (DateTime.Now < LastRunTime.AddSeconds(2))
{
return;
}
Expand Down Expand Up @@ -397,7 +397,7 @@ public static void LocalRotationWatcher()
});
}

LastRunTime = DateTime.UtcNow;
LastRunTime = DateTime.Now;
}

public static Type[] TryGetTypes(Assembly assembly)
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver/Updaters/TargetUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ internal static void UpdateTarget()

private static void UpdateTimeToKill()
{
var now = DateTime.UtcNow;
var now = DateTime.Now;
if (now - _lastUpdateTimeToKill < TimeToKillUpdateInterval) return;
_lastUpdateTimeToKill = now;

Expand Down
10 changes: 5 additions & 5 deletions RotationSolver/Watcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ private static void ActionFromEnemy(ActionEffectSet set)
var knock = Svc.Data.GetExcelSheet<Knockback>()?.GetRow(entry.value);
if (knock != null)
{
DataCenter.KnockbackStart = DateTime.UtcNow;
DataCenter.KnockbackFinished = DateTime.UtcNow + TimeSpan.FromSeconds(knock.Distance / (float)knock.Speed);
DataCenter.KnockbackStart = DateTime.Now;
DataCenter.KnockbackFinished = DateTime.Now + TimeSpan.FromSeconds(knock.Distance / (float)knock.Speed);
if (set.Action != null && !OtherConfiguration.HostileCastingKnockback.Contains(set.Action.RowId) && Service.Config.RecordKnockbackies)
{
OtherConfiguration.HostileCastingKnockback.Add(set.Action.RowId);
Expand Down Expand Up @@ -151,8 +151,8 @@ private static void ActionFromSelf(ActionEffectSet set)
DataCenter.ApplyStatus[effect.Key] = effect.Value;
}
DataCenter.MPGain = (uint)set.GetSpecificTypeEffect(ActionEffectType.MpGain).Where(i => i.Key == Player.Object.GameObjectId).Sum(i => i.Value);
DataCenter.EffectTime = DateTime.UtcNow;
DataCenter.EffectEndTime = DateTime.UtcNow.AddSeconds(set.Header.AnimationLockTime + 1);
DataCenter.EffectTime = DateTime.Now;
DataCenter.EffectEndTime = DateTime.Now.AddSeconds(set.Header.AnimationLockTime + 1);

foreach (var effect in set.TargetEffects)
{
Expand All @@ -174,7 +174,7 @@ private static void ActionFromSelf(ActionEffectSet set)
}

// Enqueue the new target
DataCenter.AttackedTargets.Enqueue((effect.TargetID, DateTime.UtcNow));
DataCenter.AttackedTargets.Enqueue((effect.TargetID, DateTime.Now));
}

// Macro
Expand Down

0 comments on commit 50848ef

Please sign in to comment.