mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2025-05-05 03:19:33 +03:00
Add public vars for plugin data and small refactoring get_xvar_id native
This commit is contained in:
parent
295d09df8b
commit
60aa1cd837
@ -160,6 +160,32 @@ int CPluginMngr::loadPluginsFromFile(const char* filename, bool warn)
|
||||
set_amxstring(plugin->getAMX(), addr, STRING(gpGlobals->mapname), MAX_MAPNAME_LENGTH - 1);
|
||||
}
|
||||
|
||||
auto length = 0;
|
||||
if (amx_FindPubVar(plugin->getAMX(), "PluginName", &addr) != AMX_ERR_NOTFOUND)
|
||||
{
|
||||
plugin->setTitle(get_amxstring(plugin->getAMX(), addr, 0, length));
|
||||
}
|
||||
|
||||
if (amx_FindPubVar(plugin->getAMX(), "PluginVersion", &addr) != AMX_ERR_NOTFOUND)
|
||||
{
|
||||
plugin->setVersion(get_amxstring(plugin->getAMX(), addr, 0, length));
|
||||
}
|
||||
|
||||
if (amx_FindPubVar(plugin->getAMX(), "PluginAuthor", &addr) != AMX_ERR_NOTFOUND)
|
||||
{
|
||||
plugin->setAuthor(get_amxstring(plugin->getAMX(), addr, 0, length));
|
||||
}
|
||||
|
||||
if (amx_FindPubVar(plugin->getAMX(), "PluginURL", &addr) != AMX_ERR_NOTFOUND)
|
||||
{
|
||||
plugin->setUrl(get_amxstring(plugin->getAMX(), addr, 0, length));
|
||||
}
|
||||
|
||||
if (amx_FindPubVar(plugin->getAMX(), "PluginDescription", &addr) != AMX_ERR_NOTFOUND)
|
||||
{
|
||||
plugin->setDescription(get_amxstring(plugin->getAMX(), addr, 0, length));
|
||||
}
|
||||
|
||||
if (amx_FindPubVar(plugin->getAMX(), "NULL_STRING", &addr) != AMX_ERR_NOTFOUND)
|
||||
{
|
||||
plugin->m_pNullStringOfs = get_amxaddr(plugin->getAMX(), addr);
|
||||
@ -281,6 +307,7 @@ CPluginMngr::CPlugin::CPlugin(int i, const char* p, const char* n, char* e, size
|
||||
title = unk;
|
||||
author = unk;
|
||||
version = unk;
|
||||
url = unk;
|
||||
|
||||
char file[PLATFORM_MAX_PATH];
|
||||
char* path = build_pathname_r(file, sizeof(file), "%s/%s", p, n);
|
||||
|
@ -56,6 +56,8 @@ public:
|
||||
ke::AString version;
|
||||
ke::AString title;
|
||||
ke::AString author;
|
||||
ke::AString url;
|
||||
ke::AString description;
|
||||
ke::AString errorMsg;
|
||||
|
||||
unsigned int failcounter;
|
||||
@ -78,6 +80,8 @@ public:
|
||||
inline const char* getVersion() { return version.chars();}
|
||||
inline const char* getTitle() { return title.chars();}
|
||||
inline const char* getAuthor() { return author.chars();}
|
||||
inline const char* getUrl() { return url.chars(); }
|
||||
inline const char* getDescription() { return description.chars(); }
|
||||
inline const char* getError() { return errorMsg.chars();}
|
||||
inline int getStatusCode() { return status; }
|
||||
inline int getId() const { return id; }
|
||||
@ -86,6 +90,8 @@ public:
|
||||
inline void setTitle(const char* n) { title = n; }
|
||||
inline void setAuthor(const char* n) { author =n; }
|
||||
inline void setVersion(const char* n) { version = n; }
|
||||
inline void setUrl(const char* n) { url = n; }
|
||||
inline void setDescription(const char* n) { description = n; }
|
||||
inline void setError(const char* n) { errorMsg = n; }
|
||||
inline bool isValid() const { return (status >= ps_paused); }
|
||||
inline bool isPaused() const { return ((status == ps_paused) || (status == ps_stopped)); }
|
||||
|
@ -23,16 +23,31 @@
|
||||
extern CFlagManager FlagMan;
|
||||
ke::Vector<CAdminData *> DynamicAdmins;
|
||||
|
||||
const char *g_sInaccessibleXVars[] =
|
||||
{
|
||||
"MaxClients",
|
||||
"MapName",
|
||||
"PluginName",
|
||||
"PluginVersion",
|
||||
"PluginAuthor",
|
||||
"PluginURL",
|
||||
"NULL_STRING",
|
||||
"NULL_VECTOR"
|
||||
};
|
||||
|
||||
static cell AMX_NATIVE_CALL get_xvar_id(AMX *amx, cell *params)
|
||||
{
|
||||
int len;
|
||||
char* sName = get_amxstring(amx, params[1], 0, len);
|
||||
cell ptr;
|
||||
|
||||
if (!strcmp(sName, "MaxClients") || !strcmp(sName, "MapName") || !strcmp(sName, "NULL_STRING") || !strcmp(sName, "NULL_VECTOR"))
|
||||
for (auto var : g_sInaccessibleXVars)
|
||||
{
|
||||
if (!strcmp(sName, var))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
for (CPluginMngr::iterator a = g_plugins.begin(); a ; ++a)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user