rebuild PlayerManager to CacheCreationService and optimize creation of the local file cache
This commit is contained in:
@@ -226,11 +226,13 @@ public class DalamudUtil : IDisposable
|
||||
{
|
||||
if (!_clientState.IsLoggedIn || characterAddress == IntPtr.Zero) return;
|
||||
|
||||
Logger.Verbose($"Starting wait for {name} to draw");
|
||||
|
||||
var obj = (GameObject*)characterAddress;
|
||||
const int tick = 250;
|
||||
int curWaitTime = 0;
|
||||
// ReSharper disable once LoopVariableIsNeverChangedInsideLoop
|
||||
while ((obj->RenderFlags & 0b100000000000) == 0b100000000000 && (!ct?.IsCancellationRequested ?? true) && curWaitTime < timeOut) // 0b100000000000 is "still rendering" or something
|
||||
while ((obj->DrawObject == null || (obj->RenderFlags & 0b100000000000) == 0b100000000000) && (!ct?.IsCancellationRequested ?? true) && curWaitTime < timeOut) // 0b100000000000 is "still rendering" or something
|
||||
{
|
||||
Logger.Verbose($"Waiting for {name} to finish drawing");
|
||||
curWaitTime += tick;
|
||||
|
||||
45
MareSynchronos/Utils/FileReplacementComparer.cs
Normal file
45
MareSynchronos/Utils/FileReplacementComparer.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using MareSynchronos.Models;
|
||||
|
||||
namespace MareSynchronos.Utils;
|
||||
|
||||
public class FileReplacementComparer : IEqualityComparer<FileReplacement>
|
||||
{
|
||||
public static FileReplacementComparer Instance => _instance;
|
||||
private static FileReplacementComparer _instance = new();
|
||||
private FileReplacementComparer() { }
|
||||
public bool Equals(FileReplacement? x, FileReplacement? y)
|
||||
{
|
||||
if (x == null || y == null) return false;
|
||||
return x.ResolvedPath.Equals(y.ResolvedPath) && CompareLists(x.GamePaths, y.GamePaths);
|
||||
}
|
||||
|
||||
public int GetHashCode(FileReplacement obj)
|
||||
{
|
||||
return HashCode.Combine(obj.ResolvedPath.GetHashCode(StringComparison.OrdinalIgnoreCase), GetOrderIndependentHashCode(obj.GamePaths));
|
||||
}
|
||||
|
||||
private static int GetOrderIndependentHashCode<T>(IEnumerable<T> source)
|
||||
{
|
||||
int hash = 0;
|
||||
foreach (T element in source)
|
||||
{
|
||||
hash = unchecked(hash +
|
||||
EqualityComparer<T>.Default.GetHashCode(element));
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
private bool CompareLists(List<string> list1, List<string> list2)
|
||||
{
|
||||
if (list1.Count != list2.Count)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < list1.Count; i++)
|
||||
{
|
||||
if (!string.Equals(list1[i], list2[i], StringComparison.OrdinalIgnoreCase))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user