diff --git a/amxmodx/CPlugin.cpp b/amxmodx/CPlugin.cpp index 04ad342f..ca1a822b 100755 --- a/amxmodx/CPlugin.cpp +++ b/amxmodx/CPlugin.cpp @@ -157,6 +157,11 @@ int CPluginMngr::loadPluginsFromFile(const char* filename, bool warn) { plugin->m_pNullStringOfs = get_amxaddr(plugin->getAMX(), addr); } + + if (amx_FindPubVar(plugin->getAMX(), "NULL_VECTOR", &addr) != AMX_ERR_NOTFOUND) + { + plugin->m_pNullVectorOfs = get_amxaddr(plugin->getAMX(), addr); + } } } @@ -261,7 +266,7 @@ const char* CPluginMngr::CPlugin::getStatus() const return "error"; } -CPluginMngr::CPlugin::CPlugin(int i, const char* p, const char* n, char* e, int d) : name(n), title(n), m_pNullStringOfs(nullptr) +CPluginMngr::CPlugin::CPlugin(int i, const char* p, const char* n, char* e, int d) : name(n), title(n), m_pNullStringOfs(nullptr), m_pNullVectorOfs(nullptr) { const char* unk = "unknown"; diff --git a/amxmodx/CPlugin.h b/amxmodx/CPlugin.h index ced01d6b..4f8d45fe 100755 --- a/amxmodx/CPlugin.h +++ b/amxmodx/CPlugin.h @@ -62,6 +62,7 @@ public: bool m_Debug; cell* m_pNullStringOfs; + cell* m_pNullVectorOfs; public: inline const char* getName() { return name.c_str();} inline const char* getVersion() { return version.c_str();} @@ -92,6 +93,7 @@ public: const char* getStatus() const; inline bool isDebug() const { return m_Debug; } inline cell* getNullStringOfs() const { return m_pNullStringOfs; } + inline cell* getNullVectorOfs() const { return m_pNullVectorOfs; } }; private: diff --git a/amxmodx/amxmodx.cpp b/amxmodx/amxmodx.cpp index 887e6e7c..2aa0efaf 100755 --- a/amxmodx/amxmodx.cpp +++ b/amxmodx/amxmodx.cpp @@ -29,7 +29,7 @@ static cell AMX_NATIVE_CALL get_xvar_id(AMX *amx, cell *params) char* sName = get_amxstring(amx, params[1], 0, len); cell ptr; - if (!strcmp(sName, "MaxClients") || !strcmp(sName, "NULL_STRING")) + if (!strcmp(sName, "MaxClients") || !strcmp(sName, "NULL_STRING") || !strcmp(sName, "NULL_VECTOR")) { return -1; } diff --git a/amxmodx/amxmodx.h b/amxmodx/amxmodx.h index 4bf6b85e..af60eaa9 100755 --- a/amxmodx/amxmodx.h +++ b/amxmodx/amxmodx.h @@ -276,7 +276,8 @@ char* format_amxstring(AMX *amx, cell *params, int parm, int& len); AMX* get_amxscript(int, void**, const char**); const char* get_amxscriptname(AMX* amx); char* get_amxstring(AMX *amx, cell amx_addr, int id, int& len); -char *get_amxstring_null(AMX *amx, cell amx_addr, int id, int& len); +char* get_amxstring_null(AMX *amx, cell amx_addr, int id, int& len); +cell* get_amxvector_null(AMX *amx, cell amx_addr); extern "C" size_t get_amxstring_r(AMX *amx, cell amx_addr, char *destination, int maxlen); int amxstring_len(cell* cstr); diff --git a/amxmodx/string.cpp b/amxmodx/string.cpp index 492c1d7a..25503fd7 100755 --- a/amxmodx/string.cpp +++ b/amxmodx/string.cpp @@ -186,6 +186,17 @@ char *get_amxstring_null(AMX *amx, cell amx_addr, int id, int& len) return get_amxstring(amx, amx_addr, id, len); } +cell *get_amxvector_null(AMX *amx, cell amx_addr) +{ + cell *addr = get_amxaddr(amx, amx_addr); + if (addr == g_plugins.findPluginFast(amx)->getNullVectorOfs()) + { + return nullptr; + } + + return addr; +} + void copy_amxmemory(cell* dest, cell* src, int len) { while (len--) diff --git a/plugins/include/amxconst.inc b/plugins/include/amxconst.inc index d2b4f681..2512f09f 100755 --- a/plugins/include/amxconst.inc +++ b/plugins/include/amxconst.inc @@ -49,6 +49,11 @@ public stock const MaxClients; */ public stock const NULL_STRING[1]; +/** + * Pass this into certain functions to act as a C++ NULL + */ +public stock const Float:NULL_VECTOR[3]; + /** * The maximum buffer size required to store a clients name. */