fwiffo
Sorceror
As for reference, I've picked up this code from .net:
http://referencesource.microsoft.com/netframework.aspx
where the "String.GetHashCode" is also referenced, for our purpose anyway you have to pick up the Gump.cs, in Server/Gumps folder, and change accordingly:
Original RunUO code to be changed, also mind that if you're using x64 machines, this could come handy even to non-unices users...
Modified code:
that's all, simple uh?
http://referencesource.microsoft.com/netframework.aspx
where the "String.GetHashCode" is also referenced, for our purpose anyway you have to pick up the Gump.cs, in Server/Gumps folder, and change accordingly:
Original RunUO code to be changed, also mind that if you're using x64 machines, this could come handy even to non-unices users...
Code:
public static int GetTypeID( Type type )
{
return type.FullName.GetHashCode();
}
Modified code:
Code:
public static int GetTypeID( Type type )
{
return GetHashCode32(type.FullName);
}
private static int GetHashCode32(string s)
{
unsafe
{
fixed (char *src = s)
{
Contract.Assert(src[s.Length] == '\0', "src[this.Length] == '\\0'");
Contract.Assert( ((int)src)%4 == 0, "Managed string should start at 4 bytes boundary");
int hash1 = (5381<<16) + 5381;
int hash2 = hash1;
// 32 bit machines.
int* pint = (int *)src;
int len = s.Length;
while (len > 2)
{
hash1 = ((hash1 << 5) + hash1 + (hash1 >> 27)) ^ pint[0];
hash2 = ((hash2 << 5) + hash2 + (hash2 >> 27)) ^ pint[1];
pint += 2;
len -= 4;
}
if (len > 0)
{
hash1 = ((hash1 << 5) + hash1 + (hash1 >> 27)) ^ pint[0];
}
return hash1 + (hash2 * 1566083941);
}
}
}
that's all, simple uh?