Add NULL_VECTOR

This commit is contained in:
Valentin Grünbacher 2015-05-06 11:28:54 +02:00
parent 39cc240a4e
commit fdb180e062
6 changed files with 27 additions and 3 deletions

View File

@ -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";

View File

@ -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:

View File

@ -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;
}

View File

@ -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);

View File

@ -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--)

View File

@ -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.
*/