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
|
||||
{
|
||||
parent->setCmdLink(&parent->sortedlists[1], this);
|
||||
|
||||
if (!parent->registerCmdPrefix(this))
|
||||
parent->setCmdLink(&parent->clcmdlist, this, false);
|
||||
}
|
||||
|
|
|
@ -52,12 +52,14 @@ public:
|
|||
class Command
|
||||
{
|
||||
friend class CmdMngr;
|
||||
|
||||
CPluginMngr::CPlugin* plugin;
|
||||
CmdMngr* parent;
|
||||
String command;
|
||||
String argument;
|
||||
String commandline;
|
||||
String info;
|
||||
|
||||
bool listable;
|
||||
int function;
|
||||
int flags;
|
||||
|
@ -65,6 +67,7 @@ public:
|
|||
int cmdtype;
|
||||
int prefix;
|
||||
static int uniqueid;
|
||||
|
||||
Command(CPluginMngr::CPlugin* pplugin, const char* pcmd, const char* pinfo, int pflags, int pfunc, bool pviewable, CmdMngr* pparent);
|
||||
~Command();
|
||||
public:
|
||||
|
@ -80,6 +83,7 @@ public:
|
|||
inline bool isViewable() const { return listable; }
|
||||
inline int getFlags() const { return flags; }
|
||||
inline long int getId() const { return (long int)id; }
|
||||
|
||||
const char* getCmdType() const;
|
||||
void setCmdType(int a);
|
||||
};
|
||||
|
@ -123,9 +127,11 @@ public:
|
|||
// Interface
|
||||
|
||||
void registerPrefix(const char* nn);
|
||||
|
||||
Command* registerCommand(CPluginMngr::CPlugin* plugin, int func, char* cmd, char* info, int level, bool listable);
|
||||
Command* getCmd(long int id, int type, int access);
|
||||
int getCmdNum(int type, int access);
|
||||
|
||||
void clearBufforedInfo();
|
||||
void clear();
|
||||
|
||||
|
@ -156,6 +162,7 @@ private:
|
|||
int buf_cmdid;
|
||||
int buf_cmdtype;
|
||||
int buf_cmdaccess;
|
||||
|
||||
iterator buf_cmdptr;
|
||||
|
||||
int buf_id;
|
||||
|
|
|
@ -135,7 +135,6 @@ EventsMngr::~EventsMngr()
|
|||
clearEvents();
|
||||
}
|
||||
|
||||
|
||||
CPluginMngr::CPlugin * EventsMngr::ClEvent::getPlugin()
|
||||
{
|
||||
return m_Plugin;
|
||||
|
@ -311,6 +310,7 @@ void EventsMngr::parseValue(int iValue)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (anyConditions && !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;
|
||||
}
|
||||
|
||||
if (execute)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (anyConditions && !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 (strstr(sz, condIter->sValue.c_str())) execute = true; break;
|
||||
}
|
||||
|
||||
if (execute)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (anyConditions && !execute)
|
||||
(*iter).m_Done = true; // don't execute
|
||||
}
|
||||
|
|
|
@ -142,11 +142,13 @@ public:
|
|||
// Interface
|
||||
|
||||
ClEvent* registerEvent(CPluginMngr::CPlugin* plugin, int func, int flags, int msgid);
|
||||
|
||||
void parserInit(int msg_type, float* timer, CPlayer* pPlayer, int index);
|
||||
void parseValue(int iValue);
|
||||
void parseValue(float fValue);
|
||||
void parseValue(const char *sz);
|
||||
void executeEvents();
|
||||
|
||||
int getArgNum() const; //{ return (parsePos + 1); }
|
||||
const char* getArgString(int a) const;
|
||||
int getArgInteger(int a) const;
|
||||
|
|
|
@ -43,13 +43,17 @@ class File
|
|||
public:
|
||||
File(const char* n, const char* m);
|
||||
~File();
|
||||
|
||||
operator bool () const;
|
||||
|
||||
friend File& operator<<(File& f, const String& n);
|
||||
friend File& operator<<(File& f, const char* n);
|
||||
friend File& operator<<(File& f, const char& c);
|
||||
friend File& operator<<(File& f, int n);
|
||||
friend File& operator>>(File& f, String& n);
|
||||
friend File& operator>>(File& f, char* n);
|
||||
|
||||
int getline(char* buf, int sz);
|
||||
|
||||
File& skipWs();
|
||||
};
|
||||
|
|
|
@ -37,11 +37,14 @@ CForward::CForward(const char *name, ForwardExecType et, int numParams, const Fo
|
|||
m_FuncName = name;
|
||||
m_ExecType = et;
|
||||
m_NumParams = numParams;
|
||||
|
||||
memcpy((void *)m_ParamTypes, paramTypes, numParams * sizeof(ForwardParam));
|
||||
|
||||
// find funcs
|
||||
int func;
|
||||
AMXForward *tmp = NULL;
|
||||
m_Funcs.clear();
|
||||
|
||||
for (CPluginMngr::iterator iter = g_plugins.begin(); iter; ++iter)
|
||||
{
|
||||
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
|
||||
AMX *amx = (*iter).pPlugin->getAMX();
|
||||
Debugger *pDebugger = (Debugger *)amx->userdata[UD_DEBUGGER];
|
||||
|
||||
if (pDebugger)
|
||||
pDebugger->BeginExec();
|
||||
|
||||
// handle strings & arrays
|
||||
int i, ax = 0;
|
||||
|
||||
for (i = 0; i < m_NumParams; ++i)
|
||||
{
|
||||
if (m_ParamTypes[i] == FP_STRING || m_ParamTypes[i] == FP_STRINGEX)
|
||||
{
|
||||
cell *tmp;
|
||||
amx_Allot(iter->pPlugin->getAMX(),
|
||||
(m_ParamTypes[i] == FP_STRING) ? strlen(reinterpret_cast<const char*>(params[i]))+1 : STRINGEX_MAXLENGTH,
|
||||
&realParams[i], &tmp);
|
||||
amx_Allot(iter->pPlugin->getAMX(), (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);
|
||||
physAddrs[i] = tmp;
|
||||
}
|
||||
else if (m_ParamTypes[i] == FP_ARRAY)
|
||||
{
|
||||
cell *tmp;
|
||||
amx_Allot(amx, preparedArrays[params[i]].size,
|
||||
&realParams[i], &tmp);
|
||||
amx_Allot(amx, preparedArrays[params[i]].size, &realParams[i], &tmp);
|
||||
physAddrs[i] = tmp;
|
||||
|
||||
if (preparedArrays[params[i]].type == Type_Cell)
|
||||
{
|
||||
memcpy(tmp, preparedArrays[params[i]].ptr, preparedArrays[params[i]].size * sizeof(cell));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
char *data = (char*)preparedArrays[params[i]].ptr;
|
||||
|
||||
for (unsigned int j = 0; j < preparedArrays[params[i]].size; ++j)
|
||||
*tmp++ = (static_cast<cell>(*data++)) & 0xFF;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
realParams[i] = params[i];
|
||||
}
|
||||
}
|
||||
|
||||
//Push the parameters in reverse order. Weird, unfriendly part of Small 3.0!
|
||||
for (i = m_NumParams-1; i >= 0; i--)
|
||||
{
|
||||
amx_Push(amx, realParams[i]);
|
||||
}
|
||||
|
||||
// exec
|
||||
cell retVal;
|
||||
int err = amx_Exec(amx, &retVal, iter->func);
|
||||
|
||||
// log runtime error, if any
|
||||
if (err != AMX_ERR_NONE)
|
||||
{
|
||||
|
@ -126,12 +130,16 @@ cell CForward::execute(cell *params, ForwardPreparedArray *preparedArrays)
|
|||
if (pDebugger && pDebugger->ErrorExists())
|
||||
{
|
||||
//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
|
||||
LogError(amx, err, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
amx->error = AMX_ERR_NONE;
|
||||
|
||||
if (pDebugger)
|
||||
pDebugger->EndExec();
|
||||
|
||||
|
@ -157,10 +165,9 @@ cell CForward::execute(cell *params, ForwardPreparedArray *preparedArrays)
|
|||
if (preparedArrays[params[i]].type == Type_Cell)
|
||||
{
|
||||
memcpy(preparedArrays[params[i]].ptr, tmp, preparedArrays[params[i]].size * sizeof(cell));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
char *data = (char*)preparedArrays[params[i]].ptr;
|
||||
|
||||
for (unsigned int j = 0; j < preparedArrays[params[i]].size; ++j)
|
||||
*data++ = static_cast<char>(*tmp++ & 0xFF);
|
||||
}
|
||||
|
@ -190,6 +197,7 @@ cell CForward::execute(cell *params, ForwardPreparedArray *preparedArrays)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return globRetVal;
|
||||
}
|
||||
|
||||
|
@ -235,57 +243,60 @@ cell CSPForward::execute(cell *params, ForwardPreparedArray *preparedArrays)
|
|||
|
||||
// handle strings & arrays
|
||||
int i;
|
||||
|
||||
for (i = 0; i < m_NumParams; ++i)
|
||||
{
|
||||
if (m_ParamTypes[i] == FP_STRING || m_ParamTypes[i] == FP_STRINGEX)
|
||||
{
|
||||
cell *tmp;
|
||||
amx_Allot(m_Amx,
|
||||
(m_ParamTypes[i] == FP_STRING) ? strlen(reinterpret_cast<const char*>(params[i]))+1 : STRINGEX_MAXLENGTH,
|
||||
&realParams[i], &tmp);
|
||||
amx_Allot(m_Amx, (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);
|
||||
physAddrs[i] = tmp;
|
||||
}
|
||||
else if (m_ParamTypes[i] == FP_ARRAY)
|
||||
{
|
||||
cell *tmp;
|
||||
amx_Allot(m_Amx, preparedArrays[params[i]].size,
|
||||
&realParams[i], &tmp);
|
||||
amx_Allot(m_Amx, preparedArrays[params[i]].size, &realParams[i], &tmp);
|
||||
physAddrs[i] = tmp;
|
||||
|
||||
if (preparedArrays[params[i]].type == Type_Cell)
|
||||
{
|
||||
memcpy(tmp, preparedArrays[params[i]].ptr, preparedArrays[params[i]].size * sizeof(cell));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
char *data = (char*)preparedArrays[params[i]].ptr;
|
||||
|
||||
for (unsigned int j = 0; j < preparedArrays[params[i]].size; ++j)
|
||||
*tmp++ = (static_cast<cell>(*data++)) & 0xFF;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
realParams[i] = params[i];
|
||||
}
|
||||
}
|
||||
|
||||
for (i = m_NumParams - 1; i >= 0; i--)
|
||||
amx_Push(m_Amx, realParams[i]);
|
||||
|
||||
// exec
|
||||
cell retVal;
|
||||
int err = amx_Exec(m_Amx, &retVal, m_Func);
|
||||
|
||||
if (err != AMX_ERR_NONE)
|
||||
{
|
||||
//Did something else set an error?
|
||||
if (pDebugger && pDebugger->ErrorExists())
|
||||
{
|
||||
//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
|
||||
LogError(m_Amx, err, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if (pDebugger)
|
||||
pDebugger->EndExec();
|
||||
|
||||
m_Amx->error = AMX_ERR_NONE;
|
||||
|
||||
// cleanup strings & arrays
|
||||
|
@ -310,10 +321,9 @@ cell CSPForward::execute(cell *params, ForwardPreparedArray *preparedArrays)
|
|||
if (preparedArrays[params[i]].type == Type_Cell)
|
||||
{
|
||||
memcpy(preparedArrays[params[i]].ptr, tmp, preparedArrays[params[i]].size * sizeof(cell));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
char *data = (char*)preparedArrays[params[i]].ptr;
|
||||
|
||||
for (unsigned int j = 0; j < preparedArrays[params[i]].size; ++j)
|
||||
*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;
|
||||
CForward *tmp = new CForward(funcName, et, numParams, paramTypes);
|
||||
|
||||
if (!tmp)
|
||||
return -1; // should be invalid
|
||||
|
||||
m_Forwards.push_back(tmp);
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
@ -339,22 +352,26 @@ int CForwardMngr::registerSPForward(int func, AMX *amx, int numParams, const For
|
|||
{
|
||||
int retVal = -1;
|
||||
CSPForward *pForward;
|
||||
|
||||
if (!m_FreeSPForwards.empty())
|
||||
{
|
||||
retVal = m_FreeSPForwards.front();
|
||||
pForward = m_SPForwards[retVal >> 1];
|
||||
pForward->Set(func, amx, numParams, paramTypes);
|
||||
|
||||
if (pForward->getFuncsNum() == 0)
|
||||
return -1;
|
||||
|
||||
m_FreeSPForwards.pop();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
retVal = (m_SPForwards.size() << 1) | 1;
|
||||
pForward = new CSPForward();
|
||||
|
||||
if (!pForward)
|
||||
return -1;
|
||||
|
||||
pForward->Set(func, amx, numParams, paramTypes);
|
||||
|
||||
if (pForward->getFuncsNum() == 0)
|
||||
{
|
||||
return -1;
|
||||
|
@ -363,6 +380,7 @@ int CForwardMngr::registerSPForward(int func, AMX *amx, int numParams, const For
|
|||
|
||||
m_SPForwards.push_back(pForward);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
@ -370,56 +388,58 @@ int CForwardMngr::registerSPForward(const char *funcName, AMX *amx, int numParam
|
|||
{
|
||||
int retVal = (m_SPForwards.size() << 1) | 1;
|
||||
CSPForward *pForward;
|
||||
|
||||
if (!m_FreeSPForwards.empty())
|
||||
{
|
||||
retVal = m_FreeSPForwards.front();
|
||||
pForward = m_SPForwards[retVal>>1]; // >>1 because unregisterSPForward pushes the id which contains the sp flag
|
||||
pForward->Set(funcName, amx, numParams, paramTypes);
|
||||
|
||||
if (pForward->getFuncsNum() == 0)
|
||||
return -1;
|
||||
|
||||
m_FreeSPForwards.pop();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
pForward = new CSPForward();
|
||||
|
||||
if (!pForward)
|
||||
return -1;
|
||||
|
||||
pForward->Set(funcName, amx, numParams, paramTypes);
|
||||
|
||||
if (pForward->getFuncsNum() == 0)
|
||||
{
|
||||
delete pForward;
|
||||
return -1;
|
||||
}
|
||||
|
||||
m_SPForwards.push_back(pForward);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
bool CForwardMngr::isIdValid(int id) const
|
||||
{
|
||||
return (id >= 0) && ((id & 1) ?
|
||||
(static_cast<size_t>(id >> 1) < m_SPForwards.size()) :
|
||||
(static_cast<size_t>(id >> 1) < m_Forwards.size()));
|
||||
return (id >= 0) && ((id & 1) ? (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)
|
||||
{
|
||||
int retVal = (id & 1) ? m_SPForwards[id >> 1]->execute(params, m_TmpArrays) :
|
||||
m_Forwards[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_TmpArraysNum = 0;
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
int CForwardMngr::getParamsNum(int id) const
|
||||
{
|
||||
return (id & 1) ? m_SPForwards[id >> 1]->getParamsNum() :
|
||||
m_Forwards[id >> 1]->getParamsNum();
|
||||
return (id & 1) ? m_SPForwards[id >> 1]->getParamsNum() : m_Forwards[id >> 1]->getParamsNum();
|
||||
}
|
||||
|
||||
ForwardParam CForwardMngr::getParamType(int id, int paramNum) const
|
||||
{
|
||||
return (id & 1) ? m_SPForwards[id >> 1]->getParamType(paramNum) :
|
||||
m_Forwards[id >> 1]->getParamType(paramNum);
|
||||
return (id & 1) ? m_SPForwards[id >> 1]->getParamType(paramNum) : m_Forwards[id >> 1]->getParamType(paramNum);
|
||||
}
|
||||
|
||||
void CForwardMngr::clear()
|
||||
|
@ -428,7 +448,9 @@ void CForwardMngr::clear()
|
|||
{
|
||||
delete *iter;
|
||||
}
|
||||
|
||||
SPForwardVec::iterator spIter;
|
||||
|
||||
for (spIter = m_SPForwards.begin(); spIter != m_SPForwards.end(); ++spIter)
|
||||
{
|
||||
delete (*spIter);
|
||||
|
@ -436,8 +458,10 @@ void CForwardMngr::clear()
|
|||
|
||||
m_Forwards.clear();
|
||||
m_SPForwards.clear();
|
||||
|
||||
while (!m_FreeSPForwards.empty())
|
||||
m_FreeSPForwards.pop();
|
||||
|
||||
m_TmpArraysNum = 0;
|
||||
}
|
||||
|
||||
|
@ -453,70 +477,93 @@ void CForwardMngr::unregisterSPForward(int id)
|
|||
return;
|
||||
|
||||
m_SPForwards.at(id >> 1)->isFree = true;
|
||||
|
||||
m_FreeSPForwards.push(id);
|
||||
}
|
||||
|
||||
int registerForward(const char *funcName, ForwardExecType et, ...)
|
||||
{
|
||||
int curParam = 0;
|
||||
|
||||
va_list argptr;
|
||||
va_start(argptr, et);
|
||||
|
||||
ForwardParam params[FORWARD_MAX_PARAMS];
|
||||
ForwardParam tmp;
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (curParam == FORWARD_MAX_PARAMS)
|
||||
break;
|
||||
|
||||
tmp = (ForwardParam)va_arg(argptr, int);
|
||||
|
||||
if (tmp == FP_DONE)
|
||||
break;
|
||||
|
||||
params[curParam] = tmp;
|
||||
++curParam;
|
||||
}
|
||||
|
||||
va_end(argptr);
|
||||
|
||||
return g_forwards.registerForward(funcName, et, curParam, params);
|
||||
}
|
||||
|
||||
int registerSPForwardByName(AMX *amx, const char *funcName, ...)
|
||||
{
|
||||
int curParam = 0;
|
||||
|
||||
va_list argptr;
|
||||
va_start(argptr, funcName);
|
||||
|
||||
ForwardParam params[FORWARD_MAX_PARAMS];
|
||||
ForwardParam tmp;
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (curParam == FORWARD_MAX_PARAMS)
|
||||
break;
|
||||
|
||||
tmp = (ForwardParam)va_arg(argptr, int);
|
||||
|
||||
if (tmp == FP_DONE)
|
||||
break;
|
||||
|
||||
params[curParam] = tmp;
|
||||
++curParam;
|
||||
}
|
||||
|
||||
va_end(argptr);
|
||||
|
||||
return g_forwards.registerSPForward(funcName, amx, curParam, params);
|
||||
}
|
||||
|
||||
int registerSPForward(AMX *amx, int func, ...)
|
||||
{
|
||||
int curParam = 0;
|
||||
|
||||
va_list argptr;
|
||||
va_start(argptr, func);
|
||||
|
||||
ForwardParam params[FORWARD_MAX_PARAMS];
|
||||
ForwardParam tmp;
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (curParam == FORWARD_MAX_PARAMS)
|
||||
break;
|
||||
|
||||
tmp = (ForwardParam)va_arg(argptr, int);
|
||||
|
||||
if (tmp == FP_DONE)
|
||||
break;
|
||||
|
||||
params[curParam] = tmp;
|
||||
++curParam;
|
||||
}
|
||||
|
||||
va_end(argptr);
|
||||
|
||||
return g_forwards.registerSPForward(func, amx, curParam, params);
|
||||
}
|
||||
|
||||
|
@ -526,9 +573,12 @@ cell executeForwards(int id, ...)
|
|||
return -1;
|
||||
|
||||
cell params[FORWARD_MAX_PARAMS];
|
||||
|
||||
int paramsNum = g_forwards.getParamsNum(id);
|
||||
|
||||
va_list argptr;
|
||||
va_start(argptr, id);
|
||||
|
||||
for (int i = 0; i < paramsNum && i < FORWARD_MAX_PARAMS; ++i)
|
||||
{
|
||||
if (g_forwards.getParamType(id, i) == FP_FLOAT)
|
||||
|
@ -539,7 +589,9 @@ cell executeForwards(int id, ...)
|
|||
else
|
||||
params[i] = (cell)va_arg(argptr, cell);
|
||||
}
|
||||
|
||||
va_end(argptr);
|
||||
|
||||
return g_forwards.executeForwards(id, params);
|
||||
}
|
||||
|
||||
|
@ -550,10 +602,13 @@ cell CForwardMngr::prepareArray(void *ptr, unsigned int size, ForwardArrayElemTy
|
|||
#ifdef MEMORY_TEST
|
||||
m_validateAllAllocUnits();
|
||||
#endif // MEMORY_TEST
|
||||
|
||||
AMXXLOG_Log("[AMXX] Forwards with more than 32 parameters are not supported (tried to prepare array # %d).", m_TmpArraysNum + 1);
|
||||
m_TmpArraysNum = 0;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
m_TmpArrays[m_TmpArraysNum].ptr = ptr;
|
||||
m_TmpArrays[m_TmpArraysNum].size = size;
|
||||
m_TmpArrays[m_TmpArraysNum].type = type;
|
||||
|
|
|
@ -77,7 +77,9 @@ enum ForwardArrayElemType
|
|||
struct ForwardPreparedArray
|
||||
{
|
||||
void *ptr;
|
||||
|
||||
ForwardArrayElemType type;
|
||||
|
||||
unsigned int size;
|
||||
bool copyBack;
|
||||
};
|
||||
|
@ -96,13 +98,14 @@ class CForward
|
|||
};
|
||||
|
||||
typedef CVector<AMXForward> AMXForwardList;
|
||||
|
||||
AMXForwardList m_Funcs;
|
||||
ForwardParam m_ParamTypes[FORWARD_MAX_PARAMS];
|
||||
|
||||
public:
|
||||
CForward(const char *name, ForwardExecType et, int numParams, const ForwardParam * paramTypes);
|
||||
CForward()
|
||||
{ } // leaves everything unitialized'
|
||||
CForward() {} // leaves everything unitialized'
|
||||
|
||||
cell execute(cell *params, ForwardPreparedArray *preparedArrays);
|
||||
|
||||
int getParamsNum() const
|
||||
|
@ -129,8 +132,10 @@ class CSPForward
|
|||
{
|
||||
const char *m_FuncName;
|
||||
int m_NumParams;
|
||||
|
||||
ForwardParam m_ParamTypes[FORWARD_MAX_PARAMS];
|
||||
AMX *m_Amx;
|
||||
|
||||
int m_Func;
|
||||
bool m_HasFunc;
|
||||
|
||||
|
@ -179,8 +184,7 @@ public:
|
|||
|
||||
CForwardMngr()
|
||||
{ m_TmpArraysNum = 0; }
|
||||
~CForwardMngr()
|
||||
{ }
|
||||
~CForwardMngr() {}
|
||||
|
||||
// Interface
|
||||
// Register normal forward
|
||||
|
@ -188,15 +192,19 @@ public:
|
|||
// Register single plugin forward
|
||||
int registerSPForward(const char *funcName, AMX *amx, int numParams, const ForwardParam * paramTypes);
|
||||
int registerSPForward(int func, AMX *amx, int numParams, const ForwardParam * paramTypes);
|
||||
|
||||
// Unregister single plugin forward
|
||||
void unregisterSPForward(int id);
|
||||
|
||||
// execute forward
|
||||
cell executeForwards(int id, cell *params);
|
||||
void clear(); // delete all forwards
|
||||
|
||||
bool isIdValid(int id) const; // check whether forward id is valid
|
||||
bool isSPForward(int id) const; // check whether forward is single plugin
|
||||
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
|
||||
|
||||
ForwardParam getParamType(int id, int paramId) const;
|
||||
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);
|
||||
|
||||
#endif //FORWARD_H
|
||||
|
||||
|
|
|
@ -973,6 +973,7 @@ char *CLangMngr::FormatString(const char *fmt, va_list &ap)
|
|||
|
||||
return outbuf;
|
||||
}
|
||||
|
||||
void CLangMngr::MergeDefinitions(const char *lang, CQueue<sKeyDef*> &tmpVec)
|
||||
{
|
||||
CLang * language = GetLang(lang);
|
||||
|
|
|
@ -51,6 +51,7 @@ struct sKeyDef
|
|||
{
|
||||
sKeyDef() { key = -1; def = 0; }
|
||||
~sKeyDef() { if (def) delete def; }
|
||||
|
||||
int key;
|
||||
String *def;
|
||||
};
|
||||
|
|
|
@ -66,8 +66,10 @@ private:
|
|||
~CElement()
|
||||
{
|
||||
delete m_pObject;
|
||||
|
||||
if (m_pNext)
|
||||
m_pNext->m_pPrev = m_pPrev;
|
||||
|
||||
if (m_pPrev)
|
||||
m_pPrev->m_pNext = m_pNext;
|
||||
}
|
||||
|
@ -111,6 +113,7 @@ public:
|
|||
class iterator
|
||||
{
|
||||
friend class CList<T, F>;
|
||||
|
||||
CList<T, F> *m_pList; // The list that created this iterator
|
||||
CElement *m_CurPos; // Current position in the list
|
||||
public:
|
||||
|
@ -205,6 +208,7 @@ public:
|
|||
|
||||
if (where.m_CurPos == m_pHead)
|
||||
m_pHead = where.m_CurPos->GetNext();
|
||||
|
||||
if (where.m_CurPos == m_pTail)
|
||||
m_pTail = where.m_CurPos->GetPrev();
|
||||
|
||||
|
|
|
@ -55,7 +55,9 @@ int LogEventsMngr::CLogCmp::compareCondition(const char* string)
|
|||
return result;
|
||||
|
||||
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());
|
||||
}
|
||||
|
@ -71,7 +73,10 @@ LogEventsMngr::CLogCmp* LogEventsMngr::registerCondition(char* filter)
|
|||
bool in = (*filter=='&');
|
||||
*filter++ = 0;
|
||||
int pos = atoi(temp);
|
||||
if (pos < 0 || pos >= MAX_LOGARGS) pos = 0;
|
||||
|
||||
if (pos < 0 || pos >= MAX_LOGARGS)
|
||||
pos = 0;
|
||||
|
||||
CLogCmp* c = logcmplist;
|
||||
|
||||
while (c)
|
||||
|
@ -99,7 +104,10 @@ void LogEventsMngr::CLogEvent::registerFilter(char* filter)
|
|||
}
|
||||
|
||||
LogCondEle* aa = new LogCondEle(cmp, 0);
|
||||
if (aa == 0) return;
|
||||
|
||||
if (aa == 0)
|
||||
return;
|
||||
|
||||
filters = new LogCond(cmp->pos, aa, filters);
|
||||
}
|
||||
|
||||
|
@ -114,7 +122,9 @@ void LogEventsMngr::setLogString(char* frmt, va_list& vaptr)
|
|||
logString[len] = 0;
|
||||
}
|
||||
|
||||
if (len) logString[--len] = 0;
|
||||
if (len)
|
||||
logString[--len] = 0;
|
||||
|
||||
logArgc = 0;
|
||||
}
|
||||
|
||||
|
@ -132,7 +142,10 @@ void LogEventsMngr::setLogString(char* frmt, ...)
|
|||
}
|
||||
|
||||
va_end(logArgPtr);
|
||||
if (len) logString[--len] = 0;
|
||||
|
||||
if (len)
|
||||
logString[--len] = 0;
|
||||
|
||||
logArgc = 0;
|
||||
}
|
||||
|
||||
|
@ -180,7 +193,9 @@ LogEventsMngr::CLogEvent* LogEventsMngr::registerLogEvent(CPluginMngr::CPlugin*
|
|||
|
||||
arelogevents = true;
|
||||
CLogEvent** d = &logevents[pos];
|
||||
while (*d) d = &(*d)->next;
|
||||
|
||||
while (*d)
|
||||
d = &(*d)->next;
|
||||
|
||||
return *d = new CLogEvent(plugin, func, this);
|
||||
}
|
||||
|
|
|
@ -61,12 +61,15 @@ public:
|
|||
{
|
||||
friend class LogEventsMngr;
|
||||
friend class CLogEvent;
|
||||
|
||||
LogEventsMngr* parent;
|
||||
String text;
|
||||
|
||||
int logid;
|
||||
int pos;
|
||||
int result;
|
||||
bool in;
|
||||
|
||||
CLogCmp *next;
|
||||
|
||||
CLogCmp(const char* s, bool r, int p, CLogCmp *n, LogEventsMngr* mg) : text(s)
|
||||
|
@ -101,6 +104,7 @@ public:
|
|||
struct LogCond
|
||||
{
|
||||
int argnum;
|
||||
|
||||
LogCondEle *list;
|
||||
LogCond *next;
|
||||
LogCond(int a, LogCondEle* ee, LogCond* n) : argnum(a), list(ee), next(n) {}
|
||||
|
@ -108,9 +112,12 @@ public:
|
|||
};
|
||||
|
||||
CPluginMngr::CPlugin *plugin;
|
||||
|
||||
int func;
|
||||
|
||||
LogCond *filters;
|
||||
LogEventsMngr* parent;
|
||||
|
||||
CLogEvent *next;
|
||||
CLogEvent(CPluginMngr::CPlugin *p, int f, LogEventsMngr* ppp) : plugin(p), func(f), filters(0), parent(ppp), next(0) {}
|
||||
~CLogEvent();
|
||||
|
@ -124,6 +131,7 @@ private:
|
|||
CLogEvent *logevents[MAX_LOGARGS + 1];
|
||||
CLogEvent *getValidLogEvent(CLogEvent * a);
|
||||
CLogCmp* registerCondition(char* filter);
|
||||
|
||||
void clearConditions();
|
||||
public:
|
||||
LogEventsMngr();
|
||||
|
@ -132,10 +140,12 @@ public:
|
|||
// Interface
|
||||
CLogEvent* registerLogEvent(CPluginMngr::CPlugin* plugin, int func, int pos);
|
||||
inline bool logEventsExist() { return arelogevents; }
|
||||
|
||||
void setLogString(char* frmt, va_list& vaptr);
|
||||
void setLogString(char* frmt, ...);
|
||||
void parseLogString();
|
||||
void executeLogEvents();
|
||||
|
||||
inline const char* getLogString() { return logString; }
|
||||
inline int getLogArgNum() { return logArgc; }
|
||||
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 id = findMenuId(n, a);
|
||||
if (id) return id;
|
||||
|
||||
if (id)
|
||||
return id;
|
||||
|
||||
headid = new MenuIdEle(n, a, headid);
|
||||
|
||||
if (!headid)
|
||||
|
|
|
@ -43,6 +43,7 @@ class MenuMngr
|
|||
String name;
|
||||
AMX* amx;
|
||||
MenuIdEle* next;
|
||||
|
||||
int id;
|
||||
static int uniqueid;
|
||||
|
||||
|
@ -67,6 +68,7 @@ private:
|
|||
int menuid;
|
||||
int keys;
|
||||
int function;
|
||||
|
||||
MenuCommand* next;
|
||||
MenuCommand(CPluginMngr::CPlugin *a, int mi, int k, int f);
|
||||
public:
|
||||
|
|
|
@ -89,8 +89,10 @@ bool CPlayer::Connect(const char* connectname, const char* ipaddress)
|
|||
time = gpGlobals->time;
|
||||
bot = IsBot();
|
||||
death_killer = 0;
|
||||
|
||||
memset(flags, 0, sizeof(flags));
|
||||
memset(weapons, 0, sizeof(weapons));
|
||||
|
||||
initialized = true;
|
||||
authorized = false;
|
||||
|
||||
|
@ -180,6 +182,7 @@ int XVars::put(AMX* p, cell* v)
|
|||
|
||||
head[num].value = v;
|
||||
head[num].amx = p;
|
||||
|
||||
return num++;
|
||||
}
|
||||
|
||||
|
@ -237,7 +240,10 @@ void TeamIds::registerTeam(const char* n, int s)
|
|||
}
|
||||
|
||||
*a = new TeamEle(n, s);
|
||||
if (*a == 0) return;
|
||||
|
||||
if (*a == 0)
|
||||
return;
|
||||
|
||||
newTeam |= (1<<(*a)->tid);
|
||||
}
|
||||
|
||||
|
|
|
@ -157,6 +157,7 @@ class Grenades
|
|||
public:
|
||||
Grenades() { head = 0; }
|
||||
~Grenades() { clear(); }
|
||||
|
||||
void put(edict_t* grenade, float time, int type, CPlayer* player);
|
||||
bool find(edict_t* enemy, CPlayer** p, int& type);
|
||||
void clear();
|
||||
|
@ -174,13 +175,14 @@ class ForceObject
|
|||
Vector maxs;
|
||||
AMX* amx;
|
||||
public:
|
||||
ForceObject(const char* n, FORCE_TYPE c, Vector& mi, Vector& ma, AMX* a) :
|
||||
filename(n), type(c), mins(mi), maxs(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) {}
|
||||
|
||||
inline const char* getFilename() { return filename.c_str(); }
|
||||
inline AMX* getAMX() { return amx; }
|
||||
|
||||
Vector& getMin() { return mins; }
|
||||
Vector& getMax() { return maxs; }
|
||||
|
||||
inline FORCE_TYPE getForceType() { return type; }
|
||||
};
|
||||
|
||||
|
@ -197,6 +199,7 @@ class XVars
|
|||
};
|
||||
|
||||
XVarEle* head;
|
||||
|
||||
int size;
|
||||
int num;
|
||||
int realloc_array(int nsize);
|
||||
|
@ -204,6 +207,7 @@ class XVars
|
|||
public:
|
||||
XVars() { num = 0; size = 0; head = 0; }
|
||||
~XVars() { clear(); }
|
||||
|
||||
void clear();
|
||||
int put(AMX* a, cell* v);
|
||||
|
||||
|
@ -269,6 +273,7 @@ class TeamIds
|
|||
public:
|
||||
TeamIds();
|
||||
~TeamIds();
|
||||
|
||||
void registerTeam(const char* n, int s);
|
||||
int findTeamId(const char* n);
|
||||
int findTeamIdCase(const char* n);
|
||||
|
|
|
@ -71,8 +71,10 @@ struct amxx_module_info_s
|
|||
class CModule
|
||||
{
|
||||
String m_Filename; // Filename
|
||||
|
||||
bool m_Metamod; // Using metamod?
|
||||
bool m_Amxx; // Using new module interface?
|
||||
|
||||
amxx_module_info_s m_InfoNew; // module info (new module interface)
|
||||
DLHANDLE m_Handle; // handle
|
||||
MODULE_STATUS m_Status; // status
|
||||
|
@ -106,6 +108,7 @@ public:
|
|||
inline const char *getMissingFunc() const { return m_MissingFunc; }
|
||||
inline const char *getFilename() { return m_Filename.c_str(); }
|
||||
inline bool IsMetamod() { return m_Metamod; }
|
||||
|
||||
void CModule::CallPluginsLoaded();
|
||||
|
||||
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)
|
||||
{
|
||||
CPlugin** a = &head;
|
||||
while( *a ) a = &(*a)->next;
|
||||
|
||||
while (*a)
|
||||
a = &(*a)->next;
|
||||
|
||||
*a = new CPlugin(pCounter++, path, name, error, debug);
|
||||
|
||||
return (*a);
|
||||
}
|
||||
|
||||
void CPluginMngr::unloadPlugin( CPlugin** a ) {
|
||||
void CPluginMngr::unloadPlugin(CPlugin** a)
|
||||
{
|
||||
CPlugin* next = (*a)->next;
|
||||
delete *a;
|
||||
*a = next;
|
||||
|
@ -58,9 +63,10 @@ void CPluginMngr::Finalize()
|
|||
{
|
||||
if (m_Finalized)
|
||||
return;
|
||||
pNatives = BuildNativeTable();
|
||||
|
||||
pNatives = BuildNativeTable();
|
||||
CPlugin *a = head;
|
||||
|
||||
while (a)
|
||||
{
|
||||
if (a->getStatusCode() == ps_running)
|
||||
|
@ -70,6 +76,7 @@ void CPluginMngr::Finalize()
|
|||
}
|
||||
a = a->next;
|
||||
}
|
||||
|
||||
m_Finalized = true;
|
||||
}
|
||||
|
||||
|
@ -94,12 +101,16 @@ int CPluginMngr::loadPluginsFromFile( const char* filename )
|
|||
while (!feof(fp))
|
||||
{
|
||||
pluginName[0] = '\0';
|
||||
|
||||
debug[0] = '\0';
|
||||
debugFlag = 0;
|
||||
|
||||
line.clear();
|
||||
line._fread(fp);
|
||||
sscanf(line.c_str(), "%s %s", pluginName, debug);
|
||||
if (!isalnum(*pluginName)) continue;
|
||||
|
||||
if (!isalnum(*pluginName))
|
||||
continue;
|
||||
|
||||
if (isalnum(*debug) && strcmp(debug, "debug") == 0)
|
||||
{
|
||||
|
@ -122,11 +133,15 @@ int CPluginMngr::loadPluginsFromFile( const char* filename )
|
|||
return pCounter;
|
||||
}
|
||||
|
||||
void CPluginMngr::clear() {
|
||||
void CPluginMngr::clear()
|
||||
{
|
||||
CPlugin**a = &head;
|
||||
|
||||
while (*a)
|
||||
unloadPlugin(a);
|
||||
|
||||
m_Finalized = false;
|
||||
|
||||
if (pNatives)
|
||||
{
|
||||
delete [] pNatives;
|
||||
|
@ -139,32 +154,48 @@ CPluginMngr::CPlugin* CPluginMngr::findPluginFast(AMX *amx)
|
|||
return (CPlugin*)(amx->userdata[UD_FINDPLUGIN]);
|
||||
}
|
||||
|
||||
CPluginMngr::CPlugin* CPluginMngr::findPlugin(AMX *amx) {
|
||||
CPluginMngr::CPlugin* CPluginMngr::findPlugin(AMX *amx)
|
||||
{
|
||||
CPlugin*a = head;
|
||||
|
||||
while (a && &a->amx != amx)
|
||||
a = a->next;
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
CPluginMngr::CPlugin* CPluginMngr::findPlugin(int index){
|
||||
CPluginMngr::CPlugin* CPluginMngr::findPlugin(int index)
|
||||
{
|
||||
CPlugin*a = head;
|
||||
|
||||
while (a && index--)
|
||||
a = a->next;
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
CPluginMngr::CPlugin* CPluginMngr::findPlugin(const char* name) {
|
||||
if (!name) return 0;
|
||||
CPluginMngr::CPlugin* CPluginMngr::findPlugin(const char* name)
|
||||
{
|
||||
if (!name)
|
||||
return 0;
|
||||
|
||||
int len = strlen(name);
|
||||
if (!len) return 0;
|
||||
|
||||
if (!len)
|
||||
return 0;
|
||||
|
||||
CPlugin*a = head;
|
||||
|
||||
while (a && strncmp(a->name.c_str(), name, len))
|
||||
a = a->next;
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
const char* CPluginMngr::CPlugin::getStatus() const {
|
||||
switch(status){
|
||||
const char* CPluginMngr::CPlugin::getStatus() const
|
||||
{
|
||||
switch (status)
|
||||
{
|
||||
case ps_running:
|
||||
{
|
||||
if (m_Debug)
|
||||
|
@ -180,33 +211,41 @@ const char* CPluginMngr::CPlugin::getStatus() const {
|
|||
case ps_stopped: return "stopped";
|
||||
case ps_locked: return "locked";
|
||||
}
|
||||
|
||||
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";
|
||||
|
||||
title.assign(unk);
|
||||
author.assign(unk);
|
||||
version.assign(unk);
|
||||
|
||||
char file[256];
|
||||
char* path = build_pathname_r(file, sizeof(file) - 1, "%s/%s", p, n);
|
||||
code = 0;
|
||||
memset(&amx, 0, sizeof(AMX));
|
||||
int err = load_amxscript(&amx, &code, path, e, d);
|
||||
|
||||
if (err == AMX_ERR_NONE)
|
||||
{
|
||||
status = ps_running;
|
||||
} else {
|
||||
status = ps_bad_load;
|
||||
}
|
||||
|
||||
amx.userdata[UD_FINDPLUGIN] = this;
|
||||
paused_fun = 0;
|
||||
next = 0;
|
||||
id = i;
|
||||
|
||||
if (status == ps_running)
|
||||
{
|
||||
m_PauseFwd = registerSPForwardByName(&amx, "plugin_pause");
|
||||
m_UnpauseFwd = registerSPForwardByName(&amx, "plugin_unpause");
|
||||
|
||||
if (amx.flags & AMX_FLAG_DEBUG)
|
||||
{
|
||||
m_Debug = true;
|
||||
|
@ -274,16 +313,18 @@ static cell AMX_NATIVE_CALL invalid_native(AMX *amx, cell *params)
|
|||
void CPluginMngr::CPlugin::Finalize()
|
||||
{
|
||||
char buffer[128];
|
||||
|
||||
int old_status = status;
|
||||
|
||||
if (CheckModules(&amx, buffer))
|
||||
{
|
||||
if (amx_Register(&amx, core_Natives, -1) != AMX_ERR_NONE)
|
||||
{
|
||||
Handler *pHandler = (Handler *)amx.userdata[UD_HANDLER];
|
||||
int res = 0;
|
||||
|
||||
if (pHandler->IsNativeFiltering())
|
||||
res = amx_CheckNatives(&amx, native_handler);
|
||||
|
||||
if (!res)
|
||||
{
|
||||
status = ps_bad_load;
|
||||
|
@ -299,6 +340,7 @@ void CPluginMngr::CPlugin::Finalize()
|
|||
errorMsg.assign(buffer);
|
||||
amx.error = AMX_ERR_NOTFOUND;
|
||||
}
|
||||
|
||||
if (old_status != status)
|
||||
{
|
||||
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;
|
||||
g_commands.clearBufforedInfo(); // ugly way
|
||||
}
|
||||
|
@ -337,8 +380,8 @@ void CPluginMngr::CPlugin::unpausePlugin()
|
|||
if (isValid())
|
||||
{
|
||||
// set status first so the function will be marked executable
|
||||
|
||||
setStatus(ps_running);
|
||||
|
||||
// call plugin_unpause if provided
|
||||
if (m_UnpauseFwd != -1)
|
||||
executeForwards(m_UnpauseFwd);
|
||||
|
|
|
@ -59,19 +59,23 @@ public:
|
|||
|
||||
AMX amx;
|
||||
void* code;
|
||||
|
||||
String name;
|
||||
String version;
|
||||
String title;
|
||||
String author;
|
||||
String errorMsg;
|
||||
|
||||
int m_PauseFwd;
|
||||
int m_UnpauseFwd;
|
||||
int paused_fun;
|
||||
int status;
|
||||
CPlugin* next;
|
||||
int id;
|
||||
|
||||
CPlugin(int i, const char* p, const char* n, char* e, int d);
|
||||
~CPlugin();
|
||||
|
||||
bool m_Debug;
|
||||
public:
|
||||
inline const char* getName() { return name.c_str();}
|
||||
|
@ -90,12 +94,14 @@ public:
|
|||
inline bool isValid() const { return (status >= ps_paused); }
|
||||
inline bool isPaused() const { return ((status == ps_paused) || (status == ps_stopped)); }
|
||||
inline bool isExecutable(int id) const { return (isValid() && !isPaused()); }
|
||||
|
||||
void Finalize();
|
||||
void pausePlugin();
|
||||
void unpausePlugin();
|
||||
void pauseFunction(int id);
|
||||
void unpauseFunction(int id);
|
||||
void setStatus(int a);
|
||||
|
||||
const char* getStatus() const;
|
||||
inline bool isDebug() const { return m_Debug; }
|
||||
};
|
||||
|
@ -115,10 +121,12 @@ public:
|
|||
CPlugin* loadPlugin(const char* path, const char* name, char* error, int debug);
|
||||
void unloadPlugin(CPlugin** a);
|
||||
int loadPluginsFromFile(const char* filename);
|
||||
|
||||
CPlugin* findPluginFast(AMX *amx);
|
||||
CPlugin* findPlugin(AMX *amx);
|
||||
CPlugin* findPlugin(int index);
|
||||
CPlugin* findPlugin(const char* name);
|
||||
|
||||
inline int getPluginsNum() const { return pCounter; }
|
||||
void Finalize();
|
||||
void clear();
|
||||
|
|
|
@ -45,14 +45,17 @@ public:
|
|||
item = i;
|
||||
next = n;
|
||||
}
|
||||
|
||||
CQueueItem *GetNext()
|
||||
{
|
||||
return next;
|
||||
}
|
||||
|
||||
T & GetItem()
|
||||
{
|
||||
return item;
|
||||
}
|
||||
|
||||
void SetNext(CQueueItem *n)
|
||||
{
|
||||
next = n;
|
||||
|
@ -119,8 +122,8 @@ public:
|
|||
private:
|
||||
CQueueItem *mFirst;
|
||||
CQueueItem *mLast;
|
||||
|
||||
unsigned int mSize;
|
||||
};
|
||||
|
||||
#endif //_INCLUDE_CQUEUE_H
|
||||
|
||||
|
|
|
@ -39,15 +39,18 @@ private:
|
|||
class CTask
|
||||
{
|
||||
// task settings
|
||||
|
||||
CPluginMngr::CPlugin *m_pPlugin;
|
||||
int m_iId;
|
||||
int m_iFunc;
|
||||
int m_iRepeat;
|
||||
|
||||
bool m_bLoop;
|
||||
bool m_bAfterStart;
|
||||
bool m_bBeforeEnd;
|
||||
float m_fBase; // for normal tasks, stores the interval, for the others, stores the amount of time before start / after end
|
||||
int m_iParamLen;
|
||||
|
||||
cell *m_pParams;
|
||||
bool m_bFree;
|
||||
|
||||
|
@ -91,15 +94,16 @@ private:
|
|||
if (right.m_bFree)
|
||||
return left.isFree();
|
||||
|
||||
return !left.isFree() && (right.m_pAmx ? left.getPlugin()->getAMX() == right.m_pAmx : true) &&
|
||||
left.getTaskId() == right.m_iId;
|
||||
return !left.isFree() && (right.m_pAmx ? left.getPlugin()->getAMX() == right.m_pAmx : true) && left.getTaskId() == right.m_iId;
|
||||
}
|
||||
};
|
||||
|
||||
/*** CTaskMngr priv members ***/
|
||||
typedef CList<CTask, CTaskDescriptor> TaskList;
|
||||
typedef TaskList::iterator TaskListIter;
|
||||
|
||||
TaskList m_Tasks;
|
||||
|
||||
float *m_pTmr_CurrentTime;
|
||||
float *m_pTmr_TimeLimit;
|
||||
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 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 changeTasks(int iId, AMX *pAmx, float fNewBase); // change all tasks that match the id and amx
|
||||
bool taskExists(int iId, AMX *pAmx);
|
||||
|
||||
void startFrame();
|
||||
void clear();
|
||||
};
|
||||
|
|
|
@ -45,6 +45,7 @@ class Vault
|
|||
{
|
||||
String key;
|
||||
String value;
|
||||
|
||||
int number;
|
||||
Obj *next;
|
||||
Obj(const char* k, const char* v);
|
||||
|
@ -62,13 +63,17 @@ public:
|
|||
// Interface
|
||||
|
||||
bool exists(const char* k);
|
||||
|
||||
void put(const char* k, const char* v);
|
||||
void remove(const char* k);
|
||||
|
||||
const char* get(const char* n);
|
||||
int get_number(const char* n);
|
||||
void setSource(const char* n);
|
||||
|
||||
bool loadVault();
|
||||
bool saveVault();
|
||||
|
||||
void clear();
|
||||
|
||||
class iterator
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -32,7 +32,6 @@
|
|||
#ifndef AMXMODX_H
|
||||
#define AMXMODX_H
|
||||
|
||||
|
||||
#ifdef __linux__
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -109,6 +108,7 @@ typedef void* DLHANDLE;
|
|||
|
||||
char* UTIL_SplitHudMessage(register const char *src);
|
||||
int UTIL_ReadFlags(const char* c);
|
||||
|
||||
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_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_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);
|
||||
|
||||
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_I(i) (&g_players[i])
|
||||
|
||||
struct WeaponsVault {
|
||||
struct WeaponsVault
|
||||
{
|
||||
String fullName;
|
||||
short int iId;
|
||||
short int ammoSlot;
|
||||
};
|
||||
|
||||
struct fakecmd_t {
|
||||
struct fakecmd_t
|
||||
{
|
||||
char args[256];
|
||||
const char *argv[3];
|
||||
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);
|
||||
void detachModules();
|
||||
void detachReloadModules();
|
||||
|
||||
#ifdef FAKEMETA
|
||||
void attachModules();
|
||||
#endif
|
||||
|
@ -252,11 +256,13 @@ char* format_amxstring(AMX *amx, cell *params, int parm,int& len);
|
|||
AMX* get_amxscript(int, void**, const char**);
|
||||
const char* get_amxscriptname(AMX* amx);
|
||||
char* get_amxstring(AMX *amx, cell amx_addr, int id, int& len);
|
||||
|
||||
int amxstring_len(cell* cstr);
|
||||
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_amxstring(AMX *amx, cell amx_addr, const char *source, int max);
|
||||
int unload_amxscript(AMX* amx, void** program);
|
||||
|
||||
void copy_amxmemory(cell* dest, cell* src, int len);
|
||||
void get_modname(char*);
|
||||
void print_srvconsole(char *fmt, ...);
|
||||
|
@ -279,6 +285,7 @@ enum ModuleCallReason
|
|||
extern ModuleCallReason g_ModuleCallReason; // modules.cpp
|
||||
extern CModule *g_CurrentlyCalledModule; // modules.cpp
|
||||
extern const char *g_LastRequestedFunc; // modules.cpp
|
||||
|
||||
void Module_CacheFunctions();
|
||||
void Module_UncacheFunctions();
|
||||
|
||||
|
@ -311,4 +318,3 @@ struct func_s
|
|||
};
|
||||
|
||||
#endif // AMXMODX_H
|
||||
|
||||
|
|
|
@ -83,7 +83,6 @@ CAmxxReader::CAmxxReader(const char *filename, int cellsize)
|
|||
|
||||
m_Status = Err_None;
|
||||
m_CellSize = cellsize;
|
||||
|
||||
m_pFile = fopen(filename, "rb");
|
||||
|
||||
if (!m_pFile)
|
||||
|
@ -115,6 +114,7 @@ CAmxxReader::CAmxxReader(const char *filename, int cellsize)
|
|||
m_Status = Err_OldFile;
|
||||
fclose(m_pFile);
|
||||
m_pFile = NULL;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -151,6 +151,7 @@ CAmxxReader::CAmxxReader(const char *filename, int cellsize)
|
|||
m_Status = Err_SectionNotFound;
|
||||
fclose(m_pFile);
|
||||
m_pFile = NULL;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -275,6 +276,7 @@ size_t CAmxxReader::GetBufferSize()
|
|||
AMX_HEADER hdr;
|
||||
DATAREAD(&hdr, sizeof(hdr), 1);
|
||||
fseek(m_pFile, save, SEEK_SET);
|
||||
|
||||
return hdr.stp;
|
||||
}
|
||||
else if (m_AmxxFile)
|
||||
|
|
|
@ -95,4 +95,3 @@ public:
|
|||
};
|
||||
|
||||
#endif // __AMXXFILE_H__
|
||||
|
||||
|
|
|
@ -86,6 +86,7 @@ void CLog::CloseFile()
|
|||
void CLog::CreateNewFile()
|
||||
{
|
||||
CloseFile();
|
||||
|
||||
// build filename
|
||||
time_t 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);
|
||||
pF = fopen(file, "a+");
|
||||
}
|
||||
|
||||
if (pF)
|
||||
{
|
||||
fprintf(pF, "L %s: %s\n", date, msg);
|
||||
|
|
|
@ -42,6 +42,7 @@ private:
|
|||
public:
|
||||
CLog();
|
||||
~CLog();
|
||||
|
||||
void CreateNewFile();
|
||||
void CloseFile();
|
||||
void MapChange();
|
||||
|
@ -49,4 +50,3 @@ public:
|
|||
};
|
||||
|
||||
#endif // __AMXXLOG_H__
|
||||
|
||||
|
|
|
@ -47,17 +47,20 @@ public:
|
|||
class Tracer
|
||||
{
|
||||
public:
|
||||
|
||||
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 frm;
|
||||
|
||||
trace_info *next;
|
||||
trace_info *prev;
|
||||
|
||||
bool used;
|
||||
};
|
||||
|
||||
public:
|
||||
Tracer() : m_Error(0), m_pStart(NULL), m_pEnd(NULL), m_Reset(true) {};
|
||||
~Tracer();
|
||||
|
@ -65,6 +68,7 @@ public:
|
|||
void StepI(cell frm, cell cip);
|
||||
void Reset();
|
||||
void Clear();
|
||||
|
||||
Debugger::Tracer::trace_info *GetStart() const;
|
||||
Debugger::Tracer::trace_info *GetEnd() const;
|
||||
public:
|
||||
|
@ -72,11 +76,12 @@ public:
|
|||
private:
|
||||
trace_info *m_pStart;
|
||||
trace_info *m_pEnd;
|
||||
|
||||
bool m_Reset;
|
||||
};
|
||||
|
||||
public:
|
||||
Debugger(AMX *pAmx, AMX_DBG *pAmxDbg) :
|
||||
m_pAmx(pAmx), m_pAmxDbg(pAmxDbg), m_Top(-1)
|
||||
Debugger(AMX *pAmx, AMX_DBG *pAmxDbg) : m_pAmx(pAmx), m_pAmxDbg(pAmxDbg), m_Top(-1)
|
||||
{
|
||||
_CacheAmxOpcodeList();
|
||||
};
|
||||
|
@ -123,19 +128,24 @@ public:
|
|||
public:
|
||||
//generic static opcode breaker
|
||||
static int AMXAPI DebugHook(AMX *amx);
|
||||
|
||||
static void FmtGenericMsg(AMX *amx, int error, char buffer[], size_t maxLength);
|
||||
static void GenericMessage(AMX *amx, int error);
|
||||
private:
|
||||
void _CacheAmxOpcodeList();
|
||||
|
||||
int _GetOpcodeFromCip(cell cip, cell *&addr);
|
||||
cell _CipAsVa(cell cip);
|
||||
|
||||
const char *_GetFilename();
|
||||
public:
|
||||
AMX *m_pAmx;
|
||||
AMX_DBG *m_pAmxDbg;
|
||||
|
||||
int m_Top;
|
||||
cell *m_pOpcodeList;
|
||||
String m_FileName;
|
||||
|
||||
CVector<Tracer *> m_pCalls;
|
||||
};
|
||||
|
||||
|
@ -148,10 +158,7 @@ typedef Debugger::Tracer::trace_info trace_info_t;
|
|||
class Handler
|
||||
{
|
||||
public:
|
||||
Handler(AMX *pAmx) : m_pAmx(pAmx),
|
||||
m_iErrFunc(-1), m_iModFunc(-1), m_iNatFunc(-1),
|
||||
m_Handling(false), m_InNativeFilter(false)
|
||||
{ };
|
||||
Handler(AMX *pAmx) : m_pAmx(pAmx), m_iErrFunc(-1), m_iModFunc(-1), m_iNatFunc(-1), m_Handling(false), m_InNativeFilter(false) {};
|
||||
~Handler() {};
|
||||
public:
|
||||
int SetErrorHandler(const char *function);
|
||||
|
@ -164,21 +171,28 @@ public:
|
|||
public:
|
||||
bool IsHandling() const { return m_Handling; }
|
||||
void SetErrorMsg(const char *msg);
|
||||
|
||||
const char *GetLastMsg();
|
||||
trace_info_t *GetTrace() const { return m_pTrace; }
|
||||
const char *GetFmtCache() { return m_FmtCache.c_str(); }
|
||||
|
||||
bool IsNativeFiltering() { return (m_iNatFunc > 0); }
|
||||
bool InNativeFilter() { return m_InNativeFilter; }
|
||||
private:
|
||||
AMX *m_pAmx;
|
||||
|
||||
int m_iErrFunc;
|
||||
int m_iModFunc;
|
||||
int m_iNatFunc;
|
||||
|
||||
bool m_Handling;
|
||||
|
||||
//in the future, make this a stack!
|
||||
bool m_InNativeFilter;
|
||||
|
||||
String m_MsgCache;
|
||||
String m_FmtCache;
|
||||
|
||||
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)
|
||||
return 0;
|
||||
|
||||
seekdir(dp, a);
|
||||
|
||||
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))
|
||||
i++;
|
||||
|
||||
fclose(fp);
|
||||
|
||||
if (i > iLine)
|
||||
{
|
||||
int len = strlen(buffor);
|
||||
|
||||
if (buffor[len - 1] == '\n')
|
||||
buffor[--len] = 0;
|
||||
|
||||
if (buffor[len - 1] == '\r')
|
||||
buffor[--len] = 0;
|
||||
|
||||
cell *length = get_amxaddr(amx, params[5]);
|
||||
*length = set_amxstring(amx, params[3], buffor, params[4]);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
|
@ -186,6 +192,7 @@ static cell AMX_NATIVE_CALL write_file(AMX *amx, cell *params) /* 3 param */
|
|||
fputs(sText, pFile);
|
||||
fputc('\n', pFile);
|
||||
fclose(pFile);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -204,6 +211,7 @@ static cell AMX_NATIVE_CALL write_file(AMX *amx, cell *params) /* 3 param */
|
|||
fputs(sText, pFile);
|
||||
fputc('\n', pFile);
|
||||
fclose(pFile);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -233,7 +241,8 @@ static cell AMX_NATIVE_CALL write_file(AMX *amx, cell *params) /* 3 param */
|
|||
{
|
||||
fputc('\n', pTemp);
|
||||
}
|
||||
else break;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
fclose(pFile);
|
||||
|
@ -259,6 +268,7 @@ static cell AMX_NATIVE_CALL delete_file(AMX *amx, cell *params) /* 1 param */
|
|||
{
|
||||
int iLen;
|
||||
char* sFile = get_amxstring(amx, params[1], 0, iLen);
|
||||
|
||||
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
|
||||
DWORD attr = GetFileAttributes(file);
|
||||
|
||||
if (attr == INVALID_FILE_ATTRIBUTES)
|
||||
return 0;
|
||||
|
||||
if (attr == FILE_ATTRIBUTE_DIRECTORY)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
#else
|
||||
struct stat s;
|
||||
|
||||
if (stat(file, &s) != 0)
|
||||
return 0;
|
||||
|
||||
if (S_ISDIR(s.st_mode))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
@ -293,17 +309,23 @@ static cell AMX_NATIVE_CALL dir_exists(AMX *amx, cell *params) /* 1 param */
|
|||
|
||||
#if defined WIN32 || defined _WIN32
|
||||
DWORD attr = GetFileAttributes(file);
|
||||
|
||||
if (attr == INVALID_FILE_ATTRIBUTES)
|
||||
return 0;
|
||||
|
||||
if (attr == FILE_ATTRIBUTE_DIRECTORY)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
#else
|
||||
struct stat s;
|
||||
|
||||
if (stat(file, &s) != 0)
|
||||
return 0;
|
||||
|
||||
if (S_ISDIR(s.st_mode))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
@ -320,6 +342,7 @@ static cell AMX_NATIVE_CALL file_size(AMX *amx, cell *params) /* 1 param */
|
|||
{
|
||||
fseek(fp, 0, SEEK_END);
|
||||
int size = ftell(fp);
|
||||
|
||||
return size;
|
||||
}
|
||||
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')
|
||||
return 1;
|
||||
|
||||
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);
|
||||
|
||||
FILE *fp = fopen(file, flags);
|
||||
|
||||
if (fp == NULL)
|
||||
{
|
||||
// Failed
|
||||
|
@ -396,6 +421,7 @@ static cell AMX_NATIVE_CALL amx_fclose(AMX *amx, cell *params)
|
|||
|
||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||
return 0;
|
||||
|
||||
FILE *fp = FileList.at(id);
|
||||
|
||||
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)
|
||||
return 0;
|
||||
|
||||
FILE *fp = FileList.at(id);
|
||||
|
||||
char *buffer;
|
||||
|
@ -422,6 +449,7 @@ static cell AMX_NATIVE_CALL amx_fread(AMX *amx, cell *params)
|
|||
fread(buffer, sizeof(char), params[3], fp);
|
||||
set_amxstring(amx, params[2], buffer, params[3]);
|
||||
delete [] buffer;
|
||||
|
||||
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)
|
||||
return 0;
|
||||
|
||||
FILE *fp = FileList.at(id);
|
||||
|
||||
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)
|
||||
return 0;
|
||||
|
||||
FILE *fp = FileList.at(id);
|
||||
char *buf;
|
||||
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)
|
||||
return 0;
|
||||
|
||||
FILE *fp = FileList.at(id);
|
||||
|
||||
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)
|
||||
return 0;
|
||||
|
||||
FILE *fp = FileList.at(id);
|
||||
|
||||
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)
|
||||
return 0;
|
||||
|
||||
FILE *fp = FileList.at(id);
|
||||
|
||||
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)
|
||||
return 0;
|
||||
|
||||
FILE *fp = FileList.at(id);
|
||||
|
||||
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)
|
||||
return 0;
|
||||
|
||||
FILE *fp = FileList.at(id);
|
||||
|
||||
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)
|
||||
return 0;
|
||||
|
||||
FILE *fp = FileList.at(id);
|
||||
|
||||
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)
|
||||
return 0;
|
||||
|
||||
FILE *fp = FileList.at(id);
|
||||
|
||||
if (fp)
|
||||
|
@ -591,12 +628,14 @@ static cell AMX_NATIVE_CALL amx_filesize(AMX *amx, cell *params)
|
|||
int len;
|
||||
char *file = build_pathname("%s", format_amxstring(amx, params, 1, len));
|
||||
long size;
|
||||
|
||||
AutoFilePtr fp(fopen(file, "rb"));
|
||||
|
||||
if (fp)
|
||||
{
|
||||
fseek(fp, 0, SEEK_END);
|
||||
size = ftell(fp);
|
||||
|
||||
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)
|
||||
return 0;
|
||||
|
||||
FILE *fp = FileList.at(id);
|
||||
|
||||
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)
|
||||
return 0;
|
||||
|
||||
FILE *fp = FileList.at(id);
|
||||
|
||||
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)
|
||||
return 0;
|
||||
|
||||
FILE *fp = FileList.at(id);
|
||||
|
||||
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)
|
||||
return 0;
|
||||
|
||||
FILE *fp = FileList.at(id);
|
||||
|
||||
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)
|
||||
return 0;
|
||||
|
||||
FILE *fp = FileList.at(id);
|
||||
|
||||
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)
|
||||
return 0;
|
||||
|
||||
FILE *fp = FileList.at(id);
|
||||
|
||||
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)
|
||||
return 0;
|
||||
|
||||
FILE *fp = FileList.at(id);
|
||||
|
||||
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)
|
||||
return 0;
|
||||
|
||||
FILE *fp = FileList.at(id);
|
||||
|
||||
float size = *(float *)((void *)¶ms[2]);
|
||||
|
@ -757,6 +804,7 @@ static cell AMX_NATIVE_CALL amx_build_pathname(AMX *amx, cell *params)
|
|||
{
|
||||
int len;
|
||||
char *szPath = get_amxstring(amx, params[1], 0, len);
|
||||
|
||||
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
|
||||
char *dirname = build_pathname("%s\\*", path);
|
||||
|
||||
WIN32_FIND_DATA fd;
|
||||
HANDLE hFile = FindFirstFile(dirname, &fd);
|
||||
|
||||
if (hFile == INVALID_HANDLE_VALUE)
|
||||
return 0;
|
||||
|
||||
set_amxstring(amx, params[2], fd.cFileName, params[3]);
|
||||
|
||||
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)
|
||||
return 0;
|
||||
|
||||
FindClose(hFile);
|
||||
|
||||
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)
|
||||
return 0;
|
||||
|
||||
WIN32_FIND_DATA fd;
|
||||
|
||||
if (!FindNextFile(hFile, &fd))
|
||||
return 0;
|
||||
|
||||
set_amxstring(amx, params[2], fd.cFileName, params[3]);
|
||||
|
||||
return 1;
|
||||
|
@ -839,6 +892,7 @@ static cell AMX_NATIVE_CALL amx_get_dir(AMX *amx, cell *params)
|
|||
|
||||
if (!ep)
|
||||
return 0;
|
||||
|
||||
set_amxstring(amx, params[2], ep->d_name, params[3]);
|
||||
|
||||
return 1;
|
||||
|
|
|
@ -30,9 +30,11 @@
|
|||
*/
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#if defined WIN32
|
||||
#include <direct.h>
|
||||
#endif
|
||||
|
||||
#include "amxmodx.h"
|
||||
#include "fakemeta.h"
|
||||
#include "newmenus.h"
|
||||
|
@ -60,6 +62,7 @@ pextension_funcs_t *gpMetaPExtFuncs;
|
|||
|
||||
funEventCall modMsgsEnd[MAX_REG_MSGS];
|
||||
funEventCall modMsgs[MAX_REG_MSGS];
|
||||
|
||||
void (*function)(void*);
|
||||
void (*endfunction)(void*);
|
||||
|
||||
|
@ -75,6 +78,7 @@ CPlayer* mPlayer;
|
|||
CPluginMngr g_plugins;
|
||||
CTaskMngr g_tasksMngr;
|
||||
CmdMngr g_commands;
|
||||
|
||||
EventsMngr g_events;
|
||||
Grenades g_grenades;
|
||||
LogEventsMngr g_logevents;
|
||||
|
@ -83,16 +87,20 @@ CLangMngr g_langMngr;
|
|||
String g_log_dir;
|
||||
String g_mod_name;
|
||||
XVars g_xvars;
|
||||
|
||||
bool g_bmod_cstrike;
|
||||
bool g_bmod_dod;
|
||||
bool g_dontprecache;
|
||||
bool g_forcedmodules;
|
||||
bool g_forcedsounds;
|
||||
|
||||
fakecmd_t g_fakecmd;
|
||||
|
||||
float g_game_restarting;
|
||||
float g_game_timeleft;
|
||||
float g_task_time;
|
||||
float g_auth_time;
|
||||
|
||||
bool g_initialized = false;
|
||||
bool g_IsNewMM = false;
|
||||
bool g_NeedsP = false;
|
||||
|
@ -260,6 +268,7 @@ int C_Spawn(edict_t *pent)
|
|||
// ###### Load modules
|
||||
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
|
||||
|
||||
// Set some info about amx version and modules
|
||||
CVAR_SET_STRING(init_amxmodx_version.name, AMX_VERSION);
|
||||
char buffer[32];
|
||||
|
@ -280,11 +289,9 @@ int C_Spawn(edict_t *pent)
|
|||
g_game_timeleft = g_bmod_dod ? 1.0f : 0.0f;
|
||||
g_task_time = gpGlobals->time + 99999.0f;
|
||||
g_auth_time = gpGlobals->time + 99999.0f;
|
||||
|
||||
#ifdef MEMORY_TEST
|
||||
g_next_memreport_time = gpGlobals->time + 99999.0f;
|
||||
#endif
|
||||
|
||||
g_players_num = 0;
|
||||
|
||||
// Set server flags
|
||||
|
@ -494,7 +501,9 @@ void C_ServerDeactivate_Post()
|
|||
g_xvars.clear();
|
||||
g_plugins.clear();
|
||||
ClearPluginLibraries();
|
||||
|
||||
char file[256];
|
||||
|
||||
g_langMngr.Save(build_pathname_r(file, sizeof(file) - 1, "%s/languages.dat", get_localinfo("amxx_datadir", "addons/amxmodx/data")));
|
||||
g_langMngr.SaveCache(build_pathname_r(file, sizeof(file) - 1, "%s/dictionary.cache", get_localinfo("amxx_datadir", "addons/amxmodx/data")));
|
||||
g_langMngr.Clear();
|
||||
|
@ -540,12 +549,15 @@ void C_ServerDeactivate_Post()
|
|||
}
|
||||
}
|
||||
g_memreport_dir.assign(buffer);
|
||||
|
||||
// g_memreport_dir should be valid now
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
g_memreport_count++;
|
||||
}
|
||||
#endif // MEMORY_TEST
|
||||
|
@ -637,8 +649,10 @@ void C_ClientUserInfoChanged_Post(edict_t *pEntity, char *infobuffer)
|
|||
void C_ClientCommand(edict_t *pEntity)
|
||||
{
|
||||
CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity);
|
||||
|
||||
META_RES result = MRES_IGNORED;
|
||||
cell ret = 0;
|
||||
|
||||
const char* cmd = CMD_ARGV(0);
|
||||
const char* arg = CMD_ARGV(1);
|
||||
|
||||
|
@ -649,6 +663,7 @@ void C_ClientCommand(edict_t *pEntity)
|
|||
{
|
||||
// Print version
|
||||
static char buf[1024];
|
||||
|
||||
sprintf(buf, "%s %s\n", Plugin_info.name, Plugin_info.version);
|
||||
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);
|
||||
|
@ -675,7 +690,9 @@ void C_ClientCommand(edict_t *pEntity)
|
|||
/* check for command and if needed also for first argument and call proper function */
|
||||
|
||||
CmdMngr::iterator aa = g_commands.clcmdprefixbegin(cmd);
|
||||
if (!aa) aa = g_commands.clcmdbegin();
|
||||
|
||||
if (!aa)
|
||||
aa = g_commands.clcmdbegin();
|
||||
|
||||
while (aa)
|
||||
{
|
||||
|
@ -717,9 +734,10 @@ void C_ClientCommand(edict_t *pEntity)
|
|||
int item = pMenu->PagekeyToItem(pPlayer->page, pressed_key);
|
||||
ret = executeForwards((*a).getFunction(), pPlayer->index, menu, item);
|
||||
|
||||
if (ret & 2) result = MRES_SUPERCEDE;
|
||||
else
|
||||
if (ret & 1) RETURN_META(MRES_SUPERCEDE);
|
||||
if (ret & 2)
|
||||
result = MRES_SUPERCEDE;
|
||||
else if (ret & 1)
|
||||
RETURN_META(MRES_SUPERCEDE);
|
||||
else
|
||||
{
|
||||
if (item == MENU_BACK)
|
||||
|
@ -774,6 +792,7 @@ void C_StartFrame_Post(void)
|
|||
(*a)->Authorize();
|
||||
executeForwards(FF_ClientAuthorized, (*a)->index);
|
||||
a.remove();
|
||||
|
||||
continue;
|
||||
}
|
||||
++a;
|
||||
|
@ -791,6 +810,7 @@ void C_StartFrame_Post(void)
|
|||
time_t td;
|
||||
time(&td);
|
||||
tm *curTime = localtime(&td);
|
||||
|
||||
int i = 0;
|
||||
#ifdef __linux__
|
||||
mkdir(build_pathname("%s/memreports", get_localinfo("amxx_basedir", "addons/amxmodx")), 0700);
|
||||
|
@ -826,8 +846,10 @@ void C_StartFrame_Post(void)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
g_memreport_count++;
|
||||
}
|
||||
#endif // MEMORY_TEST
|
||||
|
@ -836,7 +858,6 @@ void C_StartFrame_Post(void)
|
|||
RETURN_META(MRES_IGNORED);
|
||||
|
||||
g_task_time = gpGlobals->time + 0.1f;
|
||||
|
||||
g_tasksMngr.startFrame();
|
||||
|
||||
// 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;
|
||||
#endif
|
||||
int stop = (int)ed->v.armorvalue;
|
||||
|
||||
*z = 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;
|
||||
function = modMsgs[msg_type];
|
||||
endfunction = modMsgsEnd[msg_type];
|
||||
|
||||
g_events.parserInit(msg_type, &gpGlobals->time, mPlayer, mPlayerIndex);
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
|
@ -970,6 +993,7 @@ void C_ChangeLevel(char* s1, char* s2)
|
|||
{
|
||||
int retVal = 0;
|
||||
char *map = s1;
|
||||
|
||||
retVal = executeForwards(FF_ChangeLevel, map);
|
||||
|
||||
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;
|
||||
|
||||
LOG_MESSAGE(PLID, "WARNING: meta-interface version mismatch; requested=%s ours=%s", Plugin_info.logtag, ifvers);
|
||||
|
||||
sscanf(ifvers, "%d:%d", &mmajor, &mminor);
|
||||
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_modules);
|
||||
CVAR_REGISTER(&init_amxmodx_debug);
|
||||
|
||||
amxmodx_version = CVAR_GET_POINTER(init_amxmodx_version.name);
|
||||
|
||||
REG_SVR_COMMAND("amxx", amx_command);
|
||||
|
||||
char gameDir[512];
|
||||
|
@ -1236,9 +1263,7 @@ C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now, META_FUNCTIONS *pFunctionTable, m
|
|||
|
||||
g_mod_name.assign(a);
|
||||
|
||||
if (g_mod_name.compare("cstrike") == 0 ||
|
||||
g_mod_name.compare("czero") == 0 ||
|
||||
g_mod_name.compare("dod") == 0)
|
||||
if (g_mod_name.compare("cstrike") == 0 || g_mod_name.compare("czero") == 0 || g_mod_name.compare("dod") == 0)
|
||||
g_coloredmenus = true;
|
||||
else
|
||||
g_coloredmenus = false;
|
||||
|
@ -1499,9 +1524,7 @@ C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable, int *in
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifdef FAKEMETA
|
||||
|
||||
NEW_DLL_FUNCTIONS gNewDLLFunctionTable_Post;
|
||||
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));
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
|
@ -35,6 +35,7 @@
|
|||
#include <sys/mman.h>
|
||||
#include "sclinux.h"
|
||||
#endif
|
||||
|
||||
#include "amxmodx.h"
|
||||
#include "osdep.h" // sleep, etc
|
||||
#include "CFile.h"
|
||||
|
@ -48,6 +49,7 @@ CList<CModule,const char*> g_modules;
|
|||
CList<CScript, AMX*> g_loadedscripts;
|
||||
|
||||
CModule *g_CurrentlyCalledModule = NULL; // The module we are in at the moment; NULL otherwise
|
||||
|
||||
// also NULL for non-amxx modules
|
||||
// This is needed so we know which module called a function
|
||||
ModuleCallReason g_ModuleCallReason;
|
||||
|
@ -63,12 +65,12 @@ void report_error( int code, char* fmt, ... )
|
|||
vsnprintf(string, 255, fmt, argptr);
|
||||
string[255] = 0;
|
||||
va_end(argptr);
|
||||
if ( *string ) {
|
||||
|
||||
if (*string)
|
||||
{
|
||||
AMXXLOG_Log("Error:");
|
||||
AMXXLOG_Log(string);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
AMXXLOG_Log("!!! There was an unexpected module error.");
|
||||
AMXXLOG_Log("The server may not work correctly.");
|
||||
}
|
||||
|
@ -82,6 +84,7 @@ void print_srvconsole( char *fmt, ... )
|
|||
vsnprintf(string, sizeof(string) - 1, fmt, argptr);
|
||||
string[sizeof(string) - 1] = '\0';
|
||||
va_end(argptr);
|
||||
|
||||
SERVER_PRINT(string);
|
||||
}
|
||||
|
||||
|
@ -101,17 +104,21 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
|
|||
{
|
||||
*error = 0;
|
||||
CAmxxReader reader(filename, PAWN_CELL_SIZE / 8);
|
||||
|
||||
if (reader.GetStatus() == CAmxxReader::Err_None)
|
||||
{
|
||||
size_t bufSize = reader.GetBufferSize();
|
||||
|
||||
if (bufSize != 0)
|
||||
{
|
||||
*program = (void*) (new char[bufSize]);
|
||||
|
||||
if (!*program)
|
||||
{
|
||||
strcpy(error, "Failed to allocate memory");
|
||||
return (amx->error = AMX_ERR_MEMORY);
|
||||
}
|
||||
|
||||
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;
|
||||
uint16_t magic = hdr->magic;
|
||||
amx_Align16(&magic);
|
||||
|
||||
if (magic != AMX_MAGIC)
|
||||
{
|
||||
strcpy(error, "Invalid Plugin");
|
||||
|
@ -161,7 +169,6 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
|
|||
int err;
|
||||
memset(amx, 0, sizeof(*amx));
|
||||
bool will_be_debugged = false;
|
||||
|
||||
tagAMX_DBG *pDbg = NULL;
|
||||
|
||||
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");
|
||||
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;
|
||||
|
||||
char *addr = (char *)hdr + hdr->size;
|
||||
pDbg = new tagAMX_DBG;
|
||||
|
||||
memset(pDbg, 0, sizeof(AMX_DBG));
|
||||
|
||||
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);
|
||||
delete pDbg;
|
||||
}
|
||||
|
||||
sprintf(error, "Load error %d (invalid file format or version)", err);
|
||||
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 *rt = new char[amx->reloc_size];
|
||||
|
||||
if (!np || (!rt && amx->reloc_size > 0))
|
||||
{
|
||||
delete[] np;
|
||||
delete[] rt;
|
||||
strcpy(error, "Failed to initialize JIT'd plugin");
|
||||
|
||||
return (amx->error = AMX_ERR_INIT);
|
||||
}
|
||||
|
||||
|
@ -254,25 +268,29 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
|
|||
#endif
|
||||
if (amx->base)
|
||||
memcpy(amx->base, np, amx->code_size);
|
||||
|
||||
delete[] np;
|
||||
delete[] rt;
|
||||
|
||||
char *prg = (char *)(*program);
|
||||
|
||||
delete[] prg;
|
||||
(*program) = amx->base;
|
||||
if ( *program == 0 ){
|
||||
|
||||
if (*program == 0)
|
||||
{
|
||||
strcpy(error, "Failed to allocate memory");
|
||||
return (amx->error = AMX_ERR_MEMORY);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
delete[] np;
|
||||
delete[] rt;
|
||||
|
||||
sprintf(error, "Failed to initialize plugin (%d)", err);
|
||||
|
||||
return (amx->error = AMX_ERR_INIT_JIT);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
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)
|
||||
{
|
||||
amx_Register(amx, g_plugins.pNatives, -1);
|
||||
|
||||
if (CheckModules(amx, error))
|
||||
{
|
||||
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[len] = 0;
|
||||
|
||||
len = strlen(bs);
|
||||
|
@ -330,6 +350,7 @@ const char *StrCaseStr(const char *as, const char *bs)
|
|||
{
|
||||
b[i] = tolower(bs[i]);
|
||||
}
|
||||
|
||||
b[len] = 0;
|
||||
|
||||
return strstr(a, b);
|
||||
|
@ -340,35 +361,40 @@ int CheckModules(AMX *amx, char error[128])
|
|||
{
|
||||
int numLibraries = amx_GetLibraries(amx);
|
||||
char buffer[32];
|
||||
|
||||
bool found = false;
|
||||
bool isdbi = false;
|
||||
|
||||
CList<CModule, const char *>::iterator a;
|
||||
|
||||
const amxx_module_info_s *info;
|
||||
|
||||
Handler *pHandler = (Handler *)amx->userdata[UD_HANDLER];
|
||||
|
||||
for (int i = 0; i < numLibraries; i++)
|
||||
{
|
||||
amx_GetLibrary(amx, i, buffer, sizeof(buffer) - 1);
|
||||
found = false;
|
||||
|
||||
if (stricmp(buffer, "float") == 0)
|
||||
continue;
|
||||
|
||||
isdbi = false;
|
||||
|
||||
if (stricmp(buffer, "dbi") == 0)
|
||||
isdbi = true;
|
||||
|
||||
for (a = g_modules.begin(); a; ++a)
|
||||
{
|
||||
if ((*a).getStatusValue() == MODULE_LOADED)
|
||||
{
|
||||
info = (*a).getInfoNew();
|
||||
|
||||
if (info)
|
||||
{
|
||||
if (isdbi)
|
||||
{
|
||||
if (info->logtag
|
||||
&& (StrCaseStr(info->logtag, "sql")
|
||||
||
|
||||
StrCaseStr(info->logtag, "dbi"))
|
||||
)
|
||||
if (info->logtag && (StrCaseStr(info->logtag, "sql") || StrCaseStr(info->logtag, "dbi")))
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
|
@ -383,13 +409,16 @@ int CheckModules(AMX *amx, char error[128])
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
found = LibraryExists(buffer);
|
||||
|
||||
if (!found)
|
||||
{
|
||||
if (pHandler->HandleModule(buffer))
|
||||
found = true;
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
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<AMX_NATIVE_INFO*>::iterator cc =
|
||||
(*a).m_Natives.begin(); cc; ++cc )
|
||||
for (CList<AMX_NATIVE_INFO*>::iterator cc = (*a).m_Natives.begin(); cc; ++cc)
|
||||
amx_Register(amx, *cc, -1);
|
||||
}
|
||||
|
||||
|
@ -425,6 +453,7 @@ int set_amxnatives(AMX* amx,char error[128])
|
|||
|
||||
int idx, err;
|
||||
cell retval;
|
||||
|
||||
if (amx_FindPublic(amx, "plugin_natives", &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 flags = amx->flags;
|
||||
|
||||
Debugger *pDebugger = (Debugger *)amx->userdata[UD_DEBUGGER];
|
||||
if (pDebugger)
|
||||
delete pDebugger;
|
||||
|
||||
Handler *pHandler = (Handler *)amx->userdata[UD_HANDLER];
|
||||
if (pHandler)
|
||||
delete pHandler;
|
||||
|
||||
CList<CScript, AMX*>::iterator a = g_loadedscripts.find(amx);
|
||||
if ( a ) a.remove();
|
||||
|
||||
if (a)
|
||||
a.remove();
|
||||
|
||||
char *prg = (char *)*program;
|
||||
|
||||
if (!prg)
|
||||
return AMX_ERR_NONE;
|
||||
|
||||
#if defined JIT
|
||||
#if defined __linux__
|
||||
if ((flags & AMX_FLAG_JITC) != AMX_FLAG_JITC)
|
||||
|
@ -468,10 +505,13 @@ int unload_amxscript(AMX* amx, void** program)
|
|||
#endif
|
||||
}
|
||||
#elif defined WIN32
|
||||
|
||||
if ((flags & AMX_FLAG_JITC) != AMX_FLAG_JITC)
|
||||
{
|
||||
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());
|
||||
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)
|
||||
{
|
||||
CList<CScript, AMX*>::iterator a = g_loadedscripts.begin();
|
||||
|
||||
while (a && id--)
|
||||
++a;
|
||||
if ( a ){
|
||||
|
||||
if (a)
|
||||
{
|
||||
*filename = (*a).getName();
|
||||
*code = (*a).getCode();
|
||||
|
||||
return (*a).getAMX();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -511,11 +556,8 @@ void get_modname(char* buffer )
|
|||
char* build_pathname(char *fmt, ...)
|
||||
{
|
||||
static char string[256];
|
||||
|
||||
int b;
|
||||
|
||||
int a = b = snprintf(string, 255,
|
||||
|
||||
#ifndef __linux__
|
||||
"%s\\",
|
||||
#else
|
||||
|
@ -552,8 +594,7 @@ char *build_pathname_r(char *buffer, size_t maxlen, char *fmt, ...)
|
|||
#else
|
||||
"%s\\",
|
||||
#endif
|
||||
g_mod_name.c_str()
|
||||
);
|
||||
g_mod_name.c_str());
|
||||
|
||||
size_t len = strlen(buffer);
|
||||
char *ptr = buffer + len;
|
||||
|
@ -576,7 +617,6 @@ char *build_pathname_r(char *buffer, size_t maxlen, char *fmt, ...)
|
|||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
// build pathname based on addons dir
|
||||
char* build_pathname_addons(char *fmt, ...)
|
||||
{
|
||||
|
@ -605,6 +645,7 @@ char* build_pathname_addons(char *fmt, ... )
|
|||
bool validFile(const char* file)
|
||||
{
|
||||
const char* a = 0;
|
||||
|
||||
while (*file)
|
||||
if (*file++ == '.')
|
||||
a = file;
|
||||
|
@ -619,6 +660,7 @@ void ConvertModuleName(const char *pathString, String &path)
|
|||
{
|
||||
#if PAWN_CELL_SIZE==64
|
||||
char *ptr = strstr(pathString, "i386");
|
||||
|
||||
if (ptr)
|
||||
{
|
||||
//attempt to fix the binary name
|
||||
|
@ -627,6 +669,7 @@ void ConvertModuleName(const char *pathString, String &path)
|
|||
path.append("amd64.so");
|
||||
} else {
|
||||
ptr = strstr(pathString, ".dll");
|
||||
|
||||
if (ptr)
|
||||
{
|
||||
*ptr = 0;
|
||||
|
@ -634,6 +677,7 @@ void ConvertModuleName(const char *pathString, String &path)
|
|||
path.append("_amd64.so");
|
||||
} else {
|
||||
ptr = strstr(pathString, ".so");
|
||||
|
||||
if (ptr)
|
||||
{
|
||||
path.assign(pathString);
|
||||
|
@ -645,8 +689,10 @@ void ConvertModuleName(const char *pathString, String &path)
|
|||
}
|
||||
}
|
||||
#else
|
||||
|
||||
#ifdef __linux__
|
||||
char *ptr = strstr(pathString, "amd64");
|
||||
|
||||
if (ptr)
|
||||
{
|
||||
//attempt to fix the binary name
|
||||
|
@ -655,6 +701,7 @@ void ConvertModuleName(const char *pathString, String &path)
|
|||
path.append("i386.so");
|
||||
} else {
|
||||
ptr = strstr(pathString, ".dll");
|
||||
|
||||
if (ptr)
|
||||
{
|
||||
*ptr = 0;
|
||||
|
@ -663,6 +710,7 @@ void ConvertModuleName(const char *pathString, String &path)
|
|||
} else {
|
||||
//check to see if this file even has an extension
|
||||
ptr = strstr(pathString, ".so");
|
||||
|
||||
if (ptr)
|
||||
{
|
||||
path.assign(pathString);
|
||||
|
@ -674,15 +722,18 @@ void ConvertModuleName(const char *pathString, String &path)
|
|||
}
|
||||
#else
|
||||
char *ptr = strstr(pathString, ".dll");
|
||||
|
||||
if (ptr)
|
||||
{
|
||||
path.assign(pathString);
|
||||
} else {
|
||||
//prevent this from loading .so too
|
||||
ptr = strstr(pathString, ".so");
|
||||
|
||||
if (ptr)
|
||||
{
|
||||
int i = 0, len = strlen(pathString), c = -1;
|
||||
|
||||
for (i = len - 1; i >= 0; i--)
|
||||
{
|
||||
//cut off at first _
|
||||
|
@ -691,11 +742,13 @@ void ConvertModuleName(const char *pathString, String &path)
|
|||
//make sure this is a valid _
|
||||
if (i == len - 1 || strncmp(&(pathString[i + 1]), "amxx", 4) == 0)
|
||||
break;
|
||||
|
||||
c = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
*ptr = 0;
|
||||
|
||||
if (c == -1)
|
||||
{
|
||||
path.assign(pathString);
|
||||
|
@ -736,14 +789,16 @@ int loadModules(const char* filename, PLUG_LOADTIME now)
|
|||
{
|
||||
if (!line._fread(fp) || line.size() < 1)
|
||||
continue;
|
||||
|
||||
line.trim();
|
||||
*moduleName = 0;
|
||||
|
||||
if (sscanf(line.c_str(), "%s", moduleName) == EOF)
|
||||
continue;
|
||||
|
||||
if (moduleName[0] == ';')
|
||||
continue;
|
||||
|
||||
|
||||
char* pathname = build_pathname("%s/%s", get_localinfo("amxx_modulesdir", "addons/amxmodx/modules"), moduleName);
|
||||
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());
|
||||
|
||||
if ( a ) continue; // already loaded
|
||||
if (a)
|
||||
continue; // already loaded
|
||||
|
||||
CModule* cc = new CModule(path.c_str());
|
||||
|
||||
|
@ -768,7 +824,8 @@ int loadModules(const char* filename, PLUG_LOADTIME now)
|
|||
|
||||
cc->queryModule();
|
||||
|
||||
switch( cc->getStatusValue() ) {
|
||||
switch (cc->getStatusValue())
|
||||
{
|
||||
case MODULE_BADLOAD:
|
||||
report_error(1, "[AMXX] Module is not a valid library (file \"%s\")", path.c_str());
|
||||
break;
|
||||
|
@ -803,11 +860,13 @@ int loadModules(const char* filename, PLUG_LOADTIME now)
|
|||
if (cc->IsMetamod())
|
||||
{
|
||||
char* mmpathname = build_pathname_addons("%s/%s", get_localinfo("amxx_modulesdir", "addons/amxmodx/modules"), line.c_str());
|
||||
|
||||
ConvertModuleName(mmpathname, path);
|
||||
cc->attachMetamod(path.c_str(), now);
|
||||
}
|
||||
|
||||
bool retVal = cc->attachModule();
|
||||
|
||||
if (cc->isAmxx() && !retVal)
|
||||
{
|
||||
switch (cc->getStatusValue())
|
||||
|
@ -859,12 +918,11 @@ void detachReloadModules()
|
|||
{
|
||||
(*a).detachModule();
|
||||
a.remove();
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
++a;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#ifdef FAKEMETA
|
||||
|
@ -875,6 +933,7 @@ void attachModules()
|
|||
while (a)
|
||||
{
|
||||
bool retVal = (*a).attachModule();
|
||||
|
||||
if ((*a).isAmxx() && !retVal)
|
||||
{
|
||||
switch ((*a).getStatusValue())
|
||||
|
@ -893,7 +952,6 @@ void attachModules()
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
++a;
|
||||
}
|
||||
}
|
||||
|
@ -902,13 +960,17 @@ void attachModules()
|
|||
const char* strip_name(const char* a)
|
||||
{
|
||||
const char* ret = a;
|
||||
while(*a){
|
||||
if ( *a== '/' || *a=='\\' ){
|
||||
|
||||
while (*a)
|
||||
{
|
||||
if (*a == '/' || *a == '\\')
|
||||
{
|
||||
ret = ++a;
|
||||
continue;
|
||||
}
|
||||
++a;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -972,17 +1034,18 @@ void attachMetaModModules(PLUG_LOADTIME now, const char* filename)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
g_FakeMeta.Meta_Query(gpMetaUtilFuncs);
|
||||
g_FakeMeta.Meta_Attach(now, gpMetaGlobals, gpGamedllFuncs);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// Get the number of running modules
|
||||
int countModules(CountModulesMode mode)
|
||||
{
|
||||
CList<CModule, const char *>::iterator iter;
|
||||
int num;
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case CountModules_All:
|
||||
|
@ -990,24 +1053,29 @@ int countModules(CountModulesMode mode)
|
|||
case CountModules_Running:
|
||||
iter = g_modules.begin();
|
||||
num = 0;
|
||||
|
||||
while (iter)
|
||||
{
|
||||
if ((*iter).getStatusValue() == MODULE_LOADED)
|
||||
++num;
|
||||
++iter;
|
||||
}
|
||||
|
||||
return num;
|
||||
case CountModules_Stopped:
|
||||
iter = g_modules.begin();
|
||||
num = 0;
|
||||
|
||||
while (iter)
|
||||
{
|
||||
if ((*iter).getStatusValue() != MODULE_LOADED)
|
||||
++num;
|
||||
++iter;
|
||||
}
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1015,6 +1083,7 @@ int countModules(CountModulesMode mode)
|
|||
void modules_callPluginsLoaded()
|
||||
{
|
||||
CList<CModule, const char *>::iterator iter = g_modules.begin();
|
||||
|
||||
while (iter)
|
||||
{
|
||||
(*iter).CallPluginsLoaded();
|
||||
|
@ -1023,7 +1092,6 @@ void modules_callPluginsLoaded()
|
|||
}
|
||||
|
||||
// new functions
|
||||
|
||||
int MNF_AddNatives(AMX_NATIVE_INFO* natives)
|
||||
{
|
||||
CList<CModule, const char *>::iterator a = g_modules.begin();
|
||||
|
@ -1037,6 +1105,7 @@ int MNF_AddNatives(AMX_NATIVE_INFO* natives)
|
|||
return FALSE;
|
||||
|
||||
g_CurrentlyCalledModule->m_Natives.put(pPtr);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -1055,22 +1124,26 @@ const char *MNF_GetModname(void)
|
|||
AMX *MNF_GetAmxScript(int id)
|
||||
{
|
||||
CList<CScript, AMX*>::iterator iter = g_loadedscripts.begin();
|
||||
|
||||
while (iter && id--)
|
||||
++iter;
|
||||
|
||||
if (iter == NULL)
|
||||
return NULL;
|
||||
|
||||
return (*iter).getAMX();
|
||||
}
|
||||
|
||||
const char *MNF_GetAmxScriptName(int id)
|
||||
{
|
||||
CList<CScript, AMX*>::iterator iter = g_loadedscripts.begin();
|
||||
|
||||
while (iter && id--)
|
||||
++iter;
|
||||
|
||||
if (iter == NULL)
|
||||
return NULL;
|
||||
|
||||
return (*iter).getName();
|
||||
}
|
||||
|
||||
|
@ -1079,6 +1152,7 @@ int MNF_FindAmxScriptByName(const char *name)
|
|||
CList<CScript, AMX*>::iterator iter = g_loadedscripts.begin();
|
||||
bool found = false;
|
||||
int i = 0;
|
||||
|
||||
while (iter)
|
||||
{
|
||||
if (stricmp((*iter).getName(), name) == 0)
|
||||
|
@ -1089,8 +1163,10 @@ int MNF_FindAmxScriptByName(const char *name)
|
|||
++iter;
|
||||
++i;
|
||||
}
|
||||
|
||||
if (!found)
|
||||
return -1;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
|
@ -1099,7 +1175,9 @@ int MNF_FindAmxScriptByAmx(const AMX *amx)
|
|||
CList<CScript, AMX*>::iterator iter = g_loadedscripts.begin();
|
||||
bool found = false;
|
||||
int i = 0;
|
||||
|
||||
while (iter)
|
||||
|
||||
{
|
||||
if (amx == (*iter).getAMX())
|
||||
{
|
||||
|
@ -1109,8 +1187,10 @@ int MNF_FindAmxScriptByAmx(const AMX *amx)
|
|||
++iter;
|
||||
++i;
|
||||
}
|
||||
|
||||
if (!found)
|
||||
return -1;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
|
@ -1118,16 +1198,20 @@ char *MNF_GetAmxString(AMX *amx, cell amx_addr, int bufferId, int *pLen)
|
|||
{
|
||||
int len;
|
||||
char *retVal = get_amxstring(amx, amx_addr, bufferId, len);
|
||||
|
||||
if (pLen)
|
||||
*pLen = len;
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
int MNF_GetAmxStringLen(const cell *ptr)
|
||||
{
|
||||
register int c = 0;
|
||||
|
||||
while (ptr[c])
|
||||
++c;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
@ -1135,8 +1219,10 @@ char *MNF_FormatAmxString(AMX *amx, cell *params, int startParam, int *pLen)
|
|||
{
|
||||
int len;
|
||||
char *retVal = format_amxstring(amx, params, startParam, len);
|
||||
|
||||
if (pLen)
|
||||
*pLen = len;
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
@ -1144,7 +1230,9 @@ int MNF_GetPlayerFlags(int id)
|
|||
{
|
||||
if (id < 1 || id > gpGlobals->maxClients)
|
||||
return 0;
|
||||
|
||||
CPlayer *pPlayer = GET_PLAYER_POINTER_I(id);
|
||||
|
||||
return (pPlayer->flags[0]);
|
||||
}
|
||||
|
||||
|
@ -1157,116 +1245,155 @@ int MNF_IsPlayerValid(int id)
|
|||
{
|
||||
if (id < 1 || id > gpGlobals->maxClients)
|
||||
return 0;
|
||||
|
||||
CPlayer *pPlayer = GET_PLAYER_POINTER_I(id);
|
||||
|
||||
return (pPlayer->initialized) ? 1 : 0;
|
||||
}
|
||||
|
||||
const char * MNF_GetPlayerName(int id)
|
||||
{
|
||||
if (id < 1 || id > gpGlobals->maxClients)
|
||||
return NULL;
|
||||
|
||||
return GET_PLAYER_POINTER_I(id)->name.c_str();
|
||||
}
|
||||
|
||||
const char * MNF_GetPlayerIP(int id)
|
||||
{
|
||||
if (id < 1 || id > gpGlobals->maxClients)
|
||||
return NULL;
|
||||
|
||||
return GET_PLAYER_POINTER_I(id)->ip.c_str();
|
||||
}
|
||||
|
||||
int MNF_IsPlayerInGame(int id)
|
||||
{
|
||||
if (id < 1 || id > gpGlobals->maxClients)
|
||||
return 0;
|
||||
|
||||
return GET_PLAYER_POINTER_I(id)->ingame ? 1 : 0;
|
||||
}
|
||||
|
||||
int MNF_IsPlayerBot(int id)
|
||||
{
|
||||
if (id < 1 || id > gpGlobals->maxClients)
|
||||
return 0;
|
||||
|
||||
return GET_PLAYER_POINTER_I(id)->IsBot() ? 1 : 0;
|
||||
}
|
||||
|
||||
int MNF_IsPlayerAuthorized(int id)
|
||||
{
|
||||
if (id < 1 || id > gpGlobals->maxClients)
|
||||
return 0;
|
||||
|
||||
return GET_PLAYER_POINTER_I(id)->authorized ? 1 : 0;
|
||||
}
|
||||
|
||||
float MNF_GetPlayerTime(int id)
|
||||
{
|
||||
if (id < 1 || id > gpGlobals->maxClients)
|
||||
return 0.0f;
|
||||
|
||||
return GET_PLAYER_POINTER_I(id)->time;
|
||||
}
|
||||
|
||||
float MNF_GetPlayerPlayTime(int id)
|
||||
{
|
||||
if (id < 1 || id > gpGlobals->maxClients)
|
||||
return 0.0f;
|
||||
|
||||
return GET_PLAYER_POINTER_I(id)->playtime;
|
||||
}
|
||||
|
||||
int MNF_GetPlayerCurweapon(int id)
|
||||
{
|
||||
if (id < 1 || id > gpGlobals->maxClients)
|
||||
return 0;
|
||||
|
||||
return GET_PLAYER_POINTER_I(id)->current;
|
||||
}
|
||||
|
||||
int MNF_GetPlayerTeamID(int id)
|
||||
{
|
||||
if (id < 1 || id > gpGlobals->maxClients)
|
||||
return 0;
|
||||
|
||||
return GET_PLAYER_POINTER_I(id)->teamId;
|
||||
}
|
||||
|
||||
int MNF_GetPlayerDeaths(int id)
|
||||
{
|
||||
if (id < 1 || id > gpGlobals->maxClients)
|
||||
return 0;
|
||||
|
||||
return GET_PLAYER_POINTER_I(id)->deaths;
|
||||
}
|
||||
|
||||
int MNF_GetPlayerMenu(int id)
|
||||
{
|
||||
if (id < 1 || id > gpGlobals->maxClients)
|
||||
return 0;
|
||||
|
||||
return GET_PLAYER_POINTER_I(id)->menu;
|
||||
}
|
||||
|
||||
int MNF_GetPlayerKeys(int id)
|
||||
{
|
||||
if (id < 1 || id > gpGlobals->maxClients)
|
||||
return 0;
|
||||
|
||||
return GET_PLAYER_POINTER_I(id)->keys;
|
||||
}
|
||||
|
||||
int MNF_IsPlayerAlive(int id)
|
||||
{
|
||||
if (id < 1 || id > gpGlobals->maxClients)
|
||||
return 0;
|
||||
|
||||
return GET_PLAYER_POINTER_I(id)->IsAlive() ? 1 : 0;
|
||||
}
|
||||
|
||||
float MNF_GetPlayerFrags(int id)
|
||||
{
|
||||
if (id < 1 || id > gpGlobals->maxClients)
|
||||
return 0.0f;
|
||||
|
||||
return GET_PLAYER_POINTER_I(id)->pEdict->v.frags;
|
||||
}
|
||||
|
||||
int MNF_IsPlayerConnecting(int id)
|
||||
{
|
||||
if (id < 1 || id > gpGlobals->maxClients)
|
||||
return 0;
|
||||
|
||||
CPlayer * pPlayer = GET_PLAYER_POINTER_I(id);
|
||||
|
||||
return (!pPlayer->ingame && pPlayer->initialized && (GETPLAYERUSERID(pPlayer->pEdict) > 0)) ? 1 : 0;
|
||||
}
|
||||
|
||||
int MNF_IsPlayerHLTV(int id)
|
||||
{
|
||||
if (id < 1 || id > gpGlobals->maxClients)
|
||||
return 0;
|
||||
|
||||
return (GET_PLAYER_POINTER_I(id)->pEdict->v.flags & FL_PROXY) ? 1 : 0;
|
||||
}
|
||||
|
||||
float MNF_GetPlayerArmor(int id)
|
||||
{
|
||||
if (id < 1 || id > gpGlobals->maxClients)
|
||||
return 0.0f;
|
||||
|
||||
return (GET_PLAYER_POINTER_I(id)->pEdict->v.armorvalue);
|
||||
}
|
||||
|
||||
float MNF_GetPlayerHealth(int id)
|
||||
{
|
||||
if (id < 1 || id > gpGlobals->maxClients)
|
||||
return 0;
|
||||
|
||||
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);
|
||||
//vsprintf(msg, fmt, arglst);
|
||||
va_end(arglst);
|
||||
|
||||
AMXXLOG_Log("%s", msg);
|
||||
}
|
||||
|
||||
|
@ -1302,6 +1430,7 @@ void LogError(AMX *amx, int err, const char *fmt, ...)
|
|||
char msg_buffer[2048];
|
||||
|
||||
msg_buffer[0] = '\0';
|
||||
|
||||
if (fmt != NULL)
|
||||
{
|
||||
va_list ap;
|
||||
|
@ -1326,6 +1455,7 @@ void LogError(AMX *amx, int err, const char *fmt, ...)
|
|||
pHandler->SetErrorMsg(msg_buffer);
|
||||
return;
|
||||
}
|
||||
|
||||
//give the user a first-chance at blocking the error from displaying
|
||||
if (pHandler->HandleError(fmt ? msg_buffer : NULL) != 0)
|
||||
{
|
||||
|
@ -1339,6 +1469,7 @@ void LogError(AMX *amx, int err, const char *fmt, ...)
|
|||
{
|
||||
if (fmt)
|
||||
AMXXLOG_Log("%s", msg_buffer);
|
||||
|
||||
Debugger::GenericMessage(amx, err);
|
||||
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
|
||||
|
@ -1360,6 +1491,7 @@ edict_t* MNF_GetPlayerEdict(int id)
|
|||
{
|
||||
if (id < 1 || id > gpGlobals->maxClients)
|
||||
return NULL;
|
||||
|
||||
return (GET_PLAYER_POINTER_I(id)->pEdict);
|
||||
}
|
||||
|
||||
|
@ -1369,6 +1501,7 @@ const char *MNF_Format(const char *fmt, ...)
|
|||
va_start(ap, fmt);
|
||||
const char *retVal = g_langMngr.FormatString(fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
@ -1412,6 +1545,7 @@ inline bool operator ==(func_s &arg1, const char *desc)
|
|||
{
|
||||
if (strcmp(arg1.desc, desc) == 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1536,6 +1670,7 @@ void *Module_ReqFnptr(const char *funcName)
|
|||
{
|
||||
// code
|
||||
// ^---- really? wow!
|
||||
|
||||
if (!g_CurrentlyCalledModule)
|
||||
{
|
||||
return NULL;
|
||||
|
@ -1544,6 +1679,7 @@ void *Module_ReqFnptr(const char *funcName)
|
|||
g_LastRequestedFunc = funcName;
|
||||
|
||||
CList<func_s, const char *>::iterator iter;
|
||||
|
||||
for (iter = g_functions.begin(); iter; ++iter)
|
||||
{
|
||||
if (strcmp(funcName, iter->desc) == 0)
|
||||
|
@ -1554,22 +1690,25 @@ void *Module_ReqFnptr(const char *funcName)
|
|||
}
|
||||
|
||||
#if !defined MEMORY_TEST && !defined WIN32
|
||||
void * ::operator new(size_t size) {
|
||||
void * ::operator new(size_t size)
|
||||
{
|
||||
return (calloc(1, size));
|
||||
}
|
||||
|
||||
void * ::operator new[](size_t size) {
|
||||
void * ::operator new[](size_t size)
|
||||
{
|
||||
return (calloc(1, size));
|
||||
}
|
||||
|
||||
void ::operator delete(void * ptr) {
|
||||
void ::operator delete(void * ptr)
|
||||
{
|
||||
if (ptr)
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
void ::operator delete[](void * ptr) {
|
||||
void ::operator delete[](void * ptr)
|
||||
{
|
||||
if (ptr)
|
||||
free(ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ void ClearMenus()
|
|||
{
|
||||
for (size_t i = 0; i < g_NewMenus.size(); i++)
|
||||
delete g_NewMenus[i];
|
||||
|
||||
g_NewMenus.clear();
|
||||
}
|
||||
|
||||
|
@ -51,6 +52,7 @@ Menu::~Menu()
|
|||
{
|
||||
for (size_t i = 0; i < m_Items.size(); i++)
|
||||
delete m_Items[i];
|
||||
|
||||
m_Items.clear();
|
||||
}
|
||||
|
||||
|
@ -110,6 +112,7 @@ int Menu::PagekeyToItem(page_t page, item_t key)
|
|||
if (page == 0)
|
||||
{
|
||||
item_t rem = numItems >= 7 ? 7 : numItems;
|
||||
|
||||
if (key == rem)
|
||||
{
|
||||
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);
|
||||
else
|
||||
_snprintf(buffer, sizeof(buffer)-1, "%s %d/%d\n\n", m_Title.c_str(), page + 1, pages);
|
||||
|
||||
m_Text.append(buffer);
|
||||
|
||||
item_t start = page * 7;
|
||||
|
@ -200,15 +204,19 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
|
|||
}
|
||||
|
||||
menuitem *pItem = NULL;
|
||||
|
||||
int option = 0;
|
||||
keys = 0;
|
||||
bool enabled = true;
|
||||
int ret = 0;
|
||||
|
||||
for (item_t i = start; i < end; i++)
|
||||
{
|
||||
pItem = m_Items[i];
|
||||
|
||||
if (pItem->access && !(pItem->access & g_players[player].flags[0]))
|
||||
enabled = false;
|
||||
|
||||
if (pItem->handler != -1)
|
||||
{
|
||||
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)
|
||||
enabled = false;
|
||||
}
|
||||
|
||||
if (pItem->pfn)
|
||||
{
|
||||
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)
|
||||
enabled = false;
|
||||
}
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
keys |= (1<<option);
|
||||
|
@ -240,6 +250,7 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
|
|||
}
|
||||
m_Text.append(buffer);
|
||||
}
|
||||
|
||||
//now for a weird part >:o
|
||||
//this will either be MORE or BACK..
|
||||
keys |= (1<<option++);
|
||||
|
@ -249,7 +260,9 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
|
|||
} else {
|
||||
_snprintf(buffer, sizeof(buffer)-1, "%d. %s\n", option, "Exit");
|
||||
}
|
||||
|
||||
m_Text.append(buffer);
|
||||
|
||||
if (pages > 1)
|
||||
{
|
||||
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);
|
||||
|
||||
int func = registerSPForwardByName(amx, handler, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
|
||||
|
||||
if (func == -1)
|
||||
{
|
||||
LogError(amx, AMX_ERR_NOTFOUND, "Invalid function \"%s\"", handler);
|
||||
|
|
|
@ -47,8 +47,10 @@ struct menuitem
|
|||
{
|
||||
String name;
|
||||
String cmd;
|
||||
|
||||
int access;
|
||||
int handler;
|
||||
|
||||
MENUITEM_CALLBACK pfn;
|
||||
size_t id;
|
||||
};
|
||||
|
@ -62,18 +64,23 @@ class Menu
|
|||
public:
|
||||
Menu(const char *title, int menuId, int thisId);
|
||||
~Menu();
|
||||
|
||||
menuitem *GetMenuItem(item_t item);
|
||||
size_t GetPageCount();
|
||||
size_t GetItemCount();
|
||||
menuitem *AddItem(const char *name, const char *cmd, int access);
|
||||
|
||||
const char *GetTextString(int player, page_t page, int &keys);
|
||||
bool Display(int player, page_t page);
|
||||
|
||||
int PagekeyToItem(page_t page, item_t key);
|
||||
int GetMenuMenuid();
|
||||
private:
|
||||
CVector<menuitem * > m_Items;
|
||||
|
||||
String m_Title;
|
||||
String m_Text;
|
||||
|
||||
int menuId;
|
||||
int thisId;
|
||||
};
|
||||
|
|
|
@ -107,7 +107,6 @@ void copy_amxmemory(cell* dest, cell* src, int len)
|
|||
*dest++=*src++;
|
||||
}
|
||||
|
||||
|
||||
char* parse_arg(char** line, int& state)
|
||||
{
|
||||
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 char buffor[3072];
|
||||
|
||||
cell *a = get_amxaddr(amx, params[1]);
|
||||
cell *b = get_amxaddr(amx, params[3]);
|
||||
cell *c = get_amxaddr(amx, params[4]);
|
||||
|
||||
int iMain = amxstring_len(a);
|
||||
int iWhat = amxstring_len(b);
|
||||
int iWith = amxstring_len(c);
|
||||
|
@ -264,6 +265,7 @@ static cell AMX_NATIVE_CALL numtostr(AMX *amx, cell *params) /* 3 param */
|
|||
{
|
||||
char szTemp[32];
|
||||
sprintf(szTemp, "%d", (int)params[1]);
|
||||
|
||||
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];
|
||||
sprintf(szTemp, "%f", amx_ctof(params[1]));
|
||||
|
||||
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;
|
||||
cell bytes= *(cell *)(data + (int)amx->frm + 2 * 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;
|
||||
cell value = *(cell *)(data + (int)amx->frm + (pos + 3) * sizeof(cell));
|
||||
|
||||
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;
|
||||
cell value = *(cell *)(data + (int)amx->frm + (pos + 3) * sizeof(cell));
|
||||
cell number = *(cell *)(data + (int)value);
|
||||
|
||||
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
|
||||
|
||||
return set_amxstring(amx, params[1], string, params[2]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user