final cleaned revision (I hope)
This commit is contained in:
parent
4b1769f457
commit
ebd4974c75
|
@ -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:
|
||||||
|
@ -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);
|
||||||
};
|
};
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,11 +142,13 @@ 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;
|
||||||
|
|
|
@ -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!
|
//Push the parameters in reverse order. Weird, unfriendly part of Small 3.0!
|
||||||
for (i = m_NumParams-1; i >= 0; i--)
|
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);
|
||||||
}
|
}
|
||||||
|
@ -190,6 +197,7 @@ cell CForward::execute(cell *params, ForwardPreparedArray *preparedArrays)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -453,70 +477,93 @@ void CForwardMngr::unregisterSPForward(int id)
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -550,10 +602,13 @@ cell CForwardMngr::prepareArray(void *ptr, unsigned int size, ForwardArrayElemTy
|
||||||
#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
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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;
|
||||||
};
|
};
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -111,6 +113,7 @@ public:
|
||||||
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:
|
||||||
|
@ -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());
|
||||||
}
|
}
|
||||||
|
@ -71,7 +73,10 @@ LogEventsMngr::CLogCmp* LogEventsMngr::registerCondition(char* 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,7 +193,9 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
||||||
|
@ -101,6 +104,7 @@ public:
|
||||||
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,9 +112,12 @@ 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();
|
||||||
|
@ -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]; }
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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();
|
||||||
|
@ -174,13 +175,14 @@ class ForceObject
|
||||||
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,6 +199,7 @@ class XVars
|
||||||
};
|
};
|
||||||
|
|
||||||
XVarEle* head;
|
XVarEle* head;
|
||||||
|
|
||||||
int size;
|
int size;
|
||||||
int num;
|
int num;
|
||||||
int realloc_array(int nsize);
|
int realloc_array(int nsize);
|
||||||
|
@ -204,6 +207,7 @@ class XVars
|
||||||
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);
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
|
|
@ -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
|
||||||
|
@ -106,6 +108,7 @@ public:
|
||||||
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)
|
||||||
|
@ -70,6 +76,7 @@ void CPluginMngr::Finalize()
|
||||||
}
|
}
|
||||||
a = a->next;
|
a = a->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Finalized = true;
|
m_Finalized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,12 +101,16 @@ int CPluginMngr::loadPluginsFromFile( const char* filename )
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
@ -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,32 +154,48 @@ 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)
|
while (a && &a->amx != amx)
|
||||||
a = a->next;
|
a = a->next;
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
CPluginMngr::CPlugin* CPluginMngr::findPlugin(int index){
|
CPluginMngr::CPlugin* CPluginMngr::findPlugin(int index)
|
||||||
|
{
|
||||||
CPlugin*a = head;
|
CPlugin*a = head;
|
||||||
|
|
||||||
while (a && index--)
|
while (a && index--)
|
||||||
a = a->next;
|
a = a->next;
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
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))
|
while (a && strncmp(a->name.c_str(), name, len))
|
||||||
a = a->next;
|
a = a->next;
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* CPluginMngr::CPlugin::getStatus() const {
|
const char* CPluginMngr::CPlugin::getStatus() const
|
||||||
switch(status){
|
{
|
||||||
|
switch (status)
|
||||||
|
{
|
||||||
case ps_running:
|
case ps_running:
|
||||||
{
|
{
|
||||||
if (m_Debug)
|
if (m_Debug)
|
||||||
|
@ -180,33 +211,41 @@ const char* CPluginMngr::CPlugin::getStatus() const {
|
||||||
case ps_stopped: return "stopped";
|
case ps_stopped: return "stopped";
|
||||||
case ps_locked: return "locked";
|
case ps_locked: return "locked";
|
||||||
}
|
}
|
||||||
|
|
||||||
return "error";
|
return "error";
|
||||||
}
|
}
|
||||||
|
|
||||||
CPluginMngr::CPlugin::CPlugin(int i, const char* p,const char* n, char* e, int d) : name(n), title(n) {
|
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;
|
||||||
|
@ -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,6 +340,7 @@ 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());
|
||||||
|
@ -313,7 +355,8 @@ void CPluginMngr::CPlugin::unpauseFunction( int id )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPluginMngr::CPlugin::setStatus( int a ) {
|
void CPluginMngr::CPlugin::setStatus(int a)
|
||||||
|
{
|
||||||
status = a;
|
status = a;
|
||||||
g_commands.clearBufforedInfo(); // ugly way
|
g_commands.clearBufforedInfo(); // ugly way
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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();
|
||||||
};
|
};
|
||||||
|
|
|
@ -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);
|
||||||
|
@ -62,13 +63,17 @@ public:
|
||||||
// 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
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -32,7 +32,6 @@
|
||||||
#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>
|
||||||
|
@ -109,6 +108,7 @@ 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);
|
||||||
|
@ -116,6 +116,7 @@ void UTIL_HudMessage(edict_t *pEntity, const hudtextparms_t &textparms, char *pM
|
||||||
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, ...);
|
||||||
|
|
||||||
|
|
||||||
|
@ -123,13 +124,15 @@ char *UTIL_VarArgs(const char *fmt, ...);
|
||||||
//#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;
|
String fullName;
|
||||||
short int iId;
|
short int iId;
|
||||||
short int ammoSlot;
|
short int ammoSlot;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct fakecmd_t {
|
struct fakecmd_t
|
||||||
|
{
|
||||||
char args[256];
|
char args[256];
|
||||||
const char *argv[3];
|
const char *argv[3];
|
||||||
int argc;
|
int argc;
|
||||||
|
@ -230,6 +233,7 @@ 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
|
||||||
|
@ -252,11 +256,13 @@ 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, ...);
|
||||||
|
@ -279,6 +285,7 @@ enum ModuleCallReason
|
||||||
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();
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
@ -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,17 +47,20 @@ 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();
|
||||||
|
@ -65,6 +68,7 @@ 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,11 +76,12 @@ 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();
|
||||||
};
|
};
|
||||||
|
@ -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,10 +158,7 @@ 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),
|
|
||||||
m_Handling(false), m_InNativeFilter(false)
|
|
||||||
{ };
|
|
||||||
~Handler() {};
|
~Handler() {};
|
||||||
public:
|
public:
|
||||||
int SetErrorHandler(const char *function);
|
int SetErrorHandler(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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -364,6 +388,7 @@ static cell AMX_NATIVE_CALL amx_fopen(AMX *amx, cell *params)
|
||||||
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;
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -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];
|
||||||
|
@ -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
|
||||||
|
@ -494,7 +501,9 @@ 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.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")));
|
||||||
g_langMngr.Clear();
|
g_langMngr.Clear();
|
||||||
|
@ -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
|
||||||
|
@ -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,9 +734,10 @@ 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)
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -887,6 +909,7 @@ void C_MessageBegin_Post(int msg_dest, int msg_type, const float *pOrigin, edict
|
||||||
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)
|
||||||
|
@ -1115,6 +1139,7 @@ C_DLLEXPORT int Meta_Query(char *ifvers, plugin_info_t **pPlugInfo, mutil_funcs_
|
||||||
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);
|
||||||
|
|
||||||
|
@ -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
|
|
@ -35,6 +35,7 @@
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include "sclinux.h"
|
#include "sclinux.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "amxmodx.h"
|
#include "amxmodx.h"
|
||||||
#include "osdep.h" // sleep, etc
|
#include "osdep.h" // sleep, etc
|
||||||
#include "CFile.h"
|
#include "CFile.h"
|
||||||
|
@ -48,6 +49,7 @@ CList<CModule,const char*> g_modules;
|
||||||
CList<CScript, AMX*> g_loadedscripts;
|
CList<CScript, AMX*> g_loadedscripts;
|
||||||
|
|
||||||
CModule *g_CurrentlyCalledModule = NULL; // The module we are in at the moment; NULL otherwise
|
CModule *g_CurrentlyCalledModule = NULL; // The module we are in at the moment; NULL otherwise
|
||||||
|
|
||||||
// also NULL for non-amxx modules
|
// also NULL for non-amxx modules
|
||||||
// This is needed so we know which module called a function
|
// This is needed so we know which module called a function
|
||||||
ModuleCallReason g_ModuleCallReason;
|
ModuleCallReason g_ModuleCallReason;
|
||||||
|
@ -63,12 +65,12 @@ void report_error( int code, char* fmt, ... )
|
||||||
vsnprintf(string, 255, fmt, argptr);
|
vsnprintf(string, 255, fmt, argptr);
|
||||||
string[255] = 0;
|
string[255] = 0;
|
||||||
va_end(argptr);
|
va_end(argptr);
|
||||||
if ( *string ) {
|
|
||||||
|
if (*string)
|
||||||
|
{
|
||||||
AMXXLOG_Log("Error:");
|
AMXXLOG_Log("Error:");
|
||||||
AMXXLOG_Log(string);
|
AMXXLOG_Log(string);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
AMXXLOG_Log("!!! There was an unexpected module error.");
|
AMXXLOG_Log("!!! There was an unexpected module error.");
|
||||||
AMXXLOG_Log("The server may not work correctly.");
|
AMXXLOG_Log("The server may not work correctly.");
|
||||||
}
|
}
|
||||||
|
@ -82,6 +84,7 @@ void print_srvconsole( char *fmt, ... )
|
||||||
vsnprintf(string, sizeof(string) - 1, fmt, argptr);
|
vsnprintf(string, sizeof(string) - 1, fmt, argptr);
|
||||||
string[sizeof(string) - 1] = '\0';
|
string[sizeof(string) - 1] = '\0';
|
||||||
va_end(argptr);
|
va_end(argptr);
|
||||||
|
|
||||||
SERVER_PRINT(string);
|
SERVER_PRINT(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,17 +104,21 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
|
||||||
{
|
{
|
||||||
*error = 0;
|
*error = 0;
|
||||||
CAmxxReader reader(filename, PAWN_CELL_SIZE / 8);
|
CAmxxReader reader(filename, PAWN_CELL_SIZE / 8);
|
||||||
|
|
||||||
if (reader.GetStatus() == CAmxxReader::Err_None)
|
if (reader.GetStatus() == CAmxxReader::Err_None)
|
||||||
{
|
{
|
||||||
size_t bufSize = reader.GetBufferSize();
|
size_t bufSize = reader.GetBufferSize();
|
||||||
|
|
||||||
if (bufSize != 0)
|
if (bufSize != 0)
|
||||||
{
|
{
|
||||||
*program = (void*) (new char[bufSize]);
|
*program = (void*) (new char[bufSize]);
|
||||||
|
|
||||||
if (!*program)
|
if (!*program)
|
||||||
{
|
{
|
||||||
strcpy(error, "Failed to allocate memory");
|
strcpy(error, "Failed to allocate memory");
|
||||||
return (amx->error = AMX_ERR_MEMORY);
|
return (amx->error = AMX_ERR_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
reader.GetSection(*program);
|
reader.GetSection(*program);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -152,6 +159,7 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
|
||||||
AMX_HEADER *hdr = (AMX_HEADER*)*program;
|
AMX_HEADER *hdr = (AMX_HEADER*)*program;
|
||||||
uint16_t magic = hdr->magic;
|
uint16_t magic = hdr->magic;
|
||||||
amx_Align16(&magic);
|
amx_Align16(&magic);
|
||||||
|
|
||||||
if (magic != AMX_MAGIC)
|
if (magic != AMX_MAGIC)
|
||||||
{
|
{
|
||||||
strcpy(error, "Invalid Plugin");
|
strcpy(error, "Invalid Plugin");
|
||||||
|
@ -161,7 +169,6 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
|
||||||
int err;
|
int err;
|
||||||
memset(amx, 0, sizeof(*amx));
|
memset(amx, 0, sizeof(*amx));
|
||||||
bool will_be_debugged = false;
|
bool will_be_debugged = false;
|
||||||
|
|
||||||
tagAMX_DBG *pDbg = NULL;
|
tagAMX_DBG *pDbg = NULL;
|
||||||
|
|
||||||
if ((int)CVAR_GET_FLOAT("amx_debug") >= 2 || debug)
|
if ((int)CVAR_GET_FLOAT("amx_debug") >= 2 || debug)
|
||||||
|
@ -170,10 +177,14 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
|
||||||
{
|
{
|
||||||
sprintf(error, "Plugin needs newer debug version info");
|
sprintf(error, "Plugin needs newer debug version info");
|
||||||
return (amx->error = AMX_ERR_VERSION);
|
return (amx->error = AMX_ERR_VERSION);
|
||||||
} else if ((hdr->flags & AMX_FLAG_DEBUG) != 0) {
|
}
|
||||||
|
else if ((hdr->flags & AMX_FLAG_DEBUG) != 0)
|
||||||
|
{
|
||||||
will_be_debugged = true;
|
will_be_debugged = true;
|
||||||
|
|
||||||
char *addr = (char *)hdr + hdr->size;
|
char *addr = (char *)hdr + hdr->size;
|
||||||
pDbg = new tagAMX_DBG;
|
pDbg = new tagAMX_DBG;
|
||||||
|
|
||||||
memset(pDbg, 0, sizeof(AMX_DBG));
|
memset(pDbg, 0, sizeof(AMX_DBG));
|
||||||
|
|
||||||
int err = dbg_LoadInfo(pDbg, addr);
|
int err = dbg_LoadInfo(pDbg, addr);
|
||||||
|
@ -205,6 +216,7 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
|
||||||
dbg_FreeInfo(pDbg);
|
dbg_FreeInfo(pDbg);
|
||||||
delete pDbg;
|
delete pDbg;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(error, "Load error %d (invalid file format or version)", err);
|
sprintf(error, "Load error %d (invalid file format or version)", err);
|
||||||
return (amx->error = AMX_ERR_INIT);
|
return (amx->error = AMX_ERR_INIT);
|
||||||
}
|
}
|
||||||
|
@ -234,11 +246,13 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
|
||||||
{
|
{
|
||||||
char *np = new char[amx->code_size];
|
char *np = new char[amx->code_size];
|
||||||
char *rt = new char[amx->reloc_size];
|
char *rt = new char[amx->reloc_size];
|
||||||
|
|
||||||
if (!np || (!rt && amx->reloc_size > 0))
|
if (!np || (!rt && amx->reloc_size > 0))
|
||||||
{
|
{
|
||||||
delete[] np;
|
delete[] np;
|
||||||
delete[] rt;
|
delete[] rt;
|
||||||
strcpy(error, "Failed to initialize JIT'd plugin");
|
strcpy(error, "Failed to initialize JIT'd plugin");
|
||||||
|
|
||||||
return (amx->error = AMX_ERR_INIT);
|
return (amx->error = AMX_ERR_INIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,25 +268,29 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
|
||||||
#endif
|
#endif
|
||||||
if (amx->base)
|
if (amx->base)
|
||||||
memcpy(amx->base, np, amx->code_size);
|
memcpy(amx->base, np, amx->code_size);
|
||||||
|
|
||||||
delete[] np;
|
delete[] np;
|
||||||
delete[] rt;
|
delete[] rt;
|
||||||
|
|
||||||
char *prg = (char *)(*program);
|
char *prg = (char *)(*program);
|
||||||
|
|
||||||
delete[] prg;
|
delete[] prg;
|
||||||
(*program) = amx->base;
|
(*program) = amx->base;
|
||||||
if ( *program == 0 ){
|
|
||||||
|
if (*program == 0)
|
||||||
|
{
|
||||||
strcpy(error, "Failed to allocate memory");
|
strcpy(error, "Failed to allocate memory");
|
||||||
return (amx->error = AMX_ERR_MEMORY);
|
return (amx->error = AMX_ERR_MEMORY);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
delete[] np;
|
delete[] np;
|
||||||
delete[] rt;
|
delete[] rt;
|
||||||
|
|
||||||
sprintf(error, "Failed to initialize plugin (%d)", err);
|
sprintf(error, "Failed to initialize plugin (%d)", err);
|
||||||
|
|
||||||
return (amx->error = AMX_ERR_INIT_JIT);
|
return (amx->error = AMX_ERR_INIT_JIT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CScript* aa = new CScript(amx, *program, filename);
|
CScript* aa = new CScript(amx, *program, filename);
|
||||||
|
@ -290,6 +308,7 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
|
||||||
if (g_plugins.m_Finalized)
|
if (g_plugins.m_Finalized)
|
||||||
{
|
{
|
||||||
amx_Register(amx, g_plugins.pNatives, -1);
|
amx_Register(amx, g_plugins.pNatives, -1);
|
||||||
|
|
||||||
if (CheckModules(amx, error))
|
if (CheckModules(amx, error))
|
||||||
{
|
{
|
||||||
if (amx_Register(amx, core_Natives, -1) != AMX_ERR_NONE)
|
if (amx_Register(amx, core_Natives, -1) != AMX_ERR_NONE)
|
||||||
|
@ -319,6 +338,7 @@ const char *StrCaseStr(const char *as, const char *bs)
|
||||||
{
|
{
|
||||||
a[i] = tolower(as[i]);
|
a[i] = tolower(as[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
a[len] = 0;
|
a[len] = 0;
|
||||||
|
|
||||||
len = strlen(bs);
|
len = strlen(bs);
|
||||||
|
@ -330,6 +350,7 @@ const char *StrCaseStr(const char *as, const char *bs)
|
||||||
{
|
{
|
||||||
b[i] = tolower(bs[i]);
|
b[i] = tolower(bs[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
b[len] = 0;
|
b[len] = 0;
|
||||||
|
|
||||||
return strstr(a, b);
|
return strstr(a, b);
|
||||||
|
@ -340,35 +361,40 @@ int CheckModules(AMX *amx, char error[128])
|
||||||
{
|
{
|
||||||
int numLibraries = amx_GetLibraries(amx);
|
int numLibraries = amx_GetLibraries(amx);
|
||||||
char buffer[32];
|
char buffer[32];
|
||||||
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
bool isdbi = false;
|
bool isdbi = false;
|
||||||
|
|
||||||
CList<CModule, const char *>::iterator a;
|
CList<CModule, const char *>::iterator a;
|
||||||
|
|
||||||
const amxx_module_info_s *info;
|
const amxx_module_info_s *info;
|
||||||
|
|
||||||
Handler *pHandler = (Handler *)amx->userdata[UD_HANDLER];
|
Handler *pHandler = (Handler *)amx->userdata[UD_HANDLER];
|
||||||
|
|
||||||
for (int i = 0; i < numLibraries; i++)
|
for (int i = 0; i < numLibraries; i++)
|
||||||
{
|
{
|
||||||
amx_GetLibrary(amx, i, buffer, sizeof(buffer) - 1);
|
amx_GetLibrary(amx, i, buffer, sizeof(buffer) - 1);
|
||||||
found = false;
|
found = false;
|
||||||
|
|
||||||
if (stricmp(buffer, "float") == 0)
|
if (stricmp(buffer, "float") == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
isdbi = false;
|
isdbi = false;
|
||||||
|
|
||||||
if (stricmp(buffer, "dbi") == 0)
|
if (stricmp(buffer, "dbi") == 0)
|
||||||
isdbi = true;
|
isdbi = true;
|
||||||
|
|
||||||
for (a = g_modules.begin(); a; ++a)
|
for (a = g_modules.begin(); a; ++a)
|
||||||
{
|
{
|
||||||
if ((*a).getStatusValue() == MODULE_LOADED)
|
if ((*a).getStatusValue() == MODULE_LOADED)
|
||||||
{
|
{
|
||||||
info = (*a).getInfoNew();
|
info = (*a).getInfoNew();
|
||||||
|
|
||||||
if (info)
|
if (info)
|
||||||
{
|
{
|
||||||
if (isdbi)
|
if (isdbi)
|
||||||
{
|
{
|
||||||
if (info->logtag
|
if (info->logtag && (StrCaseStr(info->logtag, "sql") || StrCaseStr(info->logtag, "dbi")))
|
||||||
&& (StrCaseStr(info->logtag, "sql")
|
|
||||||
||
|
|
||||||
StrCaseStr(info->logtag, "dbi"))
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
|
@ -383,13 +409,16 @@ int CheckModules(AMX *amx, char error[128])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
found = LibraryExists(buffer);
|
found = LibraryExists(buffer);
|
||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
{
|
{
|
||||||
if (pHandler->HandleModule(buffer))
|
if (pHandler->HandleModule(buffer))
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
{
|
{
|
||||||
sprintf(error, "Module \"%s\" required for plugin. Check modules.ini.", buffer);
|
sprintf(error, "Module \"%s\" required for plugin. Check modules.ini.", buffer);
|
||||||
|
@ -404,8 +433,7 @@ int set_amxnatives(AMX* amx,char error[128])
|
||||||
{
|
{
|
||||||
for (CList<CModule, const char *>::iterator a = g_modules.begin(); a ; ++a)
|
for (CList<CModule, const char *>::iterator a = g_modules.begin(); a ; ++a)
|
||||||
{
|
{
|
||||||
for( CList<AMX_NATIVE_INFO*>::iterator cc =
|
for (CList<AMX_NATIVE_INFO*>::iterator cc = (*a).m_Natives.begin(); cc; ++cc)
|
||||||
(*a).m_Natives.begin(); cc; ++cc )
|
|
||||||
amx_Register(amx, *cc, -1);
|
amx_Register(amx, *cc, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -425,6 +453,7 @@ int set_amxnatives(AMX* amx,char error[128])
|
||||||
|
|
||||||
int idx, err;
|
int idx, err;
|
||||||
cell retval;
|
cell retval;
|
||||||
|
|
||||||
if (amx_FindPublic(amx, "plugin_natives", &idx) == AMX_ERR_NONE)
|
if (amx_FindPublic(amx, "plugin_natives", &idx) == AMX_ERR_NONE)
|
||||||
{
|
{
|
||||||
if ((err = amx_Exec(amx, &retval, idx)) != AMX_ERR_NONE)
|
if ((err = amx_Exec(amx, &retval, idx)) != AMX_ERR_NONE)
|
||||||
|
@ -442,17 +471,25 @@ int set_amxnatives(AMX* amx,char error[128])
|
||||||
int unload_amxscript(AMX* amx, void** program)
|
int unload_amxscript(AMX* amx, void** program)
|
||||||
{
|
{
|
||||||
int flags = amx->flags;
|
int flags = amx->flags;
|
||||||
|
|
||||||
Debugger *pDebugger = (Debugger *)amx->userdata[UD_DEBUGGER];
|
Debugger *pDebugger = (Debugger *)amx->userdata[UD_DEBUGGER];
|
||||||
if (pDebugger)
|
if (pDebugger)
|
||||||
delete pDebugger;
|
delete pDebugger;
|
||||||
|
|
||||||
Handler *pHandler = (Handler *)amx->userdata[UD_HANDLER];
|
Handler *pHandler = (Handler *)amx->userdata[UD_HANDLER];
|
||||||
if (pHandler)
|
if (pHandler)
|
||||||
delete pHandler;
|
delete pHandler;
|
||||||
|
|
||||||
CList<CScript, AMX*>::iterator a = g_loadedscripts.find(amx);
|
CList<CScript, AMX*>::iterator a = g_loadedscripts.find(amx);
|
||||||
if ( a ) a.remove();
|
|
||||||
|
if (a)
|
||||||
|
a.remove();
|
||||||
|
|
||||||
char *prg = (char *)*program;
|
char *prg = (char *)*program;
|
||||||
|
|
||||||
if (!prg)
|
if (!prg)
|
||||||
return AMX_ERR_NONE;
|
return AMX_ERR_NONE;
|
||||||
|
|
||||||
#if defined JIT
|
#if defined JIT
|
||||||
#if defined __linux__
|
#if defined __linux__
|
||||||
if ((flags & AMX_FLAG_JITC) != AMX_FLAG_JITC)
|
if ((flags & AMX_FLAG_JITC) != AMX_FLAG_JITC)
|
||||||
|
@ -468,10 +505,13 @@ int unload_amxscript(AMX* amx, void** program)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#elif defined WIN32
|
#elif defined WIN32
|
||||||
|
|
||||||
if ((flags & AMX_FLAG_JITC) != AMX_FLAG_JITC)
|
if ((flags & AMX_FLAG_JITC) != AMX_FLAG_JITC)
|
||||||
{
|
{
|
||||||
delete [] prg;
|
delete [] prg;
|
||||||
} else if (!VirtualFree((LPVOID)prg, 0, MEM_RELEASE)) {
|
}
|
||||||
|
else if (!VirtualFree((LPVOID)prg, 0, MEM_RELEASE))
|
||||||
|
{
|
||||||
AMXXLOG_Log("[AMXX] Could not free plugin memory, failure %d.", GetLastError());
|
AMXXLOG_Log("[AMXX] Could not free plugin memory, failure %d.", GetLastError());
|
||||||
return AMX_ERR_PARAMS;
|
return AMX_ERR_PARAMS;
|
||||||
}
|
}
|
||||||
|
@ -487,13 +527,18 @@ int unload_amxscript(AMX* amx, void** program)
|
||||||
AMX* get_amxscript(int id, void** code, const char** filename)
|
AMX* get_amxscript(int id, void** code, const char** filename)
|
||||||
{
|
{
|
||||||
CList<CScript, AMX*>::iterator a = g_loadedscripts.begin();
|
CList<CScript, AMX*>::iterator a = g_loadedscripts.begin();
|
||||||
|
|
||||||
while (a && id--)
|
while (a && id--)
|
||||||
++a;
|
++a;
|
||||||
if ( a ){
|
|
||||||
|
if (a)
|
||||||
|
{
|
||||||
*filename = (*a).getName();
|
*filename = (*a).getName();
|
||||||
*code = (*a).getCode();
|
*code = (*a).getCode();
|
||||||
|
|
||||||
return (*a).getAMX();
|
return (*a).getAMX();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -511,11 +556,8 @@ void get_modname(char* buffer )
|
||||||
char* build_pathname(char *fmt, ...)
|
char* build_pathname(char *fmt, ...)
|
||||||
{
|
{
|
||||||
static char string[256];
|
static char string[256];
|
||||||
|
|
||||||
int b;
|
int b;
|
||||||
|
|
||||||
int a = b = snprintf(string, 255,
|
int a = b = snprintf(string, 255,
|
||||||
|
|
||||||
#ifndef __linux__
|
#ifndef __linux__
|
||||||
"%s\\",
|
"%s\\",
|
||||||
#else
|
#else
|
||||||
|
@ -552,8 +594,7 @@ char *build_pathname_r(char *buffer, size_t maxlen, char *fmt, ...)
|
||||||
#else
|
#else
|
||||||
"%s\\",
|
"%s\\",
|
||||||
#endif
|
#endif
|
||||||
g_mod_name.c_str()
|
g_mod_name.c_str());
|
||||||
);
|
|
||||||
|
|
||||||
size_t len = strlen(buffer);
|
size_t len = strlen(buffer);
|
||||||
char *ptr = buffer + len;
|
char *ptr = buffer + len;
|
||||||
|
@ -576,7 +617,6 @@ char *build_pathname_r(char *buffer, size_t maxlen, char *fmt, ...)
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// build pathname based on addons dir
|
// build pathname based on addons dir
|
||||||
char* build_pathname_addons(char *fmt, ...)
|
char* build_pathname_addons(char *fmt, ...)
|
||||||
{
|
{
|
||||||
|
@ -605,6 +645,7 @@ char* build_pathname_addons(char *fmt, ... )
|
||||||
bool validFile(const char* file)
|
bool validFile(const char* file)
|
||||||
{
|
{
|
||||||
const char* a = 0;
|
const char* a = 0;
|
||||||
|
|
||||||
while (*file)
|
while (*file)
|
||||||
if (*file++ == '.')
|
if (*file++ == '.')
|
||||||
a = file;
|
a = file;
|
||||||
|
@ -619,6 +660,7 @@ void ConvertModuleName(const char *pathString, String &path)
|
||||||
{
|
{
|
||||||
#if PAWN_CELL_SIZE==64
|
#if PAWN_CELL_SIZE==64
|
||||||
char *ptr = strstr(pathString, "i386");
|
char *ptr = strstr(pathString, "i386");
|
||||||
|
|
||||||
if (ptr)
|
if (ptr)
|
||||||
{
|
{
|
||||||
//attempt to fix the binary name
|
//attempt to fix the binary name
|
||||||
|
@ -627,6 +669,7 @@ void ConvertModuleName(const char *pathString, String &path)
|
||||||
path.append("amd64.so");
|
path.append("amd64.so");
|
||||||
} else {
|
} else {
|
||||||
ptr = strstr(pathString, ".dll");
|
ptr = strstr(pathString, ".dll");
|
||||||
|
|
||||||
if (ptr)
|
if (ptr)
|
||||||
{
|
{
|
||||||
*ptr = 0;
|
*ptr = 0;
|
||||||
|
@ -634,6 +677,7 @@ void ConvertModuleName(const char *pathString, String &path)
|
||||||
path.append("_amd64.so");
|
path.append("_amd64.so");
|
||||||
} else {
|
} else {
|
||||||
ptr = strstr(pathString, ".so");
|
ptr = strstr(pathString, ".so");
|
||||||
|
|
||||||
if (ptr)
|
if (ptr)
|
||||||
{
|
{
|
||||||
path.assign(pathString);
|
path.assign(pathString);
|
||||||
|
@ -645,8 +689,10 @@ void ConvertModuleName(const char *pathString, String &path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
char *ptr = strstr(pathString, "amd64");
|
char *ptr = strstr(pathString, "amd64");
|
||||||
|
|
||||||
if (ptr)
|
if (ptr)
|
||||||
{
|
{
|
||||||
//attempt to fix the binary name
|
//attempt to fix the binary name
|
||||||
|
@ -655,6 +701,7 @@ void ConvertModuleName(const char *pathString, String &path)
|
||||||
path.append("i386.so");
|
path.append("i386.so");
|
||||||
} else {
|
} else {
|
||||||
ptr = strstr(pathString, ".dll");
|
ptr = strstr(pathString, ".dll");
|
||||||
|
|
||||||
if (ptr)
|
if (ptr)
|
||||||
{
|
{
|
||||||
*ptr = 0;
|
*ptr = 0;
|
||||||
|
@ -663,6 +710,7 @@ void ConvertModuleName(const char *pathString, String &path)
|
||||||
} else {
|
} else {
|
||||||
//check to see if this file even has an extension
|
//check to see if this file even has an extension
|
||||||
ptr = strstr(pathString, ".so");
|
ptr = strstr(pathString, ".so");
|
||||||
|
|
||||||
if (ptr)
|
if (ptr)
|
||||||
{
|
{
|
||||||
path.assign(pathString);
|
path.assign(pathString);
|
||||||
|
@ -674,15 +722,18 @@ void ConvertModuleName(const char *pathString, String &path)
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
char *ptr = strstr(pathString, ".dll");
|
char *ptr = strstr(pathString, ".dll");
|
||||||
|
|
||||||
if (ptr)
|
if (ptr)
|
||||||
{
|
{
|
||||||
path.assign(pathString);
|
path.assign(pathString);
|
||||||
} else {
|
} else {
|
||||||
//prevent this from loading .so too
|
//prevent this from loading .so too
|
||||||
ptr = strstr(pathString, ".so");
|
ptr = strstr(pathString, ".so");
|
||||||
|
|
||||||
if (ptr)
|
if (ptr)
|
||||||
{
|
{
|
||||||
int i = 0, len = strlen(pathString), c = -1;
|
int i = 0, len = strlen(pathString), c = -1;
|
||||||
|
|
||||||
for (i = len - 1; i >= 0; i--)
|
for (i = len - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
//cut off at first _
|
//cut off at first _
|
||||||
|
@ -691,11 +742,13 @@ void ConvertModuleName(const char *pathString, String &path)
|
||||||
//make sure this is a valid _
|
//make sure this is a valid _
|
||||||
if (i == len - 1 || strncmp(&(pathString[i + 1]), "amxx", 4) == 0)
|
if (i == len - 1 || strncmp(&(pathString[i + 1]), "amxx", 4) == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
c = i;
|
c = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*ptr = 0;
|
*ptr = 0;
|
||||||
|
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
{
|
{
|
||||||
path.assign(pathString);
|
path.assign(pathString);
|
||||||
|
@ -736,14 +789,16 @@ int loadModules(const char* filename, PLUG_LOADTIME now)
|
||||||
{
|
{
|
||||||
if (!line._fread(fp) || line.size() < 1)
|
if (!line._fread(fp) || line.size() < 1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
line.trim();
|
line.trim();
|
||||||
*moduleName = 0;
|
*moduleName = 0;
|
||||||
|
|
||||||
if (sscanf(line.c_str(), "%s", moduleName) == EOF)
|
if (sscanf(line.c_str(), "%s", moduleName) == EOF)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (moduleName[0] == ';')
|
if (moduleName[0] == ';')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
||||||
char* pathname = build_pathname("%s/%s", get_localinfo("amxx_modulesdir", "addons/amxmodx/modules"), moduleName);
|
char* pathname = build_pathname("%s/%s", get_localinfo("amxx_modulesdir", "addons/amxmodx/modules"), moduleName);
|
||||||
strcpy(pathString, pathname);
|
strcpy(pathString, pathname);
|
||||||
|
|
||||||
|
@ -756,7 +811,8 @@ int loadModules(const char* filename, PLUG_LOADTIME now)
|
||||||
|
|
||||||
CList<CModule, const char *>::iterator a = g_modules.find(path.c_str());
|
CList<CModule, const char *>::iterator a = g_modules.find(path.c_str());
|
||||||
|
|
||||||
if ( a ) continue; // already loaded
|
if (a)
|
||||||
|
continue; // already loaded
|
||||||
|
|
||||||
CModule* cc = new CModule(path.c_str());
|
CModule* cc = new CModule(path.c_str());
|
||||||
|
|
||||||
|
@ -768,7 +824,8 @@ int loadModules(const char* filename, PLUG_LOADTIME now)
|
||||||
|
|
||||||
cc->queryModule();
|
cc->queryModule();
|
||||||
|
|
||||||
switch( cc->getStatusValue() ) {
|
switch (cc->getStatusValue())
|
||||||
|
{
|
||||||
case MODULE_BADLOAD:
|
case MODULE_BADLOAD:
|
||||||
report_error(1, "[AMXX] Module is not a valid library (file \"%s\")", path.c_str());
|
report_error(1, "[AMXX] Module is not a valid library (file \"%s\")", path.c_str());
|
||||||
break;
|
break;
|
||||||
|
@ -803,11 +860,13 @@ int loadModules(const char* filename, PLUG_LOADTIME now)
|
||||||
if (cc->IsMetamod())
|
if (cc->IsMetamod())
|
||||||
{
|
{
|
||||||
char* mmpathname = build_pathname_addons("%s/%s", get_localinfo("amxx_modulesdir", "addons/amxmodx/modules"), line.c_str());
|
char* mmpathname = build_pathname_addons("%s/%s", get_localinfo("amxx_modulesdir", "addons/amxmodx/modules"), line.c_str());
|
||||||
|
|
||||||
ConvertModuleName(mmpathname, path);
|
ConvertModuleName(mmpathname, path);
|
||||||
cc->attachMetamod(path.c_str(), now);
|
cc->attachMetamod(path.c_str(), now);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool retVal = cc->attachModule();
|
bool retVal = cc->attachModule();
|
||||||
|
|
||||||
if (cc->isAmxx() && !retVal)
|
if (cc->isAmxx() && !retVal)
|
||||||
{
|
{
|
||||||
switch (cc->getStatusValue())
|
switch (cc->getStatusValue())
|
||||||
|
@ -859,12 +918,11 @@ void detachReloadModules()
|
||||||
{
|
{
|
||||||
(*a).detachModule();
|
(*a).detachModule();
|
||||||
a.remove();
|
a.remove();
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
++a;
|
++a;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef FAKEMETA
|
#ifdef FAKEMETA
|
||||||
|
@ -875,6 +933,7 @@ void attachModules()
|
||||||
while (a)
|
while (a)
|
||||||
{
|
{
|
||||||
bool retVal = (*a).attachModule();
|
bool retVal = (*a).attachModule();
|
||||||
|
|
||||||
if ((*a).isAmxx() && !retVal)
|
if ((*a).isAmxx() && !retVal)
|
||||||
{
|
{
|
||||||
switch ((*a).getStatusValue())
|
switch ((*a).getStatusValue())
|
||||||
|
@ -893,7 +952,6 @@ void attachModules()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
++a;
|
++a;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -902,13 +960,17 @@ void attachModules()
|
||||||
const char* strip_name(const char* a)
|
const char* strip_name(const char* a)
|
||||||
{
|
{
|
||||||
const char* ret = a;
|
const char* ret = a;
|
||||||
while(*a){
|
|
||||||
if ( *a== '/' || *a=='\\' ){
|
while (*a)
|
||||||
|
{
|
||||||
|
if (*a == '/' || *a == '\\')
|
||||||
|
{
|
||||||
ret = ++a;
|
ret = ++a;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
++a;
|
++a;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -972,17 +1034,18 @@ void attachMetaModModules(PLUG_LOADTIME now, const char* filename)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_FakeMeta.Meta_Query(gpMetaUtilFuncs);
|
g_FakeMeta.Meta_Query(gpMetaUtilFuncs);
|
||||||
g_FakeMeta.Meta_Attach(now, gpMetaGlobals, gpGamedllFuncs);
|
g_FakeMeta.Meta_Attach(now, gpMetaGlobals, gpGamedllFuncs);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Get the number of running modules
|
// Get the number of running modules
|
||||||
int countModules(CountModulesMode mode)
|
int countModules(CountModulesMode mode)
|
||||||
{
|
{
|
||||||
CList<CModule, const char *>::iterator iter;
|
CList<CModule, const char *>::iterator iter;
|
||||||
int num;
|
int num;
|
||||||
|
|
||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
case CountModules_All:
|
case CountModules_All:
|
||||||
|
@ -990,24 +1053,29 @@ int countModules(CountModulesMode mode)
|
||||||
case CountModules_Running:
|
case CountModules_Running:
|
||||||
iter = g_modules.begin();
|
iter = g_modules.begin();
|
||||||
num = 0;
|
num = 0;
|
||||||
|
|
||||||
while (iter)
|
while (iter)
|
||||||
{
|
{
|
||||||
if ((*iter).getStatusValue() == MODULE_LOADED)
|
if ((*iter).getStatusValue() == MODULE_LOADED)
|
||||||
++num;
|
++num;
|
||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
return num;
|
return num;
|
||||||
case CountModules_Stopped:
|
case CountModules_Stopped:
|
||||||
iter = g_modules.begin();
|
iter = g_modules.begin();
|
||||||
num = 0;
|
num = 0;
|
||||||
|
|
||||||
while (iter)
|
while (iter)
|
||||||
{
|
{
|
||||||
if ((*iter).getStatusValue() != MODULE_LOADED)
|
if ((*iter).getStatusValue() != MODULE_LOADED)
|
||||||
++num;
|
++num;
|
||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1015,6 +1083,7 @@ int countModules(CountModulesMode mode)
|
||||||
void modules_callPluginsLoaded()
|
void modules_callPluginsLoaded()
|
||||||
{
|
{
|
||||||
CList<CModule, const char *>::iterator iter = g_modules.begin();
|
CList<CModule, const char *>::iterator iter = g_modules.begin();
|
||||||
|
|
||||||
while (iter)
|
while (iter)
|
||||||
{
|
{
|
||||||
(*iter).CallPluginsLoaded();
|
(*iter).CallPluginsLoaded();
|
||||||
|
@ -1023,7 +1092,6 @@ void modules_callPluginsLoaded()
|
||||||
}
|
}
|
||||||
|
|
||||||
// new functions
|
// new functions
|
||||||
|
|
||||||
int MNF_AddNatives(AMX_NATIVE_INFO* natives)
|
int MNF_AddNatives(AMX_NATIVE_INFO* natives)
|
||||||
{
|
{
|
||||||
CList<CModule, const char *>::iterator a = g_modules.begin();
|
CList<CModule, const char *>::iterator a = g_modules.begin();
|
||||||
|
@ -1037,6 +1105,7 @@ int MNF_AddNatives(AMX_NATIVE_INFO* natives)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
g_CurrentlyCalledModule->m_Natives.put(pPtr);
|
g_CurrentlyCalledModule->m_Natives.put(pPtr);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1055,22 +1124,26 @@ const char *MNF_GetModname(void)
|
||||||
AMX *MNF_GetAmxScript(int id)
|
AMX *MNF_GetAmxScript(int id)
|
||||||
{
|
{
|
||||||
CList<CScript, AMX*>::iterator iter = g_loadedscripts.begin();
|
CList<CScript, AMX*>::iterator iter = g_loadedscripts.begin();
|
||||||
|
|
||||||
while (iter && id--)
|
while (iter && id--)
|
||||||
++iter;
|
++iter;
|
||||||
|
|
||||||
if (iter == NULL)
|
if (iter == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return (*iter).getAMX();
|
return (*iter).getAMX();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *MNF_GetAmxScriptName(int id)
|
const char *MNF_GetAmxScriptName(int id)
|
||||||
{
|
{
|
||||||
CList<CScript, AMX*>::iterator iter = g_loadedscripts.begin();
|
CList<CScript, AMX*>::iterator iter = g_loadedscripts.begin();
|
||||||
|
|
||||||
while (iter && id--)
|
while (iter && id--)
|
||||||
++iter;
|
++iter;
|
||||||
|
|
||||||
if (iter == NULL)
|
if (iter == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return (*iter).getName();
|
return (*iter).getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1079,6 +1152,7 @@ int MNF_FindAmxScriptByName(const char *name)
|
||||||
CList<CScript, AMX*>::iterator iter = g_loadedscripts.begin();
|
CList<CScript, AMX*>::iterator iter = g_loadedscripts.begin();
|
||||||
bool found = false;
|
bool found = false;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
while (iter)
|
while (iter)
|
||||||
{
|
{
|
||||||
if (stricmp((*iter).getName(), name) == 0)
|
if (stricmp((*iter).getName(), name) == 0)
|
||||||
|
@ -1089,8 +1163,10 @@ int MNF_FindAmxScriptByName(const char *name)
|
||||||
++iter;
|
++iter;
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1099,7 +1175,9 @@ int MNF_FindAmxScriptByAmx(const AMX *amx)
|
||||||
CList<CScript, AMX*>::iterator iter = g_loadedscripts.begin();
|
CList<CScript, AMX*>::iterator iter = g_loadedscripts.begin();
|
||||||
bool found = false;
|
bool found = false;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
while (iter)
|
while (iter)
|
||||||
|
|
||||||
{
|
{
|
||||||
if (amx == (*iter).getAMX())
|
if (amx == (*iter).getAMX())
|
||||||
{
|
{
|
||||||
|
@ -1109,8 +1187,10 @@ int MNF_FindAmxScriptByAmx(const AMX *amx)
|
||||||
++iter;
|
++iter;
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1118,16 +1198,20 @@ char *MNF_GetAmxString(AMX *amx, cell amx_addr, int bufferId, int *pLen)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
char *retVal = get_amxstring(amx, amx_addr, bufferId, len);
|
char *retVal = get_amxstring(amx, amx_addr, bufferId, len);
|
||||||
|
|
||||||
if (pLen)
|
if (pLen)
|
||||||
*pLen = len;
|
*pLen = len;
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MNF_GetAmxStringLen(const cell *ptr)
|
int MNF_GetAmxStringLen(const cell *ptr)
|
||||||
{
|
{
|
||||||
register int c = 0;
|
register int c = 0;
|
||||||
|
|
||||||
while (ptr[c])
|
while (ptr[c])
|
||||||
++c;
|
++c;
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1135,8 +1219,10 @@ char *MNF_FormatAmxString(AMX *amx, cell *params, int startParam, int *pLen)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
char *retVal = format_amxstring(amx, params, startParam, len);
|
char *retVal = format_amxstring(amx, params, startParam, len);
|
||||||
|
|
||||||
if (pLen)
|
if (pLen)
|
||||||
*pLen = len;
|
*pLen = len;
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1144,7 +1230,9 @@ int MNF_GetPlayerFlags(int id)
|
||||||
{
|
{
|
||||||
if (id < 1 || id > gpGlobals->maxClients)
|
if (id < 1 || id > gpGlobals->maxClients)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
CPlayer *pPlayer = GET_PLAYER_POINTER_I(id);
|
CPlayer *pPlayer = GET_PLAYER_POINTER_I(id);
|
||||||
|
|
||||||
return (pPlayer->flags[0]);
|
return (pPlayer->flags[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1157,116 +1245,155 @@ int MNF_IsPlayerValid(int id)
|
||||||
{
|
{
|
||||||
if (id < 1 || id > gpGlobals->maxClients)
|
if (id < 1 || id > gpGlobals->maxClients)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
CPlayer *pPlayer = GET_PLAYER_POINTER_I(id);
|
CPlayer *pPlayer = GET_PLAYER_POINTER_I(id);
|
||||||
|
|
||||||
return (pPlayer->initialized) ? 1 : 0;
|
return (pPlayer->initialized) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * MNF_GetPlayerName(int id)
|
const char * MNF_GetPlayerName(int id)
|
||||||
{
|
{
|
||||||
if (id < 1 || id > gpGlobals->maxClients)
|
if (id < 1 || id > gpGlobals->maxClients)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return GET_PLAYER_POINTER_I(id)->name.c_str();
|
return GET_PLAYER_POINTER_I(id)->name.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * MNF_GetPlayerIP(int id)
|
const char * MNF_GetPlayerIP(int id)
|
||||||
{
|
{
|
||||||
if (id < 1 || id > gpGlobals->maxClients)
|
if (id < 1 || id > gpGlobals->maxClients)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return GET_PLAYER_POINTER_I(id)->ip.c_str();
|
return GET_PLAYER_POINTER_I(id)->ip.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
int MNF_IsPlayerInGame(int id)
|
int MNF_IsPlayerInGame(int id)
|
||||||
{
|
{
|
||||||
if (id < 1 || id > gpGlobals->maxClients)
|
if (id < 1 || id > gpGlobals->maxClients)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return GET_PLAYER_POINTER_I(id)->ingame ? 1 : 0;
|
return GET_PLAYER_POINTER_I(id)->ingame ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MNF_IsPlayerBot(int id)
|
int MNF_IsPlayerBot(int id)
|
||||||
{
|
{
|
||||||
if (id < 1 || id > gpGlobals->maxClients)
|
if (id < 1 || id > gpGlobals->maxClients)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return GET_PLAYER_POINTER_I(id)->IsBot() ? 1 : 0;
|
return GET_PLAYER_POINTER_I(id)->IsBot() ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MNF_IsPlayerAuthorized(int id)
|
int MNF_IsPlayerAuthorized(int id)
|
||||||
{
|
{
|
||||||
if (id < 1 || id > gpGlobals->maxClients)
|
if (id < 1 || id > gpGlobals->maxClients)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return GET_PLAYER_POINTER_I(id)->authorized ? 1 : 0;
|
return GET_PLAYER_POINTER_I(id)->authorized ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
float MNF_GetPlayerTime(int id)
|
float MNF_GetPlayerTime(int id)
|
||||||
{
|
{
|
||||||
if (id < 1 || id > gpGlobals->maxClients)
|
if (id < 1 || id > gpGlobals->maxClients)
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
|
|
||||||
return GET_PLAYER_POINTER_I(id)->time;
|
return GET_PLAYER_POINTER_I(id)->time;
|
||||||
}
|
}
|
||||||
|
|
||||||
float MNF_GetPlayerPlayTime(int id)
|
float MNF_GetPlayerPlayTime(int id)
|
||||||
{
|
{
|
||||||
if (id < 1 || id > gpGlobals->maxClients)
|
if (id < 1 || id > gpGlobals->maxClients)
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
|
|
||||||
return GET_PLAYER_POINTER_I(id)->playtime;
|
return GET_PLAYER_POINTER_I(id)->playtime;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MNF_GetPlayerCurweapon(int id)
|
int MNF_GetPlayerCurweapon(int id)
|
||||||
{
|
{
|
||||||
if (id < 1 || id > gpGlobals->maxClients)
|
if (id < 1 || id > gpGlobals->maxClients)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return GET_PLAYER_POINTER_I(id)->current;
|
return GET_PLAYER_POINTER_I(id)->current;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MNF_GetPlayerTeamID(int id)
|
int MNF_GetPlayerTeamID(int id)
|
||||||
{
|
{
|
||||||
if (id < 1 || id > gpGlobals->maxClients)
|
if (id < 1 || id > gpGlobals->maxClients)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return GET_PLAYER_POINTER_I(id)->teamId;
|
return GET_PLAYER_POINTER_I(id)->teamId;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MNF_GetPlayerDeaths(int id)
|
int MNF_GetPlayerDeaths(int id)
|
||||||
{
|
{
|
||||||
if (id < 1 || id > gpGlobals->maxClients)
|
if (id < 1 || id > gpGlobals->maxClients)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return GET_PLAYER_POINTER_I(id)->deaths;
|
return GET_PLAYER_POINTER_I(id)->deaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MNF_GetPlayerMenu(int id)
|
int MNF_GetPlayerMenu(int id)
|
||||||
{
|
{
|
||||||
if (id < 1 || id > gpGlobals->maxClients)
|
if (id < 1 || id > gpGlobals->maxClients)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return GET_PLAYER_POINTER_I(id)->menu;
|
return GET_PLAYER_POINTER_I(id)->menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MNF_GetPlayerKeys(int id)
|
int MNF_GetPlayerKeys(int id)
|
||||||
{
|
{
|
||||||
if (id < 1 || id > gpGlobals->maxClients)
|
if (id < 1 || id > gpGlobals->maxClients)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return GET_PLAYER_POINTER_I(id)->keys;
|
return GET_PLAYER_POINTER_I(id)->keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MNF_IsPlayerAlive(int id)
|
int MNF_IsPlayerAlive(int id)
|
||||||
{
|
{
|
||||||
if (id < 1 || id > gpGlobals->maxClients)
|
if (id < 1 || id > gpGlobals->maxClients)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return GET_PLAYER_POINTER_I(id)->IsAlive() ? 1 : 0;
|
return GET_PLAYER_POINTER_I(id)->IsAlive() ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
float MNF_GetPlayerFrags(int id)
|
float MNF_GetPlayerFrags(int id)
|
||||||
{
|
{
|
||||||
if (id < 1 || id > gpGlobals->maxClients)
|
if (id < 1 || id > gpGlobals->maxClients)
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
|
|
||||||
return GET_PLAYER_POINTER_I(id)->pEdict->v.frags;
|
return GET_PLAYER_POINTER_I(id)->pEdict->v.frags;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MNF_IsPlayerConnecting(int id)
|
int MNF_IsPlayerConnecting(int id)
|
||||||
{
|
{
|
||||||
if (id < 1 || id > gpGlobals->maxClients)
|
if (id < 1 || id > gpGlobals->maxClients)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
CPlayer * pPlayer = GET_PLAYER_POINTER_I(id);
|
CPlayer * pPlayer = GET_PLAYER_POINTER_I(id);
|
||||||
|
|
||||||
return (!pPlayer->ingame && pPlayer->initialized && (GETPLAYERUSERID(pPlayer->pEdict) > 0)) ? 1 : 0;
|
return (!pPlayer->ingame && pPlayer->initialized && (GETPLAYERUSERID(pPlayer->pEdict) > 0)) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MNF_IsPlayerHLTV(int id)
|
int MNF_IsPlayerHLTV(int id)
|
||||||
{
|
{
|
||||||
if (id < 1 || id > gpGlobals->maxClients)
|
if (id < 1 || id > gpGlobals->maxClients)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return (GET_PLAYER_POINTER_I(id)->pEdict->v.flags & FL_PROXY) ? 1 : 0;
|
return (GET_PLAYER_POINTER_I(id)->pEdict->v.flags & FL_PROXY) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
float MNF_GetPlayerArmor(int id)
|
float MNF_GetPlayerArmor(int id)
|
||||||
{
|
{
|
||||||
if (id < 1 || id > gpGlobals->maxClients)
|
if (id < 1 || id > gpGlobals->maxClients)
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
|
|
||||||
return (GET_PLAYER_POINTER_I(id)->pEdict->v.armorvalue);
|
return (GET_PLAYER_POINTER_I(id)->pEdict->v.armorvalue);
|
||||||
}
|
}
|
||||||
|
|
||||||
float MNF_GetPlayerHealth(int id)
|
float MNF_GetPlayerHealth(int id)
|
||||||
{
|
{
|
||||||
if (id < 1 || id > gpGlobals->maxClients)
|
if (id < 1 || id > gpGlobals->maxClients)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return (GET_PLAYER_POINTER_I(id)->pEdict->v.health);
|
return (GET_PLAYER_POINTER_I(id)->pEdict->v.health);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1288,6 +1415,7 @@ void MNF_Log(const char *fmt, ...)
|
||||||
_vsnprintf(msg, sizeof(msg) - 1, fmt, arglst);
|
_vsnprintf(msg, sizeof(msg) - 1, fmt, arglst);
|
||||||
//vsprintf(msg, fmt, arglst);
|
//vsprintf(msg, fmt, arglst);
|
||||||
va_end(arglst);
|
va_end(arglst);
|
||||||
|
|
||||||
AMXXLOG_Log("%s", msg);
|
AMXXLOG_Log("%s", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1302,6 +1430,7 @@ void LogError(AMX *amx, int err, const char *fmt, ...)
|
||||||
char msg_buffer[2048];
|
char msg_buffer[2048];
|
||||||
|
|
||||||
msg_buffer[0] = '\0';
|
msg_buffer[0] = '\0';
|
||||||
|
|
||||||
if (fmt != NULL)
|
if (fmt != NULL)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
@ -1326,6 +1455,7 @@ void LogError(AMX *amx, int err, const char *fmt, ...)
|
||||||
pHandler->SetErrorMsg(msg_buffer);
|
pHandler->SetErrorMsg(msg_buffer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//give the user a first-chance at blocking the error from displaying
|
//give the user a first-chance at blocking the error from displaying
|
||||||
if (pHandler->HandleError(fmt ? msg_buffer : NULL) != 0)
|
if (pHandler->HandleError(fmt ? msg_buffer : NULL) != 0)
|
||||||
{
|
{
|
||||||
|
@ -1339,6 +1469,7 @@ void LogError(AMX *amx, int err, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
if (fmt)
|
if (fmt)
|
||||||
AMXXLOG_Log("%s", msg_buffer);
|
AMXXLOG_Log("%s", msg_buffer);
|
||||||
|
|
||||||
Debugger::GenericMessage(amx, err);
|
Debugger::GenericMessage(amx, err);
|
||||||
AMXXLOG_Log("[AMXX] To enable debug mode, add \"debug\" after the plugin name in plugins.ini (without quotes).");
|
AMXXLOG_Log("[AMXX] To enable debug mode, add \"debug\" after the plugin name in plugins.ini (without quotes).");
|
||||||
//destroy original error code so the original is not displayed again
|
//destroy original error code so the original is not displayed again
|
||||||
|
@ -1360,6 +1491,7 @@ edict_t* MNF_GetPlayerEdict(int id)
|
||||||
{
|
{
|
||||||
if (id < 1 || id > gpGlobals->maxClients)
|
if (id < 1 || id > gpGlobals->maxClients)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return (GET_PLAYER_POINTER_I(id)->pEdict);
|
return (GET_PLAYER_POINTER_I(id)->pEdict);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1369,6 +1501,7 @@ const char *MNF_Format(const char *fmt, ...)
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
const char *retVal = g_langMngr.FormatString(fmt, ap);
|
const char *retVal = g_langMngr.FormatString(fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1412,6 +1545,7 @@ inline bool operator ==(func_s &arg1, const char *desc)
|
||||||
{
|
{
|
||||||
if (strcmp(arg1.desc, desc) == 0)
|
if (strcmp(arg1.desc, desc) == 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1536,6 +1670,7 @@ void *Module_ReqFnptr(const char *funcName)
|
||||||
{
|
{
|
||||||
// code
|
// code
|
||||||
// ^---- really? wow!
|
// ^---- really? wow!
|
||||||
|
|
||||||
if (!g_CurrentlyCalledModule)
|
if (!g_CurrentlyCalledModule)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1544,6 +1679,7 @@ void *Module_ReqFnptr(const char *funcName)
|
||||||
g_LastRequestedFunc = funcName;
|
g_LastRequestedFunc = funcName;
|
||||||
|
|
||||||
CList<func_s, const char *>::iterator iter;
|
CList<func_s, const char *>::iterator iter;
|
||||||
|
|
||||||
for (iter = g_functions.begin(); iter; ++iter)
|
for (iter = g_functions.begin(); iter; ++iter)
|
||||||
{
|
{
|
||||||
if (strcmp(funcName, iter->desc) == 0)
|
if (strcmp(funcName, iter->desc) == 0)
|
||||||
|
@ -1554,22 +1690,25 @@ void *Module_ReqFnptr(const char *funcName)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined MEMORY_TEST && !defined WIN32
|
#if !defined MEMORY_TEST && !defined WIN32
|
||||||
void * ::operator new(size_t size) {
|
void * ::operator new(size_t size)
|
||||||
|
{
|
||||||
return (calloc(1, size));
|
return (calloc(1, size));
|
||||||
}
|
}
|
||||||
|
|
||||||
void * ::operator new[](size_t size) {
|
void * ::operator new[](size_t size)
|
||||||
|
{
|
||||||
return (calloc(1, size));
|
return (calloc(1, size));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ::operator delete(void * ptr) {
|
void ::operator delete(void * ptr)
|
||||||
|
{
|
||||||
if (ptr)
|
if (ptr)
|
||||||
free(ptr);
|
free(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ::operator delete[](void * ptr) {
|
void ::operator delete[](void * ptr)
|
||||||
|
{
|
||||||
if (ptr)
|
if (ptr)
|
||||||
free(ptr);
|
free(ptr);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user