fix: Makes gump type id stable (#1358)

This commit is contained in:
Kamron Batman 2023-03-02 19:29:57 -08:00 • committed by GitHub
parent 57ff488d51
commit 50d52fb25e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 60 additions and 4 deletions

View file

@ -81,7 +81,15 @@ public partial class Gump
public bool Closable { get; set; } = true;
public static int GetTypeID(Type type) => type?.FullName?.GetHashCode(StringComparison.Ordinal) ?? -1;
public static int GetTypeID(Type type)
{
unchecked
{
// To use the original .NET Framework deterministic hash code (with really bad performance)
// change the next line to use HashUtility.GetNetFrameworkHashCode
return (int)HashUtility.ComputeHash32(type?.FullName);
}
}
public void AddPage(int page)
{