@@ -8,7 +8,7 @@ namespace MareSynchronos.API
|
|||||||
{
|
{
|
||||||
public class Api
|
public class Api
|
||||||
{
|
{
|
||||||
public const int Version = 5;
|
public const int Version = 6;
|
||||||
public const string Path = "/mare";
|
public const string Path = "/mare";
|
||||||
|
|
||||||
public const string SendFileAbortUpload = "AbortUpload";
|
public const string SendFileAbortUpload = "AbortUpload";
|
||||||
|
|||||||
@@ -1,12 +1,50 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace MareSynchronos.API
|
namespace MareSynchronos.API
|
||||||
{
|
{
|
||||||
public record CharacterCacheDto
|
public class CharacterCacheDto
|
||||||
{
|
{
|
||||||
public List<FileReplacementDto> FileReplacements { get; set; } = new();
|
public Dictionary<ObjectKind, List<FileReplacementDto>> FileReplacements { get; set; } = new();
|
||||||
public string GlamourerData { get; set; }
|
public Dictionary<ObjectKind, string> GlamourerData { get; set; } = new();
|
||||||
public string ManipulationData { get; set; }
|
public string ManipulationData { get; set; } = string.Empty;
|
||||||
public string Hash { get; set; }
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return GetHashCode() + Environment.NewLine + "Manip:" + ManipulationData + Environment.NewLine
|
||||||
|
+ string.Join(Environment.NewLine, GlamourerData.Select(g => g.Key + ":" + g.Value)) + Environment.NewLine
|
||||||
|
+ string.Join(Environment.NewLine, FileReplacements.Select(g => g.Key + Environment.NewLine + string.Join(Environment.NewLine, g.Value)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
int fileReplacementsHash = 0;
|
||||||
|
foreach (var item in FileReplacements)
|
||||||
|
{
|
||||||
|
foreach (var values in item.Value)
|
||||||
|
{
|
||||||
|
fileReplacementsHash = unchecked(fileReplacementsHash + values.GetHashCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int glamourerHash = 0;
|
||||||
|
foreach (var item in GlamourerData)
|
||||||
|
{
|
||||||
|
glamourerHash = unchecked(glamourerHash + item.Value.GetHashCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
return HashCode.Combine(fileReplacementsHash, glamourerHash, ManipulationData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,39 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace MareSynchronos.API
|
namespace MareSynchronos.API
|
||||||
{
|
{
|
||||||
public record FileReplacementDto
|
public class FileReplacementDto
|
||||||
{
|
{
|
||||||
public string[] GamePaths { get; set; } = Array.Empty<string>();
|
public string[] GamePaths { get; set; } = Array.Empty<string>();
|
||||||
public string Hash { get; set; }
|
public string Hash { get; set; }
|
||||||
|
|
||||||
|
public override bool Equals(object? otherObj)
|
||||||
|
{
|
||||||
|
if (otherObj == null || otherObj is not FileReplacementDto other) return false;
|
||||||
|
return Hash == other.Hash && Enumerable.SequenceEqual(GamePaths, other.GamePaths);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
return HashCode.Combine(GetOrderIndependentHashCode(GamePaths), Hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
public 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return Hash + ":" + string.Join(",", GamePaths);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
17
MareSynchronosAPI/ObjectKind.cs
Normal file
17
MareSynchronosAPI/ObjectKind.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MareSynchronos.API
|
||||||
|
{
|
||||||
|
public enum ObjectKind
|
||||||
|
{
|
||||||
|
Player = 0,
|
||||||
|
Minion = 1,
|
||||||
|
Companion = 2,
|
||||||
|
Pet = 3,
|
||||||
|
Mount = 4
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user