I am working on a bot for an emu server, so my offsets are from patch 4.0.6 - 13623
here are the NameOffsets
Code:
public enum NameOffsets : ulong
{
ObjectName1 = 0x1CC,
ObjectName2 = 0xB4,
UnitName1 = 0xA24,
UnitName2 = 0x60,
nameStore = 0x89ACC0 + 0x8,
nameMask = 0x24,
nameBase = 0x1C,
nameString = 0x20
}
which I am pretty sure are correct, because I can grab NPC name from Guid with no problem
Can anyone tell me why this next function fails at "Exception3"
specifically this read fails "testGUID = wow.ReadUInt((uint)current);"
(credits to WhatSupMang)
Code:
public string PlayerNameFromGuid(ulong Guid)
{
ulong mask, base_, offset, current, shortGUID, testGUID;
try
{
mask = wow.ReadUInt(WoWBase = (uint)NameOffsets.nameStore + (uint)NameOffsets.nameMask);
}
catch (Exception)
{
return "Exception1";
}
base_ = wow.ReadUInt(WoWBase + (uint)NameOffsets.nameStore + (uint)NameOffsets.nameBase);
shortGUID = Guid & 0xFFFFFFFF;
offset = 12 * (mask & shortGUID);
try
{
current = wow.ReadUInt((uint)base_ + (uint)offset + 8);
}
catch (Exception)
{
return "Exception2";
}
offset = wow.ReadUInt((uint)base_ + (uint)offset);
if ((current & 0x1) == 0x1) { return ""; }
try
{
testGUID = wow.ReadUInt((uint)current);
}
catch (Exception)
{
return "Exception3";
}
while (testGUID != shortGUID)
{
current = wow.ReadUInt((uint)current + (uint)offset + 4);
if ((current & 0x1) == 0x1) { return ""; }
try
{
testGUID = wow.ReadUInt((uint)current);
}
catch (Exception)
{
return "Exception4";
}
}
return wow.ReadASCIIString((uint)current + (uint)NameOffsets.nameString, 30);
}//end PlayerNameFromGuid