mirror of
https://github.com/CookiePLMonster/SilentPatch.git
synced 2024-12-29 15:23:02 +05:00
Branchless GetExtendedID
This commit is contained in:
parent
9eec64ab83
commit
07d994cc3e
2 changed files with 8 additions and 6 deletions
|
@ -3,7 +3,7 @@
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
||||||
int32_t (*FLAUtils::GetExtendedIDFunc)(const void* ptr) = nullptr;
|
int32_t (*FLAUtils::GetExtendedIDFunc)(const void* ptr) = FLAUtils::GetExtendedID_Stock;
|
||||||
|
|
||||||
void FLAUtils::Init()
|
void FLAUtils::Init()
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,11 +7,7 @@ class FLAUtils
|
||||||
public:
|
public:
|
||||||
static int32_t GetExtendedID(const void* ptr)
|
static int32_t GetExtendedID(const void* ptr)
|
||||||
{
|
{
|
||||||
if ( GetExtendedIDFunc != nullptr )
|
return GetExtendedIDFunc(ptr);
|
||||||
return GetExtendedIDFunc(ptr);
|
|
||||||
|
|
||||||
uint16_t uID = *static_cast<const uint16_t*>(ptr);
|
|
||||||
return uID > MAX_UINT16_ID ? *static_cast<const int16_t*>(ptr) : uID;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Init();
|
static void Init();
|
||||||
|
@ -19,5 +15,11 @@ public:
|
||||||
private:
|
private:
|
||||||
static const int32_t MAX_UINT16_ID = 0xFFFD;
|
static const int32_t MAX_UINT16_ID = 0xFFFD;
|
||||||
|
|
||||||
|
static int32_t GetExtendedID_Stock(const void* ptr)
|
||||||
|
{
|
||||||
|
uint16_t uID = *static_cast<const uint16_t*>(ptr);
|
||||||
|
return uID > MAX_UINT16_ID ? *static_cast<const int16_t*>(ptr) : uID;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t (*GetExtendedIDFunc)(const void* ptr);
|
static int32_t (*GetExtendedIDFunc)(const void* ptr);
|
||||||
};
|
};
|
Loading…
Reference in a new issue