aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDLL/core
diff options
context:
space:
mode:
authorEmma Miler <emma.pi@protonmail.com>2022-12-22 20:05:45 +0100
committerGitHub <noreply@github.com>2022-12-22 20:05:45 +0100
commitff889f16820430461dec797bb34eeab195b5e930 (patch)
treec145c0285d779975ff521319824c0f7210e3933a /NorthstarDLL/core
parent64100065b55f79e76542ba689545c60e6fb0dcef (diff)
downloadNorthstarLauncher-ff889f16820430461dec797bb34eeab195b5e930.tar.gz
NorthstarLauncher-ff889f16820430461dec797bb34eeab195b5e930.zip
Add NSGetModName (#366)
* Stackinfos * Formatting * Add option for depth * Revert "Merge branch 'main' into stackinfos" This reverts commit e9e8948d2ae9ab72095eb2162de40383b7211276, reversing changes made to d1cf18f7165a9d4fbe7f8ae2f1dfacbba36e4852. * Move macros header * Add macro header to filters * Fix merge conflict mistake * Fix stuff * I hate git * create `NSGetCurrentModName` * Fix merge issues
Diffstat (limited to 'NorthstarDLL/core')
-rw-r--r--NorthstarDLL/core/convar/cvar.h1
-rw-r--r--NorthstarDLL/core/macros.h19
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; \
+ }