final cleaned revision (I hope)
This commit is contained in:
parent
4b1769f457
commit
ebd4974c75
|
@ -52,7 +52,7 @@ CmdMngr::CmdMngr()
|
||||||
}
|
}
|
||||||
|
|
||||||
CmdMngr::Command::Command(CPluginMngr::CPlugin* pplugin, const char* pcmd, const char* pinfo, int pflags,
|
CmdMngr::Command::Command(CPluginMngr::CPlugin* pplugin, const char* pcmd, const char* pinfo, int pflags,
|
||||||
int pfunc, bool pviewable, CmdMngr* pparent) : commandline(pcmd), info(pinfo)
|
int pfunc, bool pviewable, CmdMngr* pparent) : commandline(pcmd), info(pinfo)
|
||||||
{
|
{
|
||||||
char szCmd[64], szArg[64];
|
char szCmd[64], szArg[64];
|
||||||
*szCmd = 0; *szArg = 0;
|
*szCmd = 0; *szArg = 0;
|
||||||
|
@ -193,6 +193,7 @@ void CmdMngr::Command::setCmdType(int a)
|
||||||
if (cmdtype & 1) // ClientCommand
|
if (cmdtype & 1) // ClientCommand
|
||||||
{
|
{
|
||||||
parent->setCmdLink(&parent->sortedlists[1], this);
|
parent->setCmdLink(&parent->sortedlists[1], this);
|
||||||
|
|
||||||
if (!parent->registerCmdPrefix(this))
|
if (!parent->registerCmdPrefix(this))
|
||||||
parent->setCmdLink(&parent->clcmdlist, this, false);
|
parent->setCmdLink(&parent->clcmdlist, this, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,12 +52,14 @@ public:
|
||||||
class Command
|
class Command
|
||||||
{
|
{
|
||||||
friend class CmdMngr;
|
friend class CmdMngr;
|
||||||
|
|
||||||
CPluginMngr::CPlugin* plugin;
|
CPluginMngr::CPlugin* plugin;
|
||||||
CmdMngr* parent;
|
CmdMngr* parent;
|
||||||
String command;
|
String command;
|
||||||
String argument;
|
String argument;
|
||||||
String commandline;
|
String commandline;
|
||||||
String info;
|
String info;
|
||||||
|
|
||||||
bool listable;
|
bool listable;
|
||||||
int function;
|
int function;
|
||||||
int flags;
|
int flags;
|
||||||
|
@ -65,6 +67,7 @@ public:
|
||||||
int cmdtype;
|
int cmdtype;
|
||||||
int prefix;
|
int prefix;
|
||||||
static int uniqueid;
|
static int uniqueid;
|
||||||
|
|
||||||
Command(CPluginMngr::CPlugin* pplugin, const char* pcmd, const char* pinfo, int pflags, int pfunc, bool pviewable, CmdMngr* pparent);
|
Command(CPluginMngr::CPlugin* pplugin, const char* pcmd, const char* pinfo, int pflags, int pfunc, bool pviewable, CmdMngr* pparent);
|
||||||
~Command();
|
~Command();
|
||||||
public:
|
public:
|
||||||
|
@ -72,7 +75,7 @@ public:
|
||||||
inline const char* getArgument() { return argument.c_str(); }
|
inline const char* getArgument() { return argument.c_str(); }
|
||||||
inline const char* getCmdInfo() { return info.c_str(); }
|
inline const char* getCmdInfo() { return info.c_str(); }
|
||||||
inline const char* getCmdLine() { return commandline.c_str(); }
|
inline const char* getCmdLine() { return commandline.c_str(); }
|
||||||
inline bool matchCommandLine(const char* cmd, const char* arg) { return (!stricmp(command.c_str()+prefix, cmd+prefix) && (argument.empty() || !stricmp(argument.c_str(), arg))); }
|
inline bool matchCommandLine(const char* cmd, const char* arg) { return (!stricmp(command.c_str() + prefix, cmd + prefix) && (argument.empty() || !stricmp(argument.c_str(), arg))); }
|
||||||
inline bool matchCommand(const char* cmd) { return (!strcmp(command.c_str(), cmd)); }
|
inline bool matchCommand(const char* cmd) { return (!strcmp(command.c_str(), cmd)); }
|
||||||
inline int getFunction() const { return function; }
|
inline int getFunction() const { return function; }
|
||||||
inline bool gotAccess(int f) const { return (!flags || ((flags & f) == flags)); }
|
inline bool gotAccess(int f) const { return (!flags || ((flags & f) == flags)); }
|
||||||
|
@ -80,6 +83,7 @@ public:
|
||||||
inline bool isViewable() const { return listable; }
|
inline bool isViewable() const { return listable; }
|
||||||
inline int getFlags() const { return flags; }
|
inline int getFlags() const { return flags; }
|
||||||
inline long int getId() const { return (long int)id; }
|
inline long int getId() const { return (long int)id; }
|
||||||
|
|
||||||
const char* getCmdType() const;
|
const char* getCmdType() const;
|
||||||
void setCmdType(int a);
|
void setCmdType(int a);
|
||||||
};
|
};
|
||||||
|
@ -105,7 +109,7 @@ private:
|
||||||
CmdMngr* parent;
|
CmdMngr* parent;
|
||||||
CmdLink* list;
|
CmdLink* list;
|
||||||
CmdPrefix* next;
|
CmdPrefix* next;
|
||||||
CmdPrefix(const char* nn, CmdMngr* pp) : name(nn), parent(pp), list(0), next(0){}
|
CmdPrefix(const char* nn, CmdMngr* pp): name(nn), parent(pp), list(0), next(0) {}
|
||||||
~CmdPrefix() { parent->clearCmdLink(&list); }
|
~CmdPrefix() { parent->clearCmdLink(&list); }
|
||||||
} *prefixHead;
|
} *prefixHead;
|
||||||
|
|
||||||
|
@ -123,9 +127,11 @@ public:
|
||||||
// Interface
|
// Interface
|
||||||
|
|
||||||
void registerPrefix(const char* nn);
|
void registerPrefix(const char* nn);
|
||||||
|
|
||||||
Command* registerCommand(CPluginMngr::CPlugin* plugin, int func, char* cmd, char* info, int level, bool listable);
|
Command* registerCommand(CPluginMngr::CPlugin* plugin, int func, char* cmd, char* info, int level, bool listable);
|
||||||
Command* getCmd(long int id, int type, int access);
|
Command* getCmd(long int id, int type, int access);
|
||||||
int getCmdNum(int type, int access);
|
int getCmdNum(int type, int access);
|
||||||
|
|
||||||
void clearBufforedInfo();
|
void clearBufforedInfo();
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
|
@ -156,6 +162,7 @@ private:
|
||||||
int buf_cmdid;
|
int buf_cmdid;
|
||||||
int buf_cmdtype;
|
int buf_cmdtype;
|
||||||
int buf_cmdaccess;
|
int buf_cmdaccess;
|
||||||
|
|
||||||
iterator buf_cmdptr;
|
iterator buf_cmdptr;
|
||||||
|
|
||||||
int buf_id;
|
int buf_id;
|
||||||
|
|
|
@ -135,7 +135,6 @@ EventsMngr::~EventsMngr()
|
||||||
clearEvents();
|
clearEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CPluginMngr::CPlugin * EventsMngr::ClEvent::getPlugin()
|
CPluginMngr::CPlugin * EventsMngr::ClEvent::getPlugin()
|
||||||
{
|
{
|
||||||
return m_Plugin;
|
return m_Plugin;
|
||||||
|
@ -311,6 +310,7 @@ void EventsMngr::parseValue(int iValue)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (anyConditions && !execute)
|
if (anyConditions && !execute)
|
||||||
(*iter).m_Done = true; // don't execute
|
(*iter).m_Done = true; // don't execute
|
||||||
}
|
}
|
||||||
|
@ -352,10 +352,12 @@ void EventsMngr::parseValue(float fValue)
|
||||||
case '<': if (fValue < condIter->fValue) execute = true; break;
|
case '<': if (fValue < condIter->fValue) execute = true; break;
|
||||||
case '>': if (fValue > condIter->fValue) execute = true; break;
|
case '>': if (fValue > condIter->fValue) execute = true; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (execute)
|
if (execute)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (anyConditions && !execute)
|
if (anyConditions && !execute)
|
||||||
(*iter).m_Done = true; // don't execute
|
(*iter).m_Done = true; // don't execute
|
||||||
}
|
}
|
||||||
|
@ -396,10 +398,12 @@ void EventsMngr::parseValue(const char *sz)
|
||||||
case '!': if (strcmp(sz, condIter->sValue.c_str())) execute = true; break;
|
case '!': if (strcmp(sz, condIter->sValue.c_str())) execute = true; break;
|
||||||
case '&': if (strstr(sz, condIter->sValue.c_str())) execute = true; break;
|
case '&': if (strstr(sz, condIter->sValue.c_str())) execute = true; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (execute)
|
if (execute)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (anyConditions && !execute)
|
if (anyConditions && !execute)
|
||||||
(*iter).m_Done = true; // don't execute
|
(*iter).m_Done = true; // don't execute
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
#ifndef __CEVENTS_H__
|
#ifndef __CEVENTS_H__
|
||||||
#define __CEVENTS_H__
|
#define __CEVENTS_H__
|
||||||
|
|
||||||
#define MAX_AMX_REG_MSG MAX_REG_MSGS+16
|
#define MAX_AMX_REG_MSG MAX_REG_MSGS + 16
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -142,12 +142,14 @@ public:
|
||||||
// Interface
|
// Interface
|
||||||
|
|
||||||
ClEvent* registerEvent(CPluginMngr::CPlugin* plugin, int func, int flags, int msgid);
|
ClEvent* registerEvent(CPluginMngr::CPlugin* plugin, int func, int flags, int msgid);
|
||||||
|
|
||||||
void parserInit(int msg_type, float* timer, CPlayer* pPlayer, int index);
|
void parserInit(int msg_type, float* timer, CPlayer* pPlayer, int index);
|
||||||
void parseValue(int iValue);
|
void parseValue(int iValue);
|
||||||
void parseValue(float fValue);
|
void parseValue(float fValue);
|
||||||
void parseValue(const char *sz);
|
void parseValue(const char *sz);
|
||||||
void executeEvents();
|
void executeEvents();
|
||||||
int getArgNum() const; //{ return (parsePos+1); }
|
|
||||||
|
int getArgNum() const; //{ return (parsePos + 1); }
|
||||||
const char* getArgString(int a) const;
|
const char* getArgString(int a) const;
|
||||||
int getArgInteger(int a) const;
|
int getArgInteger(int a) const;
|
||||||
float getArgFloat(int a) const;
|
float getArgFloat(int a) const;
|
||||||
|
|
|
@ -43,13 +43,17 @@ class File
|
||||||
public:
|
public:
|
||||||
File(const char* n, const char* m);
|
File(const char* n, const char* m);
|
||||||
~File();
|
~File();
|
||||||
|
|
||||||
operator bool () const;
|
operator bool () const;
|
||||||
|
|
||||||
friend File& operator<<(File& f, const String& n);
|
friend File& operator<<(File& f, const String& n);
|
||||||
friend File& operator<<(File& f, const char* n);
|
friend File& operator<<(File& f, const char* n);
|
||||||
friend File& operator<<(File& f, const char& c);
|
friend File& operator<<(File& f, const char& c);
|
||||||
friend File& operator<<(File& f, int n);
|
friend File& operator<<(File& f, int n);
|
||||||
friend File& operator>>(File& f, String& n);
|
friend File& operator>>(File& f, String& n);
|
||||||
friend File& operator>>(File& f, char* n);
|
friend File& operator>>(File& f, char* n);
|
||||||
|
|
||||||
int getline(char* buf, int sz);
|
int getline(char* buf, int sz);
|
||||||
|
|
||||||
File& skipWs();
|
File& skipWs();
|
||||||
};
|
};
|
||||||
|
|
|
@ -37,11 +37,14 @@ CForward::CForward(const char *name, ForwardExecType et, int numParams, const Fo
|
||||||
m_FuncName = name;
|
m_FuncName = name;
|
||||||
m_ExecType = et;
|
m_ExecType = et;
|
||||||
m_NumParams = numParams;
|
m_NumParams = numParams;
|
||||||
|
|
||||||
memcpy((void *)m_ParamTypes, paramTypes, numParams * sizeof(ForwardParam));
|
memcpy((void *)m_ParamTypes, paramTypes, numParams * sizeof(ForwardParam));
|
||||||
|
|
||||||
// find funcs
|
// find funcs
|
||||||
int func;
|
int func;
|
||||||
AMXForward *tmp = NULL;
|
AMXForward *tmp = NULL;
|
||||||
m_Funcs.clear();
|
m_Funcs.clear();
|
||||||
|
|
||||||
for (CPluginMngr::iterator iter = g_plugins.begin(); iter; ++iter)
|
for (CPluginMngr::iterator iter = g_plugins.begin(); iter; ++iter)
|
||||||
{
|
{
|
||||||
if ((*iter).isValid() && amx_FindPublic((*iter).getAMX(), name, &func) == AMX_ERR_NONE)
|
if ((*iter).isValid() && amx_FindPublic((*iter).getAMX(), name, &func) == AMX_ERR_NONE)
|
||||||
|
@ -74,51 +77,52 @@ cell CForward::execute(cell *params, ForwardPreparedArray *preparedArrays)
|
||||||
// Get debug info
|
// Get debug info
|
||||||
AMX *amx = (*iter).pPlugin->getAMX();
|
AMX *amx = (*iter).pPlugin->getAMX();
|
||||||
Debugger *pDebugger = (Debugger *)amx->userdata[UD_DEBUGGER];
|
Debugger *pDebugger = (Debugger *)amx->userdata[UD_DEBUGGER];
|
||||||
|
|
||||||
if (pDebugger)
|
if (pDebugger)
|
||||||
pDebugger->BeginExec();
|
pDebugger->BeginExec();
|
||||||
|
|
||||||
// handle strings & arrays
|
// handle strings & arrays
|
||||||
int i, ax=0;
|
int i, ax = 0;
|
||||||
|
|
||||||
for (i = 0; i < m_NumParams; ++i)
|
for (i = 0; i < m_NumParams; ++i)
|
||||||
{
|
{
|
||||||
if (m_ParamTypes[i] == FP_STRING || m_ParamTypes[i] == FP_STRINGEX)
|
if (m_ParamTypes[i] == FP_STRING || m_ParamTypes[i] == FP_STRINGEX)
|
||||||
{
|
{
|
||||||
cell *tmp;
|
cell *tmp;
|
||||||
amx_Allot(iter->pPlugin->getAMX(),
|
amx_Allot(iter->pPlugin->getAMX(), (m_ParamTypes[i] == FP_STRING) ? strlen(reinterpret_cast<const char*>(params[i])) + 1 : STRINGEX_MAXLENGTH, &realParams[i], &tmp);
|
||||||
(m_ParamTypes[i] == FP_STRING) ? strlen(reinterpret_cast<const char*>(params[i]))+1 : STRINGEX_MAXLENGTH,
|
|
||||||
&realParams[i], &tmp);
|
|
||||||
amx_SetStringOld(tmp, (const char *)(params[i]), 0, 0);
|
amx_SetStringOld(tmp, (const char *)(params[i]), 0, 0);
|
||||||
physAddrs[i] = tmp;
|
physAddrs[i] = tmp;
|
||||||
}
|
}
|
||||||
else if (m_ParamTypes[i] == FP_ARRAY)
|
else if (m_ParamTypes[i] == FP_ARRAY)
|
||||||
{
|
{
|
||||||
cell *tmp;
|
cell *tmp;
|
||||||
amx_Allot(amx, preparedArrays[params[i]].size,
|
amx_Allot(amx, preparedArrays[params[i]].size, &realParams[i], &tmp);
|
||||||
&realParams[i], &tmp);
|
|
||||||
physAddrs[i] = tmp;
|
physAddrs[i] = tmp;
|
||||||
|
|
||||||
if (preparedArrays[params[i]].type == Type_Cell)
|
if (preparedArrays[params[i]].type == Type_Cell)
|
||||||
{
|
{
|
||||||
memcpy(tmp, preparedArrays[params[i]].ptr, preparedArrays[params[i]].size * sizeof(cell));
|
memcpy(tmp, preparedArrays[params[i]].ptr, preparedArrays[params[i]].size * sizeof(cell));
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
char *data = (char*)preparedArrays[params[i]].ptr;
|
char *data = (char*)preparedArrays[params[i]].ptr;
|
||||||
|
|
||||||
for (unsigned int j = 0; j < preparedArrays[params[i]].size; ++j)
|
for (unsigned int j = 0; j < preparedArrays[params[i]].size; ++j)
|
||||||
*tmp++ = (static_cast<cell>(*data++)) & 0xFF;
|
*tmp++ = (static_cast<cell>(*data++)) & 0xFF;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
realParams[i] = params[i];
|
realParams[i] = params[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Push the parameters in reverse order. Weird, unfriendly part of Small 3.0!
|
|
||||||
for (i=m_NumParams-1; i>=0; i--)
|
//Push the parameters in reverse order. Weird, unfriendly part of Small 3.0!
|
||||||
|
for (i = m_NumParams-1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
amx_Push(amx, realParams[i]);
|
amx_Push(amx, realParams[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// exec
|
// exec
|
||||||
cell retVal;
|
cell retVal;
|
||||||
int err = amx_Exec(amx, &retVal, iter->func);
|
int err = amx_Exec(amx, &retVal, iter->func);
|
||||||
|
|
||||||
// log runtime error, if any
|
// log runtime error, if any
|
||||||
if (err != AMX_ERR_NONE)
|
if (err != AMX_ERR_NONE)
|
||||||
{
|
{
|
||||||
|
@ -126,12 +130,16 @@ cell CForward::execute(cell *params, ForwardPreparedArray *preparedArrays)
|
||||||
if (pDebugger && pDebugger->ErrorExists())
|
if (pDebugger && pDebugger->ErrorExists())
|
||||||
{
|
{
|
||||||
//we don't care, something else logged the error.
|
//we don't care, something else logged the error.
|
||||||
} else if (err != -1) {
|
}
|
||||||
|
else if (err != -1)
|
||||||
|
{
|
||||||
//nothing logged the error so spit it out anyway
|
//nothing logged the error so spit it out anyway
|
||||||
LogError(amx, err, NULL);
|
LogError(amx, err, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
amx->error = AMX_ERR_NONE;
|
amx->error = AMX_ERR_NONE;
|
||||||
|
|
||||||
if (pDebugger)
|
if (pDebugger)
|
||||||
pDebugger->EndExec();
|
pDebugger->EndExec();
|
||||||
|
|
||||||
|
@ -157,10 +165,9 @@ cell CForward::execute(cell *params, ForwardPreparedArray *preparedArrays)
|
||||||
if (preparedArrays[params[i]].type == Type_Cell)
|
if (preparedArrays[params[i]].type == Type_Cell)
|
||||||
{
|
{
|
||||||
memcpy(preparedArrays[params[i]].ptr, tmp, preparedArrays[params[i]].size * sizeof(cell));
|
memcpy(preparedArrays[params[i]].ptr, tmp, preparedArrays[params[i]].size * sizeof(cell));
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
char *data = (char*)preparedArrays[params[i]].ptr;
|
char *data = (char*)preparedArrays[params[i]].ptr;
|
||||||
|
|
||||||
for (unsigned int j = 0; j < preparedArrays[params[i]].size; ++j)
|
for (unsigned int j = 0; j < preparedArrays[params[i]].size; ++j)
|
||||||
*data++ = static_cast<char>(*tmp++ & 0xFF);
|
*data++ = static_cast<char>(*tmp++ & 0xFF);
|
||||||
}
|
}
|
||||||
|
@ -172,24 +179,25 @@ cell CForward::execute(cell *params, ForwardPreparedArray *preparedArrays)
|
||||||
// decide what to do (based on exectype and retval)
|
// decide what to do (based on exectype and retval)
|
||||||
switch (m_ExecType)
|
switch (m_ExecType)
|
||||||
{
|
{
|
||||||
case ET_IGNORE:
|
case ET_IGNORE:
|
||||||
break;
|
break;
|
||||||
case ET_STOP:
|
case ET_STOP:
|
||||||
if (retVal > 0)
|
if (retVal > 0)
|
||||||
return retVal;
|
return retVal;
|
||||||
case ET_STOP2:
|
case ET_STOP2:
|
||||||
if (retVal == 1)
|
if (retVal == 1)
|
||||||
return 1;
|
return 1;
|
||||||
else if (retVal > globRetVal)
|
else if (retVal > globRetVal)
|
||||||
globRetVal = retVal;
|
globRetVal = retVal;
|
||||||
break;
|
break;
|
||||||
case ET_CONTINUE:
|
case ET_CONTINUE:
|
||||||
if (retVal > globRetVal)
|
if (retVal > globRetVal)
|
||||||
globRetVal = retVal;
|
globRetVal = retVal;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return globRetVal;
|
return globRetVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,57 +243,60 @@ cell CSPForward::execute(cell *params, ForwardPreparedArray *preparedArrays)
|
||||||
|
|
||||||
// handle strings & arrays
|
// handle strings & arrays
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < m_NumParams; ++i)
|
for (i = 0; i < m_NumParams; ++i)
|
||||||
{
|
{
|
||||||
if (m_ParamTypes[i] == FP_STRING || m_ParamTypes[i] == FP_STRINGEX)
|
if (m_ParamTypes[i] == FP_STRING || m_ParamTypes[i] == FP_STRINGEX)
|
||||||
{
|
{
|
||||||
cell *tmp;
|
cell *tmp;
|
||||||
amx_Allot(m_Amx,
|
amx_Allot(m_Amx, (m_ParamTypes[i] == FP_STRING) ? strlen(reinterpret_cast<const char*>(params[i])) + 1 : STRINGEX_MAXLENGTH, &realParams[i], &tmp);
|
||||||
(m_ParamTypes[i] == FP_STRING) ? strlen(reinterpret_cast<const char*>(params[i]))+1 : STRINGEX_MAXLENGTH,
|
|
||||||
&realParams[i], &tmp);
|
|
||||||
amx_SetStringOld(tmp, (const char *)(params[i]), 0, 0);
|
amx_SetStringOld(tmp, (const char *)(params[i]), 0, 0);
|
||||||
physAddrs[i] = tmp;
|
physAddrs[i] = tmp;
|
||||||
}
|
}
|
||||||
else if (m_ParamTypes[i] == FP_ARRAY)
|
else if (m_ParamTypes[i] == FP_ARRAY)
|
||||||
{
|
{
|
||||||
cell *tmp;
|
cell *tmp;
|
||||||
amx_Allot(m_Amx, preparedArrays[params[i]].size,
|
amx_Allot(m_Amx, preparedArrays[params[i]].size, &realParams[i], &tmp);
|
||||||
&realParams[i], &tmp);
|
|
||||||
physAddrs[i] = tmp;
|
physAddrs[i] = tmp;
|
||||||
|
|
||||||
if (preparedArrays[params[i]].type == Type_Cell)
|
if (preparedArrays[params[i]].type == Type_Cell)
|
||||||
{
|
{
|
||||||
memcpy(tmp, preparedArrays[params[i]].ptr, preparedArrays[params[i]].size * sizeof(cell));
|
memcpy(tmp, preparedArrays[params[i]].ptr, preparedArrays[params[i]].size * sizeof(cell));
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
char *data = (char*)preparedArrays[params[i]].ptr;
|
char *data = (char*)preparedArrays[params[i]].ptr;
|
||||||
|
|
||||||
for (unsigned int j = 0; j < preparedArrays[params[i]].size; ++j)
|
for (unsigned int j = 0; j < preparedArrays[params[i]].size; ++j)
|
||||||
*tmp++ = (static_cast<cell>(*data++)) & 0xFF;
|
*tmp++ = (static_cast<cell>(*data++)) & 0xFF;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
realParams[i] = params[i];
|
realParams[i] = params[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i=m_NumParams-1; i>=0; i--)
|
|
||||||
|
for (i = m_NumParams - 1; i >= 0; i--)
|
||||||
amx_Push(m_Amx, realParams[i]);
|
amx_Push(m_Amx, realParams[i]);
|
||||||
|
|
||||||
// exec
|
// exec
|
||||||
cell retVal;
|
cell retVal;
|
||||||
int err = amx_Exec(m_Amx, &retVal, m_Func);
|
int err = amx_Exec(m_Amx, &retVal, m_Func);
|
||||||
|
|
||||||
if (err != AMX_ERR_NONE)
|
if (err != AMX_ERR_NONE)
|
||||||
{
|
{
|
||||||
//Did something else set an error?
|
//Did something else set an error?
|
||||||
if (pDebugger && pDebugger->ErrorExists())
|
if (pDebugger && pDebugger->ErrorExists())
|
||||||
{
|
{
|
||||||
//we don't care, something else logged the error.
|
//we don't care, something else logged the error.
|
||||||
} else if (err != -1) {
|
}
|
||||||
|
else if (err != -1)
|
||||||
|
{
|
||||||
//nothing logged the error so spit it out anyway
|
//nothing logged the error so spit it out anyway
|
||||||
LogError(m_Amx, err, NULL);
|
LogError(m_Amx, err, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pDebugger)
|
if (pDebugger)
|
||||||
pDebugger->EndExec();
|
pDebugger->EndExec();
|
||||||
|
|
||||||
m_Amx->error = AMX_ERR_NONE;
|
m_Amx->error = AMX_ERR_NONE;
|
||||||
|
|
||||||
// cleanup strings & arrays
|
// cleanup strings & arrays
|
||||||
|
@ -310,10 +321,9 @@ cell CSPForward::execute(cell *params, ForwardPreparedArray *preparedArrays)
|
||||||
if (preparedArrays[params[i]].type == Type_Cell)
|
if (preparedArrays[params[i]].type == Type_Cell)
|
||||||
{
|
{
|
||||||
memcpy(preparedArrays[params[i]].ptr, tmp, preparedArrays[params[i]].size * sizeof(cell));
|
memcpy(preparedArrays[params[i]].ptr, tmp, preparedArrays[params[i]].size * sizeof(cell));
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
char *data = (char*)preparedArrays[params[i]].ptr;
|
char *data = (char*)preparedArrays[params[i]].ptr;
|
||||||
|
|
||||||
for (unsigned int j = 0; j < preparedArrays[params[i]].size; ++j)
|
for (unsigned int j = 0; j < preparedArrays[params[i]].size; ++j)
|
||||||
*data++ = static_cast<char>(*tmp++ & 0xFF);
|
*data++ = static_cast<char>(*tmp++ & 0xFF);
|
||||||
}
|
}
|
||||||
|
@ -329,9 +339,12 @@ int CForwardMngr::registerForward(const char *funcName, ForwardExecType et, int
|
||||||
{
|
{
|
||||||
int retVal = m_Forwards.size() << 1;
|
int retVal = m_Forwards.size() << 1;
|
||||||
CForward *tmp = new CForward(funcName, et, numParams, paramTypes);
|
CForward *tmp = new CForward(funcName, et, numParams, paramTypes);
|
||||||
|
|
||||||
if (!tmp)
|
if (!tmp)
|
||||||
return -1; // should be invalid
|
return -1; // should be invalid
|
||||||
|
|
||||||
m_Forwards.push_back(tmp);
|
m_Forwards.push_back(tmp);
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,22 +352,26 @@ int CForwardMngr::registerSPForward(int func, AMX *amx, int numParams, const For
|
||||||
{
|
{
|
||||||
int retVal = -1;
|
int retVal = -1;
|
||||||
CSPForward *pForward;
|
CSPForward *pForward;
|
||||||
|
|
||||||
if (!m_FreeSPForwards.empty())
|
if (!m_FreeSPForwards.empty())
|
||||||
{
|
{
|
||||||
retVal = m_FreeSPForwards.front();
|
retVal = m_FreeSPForwards.front();
|
||||||
pForward = m_SPForwards[retVal >> 1];
|
pForward = m_SPForwards[retVal >> 1];
|
||||||
pForward->Set(func, amx, numParams, paramTypes);
|
pForward->Set(func, amx, numParams, paramTypes);
|
||||||
|
|
||||||
if (pForward->getFuncsNum() == 0)
|
if (pForward->getFuncsNum() == 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
m_FreeSPForwards.pop();
|
m_FreeSPForwards.pop();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
retVal = (m_SPForwards.size() << 1) | 1;
|
retVal = (m_SPForwards.size() << 1) | 1;
|
||||||
pForward = new CSPForward();
|
pForward = new CSPForward();
|
||||||
|
|
||||||
if (!pForward)
|
if (!pForward)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
pForward->Set(func, amx, numParams, paramTypes);
|
pForward->Set(func, amx, numParams, paramTypes);
|
||||||
|
|
||||||
if (pForward->getFuncsNum() == 0)
|
if (pForward->getFuncsNum() == 0)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -363,6 +380,7 @@ int CForwardMngr::registerSPForward(int func, AMX *amx, int numParams, const For
|
||||||
|
|
||||||
m_SPForwards.push_back(pForward);
|
m_SPForwards.push_back(pForward);
|
||||||
}
|
}
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -370,56 +388,58 @@ int CForwardMngr::registerSPForward(const char *funcName, AMX *amx, int numParam
|
||||||
{
|
{
|
||||||
int retVal = (m_SPForwards.size() << 1) | 1;
|
int retVal = (m_SPForwards.size() << 1) | 1;
|
||||||
CSPForward *pForward;
|
CSPForward *pForward;
|
||||||
|
|
||||||
if (!m_FreeSPForwards.empty())
|
if (!m_FreeSPForwards.empty())
|
||||||
{
|
{
|
||||||
retVal = m_FreeSPForwards.front();
|
retVal = m_FreeSPForwards.front();
|
||||||
pForward = m_SPForwards[retVal>>1]; // >>1 because unregisterSPForward pushes the id which contains the sp flag
|
pForward = m_SPForwards[retVal>>1]; // >>1 because unregisterSPForward pushes the id which contains the sp flag
|
||||||
pForward->Set(funcName, amx, numParams, paramTypes);
|
pForward->Set(funcName, amx, numParams, paramTypes);
|
||||||
|
|
||||||
if (pForward->getFuncsNum() == 0)
|
if (pForward->getFuncsNum() == 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
m_FreeSPForwards.pop();
|
m_FreeSPForwards.pop();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
pForward = new CSPForward();
|
pForward = new CSPForward();
|
||||||
|
|
||||||
if (!pForward)
|
if (!pForward)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
pForward->Set(funcName, amx, numParams, paramTypes);
|
pForward->Set(funcName, amx, numParams, paramTypes);
|
||||||
|
|
||||||
if (pForward->getFuncsNum() == 0)
|
if (pForward->getFuncsNum() == 0)
|
||||||
{
|
{
|
||||||
delete pForward;
|
delete pForward;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_SPForwards.push_back(pForward);
|
m_SPForwards.push_back(pForward);
|
||||||
}
|
}
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CForwardMngr::isIdValid(int id) const
|
bool CForwardMngr::isIdValid(int id) const
|
||||||
{
|
{
|
||||||
return (id >= 0) && ((id & 1) ?
|
return (id >= 0) && ((id & 1) ? (static_cast<size_t>(id >> 1) < m_SPForwards.size()) : (static_cast<size_t>(id >> 1) < m_Forwards.size()));
|
||||||
(static_cast<size_t>(id >> 1) < m_SPForwards.size()) :
|
|
||||||
(static_cast<size_t>(id >> 1) < m_Forwards.size()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cell CForwardMngr::executeForwards(int id, cell *params)
|
cell CForwardMngr::executeForwards(int id, cell *params)
|
||||||
{
|
{
|
||||||
int retVal = (id & 1) ? m_SPForwards[id >> 1]->execute(params, m_TmpArrays) :
|
int retVal = (id & 1) ? m_SPForwards[id >> 1]->execute(params, m_TmpArrays) : m_Forwards[id >> 1]->execute(params, m_TmpArrays);
|
||||||
m_Forwards[id >> 1]->execute(params, m_TmpArrays);
|
|
||||||
m_TmpArraysNum = 0;
|
m_TmpArraysNum = 0;
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CForwardMngr::getParamsNum(int id) const
|
int CForwardMngr::getParamsNum(int id) const
|
||||||
{
|
{
|
||||||
return (id & 1) ? m_SPForwards[id >> 1]->getParamsNum() :
|
return (id & 1) ? m_SPForwards[id >> 1]->getParamsNum() : m_Forwards[id >> 1]->getParamsNum();
|
||||||
m_Forwards[id >> 1]->getParamsNum();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ForwardParam CForwardMngr::getParamType(int id, int paramNum) const
|
ForwardParam CForwardMngr::getParamType(int id, int paramNum) const
|
||||||
{
|
{
|
||||||
return (id & 1) ? m_SPForwards[id >> 1]->getParamType(paramNum) :
|
return (id & 1) ? m_SPForwards[id >> 1]->getParamType(paramNum) : m_Forwards[id >> 1]->getParamType(paramNum);
|
||||||
m_Forwards[id >> 1]->getParamType(paramNum);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CForwardMngr::clear()
|
void CForwardMngr::clear()
|
||||||
|
@ -428,7 +448,9 @@ void CForwardMngr::clear()
|
||||||
{
|
{
|
||||||
delete *iter;
|
delete *iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
SPForwardVec::iterator spIter;
|
SPForwardVec::iterator spIter;
|
||||||
|
|
||||||
for (spIter = m_SPForwards.begin(); spIter != m_SPForwards.end(); ++spIter)
|
for (spIter = m_SPForwards.begin(); spIter != m_SPForwards.end(); ++spIter)
|
||||||
{
|
{
|
||||||
delete (*spIter);
|
delete (*spIter);
|
||||||
|
@ -436,8 +458,10 @@ void CForwardMngr::clear()
|
||||||
|
|
||||||
m_Forwards.clear();
|
m_Forwards.clear();
|
||||||
m_SPForwards.clear();
|
m_SPForwards.clear();
|
||||||
|
|
||||||
while (!m_FreeSPForwards.empty())
|
while (!m_FreeSPForwards.empty())
|
||||||
m_FreeSPForwards.pop();
|
m_FreeSPForwards.pop();
|
||||||
|
|
||||||
m_TmpArraysNum = 0;
|
m_TmpArraysNum = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -449,74 +473,97 @@ bool CForwardMngr::isSPForward(int id) const
|
||||||
void CForwardMngr::unregisterSPForward(int id)
|
void CForwardMngr::unregisterSPForward(int id)
|
||||||
{
|
{
|
||||||
//make sure the id is valid
|
//make sure the id is valid
|
||||||
if ( !isIdValid(id) || m_SPForwards.at(id >> 1)->isFree )
|
if (!isIdValid(id) || m_SPForwards.at(id >> 1)->isFree)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_SPForwards.at(id >> 1)->isFree = true;
|
m_SPForwards.at(id >> 1)->isFree = true;
|
||||||
|
|
||||||
m_FreeSPForwards.push(id);
|
m_FreeSPForwards.push(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
int registerForward(const char *funcName, ForwardExecType et, ...)
|
int registerForward(const char *funcName, ForwardExecType et, ...)
|
||||||
{
|
{
|
||||||
int curParam = 0;
|
int curParam = 0;
|
||||||
|
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
va_start(argptr, et);
|
va_start(argptr, et);
|
||||||
|
|
||||||
ForwardParam params[FORWARD_MAX_PARAMS];
|
ForwardParam params[FORWARD_MAX_PARAMS];
|
||||||
ForwardParam tmp;
|
ForwardParam tmp;
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if (curParam == FORWARD_MAX_PARAMS)
|
if (curParam == FORWARD_MAX_PARAMS)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
tmp = (ForwardParam)va_arg(argptr, int);
|
tmp = (ForwardParam)va_arg(argptr, int);
|
||||||
|
|
||||||
if (tmp == FP_DONE)
|
if (tmp == FP_DONE)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
params[curParam] = tmp;
|
params[curParam] = tmp;
|
||||||
++curParam;
|
++curParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
va_end(argptr);
|
va_end(argptr);
|
||||||
|
|
||||||
return g_forwards.registerForward(funcName, et, curParam, params);
|
return g_forwards.registerForward(funcName, et, curParam, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
int registerSPForwardByName(AMX *amx, const char *funcName, ...)
|
int registerSPForwardByName(AMX *amx, const char *funcName, ...)
|
||||||
{
|
{
|
||||||
int curParam = 0;
|
int curParam = 0;
|
||||||
|
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
va_start(argptr, funcName);
|
va_start(argptr, funcName);
|
||||||
|
|
||||||
ForwardParam params[FORWARD_MAX_PARAMS];
|
ForwardParam params[FORWARD_MAX_PARAMS];
|
||||||
ForwardParam tmp;
|
ForwardParam tmp;
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if (curParam == FORWARD_MAX_PARAMS)
|
if (curParam == FORWARD_MAX_PARAMS)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
tmp = (ForwardParam)va_arg(argptr, int);
|
tmp = (ForwardParam)va_arg(argptr, int);
|
||||||
|
|
||||||
if (tmp == FP_DONE)
|
if (tmp == FP_DONE)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
params[curParam] = tmp;
|
params[curParam] = tmp;
|
||||||
++curParam;
|
++curParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
va_end(argptr);
|
va_end(argptr);
|
||||||
|
|
||||||
return g_forwards.registerSPForward(funcName, amx, curParam, params);
|
return g_forwards.registerSPForward(funcName, amx, curParam, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
int registerSPForward(AMX *amx, int func, ...)
|
int registerSPForward(AMX *amx, int func, ...)
|
||||||
{
|
{
|
||||||
int curParam = 0;
|
int curParam = 0;
|
||||||
|
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
va_start(argptr, func);
|
va_start(argptr, func);
|
||||||
|
|
||||||
ForwardParam params[FORWARD_MAX_PARAMS];
|
ForwardParam params[FORWARD_MAX_PARAMS];
|
||||||
ForwardParam tmp;
|
ForwardParam tmp;
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if (curParam == FORWARD_MAX_PARAMS)
|
if (curParam == FORWARD_MAX_PARAMS)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
tmp = (ForwardParam)va_arg(argptr, int);
|
tmp = (ForwardParam)va_arg(argptr, int);
|
||||||
|
|
||||||
if (tmp == FP_DONE)
|
if (tmp == FP_DONE)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
params[curParam] = tmp;
|
params[curParam] = tmp;
|
||||||
++curParam;
|
++curParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
va_end(argptr);
|
va_end(argptr);
|
||||||
|
|
||||||
return g_forwards.registerSPForward(func, amx, curParam, params);
|
return g_forwards.registerSPForward(func, amx, curParam, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -526,9 +573,12 @@ cell executeForwards(int id, ...)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
cell params[FORWARD_MAX_PARAMS];
|
cell params[FORWARD_MAX_PARAMS];
|
||||||
|
|
||||||
int paramsNum = g_forwards.getParamsNum(id);
|
int paramsNum = g_forwards.getParamsNum(id);
|
||||||
|
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
va_start(argptr, id);
|
va_start(argptr, id);
|
||||||
|
|
||||||
for (int i = 0; i < paramsNum && i < FORWARD_MAX_PARAMS; ++i)
|
for (int i = 0; i < paramsNum && i < FORWARD_MAX_PARAMS; ++i)
|
||||||
{
|
{
|
||||||
if (g_forwards.getParamType(id, i) == FP_FLOAT)
|
if (g_forwards.getParamType(id, i) == FP_FLOAT)
|
||||||
|
@ -539,7 +589,9 @@ cell executeForwards(int id, ...)
|
||||||
else
|
else
|
||||||
params[i] = (cell)va_arg(argptr, cell);
|
params[i] = (cell)va_arg(argptr, cell);
|
||||||
}
|
}
|
||||||
|
|
||||||
va_end(argptr);
|
va_end(argptr);
|
||||||
|
|
||||||
return g_forwards.executeForwards(id, params);
|
return g_forwards.executeForwards(id, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -547,13 +599,16 @@ cell CForwardMngr::prepareArray(void *ptr, unsigned int size, ForwardArrayElemTy
|
||||||
{
|
{
|
||||||
if (m_TmpArraysNum >= FORWARD_MAX_PARAMS)
|
if (m_TmpArraysNum >= FORWARD_MAX_PARAMS)
|
||||||
{
|
{
|
||||||
#ifdef MEMORY_TEST
|
#ifdef MEMORY_TEST
|
||||||
m_validateAllAllocUnits();
|
m_validateAllAllocUnits();
|
||||||
#endif // MEMORY_TEST
|
#endif // MEMORY_TEST
|
||||||
|
|
||||||
AMXXLOG_Log("[AMXX] Forwards with more than 32 parameters are not supported (tried to prepare array # %d).", m_TmpArraysNum + 1);
|
AMXXLOG_Log("[AMXX] Forwards with more than 32 parameters are not supported (tried to prepare array # %d).", m_TmpArraysNum + 1);
|
||||||
m_TmpArraysNum = 0;
|
m_TmpArraysNum = 0;
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_TmpArrays[m_TmpArraysNum].ptr = ptr;
|
m_TmpArrays[m_TmpArraysNum].ptr = ptr;
|
||||||
m_TmpArrays[m_TmpArraysNum].size = size;
|
m_TmpArrays[m_TmpArraysNum].size = size;
|
||||||
m_TmpArrays[m_TmpArraysNum].type = type;
|
m_TmpArrays[m_TmpArraysNum].type = type;
|
||||||
|
|
|
@ -77,7 +77,9 @@ enum ForwardArrayElemType
|
||||||
struct ForwardPreparedArray
|
struct ForwardPreparedArray
|
||||||
{
|
{
|
||||||
void *ptr;
|
void *ptr;
|
||||||
|
|
||||||
ForwardArrayElemType type;
|
ForwardArrayElemType type;
|
||||||
|
|
||||||
unsigned int size;
|
unsigned int size;
|
||||||
bool copyBack;
|
bool copyBack;
|
||||||
};
|
};
|
||||||
|
@ -96,13 +98,14 @@ class CForward
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef CVector<AMXForward> AMXForwardList;
|
typedef CVector<AMXForward> AMXForwardList;
|
||||||
|
|
||||||
AMXForwardList m_Funcs;
|
AMXForwardList m_Funcs;
|
||||||
ForwardParam m_ParamTypes[FORWARD_MAX_PARAMS];
|
ForwardParam m_ParamTypes[FORWARD_MAX_PARAMS];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CForward(const char *name, ForwardExecType et, int numParams, const ForwardParam * paramTypes);
|
CForward(const char *name, ForwardExecType et, int numParams, const ForwardParam * paramTypes);
|
||||||
CForward()
|
CForward() {} // leaves everything unitialized'
|
||||||
{ } // leaves everything unitialized'
|
|
||||||
cell execute(cell *params, ForwardPreparedArray *preparedArrays);
|
cell execute(cell *params, ForwardPreparedArray *preparedArrays);
|
||||||
|
|
||||||
int getParamsNum() const
|
int getParamsNum() const
|
||||||
|
@ -129,8 +132,10 @@ class CSPForward
|
||||||
{
|
{
|
||||||
const char *m_FuncName;
|
const char *m_FuncName;
|
||||||
int m_NumParams;
|
int m_NumParams;
|
||||||
|
|
||||||
ForwardParam m_ParamTypes[FORWARD_MAX_PARAMS];
|
ForwardParam m_ParamTypes[FORWARD_MAX_PARAMS];
|
||||||
AMX *m_Amx;
|
AMX *m_Amx;
|
||||||
|
|
||||||
int m_Func;
|
int m_Func;
|
||||||
bool m_HasFunc;
|
bool m_HasFunc;
|
||||||
|
|
||||||
|
@ -179,8 +184,7 @@ public:
|
||||||
|
|
||||||
CForwardMngr()
|
CForwardMngr()
|
||||||
{ m_TmpArraysNum = 0; }
|
{ m_TmpArraysNum = 0; }
|
||||||
~CForwardMngr()
|
~CForwardMngr() {}
|
||||||
{ }
|
|
||||||
|
|
||||||
// Interface
|
// Interface
|
||||||
// Register normal forward
|
// Register normal forward
|
||||||
|
@ -188,15 +192,19 @@ public:
|
||||||
// Register single plugin forward
|
// Register single plugin forward
|
||||||
int registerSPForward(const char *funcName, AMX *amx, int numParams, const ForwardParam * paramTypes);
|
int registerSPForward(const char *funcName, AMX *amx, int numParams, const ForwardParam * paramTypes);
|
||||||
int registerSPForward(int func, AMX *amx, int numParams, const ForwardParam * paramTypes);
|
int registerSPForward(int func, AMX *amx, int numParams, const ForwardParam * paramTypes);
|
||||||
|
|
||||||
// Unregister single plugin forward
|
// Unregister single plugin forward
|
||||||
void unregisterSPForward(int id);
|
void unregisterSPForward(int id);
|
||||||
|
|
||||||
// execute forward
|
// execute forward
|
||||||
cell executeForwards(int id, cell *params);
|
cell executeForwards(int id, cell *params);
|
||||||
void clear(); // delete all forwards
|
void clear(); // delete all forwards
|
||||||
|
|
||||||
bool isIdValid(int id) const; // check whether forward id is valid
|
bool isIdValid(int id) const; // check whether forward id is valid
|
||||||
bool isSPForward(int id) const; // check whether forward is single plugin
|
bool isSPForward(int id) const; // check whether forward is single plugin
|
||||||
int getParamsNum(int id) const; // get num of params of a forward
|
int getParamsNum(int id) const; // get num of params of a forward
|
||||||
int getFuncsNum(int id) const; // get num of found functions of a forward
|
int getFuncsNum(int id) const; // get num of found functions of a forward
|
||||||
|
|
||||||
ForwardParam getParamType(int id, int paramId) const;
|
ForwardParam getParamType(int id, int paramId) const;
|
||||||
cell prepareArray(void *ptr, unsigned int size, ForwardArrayElemType type, bool copyBack); // prepare array
|
cell prepareArray(void *ptr, unsigned int size, ForwardArrayElemType type, bool copyBack); // prepare array
|
||||||
};
|
};
|
||||||
|
@ -214,4 +222,3 @@ cell prepareCellArray(cell *ptr, unsigned int size, bool copyBack = false);
|
||||||
cell prepareCharArray(char *ptr, unsigned int size, bool copyBack = false);
|
cell prepareCharArray(char *ptr, unsigned int size, bool copyBack = false);
|
||||||
|
|
||||||
#endif //FORWARD_H
|
#endif //FORWARD_H
|
||||||
|
|
||||||
|
|
|
@ -280,7 +280,7 @@ CLangMngr::CLang::CLang(const char *lang)
|
||||||
{
|
{
|
||||||
m_LookUpTable.clear();
|
m_LookUpTable.clear();
|
||||||
strncpy(m_LanguageName, lang, 2);
|
strncpy(m_LanguageName, lang, 2);
|
||||||
m_LanguageName[2]=0;
|
m_LanguageName[2] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CLangMngr::CLang::LangEntry *CLangMngr::CLang::AddEntry(int pKey, uint32_t defHash, const char *def, bool cache)
|
CLangMngr::CLang::LangEntry *CLangMngr::CLang::AddEntry(int pKey, uint32_t defHash, const char *def, bool cache)
|
||||||
|
@ -588,14 +588,14 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
|
||||||
{
|
{
|
||||||
def = GetDef(g_vault.get("server_language"), key);
|
def = GetDef(g_vault.get("server_language"), key);
|
||||||
}
|
}
|
||||||
if (strcmp(cpLangName, "en")!=0 && strcmp(g_vault.get("server_language"), "en")!=0)
|
if (strcmp(cpLangName, "en") != 0 && strcmp(g_vault.get("server_language"), "en") != 0)
|
||||||
{
|
{
|
||||||
def = GetDef("en", key);
|
def = GetDef("en", key);
|
||||||
}
|
}
|
||||||
if (!def)
|
if (!def)
|
||||||
{
|
{
|
||||||
static char buf[512];
|
static char buf[512];
|
||||||
CHECK_PTR((char*)(buf+17+strlen(key)), buf, sizeof(buf));
|
CHECK_PTR((char*)(buf + 17 + strlen(key)), buf, sizeof(buf));
|
||||||
sprintf(buf, "ML_LNOTFOUND: %s", key);
|
sprintf(buf, "ML_LNOTFOUND: %s", key);
|
||||||
def = buf;
|
def = buf;
|
||||||
}
|
}
|
||||||
|
@ -613,7 +613,7 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
|
||||||
} else {
|
} else {
|
||||||
static char format[32];
|
static char format[32];
|
||||||
format[0] = '%';
|
format[0] = '%';
|
||||||
char *ptr = format+1;
|
char *ptr = format + 1;
|
||||||
|
|
||||||
while (ptr-format<sizeof(format) && !isalpha(*ptr++ = *def++))
|
while (ptr-format<sizeof(format) && !isalpha(*ptr++ = *def++))
|
||||||
/*nothing*/;
|
/*nothing*/;
|
||||||
|
@ -655,7 +655,7 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
CHECK_OUTPTR(strlen(format)+1);
|
CHECK_OUTPTR(strlen(format) + 1);
|
||||||
strcpy(outptr, format);
|
strcpy(outptr, format);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -700,7 +700,7 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
|
||||||
char *tmpPtr = tmpString;
|
char *tmpPtr = tmpString;
|
||||||
int tmpLen = 0;
|
int tmpLen = 0;
|
||||||
static char format[32] = {'%'};
|
static char format[32] = {'%'};
|
||||||
char *ptr = format+1;
|
char *ptr = format + 1;
|
||||||
|
|
||||||
if (*src != '%')
|
if (*src != '%')
|
||||||
{
|
{
|
||||||
|
@ -740,7 +740,7 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
CHECK_OUTPTR(strlen(format)+1);
|
CHECK_OUTPTR(strlen(format) + 1);
|
||||||
strcpy(outptr, format);
|
strcpy(outptr, format);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -847,14 +847,14 @@ char *CLangMngr::FormatString(const char *fmt, va_list &ap)
|
||||||
{
|
{
|
||||||
def = GetDef(g_vault.get("server_language"), key);
|
def = GetDef(g_vault.get("server_language"), key);
|
||||||
}
|
}
|
||||||
if (strcmp(cpLangName, "en")!=0 && strcmp(g_vault.get("server_language"), "en")!=0)
|
if (strcmp(cpLangName, "en") != 0 && strcmp(g_vault.get("server_language"), "en") != 0)
|
||||||
{
|
{
|
||||||
def = GetDef("en", key);
|
def = GetDef("en", key);
|
||||||
}
|
}
|
||||||
if (!def)
|
if (!def)
|
||||||
{
|
{
|
||||||
static char buf[512];
|
static char buf[512];
|
||||||
CHECK_PTR((char*)(buf+17+strlen(key)), buf, sizeof(buf));
|
CHECK_PTR((char*)(buf + 17 + strlen(key)), buf, sizeof(buf));
|
||||||
sprintf(buf, "ML_LNOTFOUND: %s", key);
|
sprintf(buf, "ML_LNOTFOUND: %s", key);
|
||||||
def = buf;
|
def = buf;
|
||||||
}
|
}
|
||||||
|
@ -867,7 +867,7 @@ char *CLangMngr::FormatString(const char *fmt, va_list &ap)
|
||||||
++def;
|
++def;
|
||||||
static char format[32];
|
static char format[32];
|
||||||
format[0] = '%';
|
format[0] = '%';
|
||||||
char *ptr = format+1;
|
char *ptr = format + 1;
|
||||||
while (ptr-format<sizeof(format) && !isalpha(*ptr++ = *def++))
|
while (ptr-format<sizeof(format) && !isalpha(*ptr++ = *def++))
|
||||||
/*nothing*/;
|
/*nothing*/;
|
||||||
ZEROTERM(format);
|
ZEROTERM(format);
|
||||||
|
@ -927,7 +927,7 @@ char *CLangMngr::FormatString(const char *fmt, va_list &ap)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
static char format[32] = {'%'};
|
static char format[32] = {'%'};
|
||||||
char *ptr = format+1;
|
char *ptr = format + 1;
|
||||||
|
|
||||||
if (*src != '%')
|
if (*src != '%')
|
||||||
{
|
{
|
||||||
|
@ -973,6 +973,7 @@ char *CLangMngr::FormatString(const char *fmt, va_list &ap)
|
||||||
|
|
||||||
return outbuf;
|
return outbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLangMngr::MergeDefinitions(const char *lang, CQueue<sKeyDef*> &tmpVec)
|
void CLangMngr::MergeDefinitions(const char *lang, CQueue<sKeyDef*> &tmpVec)
|
||||||
{
|
{
|
||||||
CLang * language = GetLang(lang);
|
CLang * language = GetLang(lang);
|
||||||
|
@ -1086,7 +1087,7 @@ int CLangMngr::MergeDefinitionFile(const char *file)
|
||||||
String key;
|
String key;
|
||||||
key.assign(buf.substr(0, pos).c_str());
|
key.assign(buf.substr(0, pos).c_str());
|
||||||
String def;
|
String def;
|
||||||
def.assign(buf.substr(pos+1).c_str());
|
def.assign(buf.substr(pos + 1).c_str());
|
||||||
key.trim();
|
key.trim();
|
||||||
key.toLower();
|
key.toLower();
|
||||||
int iKey = GetKeyEntry(key);
|
int iKey = GetKeyEntry(key);
|
||||||
|
@ -1374,7 +1375,7 @@ bool CLangMngr::Load(const char *filename)
|
||||||
save = ftell(fp);
|
save = ftell(fp);
|
||||||
fseek(fp, keyoffset, SEEK_SET);
|
fseek(fp, keyoffset, SEEK_SET);
|
||||||
fread((void*)&keylen, sizeof(char), 1, fp);
|
fread((void*)&keylen, sizeof(char), 1, fp);
|
||||||
char *data = new char[keylen+1];
|
char *data = new char[keylen + 1];
|
||||||
fread(data, sizeof(char), keylen, fp);
|
fread(data, sizeof(char), keylen, fp);
|
||||||
data[keylen] = 0;
|
data[keylen] = 0;
|
||||||
e->key.assign(data);
|
e->key.assign(data);
|
||||||
|
@ -1402,7 +1403,7 @@ bool CLangMngr::Load(const char *filename)
|
||||||
save = ftell(fp);
|
save = ftell(fp);
|
||||||
fseek(fp, defoffset, SEEK_SET);
|
fseek(fp, defoffset, SEEK_SET);
|
||||||
fread((void *)&deflen, sizeof(unsigned short), 1, fp);
|
fread((void *)&deflen, sizeof(unsigned short), 1, fp);
|
||||||
char *data = new char[deflen+1];
|
char *data = new char[deflen + 1];
|
||||||
fread(data, sizeof(char), deflen, fp);
|
fread(data, sizeof(char), deflen, fp);
|
||||||
data[deflen] = 0;
|
data[deflen] = 0;
|
||||||
m_Languages[i]->AddEntry(keynum, defhash, data, true);
|
m_Languages[i]->AddEntry(keynum, defhash, data, true);
|
||||||
|
|
|
@ -51,6 +51,7 @@ struct sKeyDef
|
||||||
{
|
{
|
||||||
sKeyDef() { key = -1; def = 0; }
|
sKeyDef() { key = -1; def = 0; }
|
||||||
~sKeyDef() { if (def) delete def; }
|
~sKeyDef() { if (def) delete def; }
|
||||||
|
|
||||||
int key;
|
int key;
|
||||||
String *def;
|
String *def;
|
||||||
};
|
};
|
||||||
|
@ -77,7 +78,7 @@ class CLangMngr
|
||||||
// compare this language to a language name
|
// compare this language to a language name
|
||||||
friend bool operator == (const CLang &left, const char *right)
|
friend bool operator == (const CLang &left, const char *right)
|
||||||
{
|
{
|
||||||
return strcmp(left.m_LanguageName, right)==0 ? true : false;
|
return strcmp(left.m_LanguageName, right) == 0 ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get language name
|
// Get language name
|
||||||
|
|
|
@ -66,8 +66,10 @@ private:
|
||||||
~CElement()
|
~CElement()
|
||||||
{
|
{
|
||||||
delete m_pObject;
|
delete m_pObject;
|
||||||
|
|
||||||
if (m_pNext)
|
if (m_pNext)
|
||||||
m_pNext->m_pPrev = m_pPrev;
|
m_pNext->m_pPrev = m_pPrev;
|
||||||
|
|
||||||
if (m_pPrev)
|
if (m_pPrev)
|
||||||
m_pPrev->m_pNext = m_pNext;
|
m_pPrev->m_pNext = m_pNext;
|
||||||
}
|
}
|
||||||
|
@ -103,15 +105,16 @@ private:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// CList<T,F> class
|
// CList<T, F> class
|
||||||
CElement *m_pHead; // head of the linked list
|
CElement *m_pHead; // head of the linked list
|
||||||
CElement *m_pTail; // tail of the linked list
|
CElement *m_pTail; // tail of the linked list
|
||||||
public:
|
public:
|
||||||
// iterator class
|
// iterator class
|
||||||
class iterator
|
class iterator
|
||||||
{
|
{
|
||||||
friend class CList<T,F>;
|
friend class CList<T, F>;
|
||||||
CList<T,F> *m_pList; // The list that created this iterator
|
|
||||||
|
CList<T, F> *m_pList; // The list that created this iterator
|
||||||
CElement *m_CurPos; // Current position in the list
|
CElement *m_CurPos; // Current position in the list
|
||||||
public:
|
public:
|
||||||
iterator()
|
iterator()
|
||||||
|
@ -121,7 +124,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// constructor based on list, element
|
// constructor based on list, element
|
||||||
iterator(CList<T,F> *pList, CElement *startPos)
|
iterator(CList<T, F> *pList, CElement *startPos)
|
||||||
{
|
{
|
||||||
m_pList = pList;
|
m_pList = pList;
|
||||||
m_CurPos = startPos;
|
m_CurPos = startPos;
|
||||||
|
@ -148,7 +151,7 @@ public:
|
||||||
// validity check operator
|
// validity check operator
|
||||||
inline operator bool () const
|
inline operator bool () const
|
||||||
{
|
{
|
||||||
return m_pList!=NULL && m_CurPos!=NULL && m_CurPos->GetObj()!=NULL;
|
return m_pList != NULL && m_CurPos != NULL && m_CurPos->GetObj() != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// pre increment operator
|
// pre increment operator
|
||||||
|
@ -185,13 +188,13 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
CList<T,F>()
|
CList<T, F>()
|
||||||
{
|
{
|
||||||
m_pHead = NULL;
|
m_pHead = NULL;
|
||||||
m_pTail = NULL;
|
m_pTail = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
~CList<T,F>()
|
~CList<T, F>()
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
@ -205,6 +208,7 @@ public:
|
||||||
|
|
||||||
if (where.m_CurPos == m_pHead)
|
if (where.m_CurPos == m_pHead)
|
||||||
m_pHead = where.m_CurPos->GetNext();
|
m_pHead = where.m_CurPos->GetNext();
|
||||||
|
|
||||||
if (where.m_CurPos == m_pTail)
|
if (where.m_CurPos == m_pTail)
|
||||||
m_pTail = where.m_CurPos->GetPrev();
|
m_pTail = where.m_CurPos->GetPrev();
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,9 @@ int LogEventsMngr::CLogCmp::compareCondition(const char* string)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
logid = parent->logCounter;
|
logid = parent->logCounter;
|
||||||
if (in) return result = strstr(string, text.c_str()) ? 0 : 1;
|
|
||||||
|
if (in)
|
||||||
|
return result = strstr(string, text.c_str()) ? 0 : 1;
|
||||||
|
|
||||||
return result = strcmp(string,text.c_str());
|
return result = strcmp(string,text.c_str());
|
||||||
}
|
}
|
||||||
|
@ -69,9 +71,12 @@ LogEventsMngr::CLogCmp* LogEventsMngr::registerCondition(char* filter)
|
||||||
++filter;
|
++filter;
|
||||||
|
|
||||||
bool in = (*filter=='&');
|
bool in = (*filter=='&');
|
||||||
*filter++ = 0;
|
*filter++ = 0;
|
||||||
int pos = atoi(temp);
|
int pos = atoi(temp);
|
||||||
if (pos < 0 || pos >= MAX_LOGARGS) pos = 0;
|
|
||||||
|
if (pos < 0 || pos >= MAX_LOGARGS)
|
||||||
|
pos = 0;
|
||||||
|
|
||||||
CLogCmp* c = logcmplist;
|
CLogCmp* c = logcmplist;
|
||||||
|
|
||||||
while (c)
|
while (c)
|
||||||
|
@ -99,7 +104,10 @@ void LogEventsMngr::CLogEvent::registerFilter(char* filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
LogCondEle* aa = new LogCondEle(cmp, 0);
|
LogCondEle* aa = new LogCondEle(cmp, 0);
|
||||||
if (aa == 0) return;
|
|
||||||
|
if (aa == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
filters = new LogCond(cmp->pos, aa, filters);
|
filters = new LogCond(cmp->pos, aa, filters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +122,9 @@ void LogEventsMngr::setLogString(char* frmt, va_list& vaptr)
|
||||||
logString[len] = 0;
|
logString[len] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len) logString[--len] = 0;
|
if (len)
|
||||||
|
logString[--len] = 0;
|
||||||
|
|
||||||
logArgc = 0;
|
logArgc = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +142,10 @@ void LogEventsMngr::setLogString(char* frmt, ...)
|
||||||
}
|
}
|
||||||
|
|
||||||
va_end(logArgPtr);
|
va_end(logArgPtr);
|
||||||
if (len) logString[--len] = 0;
|
|
||||||
|
if (len)
|
||||||
|
logString[--len] = 0;
|
||||||
|
|
||||||
logArgc = 0;
|
logArgc = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,14 +193,16 @@ LogEventsMngr::CLogEvent* LogEventsMngr::registerLogEvent(CPluginMngr::CPlugin*
|
||||||
|
|
||||||
arelogevents = true;
|
arelogevents = true;
|
||||||
CLogEvent** d = &logevents[pos];
|
CLogEvent** d = &logevents[pos];
|
||||||
while (*d) d = &(*d)->next;
|
|
||||||
|
while (*d)
|
||||||
|
d = &(*d)->next;
|
||||||
|
|
||||||
return *d = new CLogEvent(plugin, func, this);
|
return *d = new CLogEvent(plugin, func, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogEventsMngr::executeLogEvents()
|
void LogEventsMngr::executeLogEvents()
|
||||||
{
|
{
|
||||||
bool valid;
|
bool valid;
|
||||||
|
|
||||||
for (CLogEvent* a = logevents[logArgc]; a; a = a->next)
|
for (CLogEvent* a = logevents[logArgc]; a; a = a->next)
|
||||||
{
|
{
|
||||||
|
@ -214,7 +229,7 @@ void LogEventsMngr::executeLogEvents()
|
||||||
{
|
{
|
||||||
executeForwards(a->func);
|
executeForwards(a->func);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogEventsMngr::clearLogEvents()
|
void LogEventsMngr::clearLogEvents()
|
||||||
|
|
|
@ -61,12 +61,15 @@ public:
|
||||||
{
|
{
|
||||||
friend class LogEventsMngr;
|
friend class LogEventsMngr;
|
||||||
friend class CLogEvent;
|
friend class CLogEvent;
|
||||||
|
|
||||||
LogEventsMngr* parent;
|
LogEventsMngr* parent;
|
||||||
String text;
|
String text;
|
||||||
|
|
||||||
int logid;
|
int logid;
|
||||||
int pos;
|
int pos;
|
||||||
int result;
|
int result;
|
||||||
bool in;
|
bool in;
|
||||||
|
|
||||||
CLogCmp *next;
|
CLogCmp *next;
|
||||||
|
|
||||||
CLogCmp(const char* s, bool r, int p, CLogCmp *n, LogEventsMngr* mg) : text(s)
|
CLogCmp(const char* s, bool r, int p, CLogCmp *n, LogEventsMngr* mg) : text(s)
|
||||||
|
@ -95,12 +98,13 @@ public:
|
||||||
{
|
{
|
||||||
CLogCmp *cmp;
|
CLogCmp *cmp;
|
||||||
LogCondEle *next;
|
LogCondEle *next;
|
||||||
LogCondEle(CLogCmp *c, LogCondEle *n): cmp(c), next(n) { }
|
LogCondEle(CLogCmp *c, LogCondEle *n): cmp(c), next(n) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LogCond
|
struct LogCond
|
||||||
{
|
{
|
||||||
int argnum;
|
int argnum;
|
||||||
|
|
||||||
LogCondEle *list;
|
LogCondEle *list;
|
||||||
LogCond *next;
|
LogCond *next;
|
||||||
LogCond(int a, LogCondEle* ee, LogCond* n) : argnum(a), list(ee), next(n) {}
|
LogCond(int a, LogCondEle* ee, LogCond* n) : argnum(a), list(ee), next(n) {}
|
||||||
|
@ -108,11 +112,14 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
CPluginMngr::CPlugin *plugin;
|
CPluginMngr::CPlugin *plugin;
|
||||||
|
|
||||||
int func;
|
int func;
|
||||||
|
|
||||||
LogCond *filters;
|
LogCond *filters;
|
||||||
LogEventsMngr* parent;
|
LogEventsMngr* parent;
|
||||||
|
|
||||||
CLogEvent *next;
|
CLogEvent *next;
|
||||||
CLogEvent(CPluginMngr::CPlugin *p, int f, LogEventsMngr* ppp) : plugin(p), func(f), filters(0), parent(ppp), next(0) { }
|
CLogEvent(CPluginMngr::CPlugin *p, int f, LogEventsMngr* ppp) : plugin(p), func(f), filters(0), parent(ppp), next(0) {}
|
||||||
~CLogEvent();
|
~CLogEvent();
|
||||||
public:
|
public:
|
||||||
inline CPluginMngr::CPlugin *getPlugin() { return plugin; }
|
inline CPluginMngr::CPlugin *getPlugin() { return plugin; }
|
||||||
|
@ -124,6 +131,7 @@ private:
|
||||||
CLogEvent *logevents[MAX_LOGARGS + 1];
|
CLogEvent *logevents[MAX_LOGARGS + 1];
|
||||||
CLogEvent *getValidLogEvent(CLogEvent * a);
|
CLogEvent *getValidLogEvent(CLogEvent * a);
|
||||||
CLogCmp* registerCondition(char* filter);
|
CLogCmp* registerCondition(char* filter);
|
||||||
|
|
||||||
void clearConditions();
|
void clearConditions();
|
||||||
public:
|
public:
|
||||||
LogEventsMngr();
|
LogEventsMngr();
|
||||||
|
@ -132,10 +140,12 @@ public:
|
||||||
// Interface
|
// Interface
|
||||||
CLogEvent* registerLogEvent(CPluginMngr::CPlugin* plugin, int func, int pos);
|
CLogEvent* registerLogEvent(CPluginMngr::CPlugin* plugin, int func, int pos);
|
||||||
inline bool logEventsExist() { return arelogevents; }
|
inline bool logEventsExist() { return arelogevents; }
|
||||||
|
|
||||||
void setLogString(char* frmt, va_list& vaptr);
|
void setLogString(char* frmt, va_list& vaptr);
|
||||||
void setLogString(char* frmt, ...);
|
void setLogString(char* frmt, ...);
|
||||||
void parseLogString();
|
void parseLogString();
|
||||||
void executeLogEvents();
|
void executeLogEvents();
|
||||||
|
|
||||||
inline const char* getLogString() { return logString; }
|
inline const char* getLogString() { return logString; }
|
||||||
inline int getLogArgNum() { return logArgc; }
|
inline int getLogArgNum() { return logArgc; }
|
||||||
inline const char* getLogArg(int i) { return (i < 0 || i >= logArgc) ? "" : logArgs[i]; }
|
inline const char* getLogArg(int i) { return (i < 0 || i >= logArgc) ? "" : logArgs[i]; }
|
||||||
|
@ -147,7 +157,7 @@ public:
|
||||||
LogEventsMngr* b;
|
LogEventsMngr* b;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
inline iterator(CLogEvent*aa,LogEventsMngr* bb) : a(aa), b(bb) {}
|
inline iterator(CLogEvent*aa, LogEventsMngr* bb) : a(aa), b(bb) {}
|
||||||
|
|
||||||
inline iterator& operator++()
|
inline iterator& operator++()
|
||||||
{
|
{
|
||||||
|
@ -156,7 +166,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool operator==(const iterator& c) const { return a == c.a; }
|
inline bool operator==(const iterator& c) const { return a == c.a; }
|
||||||
inline bool operator!=(const iterator& c) const { return !operator == (c); }
|
inline bool operator!=(const iterator& c) const { return !operator == (c); }
|
||||||
CLogEvent& operator*() { return *a; }
|
CLogEvent& operator*() { return *a; }
|
||||||
operator bool () const { return a ? true : false; }
|
operator bool () const { return a ? true : false; }
|
||||||
};
|
};
|
||||||
|
|
|
@ -63,7 +63,10 @@ int MenuMngr::findMenuId(const char* name, AMX* amx)
|
||||||
int MenuMngr::registerMenuId(const char* n, AMX* a)
|
int MenuMngr::registerMenuId(const char* n, AMX* a)
|
||||||
{
|
{
|
||||||
int id = findMenuId(n, a);
|
int id = findMenuId(n, a);
|
||||||
if (id) return id;
|
|
||||||
|
if (id)
|
||||||
|
return id;
|
||||||
|
|
||||||
headid = new MenuIdEle(n, a, headid);
|
headid = new MenuIdEle(n, a, headid);
|
||||||
|
|
||||||
if (!headid)
|
if (!headid)
|
||||||
|
|
|
@ -43,6 +43,7 @@ class MenuMngr
|
||||||
String name;
|
String name;
|
||||||
AMX* amx;
|
AMX* amx;
|
||||||
MenuIdEle* next;
|
MenuIdEle* next;
|
||||||
|
|
||||||
int id;
|
int id;
|
||||||
static int uniqueid;
|
static int uniqueid;
|
||||||
|
|
||||||
|
@ -67,6 +68,7 @@ private:
|
||||||
int menuid;
|
int menuid;
|
||||||
int keys;
|
int keys;
|
||||||
int function;
|
int function;
|
||||||
|
|
||||||
MenuCommand* next;
|
MenuCommand* next;
|
||||||
MenuCommand(CPluginMngr::CPlugin *a, int mi, int k, int f);
|
MenuCommand(CPluginMngr::CPlugin *a, int mi, int k, int f);
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -89,8 +89,10 @@ bool CPlayer::Connect(const char* connectname, const char* ipaddress)
|
||||||
time = gpGlobals->time;
|
time = gpGlobals->time;
|
||||||
bot = IsBot();
|
bot = IsBot();
|
||||||
death_killer = 0;
|
death_killer = 0;
|
||||||
|
|
||||||
memset(flags, 0, sizeof(flags));
|
memset(flags, 0, sizeof(flags));
|
||||||
memset(weapons, 0, sizeof(weapons));
|
memset(weapons, 0, sizeof(weapons));
|
||||||
|
|
||||||
initialized = true;
|
initialized = true;
|
||||||
authorized = false;
|
authorized = false;
|
||||||
|
|
||||||
|
@ -180,6 +182,7 @@ int XVars::put(AMX* p, cell* v)
|
||||||
|
|
||||||
head[num].value = v;
|
head[num].value = v;
|
||||||
head[num].amx = p;
|
head[num].amx = p;
|
||||||
|
|
||||||
return num++;
|
return num++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,7 +240,10 @@ void TeamIds::registerTeam(const char* n, int s)
|
||||||
}
|
}
|
||||||
|
|
||||||
*a = new TeamEle(n, s);
|
*a = new TeamEle(n, s);
|
||||||
if (*a == 0) return;
|
|
||||||
|
if (*a == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
newTeam |= (1<<(*a)->tid);
|
newTeam |= (1<<(*a)->tid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,9 +40,9 @@
|
||||||
|
|
||||||
class CCVar
|
class CCVar
|
||||||
{
|
{
|
||||||
cvar_t cvar;
|
cvar_t cvar;
|
||||||
String name;
|
String name;
|
||||||
String plugin;
|
String plugin;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CCVar(const char* pname, const char* pplugin, int pflags, float pvalue) : name(pname), plugin(pplugin)
|
CCVar(const char* pname, const char* pplugin, int pflags, float pvalue) : name(pname), plugin(pplugin)
|
||||||
|
@ -51,12 +51,12 @@ public:
|
||||||
cvar.flags = pflags;
|
cvar.flags = pflags;
|
||||||
cvar.string = "";
|
cvar.string = "";
|
||||||
cvar.value = pvalue;
|
cvar.value = pvalue;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline cvar_t* getCvar() { return &cvar; }
|
inline cvar_t* getCvar() { return &cvar; }
|
||||||
inline const char* getPluginName() { return plugin.c_str(); }
|
inline const char* getPluginName() { return plugin.c_str(); }
|
||||||
inline const char* getName() { return name.c_str(); }
|
inline const char* getName() { return name.c_str(); }
|
||||||
inline bool operator == (const char* string) { return (strcmp(name.c_str(),string)==0); }
|
inline bool operator == (const char* string) { return (strcmp(name.c_str(), string) == 0); }
|
||||||
};
|
};
|
||||||
|
|
||||||
// *****************************************************
|
// *****************************************************
|
||||||
|
@ -157,6 +157,7 @@ class Grenades
|
||||||
public:
|
public:
|
||||||
Grenades() { head = 0; }
|
Grenades() { head = 0; }
|
||||||
~Grenades() { clear(); }
|
~Grenades() { clear(); }
|
||||||
|
|
||||||
void put(edict_t* grenade, float time, int type, CPlayer* player);
|
void put(edict_t* grenade, float time, int type, CPlayer* player);
|
||||||
bool find(edict_t* enemy, CPlayer** p, int& type);
|
bool find(edict_t* enemy, CPlayer** p, int& type);
|
||||||
void clear();
|
void clear();
|
||||||
|
@ -168,19 +169,20 @@ public:
|
||||||
|
|
||||||
class ForceObject
|
class ForceObject
|
||||||
{
|
{
|
||||||
String filename;
|
String filename;
|
||||||
FORCE_TYPE type;
|
FORCE_TYPE type;
|
||||||
Vector mins;
|
Vector mins;
|
||||||
Vector maxs;
|
Vector maxs;
|
||||||
AMX* amx;
|
AMX* amx;
|
||||||
public:
|
public:
|
||||||
ForceObject(const char* n, FORCE_TYPE c, Vector& mi, Vector& ma, AMX* a) :
|
ForceObject(const char* n, FORCE_TYPE c, Vector& mi, Vector& ma, AMX* a) : filename(n), type(c), mins(mi), maxs(ma), amx(a) {}
|
||||||
filename(n), type(c), mins(mi), maxs(ma), amx(a) {}
|
|
||||||
|
|
||||||
inline const char* getFilename() { return filename.c_str(); }
|
inline const char* getFilename() { return filename.c_str(); }
|
||||||
inline AMX* getAMX() { return amx; }
|
inline AMX* getAMX() { return amx; }
|
||||||
|
|
||||||
Vector& getMin() { return mins; }
|
Vector& getMin() { return mins; }
|
||||||
Vector& getMax() { return maxs; }
|
Vector& getMax() { return maxs; }
|
||||||
|
|
||||||
inline FORCE_TYPE getForceType() { return type; }
|
inline FORCE_TYPE getForceType() { return type; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -197,13 +199,15 @@ class XVars
|
||||||
};
|
};
|
||||||
|
|
||||||
XVarEle* head;
|
XVarEle* head;
|
||||||
|
|
||||||
int size;
|
int size;
|
||||||
int num;
|
int num;
|
||||||
int realloc_array(int nsize);
|
int realloc_array(int nsize);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
XVars() { num = 0; size = 0; head = 0; }
|
XVars() { num = 0; size = 0; head = 0; }
|
||||||
~XVars() { clear(); }
|
~XVars() { clear(); }
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
int put(AMX* a, cell* v);
|
int put(AMX* a, cell* v);
|
||||||
|
|
||||||
|
@ -234,7 +238,7 @@ class CScript
|
||||||
AMX* amx;
|
AMX* amx;
|
||||||
void* code;
|
void* code;
|
||||||
public:
|
public:
|
||||||
CScript(AMX* aa, void* cc, const char* ff) : filename(ff), amx(aa), code(cc) { }
|
CScript(AMX* aa, void* cc, const char* ff) : filename(ff), amx(aa), code(cc) {}
|
||||||
|
|
||||||
inline AMX* getAMX() { return amx; }
|
inline AMX* getAMX() { return amx; }
|
||||||
inline const char* getName() { return filename.c_str(); }
|
inline const char* getName() { return filename.c_str(); }
|
||||||
|
@ -269,6 +273,7 @@ class TeamIds
|
||||||
public:
|
public:
|
||||||
TeamIds();
|
TeamIds();
|
||||||
~TeamIds();
|
~TeamIds();
|
||||||
|
|
||||||
void registerTeam(const char* n, int s);
|
void registerTeam(const char* n, int s);
|
||||||
int findTeamId(const char* n);
|
int findTeamId(const char* n);
|
||||||
int findTeamIdCase(const char* n);
|
int findTeamIdCase(const char* n);
|
||||||
|
|
|
@ -136,7 +136,7 @@ bool CModule::attachModule()
|
||||||
m_MissingFunc = g_LastRequestedFunc;
|
m_MissingFunc = g_LastRequestedFunc;
|
||||||
return false;
|
return false;
|
||||||
default:
|
default:
|
||||||
AMXXLOG_Log("[AMXX] Module \"%s\" (version \"%s\") returned an invalid code.", m_Filename.c_str(), getVersion());
|
AMXXLOG_Log("[AMXX] Module \"%s\" (version \"%s\") returned an invalid code.", m_Filename.c_str(), getVersion());
|
||||||
m_Status = MODULE_BADLOAD;
|
m_Status = MODULE_BADLOAD;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -191,7 +191,7 @@ bool CModule::queryModule()
|
||||||
case AMXX_OK:
|
case AMXX_OK:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
AMXXLOG_Log("[AMXX] Module \"%s\" (version \"%s\") returned an invalid code.", m_Filename.c_str(), getVersion());
|
AMXXLOG_Log("[AMXX] Module \"%s\" (version \"%s\") returned an invalid code.", m_Filename.c_str(), getVersion());
|
||||||
m_Status = MODULE_BADLOAD;
|
m_Status = MODULE_BADLOAD;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,8 +71,10 @@ struct amxx_module_info_s
|
||||||
class CModule
|
class CModule
|
||||||
{
|
{
|
||||||
String m_Filename; // Filename
|
String m_Filename; // Filename
|
||||||
|
|
||||||
bool m_Metamod; // Using metamod?
|
bool m_Metamod; // Using metamod?
|
||||||
bool m_Amxx; // Using new module interface?
|
bool m_Amxx; // Using new module interface?
|
||||||
|
|
||||||
amxx_module_info_s m_InfoNew; // module info (new module interface)
|
amxx_module_info_s m_InfoNew; // module info (new module interface)
|
||||||
DLHANDLE m_Handle; // handle
|
DLHANDLE m_Handle; // handle
|
||||||
MODULE_STATUS m_Status; // status
|
MODULE_STATUS m_Status; // status
|
||||||
|
@ -100,12 +102,13 @@ public:
|
||||||
inline const char* getName() const { return m_InfoNew.name; }
|
inline const char* getName() const { return m_InfoNew.name; }
|
||||||
inline const amxx_module_info_s* getInfoNew() const { return &m_InfoNew; } // new
|
inline const amxx_module_info_s* getInfoNew() const { return &m_InfoNew; } // new
|
||||||
inline int getStatusValue() { return m_Status; }
|
inline int getStatusValue() { return m_Status; }
|
||||||
inline bool operator==(const char* fname) { return !strcmp(m_Filename.c_str(), fname); }
|
inline bool operator==(const char* fname) { return !strcmp(m_Filename.c_str(), fname); }
|
||||||
inline bool isReloadable() { return ((m_Status == MODULE_LOADED) && (m_InfoNew.reload != 0)); }
|
inline bool isReloadable() { return ((m_Status == MODULE_LOADED) && (m_InfoNew.reload != 0)); }
|
||||||
inline bool isAmxx() const { return m_Amxx; }
|
inline bool isAmxx() const { return m_Amxx; }
|
||||||
inline const char *getMissingFunc() const { return m_MissingFunc; }
|
inline const char *getMissingFunc() const { return m_MissingFunc; }
|
||||||
inline const char *getFilename() { return m_Filename.c_str(); }
|
inline const char *getFilename() { return m_Filename.c_str(); }
|
||||||
inline bool IsMetamod() { return m_Metamod; }
|
inline bool IsMetamod() { return m_Metamod; }
|
||||||
|
|
||||||
void CModule::CallPluginsLoaded();
|
void CModule::CallPluginsLoaded();
|
||||||
|
|
||||||
CList<AMX_NATIVE_INFO*> m_Natives;
|
CList<AMX_NATIVE_INFO*> m_Natives;
|
||||||
|
|
|
@ -42,12 +42,17 @@ 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 ) a = &(*a)->next;
|
|
||||||
|
while (*a)
|
||||||
|
a = &(*a)->next;
|
||||||
|
|
||||||
*a = new CPlugin(pCounter++, path, name, error, debug);
|
*a = new CPlugin(pCounter++, path, name, error, debug);
|
||||||
|
|
||||||
return (*a);
|
return (*a);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPluginMngr::unloadPlugin( CPlugin** a ) {
|
void CPluginMngr::unloadPlugin(CPlugin** a)
|
||||||
|
{
|
||||||
CPlugin* next = (*a)->next;
|
CPlugin* next = (*a)->next;
|
||||||
delete *a;
|
delete *a;
|
||||||
*a = next;
|
*a = next;
|
||||||
|
@ -58,9 +63,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)
|
||||||
|
@ -68,19 +74,20 @@ void CPluginMngr::Finalize()
|
||||||
amx_Register(a->getAMX(), pNatives, -1);
|
amx_Register(a->getAMX(), pNatives, -1);
|
||||||
a->Finalize();
|
a->Finalize();
|
||||||
}
|
}
|
||||||
a=a->next;
|
a = a->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Finalized = true;
|
m_Finalized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CPluginMngr::loadPluginsFromFile( const char* filename )
|
int CPluginMngr::loadPluginsFromFile(const char* filename)
|
||||||
{
|
{
|
||||||
char file[256];
|
char file[256];
|
||||||
FILE *fp = fopen(build_pathname_r(file, sizeof(file)-1, "%s",filename) , "rt");
|
FILE *fp = fopen(build_pathname_r(file, sizeof(file) - 1, "%s", filename), "rt");
|
||||||
|
|
||||||
if ( !fp )
|
if (!fp)
|
||||||
{
|
{
|
||||||
AMXXLOG_Log( "[AMXX] Plugins list not found (file \"%s\")",filename);
|
AMXXLOG_Log("[AMXX] Plugins list not found (file \"%s\")", filename);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,22 +98,26 @@ int CPluginMngr::loadPluginsFromFile( const char* filename )
|
||||||
|
|
||||||
String line;
|
String line;
|
||||||
|
|
||||||
while ( !feof(fp) )
|
while (!feof(fp))
|
||||||
{
|
{
|
||||||
pluginName[0] = '\0';
|
pluginName[0] = '\0';
|
||||||
|
|
||||||
debug[0] = '\0';
|
debug[0] = '\0';
|
||||||
debugFlag = 0;
|
debugFlag = 0;
|
||||||
|
|
||||||
line.clear();
|
line.clear();
|
||||||
line._fread(fp);
|
line._fread(fp);
|
||||||
sscanf(line.c_str(),"%s %s",pluginName, debug);
|
sscanf(line.c_str(), "%s %s", pluginName, debug);
|
||||||
if (!isalnum(*pluginName)) continue;
|
|
||||||
|
if (!isalnum(*pluginName))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (isalnum(*debug) && strcmp(debug, "debug") == 0)
|
if (isalnum(*debug) && strcmp(debug, "debug") == 0)
|
||||||
{
|
{
|
||||||
debugFlag = 1;
|
debugFlag = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
@ -122,11 +133,15 @@ int CPluginMngr::loadPluginsFromFile( const char* filename )
|
||||||
return pCounter;
|
return pCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
@ -139,74 +154,98 @@ CPluginMngr::CPlugin* CPluginMngr::findPluginFast(AMX *amx)
|
||||||
return (CPlugin*)(amx->userdata[UD_FINDPLUGIN]);
|
return (CPlugin*)(amx->userdata[UD_FINDPLUGIN]);
|
||||||
}
|
}
|
||||||
|
|
||||||
CPluginMngr::CPlugin* CPluginMngr::findPlugin(AMX *amx) {
|
CPluginMngr::CPlugin* CPluginMngr::findPlugin(AMX *amx)
|
||||||
|
{
|
||||||
CPlugin*a = head;
|
CPlugin*a = head;
|
||||||
while ( a && &a->amx != amx )
|
|
||||||
a=a->next;
|
while (a && &a->amx != amx)
|
||||||
|
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--)
|
|
||||||
a=a->next;
|
while (a && index--)
|
||||||
|
a = a->next;
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
CPluginMngr::CPlugin* CPluginMngr::findPlugin(const char* name) {
|
CPluginMngr::CPlugin* CPluginMngr::findPlugin(const char* name)
|
||||||
if (!name) return 0;
|
{
|
||||||
|
if (!name)
|
||||||
|
return 0;
|
||||||
|
|
||||||
int len = strlen(name);
|
int len = strlen(name);
|
||||||
if (!len) return 0;
|
|
||||||
|
if (!len)
|
||||||
|
return 0;
|
||||||
|
|
||||||
CPlugin*a = head;
|
CPlugin*a = head;
|
||||||
while( a && strncmp(a->name.c_str(), name,len) )
|
|
||||||
a=a->next;
|
while (a && strncmp(a->name.c_str(), name, len))
|
||||||
|
a = a->next;
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* CPluginMngr::CPlugin::getStatus() const {
|
const char* CPluginMngr::CPlugin::getStatus() const
|
||||||
switch(status){
|
{
|
||||||
case ps_running:
|
switch (status)
|
||||||
|
{
|
||||||
|
case ps_running:
|
||||||
|
{
|
||||||
|
if (m_Debug)
|
||||||
{
|
{
|
||||||
if (m_Debug)
|
return "debug";
|
||||||
{
|
} else {
|
||||||
return "debug";
|
return "running";
|
||||||
} else {
|
|
||||||
return "running";
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case ps_paused: return "paused";
|
break;
|
||||||
case ps_bad_load: return "bad load";
|
}
|
||||||
case ps_stopped: return "stopped";
|
case ps_paused: return "paused";
|
||||||
case ps_locked: return "locked";
|
case ps_bad_load: return "bad load";
|
||||||
|
case ps_stopped: return "stopped";
|
||||||
|
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) {
|
CPluginMngr::CPlugin::CPlugin(int i, const char* p, const char* n, char* e, int d) : name(n), title(n)
|
||||||
|
{
|
||||||
const char* unk = "unknown";
|
const char* unk = "unknown";
|
||||||
|
|
||||||
title.assign(unk);
|
title.assign(unk);
|
||||||
author.assign(unk);
|
author.assign(unk);
|
||||||
version.assign(unk);
|
version.assign(unk);
|
||||||
|
|
||||||
char file[256];
|
char file[256];
|
||||||
char* path = build_pathname_r(file, sizeof(file)-1, "%s/%s",p,n);
|
char* path = build_pathname_r(file, sizeof(file) - 1, "%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");
|
m_PauseFwd = registerSPForwardByName(&amx, "plugin_pause");
|
||||||
m_UnpauseFwd = registerSPForwardByName(&amx, "plugin_unpause");
|
m_UnpauseFwd = registerSPForwardByName(&amx, "plugin_unpause");
|
||||||
|
|
||||||
if (amx.flags & AMX_FLAG_DEBUG)
|
if (amx.flags & AMX_FLAG_DEBUG)
|
||||||
{
|
{
|
||||||
m_Debug = true;
|
m_Debug = true;
|
||||||
|
@ -216,16 +255,16 @@ CPluginMngr::CPlugin::CPlugin(int i, const char* p,const char* n, char* e, int d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CPluginMngr::CPlugin::~CPlugin( )
|
CPluginMngr::CPlugin::~CPlugin()
|
||||||
{
|
{
|
||||||
unload_amxscript( &amx, &code );
|
unload_amxscript(&amx, &code);
|
||||||
}
|
}
|
||||||
|
|
||||||
int AMXAPI native_handler(AMX *amx, int index)
|
int AMXAPI native_handler(AMX *amx, int index)
|
||||||
{
|
{
|
||||||
Handler *pHandler = (Handler *)amx->userdata[UD_HANDLER];
|
Handler *pHandler = (Handler *)amx->userdata[UD_HANDLER];
|
||||||
|
|
||||||
char name[sNAMEMAX+1];
|
char name[sNAMEMAX + 1];
|
||||||
amx_GetNative(amx, index, name);
|
amx_GetNative(amx, index, name);
|
||||||
|
|
||||||
return pHandler->HandleNative(name, index, 0);
|
return pHandler->HandleNative(name, index, 0);
|
||||||
|
@ -253,7 +292,7 @@ static cell AMX_NATIVE_CALL invalid_native(AMX *amx, cell *params)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
char name[sNAMEMAX+1];
|
char name[sNAMEMAX + 1];
|
||||||
int native = amx->usertags[UT_NATIVE];
|
int native = amx->usertags[UT_NATIVE];
|
||||||
int err = amx_GetNative(amx, native, name);
|
int err = amx_GetNative(amx, native, name);
|
||||||
|
|
||||||
|
@ -274,16 +313,18 @@ static cell AMX_NATIVE_CALL invalid_native(AMX *amx, cell *params)
|
||||||
void CPluginMngr::CPlugin::Finalize()
|
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;
|
||||||
|
@ -299,21 +340,23 @@ void CPluginMngr::CPlugin::Finalize()
|
||||||
errorMsg.assign(buffer);
|
errorMsg.assign(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.c_str(), errorMsg.c_str());
|
AMXXLOG_Log("[AMXX] Plugin \"%s\" failed to load: %s", name.c_str(), errorMsg.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPluginMngr::CPlugin::pauseFunction( int id )
|
void CPluginMngr::CPlugin::pauseFunction(int id)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPluginMngr::CPlugin::unpauseFunction( int id )
|
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
|
||||||
}
|
}
|
||||||
|
@ -337,8 +380,8 @@ void CPluginMngr::CPlugin::unpausePlugin()
|
||||||
if (isValid())
|
if (isValid())
|
||||||
{
|
{
|
||||||
// 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)
|
||||||
executeForwards(m_UnpauseFwd);
|
executeForwards(m_UnpauseFwd);
|
||||||
|
|
|
@ -59,19 +59,23 @@ public:
|
||||||
|
|
||||||
AMX amx;
|
AMX amx;
|
||||||
void* code;
|
void* code;
|
||||||
|
|
||||||
String name;
|
String name;
|
||||||
String version;
|
String version;
|
||||||
String title;
|
String title;
|
||||||
String author;
|
String author;
|
||||||
String errorMsg;
|
String errorMsg;
|
||||||
|
|
||||||
int m_PauseFwd;
|
int m_PauseFwd;
|
||||||
int m_UnpauseFwd;
|
int m_UnpauseFwd;
|
||||||
int paused_fun;
|
int paused_fun;
|
||||||
int status;
|
int status;
|
||||||
CPlugin* next;
|
CPlugin* next;
|
||||||
int id;
|
int id;
|
||||||
|
|
||||||
CPlugin(int i, const char* p, const char* n, char* e, int d);
|
CPlugin(int i, const char* p, const char* n, char* e, int d);
|
||||||
~CPlugin();
|
~CPlugin();
|
||||||
|
|
||||||
bool m_Debug;
|
bool m_Debug;
|
||||||
public:
|
public:
|
||||||
inline const char* getName() { return name.c_str();}
|
inline const char* getName() { return name.c_str();}
|
||||||
|
@ -90,12 +94,14 @@ public:
|
||||||
inline bool isValid() const { return (status >= ps_paused); }
|
inline bool isValid() const { return (status >= ps_paused); }
|
||||||
inline bool isPaused() const { return ((status == ps_paused) || (status == ps_stopped)); }
|
inline bool isPaused() const { return ((status == ps_paused) || (status == ps_stopped)); }
|
||||||
inline bool isExecutable(int id) const { return (isValid() && !isPaused()); }
|
inline bool isExecutable(int id) const { return (isValid() && !isPaused()); }
|
||||||
|
|
||||||
void Finalize();
|
void Finalize();
|
||||||
void pausePlugin();
|
void pausePlugin();
|
||||||
void unpausePlugin();
|
void unpausePlugin();
|
||||||
void pauseFunction(int id);
|
void pauseFunction(int id);
|
||||||
void unpauseFunction(int id);
|
void unpauseFunction(int id);
|
||||||
void setStatus(int a);
|
void setStatus(int a);
|
||||||
|
|
||||||
const char* getStatus() const;
|
const char* getStatus() const;
|
||||||
inline bool isDebug() const { return m_Debug; }
|
inline bool isDebug() const { return m_Debug; }
|
||||||
};
|
};
|
||||||
|
@ -115,10 +121,12 @@ public:
|
||||||
CPlugin* loadPlugin(const char* path, const char* name, char* error, int debug);
|
CPlugin* loadPlugin(const char* path, const char* name, char* error, int debug);
|
||||||
void unloadPlugin(CPlugin** a);
|
void unloadPlugin(CPlugin** a);
|
||||||
int loadPluginsFromFile(const char* filename);
|
int loadPluginsFromFile(const char* filename);
|
||||||
|
|
||||||
CPlugin* findPluginFast(AMX *amx);
|
CPlugin* findPluginFast(AMX *amx);
|
||||||
CPlugin* findPlugin(AMX *amx);
|
CPlugin* findPlugin(AMX *amx);
|
||||||
CPlugin* findPlugin(int index);
|
CPlugin* findPlugin(int index);
|
||||||
CPlugin* findPlugin(const char* name);
|
CPlugin* findPlugin(const char* name);
|
||||||
|
|
||||||
inline int getPluginsNum() const { return pCounter; }
|
inline int getPluginsNum() const { return pCounter; }
|
||||||
void Finalize();
|
void Finalize();
|
||||||
void clear();
|
void clear();
|
||||||
|
|
|
@ -45,14 +45,17 @@ public:
|
||||||
item = i;
|
item = i;
|
||||||
next = n;
|
next = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
CQueueItem *GetNext()
|
CQueueItem *GetNext()
|
||||||
{
|
{
|
||||||
return next;
|
return next;
|
||||||
}
|
}
|
||||||
|
|
||||||
T & GetItem()
|
T & GetItem()
|
||||||
{
|
{
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetNext(CQueueItem *n)
|
void SetNext(CQueueItem *n)
|
||||||
{
|
{
|
||||||
next = n;
|
next = n;
|
||||||
|
@ -71,7 +74,7 @@ public:
|
||||||
|
|
||||||
bool empty()
|
bool empty()
|
||||||
{
|
{
|
||||||
return ((mSize==0)?true:false);
|
return ((mSize == 0) ? true : false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void push(const T &v)
|
void push(const T &v)
|
||||||
|
@ -119,8 +122,8 @@ public:
|
||||||
private:
|
private:
|
||||||
CQueueItem *mFirst;
|
CQueueItem *mFirst;
|
||||||
CQueueItem *mLast;
|
CQueueItem *mLast;
|
||||||
|
|
||||||
unsigned int mSize;
|
unsigned int mSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //_INCLUDE_CQUEUE_H
|
#endif //_INCLUDE_CQUEUE_H
|
||||||
|
|
||||||
|
|
|
@ -102,10 +102,10 @@ void CTaskMngr::CTask::clear()
|
||||||
m_iId = 0;
|
m_iId = 0;
|
||||||
m_fBase = 0.0f;
|
m_fBase = 0.0f;
|
||||||
|
|
||||||
m_iRepeat = 0;
|
m_iRepeat = 0;
|
||||||
m_bLoop = false;
|
m_bLoop = false;
|
||||||
m_bAfterStart = false;
|
m_bAfterStart = false;
|
||||||
m_bBeforeEnd = false;
|
m_bBeforeEnd = false;
|
||||||
|
|
||||||
m_fNextExecTime = 0.0f;
|
m_fNextExecTime = 0.0f;
|
||||||
}
|
}
|
||||||
|
@ -189,10 +189,10 @@ CTaskMngr::CTask::CTask()
|
||||||
m_iId = 0;
|
m_iId = 0;
|
||||||
m_fBase = 0.0f;
|
m_fBase = 0.0f;
|
||||||
|
|
||||||
m_iRepeat = 0;
|
m_iRepeat = 0;
|
||||||
m_bLoop = false;
|
m_bLoop = false;
|
||||||
m_bAfterStart = false;
|
m_bAfterStart = false;
|
||||||
m_bBeforeEnd = false;
|
m_bBeforeEnd = false;
|
||||||
|
|
||||||
m_fNextExecTime = 0.0f;
|
m_fNextExecTime = 0.0f;
|
||||||
|
|
||||||
|
|
|
@ -39,15 +39,18 @@ private:
|
||||||
class CTask
|
class CTask
|
||||||
{
|
{
|
||||||
// task settings
|
// task settings
|
||||||
|
|
||||||
CPluginMngr::CPlugin *m_pPlugin;
|
CPluginMngr::CPlugin *m_pPlugin;
|
||||||
int m_iId;
|
int m_iId;
|
||||||
int m_iFunc;
|
int m_iFunc;
|
||||||
int m_iRepeat;
|
int m_iRepeat;
|
||||||
|
|
||||||
bool m_bLoop;
|
bool m_bLoop;
|
||||||
bool m_bAfterStart;
|
bool m_bAfterStart;
|
||||||
bool m_bBeforeEnd;
|
bool m_bBeforeEnd;
|
||||||
float m_fBase; // for normal tasks, stores the interval, for the others, stores the amount of time before start / after end
|
float m_fBase; // for normal tasks, stores the interval, for the others, stores the amount of time before start / after end
|
||||||
int m_iParamLen;
|
int m_iParamLen;
|
||||||
|
|
||||||
cell *m_pParams;
|
cell *m_pParams;
|
||||||
bool m_bFree;
|
bool m_bFree;
|
||||||
|
|
||||||
|
@ -91,15 +94,16 @@ private:
|
||||||
if (right.m_bFree)
|
if (right.m_bFree)
|
||||||
return left.isFree();
|
return left.isFree();
|
||||||
|
|
||||||
return !left.isFree() && (right.m_pAmx ? left.getPlugin()->getAMX() == right.m_pAmx : true) &&
|
return !left.isFree() && (right.m_pAmx ? left.getPlugin()->getAMX() == right.m_pAmx : true) && left.getTaskId() == right.m_iId;
|
||||||
left.getTaskId() == right.m_iId;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*** CTaskMngr priv members ***/
|
/*** CTaskMngr priv members ***/
|
||||||
typedef CList<CTask, CTaskDescriptor> TaskList;
|
typedef CList<CTask, CTaskDescriptor> TaskList;
|
||||||
typedef TaskList::iterator TaskListIter;
|
typedef TaskList::iterator TaskListIter;
|
||||||
|
|
||||||
TaskList m_Tasks;
|
TaskList m_Tasks;
|
||||||
|
|
||||||
float *m_pTmr_CurrentTime;
|
float *m_pTmr_CurrentTime;
|
||||||
float *m_pTmr_TimeLimit;
|
float *m_pTmr_TimeLimit;
|
||||||
float *m_pTmr_TimeLeft;
|
float *m_pTmr_TimeLeft;
|
||||||
|
@ -109,9 +113,11 @@ public:
|
||||||
|
|
||||||
void registerTimers(float *pCurrentTime, float *pTimeLimit, float *pTimeLeft); // The timers will always point to the right value
|
void registerTimers(float *pCurrentTime, float *pTimeLimit, float *pTimeLeft); // The timers will always point to the right value
|
||||||
void registerTask(CPluginMngr::CPlugin *pPlugin, int iFunc, int iFlags, int iId, float fBase, int iParamsLen, const cell *pParams, int iRepeat);
|
void registerTask(CPluginMngr::CPlugin *pPlugin, int iFunc, int iFlags, int iId, float fBase, int iParamsLen, const cell *pParams, int iRepeat);
|
||||||
|
|
||||||
int removeTasks(int iId, AMX *pAmx); // remove all tasks that match the id and amx
|
int removeTasks(int iId, AMX *pAmx); // remove all tasks that match the id and amx
|
||||||
int changeTasks(int iId, AMX *pAmx, float fNewBase); // change all tasks that match the id and amx
|
int changeTasks(int iId, AMX *pAmx, float fNewBase); // change all tasks that match the id and amx
|
||||||
bool taskExists(int iId, AMX *pAmx);
|
bool taskExists(int iId, AMX *pAmx);
|
||||||
|
|
||||||
void startFrame();
|
void startFrame();
|
||||||
void clear();
|
void clear();
|
||||||
};
|
};
|
||||||
|
|
|
@ -117,7 +117,7 @@ void Vault::clear()
|
||||||
{
|
{
|
||||||
Obj* a = head->next;
|
Obj* a = head->next;
|
||||||
delete head;
|
delete head;
|
||||||
head = a;
|
head = a;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,7 @@ class Vault
|
||||||
{
|
{
|
||||||
String key;
|
String key;
|
||||||
String value;
|
String value;
|
||||||
|
|
||||||
int number;
|
int number;
|
||||||
Obj *next;
|
Obj *next;
|
||||||
Obj(const char* k, const char* v);
|
Obj(const char* k, const char* v);
|
||||||
|
@ -56,19 +57,23 @@ class Vault
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Vault() {head=0;}
|
Vault() { head = 0; }
|
||||||
~Vault() { clear();}
|
~Vault() { clear(); }
|
||||||
|
|
||||||
// Interface
|
// Interface
|
||||||
|
|
||||||
bool exists(const char* k);
|
bool exists(const char* k);
|
||||||
|
|
||||||
void put(const char* k, const char* v);
|
void put(const char* k, const char* v);
|
||||||
void remove(const char* k);
|
void remove(const char* k);
|
||||||
|
|
||||||
const char* get(const char* n);
|
const char* get(const char* n);
|
||||||
int get_number(const char* n);
|
int get_number(const char* n);
|
||||||
void setSource(const char* n);
|
void setSource(const char* n);
|
||||||
|
|
||||||
bool loadVault();
|
bool loadVault();
|
||||||
bool saveVault();
|
bool saveVault();
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
class iterator
|
class iterator
|
||||||
|
|
1866
amxmodx/amxmodx.cpp
1866
amxmodx/amxmodx.cpp
File diff suppressed because it is too large
Load Diff
|
@ -32,20 +32,19 @@
|
||||||
#ifndef AMXMODX_H
|
#ifndef AMXMODX_H
|
||||||
#define AMXMODX_H
|
#define AMXMODX_H
|
||||||
|
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "sclinux.h"
|
#include "sclinux.h"
|
||||||
#endif
|
#endif
|
||||||
#include <ctype.h> //tolower, etc
|
#include <ctype.h> //tolower, etc
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include <extdll.h>
|
#include <extdll.h>
|
||||||
#include <meta_api.h>
|
#include <meta_api.h>
|
||||||
#include "mm_pextensions.h" // metamod-p extensions
|
#include "mm_pextensions.h" // metamod-p extensions
|
||||||
|
|
||||||
#ifdef MEMORY_TEST
|
#ifdef MEMORY_TEST
|
||||||
#include "mmgr/mmgr.h"
|
#include "mmgr/mmgr.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "md5.h"
|
#include "md5.h"
|
||||||
|
@ -69,11 +68,11 @@
|
||||||
#include "amxxlog.h"
|
#include "amxxlog.h"
|
||||||
|
|
||||||
#define AMXXLOG_Log g_log.Log
|
#define AMXXLOG_Log g_log.Log
|
||||||
#define AMX_VERSION "1.56"
|
#define AMX_VERSION "1.56"
|
||||||
|
|
||||||
extern AMX_NATIVE_INFO core_Natives[];
|
extern AMX_NATIVE_INFO core_Natives[];
|
||||||
extern AMX_NATIVE_INFO time_Natives[];
|
extern AMX_NATIVE_INFO time_Natives[];
|
||||||
extern AMX_NATIVE_INFO power_Natives[];
|
extern AMX_NATIVE_INFO power_Natives[];
|
||||||
extern AMX_NATIVE_INFO amxmodx_Natives[];
|
extern AMX_NATIVE_INFO amxmodx_Natives[];
|
||||||
extern AMX_NATIVE_INFO file_Natives[];
|
extern AMX_NATIVE_INFO file_Natives[];
|
||||||
extern AMX_NATIVE_INFO float_Natives[];
|
extern AMX_NATIVE_INFO float_Natives[];
|
||||||
|
@ -82,18 +81,18 @@ extern AMX_NATIVE_INFO vault_Natives[];
|
||||||
|
|
||||||
#ifndef __linux__
|
#ifndef __linux__
|
||||||
#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)
|
||||||
#else
|
#else
|
||||||
#define DLLOAD(path) (DLHANDLE)dlopen(path, RTLD_NOW)
|
#define DLLOAD(path) (DLHANDLE)dlopen(path, RTLD_NOW)
|
||||||
#define DLPROC(m,func) dlsym(m,func)
|
#define DLPROC(m, func) dlsym(m, func)
|
||||||
#define DLFREE(m) dlclose(m)
|
#define DLFREE(m) dlclose(m)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __linux__
|
#ifndef __linux__
|
||||||
typedef HINSTANCE DLHANDLE;
|
typedef HINSTANCE DLHANDLE;
|
||||||
#else
|
#else
|
||||||
typedef void* DLHANDLE;
|
typedef void* DLHANDLE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef GETPLAYERAUTHID
|
#ifndef GETPLAYERAUTHID
|
||||||
|
@ -109,31 +108,35 @@ typedef void* DLHANDLE;
|
||||||
|
|
||||||
char* UTIL_SplitHudMessage(register const char *src);
|
char* UTIL_SplitHudMessage(register const char *src);
|
||||||
int UTIL_ReadFlags(const char* c);
|
int UTIL_ReadFlags(const char* c);
|
||||||
void UTIL_ClientPrint( edict_t *pEntity, int msg_dest, char *msg );
|
|
||||||
|
void UTIL_ClientPrint(edict_t *pEntity, int msg_dest, char *msg);
|
||||||
void UTIL_FakeClientCommand(edict_t *pEdict, const char *cmd, const char *arg1 = NULL, const char *arg2 = NULL);
|
void UTIL_FakeClientCommand(edict_t *pEdict, const char *cmd, const char *arg1 = NULL, const char *arg2 = NULL);
|
||||||
void UTIL_GetFlags(char* flags,int flag);
|
void UTIL_GetFlags(char* flags, int flag);
|
||||||
void UTIL_HudMessage(edict_t *pEntity, const hudtextparms_t &textparms, char *pMessage);
|
void UTIL_HudMessage(edict_t *pEntity, const hudtextparms_t &textparms, char *pMessage);
|
||||||
void UTIL_IntToString(int value, char *output);
|
void UTIL_IntToString(int value, char *output);
|
||||||
void UTIL_ShowMOTD( edict_t *client , char *motd, int mlen, const char *name);
|
void UTIL_ShowMOTD(edict_t *client, char *motd, int mlen, const char *name);
|
||||||
void UTIL_ShowMenu( edict_t* pEntity, int slots, int time, char *menu, int mlen );
|
void UTIL_ShowMenu(edict_t* pEntity, int slots, int time, char *menu, int mlen);
|
||||||
|
|
||||||
char *UTIL_VarArgs(const char *fmt, ...);
|
char *UTIL_VarArgs(const char *fmt, ...);
|
||||||
|
|
||||||
|
|
||||||
#define GET_PLAYER_POINTER(e) (&g_players[ENTINDEX(e)])
|
#define GET_PLAYER_POINTER(e) (&g_players[ENTINDEX(e)])
|
||||||
//#define GET_PLAYER_POINTER(e) (&g_players[(((int)e-g_edict_point)/sizeof(edict_t ))])
|
//#define GET_PLAYER_POINTER(e) (&g_players[(((int)e-g_edict_point)/sizeof(edict_t))])
|
||||||
#define GET_PLAYER_POINTER_I(i) (&g_players[i])
|
#define GET_PLAYER_POINTER_I(i) (&g_players[i])
|
||||||
|
|
||||||
struct WeaponsVault {
|
struct WeaponsVault
|
||||||
String fullName;
|
{
|
||||||
short int iId;
|
String fullName;
|
||||||
short int ammoSlot;
|
short int iId;
|
||||||
|
short int ammoSlot;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct fakecmd_t {
|
struct fakecmd_t
|
||||||
char args[256];
|
{
|
||||||
const char *argv[3];
|
char args[256];
|
||||||
int argc;
|
const char *argv[3];
|
||||||
bool fake;
|
int argc;
|
||||||
|
bool fake;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern bool g_IsNewMM;
|
extern bool g_IsNewMM;
|
||||||
|
@ -148,8 +151,8 @@ extern CList<CCVar> g_cvars;
|
||||||
extern CList<ForceObject> g_forcemodels;
|
extern CList<ForceObject> g_forcemodels;
|
||||||
extern CList<ForceObject> g_forcesounds;
|
extern CList<ForceObject> g_forcesounds;
|
||||||
extern CList<ForceObject> g_forcegeneric;
|
extern CList<ForceObject> g_forcegeneric;
|
||||||
extern CList<CModule,const char *> g_modules;
|
extern CList<CModule, const char *> g_modules;
|
||||||
extern CList<CScript,AMX*> g_loadedscripts;
|
extern CList<CScript, AMX*> g_loadedscripts;
|
||||||
extern CList<CPlayer*> g_auth;
|
extern CList<CPlayer*> g_auth;
|
||||||
extern EventsMngr g_events;
|
extern EventsMngr g_events;
|
||||||
extern Grenades g_grenades;
|
extern Grenades g_grenades;
|
||||||
|
@ -160,7 +163,7 @@ extern String g_log_dir;
|
||||||
extern String g_mod_name;
|
extern String g_mod_name;
|
||||||
extern TeamIds g_teamsIds;
|
extern TeamIds g_teamsIds;
|
||||||
extern Vault g_vault;
|
extern Vault g_vault;
|
||||||
extern CForwardMngr g_forwards;
|
extern CForwardMngr g_forwards;
|
||||||
extern WeaponsVault g_weaponsData[MAX_WEAPONS];
|
extern WeaponsVault g_weaponsData[MAX_WEAPONS];
|
||||||
extern XVars g_xvars;
|
extern XVars g_xvars;
|
||||||
extern bool g_bmod_cstrike;
|
extern bool g_bmod_cstrike;
|
||||||
|
@ -224,14 +227,15 @@ void Client_DeathMsg(void*);
|
||||||
void amx_command();
|
void amx_command();
|
||||||
void plugin_srvcmd();
|
void plugin_srvcmd();
|
||||||
|
|
||||||
const char* stristr(const char* a,const char* b);
|
const char* stristr(const char* a, const char* b);
|
||||||
char *strptime(const char *buf, const char *fmt, struct tm *tm, short addthem);
|
char *strptime(const char *buf, const char *fmt, struct tm *tm, short addthem);
|
||||||
|
|
||||||
int loadModules(const char* filename, PLUG_LOADTIME now);
|
int loadModules(const char* filename, PLUG_LOADTIME now);
|
||||||
void detachModules();
|
void detachModules();
|
||||||
void detachReloadModules();
|
void detachReloadModules();
|
||||||
|
|
||||||
#ifdef FAKEMETA
|
#ifdef FAKEMETA
|
||||||
void attachModules();
|
void attachModules();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Count modules
|
// Count modules
|
||||||
|
@ -245,40 +249,43 @@ enum CountModulesMode
|
||||||
int countModules(CountModulesMode mode);
|
int countModules(CountModulesMode mode);
|
||||||
void modules_callPluginsLoaded();
|
void modules_callPluginsLoaded();
|
||||||
|
|
||||||
cell* get_amxaddr(AMX *amx,cell amx_addr);
|
cell* get_amxaddr(AMX *amx, cell amx_addr);
|
||||||
char* build_pathname(char *fmt, ... );
|
char* build_pathname(char *fmt, ...);
|
||||||
char* build_pathname_r(char *buffer, size_t maxlen, char *fmt, ...);
|
char* build_pathname_r(char *buffer, size_t maxlen, char *fmt, ...);
|
||||||
char* format_amxstring(AMX *amx, cell *params, int parm,int& len);
|
char* format_amxstring(AMX *amx, cell *params, int parm, int& len);
|
||||||
AMX* get_amxscript(int, void**,const char**);
|
AMX* get_amxscript(int, void**, const char**);
|
||||||
const char* get_amxscriptname(AMX* amx);
|
const char* get_amxscriptname(AMX* amx);
|
||||||
char* get_amxstring(AMX *amx,cell amx_addr,int id,int& len);
|
char* get_amxstring(AMX *amx, cell amx_addr, int id, int& len);
|
||||||
|
|
||||||
int amxstring_len(cell* cstr);
|
int amxstring_len(cell* cstr);
|
||||||
int load_amxscript(AMX* amx, void** program, const char* path, char error[64], int debug);
|
int load_amxscript(AMX* amx, void** program, const char* path, char error[64], int debug);
|
||||||
int set_amxnatives(AMX* amx,char error[64]);
|
int set_amxnatives(AMX* amx, char error[64]);
|
||||||
int set_amxstring(AMX *amx,cell amx_addr,const char *source,int max);
|
int set_amxstring(AMX *amx, cell amx_addr, const char *source, int max);
|
||||||
int unload_amxscript(AMX* amx,void** program);
|
int unload_amxscript(AMX* amx, void** program);
|
||||||
void copy_amxmemory(cell* dest,cell* src,int len);
|
|
||||||
|
void copy_amxmemory(cell* dest, cell* src, int len);
|
||||||
void get_modname(char*);
|
void get_modname(char*);
|
||||||
void print_srvconsole( char *fmt, ... );
|
void print_srvconsole(char *fmt, ...);
|
||||||
void report_error( int code, char* fmt, ... );
|
void report_error(int code, char* fmt, ...);
|
||||||
void* alloc_amxmemory(void**, int size);
|
void* alloc_amxmemory(void**, int size);
|
||||||
void free_amxmemory(void **ptr);
|
void free_amxmemory(void **ptr);
|
||||||
// get_localinfo
|
// get_localinfo
|
||||||
const char* get_localinfo( const char* name , const char* def );
|
const char* get_localinfo(const char* name, const char* def);
|
||||||
cell AMX_NATIVE_CALL require_module(AMX *amx, cell *params);
|
cell AMX_NATIVE_CALL require_module(AMX *amx, cell *params);
|
||||||
void LogError(AMX *amx, int err, const char *fmt, ...);
|
void LogError(AMX *amx, int err, const char *fmt, ...);
|
||||||
|
|
||||||
enum ModuleCallReason
|
enum ModuleCallReason
|
||||||
{
|
{
|
||||||
ModuleCall_NotCalled = 0, // nothing
|
ModuleCall_NotCalled = 0, // nothing
|
||||||
ModuleCall_Query, // in Query func
|
ModuleCall_Query, // in Query func
|
||||||
ModuleCall_Attach, // in Attach func
|
ModuleCall_Attach, // in Attach func
|
||||||
ModuleCall_Detach, // in Detach func
|
ModuleCall_Detach, // in Detach func
|
||||||
};
|
};
|
||||||
|
|
||||||
extern ModuleCallReason g_ModuleCallReason; // modules.cpp
|
extern ModuleCallReason g_ModuleCallReason; // modules.cpp
|
||||||
extern CModule *g_CurrentlyCalledModule; // modules.cpp
|
extern CModule *g_CurrentlyCalledModule; // modules.cpp
|
||||||
extern const char *g_LastRequestedFunc; // modules.cpp
|
extern const char *g_LastRequestedFunc; // modules.cpp
|
||||||
|
|
||||||
void Module_CacheFunctions();
|
void Module_CacheFunctions();
|
||||||
void Module_UncacheFunctions();
|
void Module_UncacheFunctions();
|
||||||
|
|
||||||
|
@ -301,7 +308,7 @@ extern int FF_ClientAuthorized;
|
||||||
extern bool g_coloredmenus;
|
extern bool g_coloredmenus;
|
||||||
|
|
||||||
#ifdef FAKEMETA
|
#ifdef FAKEMETA
|
||||||
extern CFakeMeta g_FakeMeta;
|
extern CFakeMeta g_FakeMeta;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct func_s
|
struct func_s
|
||||||
|
@ -311,4 +318,3 @@ struct func_s
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // AMXMODX_H
|
#endif // AMXMODX_H
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,6 @@ CAmxxReader::CAmxxReader(const char *filename, int cellsize)
|
||||||
|
|
||||||
m_Status = Err_None;
|
m_Status = Err_None;
|
||||||
m_CellSize = cellsize;
|
m_CellSize = cellsize;
|
||||||
|
|
||||||
m_pFile = fopen(filename, "rb");
|
m_pFile = fopen(filename, "rb");
|
||||||
|
|
||||||
if (!m_pFile)
|
if (!m_pFile)
|
||||||
|
@ -115,6 +114,7 @@ CAmxxReader::CAmxxReader(const char *filename, int cellsize)
|
||||||
m_Status = Err_OldFile;
|
m_Status = Err_OldFile;
|
||||||
fclose(m_pFile);
|
fclose(m_pFile);
|
||||||
m_pFile = NULL;
|
m_pFile = NULL;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,6 +151,7 @@ CAmxxReader::CAmxxReader(const char *filename, int cellsize)
|
||||||
m_Status = Err_SectionNotFound;
|
m_Status = Err_SectionNotFound;
|
||||||
fclose(m_pFile);
|
fclose(m_pFile);
|
||||||
m_pFile = NULL;
|
m_pFile = NULL;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,6 +276,7 @@ size_t CAmxxReader::GetBufferSize()
|
||||||
AMX_HEADER hdr;
|
AMX_HEADER hdr;
|
||||||
DATAREAD(&hdr, sizeof(hdr), 1);
|
DATAREAD(&hdr, sizeof(hdr), 1);
|
||||||
fseek(m_pFile, save, SEEK_SET);
|
fseek(m_pFile, save, SEEK_SET);
|
||||||
|
|
||||||
return hdr.stp;
|
return hdr.stp;
|
||||||
}
|
}
|
||||||
else if (m_AmxxFile)
|
else if (m_AmxxFile)
|
||||||
|
|
|
@ -95,4 +95,3 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __AMXXFILE_H__
|
#endif // __AMXXFILE_H__
|
||||||
|
|
||||||
|
|
|
@ -86,6 +86,7 @@ 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);
|
||||||
|
@ -128,9 +129,9 @@ void CLog::MapChange()
|
||||||
// create dir if not existing
|
// create dir if not existing
|
||||||
char file[256];
|
char file[256];
|
||||||
#ifdef __linux
|
#ifdef __linux
|
||||||
mkdir(build_pathname_r(file, sizeof(file)-1,"%s", g_log_dir.c_str()), 0700);
|
mkdir(build_pathname_r(file, sizeof(file)-1, "%s", g_log_dir.c_str()), 0700);
|
||||||
#else
|
#else
|
||||||
mkdir(build_pathname_r(file, sizeof(file)-1,"%s", g_log_dir.c_str()));
|
mkdir(build_pathname_r(file, sizeof(file)-1, "%s", g_log_dir.c_str()));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_LogType = atoi(get_localinfo("amxx_logging", "1"));
|
m_LogType = atoi(get_localinfo("amxx_logging", "1"));
|
||||||
|
@ -197,6 +198,7 @@ void CLog::Log(const char *fmt, ...)
|
||||||
build_pathname_r(file, sizeof(file)-1, "%s/L%02d%02d.log", g_log_dir.c_str(), curTime->tm_mon + 1, curTime->tm_mday);
|
build_pathname_r(file, sizeof(file)-1, "%s/L%02d%02d.log", g_log_dir.c_str(), 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);
|
||||||
|
|
|
@ -42,6 +42,7 @@ private:
|
||||||
public:
|
public:
|
||||||
CLog();
|
CLog();
|
||||||
~CLog();
|
~CLog();
|
||||||
|
|
||||||
void CreateNewFile();
|
void CreateNewFile();
|
||||||
void CloseFile();
|
void CloseFile();
|
||||||
void MapChange();
|
void MapChange();
|
||||||
|
@ -49,4 +50,3 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __AMXXLOG_H__
|
#endif // __AMXXLOG_H__
|
||||||
|
|
||||||
|
|
|
@ -47,24 +47,28 @@ public:
|
||||||
class Tracer
|
class Tracer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
struct trace_info
|
struct trace_info
|
||||||
{
|
{
|
||||||
trace_info() : cip(0), frm(0), used(false), next(NULL), prev(NULL)
|
trace_info() : cip(0), frm(0), used(false), next(NULL), prev(NULL) {};
|
||||||
{
|
|
||||||
};
|
|
||||||
cell cip;
|
cell cip;
|
||||||
cell frm;
|
cell frm;
|
||||||
|
|
||||||
trace_info *next;
|
trace_info *next;
|
||||||
trace_info *prev;
|
trace_info *prev;
|
||||||
|
|
||||||
bool used;
|
bool used;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Tracer() : m_Error(0), m_pStart(NULL), m_pEnd(NULL), m_Reset(true) { };
|
Tracer() : m_Error(0), m_pStart(NULL), m_pEnd(NULL), m_Reset(true) {};
|
||||||
~Tracer();
|
~Tracer();
|
||||||
public:
|
public:
|
||||||
void StepI(cell frm, cell cip);
|
void StepI(cell frm, cell cip);
|
||||||
void Reset();
|
void Reset();
|
||||||
void Clear();
|
void Clear();
|
||||||
|
|
||||||
Debugger::Tracer::trace_info *GetStart() const;
|
Debugger::Tracer::trace_info *GetStart() const;
|
||||||
Debugger::Tracer::trace_info *GetEnd() const;
|
Debugger::Tracer::trace_info *GetEnd() const;
|
||||||
public:
|
public:
|
||||||
|
@ -72,14 +76,15 @@ public:
|
||||||
private:
|
private:
|
||||||
trace_info *m_pStart;
|
trace_info *m_pStart;
|
||||||
trace_info *m_pEnd;
|
trace_info *m_pEnd;
|
||||||
|
|
||||||
bool m_Reset;
|
bool m_Reset;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Debugger(AMX *pAmx, AMX_DBG *pAmxDbg) :
|
Debugger(AMX *pAmx, AMX_DBG *pAmxDbg) : m_pAmx(pAmx), m_pAmxDbg(pAmxDbg), m_Top(-1)
|
||||||
m_pAmx(pAmx), m_pAmxDbg(pAmxDbg), m_Top(-1)
|
{
|
||||||
{
|
_CacheAmxOpcodeList();
|
||||||
_CacheAmxOpcodeList();
|
};
|
||||||
};
|
|
||||||
~Debugger();
|
~Debugger();
|
||||||
public:
|
public:
|
||||||
//Begin a trace for a function
|
//Begin a trace for a function
|
||||||
|
@ -123,19 +128,24 @@ public:
|
||||||
public:
|
public:
|
||||||
//generic static opcode breaker
|
//generic static opcode breaker
|
||||||
static int AMXAPI DebugHook(AMX *amx);
|
static int AMXAPI DebugHook(AMX *amx);
|
||||||
|
|
||||||
static void FmtGenericMsg(AMX *amx, int error, char buffer[], size_t maxLength);
|
static void FmtGenericMsg(AMX *amx, int error, char buffer[], size_t maxLength);
|
||||||
static void GenericMessage(AMX *amx, int error);
|
static void GenericMessage(AMX *amx, int error);
|
||||||
private:
|
private:
|
||||||
void _CacheAmxOpcodeList();
|
void _CacheAmxOpcodeList();
|
||||||
|
|
||||||
int _GetOpcodeFromCip(cell cip, cell *&addr);
|
int _GetOpcodeFromCip(cell cip, cell *&addr);
|
||||||
cell _CipAsVa(cell cip);
|
cell _CipAsVa(cell cip);
|
||||||
|
|
||||||
const char *_GetFilename();
|
const char *_GetFilename();
|
||||||
public:
|
public:
|
||||||
AMX *m_pAmx;
|
AMX *m_pAmx;
|
||||||
AMX_DBG *m_pAmxDbg;
|
AMX_DBG *m_pAmxDbg;
|
||||||
|
|
||||||
int m_Top;
|
int m_Top;
|
||||||
cell *m_pOpcodeList;
|
cell *m_pOpcodeList;
|
||||||
String m_FileName;
|
String m_FileName;
|
||||||
|
|
||||||
CVector<Tracer *> m_pCalls;
|
CVector<Tracer *> m_pCalls;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -148,11 +158,8 @@ typedef Debugger::Tracer::trace_info trace_info_t;
|
||||||
class Handler
|
class Handler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Handler(AMX *pAmx) : m_pAmx(pAmx),
|
Handler(AMX *pAmx) : m_pAmx(pAmx), m_iErrFunc(-1), m_iModFunc(-1), m_iNatFunc(-1), m_Handling(false), m_InNativeFilter(false) {};
|
||||||
m_iErrFunc(-1), m_iModFunc(-1), m_iNatFunc(-1),
|
~Handler() {};
|
||||||
m_Handling(false), m_InNativeFilter(false)
|
|
||||||
{ };
|
|
||||||
~Handler() { };
|
|
||||||
public:
|
public:
|
||||||
int SetErrorHandler(const char *function);
|
int SetErrorHandler(const char *function);
|
||||||
int SetNativeFilter(const char *function);
|
int SetNativeFilter(const char *function);
|
||||||
|
@ -164,21 +171,28 @@ public:
|
||||||
public:
|
public:
|
||||||
bool IsHandling() const { return m_Handling; }
|
bool IsHandling() const { return m_Handling; }
|
||||||
void SetErrorMsg(const char *msg);
|
void SetErrorMsg(const char *msg);
|
||||||
|
|
||||||
const char *GetLastMsg();
|
const char *GetLastMsg();
|
||||||
trace_info_t *GetTrace() const { return m_pTrace; }
|
trace_info_t *GetTrace() const { return m_pTrace; }
|
||||||
const char *GetFmtCache() { return m_FmtCache.c_str(); }
|
const char *GetFmtCache() { return m_FmtCache.c_str(); }
|
||||||
|
|
||||||
bool IsNativeFiltering() { return (m_iNatFunc > 0); }
|
bool IsNativeFiltering() { return (m_iNatFunc > 0); }
|
||||||
bool InNativeFilter() { return m_InNativeFilter; }
|
bool InNativeFilter() { return m_InNativeFilter; }
|
||||||
private:
|
private:
|
||||||
AMX *m_pAmx;
|
AMX *m_pAmx;
|
||||||
|
|
||||||
int m_iErrFunc;
|
int m_iErrFunc;
|
||||||
int m_iModFunc;
|
int m_iModFunc;
|
||||||
int m_iNatFunc;
|
int m_iNatFunc;
|
||||||
|
|
||||||
bool m_Handling;
|
bool m_Handling;
|
||||||
|
|
||||||
//in the future, make this a stack!
|
//in the future, make this a stack!
|
||||||
bool m_InNativeFilter;
|
bool m_InNativeFilter;
|
||||||
|
|
||||||
String m_MsgCache;
|
String m_MsgCache;
|
||||||
String m_FmtCache;
|
String m_FmtCache;
|
||||||
|
|
||||||
trace_info_t *m_pTrace;
|
trace_info_t *m_pTrace;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ class AutoFilePtr
|
||||||
FILE *m_FP;
|
FILE *m_FP;
|
||||||
public:
|
public:
|
||||||
AutoFilePtr(FILE *fp) : m_FP(fp)
|
AutoFilePtr(FILE *fp) : m_FP(fp)
|
||||||
{ }
|
{}
|
||||||
|
|
||||||
~AutoFilePtr()
|
~AutoFilePtr()
|
||||||
{
|
{
|
||||||
|
@ -87,6 +87,7 @@ static cell AMX_NATIVE_CALL read_dir(AMX *amx, cell *params)
|
||||||
|
|
||||||
if ((dp = opendir (dirname)) == NULL)
|
if ((dp = opendir (dirname)) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
seekdir(dp, a);
|
seekdir(dp, a);
|
||||||
|
|
||||||
if ((ep = readdir (dp)) != NULL)
|
if ((ep = readdir (dp)) != NULL)
|
||||||
|
@ -149,17 +150,22 @@ static cell AMX_NATIVE_CALL read_file(AMX *amx, cell *params) /* 5 param */
|
||||||
|
|
||||||
while ((i <= iLine) && fgets(buffor, 1023, fp))
|
while ((i <= iLine) && fgets(buffor, 1023, fp))
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
if (i > iLine)
|
if (i > iLine)
|
||||||
{
|
{
|
||||||
int len = strlen(buffor);
|
int len = strlen(buffor);
|
||||||
|
|
||||||
if (buffor[len - 1] == '\n')
|
if (buffor[len - 1] == '\n')
|
||||||
buffor[--len] = 0;
|
buffor[--len] = 0;
|
||||||
|
|
||||||
if (buffor[len - 1] == '\r')
|
if (buffor[len - 1] == '\r')
|
||||||
buffor[--len] = 0;
|
buffor[--len] = 0;
|
||||||
|
|
||||||
cell *length = get_amxaddr(amx, params[5]);
|
cell *length = get_amxaddr(amx, params[5]);
|
||||||
*length = set_amxstring(amx, params[3], buffor, params[4]);
|
*length = set_amxstring(amx, params[3], buffor, params[4]);
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,6 +192,7 @@ static cell AMX_NATIVE_CALL write_file(AMX *amx, cell *params) /* 3 param */
|
||||||
fputs(sText, pFile);
|
fputs(sText, pFile);
|
||||||
fputc('\n', pFile);
|
fputc('\n', pFile);
|
||||||
fclose(pFile);
|
fclose(pFile);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,6 +211,7 @@ static cell AMX_NATIVE_CALL write_file(AMX *amx, cell *params) /* 3 param */
|
||||||
fputs(sText, pFile);
|
fputs(sText, pFile);
|
||||||
fputc('\n', pFile);
|
fputc('\n', pFile);
|
||||||
fclose(pFile);
|
fclose(pFile);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,7 +241,8 @@ static cell AMX_NATIVE_CALL write_file(AMX *amx, cell *params) /* 3 param */
|
||||||
{
|
{
|
||||||
fputc('\n', pTemp);
|
fputc('\n', pTemp);
|
||||||
}
|
}
|
||||||
else break;
|
else
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(pFile);
|
fclose(pFile);
|
||||||
|
@ -259,6 +268,7 @@ static cell AMX_NATIVE_CALL delete_file(AMX *amx, cell *params) /* 1 param */
|
||||||
{
|
{
|
||||||
int iLen;
|
int iLen;
|
||||||
char* sFile = get_amxstring(amx, params[1], 0, iLen);
|
char* sFile = get_amxstring(amx, params[1], 0, iLen);
|
||||||
|
|
||||||
return (unlink(build_pathname("%s", sFile)) ? 0 : 1);
|
return (unlink(build_pathname("%s", sFile)) ? 0 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,17 +280,23 @@ static cell AMX_NATIVE_CALL file_exists(AMX *amx, cell *params) /* 1 param */
|
||||||
|
|
||||||
#if defined WIN32 || defined _WIN32
|
#if defined WIN32 || defined _WIN32
|
||||||
DWORD attr = GetFileAttributes(file);
|
DWORD attr = GetFileAttributes(file);
|
||||||
|
|
||||||
if (attr == INVALID_FILE_ATTRIBUTES)
|
if (attr == INVALID_FILE_ATTRIBUTES)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (attr == FILE_ATTRIBUTE_DIRECTORY)
|
if (attr == FILE_ATTRIBUTE_DIRECTORY)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
#else
|
#else
|
||||||
struct stat s;
|
struct stat s;
|
||||||
|
|
||||||
if (stat(file, &s) != 0)
|
if (stat(file, &s) != 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (S_ISDIR(s.st_mode))
|
if (S_ISDIR(s.st_mode))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -293,17 +309,23 @@ static cell AMX_NATIVE_CALL dir_exists(AMX *amx, cell *params) /* 1 param */
|
||||||
|
|
||||||
#if defined WIN32 || defined _WIN32
|
#if defined WIN32 || defined _WIN32
|
||||||
DWORD attr = GetFileAttributes(file);
|
DWORD attr = GetFileAttributes(file);
|
||||||
|
|
||||||
if (attr == INVALID_FILE_ATTRIBUTES)
|
if (attr == INVALID_FILE_ATTRIBUTES)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (attr == FILE_ATTRIBUTE_DIRECTORY)
|
if (attr == FILE_ATTRIBUTE_DIRECTORY)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
struct stat s;
|
struct stat s;
|
||||||
|
|
||||||
if (stat(file, &s) != 0)
|
if (stat(file, &s) != 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (S_ISDIR(s.st_mode))
|
if (S_ISDIR(s.st_mode))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -320,6 +342,7 @@ static cell AMX_NATIVE_CALL file_size(AMX *amx, cell *params) /* 1 param */
|
||||||
{
|
{
|
||||||
fseek(fp, 0, SEEK_END);
|
fseek(fp, 0, SEEK_END);
|
||||||
int size = ftell(fp);
|
int size = ftell(fp);
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
else if (params[2] == 1)
|
else if (params[2] == 1)
|
||||||
|
@ -347,6 +370,7 @@ static cell AMX_NATIVE_CALL file_size(AMX *amx, cell *params) /* 1 param */
|
||||||
|
|
||||||
if (fgetc(fp) == '\n')
|
if (fgetc(fp) == '\n')
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -359,11 +383,12 @@ static cell AMX_NATIVE_CALL file_size(AMX *amx, cell *params) /* 1 param */
|
||||||
static cell AMX_NATIVE_CALL amx_fopen(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL amx_fopen(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
int len, j=-1;
|
int len, j = -1;
|
||||||
char *file = build_pathname("%s", get_amxstring(amx, params[1], 1, len));
|
char *file = build_pathname("%s", get_amxstring(amx, params[1], 1, len));
|
||||||
char *flags = get_amxstring(amx, params[2], 0, len);
|
char *flags = get_amxstring(amx, params[2], 0, len);
|
||||||
|
|
||||||
FILE *fp = fopen(file, flags);
|
FILE *fp = fopen(file, flags);
|
||||||
|
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
{
|
{
|
||||||
// Failed
|
// Failed
|
||||||
|
@ -396,6 +421,7 @@ static cell AMX_NATIVE_CALL amx_fclose(AMX *amx, cell *params)
|
||||||
|
|
||||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FILE *fp = FileList.at(id);
|
FILE *fp = FileList.at(id);
|
||||||
|
|
||||||
if (fp)
|
if (fp)
|
||||||
|
@ -412,6 +438,7 @@ static cell AMX_NATIVE_CALL amx_fread(AMX *amx, cell *params)
|
||||||
|
|
||||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FILE *fp = FileList.at(id);
|
FILE *fp = FileList.at(id);
|
||||||
|
|
||||||
char *buffer;
|
char *buffer;
|
||||||
|
@ -422,6 +449,7 @@ static cell AMX_NATIVE_CALL amx_fread(AMX *amx, cell *params)
|
||||||
fread(buffer, sizeof(char), params[3], fp);
|
fread(buffer, sizeof(char), params[3], fp);
|
||||||
set_amxstring(amx, params[2], buffer, params[3]);
|
set_amxstring(amx, params[2], buffer, params[3]);
|
||||||
delete [] buffer;
|
delete [] buffer;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -435,6 +463,7 @@ static cell AMX_NATIVE_CALL amx_fgetc(AMX *amx, cell *params)
|
||||||
|
|
||||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FILE *fp = FileList.at(id);
|
FILE *fp = FileList.at(id);
|
||||||
|
|
||||||
if (fp)
|
if (fp)
|
||||||
|
@ -451,6 +480,7 @@ static cell AMX_NATIVE_CALL amx_fwrite(AMX *amx, cell *params)
|
||||||
|
|
||||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FILE *fp = FileList.at(id);
|
FILE *fp = FileList.at(id);
|
||||||
char *buf;
|
char *buf;
|
||||||
int len;
|
int len;
|
||||||
|
@ -470,6 +500,7 @@ static cell AMX_NATIVE_CALL amx_feof(AMX *amx, cell *params)
|
||||||
|
|
||||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FILE *fp = FileList.at(id);
|
FILE *fp = FileList.at(id);
|
||||||
|
|
||||||
if (fp)
|
if (fp)
|
||||||
|
@ -490,6 +521,7 @@ static cell AMX_NATIVE_CALL amx_fseek(AMX *amx, cell *params)
|
||||||
|
|
||||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FILE *fp = FileList.at(id);
|
FILE *fp = FileList.at(id);
|
||||||
|
|
||||||
if (fp)
|
if (fp)
|
||||||
|
@ -506,6 +538,7 @@ static cell AMX_NATIVE_CALL amx_fputc(AMX *amx, cell *params)
|
||||||
|
|
||||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FILE *fp = FileList.at(id);
|
FILE *fp = FileList.at(id);
|
||||||
|
|
||||||
if (fp)
|
if (fp)
|
||||||
|
@ -522,6 +555,7 @@ static cell AMX_NATIVE_CALL amx_rewind(AMX *amx, cell *params)
|
||||||
|
|
||||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FILE *fp = FileList.at(id);
|
FILE *fp = FileList.at(id);
|
||||||
|
|
||||||
if (fp)
|
if (fp)
|
||||||
|
@ -539,6 +573,7 @@ static cell AMX_NATIVE_CALL amx_fflush(AMX *amx, cell *params)
|
||||||
|
|
||||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FILE *fp = FileList.at(id);
|
FILE *fp = FileList.at(id);
|
||||||
|
|
||||||
if (fp)
|
if (fp)
|
||||||
|
@ -555,6 +590,7 @@ static cell AMX_NATIVE_CALL amx_fscanf(AMX *amx, cell *params)
|
||||||
|
|
||||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FILE *fp = FileList.at(id);
|
FILE *fp = FileList.at(id);
|
||||||
|
|
||||||
char *buf;
|
char *buf;
|
||||||
|
@ -575,6 +611,7 @@ static cell AMX_NATIVE_CALL amx_ftell(AMX *amx, cell *params)
|
||||||
|
|
||||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FILE *fp = FileList.at(id);
|
FILE *fp = FileList.at(id);
|
||||||
|
|
||||||
if (fp)
|
if (fp)
|
||||||
|
@ -591,12 +628,14 @@ static cell AMX_NATIVE_CALL amx_filesize(AMX *amx, cell *params)
|
||||||
int len;
|
int len;
|
||||||
char *file = build_pathname("%s", format_amxstring(amx, params, 1, len));
|
char *file = build_pathname("%s", format_amxstring(amx, params, 1, len));
|
||||||
long size;
|
long size;
|
||||||
|
|
||||||
AutoFilePtr fp(fopen(file, "rb"));
|
AutoFilePtr fp(fopen(file, "rb"));
|
||||||
|
|
||||||
if (fp)
|
if (fp)
|
||||||
{
|
{
|
||||||
fseek(fp, 0, SEEK_END);
|
fseek(fp, 0, SEEK_END);
|
||||||
size = ftell(fp);
|
size = ftell(fp);
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -610,6 +649,7 @@ static cell AMX_NATIVE_CALL amx_fgetl(AMX *amx, cell *params)
|
||||||
|
|
||||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FILE *fp = FileList.at(id);
|
FILE *fp = FileList.at(id);
|
||||||
|
|
||||||
long t;
|
long t;
|
||||||
|
@ -629,6 +669,7 @@ static cell AMX_NATIVE_CALL amx_fgeti(AMX *amx, cell *params)
|
||||||
|
|
||||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FILE *fp = FileList.at(id);
|
FILE *fp = FileList.at(id);
|
||||||
|
|
||||||
int t;
|
int t;
|
||||||
|
@ -648,6 +689,7 @@ static cell AMX_NATIVE_CALL amx_fgets(AMX *amx, cell *params)
|
||||||
|
|
||||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FILE *fp = FileList.at(id);
|
FILE *fp = FileList.at(id);
|
||||||
|
|
||||||
short t;
|
short t;
|
||||||
|
@ -667,6 +709,7 @@ static cell AMX_NATIVE_CALL amx_fputs(AMX *amx, cell *params)
|
||||||
|
|
||||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FILE *fp = FileList.at(id);
|
FILE *fp = FileList.at(id);
|
||||||
|
|
||||||
short size = params[2];
|
short size = params[2];
|
||||||
|
@ -685,6 +728,7 @@ static cell AMX_NATIVE_CALL amx_fputl(AMX *amx, cell *params)
|
||||||
|
|
||||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FILE *fp = FileList.at(id);
|
FILE *fp = FileList.at(id);
|
||||||
|
|
||||||
long size = params[2];
|
long size = params[2];
|
||||||
|
@ -703,6 +747,7 @@ static cell AMX_NATIVE_CALL amx_fputi(AMX *amx, cell *params)
|
||||||
|
|
||||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FILE *fp = FileList.at(id);
|
FILE *fp = FileList.at(id);
|
||||||
|
|
||||||
int size = params[2];
|
int size = params[2];
|
||||||
|
@ -721,6 +766,7 @@ static cell AMX_NATIVE_CALL amx_fgetf(AMX *amx, cell *params)
|
||||||
|
|
||||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FILE *fp = FileList.at(id);
|
FILE *fp = FileList.at(id);
|
||||||
|
|
||||||
float t;
|
float t;
|
||||||
|
@ -740,6 +786,7 @@ static cell AMX_NATIVE_CALL amx_fputf(AMX *amx, cell *params)
|
||||||
|
|
||||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FILE *fp = FileList.at(id);
|
FILE *fp = FileList.at(id);
|
||||||
|
|
||||||
float size = *(float *)((void *)¶ms[2]);
|
float size = *(float *)((void *)¶ms[2]);
|
||||||
|
@ -757,6 +804,7 @@ static cell AMX_NATIVE_CALL amx_build_pathname(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
char *szPath = get_amxstring(amx, params[1], 0, len);
|
char *szPath = get_amxstring(amx, params[1], 0, len);
|
||||||
|
|
||||||
return set_amxstring(amx, params[2], build_pathname("%s", szPath), params[3]);
|
return set_amxstring(amx, params[2], build_pathname("%s", szPath), params[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -767,11 +815,13 @@ static cell AMX_NATIVE_CALL amx_open_dir(AMX *amx, cell *params)
|
||||||
|
|
||||||
#if defined WIN32 || defined _WIN32
|
#if defined WIN32 || defined _WIN32
|
||||||
char *dirname = build_pathname("%s\\*", path);
|
char *dirname = build_pathname("%s\\*", path);
|
||||||
|
|
||||||
WIN32_FIND_DATA fd;
|
WIN32_FIND_DATA fd;
|
||||||
HANDLE hFile = FindFirstFile(dirname, &fd);
|
HANDLE hFile = FindFirstFile(dirname, &fd);
|
||||||
|
|
||||||
if (hFile == INVALID_HANDLE_VALUE)
|
if (hFile == INVALID_HANDLE_VALUE)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
set_amxstring(amx, params[2], fd.cFileName, params[3]);
|
set_amxstring(amx, params[2], fd.cFileName, params[3]);
|
||||||
|
|
||||||
return (DWORD)hFile;
|
return (DWORD)hFile;
|
||||||
|
@ -802,6 +852,7 @@ static cell AMX_NATIVE_CALL amx_close_dir(AMX *amx, cell *params)
|
||||||
|
|
||||||
if (hFile == INVALID_HANDLE_VALUE || hFile == NULL)
|
if (hFile == INVALID_HANDLE_VALUE || hFile == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FindClose(hFile);
|
FindClose(hFile);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -823,10 +874,12 @@ static cell AMX_NATIVE_CALL amx_get_dir(AMX *amx, cell *params)
|
||||||
|
|
||||||
if (hFile == INVALID_HANDLE_VALUE || hFile == NULL)
|
if (hFile == INVALID_HANDLE_VALUE || hFile == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
WIN32_FIND_DATA fd;
|
WIN32_FIND_DATA fd;
|
||||||
|
|
||||||
if (!FindNextFile(hFile, &fd))
|
if (!FindNextFile(hFile, &fd))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
set_amxstring(amx, params[2], fd.cFileName, params[3]);
|
set_amxstring(amx, params[2], fd.cFileName, params[3]);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -839,6 +892,7 @@ static cell AMX_NATIVE_CALL amx_get_dir(AMX *amx, cell *params)
|
||||||
|
|
||||||
if (!ep)
|
if (!ep)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
set_amxstring(amx, params[2], ep->d_name, params[3]);
|
set_amxstring(amx, params[2], ep->d_name, params[3]);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -849,9 +903,9 @@ AMX_NATIVE_INFO file_Natives[] =
|
||||||
{
|
{
|
||||||
{"delete_file", delete_file},
|
{"delete_file", delete_file},
|
||||||
{"file_exists", file_exists},
|
{"file_exists", file_exists},
|
||||||
{"file_size", file_size},
|
{"file_size", file_size},
|
||||||
{"read_dir", read_dir},
|
{"read_dir", read_dir},
|
||||||
{"read_file", read_file},
|
{"read_file", read_file},
|
||||||
{"write_file", write_file},
|
{"write_file", write_file},
|
||||||
//Sanji's File Natives
|
//Sanji's File Natives
|
||||||
{"fopen", amx_fopen},
|
{"fopen", amx_fopen},
|
||||||
|
|
|
@ -30,9 +30,11 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#if defined WIN32
|
#if defined WIN32
|
||||||
#include <direct.h>
|
#include <direct.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "amxmodx.h"
|
#include "amxmodx.h"
|
||||||
#include "fakemeta.h"
|
#include "fakemeta.h"
|
||||||
#include "newmenus.h"
|
#include "newmenus.h"
|
||||||
|
@ -60,6 +62,7 @@ pextension_funcs_t *gpMetaPExtFuncs;
|
||||||
|
|
||||||
funEventCall modMsgsEnd[MAX_REG_MSGS];
|
funEventCall modMsgsEnd[MAX_REG_MSGS];
|
||||||
funEventCall modMsgs[MAX_REG_MSGS];
|
funEventCall modMsgs[MAX_REG_MSGS];
|
||||||
|
|
||||||
void (*function)(void*);
|
void (*function)(void*);
|
||||||
void (*endfunction)(void*);
|
void (*endfunction)(void*);
|
||||||
|
|
||||||
|
@ -75,6 +78,7 @@ CPlayer* mPlayer;
|
||||||
CPluginMngr g_plugins;
|
CPluginMngr g_plugins;
|
||||||
CTaskMngr g_tasksMngr;
|
CTaskMngr g_tasksMngr;
|
||||||
CmdMngr g_commands;
|
CmdMngr g_commands;
|
||||||
|
|
||||||
EventsMngr g_events;
|
EventsMngr g_events;
|
||||||
Grenades g_grenades;
|
Grenades g_grenades;
|
||||||
LogEventsMngr g_logevents;
|
LogEventsMngr g_logevents;
|
||||||
|
@ -83,16 +87,20 @@ CLangMngr g_langMngr;
|
||||||
String g_log_dir;
|
String g_log_dir;
|
||||||
String g_mod_name;
|
String g_mod_name;
|
||||||
XVars g_xvars;
|
XVars g_xvars;
|
||||||
|
|
||||||
bool g_bmod_cstrike;
|
bool g_bmod_cstrike;
|
||||||
bool g_bmod_dod;
|
bool g_bmod_dod;
|
||||||
bool g_dontprecache;
|
bool g_dontprecache;
|
||||||
bool g_forcedmodules;
|
bool g_forcedmodules;
|
||||||
bool g_forcedsounds;
|
bool g_forcedsounds;
|
||||||
|
|
||||||
fakecmd_t g_fakecmd;
|
fakecmd_t g_fakecmd;
|
||||||
|
|
||||||
float g_game_restarting;
|
float g_game_restarting;
|
||||||
float g_game_timeleft;
|
float g_game_timeleft;
|
||||||
float g_task_time;
|
float g_task_time;
|
||||||
float g_auth_time;
|
float g_auth_time;
|
||||||
|
|
||||||
bool g_initialized = false;
|
bool g_initialized = false;
|
||||||
bool g_IsNewMM = false;
|
bool g_IsNewMM = false;
|
||||||
bool g_NeedsP = false;
|
bool g_NeedsP = false;
|
||||||
|
@ -239,8 +247,8 @@ int C_Spawn(edict_t *pent)
|
||||||
|
|
||||||
// ###### Load lang
|
// ###### Load lang
|
||||||
char file[256];
|
char file[256];
|
||||||
g_langMngr.LoadCache(build_pathname_r(file, sizeof(file)-1, "%s/dictionary.cache", get_localinfo("amxx_datadir", "addons/amxmodx/data")));
|
g_langMngr.LoadCache(build_pathname_r(file, sizeof(file) - 1, "%s/dictionary.cache", get_localinfo("amxx_datadir", "addons/amxmodx/data")));
|
||||||
g_langMngr.Load(build_pathname_r(file, sizeof(file)-1, "%s/languages.dat", get_localinfo("amxmodx_datadir", "addons/amxmodx/data")));
|
g_langMngr.Load(build_pathname_r(file, sizeof(file) - 1, "%s/languages.dat", get_localinfo("amxmodx_datadir", "addons/amxmodx/data")));
|
||||||
|
|
||||||
// ###### Initialize commands prefixes
|
// ###### Initialize commands prefixes
|
||||||
g_commands.registerPrefix("amx");
|
g_commands.registerPrefix("amx");
|
||||||
|
@ -260,6 +268,7 @@ int C_Spawn(edict_t *pent)
|
||||||
// ###### Load modules
|
// ###### Load modules
|
||||||
loadModules(get_localinfo("amxx_modules", "addons/amxmodx/configs/modules.ini"), PT_ANYTIME);
|
loadModules(get_localinfo("amxx_modules", "addons/amxmodx/configs/modules.ini"), PT_ANYTIME);
|
||||||
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, AMX_VERSION);
|
CVAR_SET_STRING(init_amxmodx_version.name, AMX_VERSION);
|
||||||
char buffer[32];
|
char buffer[32];
|
||||||
|
@ -267,7 +276,7 @@ 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
|
||||||
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) - 1, "%s", get_localinfo("amxx_vault", "addons/amxmodx/configs/vault.ini")));
|
||||||
g_vault.loadVault();
|
g_vault.loadVault();
|
||||||
|
|
||||||
if (strlen(g_vault.get("server_language")) < 1)
|
if (strlen(g_vault.get("server_language")) < 1)
|
||||||
|
@ -280,11 +289,9 @@ int C_Spawn(edict_t *pent)
|
||||||
g_game_timeleft = g_bmod_dod ? 1.0f : 0.0f;
|
g_game_timeleft = g_bmod_dod ? 1.0f : 0.0f;
|
||||||
g_task_time = gpGlobals->time + 99999.0f;
|
g_task_time = gpGlobals->time + 99999.0f;
|
||||||
g_auth_time = gpGlobals->time + 99999.0f;
|
g_auth_time = gpGlobals->time + 99999.0f;
|
||||||
|
|
||||||
#ifdef MEMORY_TEST
|
#ifdef MEMORY_TEST
|
||||||
g_next_memreport_time = gpGlobals->time + 99999.0f;
|
g_next_memreport_time = gpGlobals->time + 99999.0f;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
g_players_num = 0;
|
g_players_num = 0;
|
||||||
|
|
||||||
// Set server flags
|
// Set server flags
|
||||||
|
@ -424,8 +431,8 @@ void C_ServerActivate_Post(edict_t *pEdictList, int edictCount, int clientMax)
|
||||||
|
|
||||||
// ###### Save lang
|
// ###### Save lang
|
||||||
char file[256];
|
char file[256];
|
||||||
g_langMngr.Save(build_pathname_r(file, sizeof(file)-1, "%s/languages.dat", get_localinfo("amxx_datadir", "addons/amxmodx/data")));
|
g_langMngr.Save(build_pathname_r(file, sizeof(file) - 1, "%s/languages.dat", get_localinfo("amxx_datadir", "addons/amxmodx/data")));
|
||||||
g_langMngr.SaveCache(build_pathname_r(file, sizeof(file)-1, "%s/dictionary.cache", get_localinfo("amxx_datadir", "addons/amxmodx/data")));
|
g_langMngr.SaveCache(build_pathname_r(file, sizeof(file) - 1, "%s/dictionary.cache", get_localinfo("amxx_datadir", "addons/amxmodx/data")));
|
||||||
|
|
||||||
// Correct time in Counter-Strike and other mods (except DOD)
|
// Correct time in Counter-Strike and other mods (except DOD)
|
||||||
if (!g_bmod_dod)
|
if (!g_bmod_dod)
|
||||||
|
@ -494,9 +501,11 @@ void C_ServerDeactivate_Post()
|
||||||
g_xvars.clear();
|
g_xvars.clear();
|
||||||
g_plugins.clear();
|
g_plugins.clear();
|
||||||
ClearPluginLibraries();
|
ClearPluginLibraries();
|
||||||
|
|
||||||
char file[256];
|
char file[256];
|
||||||
g_langMngr.Save(build_pathname_r(file, sizeof(file)-1, "%s/languages.dat", get_localinfo("amxx_datadir", "addons/amxmodx/data")));
|
|
||||||
g_langMngr.SaveCache(build_pathname_r(file, sizeof(file)-1, "%s/dictionary.cache", get_localinfo("amxx_datadir", "addons/amxmodx/data")));
|
g_langMngr.Save(build_pathname_r(file, sizeof(file) - 1, "%s/languages.dat", get_localinfo("amxx_datadir", "addons/amxmodx/data")));
|
||||||
|
g_langMngr.SaveCache(build_pathname_r(file, sizeof(file) - 1, "%s/dictionary.cache", get_localinfo("amxx_datadir", "addons/amxmodx/data")));
|
||||||
g_langMngr.Clear();
|
g_langMngr.Clear();
|
||||||
|
|
||||||
// last memreport
|
// last memreport
|
||||||
|
@ -540,12 +549,15 @@ void C_ServerDeactivate_Post()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g_memreport_dir.assign(buffer);
|
g_memreport_dir.assign(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.c_str(), g_memreport_count));
|
m_dumpMemoryReport(build_pathname("%s/r%03d.txt", g_memreport_dir.c_str(), g_memreport_count));
|
||||||
AMXXLOG_Log("Memreport #%d created (file \"%s/r%03d.txt\") (interval %f)", g_memreport_count + 1, g_memreport_dir.c_str(), g_memreport_count, MEMREPORT_INTERVAL);
|
AMXXLOG_Log("Memreport #%d created (file \"%s/r%03d.txt\") (interval %f)", g_memreport_count + 1, g_memreport_dir.c_str(), g_memreport_count, MEMREPORT_INTERVAL);
|
||||||
|
|
||||||
g_memreport_count++;
|
g_memreport_count++;
|
||||||
}
|
}
|
||||||
#endif // MEMORY_TEST
|
#endif // MEMORY_TEST
|
||||||
|
@ -614,7 +626,7 @@ void C_ClientUserInfoChanged_Post(edict_t *pEntity, char *infobuffer)
|
||||||
// Emulate bot connection and putinserver
|
// Emulate bot connection and putinserver
|
||||||
if (pPlayer->ingame)
|
if (pPlayer->ingame)
|
||||||
{
|
{
|
||||||
pPlayer->name.assign(name); // Make sure player have name up to date
|
pPlayer->name.assign(name); // Make sure player have name up to date
|
||||||
}
|
}
|
||||||
else if (pPlayer->IsBot())
|
else if (pPlayer->IsBot())
|
||||||
{
|
{
|
||||||
|
@ -637,8 +649,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);
|
||||||
|
|
||||||
|
@ -649,6 +663,7 @@ void C_ClientCommand(edict_t *pEntity)
|
||||||
{
|
{
|
||||||
// Print version
|
// Print version
|
||||||
static char buf[1024];
|
static char buf[1024];
|
||||||
|
|
||||||
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);
|
||||||
sprintf(buf, "Authors: %s (%s)\n", "Felix \"SniperBeamer\" Geyer, David \"BAILOPAN\" Anderson, Pavol \"PM OnoTo\" Marko, Jonny \"Got His Gun\" Bergstrom, and Lukasz \"SidLuke\" Wlasinski.", Plugin_info.url);
|
sprintf(buf, "Authors: %s (%s)\n", "Felix \"SniperBeamer\" Geyer, David \"BAILOPAN\" Anderson, Pavol \"PM OnoTo\" Marko, Jonny \"Got His Gun\" Bergstrom, and Lukasz \"SidLuke\" Wlasinski.", Plugin_info.url);
|
||||||
|
@ -675,7 +690,9 @@ 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) aa = g_commands.clcmdbegin();
|
|
||||||
|
if (!aa)
|
||||||
|
aa = g_commands.clcmdbegin();
|
||||||
|
|
||||||
while (aa)
|
while (aa)
|
||||||
{
|
{
|
||||||
|
@ -717,14 +734,15 @@ void C_ClientCommand(edict_t *pEntity)
|
||||||
int item = pMenu->PagekeyToItem(pPlayer->page, pressed_key);
|
int item = pMenu->PagekeyToItem(pPlayer->page, pressed_key);
|
||||||
ret = executeForwards((*a).getFunction(), pPlayer->index, menu, item);
|
ret = executeForwards((*a).getFunction(), pPlayer->index, menu, item);
|
||||||
|
|
||||||
if (ret & 2) result = MRES_SUPERCEDE;
|
if (ret & 2)
|
||||||
else
|
result = MRES_SUPERCEDE;
|
||||||
if (ret & 1) RETURN_META(MRES_SUPERCEDE);
|
else if (ret & 1)
|
||||||
|
RETURN_META(MRES_SUPERCEDE);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (item == MENU_BACK)
|
if (item == MENU_BACK)
|
||||||
{
|
{
|
||||||
pMenu->Display(pPlayer->index, pPlayer->page-1);
|
pMenu->Display(pPlayer->index, pPlayer->page - 1);
|
||||||
}
|
}
|
||||||
else if (item == MENU_MORE)
|
else if (item == MENU_MORE)
|
||||||
{
|
{
|
||||||
|
@ -774,6 +792,7 @@ void C_StartFrame_Post(void)
|
||||||
(*a)->Authorize();
|
(*a)->Authorize();
|
||||||
executeForwards(FF_ClientAuthorized, (*a)->index);
|
executeForwards(FF_ClientAuthorized, (*a)->index);
|
||||||
a.remove();
|
a.remove();
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
++a;
|
++a;
|
||||||
|
@ -791,6 +810,7 @@ void C_StartFrame_Post(void)
|
||||||
time_t td;
|
time_t td;
|
||||||
time(&td);
|
time(&td);
|
||||||
tm *curTime = localtime(&td);
|
tm *curTime = localtime(&td);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
mkdir(build_pathname("%s/memreports", get_localinfo("amxx_basedir", "addons/amxmodx")), 0700);
|
mkdir(build_pathname("%s/memreports", get_localinfo("amxx_basedir", "addons/amxmodx")), 0700);
|
||||||
|
@ -826,8 +846,10 @@ void C_StartFrame_Post(void)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_dumpMemoryReport(build_pathname("%s/r%03d.txt", g_memreport_dir.c_str(), g_memreport_count));
|
m_dumpMemoryReport(build_pathname("%s/r%03d.txt", g_memreport_dir.c_str(), g_memreport_count));
|
||||||
AMXXLOG_Log("Memreport #%d created (file \"%s/r%03d.txt\") (interval %f)", g_memreport_count + 1, g_memreport_dir.c_str(), g_memreport_count, MEMREPORT_INTERVAL);
|
AMXXLOG_Log("Memreport #%d created (file \"%s/r%03d.txt\") (interval %f)", g_memreport_count + 1, g_memreport_dir.c_str(), g_memreport_count, MEMREPORT_INTERVAL);
|
||||||
|
|
||||||
g_memreport_count++;
|
g_memreport_count++;
|
||||||
}
|
}
|
||||||
#endif // MEMORY_TEST
|
#endif // MEMORY_TEST
|
||||||
|
@ -836,7 +858,6 @@ void C_StartFrame_Post(void)
|
||||||
RETURN_META(MRES_IGNORED);
|
RETURN_META(MRES_IGNORED);
|
||||||
|
|
||||||
g_task_time = gpGlobals->time + 0.1f;
|
g_task_time = gpGlobals->time + 0.1f;
|
||||||
|
|
||||||
g_tasksMngr.startFrame();
|
g_tasksMngr.startFrame();
|
||||||
|
|
||||||
// Dispatch client cvar queries
|
// Dispatch client cvar queries
|
||||||
|
@ -870,6 +891,7 @@ void C_MessageBegin_Post(int msg_dest, int msg_type, const float *pOrigin, edict
|
||||||
int *z = (int*)ptr + 0x16C;
|
int *z = (int*)ptr + 0x16C;
|
||||||
#endif
|
#endif
|
||||||
int stop = (int)ed->v.armorvalue;
|
int stop = (int)ed->v.armorvalue;
|
||||||
|
|
||||||
*z = stop;
|
*z = stop;
|
||||||
ed->v.armorvalue = (float)stop;
|
ed->v.armorvalue = (float)stop;
|
||||||
}
|
}
|
||||||
|
@ -885,8 +907,9 @@ void C_MessageBegin_Post(int msg_dest, int msg_type, const float *pOrigin, edict
|
||||||
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);
|
||||||
|
@ -970,6 +993,7 @@ void C_ChangeLevel(char* s1, char* s2)
|
||||||
{
|
{
|
||||||
int retVal = 0;
|
int retVal = 0;
|
||||||
char *map = s1;
|
char *map = s1;
|
||||||
|
|
||||||
retVal = executeForwards(FF_ChangeLevel, map);
|
retVal = executeForwards(FF_ChangeLevel, map);
|
||||||
|
|
||||||
if (retVal)
|
if (retVal)
|
||||||
|
@ -1054,9 +1078,9 @@ void C_AlertMessage_Post(ALERT_TYPE atype, char *szFmt, ...)
|
||||||
if (g_logevents.logEventsExist() || FF_PluginLog >= 0)
|
if (g_logevents.logEventsExist() || FF_PluginLog >= 0)
|
||||||
{
|
{
|
||||||
va_list logArgPtr;
|
va_list logArgPtr;
|
||||||
va_start (logArgPtr, szFmt);
|
va_start(logArgPtr, szFmt);
|
||||||
g_logevents.setLogString(szFmt, logArgPtr);
|
g_logevents.setLogString(szFmt, logArgPtr);
|
||||||
va_end (logArgPtr);
|
va_end(logArgPtr);
|
||||||
g_logevents.parseLogString();
|
g_logevents.parseLogString();
|
||||||
|
|
||||||
if (g_logevents.logEventsExist())
|
if (g_logevents.logEventsExist())
|
||||||
|
@ -1107,14 +1131,15 @@ bool m_NeedsP = false;
|
||||||
|
|
||||||
C_DLLEXPORT int Meta_Query(char *ifvers, plugin_info_t **pPlugInfo, mutil_funcs_t *pMetaUtilFuncs)
|
C_DLLEXPORT int Meta_Query(char *ifvers, plugin_info_t **pPlugInfo, mutil_funcs_t *pMetaUtilFuncs)
|
||||||
{
|
{
|
||||||
gpMetaUtilFuncs=pMetaUtilFuncs;
|
gpMetaUtilFuncs = pMetaUtilFuncs;
|
||||||
*pPlugInfo=&Plugin_info;
|
*pPlugInfo = &Plugin_info;
|
||||||
|
|
||||||
if (strcmp(ifvers, Plugin_info.ifvers))
|
if (strcmp(ifvers, Plugin_info.ifvers))
|
||||||
{
|
{
|
||||||
int mmajor = 0, mminor = 0, pmajor = 0, pminor = 0;
|
int mmajor = 0, mminor = 0, pmajor = 0, pminor = 0;
|
||||||
|
|
||||||
LOG_MESSAGE(PLID, "WARNING: meta-interface version mismatch; requested=%s ours=%s", Plugin_info.logtag, ifvers);
|
LOG_MESSAGE(PLID, "WARNING: meta-interface version mismatch; requested=%s ours=%s", Plugin_info.logtag, ifvers);
|
||||||
|
|
||||||
sscanf(ifvers, "%d:%d", &mmajor, &mminor);
|
sscanf(ifvers, "%d:%d", &mmajor, &mminor);
|
||||||
sscanf(META_INTERFACE_VERSION, "%d:%d", &pmajor, &pminor);
|
sscanf(META_INTERFACE_VERSION, "%d:%d", &pmajor, &pminor);
|
||||||
|
|
||||||
|
@ -1203,7 +1228,7 @@ C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now, META_FUNCTIONS *pFunctionTable, m
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
gpMetaGlobals=pMGlobals;
|
gpMetaGlobals = pMGlobals;
|
||||||
gMetaFunctionTable.pfnGetEntityAPI2 = GetEntityAPI2;
|
gMetaFunctionTable.pfnGetEntityAPI2 = GetEntityAPI2;
|
||||||
gMetaFunctionTable.pfnGetEntityAPI2_Post = GetEntityAPI2_Post;
|
gMetaFunctionTable.pfnGetEntityAPI2_Post = GetEntityAPI2_Post;
|
||||||
gMetaFunctionTable.pfnGetEngineFunctions = GetEngineFunctions;
|
gMetaFunctionTable.pfnGetEngineFunctions = GetEngineFunctions;
|
||||||
|
@ -1222,7 +1247,9 @@ C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now, META_FUNCTIONS *pFunctionTable, m
|
||||||
CVAR_REGISTER(&init_amxmodx_version);
|
CVAR_REGISTER(&init_amxmodx_version);
|
||||||
CVAR_REGISTER(&init_amxmodx_modules);
|
CVAR_REGISTER(&init_amxmodx_modules);
|
||||||
CVAR_REGISTER(&init_amxmodx_debug);
|
CVAR_REGISTER(&init_amxmodx_debug);
|
||||||
|
|
||||||
amxmodx_version = CVAR_GET_POINTER(init_amxmodx_version.name);
|
amxmodx_version = CVAR_GET_POINTER(init_amxmodx_version.name);
|
||||||
|
|
||||||
REG_SVR_COMMAND("amxx", amx_command);
|
REG_SVR_COMMAND("amxx", amx_command);
|
||||||
|
|
||||||
char gameDir[512];
|
char gameDir[512];
|
||||||
|
@ -1236,9 +1263,7 @@ C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now, META_FUNCTIONS *pFunctionTable, m
|
||||||
|
|
||||||
g_mod_name.assign(a);
|
g_mod_name.assign(a);
|
||||||
|
|
||||||
if (g_mod_name.compare("cstrike") == 0 ||
|
if (g_mod_name.compare("cstrike") == 0 || g_mod_name.compare("czero") == 0 || g_mod_name.compare("dod") == 0)
|
||||||
g_mod_name.compare("czero") == 0 ||
|
|
||||||
g_mod_name.compare("dod") == 0)
|
|
||||||
g_coloredmenus = true;
|
g_coloredmenus = true;
|
||||||
else
|
else
|
||||||
g_coloredmenus = false;
|
g_coloredmenus = false;
|
||||||
|
@ -1499,9 +1524,7 @@ C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable, int *in
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef FAKEMETA
|
#ifdef FAKEMETA
|
||||||
|
|
||||||
NEW_DLL_FUNCTIONS gNewDLLFunctionTable_Post;
|
NEW_DLL_FUNCTIONS gNewDLLFunctionTable_Post;
|
||||||
C_DLLEXPORT int GetNewDLLFunctions_Post(NEW_DLL_FUNCTIONS *pNewFunctionTable, int *interfaceVersion)
|
C_DLLEXPORT int GetNewDLLFunctions_Post(NEW_DLL_FUNCTIONS *pNewFunctionTable, int *interfaceVersion)
|
||||||
{
|
{
|
||||||
|
@ -1509,5 +1532,4 @@ C_DLLEXPORT int GetNewDLLFunctions_Post(NEW_DLL_FUNCTIONS *pNewFunctionTable, in
|
||||||
memcpy(pNewFunctionTable, &gNewDLLFunctionTable_Post, sizeof(NEW_DLL_FUNCTIONS));
|
memcpy(pNewFunctionTable, &gNewDLLFunctionTable_Post, sizeof(NEW_DLL_FUNCTIONS));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
#undef DLLEXPORT
|
#undef DLLEXPORT
|
||||||
#ifndef __linux__
|
#ifndef __linux__
|
||||||
#define DLLEXPORT __declspec(dllexport)
|
#define DLLEXPORT __declspec(dllexport)
|
||||||
#else
|
#else
|
||||||
#define DLLEXPORT
|
#define DLLEXPORT
|
||||||
#define WINAPI
|
#define WINAPI
|
||||||
|
|
|
@ -37,6 +37,7 @@ void ClearMenus()
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < g_NewMenus.size(); i++)
|
for (size_t i = 0; i < g_NewMenus.size(); i++)
|
||||||
delete g_NewMenus[i];
|
delete g_NewMenus[i];
|
||||||
|
|
||||||
g_NewMenus.clear();
|
g_NewMenus.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,6 +52,7 @@ Menu::~Menu()
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < m_Items.size(); i++)
|
for (size_t i = 0; i < m_Items.size(); i++)
|
||||||
delete m_Items[i];
|
delete m_Items[i];
|
||||||
|
|
||||||
m_Items.clear();
|
m_Items.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,6 +112,7 @@ int Menu::PagekeyToItem(page_t page, item_t key)
|
||||||
if (page == 0)
|
if (page == 0)
|
||||||
{
|
{
|
||||||
item_t rem = numItems >= 7 ? 7 : numItems;
|
item_t rem = numItems >= 7 ? 7 : numItems;
|
||||||
|
|
||||||
if (key == rem)
|
if (key == rem)
|
||||||
{
|
{
|
||||||
if (pages > 1)
|
if (pages > 1)
|
||||||
|
@ -188,6 +191,7 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
|
||||||
_snprintf(buffer, sizeof(buffer)-1, "\\y%s %d/%d\n\\w\n", m_Title.c_str(), page + 1, pages);
|
_snprintf(buffer, sizeof(buffer)-1, "\\y%s %d/%d\n\\w\n", m_Title.c_str(), page + 1, pages);
|
||||||
else
|
else
|
||||||
_snprintf(buffer, sizeof(buffer)-1, "%s %d/%d\n\n", m_Title.c_str(), page + 1, pages);
|
_snprintf(buffer, sizeof(buffer)-1, "%s %d/%d\n\n", m_Title.c_str(), page + 1, pages);
|
||||||
|
|
||||||
m_Text.append(buffer);
|
m_Text.append(buffer);
|
||||||
|
|
||||||
item_t start = page * 7;
|
item_t start = page * 7;
|
||||||
|
@ -200,15 +204,19 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
|
||||||
}
|
}
|
||||||
|
|
||||||
menuitem *pItem = NULL;
|
menuitem *pItem = NULL;
|
||||||
|
|
||||||
int option = 0;
|
int option = 0;
|
||||||
keys = 0;
|
keys = 0;
|
||||||
bool enabled = true;
|
bool enabled = true;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
for (item_t i = start; i < end; i++)
|
for (item_t i = start; i < end; i++)
|
||||||
{
|
{
|
||||||
pItem = m_Items[i];
|
pItem = m_Items[i];
|
||||||
|
|
||||||
if (pItem->access && !(pItem->access & g_players[player].flags[0]))
|
if (pItem->access && !(pItem->access & g_players[player].flags[0]))
|
||||||
enabled = false;
|
enabled = false;
|
||||||
|
|
||||||
if (pItem->handler != -1)
|
if (pItem->handler != -1)
|
||||||
{
|
{
|
||||||
ret = executeForwards(pItem->handler, player, thisId, i);
|
ret = executeForwards(pItem->handler, player, thisId, i);
|
||||||
|
@ -217,6 +225,7 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
|
||||||
else if (ret == ITEM_DISABLED)
|
else if (ret == ITEM_DISABLED)
|
||||||
enabled = false;
|
enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pItem->pfn)
|
if (pItem->pfn)
|
||||||
{
|
{
|
||||||
ret = (pItem->pfn)(player, thisId, i);
|
ret = (pItem->pfn)(player, thisId, i);
|
||||||
|
@ -225,6 +234,7 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
|
||||||
else if (ret == ITEM_DISABLED)
|
else if (ret == ITEM_DISABLED)
|
||||||
enabled = false;
|
enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enabled)
|
if (enabled)
|
||||||
{
|
{
|
||||||
keys |= (1<<option);
|
keys |= (1<<option);
|
||||||
|
@ -240,6 +250,7 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
|
||||||
}
|
}
|
||||||
m_Text.append(buffer);
|
m_Text.append(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
//now for a weird part >:o
|
//now for a weird part >:o
|
||||||
//this will either be MORE or BACK..
|
//this will either be MORE or BACK..
|
||||||
keys |= (1<<option++);
|
keys |= (1<<option++);
|
||||||
|
@ -249,7 +260,9 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
|
||||||
} else {
|
} else {
|
||||||
_snprintf(buffer, sizeof(buffer)-1, "%d. %s\n", option, "Exit");
|
_snprintf(buffer, sizeof(buffer)-1, "%d. %s\n", option, "Exit");
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Text.append(buffer);
|
m_Text.append(buffer);
|
||||||
|
|
||||||
if (pages > 1)
|
if (pages > 1)
|
||||||
{
|
{
|
||||||
keys |= (1<<option++);
|
keys |= (1<<option++);
|
||||||
|
@ -279,6 +292,7 @@ static cell AMX_NATIVE_CALL menu_create(AMX *amx, cell *params)
|
||||||
char *handler = get_amxstring(amx, params[2], 1, len);
|
char *handler = get_amxstring(amx, params[2], 1, len);
|
||||||
|
|
||||||
int func = registerSPForwardByName(amx, handler, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
|
int func = registerSPForwardByName(amx, handler, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
|
||||||
|
|
||||||
if (func == -1)
|
if (func == -1)
|
||||||
{
|
{
|
||||||
LogError(amx, AMX_ERR_NOTFOUND, "Invalid function \"%s\"", handler);
|
LogError(amx, AMX_ERR_NOTFOUND, "Invalid function \"%s\"", handler);
|
||||||
|
@ -286,7 +300,7 @@ static cell AMX_NATIVE_CALL menu_create(AMX *amx, cell *params)
|
||||||
}
|
}
|
||||||
|
|
||||||
int id = g_menucmds.registerMenuId(title, amx);
|
int id = g_menucmds.registerMenuId(title, amx);
|
||||||
g_menucmds.registerMenuCmd( g_plugins.findPluginFast(amx), id, 1023, func );
|
g_menucmds.registerMenuCmd(g_plugins.findPluginFast(amx), id, 1023, func);
|
||||||
|
|
||||||
Menu *pMenu = new Menu(title, id, (int)g_NewMenus.size());
|
Menu *pMenu = new Menu(title, id, (int)g_NewMenus.size());
|
||||||
g_NewMenus.push_back(pMenu);
|
g_NewMenus.push_back(pMenu);
|
||||||
|
@ -403,54 +417,54 @@ static cell AMX_NATIVE_CALL menu_makecallback(AMX *amx, cell *params)
|
||||||
|
|
||||||
static cell AMX_NATIVE_CALL menu_item_setname(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL menu_item_setname(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
GETMENU(params[1]);
|
GETMENU(params[1]);
|
||||||
|
|
||||||
menuitem *pItem = pMenu->GetMenuItem(static_cast<item_t>(params[2]));
|
menuitem *pItem = pMenu->GetMenuItem(static_cast<item_t>(params[2]));
|
||||||
|
|
||||||
if (!pItem)
|
if (!pItem)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int len;
|
int len;
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
name = get_amxstring(amx, params[3], 0, len);
|
name = get_amxstring(amx, params[3], 0, len);
|
||||||
|
|
||||||
pItem->name.assign(name);
|
pItem->name.assign(name);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cell AMX_NATIVE_CALL menu_item_setcmd(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL menu_item_setcmd(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
GETMENU(params[1]);
|
GETMENU(params[1]);
|
||||||
|
|
||||||
menuitem *pItem = pMenu->GetMenuItem(static_cast<item_t>(params[2]));
|
menuitem *pItem = pMenu->GetMenuItem(static_cast<item_t>(params[2]));
|
||||||
|
|
||||||
if (!pItem)
|
if (!pItem)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int len;
|
int len;
|
||||||
char *cmd;
|
char *cmd;
|
||||||
|
|
||||||
cmd = get_amxstring(amx, params[3], 0, len);
|
cmd = get_amxstring(amx, params[3], 0, len);
|
||||||
|
|
||||||
pItem->cmd.assign(cmd);
|
pItem->cmd.assign(cmd);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cell AMX_NATIVE_CALL menu_item_setcall(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL menu_item_setcall(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
GETMENU(params[1]);
|
GETMENU(params[1]);
|
||||||
|
|
||||||
menuitem *pItem = pMenu->GetMenuItem(static_cast<item_t>(params[2]));
|
menuitem *pItem = pMenu->GetMenuItem(static_cast<item_t>(params[2]));
|
||||||
|
|
||||||
if (!pItem)
|
if (!pItem)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
pItem->handler = params[3];
|
pItem->handler = params[3];
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
AMX_NATIVE_INFO g_NewMenuNatives[] =
|
AMX_NATIVE_INFO g_NewMenuNatives[] =
|
||||||
|
|
|
@ -47,8 +47,10 @@ struct menuitem
|
||||||
{
|
{
|
||||||
String name;
|
String name;
|
||||||
String cmd;
|
String cmd;
|
||||||
|
|
||||||
int access;
|
int access;
|
||||||
int handler;
|
int handler;
|
||||||
|
|
||||||
MENUITEM_CALLBACK pfn;
|
MENUITEM_CALLBACK pfn;
|
||||||
size_t id;
|
size_t id;
|
||||||
};
|
};
|
||||||
|
@ -62,18 +64,23 @@ class Menu
|
||||||
public:
|
public:
|
||||||
Menu(const char *title, int menuId, int thisId);
|
Menu(const char *title, int menuId, int thisId);
|
||||||
~Menu();
|
~Menu();
|
||||||
|
|
||||||
menuitem *GetMenuItem(item_t item);
|
menuitem *GetMenuItem(item_t item);
|
||||||
size_t GetPageCount();
|
size_t GetPageCount();
|
||||||
size_t GetItemCount();
|
size_t GetItemCount();
|
||||||
menuitem *AddItem(const char *name, const char *cmd, int access);
|
menuitem *AddItem(const char *name, const char *cmd, int access);
|
||||||
|
|
||||||
const char *GetTextString(int player, page_t page, int &keys);
|
const char *GetTextString(int player, page_t page, int &keys);
|
||||||
bool Display(int player, page_t page);
|
bool Display(int player, page_t page);
|
||||||
|
|
||||||
int PagekeyToItem(page_t page, item_t key);
|
int PagekeyToItem(page_t page, item_t key);
|
||||||
int GetMenuMenuid();
|
int GetMenuMenuid();
|
||||||
private:
|
private:
|
||||||
CVector<menuitem * > m_Items;
|
CVector<menuitem * > m_Items;
|
||||||
|
|
||||||
String m_Title;
|
String m_Title;
|
||||||
String m_Text;
|
String m_Text;
|
||||||
|
|
||||||
int menuId;
|
int menuId;
|
||||||
int thisId;
|
int thisId;
|
||||||
};
|
};
|
||||||
|
|
|
@ -107,7 +107,6 @@ void copy_amxmemory(cell* dest, cell* src, int len)
|
||||||
*dest++=*src++;
|
*dest++=*src++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char* parse_arg(char** line, int& state)
|
char* parse_arg(char** line, int& state)
|
||||||
{
|
{
|
||||||
static char arg[3072];
|
static char arg[3072];
|
||||||
|
@ -150,9 +149,11 @@ char* parse_arg(char** line, int& state)
|
||||||
static cell AMX_NATIVE_CALL replace(AMX *amx, cell *params) /* 4 param */
|
static cell AMX_NATIVE_CALL replace(AMX *amx, cell *params) /* 4 param */
|
||||||
{
|
{
|
||||||
static char buffor[3072];
|
static char buffor[3072];
|
||||||
|
|
||||||
cell *a = get_amxaddr(amx, params[1]);
|
cell *a = get_amxaddr(amx, params[1]);
|
||||||
cell *b = get_amxaddr(amx, params[3]);
|
cell *b = get_amxaddr(amx, params[3]);
|
||||||
cell *c = get_amxaddr(amx, params[4]);
|
cell *c = get_amxaddr(amx, params[4]);
|
||||||
|
|
||||||
int iMain = amxstring_len(a);
|
int iMain = amxstring_len(a);
|
||||||
int iWhat = amxstring_len(b);
|
int iWhat = amxstring_len(b);
|
||||||
int iWith = amxstring_len(c);
|
int iWith = amxstring_len(c);
|
||||||
|
@ -264,6 +265,7 @@ static cell AMX_NATIVE_CALL numtostr(AMX *amx, cell *params) /* 3 param */
|
||||||
{
|
{
|
||||||
char szTemp[32];
|
char szTemp[32];
|
||||||
sprintf(szTemp, "%d", (int)params[1]);
|
sprintf(szTemp, "%d", (int)params[1]);
|
||||||
|
|
||||||
return set_amxstring(amx, params[2], szTemp, params[3]);
|
return set_amxstring(amx, params[2], szTemp, params[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,6 +330,7 @@ static cell AMX_NATIVE_CALL float_to_str(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
char szTemp[32];
|
char szTemp[32];
|
||||||
sprintf(szTemp, "%f", amx_ctof(params[1]));
|
sprintf(szTemp, "%f", amx_ctof(params[1]));
|
||||||
|
|
||||||
return set_amxstring(amx, params[2], szTemp, params[3]);
|
return set_amxstring(amx, params[2], szTemp, params[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -408,7 +411,7 @@ static cell AMX_NATIVE_CALL equal(AMX *amx, cell *params) /* 3 param */
|
||||||
{
|
{
|
||||||
while (--c && *a && (*a == *b))
|
while (--c && *a && (*a == *b))
|
||||||
++a, ++b;
|
++a, ++b;
|
||||||
return (*a-*b)?0:1;
|
return (*a-*b) ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -511,6 +514,7 @@ int fo_numargs(AMX *amx)
|
||||||
{
|
{
|
||||||
unsigned char *data = amx->base + (int)((AMX_HEADER *)amx->base)->dat;
|
unsigned char *data = amx->base + (int)((AMX_HEADER *)amx->base)->dat;
|
||||||
cell bytes= *(cell *)(data + (int)amx->frm + 2 * sizeof(cell));
|
cell bytes= *(cell *)(data + (int)amx->frm + 2 * sizeof(cell));
|
||||||
|
|
||||||
return (int)(bytes / sizeof(cell));
|
return (int)(bytes / sizeof(cell));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -518,6 +522,7 @@ int fo_getargnum(AMX *amx, int pos)
|
||||||
{
|
{
|
||||||
unsigned char *data = amx->base + (int)((AMX_HEADER *)amx->base)->dat;
|
unsigned char *data = amx->base + (int)((AMX_HEADER *)amx->base)->dat;
|
||||||
cell value = *(cell *)(data + (int)amx->frm + (pos + 3) * sizeof(cell));
|
cell value = *(cell *)(data + (int)amx->frm + (pos + 3) * sizeof(cell));
|
||||||
|
|
||||||
return *(cell *)(data + (int)value);
|
return *(cell *)(data + (int)value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -526,6 +531,7 @@ float fo_getargfloat(AMX *amx, int pos)
|
||||||
unsigned char *data = amx->base + (int)((AMX_HEADER *)amx->base)->dat;
|
unsigned char *data = amx->base + (int)((AMX_HEADER *)amx->base)->dat;
|
||||||
cell value = *(cell *)(data + (int)amx->frm + (pos + 3) * sizeof(cell));
|
cell value = *(cell *)(data + (int)amx->frm + (pos + 3) * sizeof(cell));
|
||||||
cell number = *(cell *)(data + (int)value);
|
cell number = *(cell *)(data + (int)value);
|
||||||
|
|
||||||
return *(REAL *)((void *)&number);
|
return *(REAL *)((void *)&number);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -577,7 +583,7 @@ char* format_arguments(AMX *amx, int parm, int& len)
|
||||||
|
|
||||||
switch (*(ptr - 1))
|
switch (*(ptr - 1))
|
||||||
{
|
{
|
||||||
case 's': sprintf(arg, format, fo_getargstr(amx, 1, parm++)); break;
|
case 's': sprintf(arg, format, fo_getargstr(amx, 1, parm++)); break;
|
||||||
case 'f': case 'g': sprintf(arg, format, fo_getargfloat(amx, parm++)); break;
|
case 'f': case 'g': sprintf(arg, format, fo_getargfloat(amx, parm++)); break;
|
||||||
default: sprintf(arg, format, fo_getargnum(amx, parm++));
|
default: sprintf(arg, format, fo_getargnum(amx, parm++));
|
||||||
}
|
}
|
||||||
|
@ -741,6 +747,7 @@ static cell AMX_NATIVE_CALL format_args(AMX *amx, cell *params)
|
||||||
}
|
}
|
||||||
|
|
||||||
char* string = format_arguments(amx, pos, len); // indexed from 0
|
char* string = format_arguments(amx, pos, len); // indexed from 0
|
||||||
|
|
||||||
return set_amxstring(amx, params[1], string, params[2]);
|
return set_amxstring(amx, params[1], string, params[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -878,37 +885,37 @@ static cell AMX_NATIVE_CALL n_strfind(AMX *amx, cell *params)
|
||||||
|
|
||||||
AMX_NATIVE_INFO string_Natives[] =
|
AMX_NATIVE_INFO string_Natives[] =
|
||||||
{
|
{
|
||||||
{"add", add},
|
{"add", add},
|
||||||
{"contain", contain},
|
{"contain", contain},
|
||||||
{"containi", containi},
|
{"containi", containi},
|
||||||
{"copy", copy},
|
{"copy", copy},
|
||||||
{"copyc", copyc},
|
{"copyc", copyc},
|
||||||
{"equal", equal},
|
{"equal", equal},
|
||||||
{"equali", equali},
|
{"equali", equali},
|
||||||
{"format", format},
|
{"format", format},
|
||||||
{"format_args", format_args},
|
{"format_args", format_args},
|
||||||
{"isdigit", is_digit},
|
{"isdigit", is_digit},
|
||||||
{"isalnum", is_alnum},
|
{"isalnum", is_alnum},
|
||||||
{"isspace", is_space},
|
{"isspace", is_space},
|
||||||
{"isalpha", is_alpha},
|
{"isalpha", is_alpha},
|
||||||
{"num_to_str", numtostr},
|
{"num_to_str", numtostr},
|
||||||
{"numtostr", numtostr},
|
{"numtostr", numtostr},
|
||||||
{"parse", parse},
|
{"parse", parse},
|
||||||
{"replace", replace},
|
{"replace", replace},
|
||||||
{"setc", setc},
|
{"setc", setc},
|
||||||
{"strbreak", strbreak},
|
{"strbreak", strbreak},
|
||||||
{"strtolower", strtolower},
|
{"strtolower", strtolower},
|
||||||
{"strtoupper", strtoupper},
|
{"strtoupper", strtoupper},
|
||||||
{"str_to_num", strtonum},
|
{"str_to_num", strtonum},
|
||||||
{"strtonum", strtonum},
|
{"strtonum", strtonum},
|
||||||
{"trim", amx_trim},
|
{"trim", amx_trim},
|
||||||
{"ucfirst", amx_ucfirst},
|
{"ucfirst", amx_ucfirst},
|
||||||
{"strtok", amx_strtok},
|
{"strtok", amx_strtok},
|
||||||
{"strlen", amx_strlen},
|
{"strlen", amx_strlen},
|
||||||
{"strcat", n_strcat},
|
{"strcat", n_strcat},
|
||||||
{"strfind", n_strfind},
|
{"strfind", n_strfind},
|
||||||
{"strcmp", n_strcmp},
|
{"strcmp", n_strcmp},
|
||||||
{"str_to_float", str_to_float},
|
{"str_to_float", str_to_float},
|
||||||
{"float_to_str", float_to_str},
|
{"float_to_str", float_to_str},
|
||||||
{NULL, NULL }
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
|
@ -159,7 +159,7 @@ void UTIL_IntToString(int value, char *output)
|
||||||
{
|
{
|
||||||
aaa += sprintf(&output[aaa], words[tho]);
|
aaa += sprintf(&output[aaa], words[tho]);
|
||||||
aaa += sprintf(&output[aaa], words[29]);
|
aaa += sprintf(&output[aaa], words[29]);
|
||||||
value = value % 1000;
|
value = value % 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
int hun = value / 100;
|
int hun = value / 100;
|
||||||
|
@ -168,7 +168,7 @@ void UTIL_IntToString(int value, char *output)
|
||||||
{
|
{
|
||||||
aaa += sprintf(&output[aaa], words[hun]);
|
aaa += sprintf(&output[aaa], words[hun]);
|
||||||
aaa += sprintf(&output[aaa], words[28]);
|
aaa += sprintf(&output[aaa], words[28]);
|
||||||
value = value % 100;
|
value = value % 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ten = value / 10;
|
int ten = value / 10;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user