What do you think of my way to check if we got a playerBase (only read next pointer if previous pointer reading action was successful):
ReadOffset returns NULL if it fails.
Code:
// read the playerBase
UINT_PTR playerBase = Memory.ReadOffset<UINT_PTR>(Memory.BaseAddr+PlayerBasePointer);
if (!(playerBase?playerBase=Memory.ReadOffset<UINT_PTR>(playerBase+PlayerBaseOffset1):false,playerBase?playerBase=Memory.ReadOffset<UINT_PTR>(playerBase+PlayerBaseOffset2):false))
Memory._error(7);
else
std::cout << "The playerBase: " << reinterpret_cast<PVOID>(playerBase) << std::endl;
.
And this is how it would look like with normal if clauses:
Code:
// read the playerBase
UINT_PTR playerBase = Memory.ReadOffset<UINT_PTR>(Memory.BaseAddr+PlayerBasePointer);
if (playerBase != NULL)
{
playerBase = Memory.ReadOffset<UINT_PTR>(playerBase+PlayerBaseOffset1);
if (playerBase != NULL)
playerBase = Memory.ReadOffset<UINT_PTR>(playerBase+PlayerBaseOffset2);
}
if (playerBase == NULL)
Memory._error(7);
else
std::cout << "The playerBase: " << reinterpret_cast<PVOID>(playerBase) << std::endl;
Which way would you prefer?