static const unsigned long nameStorePtr = 0x00D29BA8 + 0x8; // Player name database
static const unsigned long nameMaskOffset = 0x024; // Offset for the mask used with GUID to select a linked list
static const unsigned long nameBaseOffset = 0x01c; // Offset for the start of the name linked list
static const unsigned long nameStringOffset = 0x020; // Offset to the C string in a name structure
bool getPlayerName(const GUID guid, String * const name)
{
unsigned long mask, base, offset, current, shortGUID, testGUID;
peek(nameStorePtr + nameMaskOffset, &mask);
peek(nameStorePtr + nameBaseOffset, &base);
shortGUID = guid & 0xffffffff; // Only half the guid is used to check for a hit
if (mask == 0xffffffff) {*name = ""; return false;}
offset = 12 * (mask & shortGUID); // select the appropriate linked list
peek(base + offset + 8, ¤t); // first element
peek(base + offset, &offset) // this plus 4 is the offset for the next element
if (current == 0 or (current & 0x1)) {*name = ""; return false;}
peek(current, &testGUID)
while (testGUID != shortGUID)
{
peek(current + offset + 4, ¤t);
if (current == 0 or (current & 0x1)) {*name = ""; return false;}
peek(current, &testGUID)
}
return peekString(current + nameStringOffset, name);
}