From 3d9a998239d7733f0d3f168982fcce7c4f70fb10 Mon Sep 17 00:00:00 2001 From: John Magdy Lotfy Kamel <19735243+Zorono@users.noreply.github.com> Date: Mon, 12 Jan 2026 19:14:35 +0000 Subject: [PATCH 1/2] Update syscalls.cpp 1. `error C2999: maximum template instantiation depth of 1000 exceeded (see '/templateDepth:N')` was persistent 2. ``` error C2039: 'Generate': is not a member of 'NativeGenerator<0>' error C3861: 'Generate': identifier not found ``` --- amx-deps/src/syscalls.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/amx-deps/src/syscalls.cpp b/amx-deps/src/syscalls.cpp index 25f9250..824642d 100644 --- a/amx-deps/src/syscalls.cpp +++ b/amx-deps/src/syscalls.cpp @@ -86,7 +86,12 @@ struct NativeGenerator { } }; -template<> struct NativeGenerator {}; +template<> struct NativeGenerator<0> { + static void Generate() {} +}; +template<> struct NativeGenerator { + static void Generate() {} +}; template const char* NativeGenerator::BoundNativeName = nullptr; @@ -509,3 +514,4 @@ int amx_SAMPInit(AMX *amx) { return amx_Register(amx, sampNatives, -1); } + From 0a7b6e5a12e1651ef26e0b95804210caff0799cb Mon Sep 17 00:00:00 2001 From: John Magdy Lotfy Kamel <19735243+Zorono@users.noreply.github.com> Date: Tue, 13 Jan 2026 18:36:40 +0000 Subject: [PATCH 2/2] Update syscalls.cpp --- amx-deps/src/syscalls.cpp | 46 +++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/amx-deps/src/syscalls.cpp b/amx-deps/src/syscalls.cpp index 824642d..a95301b 100644 --- a/amx-deps/src/syscalls.cpp +++ b/amx-deps/src/syscalls.cpp @@ -70,32 +70,33 @@ AMX_NATIVE boundNatives[MAX_SAMP_NATIVES]; template struct NativeGenerator { - static const char* BoundNativeName; - - static cell AMX_NATIVE_CALL DoNative(AMX* amx, const cell* params) { - return n_samp(amx, params, BoundNativeName); - } - - static void Generate() { - boundNativeNames[index] = &BoundNativeName; - boundNatives[index] = reinterpret_cast(&DoNative); - - if constexpr (index + 1 < MAX_SAMP_NATIVES) { - NativeGenerator::Generate(); - } - } -}; - -template<> struct NativeGenerator<0> { - static void Generate() {} -}; -template<> struct NativeGenerator { - static void Generate() {} + static const char* BoundNativeName; + static cell AMX_NATIVE_CALL DoNative(AMX* amx, const cell* params) { + return n_samp(amx, params, BoundNativeName); + } + + static void Register() { + boundNativeNames[index] = &BoundNativeName; + boundNatives[index] = reinterpret_cast(&DoNative); + } }; template const char* NativeGenerator::BoundNativeName = nullptr; +template +struct RecursiveRegister { + static void Run() { + if constexpr (Start == End) { + NativeGenerator::Register(); + } else { + constexpr size_t Mid = Start + (End - Start) / 2; + RecursiveRegister::Run(); + RecursiveRegister::Run(); + } + } +}; + int callLuaMTRead(lua_State *luaVM) { luaL_checktype(luaVM, 1, LUA_TTABLE); lua_getfield(luaVM, 1, "amx"); @@ -468,7 +469,7 @@ void initSAMPSyscalls() { if(!mainVM || sampNatives) return; - NativeGenerator<0>::Generate(); + RecursiveRegister<0, MAX_SAMP_NATIVES - 1>::Run(); lua_getglobal(mainVM, "g_SAMPSyscallPrototypes"); int numNatives = 0; @@ -514,4 +515,3 @@ int amx_SAMPInit(AMX *amx) { return amx_Register(amx, sampNatives, -1); } -