diff options
Diffstat (limited to 'NorthstarDLL/core')
-rw-r--r-- | NorthstarDLL/core/convar/cvar.h | 1 | ||||
-rw-r--r-- | NorthstarDLL/core/macros.h | 19 |
2 files changed, 19 insertions, 1 deletions
diff --git a/NorthstarDLL/core/convar/cvar.h b/NorthstarDLL/core/convar/cvar.h index e65e5145..3a3e1815 100644 --- a/NorthstarDLL/core/convar/cvar.h +++ b/NorthstarDLL/core/convar/cvar.h @@ -1,6 +1,5 @@ #pragma once #include "convar.h" -#include "pch.h" //----------------------------------------------------------------------------- // Forward declarations diff --git a/NorthstarDLL/core/macros.h b/NorthstarDLL/core/macros.h new file mode 100644 index 00000000..ae944cca --- /dev/null +++ b/NorthstarDLL/core/macros.h @@ -0,0 +1,19 @@ +#pragma once +template <typename ReturnType, typename... Args> ReturnType CallVFunc(int index, void* thisPtr, Args... args) +{ + return (*reinterpret_cast<ReturnType(__fastcall***)(void*, Args...)>(thisPtr))[index](thisPtr, args...); +} + +template <typename T, size_t index, typename... Args> constexpr T CallVFunc_Alt(void* classBase, Args... args) noexcept +{ + return ((*(T(__thiscall***)(void*, Args...))(classBase))[index])(classBase, args...); +} + +#define STR_HASH(s) (std::hash<std::string>()(s)) + +// Example usage: M_VMETHOD(int, GetEntityIndex, 8, (CBaseEntity* ent), (this, ent)) +#define M_VMETHOD(returnType, name, index, args, argsRaw) \ + FORCEINLINE returnType name args noexcept \ + { \ + return CallVFunc_Alt<returnType, index> argsRaw; \ + } |