more cleaned-up code
This commit is contained in:
parent
612a86dbef
commit
76760b221d
@ -111,8 +111,7 @@ CmdMngr::Command* CmdMngr::getCmd(long int id, int type, int access)
|
||||
|
||||
while (buf_cmdptr)
|
||||
{
|
||||
if ((*buf_cmdptr).gotAccess(access) && (*buf_cmdptr).getPlugin()->isExecutable((*buf_cmdptr).getFunction())
|
||||
&& (*buf_cmdptr).isViewable())
|
||||
if ((*buf_cmdptr).gotAccess(access) && (*buf_cmdptr).getPlugin()->isExecutable((*buf_cmdptr).getFunction()) && (*buf_cmdptr).isViewable())
|
||||
{
|
||||
if (id-- == 0)
|
||||
return &(*buf_cmdptr);
|
||||
@ -154,7 +153,7 @@ void CmdMngr::setCmdLink(CmdLink** a, Command* c, bool sorted)
|
||||
{
|
||||
while (*a)
|
||||
{
|
||||
int i = strcmp(c->getCommand(),(*a)->cmd->getCommand());
|
||||
int i = strcmp(c->getCommand(), (*a)->cmd->getCommand());
|
||||
|
||||
if ((i < 0) || (i == 0) && (strcmp(c->getArgument(), (*a)->cmd->getArgument()) < 0))
|
||||
break;
|
||||
@ -184,7 +183,7 @@ void CmdMngr::clearCmdLink(CmdLink** phead, bool pclear)
|
||||
|
||||
void CmdMngr::Command::setCmdType(int a)
|
||||
{
|
||||
switch(a)
|
||||
switch (a)
|
||||
{
|
||||
case CMD_ConsoleCommand: cmdtype |= 3; break;
|
||||
case CMD_ClientCommand: cmdtype |= 1; break;
|
||||
@ -207,7 +206,7 @@ void CmdMngr::Command::setCmdType(int a)
|
||||
|
||||
const char* CmdMngr::Command::getCmdType() const
|
||||
{
|
||||
switch(cmdtype)
|
||||
switch (cmdtype)
|
||||
{
|
||||
case 1: return "client";
|
||||
case 2: return "server";
|
||||
|
@ -299,7 +299,7 @@ void EventsMngr::parseValue(int iValue)
|
||||
if (condIter->paramId == m_ParsePos)
|
||||
{
|
||||
anyConditions = true;
|
||||
switch(condIter->type)
|
||||
switch (condIter->type)
|
||||
{
|
||||
case '=': if (condIter->iValue == iValue) execute = true; break;
|
||||
case '!': if (condIter->iValue != iValue) execute = true; break;
|
||||
@ -345,7 +345,7 @@ void EventsMngr::parseValue(float fValue)
|
||||
if (condIter->paramId == m_ParsePos)
|
||||
{
|
||||
anyConditions = true;
|
||||
switch(condIter->type)
|
||||
switch (condIter->type)
|
||||
{
|
||||
case '=': if (condIter->fValue == fValue) execute = true; break;
|
||||
case '!': if (condIter->fValue != fValue) execute = true; break;
|
||||
@ -390,7 +390,7 @@ void EventsMngr::parseValue(const char *sz)
|
||||
if (condIter->paramId == m_ParsePos)
|
||||
{
|
||||
anyConditions = true;
|
||||
switch(condIter->type)
|
||||
switch (condIter->type)
|
||||
{
|
||||
case '=': if (!strcmp(sz, condIter->sValue.c_str())) execute = true; break;
|
||||
case '!': if (strcmp(sz, condIter->sValue.c_str())) execute = true; break;
|
||||
@ -440,7 +440,7 @@ const char* EventsMngr::getArgString(int a) const
|
||||
|
||||
static char var[32];
|
||||
|
||||
switch(m_ParseVault[a].type)
|
||||
switch (m_ParseVault[a].type)
|
||||
{
|
||||
case MSG_INTEGER:
|
||||
sprintf(var, "%d", m_ParseVault[a].iValue);
|
||||
@ -458,7 +458,7 @@ int EventsMngr::getArgInteger(int a) const
|
||||
if (a < 0 || a > m_ParsePos)
|
||||
return 0;
|
||||
|
||||
switch(m_ParseVault[a].type)
|
||||
switch (m_ParseVault[a].type)
|
||||
{
|
||||
case MSG_INTEGER:
|
||||
return m_ParseVault[a].iValue;
|
||||
@ -474,7 +474,7 @@ float EventsMngr::getArgFloat(int a) const
|
||||
if (a < 0 || a > m_ParsePos)
|
||||
return 0.0f;
|
||||
|
||||
switch(m_ParseVault[a].type)
|
||||
switch (m_ParseVault[a].type)
|
||||
{
|
||||
case MSG_INTEGER:
|
||||
return static_cast<float>(m_ParseVault[a].iValue);
|
||||
|
@ -556,10 +556,12 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
|
||||
} else {
|
||||
cpLangName = ENTITY_KEYVALUE(GET_PLAYER_POINTER_I(m_CurGlobId)->pEdict, "lang");
|
||||
}
|
||||
} else if (*pAmxLangName == LANG_SERVER) // LANG_SERVER
|
||||
}
|
||||
else if (*pAmxLangName == LANG_SERVER) // LANG_SERVER
|
||||
{
|
||||
cpLangName = g_vault.get("server_language");
|
||||
} else if (*pAmxLangName >= 1 && *pAmxLangName <= 32) // Direct Client Id
|
||||
}
|
||||
else if (*pAmxLangName >= 1 && *pAmxLangName <= 32) // Direct Client Id
|
||||
{
|
||||
if ((int)CVAR_GET_FLOAT("amx_client_languages") == 0)
|
||||
{
|
||||
@ -629,7 +631,6 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
|
||||
cell *tmpCell = get_amxaddr(amx, params[parm++]);
|
||||
while (tmpPtr-tmpString < sizeof(tmpString) && *tmpCell)
|
||||
*tmpPtr++ = static_cast<char>(*tmpCell++);
|
||||
|
||||
*tmpPtr = 0;
|
||||
_snprintf(outptr, sizeof(outbuf)-(outptr-outbuf)-1, format, tmpString);
|
||||
ZEROTERM(outbuf);
|
||||
@ -815,10 +816,12 @@ char *CLangMngr::FormatString(const char *fmt, va_list &ap)
|
||||
} else {
|
||||
cpLangName = ENTITY_KEYVALUE(GET_PLAYER_POINTER_I(m_CurGlobId)->pEdict, "lang");
|
||||
}
|
||||
} else if (pAmxLangName == (const char *)LANG_SERVER) // LANG_SERVER
|
||||
}
|
||||
else if (pAmxLangName == (const char *)LANG_SERVER) // LANG_SERVER
|
||||
{
|
||||
cpLangName = g_vault.get("server_language");
|
||||
} else if (pAmxLangName >= (const char *)1 && pAmxLangName <= (const char *)32) // Direct Client Id
|
||||
}
|
||||
else if (pAmxLangName >= (const char *)1 && pAmxLangName <= (const char *)32) // Direct Client Id
|
||||
{
|
||||
if ((int)CVAR_GET_FLOAT("amx_client_languages"))
|
||||
{
|
||||
@ -1126,6 +1129,7 @@ int CLangMngr::MergeDefinitionFile(const char *file)
|
||||
} // if !multiline
|
||||
} //if - main
|
||||
}
|
||||
|
||||
// merge last section
|
||||
if (!Defq.empty())
|
||||
{
|
||||
@ -1170,6 +1174,7 @@ const char *CLangMngr::GetDef(const char *langName, const char *key)
|
||||
CLang *lang = GetLangR(langName);
|
||||
if (lang)
|
||||
return lang->GetDef(key);
|
||||
|
||||
return "ML_NOTFOUND(LANG)";
|
||||
}
|
||||
|
||||
|
@ -292,7 +292,7 @@ public:
|
||||
iterator find(iterator startOn, const F &desc)
|
||||
{
|
||||
iterator iter = startOn;
|
||||
while(iter)
|
||||
while (iter)
|
||||
{
|
||||
if (*iter == desc)
|
||||
break;
|
||||
|
@ -46,7 +46,7 @@ LogEventsMngr::LogEventsMngr()
|
||||
|
||||
LogEventsMngr::~LogEventsMngr()
|
||||
{
|
||||
clearLogEvents();
|
||||
clearLogEvents();
|
||||
}
|
||||
|
||||
int LogEventsMngr::CLogCmp::compareCondition(const char* string)
|
||||
|
@ -112,7 +112,7 @@ public:
|
||||
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(CPluginMngr::CPlugin *p, int f, LogEventsMngr* ppp) : plugin(p), func(f), filters(0), parent(ppp), next(0) { }
|
||||
~CLogEvent();
|
||||
public:
|
||||
inline CPluginMngr::CPlugin *getPlugin() { return plugin; }
|
||||
@ -121,7 +121,7 @@ public:
|
||||
};
|
||||
|
||||
private:
|
||||
CLogEvent *logevents[MAX_LOGARGS+1];
|
||||
CLogEvent *logevents[MAX_LOGARGS + 1];
|
||||
CLogEvent *getValidLogEvent(CLogEvent * a);
|
||||
CLogCmp* registerCondition(char* filter);
|
||||
void clearConditions();
|
||||
|
@ -35,7 +35,8 @@
|
||||
// *****************************************************
|
||||
// class MenuMngr
|
||||
// *****************************************************
|
||||
MenuMngr::MenuCommand::MenuCommand( CPluginMngr::CPlugin *a, int mi, int k, int f ) {
|
||||
MenuMngr::MenuCommand::MenuCommand(CPluginMngr::CPlugin *a, int mi, int k, int f)
|
||||
{
|
||||
plugin = a;
|
||||
keys = k;
|
||||
menuid = mi;
|
||||
@ -50,45 +51,49 @@ MenuMngr::~MenuMngr()
|
||||
|
||||
int MenuMngr::findMenuId(const char* name, AMX* amx)
|
||||
{
|
||||
for( MenuIdEle* b = headid; b ; b = b->next) {
|
||||
if ( (!amx || !b->amx || amx == b->amx) && strstr(name,b->name.c_str()) )
|
||||
return b->id;
|
||||
}
|
||||
return 0;
|
||||
for (MenuIdEle* b = headid; b; b = b->next)
|
||||
{
|
||||
if ((!amx || !b->amx || amx == b->amx) && strstr(name,b->name.c_str()))
|
||||
return b->id;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MenuMngr::registerMenuId(const char* n, AMX* a )
|
||||
int MenuMngr::registerMenuId(const char* n, AMX* a)
|
||||
{
|
||||
int id = findMenuId( n, a );
|
||||
if (id) return id;
|
||||
headid = new MenuIdEle( n, a , headid );
|
||||
if (!headid)
|
||||
return 0; // :TODO: Better error report
|
||||
return headid->id;
|
||||
int id = findMenuId(n, a);
|
||||
if (id) return id;
|
||||
headid = new MenuIdEle(n, a, headid);
|
||||
|
||||
if (!headid)
|
||||
return 0; // :TODO: Better error report
|
||||
|
||||
return headid->id;
|
||||
}
|
||||
|
||||
void MenuMngr::registerMenuCmd( CPluginMngr::CPlugin *a,int mi, int k , int f )
|
||||
void MenuMngr::registerMenuCmd(CPluginMngr::CPlugin *a, int mi, int k, int f)
|
||||
{
|
||||
MenuCommand** temp = &headcmd;
|
||||
while(*temp) temp = &(*temp)->next;
|
||||
*temp = new MenuCommand(a,mi, k,f);
|
||||
while (*temp) temp = &(*temp)->next;
|
||||
*temp = new MenuCommand(a, mi, k, f);
|
||||
}
|
||||
|
||||
void MenuMngr::clear()
|
||||
void MenuMngr::clear()
|
||||
{
|
||||
while (headid)
|
||||
{
|
||||
MenuIdEle* a = headid->next;
|
||||
delete headid;
|
||||
headid = a;
|
||||
}
|
||||
while (headid)
|
||||
{
|
||||
MenuIdEle* a = headid->next;
|
||||
delete headid;
|
||||
headid = a;
|
||||
}
|
||||
|
||||
while (headcmd)
|
||||
{
|
||||
MenuCommand* a = headcmd->next;
|
||||
delete headcmd;
|
||||
headcmd = a;
|
||||
}
|
||||
while (headcmd)
|
||||
{
|
||||
MenuCommand* a = headcmd->next;
|
||||
delete headcmd;
|
||||
headcmd = a;
|
||||
}
|
||||
}
|
||||
|
||||
int MenuMngr::MenuIdEle::uniqueid = 0;
|
||||
int MenuMngr::MenuIdEle::uniqueid = 0;
|
||||
|
@ -33,7 +33,7 @@
|
||||
// class CPlayer
|
||||
// *****************************************************
|
||||
|
||||
void CPlayer::Init( edict_t* e , int i )
|
||||
void CPlayer::Init(edict_t* e, int i)
|
||||
{
|
||||
index = i;
|
||||
pEdict = e;
|
||||
@ -55,7 +55,8 @@ void CPlayer::Init( edict_t* e , int i )
|
||||
team.clear();
|
||||
}
|
||||
|
||||
void CPlayer::Disconnect() {
|
||||
void CPlayer::Disconnect()
|
||||
{
|
||||
ingame = false;
|
||||
initialized = false;
|
||||
authorized = false;
|
||||
@ -64,8 +65,10 @@ void CPlayer::Disconnect() {
|
||||
{
|
||||
ClientCvarQuery_Info *pQuery = cvarQueryQueue.front();
|
||||
unregisterSPForward(pQuery->resultFwd);
|
||||
|
||||
if (pQuery->params)
|
||||
delete [] pQuery->params;
|
||||
|
||||
delete pQuery;
|
||||
cvarQueryQueue.pop();
|
||||
}
|
||||
@ -73,39 +76,40 @@ void CPlayer::Disconnect() {
|
||||
bot = 0;
|
||||
}
|
||||
|
||||
void CPlayer::PutInServer() {
|
||||
void CPlayer::PutInServer()
|
||||
{
|
||||
playtime = gpGlobals->time;
|
||||
ingame = true;
|
||||
}
|
||||
bool CPlayer::Connect(const char* connectname,const char* ipaddress) {
|
||||
|
||||
bool CPlayer::Connect(const char* connectname, const char* ipaddress)
|
||||
{
|
||||
name.assign(connectname);
|
||||
ip.assign(ipaddress);
|
||||
time = gpGlobals->time;
|
||||
bot = IsBot();
|
||||
death_killer = 0;
|
||||
memset(flags,0,sizeof(flags));
|
||||
memset(weapons,0,sizeof(weapons));
|
||||
memset(flags, 0, sizeof(flags));
|
||||
memset(weapons, 0, sizeof(weapons));
|
||||
initialized = true;
|
||||
authorized = false;
|
||||
|
||||
const char* authid = GETPLAYERAUTHID( pEdict );
|
||||
const char* authid = GETPLAYERAUTHID(pEdict);
|
||||
|
||||
if ( (authid == 0) || (*authid == 0)
|
||||
|| (strcmp( authid , "STEAM_ID_PENDING") == 0) )
|
||||
if ((authid == 0) || (*authid == 0) || (strcmp(authid, "STEAM_ID_PENDING") == 0))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// *****************************************************
|
||||
// class Grenades
|
||||
// *****************************************************
|
||||
void Grenades::put( edict_t* grenade, float time, int type, CPlayer* player )
|
||||
|
||||
void Grenades::put(edict_t* grenade, float time, int type, CPlayer* player)
|
||||
{
|
||||
Obj* a = new Obj;
|
||||
if ( a == 0 ) return;
|
||||
if (a == 0) return;
|
||||
a->player = player;
|
||||
a->grenade = grenade;
|
||||
a->time = gpGlobals->time + time;
|
||||
@ -114,34 +118,37 @@ void Grenades::put( edict_t* grenade, float time, int type, CPlayer* player )
|
||||
head = a;
|
||||
}
|
||||
|
||||
bool Grenades::find( edict_t* enemy, CPlayer** p, int& type )
|
||||
bool Grenades::find(edict_t* enemy, CPlayer** p, int& type)
|
||||
{
|
||||
bool found = false;
|
||||
Obj** a = &head;
|
||||
while ( *a ){
|
||||
if ( (*a)->time > gpGlobals->time ) {
|
||||
if ( (*a)->grenade == enemy ) {
|
||||
|
||||
while (*a)
|
||||
{
|
||||
if ((*a)->time > gpGlobals->time)
|
||||
{
|
||||
if ((*a)->grenade == enemy)
|
||||
{
|
||||
found = true;
|
||||
(*p) = (*a)->player;
|
||||
type = (*a)->type;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Obj* b = (*a)->next;
|
||||
delete *a;
|
||||
*a = b;
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
a = &(*a)->next;
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
void Grenades::clear()
|
||||
{
|
||||
while(head){
|
||||
while (head)
|
||||
{
|
||||
Obj* a = head->next;
|
||||
delete head;
|
||||
head = a;
|
||||
@ -151,21 +158,24 @@ void Grenades::clear()
|
||||
// *****************************************************
|
||||
// class XVars
|
||||
// *****************************************************
|
||||
void XVars::clear() {
|
||||
|
||||
void XVars::clear()
|
||||
{
|
||||
delete[] head;
|
||||
head = 0;
|
||||
num = 0;
|
||||
size = 0;
|
||||
}
|
||||
|
||||
int XVars::put( AMX* p, cell* v )
|
||||
int XVars::put(AMX* p, cell* v)
|
||||
{
|
||||
for(int a = 0; a < num; ++a) {
|
||||
if ( (head[a].amx == p) && (head[a].value == v) )
|
||||
for (int a = 0; a < num; ++a)
|
||||
{
|
||||
if ((head[a].amx == p) && (head[a].value == v))
|
||||
return a;
|
||||
}
|
||||
|
||||
if ( (num >= size) && realloc_array( size ? (size * 2) : 8 ) )
|
||||
if ((num >= size) && realloc_array(size ? (size * 2) : 8))
|
||||
return -1;
|
||||
|
||||
head[num].value = v;
|
||||
@ -173,71 +183,90 @@ int XVars::put( AMX* p, cell* v )
|
||||
return num++;
|
||||
}
|
||||
|
||||
int XVars::realloc_array( int nsize )
|
||||
int XVars::realloc_array(int nsize)
|
||||
{
|
||||
XVarEle* me = new XVarEle[nsize];
|
||||
if ( me ){
|
||||
for(int a = 0 ; a < num; ++a)
|
||||
|
||||
if (me)
|
||||
{
|
||||
for (int a = 0 ; a < num; ++a)
|
||||
me[a] = head[a];
|
||||
|
||||
delete[] head;
|
||||
head = me;
|
||||
size = nsize;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// *****************************************************
|
||||
// class TeamIds
|
||||
// *****************************************************
|
||||
|
||||
TeamIds::TeamIds() { head = 0; newTeam = 0; }
|
||||
TeamIds::~TeamIds() {
|
||||
while( head ) {
|
||||
|
||||
TeamIds::~TeamIds()
|
||||
{
|
||||
while (head)
|
||||
{
|
||||
TeamEle* a = head->next;
|
||||
delete head;
|
||||
head = a;
|
||||
}
|
||||
}
|
||||
|
||||
void TeamIds::registerTeam( const char* n ,int s )
|
||||
void TeamIds::registerTeam(const char* n, int s)
|
||||
{
|
||||
TeamEle** a = &head;
|
||||
while( *a ){
|
||||
if ( strcmp((*a)->name.c_str(),n) == 0 ){
|
||||
if (s != -1){
|
||||
|
||||
while (*a)
|
||||
{
|
||||
if (strcmp((*a)->name.c_str(),n) == 0)
|
||||
{
|
||||
if (s != -1)
|
||||
{
|
||||
(*a)->id = s;
|
||||
newTeam &= ~(1<<(*a)->tid);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
a = &(*a)->next;
|
||||
}
|
||||
*a = new TeamEle( n , s );
|
||||
if ( *a == 0 ) return;
|
||||
|
||||
*a = new TeamEle(n, s);
|
||||
if (*a == 0) return;
|
||||
newTeam |= (1<<(*a)->tid);
|
||||
}
|
||||
|
||||
int TeamIds::findTeamId( const char* n )
|
||||
int TeamIds::findTeamId(const char* n)
|
||||
{
|
||||
TeamEle* a = head;
|
||||
while( a ){
|
||||
if ( !stricmp(a->name.c_str(),n) )
|
||||
|
||||
while (a)
|
||||
{
|
||||
if (!stricmp(a->name.c_str(), n))
|
||||
return a->id;
|
||||
a = a->next;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int TeamIds::findTeamIdCase( const char* n)
|
||||
int TeamIds::findTeamIdCase(const char* n)
|
||||
{
|
||||
TeamEle* a = head;
|
||||
while( a ){
|
||||
if ( !strcmp(a->name.c_str(), n) )
|
||||
|
||||
while (a)
|
||||
{
|
||||
if (!strcmp(a->name.c_str(), n))
|
||||
return a->id;
|
||||
a = a->next;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
char TeamIds::TeamEle::uid = 0;
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include "amxmodx.h"
|
||||
|
||||
#ifndef FAR
|
||||
#define FAR
|
||||
#define FAR
|
||||
#endif
|
||||
|
||||
// New
|
||||
@ -55,7 +55,7 @@ CModule::CModule(const char* fname)
|
||||
CModule::~CModule()
|
||||
{
|
||||
// old & new
|
||||
if ( m_Handle )
|
||||
if (m_Handle)
|
||||
DLFREE(m_Handle);
|
||||
|
||||
clear();
|
||||
@ -67,6 +67,7 @@ void CModule::clear(bool clearFilename)
|
||||
m_Metamod = false;
|
||||
m_Handle = NULL;
|
||||
m_Status = MODULE_NONE;
|
||||
|
||||
if (clearFilename)
|
||||
m_Filename.assign("unknown");
|
||||
|
||||
@ -114,6 +115,7 @@ bool CModule::attachModule()
|
||||
|
||||
if (!AttachFunc_New)
|
||||
return false;
|
||||
|
||||
g_ModuleCallReason = ModuleCall_Attach;
|
||||
g_CurrentlyCalledModule = this;
|
||||
int retVal = (*AttachFunc_New)(Module_ReqFnptr);
|
||||
@ -122,21 +124,21 @@ bool CModule::attachModule()
|
||||
|
||||
switch (retVal)
|
||||
{
|
||||
case AMXX_OK:
|
||||
m_Status = MODULE_LOADED;
|
||||
return true;
|
||||
case AMXX_PARAM:
|
||||
AMXXLOG_Log("[AMXX] Internal Error: Module \"%s\" (version \"%s\") retured \"Invalid parameter\" from Attach func.", m_Filename.c_str(), getVersion());
|
||||
m_Status = MODULE_INTERROR;
|
||||
return false;
|
||||
case AMXX_FUNC_NOT_PRESENT:
|
||||
m_Status = MODULE_FUNCNOTPRESENT;
|
||||
m_MissingFunc = g_LastRequestedFunc;
|
||||
return false;
|
||||
default:
|
||||
AMXXLOG_Log("[AMXX] Module \"%s\" (version \"%s\") returned an invalid code.", m_Filename.c_str(), getVersion());
|
||||
m_Status = MODULE_BADLOAD;
|
||||
return false;
|
||||
case AMXX_OK:
|
||||
m_Status = MODULE_LOADED;
|
||||
return true;
|
||||
case AMXX_PARAM:
|
||||
AMXXLOG_Log("[AMXX] Internal Error: Module \"%s\" (version \"%s\") retured \"Invalid parameter\" from Attach func.", m_Filename.c_str(), getVersion());
|
||||
m_Status = MODULE_INTERROR;
|
||||
return false;
|
||||
case AMXX_FUNC_NOT_PRESENT:
|
||||
m_Status = MODULE_FUNCNOTPRESENT;
|
||||
m_MissingFunc = g_LastRequestedFunc;
|
||||
return false;
|
||||
default:
|
||||
AMXXLOG_Log("[AMXX] Module \"%s\" (version \"%s\") returned an invalid code.", m_Filename.c_str(), getVersion());
|
||||
m_Status = MODULE_BADLOAD;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
m_Status = MODULE_BADLOAD;
|
||||
@ -147,7 +149,7 @@ bool CModule::attachModule()
|
||||
|
||||
bool CModule::queryModule()
|
||||
{
|
||||
if (m_Status != MODULE_NONE) // don't check if already queried
|
||||
if (m_Status != MODULE_NONE) // don't check if already queried
|
||||
return false;
|
||||
|
||||
m_Handle = DLLOAD(m_Filename.c_str()); // load file
|
||||
@ -163,6 +165,7 @@ bool CModule::queryModule()
|
||||
|
||||
// Try new interface first
|
||||
QUERYMOD_NEW queryFunc_New = (QUERYMOD_NEW)DLPROC(m_Handle, "AMXX_Query");
|
||||
|
||||
if (queryFunc_New)
|
||||
{
|
||||
m_Amxx = true;
|
||||
@ -172,24 +175,25 @@ bool CModule::queryModule()
|
||||
int retVal = (*queryFunc_New)(&ifVers, &m_InfoNew);
|
||||
g_CurrentlyCalledModule = NULL;
|
||||
g_ModuleCallReason = ModuleCall_NotCalled;
|
||||
|
||||
switch (retVal)
|
||||
{
|
||||
case AMXX_PARAM:
|
||||
AMXXLOG_Log("[AMXX] Internal Error: Module \"%s\" (version \"%s\") retured \"Invalid parameter\" from Attach func.", m_Filename.c_str(), getVersion());
|
||||
m_Status = MODULE_INTERROR;
|
||||
return false;
|
||||
case AMXX_IFVERS:
|
||||
if (ifVers < AMXX_INTERFACE_VERSION)
|
||||
m_Status = MODULE_OLD;
|
||||
else
|
||||
m_Status = MODULE_NEWER;
|
||||
return false;
|
||||
case AMXX_OK:
|
||||
break;
|
||||
default:
|
||||
AMXXLOG_Log("[AMXX] Module \"%s\" (version \"%s\") returned an invalid code.", m_Filename.c_str(), getVersion());
|
||||
m_Status = MODULE_BADLOAD;
|
||||
return false;
|
||||
case AMXX_PARAM:
|
||||
AMXXLOG_Log("[AMXX] Internal Error: Module \"%s\" (version \"%s\") retured \"Invalid parameter\" from Attach func.", m_Filename.c_str(), getVersion());
|
||||
m_Status = MODULE_INTERROR;
|
||||
return false;
|
||||
case AMXX_IFVERS:
|
||||
if (ifVers < AMXX_INTERFACE_VERSION)
|
||||
m_Status = MODULE_OLD;
|
||||
else
|
||||
m_Status = MODULE_NEWER;
|
||||
return false;
|
||||
case AMXX_OK:
|
||||
break;
|
||||
default:
|
||||
AMXXLOG_Log("[AMXX] Module \"%s\" (version \"%s\") returned an invalid code.", m_Filename.c_str(), getVersion());
|
||||
m_Status = MODULE_BADLOAD;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check for attach
|
||||
@ -201,9 +205,7 @@ bool CModule::queryModule()
|
||||
|
||||
m_Status = MODULE_QUERY;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
m_Status = MODULE_NOQUERY;
|
||||
m_Amxx = false;
|
||||
return false;
|
||||
@ -218,6 +220,7 @@ bool CModule::detachModule()
|
||||
if (m_Amxx)
|
||||
{
|
||||
DETACHMOD_NEW detachFunc_New = (DETACHMOD_NEW)DLPROC(m_Handle, "AMXX_Detach");
|
||||
|
||||
if (detachFunc_New)
|
||||
{
|
||||
g_ModuleCallReason = ModuleCall_Detach;
|
||||
@ -227,14 +230,17 @@ bool CModule::detachModule()
|
||||
g_ModuleCallReason = ModuleCall_NotCalled;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef FAKEMETA
|
||||
if (IsMetamod())
|
||||
{
|
||||
UnloadMetamodPlugin(m_Handle);
|
||||
}
|
||||
#endif
|
||||
|
||||
DLFREE(m_Handle);
|
||||
clear();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -247,28 +253,31 @@ void CModule::CallPluginsLoaded()
|
||||
return;
|
||||
|
||||
PLUGINSLOADED_NEW func = (PLUGINSLOADED_NEW)DLPROC(m_Handle, "AMXX_PluginsLoaded");
|
||||
|
||||
if (!func)
|
||||
return;
|
||||
|
||||
func();
|
||||
}
|
||||
|
||||
const char* CModule::getStatus() const
|
||||
{
|
||||
switch(m_Status)
|
||||
switch (m_Status)
|
||||
{
|
||||
case MODULE_NONE: return "error";
|
||||
case MODULE_QUERY: return "pending";
|
||||
case MODULE_BADLOAD: return "bad load";
|
||||
case MODULE_LOADED: return "running";
|
||||
case MODULE_NOINFO: return "no info";
|
||||
case MODULE_NOQUERY: return "no query";
|
||||
case MODULE_NOATTACH: return "no attach";
|
||||
case MODULE_OLD: return "old";
|
||||
case MODULE_FUNCNOTPRESENT:
|
||||
case MODULE_NEWER: return "newer";
|
||||
case MODULE_INTERROR: return "internal err";
|
||||
case MODULE_NOT64BIT: return "not 64bit";
|
||||
default: break;
|
||||
case MODULE_NONE: return "error";
|
||||
case MODULE_QUERY: return "pending";
|
||||
case MODULE_BADLOAD: return "bad load";
|
||||
case MODULE_LOADED: return "running";
|
||||
case MODULE_NOINFO: return "no info";
|
||||
case MODULE_NOQUERY: return "no query";
|
||||
case MODULE_NOATTACH: return "no attach";
|
||||
case MODULE_OLD: return "old";
|
||||
case MODULE_FUNCNOTPRESENT:
|
||||
case MODULE_NEWER: return "newer";
|
||||
case MODULE_INTERROR: return "internal err";
|
||||
case MODULE_NOT64BIT: return "not 64bit";
|
||||
default: break;
|
||||
}
|
||||
|
||||
return "unknown";
|
||||
}
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "CTask.h"
|
||||
|
||||
/*********************** CTask ***********************/
|
||||
|
||||
int CTaskMngr::CTask::getTaskId() const
|
||||
{
|
||||
return m_iId;
|
||||
@ -57,12 +58,15 @@ void CTaskMngr::CTask::set(CPluginMngr::CPlugin *pPlugin, int iFunc, int iFlags,
|
||||
{
|
||||
m_bLoop = true;
|
||||
m_iRepeat = -1;
|
||||
} else if (iFlags & 1) {
|
||||
}
|
||||
else if (iFlags & 1)
|
||||
{
|
||||
m_bLoop = true;
|
||||
m_iRepeat = iRepeat;
|
||||
}
|
||||
m_bAfterStart = (iFlags & 4) ? true : false;
|
||||
m_bBeforeEnd = (iFlags & 8) ? true : false;
|
||||
|
||||
m_bAfterStart = (iFlags & 4) ? true : false;
|
||||
m_bBeforeEnd = (iFlags & 8) ? true : false;
|
||||
|
||||
m_fNextExecTime = fCurrentTime + m_fBase;
|
||||
|
||||
@ -123,8 +127,9 @@ void CTaskMngr::CTask::resetNextExecTime(float fCurrentTime)
|
||||
|
||||
void CTaskMngr::CTask::executeIfRequired(float fCurrentTime, float fTimeLimit, float fTimeLeft)
|
||||
{
|
||||
bool execute=false;
|
||||
bool done=false;
|
||||
bool execute = false;
|
||||
bool done = false;
|
||||
|
||||
if (m_bAfterStart)
|
||||
{
|
||||
if (fCurrentTime - fTimeLeft + 1.0f >= m_fBase)
|
||||
@ -134,14 +139,16 @@ void CTaskMngr::CTask::executeIfRequired(float fCurrentTime, float fTimeLimit, f
|
||||
{
|
||||
if (fTimeLimit != 0.0f && (fTimeLeft + fTimeLimit * 60.0f) - fCurrentTime - 1.0f <= m_fBase)
|
||||
execute = true;
|
||||
} else if (m_fNextExecTime <= fCurrentTime) {
|
||||
}
|
||||
else if (m_fNextExecTime <= fCurrentTime)
|
||||
{
|
||||
execute = true;
|
||||
}
|
||||
|
||||
if (execute)
|
||||
{
|
||||
//only bother calling if we have something to call
|
||||
if ( !(m_bLoop && !m_iRepeat) )
|
||||
if (!(m_bLoop && !m_iRepeat))
|
||||
{
|
||||
if (m_iParamLen) // call with parameters
|
||||
{
|
||||
@ -199,6 +206,7 @@ CTaskMngr::CTask::~CTask()
|
||||
}
|
||||
|
||||
/*********************** CTaskMngr ***********************/
|
||||
|
||||
CTaskMngr::CTaskMngr()
|
||||
{
|
||||
m_pTmr_CurrentTime = NULL;
|
||||
@ -222,17 +230,18 @@ void CTaskMngr::registerTask(CPluginMngr::CPlugin *pPlugin, int iFunc, int iFlag
|
||||
{
|
||||
// first, search for free tasks
|
||||
TaskListIter iter = m_Tasks.find(CTaskDescriptor(0, NULL, true));
|
||||
|
||||
if (iter)
|
||||
{
|
||||
// found: reuse it
|
||||
iter->set(pPlugin, iFunc, iFlags, iId, fBase, iParamsLen, pParams, iRepeat, *m_pTmr_CurrentTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// not found: make a new one
|
||||
CTask *pTmp = new CTask;
|
||||
|
||||
if (!pTmp)
|
||||
return;
|
||||
|
||||
pTmp->set(pPlugin, iFunc, iFlags, iId, fBase, iParamsLen, pParams, iRepeat, *m_pTmr_CurrentTime);
|
||||
m_Tasks.put(pTmp);
|
||||
}
|
||||
@ -242,13 +251,15 @@ int CTaskMngr::removeTasks(int iId, AMX *pAmx)
|
||||
{
|
||||
CTaskDescriptor descriptor(iId, pAmx);
|
||||
TaskListIter iter = m_Tasks.find(descriptor);
|
||||
int i=0;
|
||||
int i = 0;
|
||||
|
||||
while (iter)
|
||||
{
|
||||
iter->clear();
|
||||
++i;
|
||||
iter = m_Tasks.find(++iter, descriptor);
|
||||
iter->clear();
|
||||
++i;
|
||||
iter = m_Tasks.find(++iter, descriptor);
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
@ -256,14 +267,16 @@ int CTaskMngr::changeTasks(int iId, AMX *pAmx, float fNewBase)
|
||||
{
|
||||
CTaskDescriptor descriptor(iId, pAmx);
|
||||
TaskListIter iter = m_Tasks.find(descriptor);
|
||||
int i=0;
|
||||
int i = 0;
|
||||
|
||||
while (iter)
|
||||
{
|
||||
iter->changeBase(fNewBase);
|
||||
iter->resetNextExecTime(*m_pTmr_CurrentTime);
|
||||
++i;
|
||||
iter = m_Tasks.find(++iter, descriptor);
|
||||
iter->changeBase(fNewBase);
|
||||
iter->resetNextExecTime(*m_pTmr_CurrentTime);
|
||||
++i;
|
||||
iter = m_Tasks.find(++iter, descriptor);
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
|
@ -39,46 +39,47 @@
|
||||
// *****************************************************
|
||||
// class Vault
|
||||
// *****************************************************
|
||||
bool Vault::exists( const char* k )
|
||||
{
|
||||
if ( *k == 0 ) return false;
|
||||
|
||||
return *find( k ) != 0;
|
||||
bool Vault::exists(const char* k)
|
||||
{
|
||||
if (*k == 0) return false;
|
||||
|
||||
return *find(k) != 0;
|
||||
}
|
||||
|
||||
void Vault::put( const char* k, const char* v )
|
||||
void Vault::put(const char* k, const char* v)
|
||||
{
|
||||
if ( *k == 0 ) return;
|
||||
if (*k == 0) return;
|
||||
|
||||
if ( *v == 0 )
|
||||
if (*v == 0)
|
||||
{
|
||||
remove( k );
|
||||
remove(k);
|
||||
return;
|
||||
}
|
||||
|
||||
Obj** a = find( k );
|
||||
Obj** a = find(k);
|
||||
|
||||
if ( *a )
|
||||
if (*a)
|
||||
{
|
||||
(*a)->value.assign(v);
|
||||
(*a)->number = atoi( v );
|
||||
(*a)->number = atoi(v);
|
||||
}
|
||||
else
|
||||
*a = new Obj( k , v );
|
||||
|
||||
*a = new Obj(k, v);
|
||||
}
|
||||
|
||||
Vault::Obj::Obj( const char* k, const char* v): key(k) , value(v) , next(0) {
|
||||
Vault::Obj::Obj(const char* k, const char* v): key(k), value(v), next(0)
|
||||
{
|
||||
number = atoi(v);
|
||||
}
|
||||
|
||||
Vault::Obj** Vault::find( const char* n )
|
||||
Vault::Obj** Vault::find(const char* n)
|
||||
{
|
||||
Obj** a = &head;
|
||||
|
||||
while( *a )
|
||||
while (*a)
|
||||
{
|
||||
if ( strcmp((*a)->key.c_str(), n) == 0 )
|
||||
if (strcmp((*a)->key.c_str(), n) == 0)
|
||||
return a;
|
||||
|
||||
a = &(*a)->next;
|
||||
@ -88,31 +89,31 @@ Vault::Obj** Vault::find( const char* n )
|
||||
}
|
||||
|
||||
|
||||
int Vault::get_number( const char* n )
|
||||
int Vault::get_number(const char* n)
|
||||
{
|
||||
if ( *n == 0 ) return 0;
|
||||
if (*n == 0) return 0;
|
||||
|
||||
Obj* b = *find( n );
|
||||
Obj* b = *find(n);
|
||||
|
||||
if ( b == 0 ) return 0;
|
||||
if (b == 0) return 0;
|
||||
|
||||
return b->number;
|
||||
}
|
||||
|
||||
const char* Vault::get( const char* n )
|
||||
const char* Vault::get(const char* n)
|
||||
{
|
||||
if ( *n == 0 ) return "";
|
||||
if (*n == 0) return "";
|
||||
|
||||
Obj* b = *find( n );
|
||||
Obj* b = *find(n);
|
||||
|
||||
if ( b == 0 ) return "";
|
||||
if (b == 0) return "";
|
||||
|
||||
return b->value.c_str();
|
||||
}
|
||||
|
||||
void Vault::clear()
|
||||
{
|
||||
while ( head )
|
||||
while (head)
|
||||
{
|
||||
Obj* a = head->next;
|
||||
delete head;
|
||||
@ -120,58 +121,57 @@ void Vault::clear()
|
||||
}
|
||||
}
|
||||
|
||||
void Vault::remove( const char* n )
|
||||
void Vault::remove(const char* n)
|
||||
{
|
||||
Obj** b = find( n );
|
||||
Obj** b = find(n);
|
||||
|
||||
if ( *b == 0 ) return;
|
||||
if (*b == 0) return;
|
||||
|
||||
Obj* a = (*b)->next;
|
||||
delete *b;
|
||||
*b = a;
|
||||
}
|
||||
|
||||
void Vault::setSource( const char* n )
|
||||
void Vault::setSource(const char* n)
|
||||
{
|
||||
path.assign(n);
|
||||
}
|
||||
|
||||
|
||||
bool Vault::loadVault( )
|
||||
bool Vault::loadVault()
|
||||
{
|
||||
if ( path.empty() ) return false;
|
||||
if (path.empty()) return false;
|
||||
|
||||
clear();
|
||||
|
||||
File a( path.c_str() , "r" );
|
||||
File a(path.c_str(), "r");
|
||||
|
||||
if ( !a ) return false;
|
||||
if (!a) return false;
|
||||
|
||||
const int sz = 512;
|
||||
char value[sz+1];
|
||||
char key[sz+1];
|
||||
char value[sz + 1];
|
||||
char key[sz + 1];
|
||||
|
||||
while ( a >> key && a.skipWs() && a.getline( value , sz ) )
|
||||
while (a >> key && a.skipWs() && a.getline(value, sz))
|
||||
{
|
||||
if ( isalpha ( *key ) )
|
||||
put( key, value );
|
||||
if (isalpha(*key))
|
||||
put(key, value);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
bool Vault::saveVault( )
|
||||
bool Vault::saveVault()
|
||||
{
|
||||
if ( path.empty() ) return false;
|
||||
if (path.empty()) return false;
|
||||
|
||||
File a( path.c_str() , "w" );
|
||||
File a(path.c_str(), "w");
|
||||
|
||||
if ( !a ) return false;
|
||||
if (!a) return false;
|
||||
|
||||
a << "; Don't modify!" << '\n';
|
||||
|
||||
for (Obj* b = head; b ;b = b->next)
|
||||
for (Obj* b = head; b; b = b->next)
|
||||
a << b->key << '\t' << b->value << '\n';
|
||||
|
||||
return true;
|
||||
|
@ -105,7 +105,8 @@ CAmxxReader::CAmxxReader(const char *filename, int cellsize)
|
||||
m_pFile = NULL;
|
||||
|
||||
return;
|
||||
} else if (magic == MAGIC_HEADER2)
|
||||
}
|
||||
else if (magic == MAGIC_HEADER2)
|
||||
{
|
||||
DATAREAD(&m_Bh.version, sizeof(int16_t), 1);
|
||||
|
||||
@ -155,7 +156,8 @@ CAmxxReader::CAmxxReader(const char *filename, int cellsize)
|
||||
|
||||
pe = &(m_Bh.plugins[m_Entry]);
|
||||
m_SectionLength = pe->disksize;
|
||||
} else if (magic == MAGIC_HEADER)
|
||||
}
|
||||
else if (magic == MAGIC_HEADER)
|
||||
{
|
||||
// try to find the section
|
||||
mint8_t numOfPlugins;
|
||||
@ -185,7 +187,7 @@ CAmxxReader::CAmxxReader(const char *filename, int cellsize)
|
||||
}
|
||||
|
||||
// compute section length
|
||||
if ((i+1) < static_cast<int>(numOfPlugins))
|
||||
if ((i + 1) < static_cast<int>(numOfPlugins))
|
||||
{
|
||||
// there is a next section
|
||||
TableEntry nextEntry;
|
||||
@ -274,7 +276,8 @@ size_t CAmxxReader::GetBufferSize()
|
||||
DATAREAD(&hdr, sizeof(hdr), 1);
|
||||
fseek(m_pFile, save, SEEK_SET);
|
||||
return hdr.stp;
|
||||
} else if (m_AmxxFile)
|
||||
}
|
||||
else if (m_AmxxFile)
|
||||
{
|
||||
PluginEntry *pe = &(m_Bh.plugins[m_Entry]);
|
||||
|
||||
@ -321,7 +324,8 @@ CAmxxReader::Error CAmxxReader::GetSection(void *buffer)
|
||||
m_Status = Err_None;
|
||||
|
||||
return m_Status;
|
||||
} else if (m_AmxxFile)
|
||||
}
|
||||
else if (m_AmxxFile)
|
||||
{
|
||||
PluginEntry *pe = &(m_Bh.plugins[m_Entry]);
|
||||
char *tempBuffer = new char[m_SectionLength + 1];
|
||||
|
371
amxmodx/emsg.cpp
371
amxmodx/emsg.cpp
@ -57,197 +57,224 @@ WeaponsVault g_weaponsData[MAX_WEAPONS];
|
||||
|
||||
void Client_VGUIMenu(void* mValue)
|
||||
{
|
||||
if (!mPlayer) return;
|
||||
switch (mState++){
|
||||
case 0:
|
||||
mPlayer->menu = -(*(int*)mValue);
|
||||
break;
|
||||
case 1:
|
||||
mPlayer->keys = *(int*)mValue;
|
||||
}
|
||||
if (!mPlayer) return;
|
||||
|
||||
switch (mState++)
|
||||
{
|
||||
case 0:
|
||||
mPlayer->menu = -(*(int*)mValue);
|
||||
break;
|
||||
case 1:
|
||||
mPlayer->keys = *(int*)mValue;
|
||||
}
|
||||
}
|
||||
|
||||
void Client_ShowMenu(void* mValue)
|
||||
{
|
||||
if (!mPlayer) return;
|
||||
switch (mState++){
|
||||
case 0:
|
||||
mPlayer->keys = *(int*)mValue;
|
||||
break;
|
||||
case 3:
|
||||
mPlayer->menu = g_menucmds.findMenuId( (char*)mValue );
|
||||
}
|
||||
if (!mPlayer) return;
|
||||
|
||||
switch (mState++)
|
||||
{
|
||||
case 0:
|
||||
mPlayer->keys = *(int*)mValue;
|
||||
break;
|
||||
case 3:
|
||||
mPlayer->menu = g_menucmds.findMenuId((char*)mValue);
|
||||
}
|
||||
}
|
||||
|
||||
void Client_TeamInfo(void* mValue)
|
||||
{
|
||||
if (mPlayer) return;
|
||||
static int index;
|
||||
switch (mState++) {
|
||||
case 0:
|
||||
index = *(int*)mValue;
|
||||
break;
|
||||
case 1:
|
||||
if ( index < 1 || index > gpGlobals->maxClients ) break;
|
||||
char* msg = (char*)mValue;
|
||||
g_players[ index ].team.assign( msg );
|
||||
g_teamsIds.registerTeam( msg , -1 );
|
||||
}
|
||||
if (mPlayer) return;
|
||||
static int index;
|
||||
|
||||
switch (mState++)
|
||||
{
|
||||
case 0:
|
||||
index = *(int*)mValue;
|
||||
break;
|
||||
case 1:
|
||||
if (index < 1 || index > gpGlobals->maxClients) break;
|
||||
char* msg = (char*)mValue;
|
||||
g_players[index].team.assign(msg);
|
||||
g_teamsIds.registerTeam(msg, -1);
|
||||
}
|
||||
}
|
||||
|
||||
void Client_TextMsg(void* mValue)
|
||||
{
|
||||
if ( mPlayer ) return;
|
||||
switch (mState++) {
|
||||
case 1:{
|
||||
char * msg = (char*)mValue;
|
||||
if (!msg) break;
|
||||
if ( !strncmp("#Game_C", msg , 7) ) {
|
||||
g_game_timeleft = g_game_restarting = gpGlobals->time + 3;
|
||||
// g_endround_time = gpGlobals->time;
|
||||
// g_newround_time = gpGlobals->time + CVAR_GET_FLOAT("mp_freezetime") + 3;
|
||||
}
|
||||
else if (!strncmp("#Game_w", msg , 7) ) {
|
||||
g_game_timeleft = -2;
|
||||
}
|
||||
else if ( !strncmp("#game_clan_s", msg , 12) ){
|
||||
g_game_timeleft = -3;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2:{
|
||||
char * msg = (char*)mValue;
|
||||
if (!msg) break;
|
||||
if (g_game_timeleft == -2 ){
|
||||
g_game_timeleft = g_game_restarting = gpGlobals->time + atoi( msg );
|
||||
// g_newround_time = g_game_timeleft + CVAR_GET_FLOAT("mp_freezetime");
|
||||
}
|
||||
else if ( g_game_timeleft == -3 )
|
||||
g_game_restarting = atoi( msg ) * 60.0f;
|
||||
break;
|
||||
}
|
||||
case 3:{
|
||||
char * msg = (char*)mValue;
|
||||
if (!msg) break;
|
||||
if ( g_game_timeleft != -3 ) break;
|
||||
g_game_restarting += atoi( msg );
|
||||
g_game_timeleft = g_game_restarting = gpGlobals->time + g_game_restarting;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (mPlayer) return;
|
||||
|
||||
switch (mState++)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
char * msg = (char*)mValue;
|
||||
if (!msg) break;
|
||||
|
||||
if (!strncmp("#Game_C", msg, 7))
|
||||
{
|
||||
g_game_timeleft = g_game_restarting = gpGlobals->time + 3;
|
||||
//g_endround_time = gpGlobals->time;
|
||||
//g_newround_time = gpGlobals->time + CVAR_GET_FLOAT("mp_freezetime") + 3;
|
||||
}
|
||||
else if (!strncmp("#Game_w", msg, 7))
|
||||
{
|
||||
g_game_timeleft = -2;
|
||||
}
|
||||
else if (!strncmp("#game_clan_s", msg, 12))
|
||||
{
|
||||
g_game_timeleft = -3;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
char * msg = (char*)mValue;
|
||||
if (!msg) break;
|
||||
|
||||
if (g_game_timeleft == -2)
|
||||
{
|
||||
g_game_timeleft = g_game_restarting = gpGlobals->time + atoi(msg);
|
||||
//g_newround_time = g_game_timeleft + CVAR_GET_FLOAT("mp_freezetime");
|
||||
}
|
||||
else if (g_game_timeleft == -3)
|
||||
g_game_restarting = atoi(msg) * 60.0f;
|
||||
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
char * msg = (char*)mValue;
|
||||
if (!msg) break;
|
||||
if (g_game_timeleft != -3) break;
|
||||
g_game_restarting += atoi(msg);
|
||||
g_game_timeleft = g_game_restarting = gpGlobals->time + g_game_restarting;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Client_WeaponList(void* mValue)
|
||||
{
|
||||
static int wpnList = 0;
|
||||
//static int wpnList2;
|
||||
static int iSlot;
|
||||
static const char* wpnName;
|
||||
switch (mState++) {
|
||||
case 0:
|
||||
wpnName = (char*)mValue;
|
||||
break;
|
||||
case 1:
|
||||
iSlot = *(int*)mValue;
|
||||
break;
|
||||
case 7:
|
||||
int iId = *(int*)mValue;
|
||||
if ( (iId < 0 || iId >= MAX_WEAPONS ) || (wpnList & (1<<iId)) )
|
||||
break;
|
||||
wpnList |= (1<<iId);
|
||||
g_weaponsData[iId].iId = iId;
|
||||
g_weaponsData[iId].ammoSlot = iSlot;
|
||||
g_weaponsData[iId].fullName.assign(wpnName);
|
||||
|
||||
}
|
||||
static int wpnList = 0;
|
||||
//static int wpnList2;
|
||||
static int iSlot;
|
||||
static const char* wpnName;
|
||||
|
||||
switch (mState++)
|
||||
{
|
||||
case 0:
|
||||
wpnName = (char*)mValue;
|
||||
break;
|
||||
case 1:
|
||||
iSlot = *(int*)mValue;
|
||||
break;
|
||||
case 7:
|
||||
int iId = *(int*)mValue;
|
||||
if ((iId < 0 || iId >= MAX_WEAPONS) || (wpnList & (1<<iId)))
|
||||
break;
|
||||
wpnList |= (1<<iId);
|
||||
g_weaponsData[iId].iId = iId;
|
||||
g_weaponsData[iId].ammoSlot = iSlot;
|
||||
g_weaponsData[iId].fullName.assign(wpnName);
|
||||
}
|
||||
}
|
||||
|
||||
void Client_CurWeapon(void* mValue)
|
||||
{
|
||||
static int iState;
|
||||
static int iId;
|
||||
switch (mState++){
|
||||
case 0:
|
||||
iState = *(int*)mValue;
|
||||
break;
|
||||
case 1:
|
||||
if (!iState) break;
|
||||
iId = *(int*)mValue;
|
||||
break;
|
||||
case 2:
|
||||
if (!mPlayer) return;
|
||||
if (!iState || (iId < 1 || iId >= MAX_WEAPONS ) ) break;
|
||||
mPlayer->weapons[iId].clip = *(int*)mValue;
|
||||
mPlayer->current = iId;
|
||||
mPlayer->lastHit = mPlayer->lastTrace;
|
||||
}
|
||||
static int iState;
|
||||
static int iId;
|
||||
|
||||
switch (mState++)
|
||||
{
|
||||
case 0:
|
||||
iState = *(int*)mValue;
|
||||
break;
|
||||
case 1:
|
||||
if (!iState) break;
|
||||
iId = *(int*)mValue;
|
||||
break;
|
||||
case 2:
|
||||
if (!mPlayer) return;
|
||||
if (!iState || (iId < 1 || iId >= MAX_WEAPONS)) break;
|
||||
mPlayer->weapons[iId].clip = *(int*)mValue;
|
||||
mPlayer->current = iId;
|
||||
mPlayer->lastHit = mPlayer->lastTrace;
|
||||
}
|
||||
}
|
||||
|
||||
void Client_AmmoX(void* mValue)
|
||||
{
|
||||
|
||||
static int iAmmo;
|
||||
switch (mState++){
|
||||
case 0:
|
||||
iAmmo = *(int*)mValue;
|
||||
break;
|
||||
case 1:
|
||||
if (!mPlayer) return;
|
||||
for(int i=1;i<MAX_WEAPONS;++i)
|
||||
if (iAmmo == g_weaponsData[i].ammoSlot)
|
||||
mPlayer->weapons[i].ammo = *(int*)mValue;
|
||||
}
|
||||
static int iAmmo;
|
||||
|
||||
switch (mState++)
|
||||
{
|
||||
case 0:
|
||||
iAmmo = *(int*)mValue;
|
||||
break;
|
||||
case 1:
|
||||
if (!mPlayer) return;
|
||||
for (int i = 1; i < MAX_WEAPONS; ++i)
|
||||
if (iAmmo == g_weaponsData[i].ammoSlot)
|
||||
mPlayer->weapons[i].ammo = *(int*)mValue;
|
||||
}
|
||||
}
|
||||
|
||||
void Client_AmmoPickup(void* mValue)
|
||||
{
|
||||
static int iSlot;
|
||||
switch (mState++){
|
||||
case 0:
|
||||
iSlot = *(int*)mValue;
|
||||
break;
|
||||
case 1:
|
||||
if (!mPlayer) return;
|
||||
for(int i=1;i<MAX_WEAPONS;++i)
|
||||
if (g_weaponsData[i].ammoSlot==iSlot)
|
||||
mPlayer->weapons[i].ammo += *(int*)mValue;
|
||||
}
|
||||
static int iSlot;
|
||||
|
||||
switch (mState++)
|
||||
{
|
||||
case 0:
|
||||
iSlot = *(int*)mValue;
|
||||
break;
|
||||
case 1:
|
||||
if (!mPlayer) return;
|
||||
for (int i = 1; i < MAX_WEAPONS; ++i)
|
||||
if (g_weaponsData[i].ammoSlot==iSlot)
|
||||
mPlayer->weapons[i].ammo += *(int*)mValue;
|
||||
}
|
||||
}
|
||||
|
||||
void Client_ScoreInfo(void* mValue)
|
||||
{
|
||||
static int index;
|
||||
static int deaths;
|
||||
switch (mState++){
|
||||
case 0:
|
||||
index = *(int*)mValue;
|
||||
break;
|
||||
case 2:
|
||||
deaths = *(int*)mValue;
|
||||
break;
|
||||
case 4:
|
||||
if ( index < 1 || index > gpGlobals->maxClients ) break;
|
||||
CPlayer*pPlayer = GET_PLAYER_POINTER_I( index );
|
||||
pPlayer->deaths = deaths;
|
||||
pPlayer->teamId = *(int*)mValue;
|
||||
if ( g_teamsIds.isNewTeam() )
|
||||
g_teamsIds.registerTeam( pPlayer->team.c_str() , pPlayer->teamId );
|
||||
}
|
||||
static int index;
|
||||
static int deaths;
|
||||
|
||||
switch (mState++)
|
||||
{
|
||||
case 0:
|
||||
index = *(int*)mValue;
|
||||
break;
|
||||
case 2:
|
||||
deaths = *(int*)mValue;
|
||||
break;
|
||||
case 4:
|
||||
if (index < 1 || index > gpGlobals->maxClients) break;
|
||||
CPlayer*pPlayer = GET_PLAYER_POINTER_I(index);
|
||||
pPlayer->deaths = deaths;
|
||||
pPlayer->teamId = *(int*)mValue;
|
||||
if (g_teamsIds.isNewTeam())
|
||||
g_teamsIds.registerTeam(pPlayer->team.c_str(), pPlayer->teamId);
|
||||
}
|
||||
}
|
||||
|
||||
void Client_DamageEnd(void* mValue)
|
||||
{
|
||||
CPlayer* dead = mPlayer;
|
||||
|
||||
if ( dead && dead->death_killer )
|
||||
if (dead && dead->death_killer)
|
||||
{
|
||||
g_events.parserInit( CS_DEATHMSG , &gpGlobals->time , mPlayer = 0, mPlayerIndex = 0 );
|
||||
g_events.parseValue( dead->death_killer );
|
||||
g_events.parseValue( dead->index );
|
||||
g_events.parseValue( dead->death_headshot );
|
||||
g_events.parseValue( dead->death_weapon.c_str() );
|
||||
g_events.parseValue( dead->death_tk ? 1 : 0 );
|
||||
g_events.parserInit(CS_DEATHMSG, &gpGlobals->time, mPlayer = 0, mPlayerIndex = 0);
|
||||
g_events.parseValue(dead->death_killer);
|
||||
g_events.parseValue(dead->index);
|
||||
g_events.parseValue(dead->death_headshot);
|
||||
g_events.parseValue(dead->death_weapon.c_str());
|
||||
g_events.parseValue(dead->death_tk ? 1 : 0);
|
||||
g_events.executeEvents();
|
||||
dead->death_killer = 0;
|
||||
}
|
||||
@ -261,28 +288,25 @@ void Client_DeathMsg(void* mValue)
|
||||
static int victim_id;
|
||||
static int hs;
|
||||
|
||||
switch (mState++){
|
||||
case 0:
|
||||
killer_id = *(int*)mValue;
|
||||
killer = (killer_id > 0 && killer_id < 33) ?
|
||||
GET_PLAYER_POINTER_I(killer_id) : 0;
|
||||
break;
|
||||
case 1:
|
||||
victim_id = *(int*)mValue;
|
||||
victim = (victim_id > 0 && victim_id < 33) ?
|
||||
GET_PLAYER_POINTER_I(victim_id) : 0;
|
||||
break;
|
||||
case 2:
|
||||
hs = *(int*)mValue;
|
||||
break;
|
||||
case 3:
|
||||
|
||||
if ( !killer || !victim ) break;
|
||||
|
||||
victim->death_killer = killer_id;
|
||||
victim->death_weapon.assign((char*)mValue);
|
||||
victim->death_headshot = hs;
|
||||
victim->death_tk = (killer->teamId == victim->teamId);
|
||||
switch (mState++)
|
||||
{
|
||||
case 0:
|
||||
killer_id = *(int*)mValue;
|
||||
killer = (killer_id > 0 && killer_id < 33) ? GET_PLAYER_POINTER_I(killer_id) : 0;
|
||||
break;
|
||||
case 1:
|
||||
victim_id = *(int*)mValue;
|
||||
victim = (victim_id > 0 && victim_id < 33) ? GET_PLAYER_POINTER_I(victim_id) : 0;
|
||||
break;
|
||||
case 2:
|
||||
hs = *(int*)mValue;
|
||||
break;
|
||||
case 3:
|
||||
if (!killer || !victim) break;
|
||||
victim->death_killer = killer_id;
|
||||
victim->death_weapon.assign((char*)mValue);
|
||||
victim->death_headshot = hs;
|
||||
victim->death_tk = (killer->teamId == victim->teamId);
|
||||
}
|
||||
}
|
||||
/*
|
||||
@ -313,4 +337,3 @@ void Client_ResetHUD(void* mValue)
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
|
540
amxmodx/file.cpp
540
amxmodx/file.cpp
@ -5,7 +5,7 @@
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* under the terms of the GNU General Publicç License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
@ -63,11 +63,13 @@ class AutoFilePtr
|
||||
public:
|
||||
AutoFilePtr(FILE *fp) : m_FP(fp)
|
||||
{ }
|
||||
|
||||
~AutoFilePtr()
|
||||
{
|
||||
if (m_FP)
|
||||
fclose(m_FP);
|
||||
}
|
||||
|
||||
operator FILE* ()
|
||||
{
|
||||
return m_FP;
|
||||
@ -80,20 +82,25 @@ static cell AMX_NATIVE_CALL read_dir(AMX *amx, cell *params)
|
||||
int a;
|
||||
struct dirent *ep;
|
||||
DIR *dp;
|
||||
char* dirname = build_pathname("%s",get_amxstring(amx,params[1],0,a) );
|
||||
char* dirname = build_pathname("%s", get_amxstring(amx, params[1], 0, a));
|
||||
a = params[2];
|
||||
if ( (dp = opendir (dirname)) == NULL )
|
||||
|
||||
if ((dp = opendir (dirname)) == NULL)
|
||||
return 0;
|
||||
seekdir( dp , a );
|
||||
if ( (ep = readdir (dp)) != NULL ) {
|
||||
cell *length = get_amxaddr(amx,params[5]);
|
||||
*length = set_amxstring(amx,params[3], ep->d_name ,params[4]);
|
||||
a = telldir( dp );
|
||||
}
|
||||
else
|
||||
seekdir(dp, a);
|
||||
|
||||
if ((ep = readdir (dp)) != NULL)
|
||||
{
|
||||
cell *length = get_amxaddr(amx, params[5]);
|
||||
*length = set_amxstring(amx, params[3], ep->d_name, params[4]);
|
||||
a = telldir(dp);
|
||||
} else
|
||||
a = 0;
|
||||
|
||||
closedir (dp);
|
||||
|
||||
return a;
|
||||
|
||||
#else
|
||||
int tmp;
|
||||
char *dirname = build_pathname("%s/*", get_amxstring(amx, params[1], 0, tmp));
|
||||
@ -101,10 +108,12 @@ static cell AMX_NATIVE_CALL read_dir(AMX *amx, cell *params)
|
||||
|
||||
_finddata_t fd;
|
||||
intptr_t handle = _findfirst(dirname, &fd);
|
||||
|
||||
if (handle < 0)
|
||||
return 0;
|
||||
|
||||
++tmp;
|
||||
|
||||
for (int i = 0; i < tmp; ++i)
|
||||
{
|
||||
if (_findnext(handle, &fd) < 0)
|
||||
@ -113,8 +122,9 @@ static cell AMX_NATIVE_CALL read_dir(AMX *amx, cell *params)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// current data in fd
|
||||
cell *length = get_amxaddr(amx,params[5]); // pointer to the outLen parameter
|
||||
cell *length = get_amxaddr(amx, params[5]); // pointer to the outLen parameter
|
||||
*length = set_amxstring(amx, params[3], fd.name, params[4]); // set output and outLen parameters
|
||||
_findclose(handle);
|
||||
|
||||
@ -124,178 +134,202 @@ static cell AMX_NATIVE_CALL read_dir(AMX *amx, cell *params)
|
||||
|
||||
static cell AMX_NATIVE_CALL read_file(AMX *amx, cell *params) /* 5 param */
|
||||
{
|
||||
int iLen;
|
||||
char* szFile = get_amxstring(amx,params[1],0,iLen);
|
||||
FILE*fp;
|
||||
if ( (fp =fopen(build_pathname("%s",szFile),"r")) == NULL) {
|
||||
amx_RaiseError(amx,AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
char buffor[1024];
|
||||
int i = 0, iLine = params[2];
|
||||
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;
|
||||
}
|
||||
return 0;
|
||||
int iLen;
|
||||
char* szFile = get_amxstring(amx, params[1], 0, iLen);
|
||||
FILE *fp;
|
||||
|
||||
if ((fp =fopen(build_pathname("%s", szFile), "r")) == NULL)
|
||||
{
|
||||
amx_RaiseError(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
char buffor[1024];
|
||||
int i = 0, iLine = params[2];
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL write_file(AMX *amx, cell *params) /* 3 param */
|
||||
{
|
||||
int i;
|
||||
char* sFile = build_pathname("%s", get_amxstring(amx,params[1],0,i) );
|
||||
char* sText = get_amxstring(amx,params[2],0,i);
|
||||
FILE* pFile;
|
||||
int iLine = params[3];
|
||||
int i;
|
||||
char* sFile = build_pathname("%s", get_amxstring(amx, params[1], 0, i));
|
||||
char* sText = get_amxstring(amx, params[2], 0, i);
|
||||
FILE* pFile;
|
||||
int iLine = params[3];
|
||||
|
||||
// apending to the end
|
||||
if (iLine < 0) {
|
||||
if ( (pFile = fopen( sFile ,"a")) == NULL ){
|
||||
amx_RaiseError(amx,AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
fputs( sText , pFile );
|
||||
fputc( '\n', pFile );
|
||||
fclose( pFile );
|
||||
return 1;
|
||||
}
|
||||
// apending to the end
|
||||
if (iLine < 0)
|
||||
{
|
||||
if ((pFile = fopen(sFile, "a")) == NULL)
|
||||
{
|
||||
amx_RaiseError(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
fputs(sText, pFile);
|
||||
fputc('\n', pFile);
|
||||
fclose(pFile);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// creating a new file with a line in a middle
|
||||
if ( (pFile = fopen(sFile,"r")) == NULL ) {
|
||||
if ( (pFile = fopen(sFile,"w")) == NULL ){
|
||||
amx_RaiseError(amx,AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
for(i=0;i < iLine;++i)
|
||||
fputc('\n',pFile);
|
||||
fputs( sText , pFile );
|
||||
fputc( '\n', pFile );
|
||||
fclose(pFile);
|
||||
return 1;
|
||||
}
|
||||
// creating a new file with a line in a middle
|
||||
if ((pFile = fopen(sFile, "r")) == NULL)
|
||||
{
|
||||
if ((pFile = fopen(sFile, "w")) == NULL)
|
||||
{
|
||||
amx_RaiseError(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < iLine; ++i)
|
||||
fputc('\n', pFile);
|
||||
|
||||
fputs(sText, pFile);
|
||||
fputc('\n', pFile);
|
||||
fclose(pFile);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// adding a new line in a middle of already existing file
|
||||
FILE* pTemp;
|
||||
char buffor[2048];
|
||||
// adding a new line in a middle of already existing file
|
||||
FILE* pTemp;
|
||||
char buffor[2048];
|
||||
|
||||
if ( (pTemp = tmpfile()) == NULL ){
|
||||
amx_RaiseError(amx,AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
if ((pTemp = tmpfile()) == NULL)
|
||||
{
|
||||
amx_RaiseError(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
for(i=0;;++i){
|
||||
if ( i == iLine ){
|
||||
fgets(buffor,2047,pFile);
|
||||
fputs( sText , pTemp );
|
||||
fputc( '\n', pTemp );
|
||||
}
|
||||
else if ( fgets(buffor,2047,pFile) ){
|
||||
fputs(buffor , pTemp );
|
||||
}
|
||||
else if ( i < iLine ) {
|
||||
fputc( '\n', pTemp );
|
||||
}
|
||||
else break;
|
||||
}
|
||||
for (i = 0; ; ++i)
|
||||
{
|
||||
if (i == iLine)
|
||||
{
|
||||
fgets(buffor, 2047, pFile);
|
||||
fputs(sText, pTemp);
|
||||
fputc('\n', pTemp);
|
||||
}
|
||||
else if (fgets(buffor, 2047, pFile))
|
||||
{
|
||||
fputs(buffor, pTemp);
|
||||
}
|
||||
else if (i < iLine)
|
||||
{
|
||||
fputc('\n', pTemp);
|
||||
}
|
||||
else break;
|
||||
}
|
||||
|
||||
fclose(pFile);
|
||||
rewind(pTemp);
|
||||
fclose(pFile);
|
||||
rewind(pTemp);
|
||||
|
||||
// now rewrite because file can be now smaller...
|
||||
if ( (pFile = fopen(sFile,"w")) == NULL ){
|
||||
amx_RaiseError(amx,AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
// now rewrite because file can be now smaller...
|
||||
if ((pFile = fopen(sFile, "w")) == NULL)
|
||||
{
|
||||
amx_RaiseError(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
while(fgets(buffor,2047,pTemp))
|
||||
fputs(buffor,pFile );
|
||||
while (fgets(buffor, 2047, pTemp))
|
||||
fputs(buffor, pFile);
|
||||
|
||||
fclose(pTemp);
|
||||
fclose(pFile);
|
||||
return 1;
|
||||
fclose(pTemp);
|
||||
fclose(pFile);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
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);
|
||||
int iLen;
|
||||
char* sFile = get_amxstring(amx, params[1], 0, iLen);
|
||||
return (unlink(build_pathname("%s", sFile)) ? 0 : 1);
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL file_exists(AMX *amx, cell *params) /* 1 param */
|
||||
{
|
||||
int iLen;
|
||||
char *sFile = get_amxstring(amx,params[1],0,iLen);
|
||||
char *file = build_pathname("%s",sFile);
|
||||
int iLen;
|
||||
char *sFile = get_amxstring(amx, params[1], 0, iLen);
|
||||
char *file = build_pathname("%s", sFile);
|
||||
|
||||
#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;
|
||||
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;
|
||||
struct stat s;
|
||||
if (stat(file, &s) != 0)
|
||||
return 0;
|
||||
if (S_ISDIR(s.st_mode))
|
||||
return 0;
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL dir_exists(AMX *amx, cell *params) /* 1 param */
|
||||
{
|
||||
int iLen;
|
||||
char *sFile = get_amxstring(amx,params[1],0,iLen);
|
||||
char *file = build_pathname("%s",sFile);
|
||||
int iLen;
|
||||
char *sFile = get_amxstring(amx, params[1], 0, iLen);
|
||||
char *file = build_pathname("%s", sFile);
|
||||
|
||||
#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;
|
||||
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;
|
||||
struct stat s;
|
||||
if (stat(file, &s) != 0)
|
||||
return 0;
|
||||
if (S_ISDIR(s.st_mode))
|
||||
return 1;
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL file_size(AMX *amx, cell *params) /* 1 param */
|
||||
{
|
||||
int iLen;
|
||||
char* sFile = get_amxstring(amx,params[1],0,iLen);
|
||||
AutoFilePtr fp(fopen(build_pathname("%s",sFile),"r"));
|
||||
if ( fp != NULL)
|
||||
char* sFile = get_amxstring(amx, params[1], 0, iLen);
|
||||
AutoFilePtr fp(fopen(build_pathname("%s", sFile), "r"));
|
||||
|
||||
if (fp != NULL)
|
||||
{
|
||||
if ( params[0] < 2 || params[2] == 0 )
|
||||
if (params[0] < 2 || params[2] == 0)
|
||||
{
|
||||
fseek(fp,0,SEEK_END);
|
||||
fseek(fp, 0, SEEK_END);
|
||||
int size = ftell(fp);
|
||||
return size;
|
||||
}
|
||||
else if ( params[2] == 1 )
|
||||
else if (params[2] == 1)
|
||||
{
|
||||
int a = 0,lines = 0;
|
||||
while( a != EOF )
|
||||
|
||||
while (a != EOF)
|
||||
{
|
||||
++lines;
|
||||
while ( (a = fgetc(fp)) != '\n' && a != EOF )
|
||||
;
|
||||
while ((a = fgetc(fp)) != '\n' && a != EOF);
|
||||
}
|
||||
//int a, b = '\n';
|
||||
//while( (a = fgetc(fp)) != EOF ){
|
||||
@ -307,13 +341,16 @@ static cell AMX_NATIVE_CALL file_size(AMX *amx, cell *params) /* 1 param */
|
||||
// ++lines;
|
||||
return lines;
|
||||
}
|
||||
else if ( params[2] == 2 ){
|
||||
fseek(fp,-1,SEEK_END);
|
||||
if ( fgetc(fp) == '\n' )
|
||||
else if (params[2] == 2)
|
||||
{
|
||||
fseek(fp, -1, SEEK_END);
|
||||
|
||||
if (fgetc(fp) == '\n')
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -327,12 +364,13 @@ 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) {
|
||||
if (fp == NULL)
|
||||
{
|
||||
// Failed
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (i=0; i<FileList.size(); i++)
|
||||
for (i = 0; i < FileList.size(); i++)
|
||||
{
|
||||
if (FileList.at(i) == NULL)
|
||||
{
|
||||
@ -340,7 +378,8 @@ static cell AMX_NATIVE_CALL amx_fopen(AMX *amx, cell *params)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j==-1)
|
||||
|
||||
if (j == -1)
|
||||
{
|
||||
FileList.push_back(fp);
|
||||
j = FileList.size() - 1;
|
||||
@ -348,16 +387,19 @@ static cell AMX_NATIVE_CALL amx_fopen(AMX *amx, cell *params)
|
||||
FileList.at(j) = fp;
|
||||
}
|
||||
|
||||
return j+1;
|
||||
return j + 1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL amx_fclose(AMX *amx, cell *params)
|
||||
{
|
||||
unsigned int id = params[1] - 1;
|
||||
|
||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||
return 0;
|
||||
FILE *fp = FileList.at(id);
|
||||
if (fp) {
|
||||
|
||||
if (fp)
|
||||
{
|
||||
return fclose(fp);
|
||||
} else {
|
||||
return -1;
|
||||
@ -367,17 +409,22 @@ static cell AMX_NATIVE_CALL amx_fclose(AMX *amx, cell *params)
|
||||
static cell AMX_NATIVE_CALL amx_fread(AMX *amx, cell *params)
|
||||
{
|
||||
unsigned int id = params[1] - 1;
|
||||
|
||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||
return 0;
|
||||
FILE *fp = FileList.at(id);
|
||||
|
||||
char *buffer;
|
||||
if (fp) {
|
||||
|
||||
if (fp)
|
||||
{
|
||||
buffer = new char[params[3]]; // SLOW!!! :TODO: Find a better way (auto pointers?)
|
||||
fread(buffer, sizeof(char), params[3], fp);
|
||||
set_amxstring(amx, params[2], buffer, params[3]);
|
||||
delete [] buffer;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -385,10 +432,13 @@ static cell AMX_NATIVE_CALL amx_fread(AMX *amx, cell *params)
|
||||
static cell AMX_NATIVE_CALL amx_fgetc(AMX *amx, cell *params)
|
||||
{
|
||||
unsigned int id = params[1] - 1;
|
||||
|
||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||
return 0;
|
||||
FILE *fp = FileList.at(id);
|
||||
if (fp) {
|
||||
|
||||
if (fp)
|
||||
{
|
||||
return fgetc(fp);
|
||||
} else {
|
||||
return -1;
|
||||
@ -398,89 +448,111 @@ static cell AMX_NATIVE_CALL amx_fgetc(AMX *amx, cell *params)
|
||||
static cell AMX_NATIVE_CALL amx_fwrite(AMX *amx, cell *params)
|
||||
{
|
||||
unsigned int id = params[1] - 1;
|
||||
|
||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||
return 0;
|
||||
FILE *fp = FileList.at(id);
|
||||
char *buf;
|
||||
int len;
|
||||
if (fp) {
|
||||
|
||||
if (fp)
|
||||
{
|
||||
buf = format_amxstring(amx, params, 2, len);
|
||||
return fwrite(buf, sizeof(char), strlen(buf), fp);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL amx_feof(AMX *amx, cell *params)
|
||||
{
|
||||
unsigned int id = params[1] - 1;
|
||||
|
||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||
return 0;
|
||||
FILE *fp = FileList.at(id);
|
||||
if (fp) {
|
||||
if (feof(fp)) {
|
||||
|
||||
if (fp)
|
||||
{
|
||||
if (feof(fp))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL amx_fseek(AMX *amx, cell *params)
|
||||
{
|
||||
unsigned int id = params[1] - 1;
|
||||
|
||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||
return 0;
|
||||
FILE *fp = FileList.at(id);
|
||||
|
||||
if (fp) {
|
||||
if (fp)
|
||||
{
|
||||
return fseek(fp, (long)params[2], params[3]);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL amx_fputc(AMX *amx, cell *params)
|
||||
{
|
||||
unsigned int id = params[1] - 1;
|
||||
|
||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||
return 0;
|
||||
FILE *fp = FileList.at(id);
|
||||
|
||||
if (fp) {
|
||||
if (fp)
|
||||
{
|
||||
return fputc(params[2], fp);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL amx_rewind(AMX *amx, cell *params)
|
||||
{
|
||||
unsigned int id = params[1] - 1;
|
||||
|
||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||
return 0;
|
||||
FILE *fp = FileList.at(id);
|
||||
|
||||
if (fp) {
|
||||
if (fp)
|
||||
{
|
||||
rewind(fp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL amx_fflush(AMX *amx, cell *params)
|
||||
{
|
||||
unsigned int id = params[1] - 1;
|
||||
|
||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||
return 0;
|
||||
FILE *fp = FileList.at(id);
|
||||
|
||||
if (fp) {
|
||||
if (fp)
|
||||
{
|
||||
return fflush(fp);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL amx_fscanf(AMX *amx, cell *params)
|
||||
{
|
||||
unsigned int id = params[1] - 1;
|
||||
|
||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||
return 0;
|
||||
FILE *fp = FileList.at(id);
|
||||
@ -488,7 +560,9 @@ static cell AMX_NATIVE_CALL amx_fscanf(AMX *amx, cell *params)
|
||||
char *buf;
|
||||
int len;
|
||||
buf = format_amxstring(amx, params, 2, len);
|
||||
if (fp) {
|
||||
|
||||
if (fp)
|
||||
{
|
||||
return fscanf(fp, "%s", buf);
|
||||
}
|
||||
|
||||
@ -498,13 +572,16 @@ static cell AMX_NATIVE_CALL amx_fscanf(AMX *amx, cell *params)
|
||||
static cell AMX_NATIVE_CALL amx_ftell(AMX *amx, cell *params)
|
||||
{
|
||||
unsigned int id = params[1] - 1;
|
||||
|
||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||
return 0;
|
||||
FILE *fp = FileList.at(id);
|
||||
|
||||
if (fp) {
|
||||
if (fp)
|
||||
{
|
||||
return ftell(fp);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
#endif //UNUSED
|
||||
@ -515,11 +592,14 @@ static cell AMX_NATIVE_CALL amx_filesize(AMX *amx, cell *params)
|
||||
char *file = build_pathname("%s", format_amxstring(amx, params, 1, len));
|
||||
long size;
|
||||
AutoFilePtr fp(fopen(file, "rb"));
|
||||
if (fp) {
|
||||
|
||||
if (fp)
|
||||
{
|
||||
fseek(fp, 0, SEEK_END);
|
||||
size = ftell(fp);
|
||||
return size;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -527,116 +607,148 @@ static cell AMX_NATIVE_CALL amx_filesize(AMX *amx, cell *params)
|
||||
static cell AMX_NATIVE_CALL amx_fgetl(AMX *amx, cell *params)
|
||||
{
|
||||
unsigned int id = params[1] - 1;
|
||||
|
||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||
return 0;
|
||||
FILE *fp = FileList.at(id);
|
||||
|
||||
long t;
|
||||
if (fp) {
|
||||
|
||||
if (fp)
|
||||
{
|
||||
fread(&t, sizeof(long), 1, fp);
|
||||
return t;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL amx_fgeti(AMX *amx, cell *params)
|
||||
{
|
||||
unsigned int id = params[1] - 1;
|
||||
|
||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||
return 0;
|
||||
FILE *fp = FileList.at(id);
|
||||
|
||||
int t;
|
||||
if (fp) {
|
||||
|
||||
if (fp)
|
||||
{
|
||||
fread(&t, sizeof(int), 1, fp);
|
||||
return t;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL amx_fgets(AMX *amx, cell *params)
|
||||
{
|
||||
unsigned int id = params[1] - 1;
|
||||
|
||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||
return 0;
|
||||
FILE *fp = FileList.at(id);
|
||||
|
||||
short t;
|
||||
if (fp) {
|
||||
|
||||
if (fp)
|
||||
{
|
||||
fread(&t, sizeof(short), 1, fp);
|
||||
return t;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL amx_fputs(AMX *amx, cell *params)
|
||||
{
|
||||
unsigned int id = params[1] - 1;
|
||||
|
||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||
return 0;
|
||||
FILE *fp = FileList.at(id);
|
||||
|
||||
short size = params[2];
|
||||
if (fp) {
|
||||
|
||||
if (fp)
|
||||
{
|
||||
return fwrite(&size, sizeof(short), 1, fp);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL amx_fputl(AMX *amx, cell *params)
|
||||
{
|
||||
unsigned int id = params[1] - 1;
|
||||
|
||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||
return 0;
|
||||
FILE *fp = FileList.at(id);
|
||||
|
||||
long size = params[2];
|
||||
if (fp) {
|
||||
|
||||
if (fp)
|
||||
{
|
||||
return fwrite(&size, sizeof(long), 1, fp);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL amx_fputi(AMX *amx, cell *params)
|
||||
{
|
||||
unsigned int id = params[1] - 1;
|
||||
|
||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||
return 0;
|
||||
FILE *fp = FileList.at(id);
|
||||
|
||||
int size = params[2];
|
||||
if (fp) {
|
||||
|
||||
if (fp)
|
||||
{
|
||||
return fwrite(&size, sizeof(int), 1, fp);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL amx_fgetf(AMX *amx, cell *params)
|
||||
{
|
||||
unsigned int id = params[1] - 1;
|
||||
|
||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||
return 0;
|
||||
FILE *fp = FileList.at(id);
|
||||
|
||||
float t;
|
||||
if (fp) {
|
||||
|
||||
if (fp)
|
||||
{
|
||||
fread(&t, sizeof(float), 1, fp);
|
||||
return *(cell*)&t;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL amx_fputf(AMX *amx, cell *params)
|
||||
{
|
||||
unsigned int id = params[1] - 1;
|
||||
|
||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||
return 0;
|
||||
FILE *fp = FileList.at(id);
|
||||
|
||||
float size = *(float *)((void *)¶ms[2]);
|
||||
if (fp) {
|
||||
|
||||
if (fp)
|
||||
{
|
||||
return fwrite(&size, sizeof(float), 1, fp);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
#endif //UNUSED
|
||||
@ -657,22 +769,28 @@ static cell AMX_NATIVE_CALL amx_open_dir(AMX *amx, cell *params)
|
||||
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;
|
||||
#else
|
||||
char *dirname = build_pathname("%s", path);
|
||||
DIR *dp = opendir(dirname);
|
||||
|
||||
if (!dp)
|
||||
return NULL;
|
||||
struct dirent *ep = readdir(dp);
|
||||
|
||||
if (!ep)
|
||||
{
|
||||
closedir(dp);
|
||||
return NULL;
|
||||
}
|
||||
set_amxstring(amx,params[2], ep->d_name,params[3]);
|
||||
|
||||
set_amxstring(amx, params[2], ep->d_name, params[3]);
|
||||
|
||||
return (cell)dp;
|
||||
#endif
|
||||
}
|
||||
@ -681,14 +799,18 @@ static cell AMX_NATIVE_CALL amx_close_dir(AMX *amx, cell *params)
|
||||
{
|
||||
#if defined WIN32 || defined _WIN32
|
||||
HANDLE hFile = (HANDLE)((DWORD)params[1]);
|
||||
|
||||
if (hFile == INVALID_HANDLE_VALUE || hFile == NULL)
|
||||
return 0;
|
||||
FindClose(hFile);
|
||||
|
||||
return 1;
|
||||
#else
|
||||
DIR *dp = (DIR *)params[1];
|
||||
|
||||
if (!dp)
|
||||
return 0;
|
||||
|
||||
closedir(dp);
|
||||
return 1;
|
||||
#endif
|
||||
@ -698,64 +820,68 @@ static cell AMX_NATIVE_CALL amx_get_dir(AMX *amx, cell *params)
|
||||
{
|
||||
#if defined WIN32 || defined _WIN32
|
||||
HANDLE hFile = (HANDLE)((DWORD)params[1]);
|
||||
|
||||
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;
|
||||
#else
|
||||
DIR *dp = (DIR *)params[1];
|
||||
|
||||
if (!dp)
|
||||
return 0;
|
||||
struct dirent *ep = readdir(dp);
|
||||
|
||||
if (!ep)
|
||||
return 0;
|
||||
set_amxstring(amx,params[2], ep->d_name,params[3]);
|
||||
set_amxstring(amx, params[2], ep->d_name, params[3]);
|
||||
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
AMX_NATIVE_INFO file_Natives[] = {
|
||||
{ "delete_file", delete_file },
|
||||
{ "file_exists", file_exists },
|
||||
{ "file_size", file_size },
|
||||
{ "read_dir", read_dir },
|
||||
{ "read_file", read_file },
|
||||
{ "write_file", write_file },
|
||||
//Sanji's File Natives
|
||||
{ "fopen", amx_fopen },
|
||||
{ "fclose", amx_fclose },
|
||||
{ "fread", amx_fread },
|
||||
{ "filesize", amx_filesize },
|
||||
AMX_NATIVE_INFO file_Natives[] =
|
||||
{
|
||||
{"delete_file", delete_file},
|
||||
{"file_exists", file_exists},
|
||||
{"file_size", file_size},
|
||||
{"read_dir", read_dir},
|
||||
{"read_file", read_file},
|
||||
{"write_file", write_file},
|
||||
//Sanji's File Natives
|
||||
{"fopen", amx_fopen},
|
||||
{"fclose", amx_fclose},
|
||||
{"fread", amx_fread},
|
||||
{"filesize", amx_filesize},
|
||||
#ifdef UNUSED
|
||||
{ "fgetc", amx_fgetc },
|
||||
{ "fwrite", amx_fwrite },
|
||||
{ "feof", amx_feof },
|
||||
{ "fseek", amx_fseek },
|
||||
{ "fputc", amx_fputc },
|
||||
{ "rewind", amx_rewind },
|
||||
{ "fflush", amx_fflush },
|
||||
{ "fscanf", amx_fscanf },
|
||||
{ "ftell", amx_ftell },
|
||||
{ "fgetl", amx_fgetl },
|
||||
{ "fgeti", amx_fgeti },
|
||||
{ "fgets", amx_fgets },
|
||||
{ "fputs", amx_fputs },
|
||||
{ "fputl", amx_fputl },
|
||||
{ "fputi", amx_fputi },
|
||||
{ "fgetf", amx_fgetf },
|
||||
{ "fputf", amx_fputf },
|
||||
{"fgetc", amx_fgetc},
|
||||
{"fwrite", amx_fwrite},
|
||||
{"feof", amx_feof},
|
||||
{"fseek", amx_fseek},
|
||||
{"fputc", amx_fputc},
|
||||
{"rewind", amx_rewind},
|
||||
{"fflush", amx_fflush},
|
||||
{"fscanf", amx_fscanf},
|
||||
{"ftell", amx_ftell},
|
||||
{"fgetl", amx_fgetl},
|
||||
{"fgeti", amx_fgeti},
|
||||
{"fgets", amx_fgets},
|
||||
{"fputs", amx_fputs},
|
||||
{"fputl", amx_fputl},
|
||||
{"fputi", amx_fputi},
|
||||
{"fgetf", amx_fgetf},
|
||||
{"fputf", amx_fputf},
|
||||
#endif
|
||||
{ "unlink", delete_file },
|
||||
{ "build_pathname", amx_build_pathname},
|
||||
{ "dir_exists", dir_exists },
|
||||
{ "open_dir", amx_open_dir },
|
||||
{ "close_dir", amx_close_dir },
|
||||
{ "next_file", amx_get_dir },
|
||||
|
||||
{ NULL, NULL }
|
||||
{"unlink", delete_file},
|
||||
{"build_pathname", amx_build_pathname},
|
||||
{"dir_exists", dir_exists},
|
||||
{"open_dir", amx_open_dir},
|
||||
{"close_dir", amx_close_dir},
|
||||
{"next_file", amx_get_dir},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
|
||||
|
@ -168,7 +168,7 @@ int C_PrecacheSound(char *s)
|
||||
for (CList<ForceObject>::iterator a = g_forcesounds.begin(); a; ++a)
|
||||
{
|
||||
PRECACHE_SOUND((char*)(*a).getFilename());
|
||||
ENGINE_FORCE_UNMODIFIED((*a).getForceType(),(*a).getMin(),(*a).getMax(),(*a).getFilename());
|
||||
ENGINE_FORCE_UNMODIFIED((*a).getForceType(), (*a).getMin(), (*a).getMax(), (*a).getFilename());
|
||||
}
|
||||
|
||||
if (!g_bmod_cstrike)
|
||||
@ -206,7 +206,7 @@ const char* get_localinfo(const char* name, const char* def)
|
||||
const char* b = LOCALINFO((char*)name);
|
||||
|
||||
if (b == 0 || *b == 0)
|
||||
SET_LOCALINFO((char*)name,(char*)(b = def));
|
||||
SET_LOCALINFO((char*)name, (char*)(b = def));
|
||||
|
||||
return b;
|
||||
}
|
||||
@ -320,7 +320,7 @@ int C_Spawn(edict_t *pent)
|
||||
{
|
||||
PRECACHE_GENERIC((char*)(*a).getFilename());
|
||||
ENGINE_FORCE_UNMODIFIED((*a).getForceType(),
|
||||
(*a).getMin(),(*a).getMax(),(*a).getFilename());
|
||||
(*a).getMin(), (*a).getMax(), (*a).getFilename());
|
||||
}
|
||||
|
||||
RETURN_META_VALUE(MRES_IGNORED, 0);
|
||||
@ -413,7 +413,7 @@ void C_ServerActivate_Post(edict_t *pEdictList, int edictCount, int clientMax)
|
||||
if (g_activated)
|
||||
RETURN_META(MRES_IGNORED);
|
||||
|
||||
for (int i= 1; i <= gpGlobals->maxClients; ++i)
|
||||
for (int i = 1; i <= gpGlobals->maxClients; ++i)
|
||||
{
|
||||
CPlayer *pPlayer = GET_PLAYER_POINTER_I(i);
|
||||
pPlayer->Init(pEdictList + i, i);
|
||||
@ -609,14 +609,14 @@ void C_ClientUserInfoChanged_Post(edict_t *pEntity, char *infobuffer)
|
||||
{
|
||||
CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity);
|
||||
executeForwards(FF_ClientInfoChanged, pPlayer->index);
|
||||
const char* name = INFOKEY_VALUE(infobuffer,"name");
|
||||
const char* name = INFOKEY_VALUE(infobuffer, "name");
|
||||
|
||||
// Emulate bot connection and putinserver
|
||||
if (pPlayer->ingame)
|
||||
{
|
||||
pPlayer->name.assign(name); // Make sure player have name up to date
|
||||
}
|
||||
else if (pPlayer->IsBot())
|
||||
else if (pPlayer->IsBot())
|
||||
{
|
||||
pPlayer->Connect(name, "127.0.0.1"/*CVAR_GET_STRING("net_address")*/);
|
||||
|
||||
@ -690,7 +690,7 @@ void C_ClientCommand(edict_t *pEntity)
|
||||
|
||||
/* check menu commands */
|
||||
|
||||
if (!strcmp(cmd,"menuselect"))
|
||||
if (!strcmp(cmd, "menuselect"))
|
||||
{
|
||||
int pressed_key = atoi(arg) - 1;
|
||||
int bit_key = (1<<pressed_key);
|
||||
@ -718,16 +718,19 @@ void C_ClientCommand(edict_t *pEntity)
|
||||
ret = executeForwards((*a).getFunction(), pPlayer->index, menu, item);
|
||||
|
||||
if (ret & 2) result = MRES_SUPERCEDE;
|
||||
else if (ret & 1) RETURN_META(MRES_SUPERCEDE);
|
||||
else
|
||||
if (ret & 1) RETURN_META(MRES_SUPERCEDE);
|
||||
else
|
||||
{
|
||||
if (item == MENU_BACK)
|
||||
{
|
||||
pMenu->Display(pPlayer->index, pPlayer->page-1);
|
||||
} else if (item == MENU_MORE)
|
||||
}
|
||||
else if (item == MENU_MORE)
|
||||
{
|
||||
pMenu->Display(pPlayer->index, pPlayer->page+1);
|
||||
} else if (item == MENU_EXIT)
|
||||
pMenu->Display(pPlayer->index, pPlayer->page + 1);
|
||||
}
|
||||
else if (item == MENU_EXIT)
|
||||
{
|
||||
//nothing
|
||||
}
|
||||
@ -1119,11 +1122,13 @@ C_DLLEXPORT int Meta_Query(char *ifvers, plugin_info_t **pPlugInfo, mutil_funcs_
|
||||
{
|
||||
LOG_ERROR(PLID, "metamod version is too old for this plugin; update metamod");
|
||||
return (FALSE);
|
||||
} else if (pmajor < mmajor)
|
||||
}
|
||||
else if (pmajor < mmajor)
|
||||
{
|
||||
LOG_ERROR(PLID, "metamod version is incompatible with this plugin; please find a newer version of this plugin");
|
||||
return (FALSE);
|
||||
} else if (pmajor == mmajor)
|
||||
}
|
||||
else if (pmajor == mmajor)
|
||||
{
|
||||
#ifdef FAKEMETA
|
||||
if (mminor == 10)
|
||||
@ -1138,14 +1143,17 @@ C_DLLEXPORT int Meta_Query(char *ifvers, plugin_info_t **pPlugInfo, mutil_funcs_
|
||||
{
|
||||
g_NeedsP = true;
|
||||
#endif
|
||||
} else if (mminor >= 11)
|
||||
}
|
||||
else if (mminor >= 11)
|
||||
{
|
||||
g_IsNewMM = true;
|
||||
} else if (pminor > mminor)
|
||||
}
|
||||
else if (pminor > mminor)
|
||||
{
|
||||
LOG_ERROR(PLID, "metamod version is incompatible with this plugin; please find a newer version of this plugin");
|
||||
return FALSE;
|
||||
} else if (pminor < mminor)
|
||||
}
|
||||
else if (pminor < mminor)
|
||||
{
|
||||
LOG_MESSAGE(PLID, "WARNING: metamod version is newer than expected; consider finding a newer version of this plugin");
|
||||
|
||||
@ -1423,13 +1431,13 @@ C_DLLEXPORT int GetEntityAPI2_Post(DLL_FUNCTIONS *pFunctionTable, int *interface
|
||||
enginefuncs_t meta_engfuncs;
|
||||
C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *interfaceVersion)
|
||||
{
|
||||
if (stricmp(g_mod_name.c_str(),"cstrike") == 0 || stricmp(g_mod_name.c_str(),"czero") == 0)
|
||||
if (stricmp(g_mod_name.c_str(), "cstrike") == 0 || stricmp(g_mod_name.c_str(), "czero") == 0)
|
||||
{
|
||||
meta_engfuncs.pfnSetModel = C_SetModel;
|
||||
g_bmod_cstrike = true;
|
||||
} else {
|
||||
g_bmod_cstrike = false;
|
||||
g_bmod_dod = !stricmp(g_mod_name.c_str(),"dod");
|
||||
g_bmod_dod = !stricmp(g_mod_name.c_str(), "dod");
|
||||
}
|
||||
|
||||
meta_engfuncs.pfnCmd_Argc = C_Cmd_Argc;
|
||||
|
@ -1,3 +1,33 @@
|
||||
/* AMX Mod X
|
||||
*
|
||||
* by the AMX Mod X Development Team
|
||||
* originally developed by OLO
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, the author gives permission to
|
||||
* link the code of this program with the Half-Life Game Engine ("HL
|
||||
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
|
||||
* L.L.C ("Valve"). You must obey the GNU General Public License in all
|
||||
* respects for all of the code used other than the HL Engine and MODs
|
||||
* from Valve. If you modify this file, you may extend this exception
|
||||
* to your version of the file, but you are not obligated to do so. If
|
||||
* you do not wish to do so, delete this exception statement from your
|
||||
* version.
|
||||
*/
|
||||
|
||||
#include "amxmodx.h"
|
||||
#include "newmenus.h"
|
||||
|
||||
@ -5,7 +35,7 @@ CVector<Menu *> g_NewMenus;
|
||||
|
||||
void ClearMenus()
|
||||
{
|
||||
for (size_t i=0; i<g_NewMenus.size(); i++)
|
||||
for (size_t i = 0; i < g_NewMenus.size(); i++)
|
||||
delete g_NewMenus[i];
|
||||
g_NewMenus.clear();
|
||||
}
|
||||
@ -19,7 +49,7 @@ Menu::Menu(const char *title, int mid, int tid)
|
||||
|
||||
Menu::~Menu()
|
||||
{
|
||||
for (size_t i=0; i<m_Items.size(); i++)
|
||||
for (size_t i = 0; i < m_Items.size(); i++)
|
||||
delete m_Items[i];
|
||||
m_Items.clear();
|
||||
}
|
||||
@ -86,10 +116,14 @@ int Menu::PagekeyToItem(page_t page, item_t key)
|
||||
return MENU_MORE;
|
||||
else
|
||||
return MENU_EXIT;
|
||||
} else if (key == rem+1) {
|
||||
}
|
||||
else if (key == rem + 1)
|
||||
{
|
||||
return MENU_EXIT;
|
||||
}
|
||||
} else if (page == pages - 1) {
|
||||
}
|
||||
else if (page == pages - 1)
|
||||
{
|
||||
//find number of remaining items
|
||||
//for example, 11 items on page 1... means start=7, 11-7=4
|
||||
item_t rem = numItems - start;
|
||||
@ -97,14 +131,18 @@ int Menu::PagekeyToItem(page_t page, item_t key)
|
||||
if (key == rem)
|
||||
{
|
||||
return MENU_EXIT;
|
||||
} else if (key == rem+1) {
|
||||
}
|
||||
else if (key == rem + 1)
|
||||
{
|
||||
return MENU_BACK;
|
||||
}
|
||||
} else {
|
||||
if (key == 7)
|
||||
{
|
||||
return MENU_MORE;
|
||||
} else if (key == 8) {
|
||||
}
|
||||
else if (key == 8)
|
||||
{
|
||||
return MENU_BACK;
|
||||
}
|
||||
}
|
||||
@ -147,9 +185,9 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
|
||||
|
||||
char buffer[255];
|
||||
if (g_coloredmenus)
|
||||
_snprintf(buffer, sizeof(buffer)-1, "\\y%s %d/%d\n\\w\n", m_Title.c_str(), page+1, pages);
|
||||
_snprintf(buffer, sizeof(buffer)-1, "\\y%s %d/%d\n\\w\n", m_Title.c_str(), page + 1, pages);
|
||||
else
|
||||
_snprintf(buffer, sizeof(buffer)-1, "%s %d/%d\n\n", m_Title.c_str(), page+1, pages);
|
||||
_snprintf(buffer, sizeof(buffer)-1, "%s %d/%d\n\n", m_Title.c_str(), page + 1, pages);
|
||||
m_Text.append(buffer);
|
||||
|
||||
item_t start = page * 7;
|
||||
@ -166,7 +204,7 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
|
||||
keys = 0;
|
||||
bool enabled = true;
|
||||
int ret = 0;
|
||||
for (item_t i=start; i<end; i++)
|
||||
for (item_t i = start; i < end; i++)
|
||||
{
|
||||
pItem = m_Items[i];
|
||||
if (pItem->access && !(pItem->access & g_players[player].flags[0]))
|
||||
|
@ -31,240 +31,218 @@
|
||||
|
||||
#include "amxmodx.h"
|
||||
|
||||
void amx_command(){
|
||||
void amx_command()
|
||||
{
|
||||
const char* cmd = CMD_ARGV(1);
|
||||
|
||||
const char* cmd = CMD_ARGV(1);
|
||||
if (!strcmp(cmd, "plugins") || !strcmp(cmd, "list"))
|
||||
{
|
||||
|
||||
print_srvconsole("Currently loaded plugins:\n");
|
||||
print_srvconsole(" %-18.17s %-8.7s %-17.16s %-16.15s %-9.8s\n", "name", "version", "author", "file", "status");
|
||||
|
||||
int plugins = 0;
|
||||
int running = 0;
|
||||
|
||||
CPluginMngr::iterator a = g_plugins.begin();
|
||||
|
||||
while (a)
|
||||
{
|
||||
++plugins;
|
||||
if ((*a).isValid() && !(*a).isPaused())
|
||||
++running;
|
||||
|
||||
print_srvconsole(" [%3d] %-18.17s %-8.7s %-17.16s %-16.15s %-9.8s\n", plugins, (*a).getTitle(), (*a).getVersion(), (*a).getAuthor(), (*a).getName(), (*a).getStatus());
|
||||
++a;
|
||||
}
|
||||
|
||||
a = g_plugins.begin();
|
||||
|
||||
while (a)
|
||||
{
|
||||
if ((*a).getStatusCode() == ps_bad_load)
|
||||
{
|
||||
//error
|
||||
print_srvconsole("Load fails: %s\n", (*a).getError());
|
||||
}
|
||||
++a;
|
||||
}
|
||||
|
||||
print_srvconsole("%d plugins, %d running\n", plugins, running);
|
||||
}
|
||||
else if (!strcmp(cmd, "pause") && CMD_ARGC() > 2)
|
||||
{
|
||||
const char* sPlugin = CMD_ARGV(2);
|
||||
|
||||
CPluginMngr::CPlugin *plugin = g_plugins.findPlugin(sPlugin);
|
||||
|
||||
if (plugin && plugin->isValid())
|
||||
{
|
||||
plugin->pausePlugin();
|
||||
print_srvconsole("Paused plugin \"%s\"\n", plugin->getName());
|
||||
}
|
||||
else
|
||||
print_srvconsole("Couldn't find plugin matching \"%s\"\n", sPlugin);
|
||||
}
|
||||
else if (!strcmp(cmd, "unpause") && CMD_ARGC() > 2)
|
||||
{
|
||||
const char* sPlugin = CMD_ARGV(2);
|
||||
|
||||
CPluginMngr::CPlugin *plugin = g_plugins.findPlugin(sPlugin);
|
||||
|
||||
if (plugin && plugin->isValid() && plugin->isPaused())
|
||||
{
|
||||
plugin->unpausePlugin();
|
||||
print_srvconsole("Unpaused plugin \"%s\"\n", plugin->getName());
|
||||
}
|
||||
else if (!plugin)
|
||||
{
|
||||
print_srvconsole("Couldn't find plugin matching \"%s\"\n", sPlugin);
|
||||
} else {
|
||||
print_srvconsole("Plugin %s can't be unpaused right now.", sPlugin);
|
||||
}
|
||||
}
|
||||
else if (!strcmp(cmd, "cvars"))
|
||||
{
|
||||
print_srvconsole("Registered cvars:\n");
|
||||
print_srvconsole(" %-24.23s %-24.23s %-16.15s\n", "name", "value", "plugin");
|
||||
|
||||
int ammount = 0;
|
||||
|
||||
for (CList<CCVar>::iterator a = g_cvars.begin(); a; ++a)
|
||||
{
|
||||
print_srvconsole(" [%3d] %-24.23s %-24.23s %-16.15s\n", ++ammount, (*a).getName(), CVAR_GET_STRING((*a).getName()), (*a).getPluginName());
|
||||
}
|
||||
|
||||
if (!strcmp(cmd,"plugins") || !strcmp(cmd,"list"))
|
||||
{
|
||||
|
||||
print_srvconsole( "Currently loaded plugins:\n");
|
||||
print_srvconsole( " %-18.17s %-8.7s %-17.16s %-16.15s %-9.8s\n",
|
||||
"name","version","author","file","status");
|
||||
|
||||
int plugins = 0;
|
||||
int running = 0;
|
||||
|
||||
|
||||
CPluginMngr::iterator a = g_plugins.begin();
|
||||
print_srvconsole("%d cvars\n", ammount);
|
||||
}
|
||||
else if (!strcmp(cmd, "cmds"))
|
||||
{
|
||||
print_srvconsole("Registered commands:\n");
|
||||
print_srvconsole(" %-24.23s %-16.15s %-8.7s %-16.15s\n", "name", "access", "type", "plugin");
|
||||
|
||||
while (a)
|
||||
{
|
||||
++plugins;
|
||||
int ammount = 0;
|
||||
char access[32];
|
||||
|
||||
if ( (*a).isValid() && !(*a).isPaused() )
|
||||
++running;
|
||||
CmdMngr::iterator a = g_commands.begin(CMD_ConsoleCommand);
|
||||
|
||||
print_srvconsole( " [%3d] %-18.17s %-8.7s %-17.16s %-16.15s %-9.8s\n",
|
||||
plugins,(*a).getTitle(),(*a).getVersion(),
|
||||
(*a).getAuthor(), (*a).getName(), (*a).getStatus() );
|
||||
|
||||
++a;
|
||||
}
|
||||
|
||||
a = g_plugins.begin();
|
||||
|
||||
while (a)
|
||||
{
|
||||
if ( (*a).getStatusCode() == ps_bad_load )
|
||||
{
|
||||
//error
|
||||
print_srvconsole("Load fails: %s\n", (*a).getError());
|
||||
}
|
||||
++a;
|
||||
}
|
||||
|
||||
print_srvconsole( "%d plugins, %d running\n",plugins,running );
|
||||
|
||||
}
|
||||
else if (!strcmp(cmd,"pause") && CMD_ARGC() > 2)
|
||||
while (a)
|
||||
{
|
||||
const char* sPlugin = CMD_ARGV(2);
|
||||
|
||||
CPluginMngr::CPlugin *plugin = g_plugins.findPlugin(sPlugin);
|
||||
|
||||
if ( plugin && plugin->isValid() )
|
||||
{
|
||||
plugin->pausePlugin();
|
||||
print_srvconsole("Paused plugin \"%s\"\n",plugin->getName() );
|
||||
}
|
||||
else print_srvconsole("Couldn't find plugin matching \"%s\"\n",sPlugin);
|
||||
|
||||
UTIL_GetFlags(access, (*a).getFlags());
|
||||
print_srvconsole(" [%3d] %-24.23s %-16.15s %-8.7s %-16.15s\n", ++ammount, (*a).getCmdLine(), access, (*a).getCmdType(), (*a).getPlugin()->getName());
|
||||
++a;
|
||||
}
|
||||
else if (!strcmp(cmd,"unpause") && CMD_ARGC() > 2)
|
||||
{
|
||||
const char* sPlugin = CMD_ARGV(2);
|
||||
|
||||
CPluginMngr::CPlugin *plugin = g_plugins.findPlugin(sPlugin);
|
||||
|
||||
if ( plugin && plugin->isValid() && plugin->isPaused() )
|
||||
{
|
||||
plugin->unpausePlugin();
|
||||
print_srvconsole("Unpaused plugin \"%s\"\n",plugin->getName() );
|
||||
} else if (!plugin) {
|
||||
print_srvconsole("Couldn't find plugin matching \"%s\"\n",sPlugin);
|
||||
} else {
|
||||
print_srvconsole("Plugin %s can't be unpaused right now.", sPlugin);
|
||||
}
|
||||
|
||||
}
|
||||
else if (!strcmp(cmd,"cvars"))
|
||||
{
|
||||
print_srvconsole( "Registered cvars:\n");
|
||||
print_srvconsole( " %-24.23s %-24.23s %-16.15s\n",
|
||||
"name","value","plugin");
|
||||
|
||||
int ammount = 0;
|
||||
|
||||
for( CList<CCVar>::iterator a = g_cvars.begin(); a ; ++a )
|
||||
{
|
||||
print_srvconsole( " [%3d] %-24.23s %-24.23s %-16.15s\n",++ammount,
|
||||
(*a).getName() ,CVAR_GET_STRING( (*a).getName() ),(*a).getPluginName() );
|
||||
}
|
||||
|
||||
print_srvconsole( "%d cvars\n",ammount);
|
||||
}
|
||||
else if ( !strcmp(cmd,"cmds") )
|
||||
{
|
||||
|
||||
print_srvconsole( "Registered commands:\n");
|
||||
print_srvconsole( " %-24.23s %-16.15s %-8.7s %-16.15s\n",
|
||||
"name","access" ,"type" ,"plugin");
|
||||
|
||||
int ammount = 0;
|
||||
|
||||
char access[32];
|
||||
|
||||
CmdMngr::iterator a = g_commands.begin( CMD_ConsoleCommand );
|
||||
|
||||
while( a )
|
||||
{
|
||||
UTIL_GetFlags( access , (*a).getFlags() );
|
||||
print_srvconsole( " [%3d] %-24.23s %-16.15s %-8.7s %-16.15s\n",
|
||||
++ammount,(*a).getCmdLine() , access , (*a).getCmdType() , (*a).getPlugin()->getName());
|
||||
++a;
|
||||
}
|
||||
|
||||
print_srvconsole( "%d commands\n",ammount);
|
||||
}
|
||||
else if (!strcmp(cmd,"version"))
|
||||
{
|
||||
|
||||
print_srvconsole( "%s %s\n", Plugin_info.name, Plugin_info.version);
|
||||
print_srvconsole( "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);
|
||||
print_srvconsole( "Compiled: %s\n", __DATE__ ", " __TIME__);
|
||||
print_srvconsole("%d commands\n",ammount);
|
||||
}
|
||||
else if (!strcmp(cmd, "version"))
|
||||
{
|
||||
print_srvconsole("%s %s\n", Plugin_info.name, Plugin_info.version);
|
||||
print_srvconsole("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);
|
||||
print_srvconsole("Compiled: %s\n", __DATE__ ", " __TIME__);
|
||||
#if defined JIT && !defined ASM32
|
||||
print_srvconsole( "Core mode: JIT Only\n");
|
||||
print_srvconsole("Core mode: JIT Only\n");
|
||||
#elif !defined JIT && defined ASM32
|
||||
print_srvconsole( "Core mode: ASM32 Only\n");
|
||||
print_srvconsole("Core mode: ASM32 Only\n");
|
||||
#elif defined JIT && defined ASM32
|
||||
print_srvconsole( "Core mode: JIT+ASM32\n");
|
||||
print_srvconsole("Core mode: JIT+ASM32\n");
|
||||
#else
|
||||
print_srvconsole( "Core mode: Normal\n");
|
||||
print_srvconsole("Core mode: Normal\n");
|
||||
#endif
|
||||
}
|
||||
else if (!strcmp(cmd,"modules"))
|
||||
}
|
||||
else if (!strcmp(cmd, "modules"))
|
||||
{
|
||||
print_srvconsole("Currently loaded modules:\n");
|
||||
print_srvconsole(" %-23.22s %-8.7s %-20.19s %-11.10s\n", "name", "version", "author", "status");
|
||||
|
||||
int running = 0;
|
||||
int modules = 0;
|
||||
|
||||
CList<CModule,const char *>::iterator a = g_modules.begin();
|
||||
|
||||
while (a)
|
||||
{
|
||||
print_srvconsole( "Currently loaded modules:\n");
|
||||
print_srvconsole( " %-23.22s %-8.7s %-20.19s %-11.10s\n",
|
||||
"name", "version", "author", "status");
|
||||
if ((*a).getStatusValue() == MODULE_LOADED)
|
||||
++running;
|
||||
++modules;
|
||||
|
||||
int running = 0;
|
||||
int modules = 0;
|
||||
|
||||
CList<CModule,const char *>::iterator a = g_modules.begin();
|
||||
|
||||
while ( a )
|
||||
{
|
||||
if ( (*a).getStatusValue() == MODULE_LOADED )
|
||||
++running;
|
||||
|
||||
++modules;
|
||||
|
||||
print_srvconsole( " [%2d] %-23.22s %-8.7s %-20.19s %-11.10s\n", modules,
|
||||
(*a).getName(), (*a).getVersion(), (*a).getAuthor() , (*a).getStatus() );
|
||||
|
||||
++a;
|
||||
}
|
||||
|
||||
print_srvconsole( "%d modules, %d correct\n",modules,running);
|
||||
} else if (!strcmp(cmd, "gpl"))
|
||||
{
|
||||
print_srvconsole("AMX Mod X\n");
|
||||
print_srvconsole("\n");
|
||||
print_srvconsole(" by the AMX Mod X Development Team\n");
|
||||
print_srvconsole(" originally developed by OLO\n");
|
||||
print_srvconsole("\n");
|
||||
print_srvconsole("\n");
|
||||
print_srvconsole(" This program is free software; you can redistribute it and/or modify it\n");
|
||||
print_srvconsole(" under the terms of the GNU General Public License as published by the\n");
|
||||
print_srvconsole(" Free Software Foundation; either version 2 of the License, or (at\n");
|
||||
print_srvconsole(" your option) any later version.\n");
|
||||
print_srvconsole("\n");
|
||||
print_srvconsole(" This program is distributed in the hope that it will be useful, but\n");
|
||||
print_srvconsole(" WITHOUT ANY WARRANTY; without even the implied warranty of\n");
|
||||
print_srvconsole(" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n");
|
||||
print_srvconsole(" General Public License for more details.\n");
|
||||
print_srvconsole("\n");
|
||||
print_srvconsole(" You should have received a copy of the GNU General Public License\n");
|
||||
print_srvconsole(" along with this program; if not, write to the Free Software Foundation,\n");
|
||||
print_srvconsole(" Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n");
|
||||
print_srvconsole("\n");
|
||||
print_srvconsole(" In addition, as a special exception, the author gives permission to\n");
|
||||
print_srvconsole(" link the code of this program with the Half-Life Game Engine (\"HL\n");
|
||||
print_srvconsole(" Engine\") and Modified Game Libraries (\"MODs\") developed by Valve,\n");
|
||||
print_srvconsole(" L.L.C (\"Valve\"). You must obey the GNU General Public License in all\n");
|
||||
print_srvconsole(" respects for all of the code used other than the HL Engine and MODs\n");
|
||||
print_srvconsole(" from Valve. If you modify this file, you may extend this exception\n");
|
||||
print_srvconsole(" to your version of the file, but you are not obligated to do so. If\n");
|
||||
print_srvconsole(" you do not wish to do so, delete this exception statement from your\n");
|
||||
print_srvconsole(" version.\n");
|
||||
print_srvconsole("\n");
|
||||
print_srvconsole(" [%2d] %-23.22s %-8.7s %-20.19s %-11.10s\n", modules, (*a).getName(), (*a).getVersion(), (*a).getAuthor(), (*a).getStatus());
|
||||
++a;
|
||||
}
|
||||
else if (!strcmp(cmd, "\x74\x75\x72\x74\x6C\x65")) // !! Hidden Command :D !!
|
||||
{
|
||||
print_srvconsole("\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x2E\x2E\x3A\x3A\x3E\x3E\x3A\x3A\x3B\x3E\x5E\x27\x2E\x27\x27\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\n");
|
||||
print_srvconsole("\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x27\x3A\x3A\x3F\x3D\x3E\x3E\x3E\x3E\x3E\x3D\x3F\x3E\x78\x2B\x3F\x3E\x3E\x3E\x3D\x3E\x3F\x2B\x3F\x3E\x3B\x2E\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\n");
|
||||
print_srvconsole("\x20\x20\x20\x20\x20\x2E\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x27\x2C\x3A\x3E\x3B\x3F\x3D\x3E\x3B\x2E\x27\x5E\x5E\x3B\x3B\x2C\x3A\x3F\x3F\x3D\x78\x3F\x3B\x3E\x3A\x3B\x3A\x5E\x3B\x3D\x3E\x2B\x2B\x2B\x2B\x3D\x2C\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\n");
|
||||
print_srvconsole("\x20\x20\x2C\x3E\x37\x24\x24\x78\x3D\x3D\x3D\x3F\x3A\x27\x20\x20\x20\x20\x20\x20\x20\x2E\x3A\x3B\x3D\x3E\x3A\x3A\x3A\x3A\x3F\x3F\x3F\x3E\x5E\x2C\x2E\x2E\x2C\x2C\x2C\x2C\x3A\x3B\x3D\x3D\x3B\x5E\x2C\x2C\x2C\x3A\x5E\x3A\x3F\x3F\x3E\x3D\x3D\x3E\x3E\x2B\x3B\x27\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\n");
|
||||
print_srvconsole("\x2C\x3D\x2B\x3E\x2C\x5E\x3D\x79\x24\x33\x78\x33\x24\x5A\x24\x3B\x20\x20\x3A\x3E\x2B\x3E\x3D\x3F\x5E\x2C\x2C\x2C\x5E\x5E\x3E\x3D\x3E\x3B\x3B\x3A\x5E\x5E\x3E\x3F\x3D\x2B\x37\x3D\x3F\x3E\x3E\x3E\x3F\x3D\x3F\x3F\x3D\x3D\x3D\x3D\x3E\x3F\x3D\x3E\x3E\x3E\x3D\x5A\x78\x3E\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\n");
|
||||
print_srvconsole("\x3D\x5A\x24\x37\x78\x66\x68\x78\x5A\x5A\x24\x79\x79\x71\x23\x23\x4D\x71\x3B\x3A\x3B\x3A\x3E\x3B\x3B\x2C\x5E\x3E\x3F\x3D\x3F\x3A\x2C\x2C\x3A\x3B\x3B\x3E\x3E\x3D\x2B\x3D\x3E\x3D\x3B\x3A\x3E\x3D\x2B\x3D\x2B\x37\x2B\x3D\x2B\x37\x37\x2B\x2B\x33\x33\x33\x37\x37\x24\x5A\x79\x3A\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\n");
|
||||
print_srvconsole("\x20\x5E\x2B\x5A\x2B\x3E\x3D\x37\x5A\x66\x40\x40\x23\x40\x48\x23\x23\x23\x38\x5E\x3B\x3D\x3F\x2B\x3E\x3B\x3E\x5E\x5E\x2C\x27\x2E\x27\x2E\x2E\x5E\x3F\x3D\x3D\x3F\x3A\x3B\x3A\x3A\x3A\x5E\x5E\x3E\x3E\x3F\x3D\x37\x37\x3D\x3D\x37\x2B\x3D\x37\x2B\x37\x78\x24\x79\x38\x68\x45\x48\x79\x3E\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\n");
|
||||
print_srvconsole("\x20\x20\x20\x2C\x3E\x3E\x78\x33\x68\x48\x23\x23\x40\x40\x48\x45\x66\x33\x20\x2C\x3A\x3E\x3E\x3E\x3B\x3B\x3A\x3A\x2C\x2E\x2C\x5E\x3A\x2C\x5E\x3B\x3E\x37\x37\x3F\x3B\x3A\x2E\x3A\x3A\x3B\x3D\x3B\x3B\x3D\x2B\x3D\x78\x33\x37\x3E\x3D\x3D\x2B\x37\x2B\x78\x78\x78\x78\x5A\x66\x71\x68\x38\x45\x27\x20\x20\x20\x20\x20\x20\x20\x20\n");
|
||||
print_srvconsole("\x20\x20\x20\x20\x20\x20\x20\x3A\x37\x37\x24\x66\x71\x45\x45\x71\x45\x3A\x3A\x2C\x5E\x3A\x3E\x3A\x3A\x3B\x3B\x5E\x3A\x2C\x5E\x5E\x2C\x2C\x5E\x3A\x3E\x2B\x33\x3D\x3E\x3A\x3A\x3A\x3D\x2B\x2B\x3D\x3F\x3F\x37\x37\x2B\x37\x3D\x3D\x5A\x33\x78\x33\x37\x78\x24\x5A\x33\x37\x38\x40\x71\x38\x66\x40\x2C\x20\x20\x20\x20\x20\x20\x20\n");
|
||||
print_srvconsole("\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x5E\x2B\x5A\x45\x40\x5E\x5E\x5E\x3A\x2C\x3A\x3B\x3E\x3A\x5E\x5E\x2C\x2E\x2E\x2C\x5E\x3B\x3B\x3A\x2B\x3E\x3F\x3B\x3F\x3F\x3F\x3F\x3E\x3F\x3D\x37\x3B\x3B\x3D\x33\x2B\x3D\x3D\x78\x78\x5A\x78\x33\x78\x5A\x5A\x5A\x24\x71\x48\x79\x5A\x24\x79\x45\x3E\x20\x20\x20\x20\x20\x20\n");
|
||||
print_srvconsole("\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x27\x3B\x2C\x2C\x27\x5E\x5E\x2C\x3A\x5E\x3A\x3A\x5E\x3A\x3B\x3F\x3E\x3F\x3E\x3B\x3E\x3E\x3F\x3D\x2B\x37\x37\x2B\x2B\x3D\x2B\x37\x2B\x37\x37\x2B\x3B\x3D\x33\x2B\x2B\x37\x37\x2B\x3D\x78\x78\x66\x78\x78\x37\x33\x66\x78\x38\x23\x23\x27\x20\x20\x20\x20\x20\n");
|
||||
print_srvconsole("\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3A\x3F\x3B\x5E\x2C\x3B\x3F\x3D\x3F\x3F\x3B\x3A\x3A\x3A\x3E\x3F\x3E\x3E\x3F\x3A\x3F\x33\x78\x78\x33\x24\x24\x33\x2B\x37\x78\x24\x78\x33\x3D\x2B\x2B\x5A\x24\x78\x24\x78\x33\x33\x24\x5A\x79\x24\x24\x24\x68\x45\x48\x38\x68\x45\x40\x3E\x20\x20\x20\x20\x20\n");
|
||||
print_srvconsole("\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x2C\x3A\x3E\x3F\x37\x3D\x3E\x3F\x2B\x3F\x3F\x3E\x3F\x3F\x3F\x3D\x3F\x3E\x3F\x3D\x37\x2B\x3E\x3E\x2B\x37\x37\x33\x37\x33\x78\x33\x33\x33\x78\x37\x37\x37\x78\x5A\x78\x5A\x79\x79\x5A\x24\x79\x79\x79\x79\x79\x68\x71\x38\x38\x71\x23\x23\x45\x37\x20\x20\x20\x20\x20\n");
|
||||
print_srvconsole("\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x5E\x2B\x2B\x3F\x2B\x78\x40\x38\x3F\x3B\x3E\x3B\x3B\x3E\x3F\x37\x2B\x3F\x3F\x3D\x3D\x3E\x3F\x2B\x37\x37\x37\x37\x33\x33\x78\x78\x33\x37\x24\x5A\x78\x5A\x5A\x78\x24\x33\x3D\x37\x37\x37\x78\x24\x5A\x78\x37\x37\x78\x66\x79\x66\x71\x66\x40\x45\x40\x3A\x20\x20\x20\x20\x20\n");
|
||||
print_srvconsole("\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x2B\x3A\x3F\x2B\x3D\x2B\x79\x23\x79\x3B\x2C\x3A\x3A\x3A\x37\x78\x3F\x3E\x3B\x3E\x3B\x3E\x3D\x37\x24\x33\x37\x33\x37\x78\x78\x33\x24\x68\x79\x33\x24\x78\x2B\x33\x33\x5A\x79\x24\x5A\x79\x24\x5A\x37\x24\x5A\x5A\x66\x38\x66\x79\x66\x40\x71\x45\x48\x5A\x3A\x20\x20\x20\x20\n");
|
||||
print_srvconsole("\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x5E\x37\x3D\x37\x37\x33\x37\x37\x66\x45\x5A\x3F\x5E\x5E\x78\x37\x3D\x3F\x3E\x3B\x3B\x3E\x2B\x2B\x24\x78\x37\x2B\x37\x2B\x37\x78\x78\x71\x79\x33\x33\x24\x24\x78\x24\x5A\x3F\x37\x78\x24\x78\x79\x66\x5A\x78\x79\x66\x79\x68\x79\x66\x5A\x33\x3F\x3D\x3D\x20\x20\x20\x20\x20\n");
|
||||
print_srvconsole("\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x5E\x2B\x3D\x3F\x37\x37\x78\x33\x5A\x4E\x4D\x23\x38\x33\x3F\x3E\x3B\x3E\x3B\x3D\x3D\x33\x66\x24\x78\x33\x2B\x78\x24\x5A\x24\x5A\x71\x79\x78\x33\x33\x78\x79\x5A\x5A\x33\x66\x24\x78\x78\x24\x79\x5A\x24\x79\x5A\x37\x66\x24\x3D\x3B\x66\x23\x4D\x4D\x4D\x79\x3B\x20\x20\n");
|
||||
print_srvconsole("\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3A\x33\x37\x37\x24\x78\x66\x79\x48\x4D\x4D\x4D\x4D\x23\x71\x68\x5A\x24\x5A\x79\x68\x68\x5A\x5A\x24\x79\x66\x68\x78\x5A\x4E\x45\x66\x66\x45\x45\x45\x24\x5A\x40\x71\x68\x5A\x68\x5A\x37\x66\x79\x78\x37\x78\x37\x68\x38\x38\x71\x48\x40\x23\x45\x3A\x3D\x37\x45\x27\n");
|
||||
print_srvconsole("\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x37\x37\x78\x37\x33\x38\x45\x45\x71\x20\x5E\x3D\x2B\x3F\x2B\x2B\x79\x71\x45\x48\x40\x45\x45\x45\x45\x45\x71\x40\x40\x71\x38\x38\x79\x66\x38\x68\x48\x48\x45\x66\x37\x2B\x3A\x37\x3F\x3B\x3A\x2C\x27\x2C\x27\x78\x4D\x23\x48\x48\x48\x79\x2B\x3A\x3F\x79\x27\n");
|
||||
print_srvconsole("\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3A\x78\x78\x24\x40\x4E\x4E\x4D\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x5E\x3E\x3E\x3F\x3E\x3E\x3E\x3E\x3B\x3B\x3B\x3A\x3A\x3F\x3E\x3A\x2E\x2E\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x2E\x45\x4D\x40\x45\x78\x5E\x33\x68\x33\x2B\n");
|
||||
print_srvconsole("\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x24\x48\x45\x48\x78\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x2B\x4E\x40\x2B\x66\x33\x78\x20\x20\n");
|
||||
print_srvconsole("\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x2B\x2C\x20\x3A\x20\x20\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
print_srvconsole("Usage: amxx < command > [ argument ]\n");
|
||||
print_srvconsole("Commands:\n");
|
||||
print_srvconsole(" version - display amxx version info\n");
|
||||
print_srvconsole(" gpl - print the license\n");
|
||||
print_srvconsole(" plugins - list plugins currently loaded\n");
|
||||
print_srvconsole(" modules - list modules currently loaded\n");
|
||||
print_srvconsole(" cvars - list cvars registered by plugins\n");
|
||||
print_srvconsole(" cmds - list commands registered by plugins\n");
|
||||
print_srvconsole(" pause < plugin > - pause a running plugin\n");
|
||||
print_srvconsole(" unpause < plugin > - unpause a previously paused plugin\n");
|
||||
|
||||
}
|
||||
print_srvconsole("%d modules, %d correct\n", modules, running);
|
||||
}
|
||||
else if (!strcmp(cmd, "gpl"))
|
||||
{
|
||||
print_srvconsole("AMX Mod X\n");
|
||||
print_srvconsole("\n");
|
||||
print_srvconsole(" by the AMX Mod X Development Team\n");
|
||||
print_srvconsole(" originally developed by OLO\n");
|
||||
print_srvconsole("\n");
|
||||
print_srvconsole("\n");
|
||||
print_srvconsole(" This program is free software; you can redistribute it and/or modify it\n");
|
||||
print_srvconsole(" under the terms of the GNU General Public License as published by the\n");
|
||||
print_srvconsole(" Free Software Foundation; either version 2 of the License, or (at\n");
|
||||
print_srvconsole(" your option) any later version.\n");
|
||||
print_srvconsole("\n");
|
||||
print_srvconsole(" This program is distributed in the hope that it will be useful, but\n");
|
||||
print_srvconsole(" WITHOUT ANY WARRANTY; without even the implied warranty of\n");
|
||||
print_srvconsole(" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n");
|
||||
print_srvconsole(" General Public License for more details.\n");
|
||||
print_srvconsole("\n");
|
||||
print_srvconsole(" You should have received a copy of the GNU General Public License\n");
|
||||
print_srvconsole(" along with this program; if not, write to the Free Software Foundation,\n");
|
||||
print_srvconsole(" Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n");
|
||||
print_srvconsole("\n");
|
||||
print_srvconsole(" In addition, as a special exception, the author gives permission to\n");
|
||||
print_srvconsole(" link the code of this program with the Half-Life Game Engine (\"HL\n");
|
||||
print_srvconsole(" Engine\") and Modified Game Libraries (\"MODs\") developed by Valve,\n");
|
||||
print_srvconsole(" L.L.C (\"Valve\"). You must obey the GNU General Public License in all\n");
|
||||
print_srvconsole(" respects for all of the code used other than the HL Engine and MODs\n");
|
||||
print_srvconsole(" from Valve. If you modify this file, you may extend this exception\n");
|
||||
print_srvconsole(" to your version of the file, but you are not obligated to do so. If\n");
|
||||
print_srvconsole(" you do not wish to do so, delete this exception statement from your\n");
|
||||
print_srvconsole(" version.\n");
|
||||
print_srvconsole("\n");
|
||||
}
|
||||
else if (!strcmp(cmd, "\x74\x75\x72\x74\x6C\x65")) // !! Hidden Command :D !!
|
||||
{
|
||||
print_srvconsole("\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x2E\x2E\x3A\x3A\x3E\x3E\x3A\x3A\x3B\x3E\x5E\x27\x2E\x27\x27\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\n");
|
||||
print_srvconsole("\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x27\x3A\x3A\x3F\x3D\x3E\x3E\x3E\x3E\x3E\x3D\x3F\x3E\x78\x2B\x3F\x3E\x3E\x3E\x3D\x3E\x3F\x2B\x3F\x3E\x3B\x2E\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\n");
|
||||
print_srvconsole("\x20\x20\x20\x20\x20\x2E\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x27\x2C\x3A\x3E\x3B\x3F\x3D\x3E\x3B\x2E\x27\x5E\x5E\x3B\x3B\x2C\x3A\x3F\x3F\x3D\x78\x3F\x3B\x3E\x3A\x3B\x3A\x5E\x3B\x3D\x3E\x2B\x2B\x2B\x2B\x3D\x2C\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\n");
|
||||
print_srvconsole("\x20\x20\x2C\x3E\x37\x24\x24\x78\x3D\x3D\x3D\x3F\x3A\x27\x20\x20\x20\x20\x20\x20\x20\x2E\x3A\x3B\x3D\x3E\x3A\x3A\x3A\x3A\x3F\x3F\x3F\x3E\x5E\x2C\x2E\x2E\x2C\x2C\x2C\x2C\x3A\x3B\x3D\x3D\x3B\x5E\x2C\x2C\x2C\x3A\x5E\x3A\x3F\x3F\x3E\x3D\x3D\x3E\x3E\x2B\x3B\x27\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\n");
|
||||
print_srvconsole("\x2C\x3D\x2B\x3E\x2C\x5E\x3D\x79\x24\x33\x78\x33\x24\x5A\x24\x3B\x20\x20\x3A\x3E\x2B\x3E\x3D\x3F\x5E\x2C\x2C\x2C\x5E\x5E\x3E\x3D\x3E\x3B\x3B\x3A\x5E\x5E\x3E\x3F\x3D\x2B\x37\x3D\x3F\x3E\x3E\x3E\x3F\x3D\x3F\x3F\x3D\x3D\x3D\x3D\x3E\x3F\x3D\x3E\x3E\x3E\x3D\x5A\x78\x3E\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\n");
|
||||
print_srvconsole("\x3D\x5A\x24\x37\x78\x66\x68\x78\x5A\x5A\x24\x79\x79\x71\x23\x23\x4D\x71\x3B\x3A\x3B\x3A\x3E\x3B\x3B\x2C\x5E\x3E\x3F\x3D\x3F\x3A\x2C\x2C\x3A\x3B\x3B\x3E\x3E\x3D\x2B\x3D\x3E\x3D\x3B\x3A\x3E\x3D\x2B\x3D\x2B\x37\x2B\x3D\x2B\x37\x37\x2B\x2B\x33\x33\x33\x37\x37\x24\x5A\x79\x3A\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\n");
|
||||
print_srvconsole("\x20\x5E\x2B\x5A\x2B\x3E\x3D\x37\x5A\x66\x40\x40\x23\x40\x48\x23\x23\x23\x38\x5E\x3B\x3D\x3F\x2B\x3E\x3B\x3E\x5E\x5E\x2C\x27\x2E\x27\x2E\x2E\x5E\x3F\x3D\x3D\x3F\x3A\x3B\x3A\x3A\x3A\x5E\x5E\x3E\x3E\x3F\x3D\x37\x37\x3D\x3D\x37\x2B\x3D\x37\x2B\x37\x78\x24\x79\x38\x68\x45\x48\x79\x3E\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\n");
|
||||
print_srvconsole("\x20\x20\x20\x2C\x3E\x3E\x78\x33\x68\x48\x23\x23\x40\x40\x48\x45\x66\x33\x20\x2C\x3A\x3E\x3E\x3E\x3B\x3B\x3A\x3A\x2C\x2E\x2C\x5E\x3A\x2C\x5E\x3B\x3E\x37\x37\x3F\x3B\x3A\x2E\x3A\x3A\x3B\x3D\x3B\x3B\x3D\x2B\x3D\x78\x33\x37\x3E\x3D\x3D\x2B\x37\x2B\x78\x78\x78\x78\x5A\x66\x71\x68\x38\x45\x27\x20\x20\x20\x20\x20\x20\x20\x20\n");
|
||||
print_srvconsole("\x20\x20\x20\x20\x20\x20\x20\x3A\x37\x37\x24\x66\x71\x45\x45\x71\x45\x3A\x3A\x2C\x5E\x3A\x3E\x3A\x3A\x3B\x3B\x5E\x3A\x2C\x5E\x5E\x2C\x2C\x5E\x3A\x3E\x2B\x33\x3D\x3E\x3A\x3A\x3A\x3D\x2B\x2B\x3D\x3F\x3F\x37\x37\x2B\x37\x3D\x3D\x5A\x33\x78\x33\x37\x78\x24\x5A\x33\x37\x38\x40\x71\x38\x66\x40\x2C\x20\x20\x20\x20\x20\x20\x20\n");
|
||||
print_srvconsole("\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x5E\x2B\x5A\x45\x40\x5E\x5E\x5E\x3A\x2C\x3A\x3B\x3E\x3A\x5E\x5E\x2C\x2E\x2E\x2C\x5E\x3B\x3B\x3A\x2B\x3E\x3F\x3B\x3F\x3F\x3F\x3F\x3E\x3F\x3D\x37\x3B\x3B\x3D\x33\x2B\x3D\x3D\x78\x78\x5A\x78\x33\x78\x5A\x5A\x5A\x24\x71\x48\x79\x5A\x24\x79\x45\x3E\x20\x20\x20\x20\x20\x20\n");
|
||||
print_srvconsole("\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x27\x3B\x2C\x2C\x27\x5E\x5E\x2C\x3A\x5E\x3A\x3A\x5E\x3A\x3B\x3F\x3E\x3F\x3E\x3B\x3E\x3E\x3F\x3D\x2B\x37\x37\x2B\x2B\x3D\x2B\x37\x2B\x37\x37\x2B\x3B\x3D\x33\x2B\x2B\x37\x37\x2B\x3D\x78\x78\x66\x78\x78\x37\x33\x66\x78\x38\x23\x23\x27\x20\x20\x20\x20\x20\n");
|
||||
print_srvconsole("\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3A\x3F\x3B\x5E\x2C\x3B\x3F\x3D\x3F\x3F\x3B\x3A\x3A\x3A\x3E\x3F\x3E\x3E\x3F\x3A\x3F\x33\x78\x78\x33\x24\x24\x33\x2B\x37\x78\x24\x78\x33\x3D\x2B\x2B\x5A\x24\x78\x24\x78\x33\x33\x24\x5A\x79\x24\x24\x24\x68\x45\x48\x38\x68\x45\x40\x3E\x20\x20\x20\x20\x20\n");
|
||||
print_srvconsole("\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x2C\x3A\x3E\x3F\x37\x3D\x3E\x3F\x2B\x3F\x3F\x3E\x3F\x3F\x3F\x3D\x3F\x3E\x3F\x3D\x37\x2B\x3E\x3E\x2B\x37\x37\x33\x37\x33\x78\x33\x33\x33\x78\x37\x37\x37\x78\x5A\x78\x5A\x79\x79\x5A\x24\x79\x79\x79\x79\x79\x68\x71\x38\x38\x71\x23\x23\x45\x37\x20\x20\x20\x20\x20\n");
|
||||
print_srvconsole("\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x5E\x2B\x2B\x3F\x2B\x78\x40\x38\x3F\x3B\x3E\x3B\x3B\x3E\x3F\x37\x2B\x3F\x3F\x3D\x3D\x3E\x3F\x2B\x37\x37\x37\x37\x33\x33\x78\x78\x33\x37\x24\x5A\x78\x5A\x5A\x78\x24\x33\x3D\x37\x37\x37\x78\x24\x5A\x78\x37\x37\x78\x66\x79\x66\x71\x66\x40\x45\x40\x3A\x20\x20\x20\x20\x20\n");
|
||||
print_srvconsole("\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x2B\x3A\x3F\x2B\x3D\x2B\x79\x23\x79\x3B\x2C\x3A\x3A\x3A\x37\x78\x3F\x3E\x3B\x3E\x3B\x3E\x3D\x37\x24\x33\x37\x33\x37\x78\x78\x33\x24\x68\x79\x33\x24\x78\x2B\x33\x33\x5A\x79\x24\x5A\x79\x24\x5A\x37\x24\x5A\x5A\x66\x38\x66\x79\x66\x40\x71\x45\x48\x5A\x3A\x20\x20\x20\x20\n");
|
||||
print_srvconsole("\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x5E\x37\x3D\x37\x37\x33\x37\x37\x66\x45\x5A\x3F\x5E\x5E\x78\x37\x3D\x3F\x3E\x3B\x3B\x3E\x2B\x2B\x24\x78\x37\x2B\x37\x2B\x37\x78\x78\x71\x79\x33\x33\x24\x24\x78\x24\x5A\x3F\x37\x78\x24\x78\x79\x66\x5A\x78\x79\x66\x79\x68\x79\x66\x5A\x33\x3F\x3D\x3D\x20\x20\x20\x20\x20\n");
|
||||
print_srvconsole("\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x5E\x2B\x3D\x3F\x37\x37\x78\x33\x5A\x4E\x4D\x23\x38\x33\x3F\x3E\x3B\x3E\x3B\x3D\x3D\x33\x66\x24\x78\x33\x2B\x78\x24\x5A\x24\x5A\x71\x79\x78\x33\x33\x78\x79\x5A\x5A\x33\x66\x24\x78\x78\x24\x79\x5A\x24\x79\x5A\x37\x66\x24\x3D\x3B\x66\x23\x4D\x4D\x4D\x79\x3B\x20\x20\n");
|
||||
print_srvconsole("\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3A\x33\x37\x37\x24\x78\x66\x79\x48\x4D\x4D\x4D\x4D\x23\x71\x68\x5A\x24\x5A\x79\x68\x68\x5A\x5A\x24\x79\x66\x68\x78\x5A\x4E\x45\x66\x66\x45\x45\x45\x24\x5A\x40\x71\x68\x5A\x68\x5A\x37\x66\x79\x78\x37\x78\x37\x68\x38\x38\x71\x48\x40\x23\x45\x3A\x3D\x37\x45\x27\n");
|
||||
print_srvconsole("\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x37\x37\x78\x37\x33\x38\x45\x45\x71\x20\x5E\x3D\x2B\x3F\x2B\x2B\x79\x71\x45\x48\x40\x45\x45\x45\x45\x45\x71\x40\x40\x71\x38\x38\x79\x66\x38\x68\x48\x48\x45\x66\x37\x2B\x3A\x37\x3F\x3B\x3A\x2C\x27\x2C\x27\x78\x4D\x23\x48\x48\x48\x79\x2B\x3A\x3F\x79\x27\n");
|
||||
print_srvconsole("\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3A\x78\x78\x24\x40\x4E\x4E\x4D\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x5E\x3E\x3E\x3F\x3E\x3E\x3E\x3E\x3B\x3B\x3B\x3A\x3A\x3F\x3E\x3A\x2E\x2E\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x2E\x45\x4D\x40\x45\x78\x5E\x33\x68\x33\x2B\n");
|
||||
print_srvconsole("\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x24\x48\x45\x48\x78\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x2B\x4E\x40\x2B\x66\x33\x78\x20\x20\n");
|
||||
print_srvconsole("\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x2B\x2C\x20\x3A\x20\x20\n");
|
||||
} else {
|
||||
print_srvconsole("Usage: amxx < command > [ argument ]\n");
|
||||
print_srvconsole("Commands:\n");
|
||||
print_srvconsole(" version - display amxx version info\n");
|
||||
print_srvconsole(" gpl - print the license\n");
|
||||
print_srvconsole(" plugins - list plugins currently loaded\n");
|
||||
print_srvconsole(" modules - list modules currently loaded\n");
|
||||
print_srvconsole(" cvars - list cvars registered by plugins\n");
|
||||
print_srvconsole(" cmds - list commands registered by plugins\n");
|
||||
print_srvconsole(" pause < plugin > - pause a running plugin\n");
|
||||
print_srvconsole(" unpause < plugin > - unpause a previously paused plugin\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void plugin_srvcmd()
|
||||
{
|
||||
cell ret = 0;
|
||||
@ -272,13 +250,12 @@ void plugin_srvcmd()
|
||||
|
||||
CmdMngr::iterator a = g_commands.srvcmdbegin();
|
||||
|
||||
while ( a )
|
||||
while (a)
|
||||
{
|
||||
if ( (*a).matchCommand( cmd ) &&
|
||||
(*a).getPlugin()->isExecutable( (*a).getFunction() ) )
|
||||
if ((*a).matchCommand(cmd) && (*a).getPlugin()->isExecutable((*a).getFunction()))
|
||||
{
|
||||
cell ret = executeForwards((*a).getFunction(), g_srvindex, (*a).getFlags(), (*a).getId());
|
||||
if ( ret ) break;
|
||||
if (ret) break;
|
||||
}
|
||||
++a;
|
||||
}
|
||||
|
@ -32,19 +32,20 @@
|
||||
#include <ctype.h>
|
||||
#include "amxmodx.h"
|
||||
|
||||
const char* stristr(const char* str,const char* substr)
|
||||
const char* stristr(const char* str, const char* substr)
|
||||
{
|
||||
register char *needle = (char *)substr;
|
||||
register char *prevloc = (char *)str;
|
||||
register char *haystack = (char *)str;
|
||||
|
||||
while (*haystack) {
|
||||
if (tolower(*haystack) == tolower(*needle)) {
|
||||
while (*haystack)
|
||||
{
|
||||
if (tolower(*haystack) == tolower(*needle))
|
||||
{
|
||||
haystack++;
|
||||
if (!*++needle)
|
||||
return prevloc;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
haystack = ++prevloc;
|
||||
needle = (char *)substr;
|
||||
}
|
||||
@ -53,7 +54,7 @@ const char* stristr(const char* str,const char* substr)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char* format_amxstring(AMX *amx, cell *params, int parm,int& len)
|
||||
char* format_amxstring(AMX *amx, cell *params, int parm, int& len)
|
||||
{
|
||||
return g_langMngr.FormatAmxString(amx, params, parm, len);
|
||||
}
|
||||
@ -62,71 +63,86 @@ int amxstring_len(cell* a)
|
||||
{
|
||||
register int c = 0;
|
||||
|
||||
while( a[ c ] )
|
||||
while (a[c])
|
||||
++c;
|
||||
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
cell* get_amxaddr(AMX *amx,cell amx_addr)
|
||||
cell* get_amxaddr(AMX *amx, cell amx_addr)
|
||||
{
|
||||
return (cell *)(amx->base + (int)(((AMX_HEADER *)amx->base)->dat + amx_addr));
|
||||
}
|
||||
|
||||
int set_amxstring(AMX *amx,cell amx_addr,const char *source,int max)
|
||||
int set_amxstring(AMX *amx, cell amx_addr, const char *source, int max)
|
||||
{
|
||||
cell* dest = (cell *)(amx->base + (int)(((AMX_HEADER *)amx->base)->dat + amx_addr));
|
||||
cell* start = dest;
|
||||
while (max--&&*source)
|
||||
*dest++=(cell)*source++;
|
||||
|
||||
while (max-- && *source)
|
||||
*dest++ = (cell)*source++;
|
||||
|
||||
*dest = 0;
|
||||
return dest-start;
|
||||
|
||||
return dest - start;
|
||||
}
|
||||
|
||||
char* get_amxstring(AMX *amx,cell amx_addr,int id, int& len)
|
||||
char* get_amxstring(AMX *amx, cell amx_addr, int id, int& len)
|
||||
{
|
||||
static char buffor[4][3072];
|
||||
register cell* source = (cell *)(amx->base + (int)(((AMX_HEADER *)amx->base)->dat + amx_addr));
|
||||
register char* dest = buffor[id];
|
||||
char* start = dest;
|
||||
while ((*dest++=(char)(*source++)))
|
||||
;
|
||||
|
||||
while ((*dest++=(char)(*source++)));
|
||||
|
||||
len = --dest - start;
|
||||
|
||||
return start;
|
||||
}
|
||||
|
||||
void copy_amxmemory(cell* dest,cell* src,int len)
|
||||
void copy_amxmemory(cell* dest, cell* src, int len)
|
||||
{
|
||||
while (len--)
|
||||
*dest++=*src++;
|
||||
}
|
||||
|
||||
|
||||
char* parse_arg(char** line,int& state)
|
||||
char* parse_arg(char** line, int& state)
|
||||
{
|
||||
static char arg[3072];
|
||||
char* dest = arg;
|
||||
state = 0;
|
||||
while(**line) {
|
||||
if ( isspace(**line) ) {
|
||||
|
||||
while (**line)
|
||||
{
|
||||
if (isspace(**line))
|
||||
{
|
||||
if (state == 1)
|
||||
break;
|
||||
else if (!state) {
|
||||
else if (!state)
|
||||
{
|
||||
(*line)++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (state != 2)
|
||||
state = 1;
|
||||
if (**line=='"') {
|
||||
|
||||
if (**line == '"')
|
||||
{
|
||||
(*line)++;
|
||||
|
||||
if (state == 2)
|
||||
break;
|
||||
|
||||
state = 2;
|
||||
continue;
|
||||
}
|
||||
|
||||
*dest++ = *(*line)++;
|
||||
}
|
||||
|
||||
*dest = '\0';
|
||||
return arg;
|
||||
}
|
||||
@ -134,89 +150,107 @@ 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]);
|
||||
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);
|
||||
int iPot = iMain + iWith - iWhat;
|
||||
if (iPot>=params[2]){
|
||||
|
||||
if (iPot >= params[2])
|
||||
{
|
||||
amx_RaiseError(amx,AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *d = buffor;
|
||||
cell *x, *y, *z = a, *l = a;
|
||||
int p = 0;
|
||||
while(*a){
|
||||
if (*a==*b){
|
||||
x=a+1;
|
||||
y=b+1;
|
||||
p=1;
|
||||
|
||||
while (*a)
|
||||
{
|
||||
if (*a == *b)
|
||||
{
|
||||
x = a + 1;
|
||||
y = b + 1;
|
||||
p = 1;
|
||||
if (!*y) break;
|
||||
while(*x==*y){
|
||||
|
||||
while (*x == *y)
|
||||
{
|
||||
x++; y++; p++;
|
||||
if (!*y) break;
|
||||
}
|
||||
|
||||
if (!*y) break;
|
||||
p = 0;
|
||||
*d++=(char)*a++;
|
||||
*d++ = (char)*a++;
|
||||
continue;
|
||||
}
|
||||
*d++=(char)*a++;
|
||||
*d++ = (char)*a++;
|
||||
}
|
||||
if (p){
|
||||
while(*c) *d++=(char)*c++;
|
||||
a+=p;
|
||||
while(*a) *d++=(char)*a++;
|
||||
*d=0;
|
||||
|
||||
if (p)
|
||||
{
|
||||
while (*c) *d++ = (char)*c++;
|
||||
a += p;
|
||||
while (*a) *d++ = (char)*a++;
|
||||
*d = 0;
|
||||
d = buffor;
|
||||
while(*d) *z++=*d++;
|
||||
*z=0;
|
||||
return (z-l);
|
||||
while (*d) *z++ = *d++;
|
||||
*z = 0;
|
||||
return (z - l);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL contain(AMX *amx, cell *params) /* 2 param */
|
||||
{
|
||||
register cell *a = get_amxaddr(amx,params[2]);
|
||||
register cell *b = get_amxaddr(amx,params[1]);
|
||||
register cell *a = get_amxaddr(amx, params[2]);
|
||||
register cell *b = get_amxaddr(amx, params[1]);
|
||||
register cell *c = b;
|
||||
cell* str = b;
|
||||
cell* substr = a;
|
||||
while (*c) {
|
||||
if (*c == *a) {
|
||||
|
||||
while (*c)
|
||||
{
|
||||
if (*c == *a)
|
||||
{
|
||||
c++;
|
||||
if (!*++a)
|
||||
return b - str;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
c = ++b;
|
||||
a = substr;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL containi(AMX *amx, cell *params) /* 2 param */
|
||||
{
|
||||
register cell *a = get_amxaddr(amx,params[2]);
|
||||
register cell *b = get_amxaddr(amx,params[1]);
|
||||
register cell *a = get_amxaddr(amx, params[2]);
|
||||
register cell *b = get_amxaddr(amx, params[1]);
|
||||
register cell *c = b;
|
||||
cell* str = b;
|
||||
cell* substr = a;
|
||||
while (*c) {
|
||||
if (tolower(*c) == tolower(*a)) {
|
||||
|
||||
while (*c)
|
||||
{
|
||||
if (tolower(*c) == tolower(*a))
|
||||
{
|
||||
c++;
|
||||
if (!*++a)
|
||||
return b - str;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
c = ++b;
|
||||
a = substr;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -237,7 +271,7 @@ static cell AMX_NATIVE_CALL str_to_float(AMX *amx, cell *params)
|
||||
{
|
||||
cell *str = get_amxaddr(amx, params[1]);
|
||||
|
||||
bool neg=false;
|
||||
bool neg = false;
|
||||
unsigned long part1 = 0;
|
||||
|
||||
if (*str == '-')
|
||||
@ -255,6 +289,7 @@ static cell AMX_NATIVE_CALL str_to_float(AMX *amx, cell *params)
|
||||
++str;
|
||||
break;
|
||||
}
|
||||
|
||||
if (*str < '0' || *str > '9')
|
||||
{
|
||||
REAL fl = neg ? -static_cast<REAL>(part1) : static_cast<REAL>(part1);
|
||||
@ -269,6 +304,7 @@ static cell AMX_NATIVE_CALL str_to_float(AMX *amx, cell *params)
|
||||
|
||||
unsigned long part2 = 0;
|
||||
unsigned long div = 1;
|
||||
|
||||
while (*str)
|
||||
{
|
||||
if (*str < '0' || *str > '9')
|
||||
@ -281,8 +317,10 @@ static cell AMX_NATIVE_CALL str_to_float(AMX *amx, cell *params)
|
||||
}
|
||||
|
||||
REAL fl = static_cast<REAL>(part1) + (static_cast<REAL>(part2) / div);
|
||||
|
||||
if (neg)
|
||||
fl = -fl;
|
||||
|
||||
return amx_ftoc(fl);
|
||||
}
|
||||
|
||||
@ -295,216 +333,264 @@ static cell AMX_NATIVE_CALL float_to_str(AMX *amx, cell *params)
|
||||
|
||||
static cell AMX_NATIVE_CALL add(AMX *amx, cell *params) /* 4 param */
|
||||
{
|
||||
cell *src = get_amxaddr(amx,params[3]);
|
||||
cell *dest = get_amxaddr(amx,params[1]);
|
||||
cell *src = get_amxaddr(amx, params[3]);
|
||||
cell *dest = get_amxaddr(amx, params[1]);
|
||||
cell *start = dest;
|
||||
int c = params[2], d = params[4];
|
||||
while(*dest&&c--)
|
||||
|
||||
while (*dest && c--)
|
||||
++dest;
|
||||
if (d){
|
||||
while(c--&&d--&&*src)
|
||||
*dest++=*src++;
|
||||
*dest=0;
|
||||
return (dest-start);
|
||||
|
||||
if (d)
|
||||
{
|
||||
while (c-- && d-- && *src)
|
||||
*dest++ =* src++;
|
||||
*dest = 0;
|
||||
|
||||
return (dest - start);
|
||||
}
|
||||
while(c--&&*src)
|
||||
*dest++=*src++;
|
||||
*dest=0;
|
||||
|
||||
while (c-- && *src)
|
||||
*dest++ =* src++;
|
||||
*dest = 0;
|
||||
|
||||
return (dest-start);
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL copy(AMX *amx, cell *params) /* 4 param */
|
||||
{
|
||||
cell *src = get_amxaddr(amx,params[3]);
|
||||
cell *dest = get_amxaddr(amx,params[1]);
|
||||
cell *src = get_amxaddr(amx, params[3]);
|
||||
cell *dest = get_amxaddr(amx, params[1]);
|
||||
cell *start = dest;
|
||||
int c = params[2];
|
||||
while(c--&&*src)
|
||||
*dest++=*src++;
|
||||
*dest=0;
|
||||
return (dest-start);
|
||||
|
||||
while (c-- && *src)
|
||||
*dest++ =* src++;
|
||||
*dest = 0;
|
||||
|
||||
return (dest - start);
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL copyc(AMX *amx, cell *params) /* 4 param */
|
||||
{
|
||||
cell *src = get_amxaddr(amx,params[3]);
|
||||
cell *dest = get_amxaddr(amx,params[1]);
|
||||
cell *src = get_amxaddr(amx, params[3]);
|
||||
cell *dest = get_amxaddr(amx, params[1]);
|
||||
cell *start = dest;
|
||||
int c = params[2];
|
||||
cell ch = params[4];
|
||||
while(c--&&*src&&*src!=ch)
|
||||
*dest++=*src++;
|
||||
*dest=0;
|
||||
return (dest-start);
|
||||
|
||||
while (c-- && *src && *src != ch)
|
||||
*dest++ =* src++;
|
||||
*dest = 0;
|
||||
|
||||
return (dest - start);
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL setc(AMX *amx, cell *params) /* 4 param */
|
||||
{
|
||||
cell *src = get_amxaddr(amx,params[1]);
|
||||
cell *src = get_amxaddr(amx, params[1]);
|
||||
int c = params[2];
|
||||
cell ch = params[3];
|
||||
while(c--)
|
||||
*src++=ch;
|
||||
|
||||
while (c--)
|
||||
*src++ = ch;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL equal(AMX *amx, cell *params) /* 3 param */
|
||||
{
|
||||
cell *a = get_amxaddr(amx,params[1]);
|
||||
cell *b = get_amxaddr(amx,params[2]);
|
||||
cell *a = get_amxaddr(amx, params[1]);
|
||||
cell *b = get_amxaddr(amx, params[2]);
|
||||
int c = params[3];
|
||||
if (c) {
|
||||
while (--c&&*a&&(*a==*b))
|
||||
|
||||
if (c)
|
||||
{
|
||||
while (--c && *a && (*a == *b))
|
||||
++a, ++b;
|
||||
return (*a-*b)?0:1;
|
||||
}
|
||||
|
||||
int ret;
|
||||
while(!(ret=*a-*b)&&*b)
|
||||
|
||||
while (!(ret = *a - *b) && *b)
|
||||
++a, ++b;
|
||||
return ret?0:1;
|
||||
|
||||
return ret ? 0 : 1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL equali(AMX *amx, cell *params) /* 3 param */
|
||||
{
|
||||
cell *a = get_amxaddr(amx,params[1]);
|
||||
cell *b = get_amxaddr(amx,params[2]);
|
||||
int f,l, c = params[3];
|
||||
if (c) {
|
||||
do {
|
||||
cell *a = get_amxaddr(amx, params[1]);
|
||||
cell *b = get_amxaddr(amx, params[2]);
|
||||
int f, l, c = params[3];
|
||||
|
||||
if (c)
|
||||
{
|
||||
do
|
||||
{
|
||||
f = tolower(*a++);
|
||||
l = tolower(*b++);
|
||||
}
|
||||
while (--c &&l&&f&& f==l);
|
||||
return(f - l)?0:1;
|
||||
} while (--c && l && f && f == l);
|
||||
|
||||
return (f - l) ? 0 : 1;
|
||||
}
|
||||
do {
|
||||
|
||||
do
|
||||
{
|
||||
f = tolower(*a++);
|
||||
l = tolower(*b++);
|
||||
} while (f && f == l);
|
||||
return (f - l)?0:1;
|
||||
|
||||
return (f - l) ? 0 : 1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL format(AMX *amx, cell *params) /* 3 param */
|
||||
{
|
||||
int len;
|
||||
return set_amxstring(amx,params[1],format_amxstring(amx,params,3,len),params[2]);
|
||||
return set_amxstring(amx, params[1], format_amxstring(amx, params, 3, len), params[2]);
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL parse(AMX *amx, cell *params) /* 3 param */
|
||||
{
|
||||
int inum = *params/sizeof(cell), iarg = 2, c;
|
||||
char* arg, *parse = get_amxstring(amx,params[1],0,c);
|
||||
int inum = *params / sizeof(cell), iarg = 2, c;
|
||||
char* arg, *parse = get_amxstring(amx, params[1], 0, c);
|
||||
cell *cptr;
|
||||
int state;
|
||||
while(*parse){
|
||||
|
||||
while (*parse)
|
||||
{
|
||||
arg = parse_arg(&parse,state);
|
||||
if (state){
|
||||
|
||||
if (state)
|
||||
{
|
||||
if (inum <= iarg)
|
||||
return( (iarg-2)>>1 );
|
||||
cptr = get_amxaddr(amx,params[iarg++]);
|
||||
c = *get_amxaddr(amx,params[iarg++]);
|
||||
while(c--&&*arg)
|
||||
*cptr++=(cell)*arg++;
|
||||
*cptr=0;
|
||||
return ((iarg - 2)>>1);
|
||||
|
||||
cptr = get_amxaddr(amx, params[iarg++]);
|
||||
c = *get_amxaddr(amx, params[iarg++]);
|
||||
|
||||
while (c-- && *arg)
|
||||
*cptr++ = (cell)*arg++;
|
||||
*cptr = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return( (iarg-2)>>1 );
|
||||
return ((iarg - 2)>>1);
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL strtolower(AMX *amx, cell *params) /* 1 param */
|
||||
{
|
||||
cell *cptr = get_amxaddr(amx,params[1]);
|
||||
cell *cptr = get_amxaddr(amx, params[1]);
|
||||
cell *begin = cptr;
|
||||
while(*cptr){
|
||||
|
||||
while (*cptr)
|
||||
{
|
||||
*cptr = tolower(*cptr);
|
||||
cptr++;
|
||||
}
|
||||
|
||||
return cptr - begin;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL strtoupper(AMX *amx, cell *params) /* 1 param */
|
||||
{
|
||||
cell *cptr = get_amxaddr(amx,params[1]);
|
||||
cell *cptr = get_amxaddr(amx, params[1]);
|
||||
cell *begin = cptr;
|
||||
while(*cptr){
|
||||
|
||||
while (*cptr)
|
||||
{
|
||||
*cptr = toupper(*cptr);
|
||||
cptr++;
|
||||
}
|
||||
|
||||
return cptr - begin;
|
||||
}
|
||||
|
||||
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));
|
||||
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));
|
||||
}
|
||||
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
char* fo_getargstr(AMX *amx, int swap, int pos)
|
||||
{
|
||||
unsigned char *data =amx->base+(int)((AMX_HEADER *)amx->base)->dat;
|
||||
cell src_value= * (cell *)(data+(int)amx->frm+(pos+3)*sizeof(cell));
|
||||
unsigned char *data = amx->base + (int)((AMX_HEADER *)amx->base)->dat;
|
||||
cell src_value= *(cell *)(data + (int)amx->frm + (pos + 3) * sizeof(cell));
|
||||
cell value;
|
||||
static char buffer[2][3072];
|
||||
char* b = buffer[swap];
|
||||
int a = 0;
|
||||
do {
|
||||
|
||||
do
|
||||
{
|
||||
value = src_value + a++ * sizeof(cell);
|
||||
value = *(cell *)(data+(int)value);
|
||||
value = *(cell *)(data + (int)value);
|
||||
*b++ = static_cast<char>(value);
|
||||
} while (value);
|
||||
|
||||
return buffer[swap];
|
||||
}
|
||||
|
||||
char* format_arguments(AMX *amx, int parm,int& len)
|
||||
char* format_arguments(AMX *amx, int parm, int& len)
|
||||
{
|
||||
static char buffer[2][3072];
|
||||
static char format[16];
|
||||
char *ptr,*arg, *dest = *buffer;
|
||||
char *src = fo_getargstr(amx, 0,parm++);
|
||||
char *ptr, *arg, *dest = *buffer;
|
||||
char *src = fo_getargstr(amx, 0, parm++);
|
||||
int numparam = fo_numargs(amx);
|
||||
while(*src) {
|
||||
if (*src=='%'&&*(src+1)) {
|
||||
|
||||
while (*src)
|
||||
{
|
||||
if (*src == '%' && *(src + 1))
|
||||
{
|
||||
ptr = format;
|
||||
*ptr++ = *src++;
|
||||
if (*src=='%'){
|
||||
*dest++=*src++;
|
||||
|
||||
if (*src == '%')
|
||||
{
|
||||
*dest++ = *src++;
|
||||
continue;
|
||||
}
|
||||
while (!isalpha(*ptr++=*src++))
|
||||
;
|
||||
|
||||
while (!isalpha(*ptr++ = *src++));
|
||||
|
||||
*ptr='\0';
|
||||
if (numparam < parm) continue;
|
||||
arg = buffer[1];
|
||||
switch(*(ptr-1)){
|
||||
case 's': sprintf(arg,format,fo_getargstr(amx,1, parm++)); break;
|
||||
case 'f': case 'g': sprintf(arg,format,fo_getargfloat(amx, parm++)); break;
|
||||
default: sprintf(arg,format,fo_getargnum(amx, parm++));
|
||||
|
||||
switch (*(ptr - 1))
|
||||
{
|
||||
case 's': sprintf(arg, format, fo_getargstr(amx, 1, parm++)); break;
|
||||
case 'f': case 'g': sprintf(arg, format, fo_getargfloat(amx, parm++)); break;
|
||||
default: sprintf(arg, format, fo_getargnum(amx, parm++));
|
||||
}
|
||||
while(*arg) *dest++=*arg++;
|
||||
|
||||
while (*arg) *dest++ = *arg++;
|
||||
continue;
|
||||
}
|
||||
*dest++=*src++;
|
||||
*dest++ = *src++;
|
||||
}
|
||||
*dest='\0';
|
||||
|
||||
*dest = '\0';
|
||||
len = dest - *buffer;
|
||||
|
||||
return *buffer;
|
||||
}
|
||||
|
||||
@ -522,16 +608,17 @@ static cell AMX_NATIVE_CALL amx_strtok(AMX *amx, cell *params)
|
||||
//string[]
|
||||
char *string = get_amxstring(amx, params[1], 0, len);
|
||||
//left[]
|
||||
char *left = new char[len+1];
|
||||
char *left = new char[len + 1];
|
||||
//right[]
|
||||
char *right = new char[len+1];
|
||||
char *right = new char[len + 1];
|
||||
int leftMax = params[3];
|
||||
int rightMax = params[5];
|
||||
//token
|
||||
char token = static_cast<char>(params[6]);
|
||||
//trim
|
||||
int trim = params[7];
|
||||
for (i=0; i<(unsigned int)len; i++)
|
||||
|
||||
for (i = 0; i < (unsigned int)len; i++)
|
||||
{
|
||||
if (trim && !done_flag)
|
||||
{
|
||||
@ -541,11 +628,13 @@ static cell AMX_NATIVE_CALL amx_strtok(AMX *amx, cell *params)
|
||||
done_flag = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!done_flag && string[i] == token)
|
||||
{
|
||||
done_flag = true;
|
||||
i++;
|
||||
}
|
||||
|
||||
if (done_flag)
|
||||
{
|
||||
right[right_pos++] = string[i];
|
||||
@ -553,12 +642,14 @@ static cell AMX_NATIVE_CALL amx_strtok(AMX *amx, cell *params)
|
||||
left[left_pos++] = string[i];
|
||||
}
|
||||
}
|
||||
|
||||
right[right_pos] = 0;
|
||||
left[left_pos] = 0;
|
||||
set_amxstring(amx, params[2], left, leftMax);
|
||||
set_amxstring(amx, params[4], right, rightMax);
|
||||
delete [] left;
|
||||
delete [] right;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -571,46 +662,63 @@ static cell AMX_NATIVE_CALL strbreak(AMX *amx, cell *params) /* 5 param */
|
||||
bool done_flag = false;
|
||||
int left_pos = 0;
|
||||
int right_pos = 0;
|
||||
int l=0;
|
||||
unsigned int i=0;
|
||||
int l = 0;
|
||||
unsigned int i = 0;
|
||||
char hold = '"';
|
||||
|
||||
char *string = get_amxstring(amx, params[1], 0, l);
|
||||
char *left = new char[strlen(string)+1];
|
||||
char *right = new char[strlen(string)+1];
|
||||
char *left = new char[strlen(string) + 1];
|
||||
char *right = new char[strlen(string) + 1];
|
||||
int LeftMax = params[3];
|
||||
int RightMax = params[5];
|
||||
|
||||
for (i=0; i<(unsigned int)l; i++) {
|
||||
if (string[i] == '"' && !quote_flag) {
|
||||
for (i = 0; i < (unsigned int)l; i++)
|
||||
{
|
||||
if (string[i] == '"' && !quote_flag)
|
||||
{
|
||||
quote_flag = true;
|
||||
} else if (string[i] == '"' && quote_flag) {
|
||||
}
|
||||
else if (string[i] == '"' && quote_flag)
|
||||
{
|
||||
quote_flag = false;
|
||||
}
|
||||
if (isspace(string[i]) && !quote_flag && !done_flag) {
|
||||
|
||||
if (isspace(string[i]) && !quote_flag && !done_flag)
|
||||
{
|
||||
done_flag = true;
|
||||
i++;
|
||||
}
|
||||
if (!done_flag && string[i]!='"') {
|
||||
if (left_pos < LeftMax) {
|
||||
|
||||
if (!done_flag && string[i]!='"')
|
||||
{
|
||||
if (left_pos < LeftMax)
|
||||
{
|
||||
left[left_pos] = string[i];
|
||||
if (left[left_pos] == '\'') {
|
||||
|
||||
if (left[left_pos] == '\'')
|
||||
{
|
||||
left[left_pos] = hold;
|
||||
}
|
||||
|
||||
left_pos++;
|
||||
} else {
|
||||
done_flag = true;
|
||||
}
|
||||
} else {
|
||||
if (right_pos < RightMax && string[i]!='"') {
|
||||
if (right_pos < RightMax && string[i]!='"')
|
||||
{
|
||||
right[right_pos] = string[i];
|
||||
if (right[right_pos] == '\'') {
|
||||
|
||||
if (right[right_pos] == '\'')
|
||||
{
|
||||
right[right_pos] = hold;
|
||||
}
|
||||
|
||||
right_pos++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
left[left_pos] = '\0';
|
||||
right[right_pos] = '\0';
|
||||
set_amxstring(amx, params[2], left, params[3]);
|
||||
@ -625,41 +733,46 @@ static cell AMX_NATIVE_CALL format_args(AMX *amx, cell *params)
|
||||
{
|
||||
int len;
|
||||
int pos = params[3];
|
||||
if (pos < 0){
|
||||
amx_RaiseError(amx,AMX_ERR_NATIVE);
|
||||
|
||||
if (pos < 0)
|
||||
{
|
||||
amx_RaiseError(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
char* string = format_arguments(amx, pos ,len); // indexed from 0
|
||||
return set_amxstring(amx,params[1],string,params[2]);
|
||||
|
||||
char* string = format_arguments(amx, pos, len); // indexed from 0
|
||||
return set_amxstring(amx, params[1], string, params[2]);
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL is_digit(AMX *amx, cell *params)
|
||||
{
|
||||
return isdigit( params[1] );
|
||||
return isdigit(params[1]);
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL is_alnum(AMX *amx, cell *params)
|
||||
{
|
||||
return isalnum( params[1] );
|
||||
return isalnum(params[1]);
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL is_space(AMX *amx, cell *params)
|
||||
{
|
||||
return isspace( params[1] );
|
||||
return isspace(params[1]);
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL is_alpha(AMX *amx, cell *params)
|
||||
{
|
||||
return isalpha( params[1] );
|
||||
return isalpha(params[1]);
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL amx_ucfirst(AMX *amx, cell *params)
|
||||
{
|
||||
int len = 0;
|
||||
cell *str = get_amxaddr(amx, params[1]);
|
||||
if (!isalpha((char)str[0]) || !(str[0]&(1<<5)))
|
||||
|
||||
if (!isalpha((char)str[0]) || !(str[0] & (1<<5)))
|
||||
return 0;
|
||||
str[0] &= ~(1<<5);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -679,7 +792,8 @@ static cell AMX_NATIVE_CALL amx_trim(AMX *amx, cell *params)
|
||||
while (*cptr++) len++;
|
||||
int flag = 0, incr = 0;
|
||||
register int i = 0;
|
||||
for (i=len-1; i>=0; i--)
|
||||
|
||||
for (i = len - 1; i >= 0; i--)
|
||||
{
|
||||
if (!isspace(asdf[i]))
|
||||
{
|
||||
@ -690,13 +804,13 @@ static cell AMX_NATIVE_CALL amx_trim(AMX *amx, cell *params)
|
||||
}
|
||||
}
|
||||
|
||||
for (i=0; i<len; i++)
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
if (isspace(asdf[i]) && !flag)
|
||||
{
|
||||
incr++;
|
||||
if (incr+i<len)
|
||||
asdf[i] = asdf[incr+i];
|
||||
if (incr + i < len)
|
||||
asdf[i] = asdf[incr + i];
|
||||
} else {
|
||||
if (!flag)
|
||||
flag = 1;
|
||||
@ -709,20 +823,23 @@ static cell AMX_NATIVE_CALL amx_trim(AMX *amx, cell *params)
|
||||
return incr;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL n_strcat(AMX *amx,cell *params)
|
||||
static cell AMX_NATIVE_CALL n_strcat(AMX *amx, cell *params)
|
||||
{
|
||||
cell *cdest,*csrc;
|
||||
cell *cdest, *csrc;
|
||||
|
||||
cdest = get_amxaddr(amx, params[1]);
|
||||
csrc = get_amxaddr(amx, params[2]);
|
||||
int num = params[3];
|
||||
|
||||
while (*cdest && num)
|
||||
{
|
||||
cdest++;
|
||||
num--;
|
||||
}
|
||||
|
||||
if (!num)
|
||||
return 0;
|
||||
|
||||
while (*csrc && num)
|
||||
{
|
||||
*cdest++ = *csrc++;
|
||||
@ -754,22 +871,25 @@ static cell AMX_NATIVE_CALL n_strfind(AMX *amx, cell *params)
|
||||
|
||||
bool found = false;
|
||||
bool igcase = params[3] ? true : false;
|
||||
|
||||
if (igcase)
|
||||
{
|
||||
for (int i=0; i<len; i++)
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
if (str[i] & (1<<5))
|
||||
str[i] &= ~(1<<5);
|
||||
}
|
||||
for (int i=0; i<sublen; i++)
|
||||
for (int i = 0; i < sublen; i++)
|
||||
{
|
||||
if (str[i] & (1<<5))
|
||||
str[i] &= ~(1<<5);
|
||||
}
|
||||
}
|
||||
|
||||
if (params[4] > len)
|
||||
return -1;
|
||||
char *pos = &(str[ params[4] ]);
|
||||
|
||||
char *pos = &(str[params[4]]);
|
||||
char *find = strstr(str, sub);
|
||||
|
||||
if (!find)
|
||||
@ -778,39 +898,39 @@ static cell AMX_NATIVE_CALL n_strfind(AMX *amx, cell *params)
|
||||
return (find - str);
|
||||
}
|
||||
|
||||
AMX_NATIVE_INFO string_Natives[] = {
|
||||
{ "add", add },
|
||||
{ "contain", contain },
|
||||
{ "containi", containi },
|
||||
{ "copy", copy },
|
||||
{ "copyc", copyc },
|
||||
{ "equal", equal },
|
||||
{ "equali", equali },
|
||||
{ "format", format },
|
||||
{ "format_args", format_args },
|
||||
{ "isdigit", is_digit },
|
||||
{ "isalnum", is_alnum },
|
||||
{ "isspace", is_space },
|
||||
{ "isalpha", is_alpha },
|
||||
{ "num_to_str", numtostr },
|
||||
{ "numtostr", numtostr },
|
||||
{ "parse", parse },
|
||||
{ "replace", replace },
|
||||
{ "setc", setc },
|
||||
{ "strbreak", strbreak},
|
||||
{ "strtolower", strtolower },
|
||||
{ "strtoupper", strtoupper },
|
||||
{ "str_to_num", strtonum },
|
||||
{ "strtonum", strtonum },
|
||||
{ "trim", amx_trim },
|
||||
{ "ucfirst", amx_ucfirst },
|
||||
{ "strtok", amx_strtok },
|
||||
{ "strlen", amx_strlen },
|
||||
{ "strcat", n_strcat },
|
||||
{ "strfind", n_strfind },
|
||||
{ "strcmp", n_strcmp },
|
||||
{ "str_to_float", str_to_float },
|
||||
{ "float_to_str", float_to_str },
|
||||
|
||||
{ NULL, NULL }
|
||||
AMX_NATIVE_INFO string_Natives[] =
|
||||
{
|
||||
{"add", add},
|
||||
{"contain", contain},
|
||||
{"containi", containi},
|
||||
{"copy", copy},
|
||||
{"copyc", copyc},
|
||||
{"equal", equal},
|
||||
{"equali", equali},
|
||||
{"format", format},
|
||||
{"format_args", format_args},
|
||||
{"isdigit", is_digit},
|
||||
{"isalnum", is_alnum},
|
||||
{"isspace", is_space},
|
||||
{"isalpha", is_alpha},
|
||||
{"num_to_str", numtostr},
|
||||
{"numtostr", numtostr},
|
||||
{"parse", parse},
|
||||
{"replace", replace},
|
||||
{"setc", setc},
|
||||
{"strbreak", strbreak},
|
||||
{"strtolower", strtolower},
|
||||
{"strtoupper", strtoupper},
|
||||
{"str_to_num", strtonum},
|
||||
{"strtonum", strtonum},
|
||||
{"trim", amx_trim},
|
||||
{"ucfirst", amx_ucfirst},
|
||||
{"strtok", amx_strtok},
|
||||
{"strlen", amx_strlen},
|
||||
{"strcat", n_strcat},
|
||||
{"strfind", n_strfind},
|
||||
{"strcmp", n_strcmp},
|
||||
{"str_to_float", str_to_float},
|
||||
{"float_to_str", float_to_str},
|
||||
{NULL, NULL }
|
||||
};
|
||||
|
173
amxmodx/util.cpp
173
amxmodx/util.cpp
@ -30,11 +30,10 @@
|
||||
*/
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include "amxmodx.h"
|
||||
|
||||
#ifdef __linux__
|
||||
#define _vsnprintf vsnprintf
|
||||
#define _vsnprintf vsnprintf
|
||||
#endif
|
||||
|
||||
char *UTIL_VarArgs(const char *fmt, ...)
|
||||
@ -52,40 +51,47 @@ char *UTIL_VarArgs(const char *fmt, ...)
|
||||
int UTIL_ReadFlags(const char* c)
|
||||
{
|
||||
int flags = 0;
|
||||
while (*c) flags |= ( 1 << ( *c++ - 'a' ) );
|
||||
|
||||
while (*c)
|
||||
flags |= (1<<(*c++ - 'a'));
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
void UTIL_GetFlags(char* f,int a)
|
||||
void UTIL_GetFlags(char* f, int a)
|
||||
{
|
||||
for(int i='a';i<='z';++i){
|
||||
if ( a & 1 ) *f++ = i;
|
||||
for (int i = 'a'; i <= 'z'; ++i)
|
||||
{
|
||||
if (a & 1) *f++ = i;
|
||||
a >>= 1;
|
||||
}
|
||||
|
||||
*f = 0;
|
||||
}
|
||||
|
||||
/* warning - don't pass here const string */
|
||||
void UTIL_ShowMenu( edict_t* pEdict, int slots, int time, char *menu, int mlen )
|
||||
void UTIL_ShowMenu(edict_t* pEdict, int slots, int time, char *menu, int mlen)
|
||||
{
|
||||
char *n = menu;
|
||||
char c = 0;
|
||||
int a;
|
||||
|
||||
if (!gmsgShowMenu)
|
||||
return; // some games don't support ShowMenu (Firearms)
|
||||
return; // some games don't support ShowMenu (Firearms)
|
||||
|
||||
while ( *n ) {
|
||||
while (*n)
|
||||
{
|
||||
a = mlen;
|
||||
if ( a > 175 ) a = 175;
|
||||
if (a > 175) a = 175;
|
||||
mlen -= a;
|
||||
c = *(n+=a);
|
||||
*n = 0;
|
||||
MESSAGE_BEGIN( MSG_ONE , gmsgShowMenu, NULL, pEdict );
|
||||
WRITE_SHORT( slots );
|
||||
WRITE_CHAR( time );
|
||||
WRITE_BYTE( c ? TRUE : FALSE);
|
||||
WRITE_STRING( menu );
|
||||
|
||||
MESSAGE_BEGIN(MSG_ONE, gmsgShowMenu, NULL, pEdict);
|
||||
WRITE_SHORT(slots);
|
||||
WRITE_CHAR(time);
|
||||
WRITE_BYTE(c ? TRUE : FALSE);
|
||||
WRITE_STRING(menu);
|
||||
MESSAGE_END();
|
||||
*n = c;
|
||||
menu = n;
|
||||
@ -93,14 +99,14 @@ void UTIL_ShowMenu( edict_t* pEdict, int slots, int time, char *menu, int mlen )
|
||||
}
|
||||
|
||||
/* warning - don't pass here const string */
|
||||
void UTIL_ShowMOTD( edict_t *client , char *motd, int mlen, const char *name)
|
||||
void UTIL_ShowMOTD(edict_t *client, char *motd, int mlen, const char *name)
|
||||
{
|
||||
if (!gmsgMOTD)
|
||||
return; // :TODO: Maybe output a warning log?
|
||||
|
||||
if (gmsgServerName)
|
||||
{
|
||||
MESSAGE_BEGIN( MSG_ONE , gmsgServerName, NULL, client );
|
||||
MESSAGE_BEGIN(MSG_ONE, gmsgServerName, NULL, client);
|
||||
WRITE_STRING(name);
|
||||
MESSAGE_END();
|
||||
}
|
||||
@ -109,15 +115,17 @@ void UTIL_ShowMOTD( edict_t *client , char *motd, int mlen, const char *name)
|
||||
char c = 0;
|
||||
int a;
|
||||
|
||||
while ( *n ) {
|
||||
while (*n)
|
||||
{
|
||||
a = mlen;
|
||||
if ( a > 175 ) a = 175;
|
||||
if (a > 175) a = 175;
|
||||
mlen -= a;
|
||||
c = *(n+=a);
|
||||
c = *(n += a);
|
||||
*n = 0;
|
||||
MESSAGE_BEGIN( MSG_ONE , gmsgMOTD, NULL, client );
|
||||
WRITE_BYTE( c ? FALSE : TRUE );
|
||||
WRITE_STRING( motd );
|
||||
|
||||
MESSAGE_BEGIN(MSG_ONE, gmsgMOTD, NULL, client);
|
||||
WRITE_BYTE(c ? FALSE : TRUE);
|
||||
WRITE_STRING(motd);
|
||||
MESSAGE_END();
|
||||
*n = c;
|
||||
motd = n;
|
||||
@ -125,42 +133,52 @@ void UTIL_ShowMOTD( edict_t *client , char *motd, int mlen, const char *name)
|
||||
|
||||
if (gmsgServerName)
|
||||
{
|
||||
MESSAGE_BEGIN( MSG_ONE , gmsgServerName, NULL, client );
|
||||
WRITE_STRING( hostname->string );
|
||||
MESSAGE_BEGIN(MSG_ONE, gmsgServerName, NULL, client);
|
||||
WRITE_STRING(hostname->string);
|
||||
MESSAGE_END();
|
||||
}
|
||||
}
|
||||
|
||||
void UTIL_IntToString(int value, char *output)
|
||||
{
|
||||
static const char *words[] = {"zero ","one ","two ","three ","four ",
|
||||
static const char *words[] =
|
||||
{"zero ","one ","two ","three ","four ",
|
||||
"five ", "six ","seven ","eight ","nine ","ten ",
|
||||
"eleven ","twelve ","thirteen ","fourteen ","fifteen ",
|
||||
"sixteen ","seventeen ","eighteen ","nineteen ",
|
||||
"twenty ","thirty ","fourty ", "fifty ","sixty ",
|
||||
"seventy ","eighty ","ninety ",
|
||||
"hundred ","thousand "};
|
||||
|
||||
*output = 0;
|
||||
if (value < 0) value = -value;
|
||||
int tho = value / 1000;
|
||||
int aaa = 0;
|
||||
if (tho){
|
||||
aaa += sprintf(&output[aaa], words[ tho ] );
|
||||
aaa += sprintf(&output[aaa], words[29] );
|
||||
|
||||
if (tho)
|
||||
{
|
||||
aaa += sprintf(&output[aaa], words[tho]);
|
||||
aaa += sprintf(&output[aaa], words[29]);
|
||||
value = value % 1000;
|
||||
}
|
||||
|
||||
int hun = value / 100;
|
||||
if (hun) {
|
||||
aaa += sprintf(&output[aaa], words[ hun ] );
|
||||
aaa += sprintf(&output[aaa], words[28] );
|
||||
|
||||
if (hun)
|
||||
{
|
||||
aaa += sprintf(&output[aaa], words[hun]);
|
||||
aaa += sprintf(&output[aaa], words[28]);
|
||||
value = value % 100;
|
||||
}
|
||||
|
||||
int ten = value / 10;
|
||||
int unit = value % 10;
|
||||
if ( ten )
|
||||
aaa += sprintf(&output[aaa], words[ ( ten > 1 ) ? ( ten + 18 ) : ( unit + 10 ) ] );
|
||||
if ( ten != 1 && ( unit || (!value && !hun && !tho) ) )
|
||||
sprintf(&output[aaa], words[ unit ] );
|
||||
|
||||
if (ten)
|
||||
aaa += sprintf(&output[aaa], words[(ten > 1) ? (ten + 18) : (unit + 10)]);
|
||||
|
||||
if (ten != 1 && (unit || (!value && !hun && !tho)))
|
||||
sprintf(&output[aaa], words[unit]);
|
||||
}
|
||||
|
||||
char* UTIL_SplitHudMessage(const char *src)
|
||||
@ -168,50 +186,57 @@ char* UTIL_SplitHudMessage(const char *src)
|
||||
static char message[512];
|
||||
short b = 0, d = 0, e = 0, c = -1;
|
||||
|
||||
while ( src[ d ] && e < 480 ) {
|
||||
if ( src[ d ] == ' ' ) {
|
||||
while (src[d] && e < 480)
|
||||
{
|
||||
if (src[d] == ' ')
|
||||
{
|
||||
c = e;
|
||||
}
|
||||
else if ( src[ d ] == '\n' ) {
|
||||
else if (src[d] == '\n')
|
||||
{
|
||||
c = -1;
|
||||
b = 0;
|
||||
}
|
||||
message[ e++ ] = src[ d++ ];
|
||||
if ( ++b == 69 ) {
|
||||
if ( c == -1 ) {
|
||||
message[ e++ ] = '\n';
|
||||
|
||||
message[e++] = src[d++];
|
||||
|
||||
if (++b == 69)
|
||||
{
|
||||
if (c == -1)
|
||||
{
|
||||
message[e++] = '\n';
|
||||
b = 0;
|
||||
}
|
||||
else {
|
||||
message[ c ] = '\n';
|
||||
} else {
|
||||
message[c] = '\n';
|
||||
b = e - c - 1;
|
||||
c = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
message[ e ] = 0;
|
||||
|
||||
message[e] = 0;
|
||||
return message;
|
||||
}
|
||||
|
||||
unsigned short FixedUnsigned16( float value, float scale )
|
||||
unsigned short FixedUnsigned16(float value, float scale)
|
||||
{
|
||||
int output = (int)(value * scale);
|
||||
|
||||
if ( output < 0 )
|
||||
if (output < 0)
|
||||
output = 0;
|
||||
else if ( output > 0xFFFF )
|
||||
else if (output > 0xFFFF)
|
||||
output = 0xFFFF;
|
||||
|
||||
return (unsigned short)output;
|
||||
}
|
||||
|
||||
short FixedSigned16( float value, float scale )
|
||||
short FixedSigned16(float value, float scale)
|
||||
{
|
||||
int output = (int)(value * scale);
|
||||
|
||||
if ( output > 32767 )
|
||||
if (output > 32767)
|
||||
output = 32767;
|
||||
else if ( output < -32768 )
|
||||
else if (output < -32768)
|
||||
output = -32768;
|
||||
|
||||
return (short)output;
|
||||
@ -219,15 +244,15 @@ short FixedSigned16( float value, float scale )
|
||||
|
||||
void UTIL_HudMessage(edict_t *pEntity, const hudtextparms_t &textparms, char *pMessage)
|
||||
{
|
||||
if ( pEntity )
|
||||
MESSAGE_BEGIN( MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, NULL, pEntity );
|
||||
if (pEntity)
|
||||
MESSAGE_BEGIN(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, NULL, pEntity);
|
||||
else
|
||||
MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
|
||||
MESSAGE_BEGIN(MSG_BROADCAST, SVC_TEMPENTITY);
|
||||
|
||||
WRITE_BYTE(29);
|
||||
WRITE_BYTE(textparms.channel & 0xFF);
|
||||
WRITE_SHORT(FixedSigned16(textparms.x, (1<<13) ));
|
||||
WRITE_SHORT(FixedSigned16(textparms.y, (1<<13) ));
|
||||
WRITE_SHORT(FixedSigned16(textparms.x, (1<<13)));
|
||||
WRITE_SHORT(FixedSigned16(textparms.y, (1<<13)));
|
||||
WRITE_BYTE(textparms.effect);
|
||||
WRITE_BYTE(textparms.r1);
|
||||
WRITE_BYTE(textparms.g1);
|
||||
@ -237,30 +262,34 @@ void UTIL_HudMessage(edict_t *pEntity, const hudtextparms_t &textparms, char *pM
|
||||
WRITE_BYTE(255);
|
||||
WRITE_BYTE(250);
|
||||
WRITE_BYTE(0);
|
||||
WRITE_SHORT(FixedUnsigned16(textparms.fadeinTime, (1<<8) ));
|
||||
WRITE_SHORT(FixedUnsigned16(textparms.fadeoutTime, (1<<8) ));
|
||||
WRITE_SHORT(FixedUnsigned16(textparms.holdTime, (1<<8) ));
|
||||
if (textparms.effect==2)
|
||||
WRITE_SHORT(FixedUnsigned16(textparms.fxTime, (1<<8) ) );
|
||||
WRITE_SHORT(FixedUnsigned16(textparms.fadeinTime, (1<<8)));
|
||||
WRITE_SHORT(FixedUnsigned16(textparms.fadeoutTime, (1<<8)));
|
||||
WRITE_SHORT(FixedUnsigned16(textparms.holdTime, (1<<8)));
|
||||
|
||||
if (textparms.effect == 2)
|
||||
WRITE_SHORT(FixedUnsigned16(textparms.fxTime, (1<<8)));
|
||||
|
||||
WRITE_STRING(pMessage);
|
||||
MESSAGE_END();
|
||||
}
|
||||
|
||||
/* warning - buffer of msg must be longer than 190 chars!
|
||||
(here in AMX it is always longer) */
|
||||
void UTIL_ClientPrint( edict_t *pEntity, int msg_dest, char *msg )
|
||||
void UTIL_ClientPrint(edict_t *pEntity, int msg_dest, char *msg)
|
||||
{
|
||||
if (!gmsgTextMsg)
|
||||
return; // :TODO: Maybe output a warning log?
|
||||
|
||||
char c = msg[190];
|
||||
msg[190] = 0; // truncate without checking with strlen()
|
||||
if ( pEntity )
|
||||
MESSAGE_BEGIN( MSG_ONE, gmsgTextMsg, NULL, pEntity );
|
||||
msg[190] = 0; // truncate without checking with strlen()
|
||||
|
||||
if (pEntity)
|
||||
MESSAGE_BEGIN(MSG_ONE, gmsgTextMsg, NULL, pEntity);
|
||||
else
|
||||
MESSAGE_BEGIN( MSG_BROADCAST , gmsgTextMsg);
|
||||
WRITE_BYTE( msg_dest );
|
||||
WRITE_STRING( msg );
|
||||
MESSAGE_BEGIN(MSG_BROADCAST, gmsgTextMsg);
|
||||
|
||||
WRITE_BYTE(msg_dest);
|
||||
WRITE_STRING(msg);
|
||||
MESSAGE_END();
|
||||
msg[190] = c;
|
||||
}
|
||||
@ -275,7 +304,7 @@ void UTIL_ClientPrint( edict_t *pEntity, int msg_dest, char *msg )
|
||||
void UTIL_FakeClientCommand(edict_t *pEdict, const char *cmd, const char *arg1, const char *arg2)
|
||||
{
|
||||
if (!cmd)
|
||||
return; // no command
|
||||
return; // no command
|
||||
|
||||
// store command
|
||||
g_fakecmd.argv[0] = cmd;
|
||||
@ -304,7 +333,7 @@ void UTIL_FakeClientCommand(edict_t *pEdict, const char *cmd, const char *arg1,
|
||||
// store argument
|
||||
g_fakecmd.argv[1] = arg1;
|
||||
// build argument line
|
||||
snprintf( g_fakecmd.args, 255, "%s", arg1);
|
||||
snprintf(g_fakecmd.args, 255, "%s", arg1);
|
||||
// if snprintf reached 255 chars limit, this will make sure there will be no access violation
|
||||
g_fakecmd.args[255] = 0;
|
||||
}
|
||||
|
@ -34,52 +34,49 @@
|
||||
|
||||
Vault g_vault;
|
||||
|
||||
static cell AMX_NATIVE_CALL set_vaultdata(AMX *amx,cell *params)
|
||||
static cell AMX_NATIVE_CALL set_vaultdata(AMX *amx, cell *params)
|
||||
{
|
||||
int iLen;
|
||||
int iLen;
|
||||
|
||||
g_vault.put( get_amxstring(amx,params[1],0,iLen) , get_amxstring(amx,params[2],1,iLen) );
|
||||
g_vault.saveVault();
|
||||
g_vault.put(get_amxstring(amx, params[1], 0, iLen), get_amxstring(amx, params[2], 1, iLen));
|
||||
g_vault.saveVault();
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_vaultdata(AMX *amx,cell *params)
|
||||
static cell AMX_NATIVE_CALL get_vaultdata(AMX *amx, cell *params)
|
||||
{
|
||||
int iLen;
|
||||
int iLen;
|
||||
const char* key = get_amxstring(amx, params[1], 0, iLen);
|
||||
|
||||
const char* key = get_amxstring(amx,params[1],0,iLen);
|
||||
if (params[3])
|
||||
return set_amxstring(amx, params[2], g_vault.get(key), params[3]);
|
||||
|
||||
if ( params[3] )
|
||||
return set_amxstring( amx , params[2] , g_vault.get( key ) , params[3] );
|
||||
|
||||
return g_vault.get_number( key );
|
||||
return g_vault.get_number(key);
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL remove_vaultdata(AMX *amx,cell *params)
|
||||
static cell AMX_NATIVE_CALL remove_vaultdata(AMX *amx, cell *params)
|
||||
{
|
||||
int iLen;
|
||||
int iLen;
|
||||
|
||||
g_vault.remove( get_amxstring(amx,params[1],0,iLen) );
|
||||
g_vault.saveVault();
|
||||
g_vault.remove(get_amxstring(amx, params[1], 0, iLen));
|
||||
g_vault.saveVault();
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL vaultdata_exists(AMX *amx,cell *params)
|
||||
static cell AMX_NATIVE_CALL vaultdata_exists(AMX *amx, cell *params)
|
||||
{
|
||||
int iLen;
|
||||
|
||||
return g_vault.exists( get_amxstring(amx,params[1],0,iLen) ) ? 1 : 0;
|
||||
int iLen;
|
||||
return g_vault.exists(get_amxstring(amx, params[1], 0, iLen)) ? 1 : 0;
|
||||
}
|
||||
|
||||
AMX_NATIVE_INFO vault_Natives[] = {
|
||||
{ "set_vaultdata", set_vaultdata },
|
||||
{ "get_vaultdata", get_vaultdata },
|
||||
{ "remove_vaultdata", remove_vaultdata },
|
||||
{ "delete_vaultdata", remove_vaultdata },
|
||||
{ "vaultdata_exists", vaultdata_exists },
|
||||
{ 0, 0 }
|
||||
AMX_NATIVE_INFO vault_Natives[] =
|
||||
{
|
||||
{"set_vaultdata", set_vaultdata},
|
||||
{"get_vaultdata", get_vaultdata},
|
||||
{"remove_vaultdata", remove_vaultdata},
|
||||
{"delete_vaultdata", remove_vaultdata},
|
||||
{"vaultdata_exists", vaultdata_exists},
|
||||
{0, 0}
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user