private static int CompareFactionHash(IntPtr hProcess, int hash1, int hash2)
{
if (hash1 == 0 || hash2 == 0)
return -1;
int hashCheck1 = 0, hashCheck2 = 0;
int hashCompare = 0;
int hashIndex = 0;
byte[] bHash1 = new byte[0x40];
byte[] bHash2 = new byte[0x40];
Memory.ReadMemory(hProcess, hash1, ref bHash1);
Memory.ReadMemory(hProcess, hash2, ref bHash2);
hashCheck1 = BitConverter.ToInt32(bHash1, 0x04);
hashCheck2 = BitConverter.ToInt32(bHash2, 0x04);
//bitwise compare of [bHash1+0x14] and [bHash2+0x0C]
if ((BitConverter.ToInt32(bHash1, 0x14) & BitConverter.ToInt32(bHash2, 0x0C)) != 0)
return 1; //hostile
hashIndex = 0x18;
hashCompare = BitConverter.ToInt32(bHash1, hashIndex);
if (hashCompare != 0)
{
for (int i = 0; i < 4; i++)
{
if (hashCompare == hashCheck2)
return 1; //hostile
hashIndex += 4;
hashCompare = BitConverter.ToInt32(bHash1, hashIndex);
if (hashCompare == 0)
break;
}
}
//bitwise compare of [bHash1+0x10] and [bHash2+0x0C]
if ((BitConverter.ToInt32(bHash1, 0x10) & BitConverter.ToInt32(bHash2, 0x0C)) != 0)
return 4; //friendly
hashIndex = 0x28;
hashCompare = BitConverter.ToInt32(bHash1, hashIndex);
if (hashCompare != 0)
{
for (int i = 0; i < 4; i++)
{
if (hashCompare == hashCheck2)
return 4; //friendly
hashIndex += 4;
hashCompare = BitConverter.ToInt32(bHash1, hashIndex);
if (hashCompare == 0)
break;
}
}
//bitwise compare of [bHash2+0x10] and [bHash1+0x0C]
if ((BitConverter.ToInt32(bHash2, 0x10) & BitConverter.ToInt32(bHash1, 0x0C)) != 0)
return 4; //friendly
hashIndex = 0x28;
hashCompare = BitConverter.ToInt32(bHash2, hashIndex);
if (hashCompare != 0)
{
for (int i = 0; i < 4; i++)
{
if (hashCompare == hashCheck1)
return 4; //friendly
hashIndex += 4;
hashCompare = BitConverter.ToInt32(bHash2, hashIndex);
if (hashCompare == 0)
break;
}
}
return 3; //neutral
}