Rework build pathname functions (#422)
* Rework build_pathname* functions * Replace old platform defines with the new ones * Correct usage of build_pathname_r() * Fix inconsistencies (white spaces) * Remove useless defines
This commit is contained in:
parent
fa3d28872e
commit
9551c70c59
|
@ -19,14 +19,14 @@
|
||||||
extern const char *no_function;
|
extern const char *no_function;
|
||||||
|
|
||||||
CPluginMngr::CPlugin* CPluginMngr::loadPlugin(const char* path, const char* name, char* error, int debug)
|
CPluginMngr::CPlugin* CPluginMngr::loadPlugin(const char* path, const char* name, char* error, int debug)
|
||||||
{
|
{
|
||||||
CPlugin** a = &head;
|
CPlugin** a = &head;
|
||||||
|
|
||||||
while (*a)
|
while (*a)
|
||||||
a = &(*a)->next;
|
a = &(*a)->next;
|
||||||
|
|
||||||
*a = new CPlugin(pCounter++, path, name, error, debug);
|
*a = new CPlugin(pCounter++, path, name, error, debug);
|
||||||
|
|
||||||
return (*a);
|
return (*a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,10 +42,10 @@ void CPluginMngr::Finalize()
|
||||||
{
|
{
|
||||||
if (m_Finalized)
|
if (m_Finalized)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pNatives = BuildNativeTable();
|
pNatives = BuildNativeTable();
|
||||||
CPlugin *a = head;
|
CPlugin *a = head;
|
||||||
|
|
||||||
while (a)
|
while (a)
|
||||||
{
|
{
|
||||||
if (a->getStatusCode() == ps_running)
|
if (a->getStatusCode() == ps_running)
|
||||||
|
@ -55,16 +55,16 @@ void CPluginMngr::Finalize()
|
||||||
}
|
}
|
||||||
a = a->next;
|
a = a->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Finalized = true;
|
m_Finalized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CPluginMngr::loadPluginsFromFile(const char* filename, bool warn)
|
int CPluginMngr::loadPluginsFromFile(const char* filename, bool warn)
|
||||||
{
|
{
|
||||||
char file[256];
|
char file[PLATFORM_MAX_PATH];
|
||||||
FILE *fp = fopen(build_pathname_r(file, sizeof(file) - 1, "%s", filename), "rt");
|
FILE *fp = fopen(build_pathname_r(file, sizeof(file), "%s", filename), "rt");
|
||||||
|
|
||||||
if (!fp)
|
if (!fp)
|
||||||
{
|
{
|
||||||
if (warn)
|
if (warn)
|
||||||
{
|
{
|
||||||
|
@ -72,23 +72,23 @@ int CPluginMngr::loadPluginsFromFile(const char* filename, bool warn)
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find now folder
|
// Find now folder
|
||||||
char pluginName[256], error[256], debug[256];
|
char pluginName[256], error[256], debug[256];
|
||||||
int debugFlag = 0;
|
int debugFlag = 0;
|
||||||
const char *pluginsDir = get_localinfo("amxx_pluginsdir", "addons/amxmodx/plugins");
|
const char *pluginsDir = get_localinfo("amxx_pluginsdir", "addons/amxmodx/plugins");
|
||||||
|
|
||||||
char line[512];
|
char line[512];
|
||||||
|
|
||||||
List<ke::AString *>::iterator block_iter;
|
List<ke::AString *>::iterator block_iter;
|
||||||
|
|
||||||
while (!feof(fp))
|
while (!feof(fp))
|
||||||
{
|
{
|
||||||
pluginName[0] = '\0';
|
pluginName[0] = '\0';
|
||||||
|
|
||||||
debug[0] = '\0';
|
debug[0] = '\0';
|
||||||
debugFlag = 0;
|
debugFlag = 0;
|
||||||
|
|
||||||
line[0] = '\0';
|
line[0] = '\0';
|
||||||
fgets(line, sizeof(line), fp);
|
fgets(line, sizeof(line), fp);
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ int CPluginMngr::loadPluginsFromFile(const char* filename, bool warn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sscanf(line, "%s %s", pluginName, debug);
|
sscanf(line, "%s %s", pluginName, debug);
|
||||||
|
|
||||||
if (!isalnum(*pluginName))
|
if (!isalnum(*pluginName))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
@ -138,7 +138,7 @@ int CPluginMngr::loadPluginsFromFile(const char* filename, bool warn)
|
||||||
}
|
}
|
||||||
|
|
||||||
CPlugin* plugin = loadPlugin(pluginsDir, pluginName, error, debugFlag);
|
CPlugin* plugin = loadPlugin(pluginsDir, pluginName, error, debugFlag);
|
||||||
|
|
||||||
if (plugin->getStatusCode() == ps_bad_load)
|
if (plugin->getStatusCode() == ps_bad_load)
|
||||||
{
|
{
|
||||||
char errorMsg[255];
|
char errorMsg[255];
|
||||||
|
@ -173,13 +173,13 @@ int CPluginMngr::loadPluginsFromFile(const char* filename, bool warn)
|
||||||
|
|
||||||
void CPluginMngr::clear()
|
void CPluginMngr::clear()
|
||||||
{
|
{
|
||||||
CPlugin**a = &head;
|
CPlugin**a = &head;
|
||||||
|
|
||||||
while (*a)
|
while (*a)
|
||||||
unloadPlugin(a);
|
unloadPlugin(a);
|
||||||
|
|
||||||
m_Finalized = false;
|
m_Finalized = false;
|
||||||
|
|
||||||
if (pNatives)
|
if (pNatives)
|
||||||
{
|
{
|
||||||
delete [] pNatives;
|
delete [] pNatives;
|
||||||
|
@ -198,20 +198,20 @@ void CPluginMngr::clear()
|
||||||
CPluginMngr::CPlugin* CPluginMngr::findPlugin(AMX *amx)
|
CPluginMngr::CPlugin* CPluginMngr::findPlugin(AMX *amx)
|
||||||
{
|
{
|
||||||
CPlugin*a = head;
|
CPlugin*a = head;
|
||||||
|
|
||||||
while (a && &a->amx != amx)
|
while (a && &a->amx != amx)
|
||||||
a = a->next;
|
a = a->next;
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
CPluginMngr::CPlugin* CPluginMngr::findPlugin(int index)
|
CPluginMngr::CPlugin* CPluginMngr::findPlugin(int index)
|
||||||
{
|
{
|
||||||
CPlugin*a = head;
|
CPlugin*a = head;
|
||||||
|
|
||||||
while (a && index--)
|
while (a && index--)
|
||||||
a = a->next;
|
a = a->next;
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,17 +219,17 @@ CPluginMngr::CPlugin* CPluginMngr::findPlugin(const char* name)
|
||||||
{
|
{
|
||||||
if (!name)
|
if (!name)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int len = strlen(name);
|
int len = strlen(name);
|
||||||
|
|
||||||
if (!len)
|
if (!len)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
CPlugin*a = head;
|
CPlugin*a = head;
|
||||||
|
|
||||||
while (a && strncmp(a->name.chars(), name, len))
|
while (a && strncmp(a->name.chars(), name, len))
|
||||||
a = a->next;
|
a = a->next;
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,7 +248,7 @@ const char* CPluginMngr::CPlugin::getStatus() const
|
||||||
{
|
{
|
||||||
switch (status)
|
switch (status)
|
||||||
{
|
{
|
||||||
case ps_running:
|
case ps_running:
|
||||||
{
|
{
|
||||||
if (m_Debug)
|
if (m_Debug)
|
||||||
{
|
{
|
||||||
|
@ -263,42 +263,42 @@ const char* CPluginMngr::CPlugin::getStatus() const
|
||||||
case ps_stopped: return "stopped";
|
case ps_stopped: return "stopped";
|
||||||
case ps_locked: return "locked";
|
case ps_locked: return "locked";
|
||||||
}
|
}
|
||||||
|
|
||||||
return "error";
|
return "error";
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
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";
|
const char* unk = "unknown";
|
||||||
|
|
||||||
failcounter = 0;
|
failcounter = 0;
|
||||||
title = unk;
|
title = unk;
|
||||||
author = unk;
|
author = unk;
|
||||||
version = unk;
|
version = unk;
|
||||||
|
|
||||||
char file[256];
|
char file[PLATFORM_MAX_PATH];
|
||||||
char* path = build_pathname_r(file, sizeof(file) - 1, "%s/%s", p, n);
|
char* path = build_pathname_r(file, sizeof(file), "%s/%s", p, n);
|
||||||
code = 0;
|
code = 0;
|
||||||
memset(&amx, 0, sizeof(AMX));
|
memset(&amx, 0, sizeof(AMX));
|
||||||
int err = load_amxscript(&amx, &code, path, e, d);
|
int err = load_amxscript(&amx, &code, path, e, d);
|
||||||
|
|
||||||
if (err == AMX_ERR_NONE)
|
if (err == AMX_ERR_NONE)
|
||||||
{
|
{
|
||||||
status = ps_running;
|
status = ps_running;
|
||||||
} else {
|
} else {
|
||||||
status = ps_bad_load;
|
status = ps_bad_load;
|
||||||
}
|
}
|
||||||
|
|
||||||
amx.userdata[UD_FINDPLUGIN] = this;
|
amx.userdata[UD_FINDPLUGIN] = this;
|
||||||
paused_fun = 0;
|
paused_fun = 0;
|
||||||
next = 0;
|
next = 0;
|
||||||
id = i;
|
id = i;
|
||||||
|
|
||||||
if (status == ps_running)
|
if (status == ps_running)
|
||||||
{
|
{
|
||||||
m_PauseFwd = registerSPForwardByName(&amx, "plugin_pause", FP_DONE);
|
m_PauseFwd = registerSPForwardByName(&amx, "plugin_pause", FP_DONE);
|
||||||
m_UnpauseFwd = registerSPForwardByName(&amx, "plugin_unpause", FP_DONE);
|
m_UnpauseFwd = registerSPForwardByName(&amx, "plugin_unpause", FP_DONE);
|
||||||
|
|
||||||
if (amx.flags & AMX_FLAG_DEBUG)
|
if (amx.flags & AMX_FLAG_DEBUG)
|
||||||
{
|
{
|
||||||
m_Debug = true;
|
m_Debug = true;
|
||||||
|
@ -368,17 +368,17 @@ void CPluginMngr::CPlugin::Finalize()
|
||||||
{
|
{
|
||||||
char buffer[128];
|
char buffer[128];
|
||||||
int old_status = status;
|
int old_status = status;
|
||||||
|
|
||||||
if (CheckModules(&amx, buffer))
|
if (CheckModules(&amx, buffer))
|
||||||
{
|
{
|
||||||
if (amx_Register(&amx, core_Natives, -1) != AMX_ERR_NONE)
|
if (amx_Register(&amx, core_Natives, -1) != AMX_ERR_NONE)
|
||||||
{
|
{
|
||||||
Handler *pHandler = (Handler *)amx.userdata[UD_HANDLER];
|
Handler *pHandler = (Handler *)amx.userdata[UD_HANDLER];
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
if (pHandler->IsNativeFiltering())
|
if (pHandler->IsNativeFiltering())
|
||||||
res = amx_CheckNatives(&amx, native_handler);
|
res = amx_CheckNatives(&amx, native_handler);
|
||||||
|
|
||||||
if (!res)
|
if (!res)
|
||||||
{
|
{
|
||||||
status = ps_bad_load;
|
status = ps_bad_load;
|
||||||
|
@ -394,7 +394,7 @@ void CPluginMngr::CPlugin::Finalize()
|
||||||
errorMsg = buffer;
|
errorMsg = buffer;
|
||||||
amx.error = AMX_ERR_NOTFOUND;
|
amx.error = AMX_ERR_NOTFOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (old_status != status)
|
if (old_status != status)
|
||||||
{
|
{
|
||||||
AMXXLOG_Log("[AMXX] Plugin \"%s\" failed to load: %s", name.chars(), errorMsg.chars());
|
AMXXLOG_Log("[AMXX] Plugin \"%s\" failed to load: %s", name.chars(), errorMsg.chars());
|
||||||
|
@ -402,7 +402,7 @@ void CPluginMngr::CPlugin::Finalize()
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPluginMngr::CPlugin::pauseFunction(int id)
|
void CPluginMngr::CPlugin::pauseFunction(int id)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPluginMngr::CPlugin::unpauseFunction(int id)
|
void CPluginMngr::CPlugin::unpauseFunction(int id)
|
||||||
|
@ -410,8 +410,8 @@ void CPluginMngr::CPlugin::unpauseFunction(int id)
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPluginMngr::CPlugin::setStatus(int a)
|
void CPluginMngr::CPlugin::setStatus(int a)
|
||||||
{
|
{
|
||||||
status = a;
|
status = a;
|
||||||
g_commands.clearBufforedInfo(); // ugly way
|
g_commands.clearBufforedInfo(); // ugly way
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -423,7 +423,7 @@ void CPluginMngr::CPlugin::pausePlugin()
|
||||||
// call plugin_pause if provided
|
// call plugin_pause if provided
|
||||||
if (m_PauseFwd != -1)
|
if (m_PauseFwd != -1)
|
||||||
executeForwards(m_PauseFwd);
|
executeForwards(m_PauseFwd);
|
||||||
|
|
||||||
setStatus(ps_paused);
|
setStatus(ps_paused);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -435,7 +435,7 @@ void CPluginMngr::CPlugin::unpausePlugin()
|
||||||
{
|
{
|
||||||
// set status first so the function will be marked executable
|
// set status first so the function will be marked executable
|
||||||
setStatus(ps_running);
|
setStatus(ps_running);
|
||||||
|
|
||||||
// call plugin_unpause if provided
|
// call plugin_unpause if provided
|
||||||
if (m_UnpauseFwd != -1)
|
if (m_UnpauseFwd != -1)
|
||||||
{
|
{
|
||||||
|
@ -597,7 +597,7 @@ void CPluginMngr::CacheAndLoadModules(const char *plugin)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((hdr.defsize != sizeof(AMX_FUNCSTUB)) &&
|
if ((hdr.defsize != sizeof(AMX_FUNCSTUB)) &&
|
||||||
(hdr.defsize != sizeof(AMX_FUNCSTUBNT)))
|
(hdr.defsize != sizeof(AMX_FUNCSTUBNT)))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -610,7 +610,7 @@ void CPluginMngr::CacheAndLoadModules(const char *plugin)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hdr.stp <= 0)
|
if (hdr.stp <= 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -655,7 +655,7 @@ void CPluginMngr::CacheAndLoadModules(const char *plugin)
|
||||||
{
|
{
|
||||||
RunLibCommand(dc);
|
RunLibCommand(dc);
|
||||||
} else if ( (dc->cmd == LibCmd_ExpectClass) ||
|
} else if ( (dc->cmd == LibCmd_ExpectClass) ||
|
||||||
(dc->cmd == LibCmd_ExpectLib) )
|
(dc->cmd == LibCmd_ExpectLib) )
|
||||||
{
|
{
|
||||||
expects.append(dc);
|
expects.append(dc);
|
||||||
} else if (dc->cmd == LibCmd_DefaultLib) {
|
} else if (dc->cmd == LibCmd_DefaultLib) {
|
||||||
|
@ -688,10 +688,10 @@ void CPluginMngr::CacheAndLoadModules(const char *plugin)
|
||||||
|
|
||||||
void CPluginMngr::CALMFromFile(const char *file)
|
void CPluginMngr::CALMFromFile(const char *file)
|
||||||
{
|
{
|
||||||
char filename[256];
|
char filename[PLATFORM_MAX_PATH];
|
||||||
FILE *fp = fopen(build_pathname_r(filename, sizeof(filename) - 1, "%s", file), "rt");
|
FILE *fp = fopen(build_pathname_r(filename, sizeof(filename), "%s", file), "rt");
|
||||||
|
|
||||||
if (!fp)
|
if (!fp)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -701,7 +701,7 @@ void CPluginMngr::CALMFromFile(const char *file)
|
||||||
char line[256];
|
char line[256];
|
||||||
char rline[256];
|
char rline[256];
|
||||||
|
|
||||||
while (!feof(fp))
|
while (!feof(fp))
|
||||||
{
|
{
|
||||||
fgets(line, sizeof(line)-1, fp);
|
fgets(line, sizeof(line)-1, fp);
|
||||||
if (line[0] == ';' || line[0] == '\n' || line[0] == '\0')
|
if (line[0] == ';' || line[0] == '\n' || line[0] == '\0')
|
||||||
|
@ -751,7 +751,7 @@ void CPluginMngr::CALMFromFile(const char *file)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
build_pathname_r(filename, sizeof(filename)-1, "%s/%s", get_localinfo("amxx_pluginsdir", "addons/amxmodx/plugins"), pluginName);
|
build_pathname_r(filename, sizeof(filename), "%s/%s", get_localinfo("amxx_pluginsdir", "addons/amxmodx/plugins"), pluginName);
|
||||||
|
|
||||||
CacheAndLoadModules(filename);
|
CacheAndLoadModules(filename);
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -10,7 +10,7 @@
|
||||||
#ifndef AMXMODX_H
|
#ifndef AMXMODX_H
|
||||||
#define AMXMODX_H
|
#define AMXMODX_H
|
||||||
|
|
||||||
#if defined(__linux__) || defined(__APPLE__)
|
#if defined PLATFORM_POSIX
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "sclinux.h"
|
#include "sclinux.h"
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
// MSVC8 - replace POSIX functions with ISO C++ conformant ones as they are deprecated
|
// MSVC8 - replace POSIX functions with ISO C++ conformant ones as they are deprecated
|
||||||
#if _MSC_VER >= 1400
|
#if _MSC_VER >= 1400
|
||||||
#define unlink _unlink
|
#define unlink _unlink
|
||||||
#define mkdir _mkdir
|
#define mkdir _mkdir
|
||||||
#define strdup _strdup
|
#define strdup _strdup
|
||||||
#endif
|
#endif
|
||||||
|
@ -75,7 +75,7 @@ extern AMX_NATIVE_INFO g_TextParserNatives[];
|
||||||
extern AMX_NATIVE_INFO g_CvarNatives[];
|
extern AMX_NATIVE_INFO g_CvarNatives[];
|
||||||
extern AMX_NATIVE_INFO g_GameConfigNatives[];
|
extern AMX_NATIVE_INFO g_GameConfigNatives[];
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined PLATFORM_WINDOWS
|
||||||
#define DLLOAD(path) (DLHANDLE)LoadLibrary(path)
|
#define DLLOAD(path) (DLHANDLE)LoadLibrary(path)
|
||||||
#define DLPROC(m, func) GetProcAddress(m, func)
|
#define DLPROC(m, func) GetProcAddress(m, func)
|
||||||
#define DLFREE(m) FreeLibrary(m)
|
#define DLFREE(m) FreeLibrary(m)
|
||||||
|
@ -96,21 +96,13 @@ extern AMX_NATIVE_INFO g_GameConfigNatives[];
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined PLATFORM_WINDOWS
|
||||||
typedef HINSTANCE DLHANDLE;
|
typedef HINSTANCE DLHANDLE;
|
||||||
#else
|
#else
|
||||||
typedef void* DLHANDLE;
|
typedef void* DLHANDLE;
|
||||||
#define INFINITE 0xFFFFFFFF
|
#define INFINITE 0xFFFFFFFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN32)
|
|
||||||
#define PATH_SEP_CHAR '\\'
|
|
||||||
#define ALT_SEP_CHAR '/'
|
|
||||||
#else
|
|
||||||
#define PATH_SEP_CHAR '/'
|
|
||||||
#define ALT_SEP_CHAR '\\'
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef GETPLAYERAUTHID
|
#ifndef GETPLAYERAUTHID
|
||||||
#define GETPLAYERAUTHID (*g_engfuncs.pfnGetPlayerAuthId)
|
#define GETPLAYERAUTHID (*g_engfuncs.pfnGetPlayerAuthId)
|
||||||
#endif
|
#endif
|
||||||
|
@ -136,7 +128,7 @@ void UTIL_ShowMenu(edict_t* pEntity, int slots, int time, char *menu, int mlen);
|
||||||
void UTIL_ClientSayText(edict_t *pEntity, int sender, char *msg);
|
void UTIL_ClientSayText(edict_t *pEntity, int sender, char *msg);
|
||||||
void UTIL_TeamInfo(edict_t *pEntity, int playerIndex, const char *pszTeamName);
|
void UTIL_TeamInfo(edict_t *pEntity, int playerIndex, const char *pszTeamName);
|
||||||
|
|
||||||
template <typename D> int UTIL_CheckValidChar(D *c);
|
template <typename D> int UTIL_CheckValidChar(D *c);
|
||||||
template <typename D, typename S> unsigned int strncopy(D *dest, const S *src, size_t count);
|
template <typename D, typename S> unsigned int strncopy(D *dest, const S *src, size_t count);
|
||||||
unsigned int UTIL_GetUTF8CharBytes(const char *stream);
|
unsigned int UTIL_GetUTF8CharBytes(const char *stream);
|
||||||
unsigned int UTIL_ReplaceAll(char *subject, size_t maxlength, const char *search, const char *replace, bool caseSensitive);
|
unsigned int UTIL_ReplaceAll(char *subject, size_t maxlength, const char *search, const char *replace, bool caseSensitive);
|
||||||
|
|
|
@ -44,7 +44,7 @@ void CLog::CloseFile()
|
||||||
if (m_LogFile.length())
|
if (m_LogFile.length())
|
||||||
{
|
{
|
||||||
FILE *fp = fopen(m_LogFile.chars(), "r");
|
FILE *fp = fopen(m_LogFile.chars(), "r");
|
||||||
|
|
||||||
if (fp)
|
if (fp)
|
||||||
{
|
{
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
@ -61,7 +61,7 @@ void CLog::CloseFile()
|
||||||
fprintf(fp, "L %s: %s\n", date, "Log file closed.");
|
fprintf(fp, "L %s: %s\n", date, "Log file closed.");
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_LogFile = nullptr;
|
m_LogFile = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,33 +69,33 @@ void CLog::CloseFile()
|
||||||
void CLog::CreateNewFile()
|
void CLog::CreateNewFile()
|
||||||
{
|
{
|
||||||
CloseFile();
|
CloseFile();
|
||||||
|
|
||||||
// build filename
|
// build filename
|
||||||
time_t td;
|
time_t td;
|
||||||
time(&td);
|
time(&td);
|
||||||
tm *curTime = localtime(&td);
|
tm *curTime = localtime(&td);
|
||||||
|
|
||||||
char file[256];
|
char file[PLATFORM_MAX_PATH];
|
||||||
char name[256];
|
char name[256];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
ke::SafeSprintf(name, sizeof(name), "%s/L%02d%02d%03d.log", g_log_dir.chars(), curTime->tm_mon + 1, curTime->tm_mday, i);
|
ke::SafeSprintf(name, sizeof(name), "%s/L%02d%02d%03d.log", g_log_dir.chars(), curTime->tm_mon + 1, curTime->tm_mday, i);
|
||||||
build_pathname_r(file, sizeof(file)-1, "%s", name);
|
build_pathname_r(file, sizeof(file), "%s", name);
|
||||||
FILE *pTmpFile = fopen(file, "r"); // open for reading to check whether the file exists
|
FILE *pTmpFile = fopen(file, "r"); // open for reading to check whether the file exists
|
||||||
|
|
||||||
if (!pTmpFile)
|
if (!pTmpFile)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
fclose(pTmpFile);
|
fclose(pTmpFile);
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
m_LogFile = file;
|
m_LogFile = file;
|
||||||
|
|
||||||
// Log logfile start
|
// Log logfile start
|
||||||
FILE *fp = fopen(m_LogFile.chars(), "w");
|
FILE *fp = fopen(m_LogFile.chars(), "w");
|
||||||
|
|
||||||
if (!fp)
|
if (!fp)
|
||||||
{
|
{
|
||||||
ALERT(at_logged, "[AMXX] Unexpected fatal logging error. AMXX Logging disabled.\n");
|
ALERT(at_logged, "[AMXX] Unexpected fatal logging error. AMXX Logging disabled.\n");
|
||||||
|
@ -108,8 +108,8 @@ void CLog::CreateNewFile()
|
||||||
|
|
||||||
void CLog::UseFile(const ke::AString &fileName)
|
void CLog::UseFile(const ke::AString &fileName)
|
||||||
{
|
{
|
||||||
static char file[256];
|
static char file[PLATFORM_MAX_PATH];
|
||||||
m_LogFile = build_pathname_r(file, sizeof(file) - 1, "%s/%s", g_log_dir.chars(), fileName.chars());
|
m_LogFile = build_pathname_r(file, sizeof(file), "%s/%s", g_log_dir.chars(), fileName.chars());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLog::SetLogType(const char* localInfo)
|
void CLog::SetLogType(const char* localInfo)
|
||||||
|
@ -128,11 +128,11 @@ void CLog::SetLogType(const char* localInfo)
|
||||||
void CLog::MapChange()
|
void CLog::MapChange()
|
||||||
{
|
{
|
||||||
// create dir if not existing
|
// create dir if not existing
|
||||||
char file[256];
|
char file[PLATFORM_MAX_PATH];
|
||||||
#if defined(__linux__) || defined(__APPLE__)
|
#if defined(__linux__) || defined(__APPLE__)
|
||||||
mkdir(build_pathname_r(file, sizeof(file)-1, "%s", g_log_dir.chars()), 0700);
|
mkdir(build_pathname_r(file, sizeof(file), "%s", g_log_dir.chars()), 0700);
|
||||||
#else
|
#else
|
||||||
mkdir(build_pathname_r(file, sizeof(file) - 1, "%s", g_log_dir.chars()));
|
mkdir(build_pathname_r(file, sizeof(file), "%s", g_log_dir.chars()));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SetLogType("amxx_logging");
|
SetLogType("amxx_logging");
|
||||||
|
@ -152,8 +152,8 @@ void CLog::MapChange()
|
||||||
|
|
||||||
void CLog::Log(const char *fmt, ...)
|
void CLog::Log(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
static char file[256];
|
static char file[PLATFORM_MAX_PATH];
|
||||||
|
|
||||||
if (m_LogType == 1 || m_LogType == 2)
|
if (m_LogType == 1 || m_LogType == 2)
|
||||||
{
|
{
|
||||||
// get time
|
// get time
|
||||||
|
@ -180,7 +180,7 @@ void CLog::Log(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
CreateNewFile();
|
CreateNewFile();
|
||||||
pF = fopen(m_LogFile.chars(), "a+");
|
pF = fopen(m_LogFile.chars(), "a+");
|
||||||
|
|
||||||
if (!pF)
|
if (!pF)
|
||||||
{
|
{
|
||||||
ALERT(at_logged, "[AMXX] Unexpected fatal logging error (couldn't open %s for a+). AMXX Logging disabled for this map.\n", m_LogFile.chars());
|
ALERT(at_logged, "[AMXX] Unexpected fatal logging error (couldn't open %s for a+). AMXX Logging disabled for this map.\n", m_LogFile.chars());
|
||||||
|
@ -189,10 +189,10 @@ void CLog::Log(const char *fmt, ...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
build_pathname_r(file, sizeof(file) - 1, "%s/L%04d%02d%02d.log", g_log_dir.chars(), (curTime->tm_year + 1900), curTime->tm_mon + 1, curTime->tm_mday);
|
build_pathname_r(file, sizeof(file), "%s/L%04d%02d%02d.log", g_log_dir.chars(), (curTime->tm_year + 1900), curTime->tm_mon + 1, curTime->tm_mday);
|
||||||
pF = fopen(file, "a+");
|
pF = fopen(file, "a+");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pF)
|
if (pF)
|
||||||
{
|
{
|
||||||
fprintf(pF, "L %s: %s\n", date, msg);
|
fprintf(pF, "L %s: %s\n", date, msg);
|
||||||
|
@ -218,7 +218,7 @@ void CLog::Log(const char *fmt, ...)
|
||||||
|
|
||||||
void CLog::LogError(const char *fmt, ...)
|
void CLog::LogError(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
static char file[256];
|
static char file[PLATFORM_MAX_PATH];
|
||||||
static char name[256];
|
static char name[256];
|
||||||
|
|
||||||
if (m_FoundError)
|
if (m_FoundError)
|
||||||
|
@ -244,7 +244,7 @@ void CLog::LogError(const char *fmt, ...)
|
||||||
|
|
||||||
FILE *pF = NULL;
|
FILE *pF = NULL;
|
||||||
ke::SafeSprintf(name, sizeof(name), "%s/error_%04d%02d%02d.log", g_log_dir.chars(), curTime->tm_year + 1900, curTime->tm_mon + 1, curTime->tm_mday);
|
ke::SafeSprintf(name, sizeof(name), "%s/error_%04d%02d%02d.log", g_log_dir.chars(), curTime->tm_year + 1900, curTime->tm_mon + 1, curTime->tm_mday);
|
||||||
build_pathname_r(file, sizeof(file)-1, "%s", name);
|
build_pathname_r(file, sizeof(file), "%s", name);
|
||||||
pF = fopen(file, "a+");
|
pF = fopen(file, "a+");
|
||||||
|
|
||||||
if (pF)
|
if (pF)
|
||||||
|
@ -266,4 +266,3 @@ void CLog::LogError(const char *fmt, ...)
|
||||||
// print on server console
|
// print on server console
|
||||||
print_srvconsole("L %s: %s\n", date, msg);
|
print_srvconsole("L %s: %s\n", date, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,9 +49,9 @@ int LookupFile(AMX_DBG *amxdbg, ucell address)
|
||||||
bool BinLog::Open()
|
bool BinLog::Open()
|
||||||
{
|
{
|
||||||
const char *data = get_localinfo("amxmodx_datadir", "addons/amxmodx/data");
|
const char *data = get_localinfo("amxmodx_datadir", "addons/amxmodx/data");
|
||||||
char path[255];
|
char path[PLATFORM_MAX_PATH];
|
||||||
build_pathname_r(path, sizeof(path)-1, "%s/binlogs", data);
|
build_pathname_r(path, sizeof(path), "%s/binlogs", data);
|
||||||
|
|
||||||
if (!DirExists(path))
|
if (!DirExists(path))
|
||||||
{
|
{
|
||||||
mkdir(path
|
mkdir(path
|
||||||
|
@ -63,8 +63,8 @@ bool BinLog::Open()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
char file[255];
|
char file[PLATFORM_MAX_PATH];
|
||||||
build_pathname_r(file, sizeof(file)-1, "%s/binlogs/lastlog", data);
|
build_pathname_r(file, sizeof(file), "%s/binlogs/lastlog", data);
|
||||||
|
|
||||||
unsigned int lastcntr = 0;
|
unsigned int lastcntr = 0;
|
||||||
FILE *lastlog = fopen(file, "rb");
|
FILE *lastlog = fopen(file, "rb");
|
||||||
|
@ -81,7 +81,7 @@ bool BinLog::Open()
|
||||||
fwrite(&lastcntr, sizeof(int), 1, lastlog);
|
fwrite(&lastcntr, sizeof(int), 1, lastlog);
|
||||||
fclose(lastlog);
|
fclose(lastlog);
|
||||||
}
|
}
|
||||||
build_pathname_r(file, sizeof(file)-1, "%s/binlogs/binlog%04d.blg", data, lastcntr);
|
build_pathname_r(file, sizeof(file), "%s/binlogs/binlog%04d.blg", data, lastcntr);
|
||||||
m_logfile = file;
|
m_logfile = file;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -678,7 +678,7 @@ static cell AMX_NATIVE_CALL amx_fprintf(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1015,8 +1015,8 @@ static cell AMX_NATIVE_CALL rename_file(AMX *amx, cell *params)
|
||||||
|
|
||||||
if (params[0] / sizeof(cell) >= 3 && params[3] > 0)
|
if (params[0] / sizeof(cell) >= 3 && params[3] > 0)
|
||||||
{
|
{
|
||||||
build_pathname_r(file_old_r, sizeof(file_old_r) - 1, "%s", file_old);
|
build_pathname_r(file_old_r, sizeof(file_old_r), "%s", file_old);
|
||||||
build_pathname_r(file_new_r, sizeof(file_new_r) - 1, "%s", file_new);
|
build_pathname_r(file_new_r, sizeof(file_new_r), "%s", file_new);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1205,7 +1205,7 @@ AMX_NATIVE_INFO file_Natives[] =
|
||||||
{"fungetc", amx_ungetc},
|
{"fungetc", amx_ungetc},
|
||||||
{"fputs", amx_fputs},
|
{"fputs", amx_fputs},
|
||||||
{"fflush", amx_fflush},
|
{"fflush", amx_fflush},
|
||||||
|
|
||||||
{"build_pathname", amx_build_pathname},
|
{"build_pathname", amx_build_pathname},
|
||||||
|
|
||||||
{"dir_exists", dir_exists},
|
{"dir_exists", dir_exists},
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
#include <resdk/mod_rehlds_api.h>
|
#include <resdk/mod_rehlds_api.h>
|
||||||
#include <amtl/am-utility.h>
|
#include <amtl/am-utility.h>
|
||||||
|
|
||||||
plugin_info_t Plugin_info =
|
plugin_info_t Plugin_info =
|
||||||
{
|
{
|
||||||
META_INTERFACE_VERSION, // ifvers
|
META_INTERFACE_VERSION, // ifvers
|
||||||
"AMX Mod X", // name
|
"AMX Mod X", // name
|
||||||
|
@ -162,7 +162,7 @@ bool ColoredMenus(const char *ModName)
|
||||||
for (size_t i = 0; i < ModsCount; ++i)
|
for (size_t i = 0; i < ModsCount; ++i)
|
||||||
{
|
{
|
||||||
if (strcmp(ModName, pModNames[i]) == 0)
|
if (strcmp(ModName, pModNames[i]) == 0)
|
||||||
return true; // this game modification currently supports colored menus
|
return true; // this game modification currently supports colored menus
|
||||||
}
|
}
|
||||||
|
|
||||||
return false; // no colored menus are supported for this game modification
|
return false; // no colored menus are supported for this game modification
|
||||||
|
@ -187,9 +187,9 @@ void ParseAndOrAdd(CStack<ke::AString *> & files, const char *name)
|
||||||
|
|
||||||
void BuildPluginFileList(const char *initialdir, CStack<ke::AString *> & files)
|
void BuildPluginFileList(const char *initialdir, CStack<ke::AString *> & files)
|
||||||
{
|
{
|
||||||
char path[255];
|
char path[PLATFORM_MAX_PATH];
|
||||||
#if defined WIN32
|
#if defined WIN32
|
||||||
build_pathname_r(path, sizeof(path)-1, "%s/*.ini", initialdir);
|
build_pathname_r(path, sizeof(path), "%s/*.ini", initialdir);
|
||||||
_finddata_t fd;
|
_finddata_t fd;
|
||||||
intptr_t handle = _findfirst(path, &fd);
|
intptr_t handle = _findfirst(path, &fd);
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ void BuildPluginFileList(const char *initialdir, CStack<ke::AString *> & files)
|
||||||
|
|
||||||
_findclose(handle);
|
_findclose(handle);
|
||||||
#elif defined(__linux__) || defined(__APPLE__)
|
#elif defined(__linux__) || defined(__APPLE__)
|
||||||
build_pathname_r(path, sizeof(path)-1, "%s/", initialdir);
|
build_pathname_r(path, sizeof(path), "%s/", initialdir);
|
||||||
struct dirent *ep;
|
struct dirent *ep;
|
||||||
DIR *dp;
|
DIR *dp;
|
||||||
|
|
||||||
|
@ -285,7 +285,7 @@ int C_PrecacheSound(const char *s)
|
||||||
PRECACHE_SOUND((char*)(*a).getFilename());
|
PRECACHE_SOUND((char*)(*a).getFilename());
|
||||||
ENGINE_FORCE_UNMODIFIED((*a).getForceType(), (*a).getMin(), (*a).getMax(), (*a).getFilename());
|
ENGINE_FORCE_UNMODIFIED((*a).getForceType(), (*a).getMin(), (*a).getMax(), (*a).getFilename());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!g_bmod_cstrike)
|
if (!g_bmod_cstrike)
|
||||||
{
|
{
|
||||||
PRECACHE_SOUND("weapons/cbar_hitbod1.wav");
|
PRECACHE_SOUND("weapons/cbar_hitbod1.wav");
|
||||||
|
@ -310,7 +310,7 @@ int C_InconsistentFile(const edict_t *player, const char *filename, char *discon
|
||||||
if (executeForwards(FF_InconsistentFile, static_cast<cell>(pPlayer->index),
|
if (executeForwards(FF_InconsistentFile, static_cast<cell>(pPlayer->index),
|
||||||
filename, disconnect_message) == 1)
|
filename, disconnect_message) == 1)
|
||||||
RETURN_META_VALUE(MRES_SUPERCEDE, FALSE);
|
RETURN_META_VALUE(MRES_SUPERCEDE, FALSE);
|
||||||
|
|
||||||
RETURN_META_VALUE(MRES_SUPERCEDE, TRUE);
|
RETURN_META_VALUE(MRES_SUPERCEDE, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -455,7 +455,7 @@ int C_Spawn(edict_t *pent)
|
||||||
g_plugins.CALMFromFile(map_pluginsfile_path);
|
g_plugins.CALMFromFile(map_pluginsfile_path);
|
||||||
|
|
||||||
int loaded = countModules(CountModules_Running); // Call after attachModules so all modules don't have pending stat
|
int loaded = countModules(CountModules_Running); // Call after attachModules so all modules don't have pending stat
|
||||||
|
|
||||||
// Set some info about amx version and modules
|
// Set some info about amx version and modules
|
||||||
CVAR_SET_STRING(init_amxmodx_version.name, AMXX_VERSION);
|
CVAR_SET_STRING(init_amxmodx_version.name, AMXX_VERSION);
|
||||||
char buffer[32];
|
char buffer[32];
|
||||||
|
@ -463,8 +463,8 @@ int C_Spawn(edict_t *pent)
|
||||||
CVAR_SET_STRING(init_amxmodx_modules.name, buffer);
|
CVAR_SET_STRING(init_amxmodx_modules.name, buffer);
|
||||||
|
|
||||||
// ###### Load Vault
|
// ###### Load Vault
|
||||||
char file[255];
|
char file[PLATFORM_MAX_PATH];
|
||||||
g_vault.setSource(build_pathname_r(file, sizeof(file) - 1, "%s", get_localinfo("amxx_vault", "addons/amxmodx/configs/vault.ini")));
|
g_vault.setSource(build_pathname_r(file, sizeof(file), "%s", get_localinfo("amxx_vault", "addons/amxmodx/configs/vault.ini")));
|
||||||
g_vault.loadVault();
|
g_vault.loadVault();
|
||||||
|
|
||||||
// ###### Init time and freeze tasks
|
// ###### Init time and freeze tasks
|
||||||
|
@ -550,7 +550,7 @@ struct sUserMsg
|
||||||
funEventCall func;
|
funEventCall func;
|
||||||
bool endmsg;
|
bool endmsg;
|
||||||
bool cstrike;
|
bool cstrike;
|
||||||
} g_user_msg[] =
|
} g_user_msg[] =
|
||||||
{
|
{
|
||||||
{"CurWeapon", &gmsgCurWeapon, Client_CurWeapon, false, false},
|
{"CurWeapon", &gmsgCurWeapon, Client_CurWeapon, false, false},
|
||||||
{"Damage", &gmsgDamage, Client_DamageEnd, true, true},
|
{"Damage", &gmsgDamage, Client_DamageEnd, true, true},
|
||||||
|
@ -607,13 +607,13 @@ plugin_init forward function from plugins
|
||||||
void C_ServerActivate(edict_t *pEdictList, int edictCount, int clientMax)
|
void C_ServerActivate(edict_t *pEdictList, int edictCount, int clientMax)
|
||||||
{
|
{
|
||||||
int id;
|
int id;
|
||||||
|
|
||||||
for (int i = 0; g_user_msg[i].name; ++i)
|
for (int i = 0; g_user_msg[i].name; ++i)
|
||||||
{
|
{
|
||||||
if ((*g_user_msg[i].id == 0) && (id = GET_USER_MSG_ID(PLID, g_user_msg[i].name, NULL)) != 0)
|
if ((*g_user_msg[i].id == 0) && (id = GET_USER_MSG_ID(PLID, g_user_msg[i].name, NULL)) != 0)
|
||||||
{
|
{
|
||||||
*g_user_msg[i].id = id;
|
*g_user_msg[i].id = id;
|
||||||
|
|
||||||
if (!g_user_msg[i].cstrike || g_bmod_cstrike)
|
if (!g_user_msg[i].cstrike || g_bmod_cstrike)
|
||||||
{
|
{
|
||||||
if (g_user_msg[i].endmsg)
|
if (g_user_msg[i].endmsg)
|
||||||
|
@ -674,7 +674,7 @@ void C_ServerDeactivate()
|
||||||
{
|
{
|
||||||
if (!g_activated)
|
if (!g_activated)
|
||||||
RETURN_META(MRES_IGNORED);
|
RETURN_META(MRES_IGNORED);
|
||||||
|
|
||||||
for (int i = 1; i <= gpGlobals->maxClients; ++i)
|
for (int i = 1; i <= gpGlobals->maxClients; ++i)
|
||||||
{
|
{
|
||||||
CPlayer *pPlayer = GET_PLAYER_POINTER_I(i);
|
CPlayer *pPlayer = GET_PLAYER_POINTER_I(i);
|
||||||
|
@ -752,7 +752,7 @@ void C_ServerDeactivate_Post()
|
||||||
modules_callPluginsUnloaded();
|
modules_callPluginsUnloaded();
|
||||||
|
|
||||||
ClearMessages();
|
ClearMessages();
|
||||||
|
|
||||||
// Flush the dynamic admins list
|
// Flush the dynamic admins list
|
||||||
for (size_t iter=DynamicAdmins.length();iter--; )
|
for (size_t iter=DynamicAdmins.length();iter--; )
|
||||||
{
|
{
|
||||||
|
@ -807,15 +807,15 @@ void C_ServerDeactivate_Post()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g_memreport_dir = buffer;
|
g_memreport_dir = buffer;
|
||||||
|
|
||||||
// g_memreport_dir should be valid now
|
// g_memreport_dir should be valid now
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_dumpMemoryReport(build_pathname("%s/r%03d.txt", g_memreport_dir.chars(), g_memreport_count));
|
m_dumpMemoryReport(build_pathname("%s/r%03d.txt", g_memreport_dir.chars(), g_memreport_count));
|
||||||
AMXXLOG_Log("Memreport #%d created (file \"%s/r%03d.txt\") (interval %f)", g_memreport_count + 1, g_memreport_dir.chars(), g_memreport_count, MEMREPORT_INTERVAL);
|
AMXXLOG_Log("Memreport #%d created (file \"%s/r%03d.txt\") (interval %f)", g_memreport_count + 1, g_memreport_dir.chars(), g_memreport_count, MEMREPORT_INTERVAL);
|
||||||
|
|
||||||
g_memreport_count++;
|
g_memreport_count++;
|
||||||
}
|
}
|
||||||
#endif // MEMORY_TEST
|
#endif // MEMORY_TEST
|
||||||
|
@ -836,11 +836,11 @@ BOOL C_ClientConnect_Post(edict_t *pEntity, const char *pszName, const char *psz
|
||||||
{
|
{
|
||||||
bool a = pPlayer->Connect(pszName, pszAddress);
|
bool a = pPlayer->Connect(pszName, pszAddress);
|
||||||
executeForwards(FF_ClientConnect, static_cast<cell>(pPlayer->index));
|
executeForwards(FF_ClientConnect, static_cast<cell>(pPlayer->index));
|
||||||
|
|
||||||
if (a)
|
if (a)
|
||||||
{
|
{
|
||||||
CPlayer** aa = new CPlayer*(pPlayer);
|
CPlayer** aa = new CPlayer*(pPlayer);
|
||||||
if (aa)
|
if (aa)
|
||||||
g_auth.put(aa);
|
g_auth.put(aa);
|
||||||
} else {
|
} else {
|
||||||
pPlayer->Authorize();
|
pPlayer->Authorize();
|
||||||
|
@ -858,7 +858,7 @@ BOOL C_ClientConnect_Post(edict_t *pEntity, const char *pszName, const char *psz
|
||||||
executeForwards(FF_ClientAuthorized, static_cast<cell>(pPlayer->index), authid);
|
executeForwards(FF_ClientAuthorized, static_cast<cell>(pPlayer->index), authid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RETURN_META_VALUE(MRES_IGNORED, TRUE);
|
RETURN_META_VALUE(MRES_IGNORED, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -880,7 +880,7 @@ void C_ClientDisconnect(edict_t *pEntity)
|
||||||
{
|
{
|
||||||
// deprecated
|
// deprecated
|
||||||
executeForwards(FF_ClientDisconnect, static_cast<cell>(pPlayer->index));
|
executeForwards(FF_ClientDisconnect, static_cast<cell>(pPlayer->index));
|
||||||
|
|
||||||
if (DropClientDetour && !pPlayer->disconnecting)
|
if (DropClientDetour && !pPlayer->disconnecting)
|
||||||
{
|
{
|
||||||
executeForwards(FF_ClientDisconnected, static_cast<cell>(pPlayer->index), FALSE, prepareCharArray(const_cast<char*>(""), 0), 0);
|
executeForwards(FF_ClientDisconnected, static_cast<cell>(pPlayer->index), FALSE, prepareCharArray(const_cast<char*>(""), 0), 0);
|
||||||
|
@ -967,7 +967,7 @@ void C_ClientPutInServer_Post(edict_t *pEntity)
|
||||||
++g_players_num;
|
++g_players_num;
|
||||||
executeForwards(FF_ClientPutInServer, static_cast<cell>(pPlayer->index));
|
executeForwards(FF_ClientPutInServer, static_cast<cell>(pPlayer->index));
|
||||||
}
|
}
|
||||||
|
|
||||||
RETURN_META(MRES_IGNORED);
|
RETURN_META(MRES_IGNORED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1012,10 +1012,10 @@ void C_ClientUserInfoChanged_Post(edict_t *pEntity, char *infobuffer)
|
||||||
void C_ClientCommand(edict_t *pEntity)
|
void C_ClientCommand(edict_t *pEntity)
|
||||||
{
|
{
|
||||||
CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity);
|
CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity);
|
||||||
|
|
||||||
META_RES result = MRES_IGNORED;
|
META_RES result = MRES_IGNORED;
|
||||||
cell ret = 0;
|
cell ret = 0;
|
||||||
|
|
||||||
const char* cmd = CMD_ARGV(0);
|
const char* cmd = CMD_ARGV(0);
|
||||||
const char* arg = CMD_ARGV(1);
|
const char* arg = CMD_ARGV(1);
|
||||||
|
|
||||||
|
@ -1027,7 +1027,7 @@ void C_ClientCommand(edict_t *pEntity)
|
||||||
// Print version
|
// Print version
|
||||||
static char buf[1024];
|
static char buf[1024];
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
|
|
||||||
sprintf(buf, "%s %s\n", Plugin_info.name, Plugin_info.version);
|
sprintf(buf, "%s %s\n", Plugin_info.name, Plugin_info.version);
|
||||||
CLIENT_PRINT(pEntity, print_console, buf);
|
CLIENT_PRINT(pEntity, print_console, buf);
|
||||||
len = sprintf(buf, "Authors: \n David \"BAILOPAN\" Anderson, Pavol \"PM OnoTo\" Marko, Felix \"SniperBeamer\" Geyer\n");
|
len = sprintf(buf, "Authors: \n David \"BAILOPAN\" Anderson, Pavol \"PM OnoTo\" Marko, Felix \"SniperBeamer\" Geyer\n");
|
||||||
|
@ -1057,7 +1057,7 @@ void C_ClientCommand(edict_t *pEntity)
|
||||||
/* check for command and if needed also for first argument and call proper function */
|
/* check for command and if needed also for first argument and call proper function */
|
||||||
|
|
||||||
CmdMngr::iterator aa = g_commands.clcmdprefixbegin(cmd);
|
CmdMngr::iterator aa = g_commands.clcmdprefixbegin(cmd);
|
||||||
|
|
||||||
if (!aa)
|
if (!aa)
|
||||||
aa = g_commands.clcmdbegin();
|
aa = g_commands.clcmdbegin();
|
||||||
|
|
||||||
|
@ -1089,7 +1089,7 @@ void C_ClientCommand(edict_t *pEntity)
|
||||||
pMenu->Close(pPlayer->index);
|
pMenu->Close(pPlayer->index);
|
||||||
|
|
||||||
RETURN_META(MRES_SUPERCEDE);
|
RETURN_META(MRES_SUPERCEDE);
|
||||||
}
|
}
|
||||||
else if (pPlayer->menu > 0 && !pPlayer->vgui)
|
else if (pPlayer->menu > 0 && !pPlayer->vgui)
|
||||||
{
|
{
|
||||||
pPlayer->menu = 0;
|
pPlayer->menu = 0;
|
||||||
|
@ -1098,7 +1098,7 @@ void C_ClientCommand(edict_t *pEntity)
|
||||||
RETURN_META(MRES_SUPERCEDE);
|
RETURN_META(MRES_SUPERCEDE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int menuid = pPlayer->menu;
|
int menuid = pPlayer->menu;
|
||||||
pPlayer->menu = 0;
|
pPlayer->menu = 0;
|
||||||
|
|
||||||
|
@ -1126,12 +1126,12 @@ void C_ClientCommand(edict_t *pEntity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* No matter what we marked it as executed, since the callback styles are
|
* No matter what we marked it as executed, since the callback styles are
|
||||||
* entirely different. After all, this is a backwards compat shim.
|
* entirely different. After all, this is a backwards compat shim.
|
||||||
*/
|
*/
|
||||||
func_was_executed = pMenu->func;
|
func_was_executed = pMenu->func;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now, do old menus */
|
/* Now, do old menus */
|
||||||
MenuMngr::iterator a = g_menucmds.begin();
|
MenuMngr::iterator a = g_menucmds.begin();
|
||||||
|
@ -1139,15 +1139,15 @@ void C_ClientCommand(edict_t *pEntity)
|
||||||
while (a)
|
while (a)
|
||||||
{
|
{
|
||||||
g_menucmds.SetWatchIter(a);
|
g_menucmds.SetWatchIter(a);
|
||||||
if ((*a).matchCommand(menuid, bit_key)
|
if ((*a).matchCommand(menuid, bit_key)
|
||||||
&& (*a).getPlugin()->isExecutable((*a).getFunction())
|
&& (*a).getPlugin()->isExecutable((*a).getFunction())
|
||||||
&& (func_was_executed == -1
|
&& (func_was_executed == -1
|
||||||
|| !g_forwards.isSameSPForward(func_was_executed, (*a).getFunction()))
|
|| !g_forwards.isSameSPForward(func_was_executed, (*a).getFunction()))
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ret = executeForwards((*a).getFunction(), static_cast<cell>(pPlayer->index),
|
ret = executeForwards((*a).getFunction(), static_cast<cell>(pPlayer->index),
|
||||||
static_cast<cell>(pressed_key), 0);
|
static_cast<cell>(pressed_key), 0);
|
||||||
|
|
||||||
if (ret & 2) result = MRES_SUPERCEDE;
|
if (ret & 2) result = MRES_SUPERCEDE;
|
||||||
if (ret & 1) RETURN_META(MRES_SUPERCEDE);
|
if (ret & 1) RETURN_META(MRES_SUPERCEDE);
|
||||||
}
|
}
|
||||||
|
@ -1197,7 +1197,7 @@ void C_StartFrame_Post(void)
|
||||||
}
|
}
|
||||||
executeForwards(FF_ClientAuthorized, static_cast<cell>((*a)->index), auth);
|
executeForwards(FF_ClientAuthorized, static_cast<cell>((*a)->index), auth);
|
||||||
a.remove();
|
a.remove();
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
++a;
|
++a;
|
||||||
|
@ -1208,14 +1208,14 @@ void C_StartFrame_Post(void)
|
||||||
if (g_memreport_enabled && g_next_memreport_time <= gpGlobals->time)
|
if (g_memreport_enabled && g_next_memreport_time <= gpGlobals->time)
|
||||||
{
|
{
|
||||||
g_next_memreport_time = gpGlobals->time + MEMREPORT_INTERVAL;
|
g_next_memreport_time = gpGlobals->time + MEMREPORT_INTERVAL;
|
||||||
|
|
||||||
if (g_memreport_count == 0)
|
if (g_memreport_count == 0)
|
||||||
{
|
{
|
||||||
// make new directory
|
// make new directory
|
||||||
time_t td;
|
time_t td;
|
||||||
time(&td);
|
time(&td);
|
||||||
tm *curTime = localtime(&td);
|
tm *curTime = localtime(&td);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
#if defined(__linux__) || defined(__APPLE__)
|
#if defined(__linux__) || defined(__APPLE__)
|
||||||
mkdir(build_pathname("%s/memreports", get_localinfo("amxx_basedir", "addons/amxmodx")), 0700);
|
mkdir(build_pathname("%s/memreports", get_localinfo("amxx_basedir", "addons/amxmodx")), 0700);
|
||||||
|
@ -1251,10 +1251,10 @@ void C_StartFrame_Post(void)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_dumpMemoryReport(build_pathname("%s/r%03d.txt", g_memreport_dir.chars(), g_memreport_count));
|
m_dumpMemoryReport(build_pathname("%s/r%03d.txt", g_memreport_dir.chars(), g_memreport_count));
|
||||||
AMXXLOG_Log("Memreport #%d created (file \"%s/r%03d.txt\") (interval %f)", g_memreport_count + 1, g_memreport_dir.chars(), g_memreport_count, MEMREPORT_INTERVAL);
|
AMXXLOG_Log("Memreport #%d created (file \"%s/r%03d.txt\") (interval %f)", g_memreport_count + 1, g_memreport_dir.chars(), g_memreport_count, MEMREPORT_INTERVAL);
|
||||||
|
|
||||||
g_memreport_count++;
|
g_memreport_count++;
|
||||||
}
|
}
|
||||||
#endif // MEMORY_TEST
|
#endif // MEMORY_TEST
|
||||||
|
@ -1282,14 +1282,14 @@ void C_MessageBegin_Post(int msg_dest, int msg_type, const float *pOrigin, edict
|
||||||
mPlayerIndex = 0;
|
mPlayerIndex = 0;
|
||||||
mPlayer = 0;
|
mPlayer = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg_type < 0 || msg_type >= MAX_REG_MSGS)
|
if (msg_type < 0 || msg_type >= MAX_REG_MSGS)
|
||||||
msg_type = 0;
|
msg_type = 0;
|
||||||
|
|
||||||
mState = 0;
|
mState = 0;
|
||||||
function = modMsgs[msg_type];
|
function = modMsgs[msg_type];
|
||||||
endfunction = modMsgsEnd[msg_type];
|
endfunction = modMsgsEnd[msg_type];
|
||||||
|
|
||||||
g_events.parserInit(msg_type, &gpGlobals->time, mPlayer, mPlayerIndex);
|
g_events.parserInit(msg_type, &gpGlobals->time, mPlayer, mPlayerIndex);
|
||||||
|
|
||||||
RETURN_META(MRES_IGNORED);
|
RETURN_META(MRES_IGNORED);
|
||||||
|
@ -1299,7 +1299,7 @@ void C_WriteByte_Post(int iValue)
|
||||||
{
|
{
|
||||||
g_events.parseValue(iValue);
|
g_events.parseValue(iValue);
|
||||||
if (function) (*function)((void *)&iValue);
|
if (function) (*function)((void *)&iValue);
|
||||||
|
|
||||||
RETURN_META(MRES_IGNORED);
|
RETURN_META(MRES_IGNORED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1315,7 +1315,7 @@ void C_WriteShort_Post(int iValue)
|
||||||
{
|
{
|
||||||
g_events.parseValue(iValue);
|
g_events.parseValue(iValue);
|
||||||
if (function) (*function)((void *)&iValue);
|
if (function) (*function)((void *)&iValue);
|
||||||
|
|
||||||
RETURN_META(MRES_IGNORED);
|
RETURN_META(MRES_IGNORED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1323,7 +1323,7 @@ void C_WriteLong_Post(int iValue)
|
||||||
{
|
{
|
||||||
g_events.parseValue(iValue);
|
g_events.parseValue(iValue);
|
||||||
if (function) (*function)((void *)&iValue);
|
if (function) (*function)((void *)&iValue);
|
||||||
|
|
||||||
RETURN_META(MRES_IGNORED);
|
RETURN_META(MRES_IGNORED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1331,7 +1331,7 @@ void C_WriteAngle_Post(float flValue)
|
||||||
{
|
{
|
||||||
g_events.parseValue(flValue);
|
g_events.parseValue(flValue);
|
||||||
if (function) (*function)((void *)&flValue);
|
if (function) (*function)((void *)&flValue);
|
||||||
|
|
||||||
RETURN_META(MRES_IGNORED);
|
RETURN_META(MRES_IGNORED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1355,7 +1355,7 @@ void C_WriteEntity_Post(int iValue)
|
||||||
{
|
{
|
||||||
g_events.parseValue(iValue);
|
g_events.parseValue(iValue);
|
||||||
if (function) (*function)((void *)&iValue);
|
if (function) (*function)((void *)&iValue);
|
||||||
|
|
||||||
RETURN_META(MRES_IGNORED);
|
RETURN_META(MRES_IGNORED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1363,7 +1363,7 @@ void C_MessageEnd_Post(void)
|
||||||
{
|
{
|
||||||
g_events.executeEvents();
|
g_events.executeEvents();
|
||||||
if (endfunction) (*endfunction)(NULL);
|
if (endfunction) (*endfunction)(NULL);
|
||||||
|
|
||||||
RETURN_META(MRES_IGNORED);
|
RETURN_META(MRES_IGNORED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1372,7 +1372,7 @@ const char *C_Cmd_Args(void)
|
||||||
// if the global "fake" flag is set, which means that engclient_cmd was used, supercede the function
|
// if the global "fake" flag is set, which means that engclient_cmd was used, supercede the function
|
||||||
if (g_fakecmd.fake)
|
if (g_fakecmd.fake)
|
||||||
RETURN_META_VALUE(MRES_SUPERCEDE, (g_fakecmd.argc > 1) ? g_fakecmd.args : g_fakecmd.argv[0]);
|
RETURN_META_VALUE(MRES_SUPERCEDE, (g_fakecmd.argc > 1) ? g_fakecmd.args : g_fakecmd.argv[0]);
|
||||||
|
|
||||||
// otherwise ignore it
|
// otherwise ignore it
|
||||||
RETURN_META_VALUE(MRES_IGNORED, NULL);
|
RETURN_META_VALUE(MRES_IGNORED, NULL);
|
||||||
}
|
}
|
||||||
|
@ -1382,7 +1382,7 @@ const char *C_Cmd_Argv(int argc)
|
||||||
// if the global "fake" flag is set, which means that engclient_cmd was used, supercede the function
|
// if the global "fake" flag is set, which means that engclient_cmd was used, supercede the function
|
||||||
if (g_fakecmd.fake)
|
if (g_fakecmd.fake)
|
||||||
RETURN_META_VALUE(MRES_SUPERCEDE, (argc < 3) ? g_fakecmd.argv[argc] : "");
|
RETURN_META_VALUE(MRES_SUPERCEDE, (argc < 3) ? g_fakecmd.argv[argc] : "");
|
||||||
|
|
||||||
// otherwise ignore it
|
// otherwise ignore it
|
||||||
RETURN_META_VALUE(MRES_IGNORED, NULL);
|
RETURN_META_VALUE(MRES_IGNORED, NULL);
|
||||||
}
|
}
|
||||||
|
@ -1392,7 +1392,7 @@ int C_Cmd_Argc(void)
|
||||||
// if the global "fake" flag is set, which means that engclient_cmd was used, supercede the function
|
// if the global "fake" flag is set, which means that engclient_cmd was used, supercede the function
|
||||||
if (g_fakecmd.fake)
|
if (g_fakecmd.fake)
|
||||||
RETURN_META_VALUE(MRES_SUPERCEDE, g_fakecmd.argc);
|
RETURN_META_VALUE(MRES_SUPERCEDE, g_fakecmd.argc);
|
||||||
|
|
||||||
// otherwise ignore it
|
// otherwise ignore it
|
||||||
RETURN_META_VALUE(MRES_IGNORED, 0);
|
RETURN_META_VALUE(MRES_IGNORED, 0);
|
||||||
}
|
}
|
||||||
|
@ -1403,7 +1403,7 @@ void C_SetModel(edict_t *e, const char *m)
|
||||||
{
|
{
|
||||||
if (e->v.owner && m[7]=='w' && m[8]=='_' && m[9]=='h')
|
if (e->v.owner && m[7]=='w' && m[8]=='_' && m[9]=='h')
|
||||||
g_grenades.put(e, 1.75, 4, GET_PLAYER_POINTER(e->v.owner));
|
g_grenades.put(e, 1.75, 4, GET_PLAYER_POINTER(e->v.owner));
|
||||||
|
|
||||||
RETURN_META(MRES_IGNORED);
|
RETURN_META(MRES_IGNORED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1413,10 +1413,10 @@ void C_TraceLine_Post(const float *v1, const float *v2, int fNoMonsters, edict_t
|
||||||
if (e && (e->v.flags & (FL_CLIENT | FL_FAKECLIENT)))
|
if (e && (e->v.flags & (FL_CLIENT | FL_FAKECLIENT)))
|
||||||
{
|
{
|
||||||
CPlayer* pPlayer = GET_PLAYER_POINTER(e);
|
CPlayer* pPlayer = GET_PLAYER_POINTER(e);
|
||||||
|
|
||||||
if (ptr->pHit && (ptr->pHit->v.flags & (FL_CLIENT | FL_FAKECLIENT)))
|
if (ptr->pHit && (ptr->pHit->v.flags & (FL_CLIENT | FL_FAKECLIENT)))
|
||||||
pPlayer->aiming = ptr->iHitgroup;
|
pPlayer->aiming = ptr->iHitgroup;
|
||||||
|
|
||||||
pPlayer->lastTrace = ptr->vecEndPos;
|
pPlayer->lastTrace = ptr->vecEndPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1515,7 +1515,7 @@ C_DLLEXPORT int Meta_Query(const char *ifvers, plugin_info_t **pPlugInfo, mutil_
|
||||||
*pPlugInfo = &Plugin_info;
|
*pPlugInfo = &Plugin_info;
|
||||||
|
|
||||||
int mmajor = 0, mminor = 0, pmajor = 0, pminor = 0;
|
int mmajor = 0, mminor = 0, pmajor = 0, pminor = 0;
|
||||||
|
|
||||||
sscanf(ifvers, "%d:%d", &mmajor, &mminor);
|
sscanf(ifvers, "%d:%d", &mmajor, &mminor);
|
||||||
sscanf(Plugin_info.ifvers, "%d:%d", &pmajor, &pminor);
|
sscanf(Plugin_info.ifvers, "%d:%d", &pmajor, &pminor);
|
||||||
|
|
||||||
|
@ -1530,7 +1530,7 @@ C_DLLEXPORT int Meta_Query(const char *ifvers, plugin_info_t **pPlugInfo, mutil_
|
||||||
LOG_ERROR(PLID, "metamod version is incompatible with this plugin; please find a newer version of this plugin");
|
LOG_ERROR(PLID, "metamod version is incompatible with this plugin; please find a newer version of this plugin");
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
} else if (pmajor == mmajor) {
|
} else if (pmajor == mmajor) {
|
||||||
if (pminor > mminor)
|
if (pminor > mminor)
|
||||||
{
|
{
|
||||||
LOG_ERROR(PLID, "metamod version is incompatible with this plugin; please find a newer version of this plugin");
|
LOG_ERROR(PLID, "metamod version is incompatible with this plugin; please find a newer version of this plugin");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -1573,21 +1573,21 @@ C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now, META_FUNCTIONS *pFunctionTable, m
|
||||||
CVAR_REGISTER(&init_amxmodx_mldebug);
|
CVAR_REGISTER(&init_amxmodx_mldebug);
|
||||||
CVAR_REGISTER(&init_amxmodx_language);
|
CVAR_REGISTER(&init_amxmodx_language);
|
||||||
CVAR_REGISTER(&init_amxmodx_cl_langs);
|
CVAR_REGISTER(&init_amxmodx_cl_langs);
|
||||||
|
|
||||||
amxmodx_version = CVAR_GET_POINTER(init_amxmodx_version.name);
|
amxmodx_version = CVAR_GET_POINTER(init_amxmodx_version.name);
|
||||||
amxmodx_language = CVAR_GET_POINTER(init_amxmodx_language.name);
|
amxmodx_language = CVAR_GET_POINTER(init_amxmodx_language.name);
|
||||||
|
|
||||||
REG_SVR_COMMAND("amxx", amx_command);
|
REG_SVR_COMMAND("amxx", amx_command);
|
||||||
|
|
||||||
char gameDir[512];
|
char gameDir[512];
|
||||||
GET_GAME_DIR(gameDir);
|
GET_GAME_DIR(gameDir);
|
||||||
char *a = gameDir;
|
char *a = gameDir;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
while (gameDir[i])
|
while (gameDir[i])
|
||||||
if (gameDir[i++] == '/')
|
if (gameDir[i++] == '/')
|
||||||
a = &gameDir[i];
|
a = &gameDir[i];
|
||||||
|
|
||||||
g_mod_name = a;
|
g_mod_name = a;
|
||||||
|
|
||||||
g_coloredmenus = ColoredMenus(g_mod_name.chars()); // whether or not to use colored menus
|
g_coloredmenus = ColoredMenus(g_mod_name.chars()); // whether or not to use colored menus
|
||||||
|
@ -1605,7 +1605,7 @@ C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now, META_FUNCTIONS *pFunctionTable, m
|
||||||
if (amx_config.loadVault())
|
if (amx_config.loadVault())
|
||||||
{
|
{
|
||||||
Vault::iterator a = amx_config.begin();
|
Vault::iterator a = amx_config.begin();
|
||||||
|
|
||||||
while (a != amx_config.end())
|
while (a != amx_config.end())
|
||||||
{
|
{
|
||||||
SET_LOCALINFO((char*)a.key().chars(), (char*)a.value().chars());
|
SET_LOCALINFO((char*)a.key().chars(), (char*)a.value().chars());
|
||||||
|
@ -1870,7 +1870,7 @@ C_DLLEXPORT int GetEngineFunctions_Post(enginefuncs_t *pengfuncsFromEngine, int
|
||||||
meta_engfuncs_post.pfnWriteByte = C_WriteByte_Post;
|
meta_engfuncs_post.pfnWriteByte = C_WriteByte_Post;
|
||||||
meta_engfuncs_post.pfnWriteChar = C_WriteChar_Post;
|
meta_engfuncs_post.pfnWriteChar = C_WriteChar_Post;
|
||||||
meta_engfuncs_post.pfnWriteShort = C_WriteShort_Post;
|
meta_engfuncs_post.pfnWriteShort = C_WriteShort_Post;
|
||||||
meta_engfuncs_post.pfnWriteLong = C_WriteLong_Post;
|
meta_engfuncs_post.pfnWriteLong = C_WriteLong_Post;
|
||||||
meta_engfuncs_post.pfnWriteAngle = C_WriteAngle_Post;
|
meta_engfuncs_post.pfnWriteAngle = C_WriteAngle_Post;
|
||||||
meta_engfuncs_post.pfnWriteCoord = C_WriteCoord_Post;
|
meta_engfuncs_post.pfnWriteCoord = C_WriteCoord_Post;
|
||||||
meta_engfuncs_post.pfnWriteString = C_WriteString_Post;
|
meta_engfuncs_post.pfnWriteString = C_WriteString_Post;
|
||||||
|
@ -1889,7 +1889,7 @@ NEW_DLL_FUNCTIONS gNewDLLFunctionTable;
|
||||||
C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable, int *interfaceVersion)
|
C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable, int *interfaceVersion)
|
||||||
{
|
{
|
||||||
memset(&gNewDLLFunctionTable, 0, sizeof(NEW_DLL_FUNCTIONS));
|
memset(&gNewDLLFunctionTable, 0, sizeof(NEW_DLL_FUNCTIONS));
|
||||||
|
|
||||||
// default metamod does not call this if the gamedll doesn't provide it
|
// default metamod does not call this if the gamedll doesn't provide it
|
||||||
if (g_engfuncs.pfnQueryClientCvarValue2)
|
if (g_engfuncs.pfnQueryClientCvarValue2)
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include "trie_natives.h"
|
#include "trie_natives.h"
|
||||||
#include "CDataPack.h"
|
#include "CDataPack.h"
|
||||||
#include "CGameConfigs.h"
|
#include "CGameConfigs.h"
|
||||||
|
#include <amtl/os/am-path.h>
|
||||||
|
|
||||||
CList<CModule, const char*> g_modules;
|
CList<CModule, const char*> g_modules;
|
||||||
CList<CScript, AMX*> g_loadedscripts;
|
CList<CScript, AMX*> g_loadedscripts;
|
||||||
|
@ -52,7 +53,7 @@ void report_error(int code, const char* fmt, ...)
|
||||||
vsnprintf(string, 255, fmt, argptr);
|
vsnprintf(string, 255, fmt, argptr);
|
||||||
string[255] = 0;
|
string[255] = 0;
|
||||||
va_end(argptr);
|
va_end(argptr);
|
||||||
|
|
||||||
if (*string)
|
if (*string)
|
||||||
{
|
{
|
||||||
AMXXLOG_Log("Error:");
|
AMXXLOG_Log("Error:");
|
||||||
|
@ -71,7 +72,7 @@ void print_srvconsole(const char *fmt, ...)
|
||||||
vsnprintf(string, sizeof(string) - 1, fmt, argptr);
|
vsnprintf(string, sizeof(string) - 1, fmt, argptr);
|
||||||
string[sizeof(string) - 1] = '\0';
|
string[sizeof(string) - 1] = '\0';
|
||||||
va_end(argptr);
|
va_end(argptr);
|
||||||
|
|
||||||
SERVER_PRINT(string);
|
SERVER_PRINT(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +112,7 @@ void BinLog_LogParams(AMX *amx, cell *params)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static binlogfuncs_t logfuncs =
|
static binlogfuncs_t logfuncs =
|
||||||
{
|
{
|
||||||
BinLog_LogNative,
|
BinLog_LogNative,
|
||||||
BinLog_LogReturn,
|
BinLog_LogReturn,
|
||||||
|
@ -127,25 +128,25 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
|
||||||
if (!*program)
|
if (!*program)
|
||||||
{
|
{
|
||||||
CAmxxReader reader(filename, PAWN_CELL_SIZE / 8);
|
CAmxxReader reader(filename, PAWN_CELL_SIZE / 8);
|
||||||
|
|
||||||
if (reader.GetStatus() == CAmxxReader::Err_None)
|
if (reader.GetStatus() == CAmxxReader::Err_None)
|
||||||
{
|
{
|
||||||
bufSize = reader.GetBufferSize();
|
bufSize = reader.GetBufferSize();
|
||||||
|
|
||||||
if (bufSize != 0)
|
if (bufSize != 0)
|
||||||
{
|
{
|
||||||
*program = (void*) (new char[bufSize]);
|
*program = (void*) (new char[bufSize]);
|
||||||
|
|
||||||
if (!*program)
|
if (!*program)
|
||||||
{
|
{
|
||||||
strcpy(error, "Failed to allocate memory");
|
strcpy(error, "Failed to allocate memory");
|
||||||
return (amx->error = AMX_ERR_MEMORY);
|
return (amx->error = AMX_ERR_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
reader.GetSection(*program);
|
reader.GetSection(*program);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (reader.GetStatus())
|
switch (reader.GetStatus())
|
||||||
{
|
{
|
||||||
case CAmxxReader::Err_None:
|
case CAmxxReader::Err_None:
|
||||||
|
@ -186,7 +187,7 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
|
||||||
AMX_HEADER *hdr = (AMX_HEADER*)*program;
|
AMX_HEADER *hdr = (AMX_HEADER*)*program;
|
||||||
uint16_t magic = hdr->magic;
|
uint16_t magic = hdr->magic;
|
||||||
amx_Align16(&magic);
|
amx_Align16(&magic);
|
||||||
|
|
||||||
if (magic != AMX_MAGIC)
|
if (magic != AMX_MAGIC)
|
||||||
{
|
{
|
||||||
strcpy(error, "Invalid Plugin");
|
strcpy(error, "Invalid Plugin");
|
||||||
|
@ -208,10 +209,10 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
|
||||||
else if ((hdr->flags & AMX_FLAG_DEBUG) != 0)
|
else if ((hdr->flags & AMX_FLAG_DEBUG) != 0)
|
||||||
{
|
{
|
||||||
will_be_debugged = true;
|
will_be_debugged = true;
|
||||||
|
|
||||||
char *addr = (char *)hdr + hdr->size;
|
char *addr = (char *)hdr + hdr->size;
|
||||||
pDbg = new tagAMX_DBG;
|
pDbg = new tagAMX_DBG;
|
||||||
|
|
||||||
memset(pDbg, 0, sizeof(AMX_DBG));
|
memset(pDbg, 0, sizeof(AMX_DBG));
|
||||||
|
|
||||||
int err = dbg_LoadInfo(pDbg, addr);
|
int err = dbg_LoadInfo(pDbg, addr);
|
||||||
|
@ -248,7 +249,7 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
|
||||||
dbg_FreeInfo(pDbg);
|
dbg_FreeInfo(pDbg);
|
||||||
delete pDbg;
|
delete pDbg;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(error, "Load error %d (invalid file format or version)", err);
|
sprintf(error, "Load error %d (invalid file format or version)", err);
|
||||||
return (amx->error = AMX_ERR_INIT);
|
return (amx->error = AMX_ERR_INIT);
|
||||||
}
|
}
|
||||||
|
@ -282,17 +283,17 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
|
||||||
{
|
{
|
||||||
char *np = new char[amx->code_size];
|
char *np = new char[amx->code_size];
|
||||||
char *rt = new char[amx->reloc_size];
|
char *rt = new char[amx->reloc_size];
|
||||||
|
|
||||||
if (!np || (!rt && amx->reloc_size > 0))
|
if (!np || (!rt && amx->reloc_size > 0))
|
||||||
{
|
{
|
||||||
delete[] np;
|
delete[] np;
|
||||||
delete[] rt;
|
delete[] rt;
|
||||||
strcpy(error, "Failed to initialize JIT'd plugin");
|
strcpy(error, "Failed to initialize JIT'd plugin");
|
||||||
|
|
||||||
return (amx->error = AMX_ERR_INIT);
|
return (amx->error = AMX_ERR_INIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((err = amx_InitJIT(amx, (void *)rt, (void *)np)) == AMX_ERR_NONE)
|
if ((err = amx_InitJIT(amx, (void *)rt, (void *)np)) == AMX_ERR_NONE)
|
||||||
{
|
{
|
||||||
//amx->base = (unsigned char FAR *)realloc(np, amx->code_size);
|
//amx->base = (unsigned char FAR *)realloc(np, amx->code_size);
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
|
@ -307,15 +308,15 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
|
||||||
#endif
|
#endif
|
||||||
if (amx->base)
|
if (amx->base)
|
||||||
memcpy(amx->base, np, amx->code_size);
|
memcpy(amx->base, np, amx->code_size);
|
||||||
|
|
||||||
delete [] np;
|
delete [] np;
|
||||||
delete [] rt;
|
delete [] rt;
|
||||||
|
|
||||||
char *prg = (char *)(*program);
|
char *prg = (char *)(*program);
|
||||||
|
|
||||||
delete [] prg;
|
delete [] prg;
|
||||||
(*program) = amx->base;
|
(*program) = amx->base;
|
||||||
|
|
||||||
if (*program == 0)
|
if (*program == 0)
|
||||||
{
|
{
|
||||||
strcpy(error, "Failed to allocate memory");
|
strcpy(error, "Failed to allocate memory");
|
||||||
|
@ -324,9 +325,9 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
|
||||||
} else {
|
} else {
|
||||||
delete[] np;
|
delete[] np;
|
||||||
delete[] rt;
|
delete[] rt;
|
||||||
|
|
||||||
sprintf(error, "Failed to initialize plugin (%d)", err);
|
sprintf(error, "Failed to initialize plugin (%d)", err);
|
||||||
|
|
||||||
return (amx->error = AMX_ERR_INIT_JIT);
|
return (amx->error = AMX_ERR_INIT_JIT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -341,7 +342,7 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
|
||||||
if (g_plugins.m_Finalized)
|
if (g_plugins.m_Finalized)
|
||||||
{
|
{
|
||||||
amx_Register(amx, g_plugins.pNatives, -1);
|
amx_Register(amx, g_plugins.pNatives, -1);
|
||||||
|
|
||||||
if (CheckModules(amx, error))
|
if (CheckModules(amx, error))
|
||||||
{
|
{
|
||||||
if (amx_Register(amx, core_Natives, -1) != AMX_ERR_NONE)
|
if (amx_Register(amx, core_Natives, -1) != AMX_ERR_NONE)
|
||||||
|
@ -371,7 +372,7 @@ const char *StrCaseStr(const char *as, const char *bs)
|
||||||
{
|
{
|
||||||
a[i] = tolower(as[i]);
|
a[i] = tolower(as[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
a[len] = 0;
|
a[len] = 0;
|
||||||
|
|
||||||
len = strlen(bs);
|
len = strlen(bs);
|
||||||
|
@ -383,7 +384,7 @@ const char *StrCaseStr(const char *as, const char *bs)
|
||||||
{
|
{
|
||||||
b[i] = tolower(bs[i]);
|
b[i] = tolower(bs[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
b[len] = 0;
|
b[len] = 0;
|
||||||
|
|
||||||
return strstr(a, b);
|
return strstr(a, b);
|
||||||
|
@ -396,14 +397,14 @@ int CheckModules(AMX *amx, char error[128])
|
||||||
char buffer[64];
|
char buffer[64];
|
||||||
LibType expect;
|
LibType expect;
|
||||||
bool found;
|
bool found;
|
||||||
|
|
||||||
Handler *pHandler = (Handler *)amx->userdata[UD_HANDLER];
|
Handler *pHandler = (Handler *)amx->userdata[UD_HANDLER];
|
||||||
|
|
||||||
/** decode old style plugins */
|
/** decode old style plugins */
|
||||||
for (int i = 0; i < numLibraries; i++)
|
for (int i = 0; i < numLibraries; i++)
|
||||||
{
|
{
|
||||||
amx_GetLibrary(amx, i, buffer, sizeof(buffer) - 1);
|
amx_GetLibrary(amx, i, buffer, sizeof(buffer) - 1);
|
||||||
|
|
||||||
if (stricmp(buffer, "float") == 0)
|
if (stricmp(buffer, "float") == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -428,8 +429,8 @@ int CheckModules(AMX *amx, char error[128])
|
||||||
++a;
|
++a;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (cm.getInfoNew() &&
|
if (cm.getInfoNew() &&
|
||||||
cm.getInfoNew()->logtag &&
|
cm.getInfoNew()->logtag &&
|
||||||
!strcasecmp(cm.getInfoNew()->logtag, buffer))
|
!strcasecmp(cm.getInfoNew()->logtag, buffer))
|
||||||
{
|
{
|
||||||
found = true;
|
found = true;
|
||||||
|
@ -438,7 +439,7 @@ int CheckModules(AMX *amx, char error[128])
|
||||||
++a;
|
++a;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
{
|
{
|
||||||
if (expect == LibType_Library)
|
if (expect == LibType_Library)
|
||||||
|
@ -452,7 +453,7 @@ int CheckModules(AMX *amx, char error[128])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
{
|
{
|
||||||
const char *type = "Module/Library";
|
const char *type = "Module/Library";
|
||||||
|
@ -541,7 +542,7 @@ int set_amxnatives(AMX* amx, char error[128])
|
||||||
|
|
||||||
Debugger *pd;
|
Debugger *pd;
|
||||||
pd = DisableDebugHandler(amx);
|
pd = DisableDebugHandler(amx);
|
||||||
|
|
||||||
if (amx_FindPublic(amx, "plugin_natives", &idx) == AMX_ERR_NONE)
|
if (amx_FindPublic(amx, "plugin_natives", &idx) == AMX_ERR_NONE)
|
||||||
{
|
{
|
||||||
if ((err = amx_Exec(amx, &retval, idx)) != AMX_ERR_NONE)
|
if ((err = amx_Exec(amx, &retval, idx)) != AMX_ERR_NONE)
|
||||||
|
@ -559,7 +560,7 @@ int set_amxnatives(AMX* amx, char error[128])
|
||||||
}
|
}
|
||||||
|
|
||||||
int unload_amxscript(AMX* amx, void** program)
|
int unload_amxscript(AMX* amx, void** program)
|
||||||
{
|
{
|
||||||
#if defined JIT
|
#if defined JIT
|
||||||
int flags = amx->flags;
|
int flags = amx->flags;
|
||||||
long code_size = amx->code_size;
|
long code_size = amx->code_size;
|
||||||
|
@ -568,7 +569,7 @@ int unload_amxscript(AMX* amx, void** program)
|
||||||
Debugger *pDebugger = (Debugger *)amx->userdata[UD_DEBUGGER];
|
Debugger *pDebugger = (Debugger *)amx->userdata[UD_DEBUGGER];
|
||||||
if (pDebugger)
|
if (pDebugger)
|
||||||
delete pDebugger;
|
delete pDebugger;
|
||||||
|
|
||||||
Handler *pHandler = (Handler *)amx->userdata[UD_HANDLER];
|
Handler *pHandler = (Handler *)amx->userdata[UD_HANDLER];
|
||||||
if (pHandler)
|
if (pHandler)
|
||||||
delete pHandler;
|
delete pHandler;
|
||||||
|
@ -576,14 +577,14 @@ int unload_amxscript(AMX* amx, void** program)
|
||||||
optimizer_s *opt = (optimizer_s *)amx->usertags[UT_OPTIMIZER];
|
optimizer_s *opt = (optimizer_s *)amx->usertags[UT_OPTIMIZER];
|
||||||
if (opt)
|
if (opt)
|
||||||
delete opt;
|
delete opt;
|
||||||
|
|
||||||
CList<CScript, AMX*>::iterator a = g_loadedscripts.find(amx);
|
CList<CScript, AMX*>::iterator a = g_loadedscripts.find(amx);
|
||||||
|
|
||||||
if (a)
|
if (a)
|
||||||
a.remove();
|
a.remove();
|
||||||
|
|
||||||
char *prg = (char *)*program;
|
char *prg = (char *)*program;
|
||||||
|
|
||||||
if (!prg)
|
if (!prg)
|
||||||
return AMX_ERR_NONE;
|
return AMX_ERR_NONE;
|
||||||
|
|
||||||
|
@ -606,7 +607,7 @@ int unload_amxscript(AMX* amx, void** program)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#elif defined WIN32
|
#elif defined WIN32
|
||||||
|
|
||||||
if ((flags & AMX_FLAG_JITC) != AMX_FLAG_JITC)
|
if ((flags & AMX_FLAG_JITC) != AMX_FLAG_JITC)
|
||||||
{
|
{
|
||||||
delete [] prg;
|
delete [] prg;
|
||||||
|
@ -628,18 +629,18 @@ int unload_amxscript(AMX* amx, void** program)
|
||||||
AMX* get_amxscript(int id, void** code, const char** filename)
|
AMX* get_amxscript(int id, void** code, const char** filename)
|
||||||
{
|
{
|
||||||
CList<CScript, AMX*>::iterator a = g_loadedscripts.begin();
|
CList<CScript, AMX*>::iterator a = g_loadedscripts.begin();
|
||||||
|
|
||||||
while (a && id--)
|
while (a && id--)
|
||||||
++a;
|
++a;
|
||||||
|
|
||||||
if (a)
|
if (a)
|
||||||
{
|
{
|
||||||
*filename = (*a).getName();
|
*filename = (*a).getName();
|
||||||
*code = (*a).getCode();
|
*code = (*a).getCode();
|
||||||
|
|
||||||
return (*a).getAMX();
|
return (*a).getAMX();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -647,7 +648,7 @@ const char* GetFileName(AMX *amx)
|
||||||
{
|
{
|
||||||
const char *filename = "";
|
const char *filename = "";
|
||||||
CPluginMngr::CPlugin *pl = g_plugins.findPluginFast(amx);
|
CPluginMngr::CPlugin *pl = g_plugins.findPluginFast(amx);
|
||||||
|
|
||||||
if (pl)
|
if (pl)
|
||||||
{
|
{
|
||||||
filename = pl->getName();
|
filename = pl->getName();
|
||||||
|
@ -671,77 +672,41 @@ void get_modname(char* buffer)
|
||||||
strcpy(buffer, g_mod_name.chars());
|
strcpy(buffer, g_mod_name.chars());
|
||||||
}
|
}
|
||||||
|
|
||||||
char* build_pathname(const char *fmt, ...)
|
char *build_pathname(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
static char string[256];
|
static char string[PLATFORM_MAX_PATH];
|
||||||
int b;
|
auto len = ke::path::Format(string, sizeof(string), "%s/", g_mod_name.chars());
|
||||||
int a = b = ke::SafeSprintf(string, sizeof(string), "%s%c", g_mod_name.chars(), PATH_SEP_CHAR);
|
|
||||||
|
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
va_start(argptr, fmt);
|
va_start(argptr, fmt);
|
||||||
a += vsnprintf (&string[a], 255 - a, fmt, argptr);
|
ke::path::FormatVa(&string[len], sizeof(string) - len, fmt, argptr);
|
||||||
string[a] = 0;
|
|
||||||
va_end(argptr);
|
va_end(argptr);
|
||||||
|
|
||||||
char* path = &string[b];
|
|
||||||
|
|
||||||
while (*path)
|
|
||||||
{
|
|
||||||
if (*path == ALT_SEP_CHAR)
|
|
||||||
{
|
|
||||||
*path = PATH_SEP_CHAR;
|
|
||||||
}
|
|
||||||
++path;
|
|
||||||
}
|
|
||||||
|
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *build_pathname_r(char *buffer, size_t maxlen, const char *fmt, ...)
|
char *build_pathname_r(char *buffer, size_t maxlen, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
ke::SafeSprintf(buffer, maxlen, "%s%c", g_mod_name.chars(), PATH_SEP_CHAR);
|
auto len = ke::path::Format(buffer, maxlen, "%s/", g_mod_name.chars());
|
||||||
|
|
||||||
size_t len = strlen(buffer);
|
|
||||||
char *ptr = buffer + len;
|
|
||||||
|
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
va_start(argptr, fmt);
|
va_start(argptr, fmt);
|
||||||
vsnprintf (ptr, maxlen-len, fmt, argptr);
|
ke::path::FormatVa(&buffer[len], maxlen - len, fmt, argptr);
|
||||||
va_end (argptr);
|
va_end (argptr);
|
||||||
|
|
||||||
while (*ptr)
|
|
||||||
{
|
|
||||||
if (*ptr == ALT_SEP_CHAR)
|
|
||||||
{
|
|
||||||
*ptr = PATH_SEP_CHAR;
|
|
||||||
}
|
|
||||||
++ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
// build pathname based on addons dir
|
// build pathname based on addons dir
|
||||||
char* build_pathname_addons(const char *fmt, ...)
|
char *build_pathname_addons(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
static char string[256];
|
static char string[PLATFORM_MAX_PATH];
|
||||||
|
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
va_start(argptr, fmt);
|
va_start(argptr, fmt);
|
||||||
vsnprintf (string, 255, fmt, argptr);
|
ke::path::FormatVa(string, sizeof(string), fmt, argptr);
|
||||||
va_end(argptr);
|
va_end(argptr);
|
||||||
|
|
||||||
char* path = string;
|
|
||||||
|
|
||||||
while (*path)
|
|
||||||
{
|
|
||||||
if (*path == ALT_SEP_CHAR)
|
|
||||||
{
|
|
||||||
*path = PATH_SEP_CHAR;
|
|
||||||
}
|
|
||||||
++path;
|
|
||||||
}
|
|
||||||
|
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -762,7 +727,7 @@ bool ConvertModuleName(const char *pathString, char *path)
|
||||||
/* run to filename instead of dir */
|
/* run to filename instead of dir */
|
||||||
char *ptr = tmpname;
|
char *ptr = tmpname;
|
||||||
ptr = tmpname + len - 1;
|
ptr = tmpname + len - 1;
|
||||||
while (ptr >= tmpname && *ptr != PATH_SEP_CHAR)
|
while (ptr >= tmpname && *ptr != PLATFORM_SEP_CHAR)
|
||||||
ptr--;
|
ptr--;
|
||||||
if (ptr >= tmpname)
|
if (ptr >= tmpname)
|
||||||
{
|
{
|
||||||
|
@ -822,7 +787,7 @@ bool ConvertModuleName(const char *pathString, char *path)
|
||||||
*ptr = '\0';
|
*ptr = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t length = ke::SafeSprintf(path, PLATFORM_MAX_PATH, "%s%c%s_amxx", orig_path, PATH_SEP_CHAR, tmpname);
|
auto length = ke::path::Format(path, PLATFORM_MAX_PATH, "%s/%s_amxx", orig_path, tmpname);
|
||||||
|
|
||||||
#if defined PLATFORM_LINUX
|
#if defined PLATFORM_LINUX
|
||||||
# if defined AMD64 || PAWN_CELL_SIZE == 64
|
# if defined AMD64 || PAWN_CELL_SIZE == 64
|
||||||
|
@ -842,8 +807,8 @@ bool LoadModule(const char *shortname, PLUG_LOADTIME now, bool simplify, bool no
|
||||||
char path[PLATFORM_MAX_PATH];
|
char path[PLATFORM_MAX_PATH];
|
||||||
|
|
||||||
build_pathname_r(
|
build_pathname_r(
|
||||||
pathString,
|
pathString,
|
||||||
sizeof(pathString)-1,
|
sizeof(pathString),
|
||||||
"%s/%s",
|
"%s/%s",
|
||||||
get_localinfo("amxx_modulesdir", "addons/amxmodx/modules"),
|
get_localinfo("amxx_modulesdir", "addons/amxmodx/modules"),
|
||||||
shortname);
|
shortname);
|
||||||
|
@ -919,8 +884,8 @@ bool LoadModule(const char *shortname, PLUG_LOADTIME now, bool simplify, bool no
|
||||||
if (cc->IsMetamod())
|
if (cc->IsMetamod())
|
||||||
{
|
{
|
||||||
char *mmpathname = build_pathname_addons(
|
char *mmpathname = build_pathname_addons(
|
||||||
"%s/%s",
|
"%s/%s",
|
||||||
get_localinfo("amxx_modulesdir", "addons/amxmodx/modules"),
|
get_localinfo("amxx_modulesdir", "addons/amxmodx/modules"),
|
||||||
shortname);
|
shortname);
|
||||||
ConvertModuleName(mmpathname, path);
|
ConvertModuleName(mmpathname, path);
|
||||||
cc->attachMetamod(path, now);
|
cc->attachMetamod(path, now);
|
||||||
|
@ -933,7 +898,7 @@ bool LoadModule(const char *shortname, PLUG_LOADTIME now, bool simplify, bool no
|
||||||
switch (cc->getStatusValue())
|
switch (cc->getStatusValue())
|
||||||
{
|
{
|
||||||
case MODULE_FUNCNOTPRESENT:
|
case MODULE_FUNCNOTPRESENT:
|
||||||
report_error(1, "[AMXX] Module requested a not existing function (file \"%s\")%s%s%s", cc->getFilename(), cc->getMissingFunc() ? " (func \"" : "",
|
report_error(1, "[AMXX] Module requested a not existing function (file \"%s\")%s%s%s", cc->getFilename(), cc->getMissingFunc() ? " (func \"" : "",
|
||||||
cc->getMissingFunc() ? cc->getMissingFunc() : "", cc->getMissingFunc() ? "\")" : "");
|
cc->getMissingFunc() ? cc->getMissingFunc() : "", cc->getMissingFunc() ? "\")" : "");
|
||||||
break;
|
break;
|
||||||
case MODULE_INTERROR:
|
case MODULE_INTERROR:
|
||||||
|
@ -982,17 +947,17 @@ int loadModules(const char* filename, PLUG_LOADTIME now)
|
||||||
{
|
{
|
||||||
simplify = false;
|
simplify = false;
|
||||||
strncopy(line, &buffer[1], sizeof(line));
|
strncopy(line, &buffer[1], sizeof(line));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strncopy(line, buffer, sizeof(line));
|
strncopy(line, buffer, sizeof(line));
|
||||||
}
|
}
|
||||||
|
|
||||||
*moduleName = '\0';
|
*moduleName = '\0';
|
||||||
|
|
||||||
if (sscanf(line, "%s", moduleName) == EOF)
|
if (sscanf(line, "%s", moduleName) == EOF)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (LoadModule(moduleName, now, simplify))
|
if (LoadModule(moduleName, now, simplify))
|
||||||
loaded++;
|
loaded++;
|
||||||
}
|
}
|
||||||
|
@ -1023,7 +988,7 @@ void detachReloadModules()
|
||||||
{
|
{
|
||||||
(*a).detachModule();
|
(*a).detachModule();
|
||||||
a.remove();
|
a.remove();
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
++a;
|
++a;
|
||||||
|
@ -1033,7 +998,7 @@ void detachReloadModules()
|
||||||
const char* strip_name(const char* a)
|
const char* strip_name(const char* a)
|
||||||
{
|
{
|
||||||
const char* ret = a;
|
const char* ret = a;
|
||||||
|
|
||||||
while (*a)
|
while (*a)
|
||||||
{
|
{
|
||||||
if (*a == '/' || *a == '\\')
|
if (*a == '/' || *a == '\\')
|
||||||
|
@ -1043,7 +1008,7 @@ const char* strip_name(const char* a)
|
||||||
}
|
}
|
||||||
++a;
|
++a;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1052,7 +1017,7 @@ int countModules(CountModulesMode mode)
|
||||||
{
|
{
|
||||||
CList<CModule, const char *>::iterator iter;
|
CList<CModule, const char *>::iterator iter;
|
||||||
int num;
|
int num;
|
||||||
|
|
||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
case CountModules_All:
|
case CountModules_All:
|
||||||
|
@ -1060,29 +1025,29 @@ int countModules(CountModulesMode mode)
|
||||||
case CountModules_Running:
|
case CountModules_Running:
|
||||||
iter = g_modules.begin();
|
iter = g_modules.begin();
|
||||||
num = 0;
|
num = 0;
|
||||||
|
|
||||||
while (iter)
|
while (iter)
|
||||||
{
|
{
|
||||||
if ((*iter).getStatusValue() == MODULE_LOADED)
|
if ((*iter).getStatusValue() == MODULE_LOADED)
|
||||||
++num;
|
++num;
|
||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
return num;
|
return num;
|
||||||
case CountModules_Stopped:
|
case CountModules_Stopped:
|
||||||
iter = g_modules.begin();
|
iter = g_modules.begin();
|
||||||
num = 0;
|
num = 0;
|
||||||
|
|
||||||
while (iter)
|
while (iter)
|
||||||
{
|
{
|
||||||
if ((*iter).getStatusValue() != MODULE_LOADED)
|
if ((*iter).getStatusValue() != MODULE_LOADED)
|
||||||
++num;
|
++num;
|
||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1090,7 +1055,7 @@ int countModules(CountModulesMode mode)
|
||||||
void modules_callPluginsLoaded()
|
void modules_callPluginsLoaded()
|
||||||
{
|
{
|
||||||
CList<CModule, const char *>::iterator iter = g_modules.begin();
|
CList<CModule, const char *>::iterator iter = g_modules.begin();
|
||||||
|
|
||||||
while (iter)
|
while (iter)
|
||||||
{
|
{
|
||||||
(*iter).CallPluginsLoaded();
|
(*iter).CallPluginsLoaded();
|
||||||
|
@ -1128,7 +1093,7 @@ int MNF_AddNatives(AMX_NATIVE_INFO* natives)
|
||||||
return FALSE; // may only be called from attach
|
return FALSE; // may only be called from attach
|
||||||
|
|
||||||
g_CurrentlyCalledModule->m_Natives.append(natives);
|
g_CurrentlyCalledModule->m_Natives.append(natives);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1150,26 +1115,26 @@ const char *MNF_GetModname(void)
|
||||||
AMX *MNF_GetAmxScript(int id)
|
AMX *MNF_GetAmxScript(int id)
|
||||||
{
|
{
|
||||||
CList<CScript, AMX*>::iterator iter = g_loadedscripts.begin();
|
CList<CScript, AMX*>::iterator iter = g_loadedscripts.begin();
|
||||||
|
|
||||||
while (iter && id--)
|
while (iter && id--)
|
||||||
++iter;
|
++iter;
|
||||||
|
|
||||||
if (iter == 0)
|
if (iter == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return (*iter).getAMX();
|
return (*iter).getAMX();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *MNF_GetAmxScriptName(int id)
|
const char *MNF_GetAmxScriptName(int id)
|
||||||
{
|
{
|
||||||
CList<CScript, AMX*>::iterator iter = g_loadedscripts.begin();
|
CList<CScript, AMX*>::iterator iter = g_loadedscripts.begin();
|
||||||
|
|
||||||
while (iter && id--)
|
while (iter && id--)
|
||||||
++iter;
|
++iter;
|
||||||
|
|
||||||
if (iter == 0)
|
if (iter == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return (*iter).getName();
|
return (*iter).getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1178,7 +1143,7 @@ int MNF_FindAmxScriptByName(const char *name)
|
||||||
CList<CScript, AMX*>::iterator iter = g_loadedscripts.begin();
|
CList<CScript, AMX*>::iterator iter = g_loadedscripts.begin();
|
||||||
bool found = false;
|
bool found = false;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
while (iter)
|
while (iter)
|
||||||
{
|
{
|
||||||
if (stricmp((*iter).getName(), name) == 0)
|
if (stricmp((*iter).getName(), name) == 0)
|
||||||
|
@ -1189,10 +1154,10 @@ int MNF_FindAmxScriptByName(const char *name)
|
||||||
++iter;
|
++iter;
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1201,9 +1166,9 @@ int MNF_FindAmxScriptByAmx(const AMX *amx)
|
||||||
CList<CScript, AMX*>::iterator iter = g_loadedscripts.begin();
|
CList<CScript, AMX*>::iterator iter = g_loadedscripts.begin();
|
||||||
bool found = false;
|
bool found = false;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
while (iter)
|
while (iter)
|
||||||
|
|
||||||
{
|
{
|
||||||
if (amx == (*iter).getAMX())
|
if (amx == (*iter).getAMX())
|
||||||
{
|
{
|
||||||
|
@ -1213,10 +1178,10 @@ int MNF_FindAmxScriptByAmx(const AMX *amx)
|
||||||
++iter;
|
++iter;
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1224,10 +1189,10 @@ extern "C" char *MNF_GetAmxString(AMX *amx, cell amx_addr, int bufferId, int *pL
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
char *retVal = get_amxstring(amx, amx_addr, bufferId, len);
|
char *retVal = get_amxstring(amx, amx_addr, bufferId, len);
|
||||||
|
|
||||||
if (pLen)
|
if (pLen)
|
||||||
*pLen = len;
|
*pLen = len;
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1245,10 +1210,10 @@ extern "C" char *MNF_GetAmxStringNull(AMX *amx, cell amx_addr, int bufferId, int
|
||||||
int MNF_GetAmxStringLen(const cell *ptr)
|
int MNF_GetAmxStringLen(const cell *ptr)
|
||||||
{
|
{
|
||||||
register int c = 0;
|
register int c = 0;
|
||||||
|
|
||||||
while (ptr[c])
|
while (ptr[c])
|
||||||
++c;
|
++c;
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1267,10 +1232,10 @@ char *MNF_FormatAmxString(AMX *amx, cell *params, int startParam, int *pLen)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
char *retVal = format_amxstring(amx, params, startParam, len);
|
char *retVal = format_amxstring(amx, params, startParam, len);
|
||||||
|
|
||||||
if (pLen)
|
if (pLen)
|
||||||
*pLen = len;
|
*pLen = len;
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1278,9 +1243,9 @@ int MNF_GetPlayerFlags(int id)
|
||||||
{
|
{
|
||||||
if (id < 1 || id > gpGlobals->maxClients)
|
if (id < 1 || id > gpGlobals->maxClients)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
CPlayer *pPlayer = GET_PLAYER_POINTER_I(id);
|
CPlayer *pPlayer = GET_PLAYER_POINTER_I(id);
|
||||||
|
|
||||||
return (pPlayer->flags[0]);
|
return (pPlayer->flags[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1293,9 +1258,9 @@ int MNF_IsPlayerValid(int id)
|
||||||
{
|
{
|
||||||
if (id < 1 || id > gpGlobals->maxClients)
|
if (id < 1 || id > gpGlobals->maxClients)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
CPlayer *pPlayer = GET_PLAYER_POINTER_I(id);
|
CPlayer *pPlayer = GET_PLAYER_POINTER_I(id);
|
||||||
|
|
||||||
return (pPlayer->initialized) ? 1 : 0;
|
return (pPlayer->initialized) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1303,7 +1268,7 @@ const char * MNF_GetPlayerName(int id)
|
||||||
{
|
{
|
||||||
if (id < 1 || id > gpGlobals->maxClients)
|
if (id < 1 || id > gpGlobals->maxClients)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return GET_PLAYER_POINTER_I(id)->name.chars();
|
return GET_PLAYER_POINTER_I(id)->name.chars();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1329,7 +1294,7 @@ const char * MNF_GetPlayerIP(int id)
|
||||||
{
|
{
|
||||||
if (id < 1 || id > gpGlobals->maxClients)
|
if (id < 1 || id > gpGlobals->maxClients)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return GET_PLAYER_POINTER_I(id)->ip.chars();
|
return GET_PLAYER_POINTER_I(id)->ip.chars();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1337,7 +1302,7 @@ int MNF_IsPlayerInGame(int id)
|
||||||
{
|
{
|
||||||
if (id < 1 || id > gpGlobals->maxClients)
|
if (id < 1 || id > gpGlobals->maxClients)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return GET_PLAYER_POINTER_I(id)->ingame ? 1 : 0;
|
return GET_PLAYER_POINTER_I(id)->ingame ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1345,7 +1310,7 @@ int MNF_IsPlayerBot(int id)
|
||||||
{
|
{
|
||||||
if (id < 1 || id > gpGlobals->maxClients)
|
if (id < 1 || id > gpGlobals->maxClients)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return GET_PLAYER_POINTER_I(id)->IsBot() ? 1 : 0;
|
return GET_PLAYER_POINTER_I(id)->IsBot() ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1353,7 +1318,7 @@ int MNF_IsPlayerAuthorized(int id)
|
||||||
{
|
{
|
||||||
if (id < 1 || id > gpGlobals->maxClients)
|
if (id < 1 || id > gpGlobals->maxClients)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return GET_PLAYER_POINTER_I(id)->authorized ? 1 : 0;
|
return GET_PLAYER_POINTER_I(id)->authorized ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1361,7 +1326,7 @@ float MNF_GetPlayerTime(int id)
|
||||||
{
|
{
|
||||||
if (id < 1 || id > gpGlobals->maxClients)
|
if (id < 1 || id > gpGlobals->maxClients)
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
|
|
||||||
return GET_PLAYER_POINTER_I(id)->time;
|
return GET_PLAYER_POINTER_I(id)->time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1369,7 +1334,7 @@ float MNF_GetPlayerPlayTime(int id)
|
||||||
{
|
{
|
||||||
if (id < 1 || id > gpGlobals->maxClients)
|
if (id < 1 || id > gpGlobals->maxClients)
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
|
|
||||||
return GET_PLAYER_POINTER_I(id)->playtime;
|
return GET_PLAYER_POINTER_I(id)->playtime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1377,7 +1342,7 @@ int MNF_GetPlayerCurweapon(int id)
|
||||||
{
|
{
|
||||||
if (id < 1 || id > gpGlobals->maxClients)
|
if (id < 1 || id > gpGlobals->maxClients)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return GET_PLAYER_POINTER_I(id)->current;
|
return GET_PLAYER_POINTER_I(id)->current;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1385,7 +1350,7 @@ int MNF_GetPlayerTeamID(int id)
|
||||||
{
|
{
|
||||||
if (id < 1 || id > gpGlobals->maxClients)
|
if (id < 1 || id > gpGlobals->maxClients)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return GET_PLAYER_POINTER_I(id)->teamId;
|
return GET_PLAYER_POINTER_I(id)->teamId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1393,7 +1358,7 @@ int MNF_GetPlayerDeaths(int id)
|
||||||
{
|
{
|
||||||
if (id < 1 || id > gpGlobals->maxClients)
|
if (id < 1 || id > gpGlobals->maxClients)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return GET_PLAYER_POINTER_I(id)->deaths;
|
return GET_PLAYER_POINTER_I(id)->deaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1401,7 +1366,7 @@ int MNF_GetPlayerMenu(int id)
|
||||||
{
|
{
|
||||||
if (id < 1 || id > gpGlobals->maxClients)
|
if (id < 1 || id > gpGlobals->maxClients)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return GET_PLAYER_POINTER_I(id)->menu;
|
return GET_PLAYER_POINTER_I(id)->menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1409,7 +1374,7 @@ int MNF_GetPlayerKeys(int id)
|
||||||
{
|
{
|
||||||
if (id < 1 || id > gpGlobals->maxClients)
|
if (id < 1 || id > gpGlobals->maxClients)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return GET_PLAYER_POINTER_I(id)->keys;
|
return GET_PLAYER_POINTER_I(id)->keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1417,7 +1382,7 @@ int MNF_IsPlayerAlive(int id)
|
||||||
{
|
{
|
||||||
if (id < 1 || id > gpGlobals->maxClients)
|
if (id < 1 || id > gpGlobals->maxClients)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return GET_PLAYER_POINTER_I(id)->IsAlive() ? 1 : 0;
|
return GET_PLAYER_POINTER_I(id)->IsAlive() ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1425,7 +1390,7 @@ float MNF_GetPlayerFrags(int id)
|
||||||
{
|
{
|
||||||
if (id < 1 || id > gpGlobals->maxClients)
|
if (id < 1 || id > gpGlobals->maxClients)
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
|
|
||||||
return GET_PLAYER_POINTER_I(id)->pEdict->v.frags;
|
return GET_PLAYER_POINTER_I(id)->pEdict->v.frags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1433,9 +1398,9 @@ int MNF_IsPlayerConnecting(int id)
|
||||||
{
|
{
|
||||||
if (id < 1 || id > gpGlobals->maxClients)
|
if (id < 1 || id > gpGlobals->maxClients)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
CPlayer * pPlayer = GET_PLAYER_POINTER_I(id);
|
CPlayer * pPlayer = GET_PLAYER_POINTER_I(id);
|
||||||
|
|
||||||
return (!pPlayer->ingame && pPlayer->initialized && (GETPLAYERUSERID(pPlayer->pEdict) > 0)) ? 1 : 0;
|
return (!pPlayer->ingame && pPlayer->initialized && (GETPLAYERUSERID(pPlayer->pEdict) > 0)) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1443,7 +1408,7 @@ int MNF_IsPlayerHLTV(int id)
|
||||||
{
|
{
|
||||||
if (id < 1 || id > gpGlobals->maxClients)
|
if (id < 1 || id > gpGlobals->maxClients)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return (GET_PLAYER_POINTER_I(id)->pEdict->v.flags & FL_PROXY) ? 1 : 0;
|
return (GET_PLAYER_POINTER_I(id)->pEdict->v.flags & FL_PROXY) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1451,7 +1416,7 @@ float MNF_GetPlayerArmor(int id)
|
||||||
{
|
{
|
||||||
if (id < 1 || id > gpGlobals->maxClients)
|
if (id < 1 || id > gpGlobals->maxClients)
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
|
|
||||||
return (GET_PLAYER_POINTER_I(id)->pEdict->v.armorvalue);
|
return (GET_PLAYER_POINTER_I(id)->pEdict->v.armorvalue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1459,7 +1424,7 @@ float MNF_GetPlayerHealth(int id)
|
||||||
{
|
{
|
||||||
if (id < 1 || id > gpGlobals->maxClients)
|
if (id < 1 || id > gpGlobals->maxClients)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return (GET_PLAYER_POINTER_I(id)->pEdict->v.health);
|
return (GET_PLAYER_POINTER_I(id)->pEdict->v.health);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1481,7 +1446,7 @@ void MNF_Log(const char *fmt, ...)
|
||||||
_vsnprintf(msg, sizeof(msg) - 1, fmt, arglst);
|
_vsnprintf(msg, sizeof(msg) - 1, fmt, arglst);
|
||||||
//vsprintf(msg, fmt, arglst);
|
//vsprintf(msg, fmt, arglst);
|
||||||
va_end(arglst);
|
va_end(arglst);
|
||||||
|
|
||||||
AMXXLOG_Log("%s", msg);
|
AMXXLOG_Log("%s", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1496,7 +1461,7 @@ extern "C" void LogError(AMX *amx, int err, const char *fmt, ...)
|
||||||
char msg_buffer[2048];
|
char msg_buffer[2048];
|
||||||
|
|
||||||
msg_buffer[0] = '\0';
|
msg_buffer[0] = '\0';
|
||||||
|
|
||||||
if (fmt != NULL)
|
if (fmt != NULL)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
@ -1534,7 +1499,7 @@ extern "C" void LogError(AMX *amx, int err, const char *fmt, ...)
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//give the user a first-chance at blocking the error from displaying
|
//give the user a first-chance at blocking the error from displaying
|
||||||
if (pHandler->HandleError(fmt ? msg_buffer : NULL) != 0)
|
if (pHandler->HandleError(fmt ? msg_buffer : NULL) != 0)
|
||||||
{
|
{
|
||||||
|
@ -1550,7 +1515,7 @@ extern "C" void LogError(AMX *amx, int err, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
AMXXLOG_Error("%s", msg_buffer);
|
AMXXLOG_Error("%s", msg_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
Debugger::GenericMessage(amx, err);
|
Debugger::GenericMessage(amx, err);
|
||||||
if (err != AMX_ERR_EXIT)
|
if (err != AMX_ERR_EXIT)
|
||||||
{
|
{
|
||||||
|
@ -1590,7 +1555,7 @@ edict_t* MNF_GetPlayerEdict(int id)
|
||||||
{
|
{
|
||||||
if (id < 1 || id > gpGlobals->maxClients)
|
if (id < 1 || id > gpGlobals->maxClients)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return (GET_PLAYER_POINTER_I(id)->pEdict);
|
return (GET_PLAYER_POINTER_I(id)->pEdict);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1639,7 +1604,7 @@ inline bool operator ==(func_s &arg1, const char *desc)
|
||||||
{
|
{
|
||||||
if (strcmp(arg1.desc, desc) == 0)
|
if (strcmp(arg1.desc, desc) == 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1920,11 +1885,11 @@ void *Module_ReqFnptr(const char *funcName)
|
||||||
{
|
{
|
||||||
// code
|
// code
|
||||||
// ^---- really? wow!
|
// ^---- really? wow!
|
||||||
|
|
||||||
g_LastRequestedFunc = funcName;
|
g_LastRequestedFunc = funcName;
|
||||||
|
|
||||||
CList<func_s, const char *>::iterator iter;
|
CList<func_s, const char *>::iterator iter;
|
||||||
|
|
||||||
for (iter = g_functions.begin(); iter; ++iter)
|
for (iter = g_functions.begin(); iter; ++iter)
|
||||||
{
|
{
|
||||||
if (strcmp(funcName, iter->desc) == 0)
|
if (strcmp(funcName, iter->desc) == 0)
|
||||||
|
@ -1937,7 +1902,7 @@ void *Module_ReqFnptr(const char *funcName)
|
||||||
Debugger *DisableDebugHandler(AMX *amx)
|
Debugger *DisableDebugHandler(AMX *amx)
|
||||||
{
|
{
|
||||||
Debugger *pd = static_cast<Debugger *>(amx->userdata[UD_DEBUGGER]);
|
Debugger *pd = static_cast<Debugger *>(amx->userdata[UD_DEBUGGER]);
|
||||||
|
|
||||||
amx->userdata[UD_DEBUGGER] = NULL;
|
amx->userdata[UD_DEBUGGER] = NULL;
|
||||||
amx->flags &= ~(AMX_FLAG_DEBUG);
|
amx->flags &= ~(AMX_FLAG_DEBUG);
|
||||||
amx_SetDebugHook(amx, NULL);
|
amx_SetDebugHook(amx, NULL);
|
||||||
|
@ -1957,12 +1922,12 @@ void EnableDebugHandler(AMX *amx, Debugger *pd)
|
||||||
#if !defined MEMORY_TEST && !defined WIN32
|
#if !defined MEMORY_TEST && !defined WIN32
|
||||||
void * operator new(size_t size)
|
void * operator new(size_t size)
|
||||||
{
|
{
|
||||||
return (calloc(1, size));
|
return (calloc(1, size));
|
||||||
}
|
}
|
||||||
|
|
||||||
void * operator new[](size_t size)
|
void * operator new[](size_t size)
|
||||||
{
|
{
|
||||||
return (calloc(1, size));
|
return (calloc(1, size));
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator delete(void * ptr)
|
void operator delete(void * ptr)
|
||||||
|
|
|
@ -242,7 +242,7 @@ int read_number(char *input)
|
||||||
char *end; /* Temporary pointer, needed for strtoul(). */
|
char *end; /* Temporary pointer, needed for strtoul(). */
|
||||||
|
|
||||||
// if begins with 0x or 0X it's to be interpretted as hex
|
// if begins with 0x or 0X it's to be interpretted as hex
|
||||||
if (*input=='0' &&
|
if (*input=='0' &&
|
||||||
(*(input+1)=='x' || *(input+1)=='X'))
|
(*(input+1)=='x' || *(input+1)=='X'))
|
||||||
{
|
{
|
||||||
return strtoul(input,&end,16);
|
return strtoul(input,&end,16);
|
||||||
|
@ -307,7 +307,7 @@ int ReadConfig(void)
|
||||||
{
|
{
|
||||||
char FileName[512];
|
char FileName[512];
|
||||||
|
|
||||||
MF_BuildPathnameR(FileName,sizeof(FileName)-1,"%s",get_localinfo("amxx_configsdir","addons/amxmodx/configs"));
|
MF_BuildPathnameR(FileName,sizeof(FileName),"%s",get_localinfo("amxx_configsdir","addons/amxmodx/configs"));
|
||||||
|
|
||||||
strncat(FileName,"/hamdata.ini",sizeof(FileName)-1);
|
strncat(FileName,"/hamdata.ini",sizeof(FileName)-1);
|
||||||
|
|
||||||
|
|
|
@ -46,13 +46,13 @@ static cell nvault_open(AMX *amx, cell *params)
|
||||||
int len, id=-1;
|
int len, id=-1;
|
||||||
char *name = MF_GetAmxString(amx, params[1], 0, &len);
|
char *name = MF_GetAmxString(amx, params[1], 0, &len);
|
||||||
char path[255], file[255];
|
char path[255], file[255];
|
||||||
MF_BuildPathnameR(path, sizeof(path)-1, "%s/vault", MF_GetLocalInfo("amxx_datadir", "addons/amxmodx/data"));
|
MF_BuildPathnameR(path, sizeof(path), "%s/vault", MF_GetLocalInfo("amxx_datadir", "addons/amxmodx/data"));
|
||||||
sprintf(file, "%s/%s.vault", path, name);
|
sprintf(file, "%s/%s.vault", path, name);
|
||||||
for (size_t i=0; i<g_Vaults.length(); i++)
|
for (size_t i=0; i<g_Vaults.length(); i++)
|
||||||
{
|
{
|
||||||
if (!g_Vaults[i])
|
if (!g_Vaults[i])
|
||||||
continue;
|
continue;
|
||||||
if (strcmp(g_Vaults.at(i)->GetFilename(), file) == 0)
|
if (strcmp(g_Vaults.at(i)->GetFilename(), file) == 0)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
NVault *v = (NVault *)g_VaultMngr.OpenVault(file);
|
NVault *v = (NVault *)g_VaultMngr.OpenVault(file);
|
||||||
|
|
|
@ -59,13 +59,13 @@ static cell AMX_NATIVE_CALL SQL_MakeDbTuple(AMX *amx, cell *params)
|
||||||
char path[255];
|
char path[255];
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
MF_BuildPathnameR(path, sizeof(path)-1, "%s", db);
|
MF_BuildPathnameR(path, sizeof(path), "%s", db);
|
||||||
if ((fp=fopen(path, "rb")))
|
if ((fp=fopen(path, "rb")))
|
||||||
{
|
{
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
sql->db = strdup(path);
|
sql->db = strdup(path);
|
||||||
} else {
|
} else {
|
||||||
MF_BuildPathnameR(path, sizeof(path)-1, "%s/sqlite3/%s.sq3",
|
MF_BuildPathnameR(path, sizeof(path), "%s/sqlite3/%s.sq3",
|
||||||
MF_GetLocalInfo("amxx_datadir", "addons/amxmodx/data"),
|
MF_GetLocalInfo("amxx_datadir", "addons/amxmodx/data"),
|
||||||
db);
|
db);
|
||||||
sql->db = strdup(path);
|
sql->db = strdup(path);
|
||||||
|
@ -601,7 +601,7 @@ static cell AMX_NATIVE_CALL SQL_SetCharset(AMX *amx, cell *params)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
AMX_NATIVE_INFO g_BaseSqlNatives[] =
|
AMX_NATIVE_INFO g_BaseSqlNatives[] =
|
||||||
{
|
{
|
||||||
{"SQL_MakeDbTuple", SQL_MakeDbTuple},
|
{"SQL_MakeDbTuple", SQL_MakeDbTuple},
|
||||||
{"SQL_FreeHandle", SQL_FreeHandle},
|
{"SQL_FreeHandle", SQL_FreeHandle},
|
||||||
|
@ -630,4 +630,3 @@ AMX_NATIVE_INFO g_BaseSqlNatives[] =
|
||||||
|
|
||||||
{NULL, NULL},
|
{NULL, NULL},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
static int g_ident = 0;
|
static int g_ident = 0;
|
||||||
|
|
||||||
SqlFunctions g_SqliteFuncs =
|
SqlFunctions g_SqliteFuncs =
|
||||||
{
|
{
|
||||||
&g_Sqlite,
|
&g_Sqlite,
|
||||||
SetMysqlAffinity,
|
SetMysqlAffinity,
|
||||||
|
@ -69,7 +69,7 @@ void OnAmxxAttach()
|
||||||
MF_OverrideNatives(g_OldCompatNatives, MODULE_NAME);
|
MF_OverrideNatives(g_OldCompatNatives, MODULE_NAME);
|
||||||
|
|
||||||
char path[255];
|
char path[255];
|
||||||
MF_BuildPathnameR(path, sizeof(path)-1, "%s/sqlite3", MF_GetLocalInfo("amxx_datadir", "addons/amxmodx/data"));
|
MF_BuildPathnameR(path, sizeof(path), "%s/sqlite3", MF_GetLocalInfo("amxx_datadir", "addons/amxmodx/data"));
|
||||||
if (!DirExists(path))
|
if (!DirExists(path))
|
||||||
{
|
{
|
||||||
mkdir(path
|
mkdir(path
|
||||||
|
@ -96,4 +96,3 @@ void OnPluginsUnloaded()
|
||||||
extern "C" void __cxa_pure_virtual(void)
|
extern "C" void __cxa_pure_virtual(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,14 +73,14 @@ static cell AMX_NATIVE_CALL dbi_connect(AMX *amx, cell *params)
|
||||||
int err;
|
int err;
|
||||||
char error[512];
|
char error[512];
|
||||||
/** if there is an older database, read there instead of the new path */
|
/** if there is an older database, read there instead of the new path */
|
||||||
MF_BuildPathnameR(path, sizeof(path)-1, "%s", info.database);
|
MF_BuildPathnameR(path, sizeof(path), "%s", info.database);
|
||||||
FILE *fp = fopen(path, "rb");
|
FILE *fp = fopen(path, "rb");
|
||||||
if (fp)
|
if (fp)
|
||||||
{
|
{
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
info.database = path;
|
info.database = path;
|
||||||
} else {
|
} else {
|
||||||
MF_BuildPathnameR(path, sizeof(path)-1, "%s/sqlite3/%s.sq3",
|
MF_BuildPathnameR(path, sizeof(path), "%s/sqlite3/%s.sq3",
|
||||||
MF_GetLocalInfo("amxx_datadir", "addons/amxmodx/data"),
|
MF_GetLocalInfo("amxx_datadir", "addons/amxmodx/data"),
|
||||||
info.database);
|
info.database);
|
||||||
info.database = path;
|
info.database = path;
|
||||||
|
@ -439,14 +439,14 @@ static cell AMX_NATIVE_CALL dbi_field_name(AMX *amx, cell *params)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
AMX_NATIVE_INFO g_OldCompatNatives[] =
|
AMX_NATIVE_INFO g_OldCompatNatives[] =
|
||||||
{
|
{
|
||||||
{ "dbi_connect", dbi_connect },
|
{ "dbi_connect", dbi_connect },
|
||||||
{ "dbi_query", dbi_query },
|
{ "dbi_query", dbi_query },
|
||||||
{ "dbi_query2", dbi_query2 },
|
{ "dbi_query2", dbi_query2 },
|
||||||
{ "dbi_field", dbi_field },
|
{ "dbi_field", dbi_field },
|
||||||
{ "dbi_nextrow", dbi_nextrow },
|
{ "dbi_nextrow", dbi_nextrow },
|
||||||
{ "dbi_close", dbi_close },
|
{ "dbi_close", dbi_close },
|
||||||
{ "dbi_error", dbi_error },
|
{ "dbi_error", dbi_error },
|
||||||
{ "dbi_type", dbi_type },
|
{ "dbi_type", dbi_type },
|
||||||
{ "dbi_free_result", dbi_free_result },
|
{ "dbi_free_result", dbi_free_result },
|
||||||
|
|
Loading…
Reference in New Issue
Block a user