more cleaned-up code

This commit is contained in:
Borja Ferrer 2005-09-10 20:09:14 +00:00
parent 612a86dbef
commit 76760b221d
20 changed files with 1537 additions and 1155 deletions

View File

@ -111,8 +111,7 @@ CmdMngr::Command* CmdMngr::getCmd(long int id, int type, int access)
while (buf_cmdptr) while (buf_cmdptr)
{ {
if ((*buf_cmdptr).gotAccess(access) && (*buf_cmdptr).getPlugin()->isExecutable((*buf_cmdptr).getFunction()) if ((*buf_cmdptr).gotAccess(access) && (*buf_cmdptr).getPlugin()->isExecutable((*buf_cmdptr).getFunction()) && (*buf_cmdptr).isViewable())
&& (*buf_cmdptr).isViewable())
{ {
if (id-- == 0) if (id-- == 0)
return &(*buf_cmdptr); return &(*buf_cmdptr);
@ -154,7 +153,7 @@ void CmdMngr::setCmdLink(CmdLink** a, Command* c, bool sorted)
{ {
while (*a) 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)) if ((i < 0) || (i == 0) && (strcmp(c->getArgument(), (*a)->cmd->getArgument()) < 0))
break; break;
@ -184,7 +183,7 @@ void CmdMngr::clearCmdLink(CmdLink** phead, bool pclear)
void CmdMngr::Command::setCmdType(int a) void CmdMngr::Command::setCmdType(int a)
{ {
switch(a) switch (a)
{ {
case CMD_ConsoleCommand: cmdtype |= 3; break; case CMD_ConsoleCommand: cmdtype |= 3; break;
case CMD_ClientCommand: cmdtype |= 1; break; case CMD_ClientCommand: cmdtype |= 1; break;
@ -207,7 +206,7 @@ void CmdMngr::Command::setCmdType(int a)
const char* CmdMngr::Command::getCmdType() const const char* CmdMngr::Command::getCmdType() const
{ {
switch(cmdtype) switch (cmdtype)
{ {
case 1: return "client"; case 1: return "client";
case 2: return "server"; case 2: return "server";

View File

@ -299,7 +299,7 @@ void EventsMngr::parseValue(int iValue)
if (condIter->paramId == m_ParsePos) if (condIter->paramId == m_ParsePos)
{ {
anyConditions = true; anyConditions = true;
switch(condIter->type) switch (condIter->type)
{ {
case '=': if (condIter->iValue == iValue) execute = true; break; case '=': if (condIter->iValue == iValue) execute = true; break;
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) if (condIter->paramId == m_ParsePos)
{ {
anyConditions = true; anyConditions = true;
switch(condIter->type) switch (condIter->type)
{ {
case '=': if (condIter->fValue == fValue) execute = true; break; case '=': if (condIter->fValue == fValue) execute = true; break;
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) if (condIter->paramId == m_ParsePos)
{ {
anyConditions = true; 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;
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]; static char var[32];
switch(m_ParseVault[a].type) switch (m_ParseVault[a].type)
{ {
case MSG_INTEGER: case MSG_INTEGER:
sprintf(var, "%d", m_ParseVault[a].iValue); sprintf(var, "%d", m_ParseVault[a].iValue);
@ -458,7 +458,7 @@ int EventsMngr::getArgInteger(int a) const
if (a < 0 || a > m_ParsePos) if (a < 0 || a > m_ParsePos)
return 0; return 0;
switch(m_ParseVault[a].type) switch (m_ParseVault[a].type)
{ {
case MSG_INTEGER: case MSG_INTEGER:
return m_ParseVault[a].iValue; return m_ParseVault[a].iValue;
@ -474,7 +474,7 @@ float EventsMngr::getArgFloat(int a) const
if (a < 0 || a > m_ParsePos) if (a < 0 || a > m_ParsePos)
return 0.0f; return 0.0f;
switch(m_ParseVault[a].type) switch (m_ParseVault[a].type)
{ {
case MSG_INTEGER: case MSG_INTEGER:
return static_cast<float>(m_ParseVault[a].iValue); return static_cast<float>(m_ParseVault[a].iValue);

View File

@ -556,10 +556,12 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
} else { } else {
cpLangName = ENTITY_KEYVALUE(GET_PLAYER_POINTER_I(m_CurGlobId)->pEdict, "lang"); 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"); 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) 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++]); cell *tmpCell = get_amxaddr(amx, params[parm++]);
while (tmpPtr-tmpString < sizeof(tmpString) && *tmpCell) while (tmpPtr-tmpString < sizeof(tmpString) && *tmpCell)
*tmpPtr++ = static_cast<char>(*tmpCell++); *tmpPtr++ = static_cast<char>(*tmpCell++);
*tmpPtr = 0; *tmpPtr = 0;
_snprintf(outptr, sizeof(outbuf)-(outptr-outbuf)-1, format, tmpString); _snprintf(outptr, sizeof(outbuf)-(outptr-outbuf)-1, format, tmpString);
ZEROTERM(outbuf); ZEROTERM(outbuf);
@ -815,10 +816,12 @@ char *CLangMngr::FormatString(const char *fmt, va_list &ap)
} else { } else {
cpLangName = ENTITY_KEYVALUE(GET_PLAYER_POINTER_I(m_CurGlobId)->pEdict, "lang"); 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"); 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")) if ((int)CVAR_GET_FLOAT("amx_client_languages"))
{ {
@ -1126,6 +1129,7 @@ int CLangMngr::MergeDefinitionFile(const char *file)
} // if !multiline } // if !multiline
} //if - main } //if - main
} }
// merge last section // merge last section
if (!Defq.empty()) if (!Defq.empty())
{ {
@ -1170,6 +1174,7 @@ const char *CLangMngr::GetDef(const char *langName, const char *key)
CLang *lang = GetLangR(langName); CLang *lang = GetLangR(langName);
if (lang) if (lang)
return lang->GetDef(key); return lang->GetDef(key);
return "ML_NOTFOUND(LANG)"; return "ML_NOTFOUND(LANG)";
} }

View File

@ -292,7 +292,7 @@ public:
iterator find(iterator startOn, const F &desc) iterator find(iterator startOn, const F &desc)
{ {
iterator iter = startOn; iterator iter = startOn;
while(iter) while (iter)
{ {
if (*iter == desc) if (*iter == desc)
break; break;

View File

@ -46,7 +46,7 @@ LogEventsMngr::LogEventsMngr()
LogEventsMngr::~LogEventsMngr() LogEventsMngr::~LogEventsMngr()
{ {
clearLogEvents(); clearLogEvents();
} }
int LogEventsMngr::CLogCmp::compareCondition(const char* string) int LogEventsMngr::CLogCmp::compareCondition(const char* string)

View File

@ -112,7 +112,7 @@ public:
LogCond *filters; LogCond *filters;
LogEventsMngr* parent; LogEventsMngr* parent;
CLogEvent *next; CLogEvent *next;
CLogEvent(CPluginMngr::CPlugin *p,int f, LogEventsMngr* ppp) : plugin(p), func(f), filters(0), parent(ppp), next(0) { } CLogEvent(CPluginMngr::CPlugin *p, int f, LogEventsMngr* ppp) : plugin(p), func(f), filters(0), parent(ppp), next(0) { }
~CLogEvent(); ~CLogEvent();
public: public:
inline CPluginMngr::CPlugin *getPlugin() { return plugin; } inline CPluginMngr::CPlugin *getPlugin() { return plugin; }
@ -121,7 +121,7 @@ public:
}; };
private: private:
CLogEvent *logevents[MAX_LOGARGS+1]; CLogEvent *logevents[MAX_LOGARGS + 1];
CLogEvent *getValidLogEvent(CLogEvent * a); CLogEvent *getValidLogEvent(CLogEvent * a);
CLogCmp* registerCondition(char* filter); CLogCmp* registerCondition(char* filter);
void clearConditions(); void clearConditions();

View File

@ -35,7 +35,8 @@
// ***************************************************** // *****************************************************
// class MenuMngr // 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; plugin = a;
keys = k; keys = k;
menuid = mi; menuid = mi;
@ -50,45 +51,49 @@ MenuMngr::~MenuMngr()
int MenuMngr::findMenuId(const char* name, AMX* amx) int MenuMngr::findMenuId(const char* name, AMX* amx)
{ {
for( MenuIdEle* b = headid; b ; b = b->next) { for (MenuIdEle* b = headid; b; b = b->next)
if ( (!amx || !b->amx || amx == b->amx) && strstr(name,b->name.c_str()) ) {
return b->id; if ((!amx || !b->amx || amx == b->amx) && strstr(name,b->name.c_str()))
} return b->id;
return 0; }
return 0;
} }
int MenuMngr::registerMenuId(const char* n, AMX* a ) int MenuMngr::registerMenuId(const char* n, AMX* a)
{ {
int id = findMenuId( n, a ); int id = findMenuId(n, a);
if (id) return id; if (id) return id;
headid = new MenuIdEle( n, a , headid ); headid = new MenuIdEle(n, a, headid);
if (!headid)
return 0; // :TODO: Better error report if (!headid)
return headid->id; 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; MenuCommand** temp = &headcmd;
while(*temp) temp = &(*temp)->next; while (*temp) temp = &(*temp)->next;
*temp = new MenuCommand(a,mi, k,f); *temp = new MenuCommand(a, mi, k, f);
} }
void MenuMngr::clear() void MenuMngr::clear()
{ {
while (headid) while (headid)
{ {
MenuIdEle* a = headid->next; MenuIdEle* a = headid->next;
delete headid; delete headid;
headid = a; headid = a;
} }
while (headcmd) while (headcmd)
{ {
MenuCommand* a = headcmd->next; MenuCommand* a = headcmd->next;
delete headcmd; delete headcmd;
headcmd = a; headcmd = a;
} }
} }
int MenuMngr::MenuIdEle::uniqueid = 0; int MenuMngr::MenuIdEle::uniqueid = 0;

View File

@ -33,7 +33,7 @@
// class CPlayer // class CPlayer
// ***************************************************** // *****************************************************
void CPlayer::Init( edict_t* e , int i ) void CPlayer::Init(edict_t* e, int i)
{ {
index = i; index = i;
pEdict = e; pEdict = e;
@ -55,7 +55,8 @@ void CPlayer::Init( edict_t* e , int i )
team.clear(); team.clear();
} }
void CPlayer::Disconnect() { void CPlayer::Disconnect()
{
ingame = false; ingame = false;
initialized = false; initialized = false;
authorized = false; authorized = false;
@ -64,8 +65,10 @@ void CPlayer::Disconnect() {
{ {
ClientCvarQuery_Info *pQuery = cvarQueryQueue.front(); ClientCvarQuery_Info *pQuery = cvarQueryQueue.front();
unregisterSPForward(pQuery->resultFwd); unregisterSPForward(pQuery->resultFwd);
if (pQuery->params) if (pQuery->params)
delete [] pQuery->params; delete [] pQuery->params;
delete pQuery; delete pQuery;
cvarQueryQueue.pop(); cvarQueryQueue.pop();
} }
@ -73,39 +76,40 @@ void CPlayer::Disconnect() {
bot = 0; bot = 0;
} }
void CPlayer::PutInServer() { void CPlayer::PutInServer()
{
playtime = gpGlobals->time; playtime = gpGlobals->time;
ingame = true; ingame = true;
} }
bool CPlayer::Connect(const char* connectname,const char* ipaddress) {
bool CPlayer::Connect(const char* connectname, const char* ipaddress)
{
name.assign(connectname); name.assign(connectname);
ip.assign(ipaddress); ip.assign(ipaddress);
time = gpGlobals->time; time = gpGlobals->time;
bot = IsBot(); bot = IsBot();
death_killer = 0; death_killer = 0;
memset(flags,0,sizeof(flags)); memset(flags, 0, sizeof(flags));
memset(weapons,0,sizeof(weapons)); memset(weapons, 0, sizeof(weapons));
initialized = true; initialized = true;
authorized = false; authorized = false;
const char* authid = GETPLAYERAUTHID( pEdict ); const char* authid = GETPLAYERAUTHID(pEdict);
if ( (authid == 0) || (*authid == 0) if ((authid == 0) || (*authid == 0) || (strcmp(authid, "STEAM_ID_PENDING") == 0))
|| (strcmp( authid , "STEAM_ID_PENDING") == 0) )
return true; return true;
return false; return false;
} }
// ***************************************************** // *****************************************************
// class Grenades // 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; Obj* a = new Obj;
if ( a == 0 ) return; if (a == 0) return;
a->player = player; a->player = player;
a->grenade = grenade; a->grenade = grenade;
a->time = gpGlobals->time + time; a->time = gpGlobals->time + time;
@ -114,34 +118,37 @@ void Grenades::put( edict_t* grenade, float time, int type, CPlayer* player )
head = a; 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; bool found = false;
Obj** a = &head; Obj** a = &head;
while ( *a ){
if ( (*a)->time > gpGlobals->time ) { while (*a)
if ( (*a)->grenade == enemy ) { {
if ((*a)->time > gpGlobals->time)
{
if ((*a)->grenade == enemy)
{
found = true; found = true;
(*p) = (*a)->player; (*p) = (*a)->player;
type = (*a)->type; type = (*a)->type;
} }
} } else {
else {
Obj* b = (*a)->next; Obj* b = (*a)->next;
delete *a; delete *a;
*a = b; *a = b;
continue; continue;
} }
a = &(*a)->next; a = &(*a)->next;
} }
return found; return found;
} }
void Grenades::clear() void Grenades::clear()
{ {
while(head){ while (head)
{
Obj* a = head->next; Obj* a = head->next;
delete head; delete head;
head = a; head = a;
@ -151,21 +158,24 @@ void Grenades::clear()
// ***************************************************** // *****************************************************
// class XVars // class XVars
// ***************************************************** // *****************************************************
void XVars::clear() {
void XVars::clear()
{
delete[] head; delete[] head;
head = 0; head = 0;
num = 0; num = 0;
size = 0; size = 0;
} }
int XVars::put( AMX* p, cell* v ) int XVars::put(AMX* p, cell* v)
{ {
for(int a = 0; a < num; ++a) { for (int a = 0; a < num; ++a)
if ( (head[a].amx == p) && (head[a].value == v) ) {
if ((head[a].amx == p) && (head[a].value == v))
return a; return a;
} }
if ( (num >= size) && realloc_array( size ? (size * 2) : 8 ) ) if ((num >= size) && realloc_array(size ? (size * 2) : 8))
return -1; return -1;
head[num].value = v; head[num].value = v;
@ -173,71 +183,90 @@ int XVars::put( AMX* p, cell* v )
return num++; return num++;
} }
int XVars::realloc_array( int nsize ) int XVars::realloc_array(int nsize)
{ {
XVarEle* me = new XVarEle[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]; me[a] = head[a];
delete[] head; delete[] head;
head = me; head = me;
size = nsize; size = nsize;
return 0; return 0;
} }
return 1; return 1;
} }
// ***************************************************** // *****************************************************
// class TeamIds // class TeamIds
// ***************************************************** // *****************************************************
TeamIds::TeamIds() { head = 0; newTeam = 0; } TeamIds::TeamIds() { head = 0; newTeam = 0; }
TeamIds::~TeamIds() {
while( head ) { TeamIds::~TeamIds()
{
while (head)
{
TeamEle* a = head->next; TeamEle* a = head->next;
delete head; delete head;
head = a; head = a;
} }
} }
void TeamIds::registerTeam( const char* n ,int s ) void TeamIds::registerTeam(const char* n, int s)
{ {
TeamEle** a = &head; TeamEle** a = &head;
while( *a ){
if ( strcmp((*a)->name.c_str(),n) == 0 ){ while (*a)
if (s != -1){ {
if (strcmp((*a)->name.c_str(),n) == 0)
{
if (s != -1)
{
(*a)->id = s; (*a)->id = s;
newTeam &= ~(1<<(*a)->tid); newTeam &= ~(1<<(*a)->tid);
} }
return; return;
} }
a = &(*a)->next; 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); newTeam |= (1<<(*a)->tid);
} }
int TeamIds::findTeamId( const char* n ) int TeamIds::findTeamId(const char* n)
{ {
TeamEle* a = head; TeamEle* a = head;
while( a ){
if ( !stricmp(a->name.c_str(),n) ) while (a)
{
if (!stricmp(a->name.c_str(), n))
return a->id; return a->id;
a = a->next; a = a->next;
} }
return -1; return -1;
} }
int TeamIds::findTeamIdCase( const char* n) int TeamIds::findTeamIdCase(const char* n)
{ {
TeamEle* a = head; TeamEle* a = head;
while( a ){
if ( !strcmp(a->name.c_str(), n) ) while (a)
{
if (!strcmp(a->name.c_str(), n))
return a->id; return a->id;
a = a->next; a = a->next;
} }
return -1; return -1;
} }
char TeamIds::TeamEle::uid = 0; char TeamIds::TeamEle::uid = 0;

View File

@ -32,7 +32,7 @@
#include "amxmodx.h" #include "amxmodx.h"
#ifndef FAR #ifndef FAR
#define FAR #define FAR
#endif #endif
// New // New
@ -55,7 +55,7 @@ CModule::CModule(const char* fname)
CModule::~CModule() CModule::~CModule()
{ {
// old & new // old & new
if ( m_Handle ) if (m_Handle)
DLFREE(m_Handle); DLFREE(m_Handle);
clear(); clear();
@ -67,6 +67,7 @@ void CModule::clear(bool clearFilename)
m_Metamod = false; m_Metamod = false;
m_Handle = NULL; m_Handle = NULL;
m_Status = MODULE_NONE; m_Status = MODULE_NONE;
if (clearFilename) if (clearFilename)
m_Filename.assign("unknown"); m_Filename.assign("unknown");
@ -114,6 +115,7 @@ bool CModule::attachModule()
if (!AttachFunc_New) if (!AttachFunc_New)
return false; return false;
g_ModuleCallReason = ModuleCall_Attach; g_ModuleCallReason = ModuleCall_Attach;
g_CurrentlyCalledModule = this; g_CurrentlyCalledModule = this;
int retVal = (*AttachFunc_New)(Module_ReqFnptr); int retVal = (*AttachFunc_New)(Module_ReqFnptr);
@ -122,21 +124,21 @@ bool CModule::attachModule()
switch (retVal) switch (retVal)
{ {
case AMXX_OK: case AMXX_OK:
m_Status = MODULE_LOADED; m_Status = MODULE_LOADED;
return true; return true;
case AMXX_PARAM: case AMXX_PARAM:
AMXXLOG_Log("[AMXX] Internal Error: Module \"%s\" (version \"%s\") retured \"Invalid parameter\" from Attach func.", m_Filename.c_str(), getVersion()); AMXXLOG_Log("[AMXX] Internal Error: Module \"%s\" (version \"%s\") retured \"Invalid parameter\" from Attach func.", m_Filename.c_str(), getVersion());
m_Status = MODULE_INTERROR; m_Status = MODULE_INTERROR;
return false; return false;
case AMXX_FUNC_NOT_PRESENT: case AMXX_FUNC_NOT_PRESENT:
m_Status = MODULE_FUNCNOTPRESENT; m_Status = MODULE_FUNCNOTPRESENT;
m_MissingFunc = g_LastRequestedFunc; m_MissingFunc = g_LastRequestedFunc;
return false; return false;
default: default:
AMXXLOG_Log("[AMXX] Module \"%s\" (version \"%s\") returned an invalid code.", m_Filename.c_str(), getVersion()); AMXXLOG_Log("[AMXX] Module \"%s\" (version \"%s\") returned an invalid code.", m_Filename.c_str(), getVersion());
m_Status = MODULE_BADLOAD; m_Status = MODULE_BADLOAD;
return false; return false;
} }
} else { } else {
m_Status = MODULE_BADLOAD; m_Status = MODULE_BADLOAD;
@ -147,7 +149,7 @@ bool CModule::attachModule()
bool CModule::queryModule() 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; return false;
m_Handle = DLLOAD(m_Filename.c_str()); // load file m_Handle = DLLOAD(m_Filename.c_str()); // load file
@ -163,6 +165,7 @@ bool CModule::queryModule()
// Try new interface first // Try new interface first
QUERYMOD_NEW queryFunc_New = (QUERYMOD_NEW)DLPROC(m_Handle, "AMXX_Query"); QUERYMOD_NEW queryFunc_New = (QUERYMOD_NEW)DLPROC(m_Handle, "AMXX_Query");
if (queryFunc_New) if (queryFunc_New)
{ {
m_Amxx = true; m_Amxx = true;
@ -172,24 +175,25 @@ bool CModule::queryModule()
int retVal = (*queryFunc_New)(&ifVers, &m_InfoNew); int retVal = (*queryFunc_New)(&ifVers, &m_InfoNew);
g_CurrentlyCalledModule = NULL; g_CurrentlyCalledModule = NULL;
g_ModuleCallReason = ModuleCall_NotCalled; g_ModuleCallReason = ModuleCall_NotCalled;
switch (retVal) switch (retVal)
{ {
case AMXX_PARAM: case AMXX_PARAM:
AMXXLOG_Log("[AMXX] Internal Error: Module \"%s\" (version \"%s\") retured \"Invalid parameter\" from Attach func.", m_Filename.c_str(), getVersion()); AMXXLOG_Log("[AMXX] Internal Error: Module \"%s\" (version \"%s\") retured \"Invalid parameter\" from Attach func.", m_Filename.c_str(), getVersion());
m_Status = MODULE_INTERROR; m_Status = MODULE_INTERROR;
return false; return false;
case AMXX_IFVERS: case AMXX_IFVERS:
if (ifVers < AMXX_INTERFACE_VERSION) if (ifVers < AMXX_INTERFACE_VERSION)
m_Status = MODULE_OLD; m_Status = MODULE_OLD;
else else
m_Status = MODULE_NEWER; m_Status = MODULE_NEWER;
return false; return false;
case AMXX_OK: case AMXX_OK:
break; break;
default: default:
AMXXLOG_Log("[AMXX] Module \"%s\" (version \"%s\") returned an invalid code.", m_Filename.c_str(), getVersion()); AMXXLOG_Log("[AMXX] Module \"%s\" (version \"%s\") returned an invalid code.", m_Filename.c_str(), getVersion());
m_Status = MODULE_BADLOAD; m_Status = MODULE_BADLOAD;
return false; return false;
} }
// Check for attach // Check for attach
@ -201,9 +205,7 @@ bool CModule::queryModule()
m_Status = MODULE_QUERY; m_Status = MODULE_QUERY;
return true; return true;
} } else {
else
{
m_Status = MODULE_NOQUERY; m_Status = MODULE_NOQUERY;
m_Amxx = false; m_Amxx = false;
return false; return false;
@ -218,6 +220,7 @@ bool CModule::detachModule()
if (m_Amxx) if (m_Amxx)
{ {
DETACHMOD_NEW detachFunc_New = (DETACHMOD_NEW)DLPROC(m_Handle, "AMXX_Detach"); DETACHMOD_NEW detachFunc_New = (DETACHMOD_NEW)DLPROC(m_Handle, "AMXX_Detach");
if (detachFunc_New) if (detachFunc_New)
{ {
g_ModuleCallReason = ModuleCall_Detach; g_ModuleCallReason = ModuleCall_Detach;
@ -227,14 +230,17 @@ bool CModule::detachModule()
g_ModuleCallReason = ModuleCall_NotCalled; g_ModuleCallReason = ModuleCall_NotCalled;
} }
} }
#ifndef FAKEMETA #ifndef FAKEMETA
if (IsMetamod()) if (IsMetamod())
{ {
UnloadMetamodPlugin(m_Handle); UnloadMetamodPlugin(m_Handle);
} }
#endif #endif
DLFREE(m_Handle); DLFREE(m_Handle);
clear(); clear();
return true; return true;
} }
@ -247,28 +253,31 @@ void CModule::CallPluginsLoaded()
return; return;
PLUGINSLOADED_NEW func = (PLUGINSLOADED_NEW)DLPROC(m_Handle, "AMXX_PluginsLoaded"); PLUGINSLOADED_NEW func = (PLUGINSLOADED_NEW)DLPROC(m_Handle, "AMXX_PluginsLoaded");
if (!func) if (!func)
return; return;
func(); func();
} }
const char* CModule::getStatus() const const char* CModule::getStatus() const
{ {
switch(m_Status) switch (m_Status)
{ {
case MODULE_NONE: return "error"; case MODULE_NONE: return "error";
case MODULE_QUERY: return "pending"; case MODULE_QUERY: return "pending";
case MODULE_BADLOAD: return "bad load"; case MODULE_BADLOAD: return "bad load";
case MODULE_LOADED: return "running"; case MODULE_LOADED: return "running";
case MODULE_NOINFO: return "no info"; case MODULE_NOINFO: return "no info";
case MODULE_NOQUERY: return "no query"; case MODULE_NOQUERY: return "no query";
case MODULE_NOATTACH: return "no attach"; case MODULE_NOATTACH: return "no attach";
case MODULE_OLD: return "old"; case MODULE_OLD: return "old";
case MODULE_FUNCNOTPRESENT: case MODULE_FUNCNOTPRESENT:
case MODULE_NEWER: return "newer"; case MODULE_NEWER: return "newer";
case MODULE_INTERROR: return "internal err"; case MODULE_INTERROR: return "internal err";
case MODULE_NOT64BIT: return "not 64bit"; case MODULE_NOT64BIT: return "not 64bit";
default: break; default: break;
} }
return "unknown"; return "unknown";
} }

View File

@ -33,6 +33,7 @@
#include "CTask.h" #include "CTask.h"
/*********************** CTask ***********************/ /*********************** CTask ***********************/
int CTaskMngr::CTask::getTaskId() const int CTaskMngr::CTask::getTaskId() const
{ {
return m_iId; return m_iId;
@ -57,12 +58,15 @@ void CTaskMngr::CTask::set(CPluginMngr::CPlugin *pPlugin, int iFunc, int iFlags,
{ {
m_bLoop = true; m_bLoop = true;
m_iRepeat = -1; m_iRepeat = -1;
} else if (iFlags & 1) { }
else if (iFlags & 1)
{
m_bLoop = true; m_bLoop = true;
m_iRepeat = iRepeat; 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; 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) void CTaskMngr::CTask::executeIfRequired(float fCurrentTime, float fTimeLimit, float fTimeLeft)
{ {
bool execute=false; bool execute = false;
bool done=false; bool done = false;
if (m_bAfterStart) if (m_bAfterStart)
{ {
if (fCurrentTime - fTimeLeft + 1.0f >= m_fBase) 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) if (fTimeLimit != 0.0f && (fTimeLeft + fTimeLimit * 60.0f) - fCurrentTime - 1.0f <= m_fBase)
execute = true; execute = true;
} else if (m_fNextExecTime <= fCurrentTime) { }
else if (m_fNextExecTime <= fCurrentTime)
{
execute = true; execute = true;
} }
if (execute) if (execute)
{ {
//only bother calling if we have something to call //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 if (m_iParamLen) // call with parameters
{ {
@ -199,6 +206,7 @@ CTaskMngr::CTask::~CTask()
} }
/*********************** CTaskMngr ***********************/ /*********************** CTaskMngr ***********************/
CTaskMngr::CTaskMngr() CTaskMngr::CTaskMngr()
{ {
m_pTmr_CurrentTime = NULL; m_pTmr_CurrentTime = NULL;
@ -222,17 +230,18 @@ void CTaskMngr::registerTask(CPluginMngr::CPlugin *pPlugin, int iFunc, int iFlag
{ {
// first, search for free tasks // first, search for free tasks
TaskListIter iter = m_Tasks.find(CTaskDescriptor(0, NULL, true)); TaskListIter iter = m_Tasks.find(CTaskDescriptor(0, NULL, true));
if (iter) if (iter)
{ {
// found: reuse it // found: reuse it
iter->set(pPlugin, iFunc, iFlags, iId, fBase, iParamsLen, pParams, iRepeat, *m_pTmr_CurrentTime); iter->set(pPlugin, iFunc, iFlags, iId, fBase, iParamsLen, pParams, iRepeat, *m_pTmr_CurrentTime);
} } else {
else
{
// not found: make a new one // not found: make a new one
CTask *pTmp = new CTask; CTask *pTmp = new CTask;
if (!pTmp) if (!pTmp)
return; return;
pTmp->set(pPlugin, iFunc, iFlags, iId, fBase, iParamsLen, pParams, iRepeat, *m_pTmr_CurrentTime); pTmp->set(pPlugin, iFunc, iFlags, iId, fBase, iParamsLen, pParams, iRepeat, *m_pTmr_CurrentTime);
m_Tasks.put(pTmp); m_Tasks.put(pTmp);
} }
@ -242,13 +251,15 @@ int CTaskMngr::removeTasks(int iId, AMX *pAmx)
{ {
CTaskDescriptor descriptor(iId, pAmx); CTaskDescriptor descriptor(iId, pAmx);
TaskListIter iter = m_Tasks.find(descriptor); TaskListIter iter = m_Tasks.find(descriptor);
int i=0; int i = 0;
while (iter) while (iter)
{ {
iter->clear(); iter->clear();
++i; ++i;
iter = m_Tasks.find(++iter, descriptor); iter = m_Tasks.find(++iter, descriptor);
} }
return i; return i;
} }
@ -256,14 +267,16 @@ int CTaskMngr::changeTasks(int iId, AMX *pAmx, float fNewBase)
{ {
CTaskDescriptor descriptor(iId, pAmx); CTaskDescriptor descriptor(iId, pAmx);
TaskListIter iter = m_Tasks.find(descriptor); TaskListIter iter = m_Tasks.find(descriptor);
int i=0; int i = 0;
while (iter) while (iter)
{ {
iter->changeBase(fNewBase); iter->changeBase(fNewBase);
iter->resetNextExecTime(*m_pTmr_CurrentTime); iter->resetNextExecTime(*m_pTmr_CurrentTime);
++i; ++i;
iter = m_Tasks.find(++iter, descriptor); iter = m_Tasks.find(++iter, descriptor);
} }
return i; return i;
} }

View File

@ -39,46 +39,47 @@
// ***************************************************** // *****************************************************
// class Vault // 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; return;
} }
Obj** a = find( k ); Obj** a = find(k);
if ( *a ) if (*a)
{ {
(*a)->value.assign(v); (*a)->value.assign(v);
(*a)->number = atoi( v ); (*a)->number = atoi(v);
} }
else 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); number = atoi(v);
} }
Vault::Obj** Vault::find( const char* n ) Vault::Obj** Vault::find(const char* n)
{ {
Obj** a = &head; 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; return a;
a = &(*a)->next; 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; 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(); return b->value.c_str();
} }
void Vault::clear() void Vault::clear()
{ {
while ( head ) while (head)
{ {
Obj* a = head->next; Obj* a = head->next;
delete head; 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; Obj* a = (*b)->next;
delete *b; delete *b;
*b = a; *b = a;
} }
void Vault::setSource( const char* n ) void Vault::setSource(const char* n)
{ {
path.assign(n); path.assign(n);
} }
bool Vault::loadVault()
bool Vault::loadVault( )
{ {
if ( path.empty() ) return false; if (path.empty()) return false;
clear(); 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; const int sz = 512;
char value[sz+1]; char value[sz + 1];
char key[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 ) ) if (isalpha(*key))
put( key, value ); put(key, value);
} }
return true; 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'; 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'; a << b->key << '\t' << b->value << '\n';
return true; return true;

View File

@ -105,7 +105,8 @@ CAmxxReader::CAmxxReader(const char *filename, int cellsize)
m_pFile = NULL; m_pFile = NULL;
return; return;
} else if (magic == MAGIC_HEADER2) }
else if (magic == MAGIC_HEADER2)
{ {
DATAREAD(&m_Bh.version, sizeof(int16_t), 1); 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]); pe = &(m_Bh.plugins[m_Entry]);
m_SectionLength = pe->disksize; m_SectionLength = pe->disksize;
} else if (magic == MAGIC_HEADER) }
else if (magic == MAGIC_HEADER)
{ {
// try to find the section // try to find the section
mint8_t numOfPlugins; mint8_t numOfPlugins;
@ -185,7 +187,7 @@ CAmxxReader::CAmxxReader(const char *filename, int cellsize)
} }
// compute section length // compute section length
if ((i+1) < static_cast<int>(numOfPlugins)) if ((i + 1) < static_cast<int>(numOfPlugins))
{ {
// there is a next section // there is a next section
TableEntry nextEntry; TableEntry nextEntry;
@ -274,7 +276,8 @@ size_t CAmxxReader::GetBufferSize()
DATAREAD(&hdr, sizeof(hdr), 1); DATAREAD(&hdr, sizeof(hdr), 1);
fseek(m_pFile, save, SEEK_SET); fseek(m_pFile, save, SEEK_SET);
return hdr.stp; return hdr.stp;
} else if (m_AmxxFile) }
else if (m_AmxxFile)
{ {
PluginEntry *pe = &(m_Bh.plugins[m_Entry]); PluginEntry *pe = &(m_Bh.plugins[m_Entry]);
@ -321,7 +324,8 @@ CAmxxReader::Error CAmxxReader::GetSection(void *buffer)
m_Status = Err_None; m_Status = Err_None;
return m_Status; return m_Status;
} else if (m_AmxxFile) }
else if (m_AmxxFile)
{ {
PluginEntry *pe = &(m_Bh.plugins[m_Entry]); PluginEntry *pe = &(m_Bh.plugins[m_Entry]);
char *tempBuffer = new char[m_SectionLength + 1]; char *tempBuffer = new char[m_SectionLength + 1];

View File

@ -57,197 +57,224 @@ WeaponsVault g_weaponsData[MAX_WEAPONS];
void Client_VGUIMenu(void* mValue) void Client_VGUIMenu(void* mValue)
{ {
if (!mPlayer) return; if (!mPlayer) return;
switch (mState++){
case 0: switch (mState++)
mPlayer->menu = -(*(int*)mValue); {
break; case 0:
case 1: mPlayer->menu = -(*(int*)mValue);
mPlayer->keys = *(int*)mValue; break;
} case 1:
mPlayer->keys = *(int*)mValue;
}
} }
void Client_ShowMenu(void* mValue) void Client_ShowMenu(void* mValue)
{ {
if (!mPlayer) return; if (!mPlayer) return;
switch (mState++){
case 0: switch (mState++)
mPlayer->keys = *(int*)mValue; {
break; case 0:
case 3: mPlayer->keys = *(int*)mValue;
mPlayer->menu = g_menucmds.findMenuId( (char*)mValue ); break;
} case 3:
mPlayer->menu = g_menucmds.findMenuId((char*)mValue);
}
} }
void Client_TeamInfo(void* mValue) void Client_TeamInfo(void* mValue)
{ {
if (mPlayer) return; if (mPlayer) return;
static int index; static int index;
switch (mState++) {
case 0: switch (mState++)
index = *(int*)mValue; {
break; case 0:
case 1: index = *(int*)mValue;
if ( index < 1 || index > gpGlobals->maxClients ) break; break;
char* msg = (char*)mValue; case 1:
g_players[ index ].team.assign( msg ); if (index < 1 || index > gpGlobals->maxClients) break;
g_teamsIds.registerTeam( msg , -1 ); char* msg = (char*)mValue;
} g_players[index].team.assign(msg);
g_teamsIds.registerTeam(msg, -1);
}
} }
void Client_TextMsg(void* mValue) void Client_TextMsg(void* mValue)
{ {
if ( mPlayer ) return; 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;
}
}
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) void Client_WeaponList(void* mValue)
{ {
static int wpnList = 0; static int wpnList = 0;
//static int wpnList2; //static int wpnList2;
static int iSlot; static int iSlot;
static const char* wpnName; static const char* wpnName;
switch (mState++) {
case 0: switch (mState++)
wpnName = (char*)mValue; {
break; case 0:
case 1: wpnName = (char*)mValue;
iSlot = *(int*)mValue; break;
break; case 1:
case 7: iSlot = *(int*)mValue;
int iId = *(int*)mValue; break;
if ( (iId < 0 || iId >= MAX_WEAPONS ) || (wpnList & (1<<iId)) ) case 7:
break; int iId = *(int*)mValue;
wpnList |= (1<<iId); if ((iId < 0 || iId >= MAX_WEAPONS) || (wpnList & (1<<iId)))
g_weaponsData[iId].iId = iId; break;
g_weaponsData[iId].ammoSlot = iSlot; wpnList |= (1<<iId);
g_weaponsData[iId].fullName.assign(wpnName); g_weaponsData[iId].iId = iId;
g_weaponsData[iId].ammoSlot = iSlot;
} g_weaponsData[iId].fullName.assign(wpnName);
}
} }
void Client_CurWeapon(void* mValue) void Client_CurWeapon(void* mValue)
{ {
static int iState; static int iState;
static int iId; static int iId;
switch (mState++){
case 0: switch (mState++)
iState = *(int*)mValue; {
break; case 0:
case 1: iState = *(int*)mValue;
if (!iState) break; break;
iId = *(int*)mValue; case 1:
break; if (!iState) break;
case 2: iId = *(int*)mValue;
if (!mPlayer) return; break;
if (!iState || (iId < 1 || iId >= MAX_WEAPONS ) ) break; case 2:
mPlayer->weapons[iId].clip = *(int*)mValue; if (!mPlayer) return;
mPlayer->current = iId; if (!iState || (iId < 1 || iId >= MAX_WEAPONS)) break;
mPlayer->lastHit = mPlayer->lastTrace; mPlayer->weapons[iId].clip = *(int*)mValue;
} mPlayer->current = iId;
mPlayer->lastHit = mPlayer->lastTrace;
}
} }
void Client_AmmoX(void* mValue) void Client_AmmoX(void* mValue)
{ {
static int iAmmo;
static int iAmmo;
switch (mState++){ switch (mState++)
case 0: {
iAmmo = *(int*)mValue; case 0:
break; iAmmo = *(int*)mValue;
case 1: break;
if (!mPlayer) return; case 1:
for(int i=1;i<MAX_WEAPONS;++i) if (!mPlayer) return;
if (iAmmo == g_weaponsData[i].ammoSlot) for (int i = 1; i < MAX_WEAPONS; ++i)
mPlayer->weapons[i].ammo = *(int*)mValue; if (iAmmo == g_weaponsData[i].ammoSlot)
} mPlayer->weapons[i].ammo = *(int*)mValue;
}
} }
void Client_AmmoPickup(void* mValue) void Client_AmmoPickup(void* mValue)
{ {
static int iSlot; static int iSlot;
switch (mState++){
case 0: switch (mState++)
iSlot = *(int*)mValue; {
break; case 0:
case 1: iSlot = *(int*)mValue;
if (!mPlayer) return; break;
for(int i=1;i<MAX_WEAPONS;++i) case 1:
if (g_weaponsData[i].ammoSlot==iSlot) if (!mPlayer) return;
mPlayer->weapons[i].ammo += *(int*)mValue; 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) void Client_ScoreInfo(void* mValue)
{ {
static int index; static int index;
static int deaths; static int deaths;
switch (mState++){
case 0: switch (mState++)
index = *(int*)mValue; {
break; case 0:
case 2: index = *(int*)mValue;
deaths = *(int*)mValue; break;
break; case 2:
case 4: deaths = *(int*)mValue;
if ( index < 1 || index > gpGlobals->maxClients ) break; break;
CPlayer*pPlayer = GET_PLAYER_POINTER_I( index ); case 4:
pPlayer->deaths = deaths; if (index < 1 || index > gpGlobals->maxClients) break;
pPlayer->teamId = *(int*)mValue; CPlayer*pPlayer = GET_PLAYER_POINTER_I(index);
if ( g_teamsIds.isNewTeam() ) pPlayer->deaths = deaths;
g_teamsIds.registerTeam( pPlayer->team.c_str() , pPlayer->teamId ); pPlayer->teamId = *(int*)mValue;
} if (g_teamsIds.isNewTeam())
g_teamsIds.registerTeam(pPlayer->team.c_str(), pPlayer->teamId);
}
} }
void Client_DamageEnd(void* mValue) void Client_DamageEnd(void* mValue)
{ {
CPlayer* dead = mPlayer; 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.parserInit(CS_DEATHMSG, &gpGlobals->time, mPlayer = 0, mPlayerIndex = 0);
g_events.parseValue( dead->death_killer ); g_events.parseValue(dead->death_killer);
g_events.parseValue( dead->index ); g_events.parseValue(dead->index);
g_events.parseValue( dead->death_headshot ); g_events.parseValue(dead->death_headshot);
g_events.parseValue( dead->death_weapon.c_str() ); g_events.parseValue(dead->death_weapon.c_str());
g_events.parseValue( dead->death_tk ? 1 : 0 ); g_events.parseValue(dead->death_tk ? 1 : 0);
g_events.executeEvents(); g_events.executeEvents();
dead->death_killer = 0; dead->death_killer = 0;
} }
@ -261,28 +288,25 @@ void Client_DeathMsg(void* mValue)
static int victim_id; static int victim_id;
static int hs; static int hs;
switch (mState++){ switch (mState++)
case 0: {
killer_id = *(int*)mValue; case 0:
killer = (killer_id > 0 && killer_id < 33) ? killer_id = *(int*)mValue;
GET_PLAYER_POINTER_I(killer_id) : 0; killer = (killer_id > 0 && killer_id < 33) ? GET_PLAYER_POINTER_I(killer_id) : 0;
break; break;
case 1: case 1:
victim_id = *(int*)mValue; victim_id = *(int*)mValue;
victim = (victim_id > 0 && victim_id < 33) ? victim = (victim_id > 0 && victim_id < 33) ? GET_PLAYER_POINTER_I(victim_id) : 0;
GET_PLAYER_POINTER_I(victim_id) : 0; break;
break; case 2:
case 2: hs = *(int*)mValue;
hs = *(int*)mValue; break;
break; case 3:
case 3: if (!killer || !victim) break;
victim->death_killer = killer_id;
if ( !killer || !victim ) break; victim->death_weapon.assign((char*)mValue);
victim->death_headshot = hs;
victim->death_killer = killer_id; victim->death_tk = (killer->teamId == victim->teamId);
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)
} }
*/ */

View File

@ -5,7 +5,7 @@
* *
* *
* This program is free software; you can redistribute it and/or modify it * 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 * Free Software Foundation; either version 2 of the License, or (at
* your option) any later version. * your option) any later version.
* *
@ -63,11 +63,13 @@ class AutoFilePtr
public: public:
AutoFilePtr(FILE *fp) : m_FP(fp) AutoFilePtr(FILE *fp) : m_FP(fp)
{ } { }
~AutoFilePtr() ~AutoFilePtr()
{ {
if (m_FP) if (m_FP)
fclose(m_FP); fclose(m_FP);
} }
operator FILE* () operator FILE* ()
{ {
return m_FP; return m_FP;
@ -80,20 +82,25 @@ static cell AMX_NATIVE_CALL read_dir(AMX *amx, cell *params)
int a; int a;
struct dirent *ep; struct dirent *ep;
DIR *dp; 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]; a = params[2];
if ( (dp = opendir (dirname)) == NULL )
if ((dp = opendir (dirname)) == NULL)
return 0; return 0;
seekdir( dp , a ); seekdir(dp, a);
if ( (ep = readdir (dp)) != NULL ) {
cell *length = get_amxaddr(amx,params[5]); if ((ep = readdir (dp)) != NULL)
*length = set_amxstring(amx,params[3], ep->d_name ,params[4]); {
a = telldir( dp ); cell *length = get_amxaddr(amx, params[5]);
} *length = set_amxstring(amx, params[3], ep->d_name, params[4]);
else a = telldir(dp);
} else
a = 0; a = 0;
closedir (dp); closedir (dp);
return a; return a;
#else #else
int tmp; int tmp;
char *dirname = build_pathname("%s/*", get_amxstring(amx, params[1], 0, 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; _finddata_t fd;
intptr_t handle = _findfirst(dirname, &fd); intptr_t handle = _findfirst(dirname, &fd);
if (handle < 0) if (handle < 0)
return 0; return 0;
++tmp; ++tmp;
for (int i = 0; i < tmp; ++i) for (int i = 0; i < tmp; ++i)
{ {
if (_findnext(handle, &fd) < 0) if (_findnext(handle, &fd) < 0)
@ -113,8 +122,9 @@ static cell AMX_NATIVE_CALL read_dir(AMX *amx, cell *params)
break; break;
} }
} }
// current data in fd // 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 *length = set_amxstring(amx, params[3], fd.name, params[4]); // set output and outLen parameters
_findclose(handle); _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 */ static cell AMX_NATIVE_CALL read_file(AMX *amx, cell *params) /* 5 param */
{ {
int iLen; int iLen;
char* szFile = get_amxstring(amx,params[1],0,iLen); char* szFile = get_amxstring(amx, params[1], 0, iLen);
FILE*fp; FILE *fp;
if ( (fp =fopen(build_pathname("%s",szFile),"r")) == NULL) {
amx_RaiseError(amx,AMX_ERR_NATIVE); if ((fp =fopen(build_pathname("%s", szFile), "r")) == NULL)
return 0; {
} amx_RaiseError(amx, AMX_ERR_NATIVE);
char buffor[1024]; return 0;
int i = 0, iLine = params[2]; }
while((i <= iLine) && fgets(buffor,1023,fp) )
i++; char buffor[1024];
fclose(fp); int i = 0, iLine = params[2];
if (i > iLine){
int len = strlen(buffor); while ((i <= iLine) && fgets(buffor, 1023, fp))
if (buffor[len-1]=='\n') i++;
buffor[--len]=0; fclose(fp);
if (buffor[len-1]=='\r')
buffor[--len]=0; if (i > iLine)
cell *length = get_amxaddr(amx,params[5]); {
*length = set_amxstring(amx,params[3],buffor,params[4]); int len = strlen(buffor);
return i; if (buffor[len - 1] == '\n')
} buffor[--len] = 0;
return 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 */ static cell AMX_NATIVE_CALL write_file(AMX *amx, cell *params) /* 3 param */
{ {
int i; int i;
char* sFile = build_pathname("%s", get_amxstring(amx,params[1],0,i) ); char* sFile = build_pathname("%s", get_amxstring(amx, params[1], 0, i));
char* sText = get_amxstring(amx,params[2],0,i); char* sText = get_amxstring(amx, params[2], 0, i);
FILE* pFile; FILE* pFile;
int iLine = params[3]; int iLine = params[3];
// apending to the end // apending to the end
if (iLine < 0) { if (iLine < 0)
if ( (pFile = fopen( sFile ,"a")) == NULL ){ {
amx_RaiseError(amx,AMX_ERR_NATIVE); if ((pFile = fopen(sFile, "a")) == NULL)
return 0; {
} amx_RaiseError(amx, AMX_ERR_NATIVE);
fputs( sText , pFile ); return 0;
fputc( '\n', pFile ); }
fclose( pFile );
return 1; fputs(sText, pFile);
} fputc('\n', pFile);
fclose(pFile);
return 1;
}
// creating a new file with a line in a middle // creating a new file with a line in a middle
if ( (pFile = fopen(sFile,"r")) == NULL ) { if ((pFile = fopen(sFile, "r")) == NULL)
if ( (pFile = fopen(sFile,"w")) == NULL ){ {
amx_RaiseError(amx,AMX_ERR_NATIVE); if ((pFile = fopen(sFile, "w")) == NULL)
return 0; {
} amx_RaiseError(amx, AMX_ERR_NATIVE);
for(i=0;i < iLine;++i) return 0;
fputc('\n',pFile); }
fputs( sText , pFile );
fputc( '\n', pFile ); for (i = 0; i < iLine; ++i)
fclose(pFile); fputc('\n', pFile);
return 1;
} fputs(sText, pFile);
fputc('\n', pFile);
fclose(pFile);
return 1;
}
// adding a new line in a middle of already existing file // adding a new line in a middle of already existing file
FILE* pTemp; FILE* pTemp;
char buffor[2048]; char buffor[2048];
if ( (pTemp = tmpfile()) == NULL ){ if ((pTemp = tmpfile()) == NULL)
amx_RaiseError(amx,AMX_ERR_NATIVE); {
return 0; amx_RaiseError(amx, AMX_ERR_NATIVE);
} return 0;
}
for(i=0;;++i){ for (i = 0; ; ++i)
if ( i == iLine ){ {
fgets(buffor,2047,pFile); if (i == iLine)
fputs( sText , pTemp ); {
fputc( '\n', pTemp ); fgets(buffor, 2047, pFile);
} fputs(sText, pTemp);
else if ( fgets(buffor,2047,pFile) ){ fputc('\n', pTemp);
fputs(buffor , pTemp ); }
} else if (fgets(buffor, 2047, pFile))
else if ( i < iLine ) { {
fputc( '\n', pTemp ); fputs(buffor, pTemp);
} }
else break; else if (i < iLine)
} {
fputc('\n', pTemp);
}
else break;
}
fclose(pFile); fclose(pFile);
rewind(pTemp); rewind(pTemp);
// now rewrite because file can be now smaller... // now rewrite because file can be now smaller...
if ( (pFile = fopen(sFile,"w")) == NULL ){ if ((pFile = fopen(sFile, "w")) == NULL)
amx_RaiseError(amx,AMX_ERR_NATIVE); {
return 0; amx_RaiseError(amx, AMX_ERR_NATIVE);
} return 0;
}
while(fgets(buffor,2047,pTemp)) while (fgets(buffor, 2047, pTemp))
fputs(buffor,pFile ); fputs(buffor, pFile);
fclose(pTemp); fclose(pTemp);
fclose(pFile); fclose(pFile);
return 1;
return 1;
} }
static cell AMX_NATIVE_CALL delete_file(AMX *amx, cell *params) /* 1 param */ static cell AMX_NATIVE_CALL delete_file(AMX *amx, cell *params) /* 1 param */
{ {
int iLen; int iLen;
char* sFile = get_amxstring(amx,params[1],0,iLen); char* sFile = get_amxstring(amx, params[1], 0, iLen);
return (unlink( build_pathname("%s",sFile) )?0:1); return (unlink(build_pathname("%s", sFile)) ? 0 : 1);
} }
static cell AMX_NATIVE_CALL file_exists(AMX *amx, cell *params) /* 1 param */ static cell AMX_NATIVE_CALL file_exists(AMX *amx, cell *params) /* 1 param */
{ {
int iLen; int iLen;
char *sFile = get_amxstring(amx,params[1],0,iLen); char *sFile = get_amxstring(amx, params[1], 0, iLen);
char *file = build_pathname("%s",sFile); char *file = build_pathname("%s", sFile);
#if defined WIN32 || defined _WIN32 #if defined WIN32 || defined _WIN32
DWORD attr = GetFileAttributes(file); DWORD attr = GetFileAttributes(file);
if (attr == INVALID_FILE_ATTRIBUTES) if (attr == INVALID_FILE_ATTRIBUTES)
return 0; return 0;
if (attr == FILE_ATTRIBUTE_DIRECTORY) if (attr == FILE_ATTRIBUTE_DIRECTORY)
return 0; return 0;
return 1; return 1;
#else #else
struct stat s; struct stat s;
if (stat(file, &s) != 0) if (stat(file, &s) != 0)
return 0; return 0;
if (S_ISDIR(s.st_mode)) if (S_ISDIR(s.st_mode))
return 0; return 0;
return 1; return 1;
#endif #endif
} }
static cell AMX_NATIVE_CALL dir_exists(AMX *amx, cell *params) /* 1 param */ static cell AMX_NATIVE_CALL dir_exists(AMX *amx, cell *params) /* 1 param */
{ {
int iLen; int iLen;
char *sFile = get_amxstring(amx,params[1],0,iLen); char *sFile = get_amxstring(amx, params[1], 0, iLen);
char *file = build_pathname("%s",sFile); char *file = build_pathname("%s", sFile);
#if defined WIN32 || defined _WIN32 #if defined WIN32 || defined _WIN32
DWORD attr = GetFileAttributes(file); DWORD attr = GetFileAttributes(file);
if (attr == INVALID_FILE_ATTRIBUTES) if (attr == INVALID_FILE_ATTRIBUTES)
return 0; return 0;
if (attr == FILE_ATTRIBUTE_DIRECTORY) if (attr == FILE_ATTRIBUTE_DIRECTORY)
return 1; return 1;
return 0; return 0;
#else #else
struct stat s; struct stat s;
if (stat(file, &s) != 0) if (stat(file, &s) != 0)
return 0; return 0;
if (S_ISDIR(s.st_mode)) if (S_ISDIR(s.st_mode))
return 1; return 1;
return 0; return 0;
#endif #endif
} }
static cell AMX_NATIVE_CALL file_size(AMX *amx, cell *params) /* 1 param */ static cell AMX_NATIVE_CALL file_size(AMX *amx, cell *params) /* 1 param */
{ {
int iLen; int iLen;
char* sFile = get_amxstring(amx,params[1],0,iLen); char* sFile = get_amxstring(amx, params[1], 0, iLen);
AutoFilePtr fp(fopen(build_pathname("%s",sFile),"r")); AutoFilePtr fp(fopen(build_pathname("%s", sFile), "r"));
if ( fp != NULL)
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); int size = ftell(fp);
return size; return size;
} }
else if ( params[2] == 1 ) else if (params[2] == 1)
{ {
int a = 0,lines = 0; int a = 0,lines = 0;
while( a != EOF )
while (a != EOF)
{ {
++lines; ++lines;
while ( (a = fgetc(fp)) != '\n' && a != EOF ) while ((a = fgetc(fp)) != '\n' && a != EOF);
;
} }
//int a, b = '\n'; //int a, b = '\n';
//while( (a = fgetc(fp)) != EOF ){ //while( (a = fgetc(fp)) != EOF ){
@ -307,13 +341,16 @@ static cell AMX_NATIVE_CALL file_size(AMX *amx, cell *params) /* 1 param */
// ++lines; // ++lines;
return lines; return lines;
} }
else if ( params[2] == 2 ){ else if (params[2] == 2)
fseek(fp,-1,SEEK_END); {
if ( fgetc(fp) == '\n' ) fseek(fp, -1, SEEK_END);
if (fgetc(fp) == '\n')
return 1; return 1;
return 0; return 0;
} }
} }
return -1; 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); char *flags = get_amxstring(amx, params[2], 0, len);
FILE *fp = fopen(file, flags); FILE *fp = fopen(file, flags);
if (fp == NULL) { if (fp == NULL)
{
// Failed // Failed
return 0; return 0;
} }
for (i=0; i<FileList.size(); i++) for (i = 0; i < FileList.size(); i++)
{ {
if (FileList.at(i) == NULL) if (FileList.at(i) == NULL)
{ {
@ -340,7 +378,8 @@ static cell AMX_NATIVE_CALL amx_fopen(AMX *amx, cell *params)
break; break;
} }
} }
if (j==-1)
if (j == -1)
{ {
FileList.push_back(fp); FileList.push_back(fp);
j = FileList.size() - 1; j = FileList.size() - 1;
@ -348,16 +387,19 @@ static cell AMX_NATIVE_CALL amx_fopen(AMX *amx, cell *params)
FileList.at(j) = fp; FileList.at(j) = fp;
} }
return j+1; return j + 1;
} }
static cell AMX_NATIVE_CALL amx_fclose(AMX *amx, cell *params) static cell AMX_NATIVE_CALL amx_fclose(AMX *amx, cell *params)
{ {
unsigned int id = params[1] - 1; unsigned int id = params[1] - 1;
if (id >= FileList.size() || FileList.at(id) == NULL) if (id >= FileList.size() || FileList.at(id) == NULL)
return 0; return 0;
FILE *fp = FileList.at(id); FILE *fp = FileList.at(id);
if (fp) {
if (fp)
{
return fclose(fp); return fclose(fp);
} else { } else {
return -1; 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) static cell AMX_NATIVE_CALL amx_fread(AMX *amx, cell *params)
{ {
unsigned int id = params[1] - 1; unsigned int id = params[1] - 1;
if (id >= FileList.size() || FileList.at(id) == NULL) if (id >= FileList.size() || FileList.at(id) == NULL)
return 0; return 0;
FILE *fp = FileList.at(id); FILE *fp = FileList.at(id);
char *buffer; char *buffer;
if (fp) {
if (fp)
{
buffer = new char[params[3]]; // SLOW!!! :TODO: Find a better way (auto pointers?) buffer = new char[params[3]]; // SLOW!!! :TODO: Find a better way (auto pointers?)
fread(buffer, sizeof(char), params[3], fp); fread(buffer, sizeof(char), params[3], fp);
set_amxstring(amx, params[2], buffer, params[3]); set_amxstring(amx, params[2], buffer, params[3]);
delete [] buffer; delete [] buffer;
return 1; return 1;
} }
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) static cell AMX_NATIVE_CALL amx_fgetc(AMX *amx, cell *params)
{ {
unsigned int id = params[1] - 1; unsigned int id = params[1] - 1;
if (id >= FileList.size() || FileList.at(id) == NULL) if (id >= FileList.size() || FileList.at(id) == NULL)
return 0; return 0;
FILE *fp = FileList.at(id); FILE *fp = FileList.at(id);
if (fp) {
if (fp)
{
return fgetc(fp); return fgetc(fp);
} else { } else {
return -1; 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) static cell AMX_NATIVE_CALL amx_fwrite(AMX *amx, cell *params)
{ {
unsigned int id = params[1] - 1; unsigned int id = params[1] - 1;
if (id >= FileList.size() || FileList.at(id) == NULL) if (id >= FileList.size() || FileList.at(id) == NULL)
return 0; return 0;
FILE *fp = FileList.at(id); FILE *fp = FileList.at(id);
char *buf; char *buf;
int len; int len;
if (fp) {
if (fp)
{
buf = format_amxstring(amx, params, 2, len); buf = format_amxstring(amx, params, 2, len);
return fwrite(buf, sizeof(char), strlen(buf), fp); return fwrite(buf, sizeof(char), strlen(buf), fp);
} }
return -1; return -1;
} }
static cell AMX_NATIVE_CALL amx_feof(AMX *amx, cell *params) static cell AMX_NATIVE_CALL amx_feof(AMX *amx, cell *params)
{ {
unsigned int id = params[1] - 1; unsigned int id = params[1] - 1;
if (id >= FileList.size() || FileList.at(id) == NULL) if (id >= FileList.size() || FileList.at(id) == NULL)
return 0; return 0;
FILE *fp = FileList.at(id); FILE *fp = FileList.at(id);
if (fp) {
if (feof(fp)) { if (fp)
{
if (feof(fp))
{
return 1; return 1;
} }
return 0; return 0;
} }
return -1; return -1;
} }
static cell AMX_NATIVE_CALL amx_fseek(AMX *amx, cell *params) static cell AMX_NATIVE_CALL amx_fseek(AMX *amx, cell *params)
{ {
unsigned int id = params[1] - 1; unsigned int id = params[1] - 1;
if (id >= FileList.size() || FileList.at(id) == NULL) if (id >= FileList.size() || FileList.at(id) == NULL)
return 0; return 0;
FILE *fp = FileList.at(id); FILE *fp = FileList.at(id);
if (fp) { if (fp)
{
return fseek(fp, (long)params[2], params[3]); return fseek(fp, (long)params[2], params[3]);
} }
return -1; return -1;
} }
static cell AMX_NATIVE_CALL amx_fputc(AMX *amx, cell *params) static cell AMX_NATIVE_CALL amx_fputc(AMX *amx, cell *params)
{ {
unsigned int id = params[1] - 1; unsigned int id = params[1] - 1;
if (id >= FileList.size() || FileList.at(id) == NULL) if (id >= FileList.size() || FileList.at(id) == NULL)
return 0; return 0;
FILE *fp = FileList.at(id); FILE *fp = FileList.at(id);
if (fp) { if (fp)
{
return fputc(params[2], fp); return fputc(params[2], fp);
} }
return -1; return -1;
} }
static cell AMX_NATIVE_CALL amx_rewind(AMX *amx, cell *params) static cell AMX_NATIVE_CALL amx_rewind(AMX *amx, cell *params)
{ {
unsigned int id = params[1] - 1; unsigned int id = params[1] - 1;
if (id >= FileList.size() || FileList.at(id) == NULL) if (id >= FileList.size() || FileList.at(id) == NULL)
return 0; return 0;
FILE *fp = FileList.at(id); FILE *fp = FileList.at(id);
if (fp) { if (fp)
{
rewind(fp); rewind(fp);
return 1; return 1;
} }
return -1; return -1;
} }
static cell AMX_NATIVE_CALL amx_fflush(AMX *amx, cell *params) static cell AMX_NATIVE_CALL amx_fflush(AMX *amx, cell *params)
{ {
unsigned int id = params[1] - 1; unsigned int id = params[1] - 1;
if (id >= FileList.size() || FileList.at(id) == NULL) if (id >= FileList.size() || FileList.at(id) == NULL)
return 0; return 0;
FILE *fp = FileList.at(id); FILE *fp = FileList.at(id);
if (fp) { if (fp)
{
return fflush(fp); return fflush(fp);
} }
return -1; return -1;
} }
static cell AMX_NATIVE_CALL amx_fscanf(AMX *amx, cell *params) static cell AMX_NATIVE_CALL amx_fscanf(AMX *amx, cell *params)
{ {
unsigned int id = params[1] - 1; unsigned int id = params[1] - 1;
if (id >= FileList.size() || FileList.at(id) == NULL) if (id >= FileList.size() || FileList.at(id) == NULL)
return 0; return 0;
FILE *fp = FileList.at(id); FILE *fp = FileList.at(id);
@ -488,7 +560,9 @@ static cell AMX_NATIVE_CALL amx_fscanf(AMX *amx, cell *params)
char *buf; char *buf;
int len; int len;
buf = format_amxstring(amx, params, 2, len); buf = format_amxstring(amx, params, 2, len);
if (fp) {
if (fp)
{
return fscanf(fp, "%s", buf); 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) static cell AMX_NATIVE_CALL amx_ftell(AMX *amx, cell *params)
{ {
unsigned int id = params[1] - 1; unsigned int id = params[1] - 1;
if (id >= FileList.size() || FileList.at(id) == NULL) if (id >= FileList.size() || FileList.at(id) == NULL)
return 0; return 0;
FILE *fp = FileList.at(id); FILE *fp = FileList.at(id);
if (fp) { if (fp)
{
return ftell(fp); return ftell(fp);
} }
return -1; return -1;
} }
#endif //UNUSED #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)); char *file = build_pathname("%s", format_amxstring(amx, params, 1, len));
long size; long size;
AutoFilePtr fp(fopen(file, "rb")); AutoFilePtr fp(fopen(file, "rb"));
if (fp) {
if (fp)
{
fseek(fp, 0, SEEK_END); fseek(fp, 0, SEEK_END);
size = ftell(fp); size = ftell(fp);
return size; return size;
} }
return -1; 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) static cell AMX_NATIVE_CALL amx_fgetl(AMX *amx, cell *params)
{ {
unsigned int id = params[1] - 1; unsigned int id = params[1] - 1;
if (id >= FileList.size() || FileList.at(id) == NULL) if (id >= FileList.size() || FileList.at(id) == NULL)
return 0; return 0;
FILE *fp = FileList.at(id); FILE *fp = FileList.at(id);
long t; long t;
if (fp) {
if (fp)
{
fread(&t, sizeof(long), 1, fp); fread(&t, sizeof(long), 1, fp);
return t; return t;
} }
return -1; return -1;
} }
static cell AMX_NATIVE_CALL amx_fgeti(AMX *amx, cell *params) static cell AMX_NATIVE_CALL amx_fgeti(AMX *amx, cell *params)
{ {
unsigned int id = params[1] - 1; unsigned int id = params[1] - 1;
if (id >= FileList.size() || FileList.at(id) == NULL) if (id >= FileList.size() || FileList.at(id) == NULL)
return 0; return 0;
FILE *fp = FileList.at(id); FILE *fp = FileList.at(id);
int t; int t;
if (fp) {
if (fp)
{
fread(&t, sizeof(int), 1, fp); fread(&t, sizeof(int), 1, fp);
return t; return t;
} }
return -1; return -1;
} }
static cell AMX_NATIVE_CALL amx_fgets(AMX *amx, cell *params) static cell AMX_NATIVE_CALL amx_fgets(AMX *amx, cell *params)
{ {
unsigned int id = params[1] - 1; unsigned int id = params[1] - 1;
if (id >= FileList.size() || FileList.at(id) == NULL) if (id >= FileList.size() || FileList.at(id) == NULL)
return 0; return 0;
FILE *fp = FileList.at(id); FILE *fp = FileList.at(id);
short t; short t;
if (fp) {
if (fp)
{
fread(&t, sizeof(short), 1, fp); fread(&t, sizeof(short), 1, fp);
return t; return t;
} }
return -1; return -1;
} }
static cell AMX_NATIVE_CALL amx_fputs(AMX *amx, cell *params) static cell AMX_NATIVE_CALL amx_fputs(AMX *amx, cell *params)
{ {
unsigned int id = params[1] - 1; unsigned int id = params[1] - 1;
if (id >= FileList.size() || FileList.at(id) == NULL) if (id >= FileList.size() || FileList.at(id) == NULL)
return 0; return 0;
FILE *fp = FileList.at(id); FILE *fp = FileList.at(id);
short size = params[2]; short size = params[2];
if (fp) {
if (fp)
{
return fwrite(&size, sizeof(short), 1, fp); return fwrite(&size, sizeof(short), 1, fp);
} }
return -1; return -1;
} }
static cell AMX_NATIVE_CALL amx_fputl(AMX *amx, cell *params) static cell AMX_NATIVE_CALL amx_fputl(AMX *amx, cell *params)
{ {
unsigned int id = params[1] - 1; unsigned int id = params[1] - 1;
if (id >= FileList.size() || FileList.at(id) == NULL) if (id >= FileList.size() || FileList.at(id) == NULL)
return 0; return 0;
FILE *fp = FileList.at(id); FILE *fp = FileList.at(id);
long size = params[2]; long size = params[2];
if (fp) {
if (fp)
{
return fwrite(&size, sizeof(long), 1, fp); return fwrite(&size, sizeof(long), 1, fp);
} }
return -1; return -1;
} }
static cell AMX_NATIVE_CALL amx_fputi(AMX *amx, cell *params) static cell AMX_NATIVE_CALL amx_fputi(AMX *amx, cell *params)
{ {
unsigned int id = params[1] - 1; unsigned int id = params[1] - 1;
if (id >= FileList.size() || FileList.at(id) == NULL) if (id >= FileList.size() || FileList.at(id) == NULL)
return 0; return 0;
FILE *fp = FileList.at(id); FILE *fp = FileList.at(id);
int size = params[2]; int size = params[2];
if (fp) {
if (fp)
{
return fwrite(&size, sizeof(int), 1, fp); return fwrite(&size, sizeof(int), 1, fp);
} }
return -1; return -1;
} }
static cell AMX_NATIVE_CALL amx_fgetf(AMX *amx, cell *params) static cell AMX_NATIVE_CALL amx_fgetf(AMX *amx, cell *params)
{ {
unsigned int id = params[1] - 1; unsigned int id = params[1] - 1;
if (id >= FileList.size() || FileList.at(id) == NULL) if (id >= FileList.size() || FileList.at(id) == NULL)
return 0; return 0;
FILE *fp = FileList.at(id); FILE *fp = FileList.at(id);
float t; float t;
if (fp) {
if (fp)
{
fread(&t, sizeof(float), 1, fp); fread(&t, sizeof(float), 1, fp);
return *(cell*)&t; return *(cell*)&t;
} }
return -1; return -1;
} }
static cell AMX_NATIVE_CALL amx_fputf(AMX *amx, cell *params) static cell AMX_NATIVE_CALL amx_fputf(AMX *amx, cell *params)
{ {
unsigned int id = params[1] - 1; unsigned int id = params[1] - 1;
if (id >= FileList.size() || FileList.at(id) == NULL) if (id >= FileList.size() || FileList.at(id) == NULL)
return 0; return 0;
FILE *fp = FileList.at(id); FILE *fp = FileList.at(id);
float size = *(float *)((void *)&params[2]); float size = *(float *)((void *)&params[2]);
if (fp) {
if (fp)
{
return fwrite(&size, sizeof(float), 1, fp); return fwrite(&size, sizeof(float), 1, fp);
} }
return -1; return -1;
} }
#endif //UNUSED #endif //UNUSED
@ -657,22 +769,28 @@ static cell AMX_NATIVE_CALL amx_open_dir(AMX *amx, cell *params)
char *dirname = build_pathname("%s\\*", path); char *dirname = build_pathname("%s\\*", path);
WIN32_FIND_DATA fd; WIN32_FIND_DATA fd;
HANDLE hFile = FindFirstFile(dirname, &fd); HANDLE hFile = FindFirstFile(dirname, &fd);
if (hFile == INVALID_HANDLE_VALUE) if (hFile == INVALID_HANDLE_VALUE)
return 0; return 0;
set_amxstring(amx, params[2], fd.cFileName, params[3]); set_amxstring(amx, params[2], fd.cFileName, params[3]);
return (DWORD)hFile; return (DWORD)hFile;
#else #else
char *dirname = build_pathname("%s", path); char *dirname = build_pathname("%s", path);
DIR *dp = opendir(dirname); DIR *dp = opendir(dirname);
if (!dp) if (!dp)
return NULL; return NULL;
struct dirent *ep = readdir(dp); struct dirent *ep = readdir(dp);
if (!ep) if (!ep)
{ {
closedir(dp); closedir(dp);
return NULL; 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; return (cell)dp;
#endif #endif
} }
@ -681,14 +799,18 @@ static cell AMX_NATIVE_CALL amx_close_dir(AMX *amx, cell *params)
{ {
#if defined WIN32 || defined _WIN32 #if defined WIN32 || defined _WIN32
HANDLE hFile = (HANDLE)((DWORD)params[1]); HANDLE hFile = (HANDLE)((DWORD)params[1]);
if (hFile == INVALID_HANDLE_VALUE || hFile == NULL) if (hFile == INVALID_HANDLE_VALUE || hFile == NULL)
return 0; return 0;
FindClose(hFile); FindClose(hFile);
return 1; return 1;
#else #else
DIR *dp = (DIR *)params[1]; DIR *dp = (DIR *)params[1];
if (!dp) if (!dp)
return 0; return 0;
closedir(dp); closedir(dp);
return 1; return 1;
#endif #endif
@ -698,64 +820,68 @@ static cell AMX_NATIVE_CALL amx_get_dir(AMX *amx, cell *params)
{ {
#if defined WIN32 || defined _WIN32 #if defined WIN32 || defined _WIN32
HANDLE hFile = (HANDLE)((DWORD)params[1]); HANDLE hFile = (HANDLE)((DWORD)params[1]);
if (hFile == INVALID_HANDLE_VALUE || hFile == NULL) if (hFile == INVALID_HANDLE_VALUE || hFile == NULL)
return 0; return 0;
WIN32_FIND_DATA fd; WIN32_FIND_DATA fd;
if (!FindNextFile(hFile, &fd)) if (!FindNextFile(hFile, &fd))
return 0; return 0;
set_amxstring(amx, params[2], fd.cFileName, params[3]); set_amxstring(amx, params[2], fd.cFileName, params[3]);
return 1; return 1;
#else #else
DIR *dp = (DIR *)params[1]; DIR *dp = (DIR *)params[1];
if (!dp) if (!dp)
return 0; return 0;
struct dirent *ep = readdir(dp); struct dirent *ep = readdir(dp);
if (!ep) if (!ep)
return 0; return 0;
set_amxstring(amx,params[2], ep->d_name,params[3]); set_amxstring(amx, params[2], ep->d_name, params[3]);
return 1; return 1;
#endif #endif
} }
AMX_NATIVE_INFO file_Natives[] = { AMX_NATIVE_INFO file_Natives[] =
{ "delete_file", delete_file }, {
{ "file_exists", file_exists }, {"delete_file", delete_file},
{ "file_size", file_size }, {"file_exists", file_exists},
{ "read_dir", read_dir }, {"file_size", file_size},
{ "read_file", read_file }, {"read_dir", read_dir},
{ "write_file", write_file }, {"read_file", read_file},
//Sanji's File Natives {"write_file", write_file},
{ "fopen", amx_fopen }, //Sanji's File Natives
{ "fclose", amx_fclose }, {"fopen", amx_fopen},
{ "fread", amx_fread }, {"fclose", amx_fclose},
{ "filesize", amx_filesize }, {"fread", amx_fread},
{"filesize", amx_filesize},
#ifdef UNUSED #ifdef UNUSED
{ "fgetc", amx_fgetc }, {"fgetc", amx_fgetc},
{ "fwrite", amx_fwrite }, {"fwrite", amx_fwrite},
{ "feof", amx_feof }, {"feof", amx_feof},
{ "fseek", amx_fseek }, {"fseek", amx_fseek},
{ "fputc", amx_fputc }, {"fputc", amx_fputc},
{ "rewind", amx_rewind }, {"rewind", amx_rewind},
{ "fflush", amx_fflush }, {"fflush", amx_fflush},
{ "fscanf", amx_fscanf }, {"fscanf", amx_fscanf},
{ "ftell", amx_ftell }, {"ftell", amx_ftell},
{ "fgetl", amx_fgetl }, {"fgetl", amx_fgetl},
{ "fgeti", amx_fgeti }, {"fgeti", amx_fgeti},
{ "fgets", amx_fgets }, {"fgets", amx_fgets},
{ "fputs", amx_fputs }, {"fputs", amx_fputs},
{ "fputl", amx_fputl }, {"fputl", amx_fputl},
{ "fputi", amx_fputi }, {"fputi", amx_fputi},
{ "fgetf", amx_fgetf }, {"fgetf", amx_fgetf},
{ "fputf", amx_fputf }, {"fputf", amx_fputf},
#endif #endif
{ "unlink", delete_file }, {"unlink", delete_file},
{ "build_pathname", amx_build_pathname}, {"build_pathname", amx_build_pathname},
{ "dir_exists", dir_exists }, {"dir_exists", dir_exists},
{ "open_dir", amx_open_dir }, {"open_dir", amx_open_dir},
{ "close_dir", amx_close_dir }, {"close_dir", amx_close_dir},
{ "next_file", amx_get_dir }, {"next_file", amx_get_dir},
{NULL, NULL}
{ NULL, NULL }
}; };

View File

@ -168,7 +168,7 @@ int C_PrecacheSound(char *s)
for (CList<ForceObject>::iterator a = g_forcesounds.begin(); a; ++a) for (CList<ForceObject>::iterator a = g_forcesounds.begin(); a; ++a)
{ {
PRECACHE_SOUND((char*)(*a).getFilename()); PRECACHE_SOUND((char*)(*a).getFilename());
ENGINE_FORCE_UNMODIFIED((*a).getForceType(),(*a).getMin(),(*a).getMax(),(*a).getFilename()); ENGINE_FORCE_UNMODIFIED((*a).getForceType(), (*a).getMin(), (*a).getMax(), (*a).getFilename());
} }
if (!g_bmod_cstrike) if (!g_bmod_cstrike)
@ -206,7 +206,7 @@ const char* get_localinfo(const char* name, const char* def)
const char* b = LOCALINFO((char*)name); const char* b = LOCALINFO((char*)name);
if (b == 0 || *b == 0) if (b == 0 || *b == 0)
SET_LOCALINFO((char*)name,(char*)(b = def)); SET_LOCALINFO((char*)name, (char*)(b = def));
return b; return b;
} }
@ -320,7 +320,7 @@ int C_Spawn(edict_t *pent)
{ {
PRECACHE_GENERIC((char*)(*a).getFilename()); PRECACHE_GENERIC((char*)(*a).getFilename());
ENGINE_FORCE_UNMODIFIED((*a).getForceType(), ENGINE_FORCE_UNMODIFIED((*a).getForceType(),
(*a).getMin(),(*a).getMax(),(*a).getFilename()); (*a).getMin(), (*a).getMax(), (*a).getFilename());
} }
RETURN_META_VALUE(MRES_IGNORED, 0); RETURN_META_VALUE(MRES_IGNORED, 0);
@ -413,7 +413,7 @@ void C_ServerActivate_Post(edict_t *pEdictList, int edictCount, int clientMax)
if (g_activated) if (g_activated)
RETURN_META(MRES_IGNORED); RETURN_META(MRES_IGNORED);
for (int i= 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CPlayer *pPlayer = GET_PLAYER_POINTER_I(i); CPlayer *pPlayer = GET_PLAYER_POINTER_I(i);
pPlayer->Init(pEdictList + 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); CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity);
executeForwards(FF_ClientInfoChanged, pPlayer->index); executeForwards(FF_ClientInfoChanged, pPlayer->index);
const char* name = INFOKEY_VALUE(infobuffer,"name"); const char* name = INFOKEY_VALUE(infobuffer, "name");
// Emulate bot connection and putinserver // Emulate bot connection and putinserver
if (pPlayer->ingame) if (pPlayer->ingame)
{ {
pPlayer->name.assign(name); // Make sure player have name up to date pPlayer->name.assign(name); // Make sure player have name up to date
} }
else if (pPlayer->IsBot()) else if (pPlayer->IsBot())
{ {
pPlayer->Connect(name, "127.0.0.1"/*CVAR_GET_STRING("net_address")*/); 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 */ /* check menu commands */
if (!strcmp(cmd,"menuselect")) if (!strcmp(cmd, "menuselect"))
{ {
int pressed_key = atoi(arg) - 1; int pressed_key = atoi(arg) - 1;
int bit_key = (1<<pressed_key); int bit_key = (1<<pressed_key);
@ -718,16 +718,19 @@ void C_ClientCommand(edict_t *pEntity)
ret = executeForwards((*a).getFunction(), pPlayer->index, menu, item); ret = executeForwards((*a).getFunction(), pPlayer->index, menu, item);
if (ret & 2) result = MRES_SUPERCEDE; if (ret & 2) result = MRES_SUPERCEDE;
else if (ret & 1) RETURN_META(MRES_SUPERCEDE); else
if (ret & 1) RETURN_META(MRES_SUPERCEDE);
else else
{ {
if (item == MENU_BACK) if (item == MENU_BACK)
{ {
pMenu->Display(pPlayer->index, pPlayer->page-1); pMenu->Display(pPlayer->index, pPlayer->page-1);
} else if (item == MENU_MORE) }
else if (item == MENU_MORE)
{ {
pMenu->Display(pPlayer->index, pPlayer->page+1); pMenu->Display(pPlayer->index, pPlayer->page + 1);
} else if (item == MENU_EXIT) }
else if (item == MENU_EXIT)
{ {
//nothing //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"); LOG_ERROR(PLID, "metamod version is too old for this plugin; update metamod");
return (FALSE); 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"); LOG_ERROR(PLID, "metamod version is incompatible with this plugin; please find a newer version of this plugin");
return (FALSE); return (FALSE);
} else if (pmajor == mmajor) }
else if (pmajor == mmajor)
{ {
#ifdef FAKEMETA #ifdef FAKEMETA
if (mminor == 10) if (mminor == 10)
@ -1138,14 +1143,17 @@ C_DLLEXPORT int Meta_Query(char *ifvers, plugin_info_t **pPlugInfo, mutil_funcs_
{ {
g_NeedsP = true; g_NeedsP = true;
#endif #endif
} else if (mminor >= 11) }
else if (mminor >= 11)
{ {
g_IsNewMM = true; 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"); LOG_ERROR(PLID, "metamod version is incompatible with this plugin; please find a newer version of this plugin");
return FALSE; 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"); 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; enginefuncs_t meta_engfuncs;
C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *interfaceVersion) 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; meta_engfuncs.pfnSetModel = C_SetModel;
g_bmod_cstrike = true; g_bmod_cstrike = true;
} else { } else {
g_bmod_cstrike = false; 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; meta_engfuncs.pfnCmd_Argc = C_Cmd_Argc;

View File

@ -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 "amxmodx.h"
#include "newmenus.h" #include "newmenus.h"
@ -5,7 +35,7 @@ CVector<Menu *> g_NewMenus;
void ClearMenus() void ClearMenus()
{ {
for (size_t i=0; i<g_NewMenus.size(); i++) for (size_t i = 0; i < g_NewMenus.size(); i++)
delete g_NewMenus[i]; delete g_NewMenus[i];
g_NewMenus.clear(); g_NewMenus.clear();
} }
@ -19,7 +49,7 @@ Menu::Menu(const char *title, int mid, int tid)
Menu::~Menu() Menu::~Menu()
{ {
for (size_t i=0; i<m_Items.size(); i++) for (size_t i = 0; i < m_Items.size(); i++)
delete m_Items[i]; delete m_Items[i];
m_Items.clear(); m_Items.clear();
} }
@ -86,10 +116,14 @@ int Menu::PagekeyToItem(page_t page, item_t key)
return MENU_MORE; return MENU_MORE;
else else
return MENU_EXIT; return MENU_EXIT;
} else if (key == rem+1) { }
else if (key == rem + 1)
{
return MENU_EXIT; return MENU_EXIT;
} }
} else if (page == pages - 1) { }
else if (page == pages - 1)
{
//find number of remaining items //find number of remaining items
//for example, 11 items on page 1... means start=7, 11-7=4 //for example, 11 items on page 1... means start=7, 11-7=4
item_t rem = numItems - start; item_t rem = numItems - start;
@ -97,14 +131,18 @@ int Menu::PagekeyToItem(page_t page, item_t key)
if (key == rem) if (key == rem)
{ {
return MENU_EXIT; return MENU_EXIT;
} else if (key == rem+1) { }
else if (key == rem + 1)
{
return MENU_BACK; return MENU_BACK;
} }
} else { } else {
if (key == 7) if (key == 7)
{ {
return MENU_MORE; return MENU_MORE;
} else if (key == 8) { }
else if (key == 8)
{
return MENU_BACK; return MENU_BACK;
} }
} }
@ -147,9 +185,9 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
char buffer[255]; char buffer[255];
if (g_coloredmenus) 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 else
_snprintf(buffer, sizeof(buffer)-1, "%s %d/%d\n\n", m_Title.c_str(), page+1, pages); _snprintf(buffer, sizeof(buffer)-1, "%s %d/%d\n\n", m_Title.c_str(), page + 1, pages);
m_Text.append(buffer); m_Text.append(buffer);
item_t start = page * 7; item_t start = page * 7;
@ -166,7 +204,7 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
keys = 0; keys = 0;
bool enabled = true; bool enabled = true;
int ret = 0; int ret = 0;
for (item_t i=start; i<end; i++) for (item_t i = start; i < end; i++)
{ {
pItem = m_Items[i]; pItem = m_Items[i];
if (pItem->access && !(pItem->access & g_players[player].flags[0])) if (pItem->access && !(pItem->access & g_players[player].flags[0]))

View File

@ -31,240 +31,218 @@
#include "amxmodx.h" #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("%d cvars\n", ammount);
{ }
else if (!strcmp(cmd, "cmds"))
print_srvconsole( "Currently loaded plugins:\n"); {
print_srvconsole( " %-18.17s %-8.7s %-17.16s %-16.15s %-9.8s\n", print_srvconsole("Registered commands:\n");
"name","version","author","file","status"); print_srvconsole(" %-24.23s %-16.15s %-8.7s %-16.15s\n", "name", "access", "type", "plugin");
int plugins = 0;
int running = 0;
CPluginMngr::iterator a = g_plugins.begin();
while (a) int ammount = 0;
{ char access[32];
++plugins;
if ( (*a).isValid() && !(*a).isPaused() ) CmdMngr::iterator a = g_commands.begin(CMD_ConsoleCommand);
++running;
print_srvconsole( " [%3d] %-18.17s %-8.7s %-17.16s %-16.15s %-9.8s\n", while (a)
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); 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());
CPluginMngr::CPlugin *plugin = g_plugins.findPlugin(sPlugin); ++a;
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); print_srvconsole("%d commands\n",ammount);
}
if ( plugin && plugin->isValid() && plugin->isPaused() ) else if (!strcmp(cmd, "version"))
{ {
plugin->unpausePlugin(); print_srvconsole("%s %s\n", Plugin_info.name, Plugin_info.version);
print_srvconsole("Unpaused plugin \"%s\"\n",plugin->getName() ); 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);
} else if (!plugin) { print_srvconsole("Compiled: %s\n", __DATE__ ", " __TIME__);
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__);
#if defined JIT && !defined ASM32 #if defined JIT && !defined ASM32
print_srvconsole( "Core mode: JIT Only\n"); print_srvconsole("Core mode: JIT Only\n");
#elif !defined JIT && defined ASM32 #elif !defined JIT && defined ASM32
print_srvconsole( "Core mode: ASM32 Only\n"); print_srvconsole("Core mode: ASM32 Only\n");
#elif defined JIT && defined ASM32 #elif defined JIT && defined ASM32
print_srvconsole( "Core mode: JIT+ASM32\n"); print_srvconsole("Core mode: JIT+ASM32\n");
#else #else
print_srvconsole( "Core mode: Normal\n"); print_srvconsole("Core mode: Normal\n");
#endif #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"); if ((*a).getStatusValue() == MODULE_LOADED)
print_srvconsole( " %-23.22s %-8.7s %-20.19s %-11.10s\n", ++running;
"name", "version", "author", "status"); ++modules;
int running = 0; print_srvconsole(" [%2d] %-23.22s %-8.7s %-20.19s %-11.10s\n", modules, (*a).getName(), (*a).getVersion(), (*a).getAuthor(), (*a).getStatus());
int modules = 0; ++a;
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");
} }
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("%d modules, %d correct\n", modules, running);
print_srvconsole("Usage: amxx < command > [ argument ]\n"); }
print_srvconsole("Commands:\n"); else if (!strcmp(cmd, "gpl"))
print_srvconsole(" version - display amxx version info\n"); {
print_srvconsole(" gpl - print the license\n"); print_srvconsole("AMX Mod X\n");
print_srvconsole(" plugins - list plugins currently loaded\n"); print_srvconsole("\n");
print_srvconsole(" modules - list modules currently loaded\n"); print_srvconsole(" by the AMX Mod X Development Team\n");
print_srvconsole(" cvars - list cvars registered by plugins\n"); print_srvconsole(" originally developed by OLO\n");
print_srvconsole(" cmds - list commands registered by plugins\n"); print_srvconsole("\n");
print_srvconsole(" pause < plugin > - pause a running plugin\n"); print_srvconsole("\n");
print_srvconsole(" unpause < plugin > - unpause a previously paused plugin\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() void plugin_srvcmd()
{ {
cell ret = 0; cell ret = 0;
@ -272,13 +250,12 @@ void plugin_srvcmd()
CmdMngr::iterator a = g_commands.srvcmdbegin(); CmdMngr::iterator a = g_commands.srvcmdbegin();
while ( a ) while (a)
{ {
if ( (*a).matchCommand( cmd ) && if ((*a).matchCommand(cmd) && (*a).getPlugin()->isExecutable((*a).getFunction()))
(*a).getPlugin()->isExecutable( (*a).getFunction() ) )
{ {
cell ret = executeForwards((*a).getFunction(), g_srvindex, (*a).getFlags(), (*a).getId()); cell ret = executeForwards((*a).getFunction(), g_srvindex, (*a).getFlags(), (*a).getId());
if ( ret ) break; if (ret) break;
} }
++a; ++a;
} }

View File

@ -32,19 +32,20 @@
#include <ctype.h> #include <ctype.h>
#include "amxmodx.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 *needle = (char *)substr;
register char *prevloc = (char *)str; register char *prevloc = (char *)str;
register char *haystack = (char *)str; register char *haystack = (char *)str;
while (*haystack) { while (*haystack)
if (tolower(*haystack) == tolower(*needle)) { {
if (tolower(*haystack) == tolower(*needle))
{
haystack++; haystack++;
if (!*++needle) if (!*++needle)
return prevloc; return prevloc;
} } else {
else {
haystack = ++prevloc; haystack = ++prevloc;
needle = (char *)substr; needle = (char *)substr;
} }
@ -53,7 +54,7 @@ const char* stristr(const char* str,const char* substr)
return NULL; 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); return g_langMngr.FormatAmxString(amx, params, parm, len);
} }
@ -62,71 +63,86 @@ int amxstring_len(cell* a)
{ {
register int c = 0; register int c = 0;
while( a[ c ] ) while (a[c])
++c; ++c;
return 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)); 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* dest = (cell *)(amx->base + (int)(((AMX_HEADER *)amx->base)->dat + amx_addr));
cell* start = dest; cell* start = dest;
while (max--&&*source)
*dest++=(cell)*source++; while (max-- && *source)
*dest++ = (cell)*source++;
*dest = 0; *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]; static char buffor[4][3072];
register cell* source = (cell *)(amx->base + (int)(((AMX_HEADER *)amx->base)->dat + amx_addr)); register cell* source = (cell *)(amx->base + (int)(((AMX_HEADER *)amx->base)->dat + amx_addr));
register char* dest = buffor[id]; register char* dest = buffor[id];
char* start = dest; char* start = dest;
while ((*dest++=(char)(*source++)))
; while ((*dest++=(char)(*source++)));
len = --dest - start; len = --dest - start;
return start; return start;
} }
void copy_amxmemory(cell* dest,cell* src,int len) void copy_amxmemory(cell* dest, cell* src, int len)
{ {
while (len--) while (len--)
*dest++=*src++; *dest++=*src++;
} }
char* parse_arg(char** line,int& state) char* parse_arg(char** line, int& state)
{ {
static char arg[3072]; static char arg[3072];
char* dest = arg; char* dest = arg;
state = 0; state = 0;
while(**line) {
if ( isspace(**line) ) { while (**line)
{
if (isspace(**line))
{
if (state == 1) if (state == 1)
break; break;
else if (!state) { else if (!state)
{
(*line)++; (*line)++;
continue; continue;
} }
} }
else if (state != 2) else if (state != 2)
state = 1; state = 1;
if (**line=='"') {
if (**line == '"')
{
(*line)++; (*line)++;
if (state == 2) if (state == 2)
break; break;
state = 2; state = 2;
continue; continue;
} }
*dest++ = *(*line)++; *dest++ = *(*line)++;
} }
*dest = '\0'; *dest = '\0';
return arg; 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 cell AMX_NATIVE_CALL replace(AMX *amx, cell *params) /* 4 param */
{ {
static char buffor[3072]; static char buffor[3072];
cell *a = get_amxaddr(amx,params[1]); cell *a = get_amxaddr(amx, params[1]);
cell *b = get_amxaddr(amx,params[3]); cell *b = get_amxaddr(amx, params[3]);
cell *c = get_amxaddr(amx,params[4]); cell *c = get_amxaddr(amx, params[4]);
int iMain = amxstring_len(a); int iMain = amxstring_len(a);
int iWhat = amxstring_len(b); int iWhat = amxstring_len(b);
int iWith = amxstring_len(c); int iWith = amxstring_len(c);
int iPot = iMain + iWith - iWhat; int iPot = iMain + iWith - iWhat;
if (iPot>=params[2]){
if (iPot >= params[2])
{
amx_RaiseError(amx,AMX_ERR_NATIVE); amx_RaiseError(amx,AMX_ERR_NATIVE);
return 0; return 0;
} }
char *d = buffor; char *d = buffor;
cell *x, *y, *z = a, *l = a; cell *x, *y, *z = a, *l = a;
int p = 0; int p = 0;
while(*a){
if (*a==*b){ while (*a)
x=a+1; {
y=b+1; if (*a == *b)
p=1; {
x = a + 1;
y = b + 1;
p = 1;
if (!*y) break; if (!*y) break;
while(*x==*y){
while (*x == *y)
{
x++; y++; p++; x++; y++; p++;
if (!*y) break; if (!*y) break;
} }
if (!*y) break; if (!*y) break;
p = 0; p = 0;
*d++=(char)*a++; *d++ = (char)*a++;
continue; continue;
} }
*d++=(char)*a++; *d++ = (char)*a++;
} }
if (p){
while(*c) *d++=(char)*c++; if (p)
a+=p; {
while(*a) *d++=(char)*a++; while (*c) *d++ = (char)*c++;
*d=0; a += p;
while (*a) *d++ = (char)*a++;
*d = 0;
d = buffor; d = buffor;
while(*d) *z++=*d++; while (*d) *z++ = *d++;
*z=0; *z = 0;
return (z-l); return (z - l);
} }
return 0; return 0;
} }
static cell AMX_NATIVE_CALL contain(AMX *amx, cell *params) /* 2 param */ static cell AMX_NATIVE_CALL contain(AMX *amx, cell *params) /* 2 param */
{ {
register cell *a = get_amxaddr(amx,params[2]); register cell *a = get_amxaddr(amx, params[2]);
register cell *b = get_amxaddr(amx,params[1]); register cell *b = get_amxaddr(amx, params[1]);
register cell *c = b; register cell *c = b;
cell* str = b; cell* str = b;
cell* substr = a; cell* substr = a;
while (*c) {
if (*c == *a) { while (*c)
{
if (*c == *a)
{
c++; c++;
if (!*++a) if (!*++a)
return b - str; return b - str;
} } else {
else {
c = ++b; c = ++b;
a = substr; a = substr;
} }
} }
return -1; return -1;
} }
static cell AMX_NATIVE_CALL containi(AMX *amx, cell *params) /* 2 param */ static cell AMX_NATIVE_CALL containi(AMX *amx, cell *params) /* 2 param */
{ {
register cell *a = get_amxaddr(amx,params[2]); register cell *a = get_amxaddr(amx, params[2]);
register cell *b = get_amxaddr(amx,params[1]); register cell *b = get_amxaddr(amx, params[1]);
register cell *c = b; register cell *c = b;
cell* str = b; cell* str = b;
cell* substr = a; cell* substr = a;
while (*c) {
if (tolower(*c) == tolower(*a)) { while (*c)
{
if (tolower(*c) == tolower(*a))
{
c++; c++;
if (!*++a) if (!*++a)
return b - str; return b - str;
} } else {
else {
c = ++b; c = ++b;
a = substr; a = substr;
} }
} }
return -1; 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]); cell *str = get_amxaddr(amx, params[1]);
bool neg=false; bool neg = false;
unsigned long part1 = 0; unsigned long part1 = 0;
if (*str == '-') if (*str == '-')
@ -255,6 +289,7 @@ static cell AMX_NATIVE_CALL str_to_float(AMX *amx, cell *params)
++str; ++str;
break; break;
} }
if (*str < '0' || *str > '9') if (*str < '0' || *str > '9')
{ {
REAL fl = neg ? -static_cast<REAL>(part1) : static_cast<REAL>(part1); 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 part2 = 0;
unsigned long div = 1; unsigned long div = 1;
while (*str) while (*str)
{ {
if (*str < '0' || *str > '9') 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); REAL fl = static_cast<REAL>(part1) + (static_cast<REAL>(part2) / div);
if (neg) if (neg)
fl = -fl; fl = -fl;
return amx_ftoc(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 */ static cell AMX_NATIVE_CALL add(AMX *amx, cell *params) /* 4 param */
{ {
cell *src = get_amxaddr(amx,params[3]); cell *src = get_amxaddr(amx, params[3]);
cell *dest = get_amxaddr(amx,params[1]); cell *dest = get_amxaddr(amx, params[1]);
cell *start = dest; cell *start = dest;
int c = params[2], d = params[4]; int c = params[2], d = params[4];
while(*dest&&c--)
while (*dest && c--)
++dest; ++dest;
if (d){
while(c--&&d--&&*src) if (d)
*dest++=*src++; {
*dest=0; while (c-- && d-- && *src)
return (dest-start); *dest++ =* src++;
*dest = 0;
return (dest - start);
} }
while(c--&&*src)
*dest++=*src++; while (c-- && *src)
*dest=0; *dest++ =* src++;
*dest = 0;
return (dest-start); return (dest-start);
} }
static cell AMX_NATIVE_CALL copy(AMX *amx, cell *params) /* 4 param */ static cell AMX_NATIVE_CALL copy(AMX *amx, cell *params) /* 4 param */
{ {
cell *src = get_amxaddr(amx,params[3]); cell *src = get_amxaddr(amx, params[3]);
cell *dest = get_amxaddr(amx,params[1]); cell *dest = get_amxaddr(amx, params[1]);
cell *start = dest; cell *start = dest;
int c = params[2]; int c = params[2];
while(c--&&*src)
*dest++=*src++; while (c-- && *src)
*dest=0; *dest++ =* src++;
return (dest-start); *dest = 0;
return (dest - start);
} }
static cell AMX_NATIVE_CALL copyc(AMX *amx, cell *params) /* 4 param */ static cell AMX_NATIVE_CALL copyc(AMX *amx, cell *params) /* 4 param */
{ {
cell *src = get_amxaddr(amx,params[3]); cell *src = get_amxaddr(amx, params[3]);
cell *dest = get_amxaddr(amx,params[1]); cell *dest = get_amxaddr(amx, params[1]);
cell *start = dest; cell *start = dest;
int c = params[2]; int c = params[2];
cell ch = params[4]; cell ch = params[4];
while(c--&&*src&&*src!=ch)
*dest++=*src++; while (c-- && *src && *src != ch)
*dest=0; *dest++ =* src++;
return (dest-start); *dest = 0;
return (dest - start);
} }
static cell AMX_NATIVE_CALL setc(AMX *amx, cell *params) /* 4 param */ 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]; int c = params[2];
cell ch = params[3]; cell ch = params[3];
while(c--)
*src++=ch; while (c--)
*src++ = ch;
return 1; return 1;
} }
static cell AMX_NATIVE_CALL equal(AMX *amx, cell *params) /* 3 param */ static cell AMX_NATIVE_CALL equal(AMX *amx, cell *params) /* 3 param */
{ {
cell *a = get_amxaddr(amx,params[1]); cell *a = get_amxaddr(amx, params[1]);
cell *b = get_amxaddr(amx,params[2]); cell *b = get_amxaddr(amx, params[2]);
int c = params[3]; int c = params[3];
if (c) {
while (--c&&*a&&(*a==*b)) if (c)
{
while (--c && *a && (*a == *b))
++a, ++b; ++a, ++b;
return (*a-*b)?0:1; return (*a-*b)?0:1;
} }
int ret; int ret;
while(!(ret=*a-*b)&&*b)
while (!(ret = *a - *b) && *b)
++a, ++b; ++a, ++b;
return ret?0:1;
return ret ? 0 : 1;
} }
static cell AMX_NATIVE_CALL equali(AMX *amx, cell *params) /* 3 param */ static cell AMX_NATIVE_CALL equali(AMX *amx, cell *params) /* 3 param */
{ {
cell *a = get_amxaddr(amx,params[1]); cell *a = get_amxaddr(amx, params[1]);
cell *b = get_amxaddr(amx,params[2]); cell *b = get_amxaddr(amx, params[2]);
int f,l, c = params[3]; int f, l, c = params[3];
if (c) {
do { if (c)
{
do
{
f = tolower(*a++); f = tolower(*a++);
l = tolower(*b++); l = tolower(*b++);
} } while (--c && l && f && f == l);
while (--c &&l&&f&& f==l);
return(f - l)?0:1; return (f - l) ? 0 : 1;
} }
do {
do
{
f = tolower(*a++); f = tolower(*a++);
l = tolower(*b++); l = tolower(*b++);
} while (f && f == l); } 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 */ static cell AMX_NATIVE_CALL format(AMX *amx, cell *params) /* 3 param */
{ {
int len; 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 */ static cell AMX_NATIVE_CALL parse(AMX *amx, cell *params) /* 3 param */
{ {
int inum = *params/sizeof(cell), iarg = 2, c; int inum = *params / sizeof(cell), iarg = 2, c;
char* arg, *parse = get_amxstring(amx,params[1],0,c); char* arg, *parse = get_amxstring(amx, params[1], 0, c);
cell *cptr; cell *cptr;
int state; int state;
while(*parse){
while (*parse)
{
arg = parse_arg(&parse,state); arg = parse_arg(&parse,state);
if (state){
if (state)
{
if (inum <= iarg) if (inum <= iarg)
return( (iarg-2)>>1 ); return ((iarg - 2)>>1);
cptr = get_amxaddr(amx,params[iarg++]);
c = *get_amxaddr(amx,params[iarg++]); cptr = get_amxaddr(amx, params[iarg++]);
while(c--&&*arg) c = *get_amxaddr(amx, params[iarg++]);
*cptr++=(cell)*arg++;
*cptr=0; 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 */ 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; cell *begin = cptr;
while(*cptr){
while (*cptr)
{
*cptr = tolower(*cptr); *cptr = tolower(*cptr);
cptr++; cptr++;
} }
return cptr - begin; return cptr - begin;
} }
static cell AMX_NATIVE_CALL strtoupper(AMX *amx, cell *params) /* 1 param */ 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; cell *begin = cptr;
while(*cptr){
while (*cptr)
{
*cptr = toupper(*cptr); *cptr = toupper(*cptr);
cptr++; cptr++;
} }
return cptr - begin; return cptr - begin;
} }
int fo_numargs(AMX *amx) int fo_numargs(AMX *amx)
{ {
unsigned char *data =amx->base+(int)((AMX_HEADER *)amx->base)->dat; unsigned char *data = amx->base + (int)((AMX_HEADER *)amx->base)->dat;
cell bytes= * (cell *)(data+(int)amx->frm+2*sizeof(cell)); cell bytes= *(cell *)(data + (int)amx->frm + 2 * sizeof(cell));
return (int)(bytes/sizeof(cell)); return (int)(bytes / sizeof(cell));
} }
int fo_getargnum(AMX *amx, int pos) int fo_getargnum(AMX *amx, int pos)
{ {
unsigned char *data =amx->base+(int)((AMX_HEADER *)amx->base)->dat; unsigned char *data = amx->base + (int)((AMX_HEADER *)amx->base)->dat;
cell value = * (cell *)(data+(int)amx->frm+(pos+3)*sizeof(cell)); cell value = *(cell *)(data + (int)amx->frm + (pos + 3) * sizeof(cell));
return *(cell *)(data+(int)value); return *(cell *)(data + (int)value);
} }
float fo_getargfloat(AMX *amx, int pos) float fo_getargfloat(AMX *amx, int pos)
{ {
unsigned char *data =amx->base+(int)((AMX_HEADER *)amx->base)->dat; unsigned char *data = amx->base + (int)((AMX_HEADER *)amx->base)->dat;
cell value = * (cell *)(data+(int)amx->frm+(pos+3)*sizeof(cell)); cell value = *(cell *)(data + (int)amx->frm + (pos + 3) * sizeof(cell));
cell number = *(cell *)(data+(int)value); cell number = *(cell *)(data + (int)value);
return *(REAL *)((void *)&number); return *(REAL *)((void *)&number);
} }
char* fo_getargstr(AMX *amx, int swap, int pos) char* fo_getargstr(AMX *amx, int swap, int pos)
{ {
unsigned char *data =amx->base+(int)((AMX_HEADER *)amx->base)->dat; unsigned char *data = amx->base + (int)((AMX_HEADER *)amx->base)->dat;
cell src_value= * (cell *)(data+(int)amx->frm+(pos+3)*sizeof(cell)); cell src_value= *(cell *)(data + (int)amx->frm + (pos + 3) * sizeof(cell));
cell value; cell value;
static char buffer[2][3072]; static char buffer[2][3072];
char* b = buffer[swap]; char* b = buffer[swap];
int a = 0; int a = 0;
do {
do
{
value = src_value + a++ * sizeof(cell); value = src_value + a++ * sizeof(cell);
value = *(cell *)(data+(int)value); value = *(cell *)(data + (int)value);
*b++ = static_cast<char>(value); *b++ = static_cast<char>(value);
} while (value); } while (value);
return buffer[swap]; 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 buffer[2][3072];
static char format[16]; static char format[16];
char *ptr,*arg, *dest = *buffer; char *ptr, *arg, *dest = *buffer;
char *src = fo_getargstr(amx, 0,parm++); char *src = fo_getargstr(amx, 0, parm++);
int numparam = fo_numargs(amx); int numparam = fo_numargs(amx);
while(*src) {
if (*src=='%'&&*(src+1)) { while (*src)
{
if (*src == '%' && *(src + 1))
{
ptr = format; ptr = format;
*ptr++ = *src++; *ptr++ = *src++;
if (*src=='%'){
*dest++=*src++; if (*src == '%')
{
*dest++ = *src++;
continue; continue;
} }
while (!isalpha(*ptr++=*src++))
; while (!isalpha(*ptr++ = *src++));
*ptr='\0'; *ptr='\0';
if (numparam < parm) continue; if (numparam < parm) continue;
arg = buffer[1]; arg = buffer[1];
switch(*(ptr-1)){
case 's': sprintf(arg,format,fo_getargstr(amx,1, parm++)); break; switch (*(ptr - 1))
case 'f': case 'g': sprintf(arg,format,fo_getargfloat(amx, parm++)); break; {
default: sprintf(arg,format,fo_getargnum(amx, parm++)); 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; continue;
} }
*dest++=*src++; *dest++ = *src++;
} }
*dest='\0';
*dest = '\0';
len = dest - *buffer; len = dest - *buffer;
return *buffer; return *buffer;
} }
@ -522,16 +608,17 @@ static cell AMX_NATIVE_CALL amx_strtok(AMX *amx, cell *params)
//string[] //string[]
char *string = get_amxstring(amx, params[1], 0, len); char *string = get_amxstring(amx, params[1], 0, len);
//left[] //left[]
char *left = new char[len+1]; char *left = new char[len + 1];
//right[] //right[]
char *right = new char[len+1]; char *right = new char[len + 1];
int leftMax = params[3]; int leftMax = params[3];
int rightMax = params[5]; int rightMax = params[5];
//token //token
char token = static_cast<char>(params[6]); char token = static_cast<char>(params[6]);
//trim //trim
int trim = params[7]; int trim = params[7];
for (i=0; i<(unsigned int)len; i++)
for (i = 0; i < (unsigned int)len; i++)
{ {
if (trim && !done_flag) if (trim && !done_flag)
{ {
@ -541,11 +628,13 @@ static cell AMX_NATIVE_CALL amx_strtok(AMX *amx, cell *params)
done_flag = true; done_flag = true;
} }
} }
if (!done_flag && string[i] == token) if (!done_flag && string[i] == token)
{ {
done_flag = true; done_flag = true;
i++; i++;
} }
if (done_flag) if (done_flag)
{ {
right[right_pos++] = string[i]; 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]; left[left_pos++] = string[i];
} }
} }
right[right_pos] = 0; right[right_pos] = 0;
left[left_pos] = 0; left[left_pos] = 0;
set_amxstring(amx, params[2], left, leftMax); set_amxstring(amx, params[2], left, leftMax);
set_amxstring(amx, params[4], right, rightMax); set_amxstring(amx, params[4], right, rightMax);
delete [] left; delete [] left;
delete [] right; delete [] right;
return 1; return 1;
} }
@ -571,46 +662,63 @@ static cell AMX_NATIVE_CALL strbreak(AMX *amx, cell *params) /* 5 param */
bool done_flag = false; bool done_flag = false;
int left_pos = 0; int left_pos = 0;
int right_pos = 0; int right_pos = 0;
int l=0; int l = 0;
unsigned int i=0; unsigned int i = 0;
char hold = '"'; char hold = '"';
char *string = get_amxstring(amx, params[1], 0, l); char *string = get_amxstring(amx, params[1], 0, l);
char *left = new char[strlen(string)+1]; char *left = new char[strlen(string) + 1];
char *right = new char[strlen(string)+1]; char *right = new char[strlen(string) + 1];
int LeftMax = params[3]; int LeftMax = params[3];
int RightMax = params[5]; int RightMax = params[5];
for (i=0; i<(unsigned int)l; i++) { for (i = 0; i < (unsigned int)l; i++)
if (string[i] == '"' && !quote_flag) { {
if (string[i] == '"' && !quote_flag)
{
quote_flag = true; quote_flag = true;
} else if (string[i] == '"' && quote_flag) { }
else if (string[i] == '"' && quote_flag)
{
quote_flag = false; quote_flag = false;
} }
if (isspace(string[i]) && !quote_flag && !done_flag) {
if (isspace(string[i]) && !quote_flag && !done_flag)
{
done_flag = true; done_flag = true;
i++; i++;
} }
if (!done_flag && string[i]!='"') {
if (left_pos < LeftMax) { if (!done_flag && string[i]!='"')
{
if (left_pos < LeftMax)
{
left[left_pos] = string[i]; left[left_pos] = string[i];
if (left[left_pos] == '\'') {
if (left[left_pos] == '\'')
{
left[left_pos] = hold; left[left_pos] = hold;
} }
left_pos++; left_pos++;
} else { } else {
done_flag = true; done_flag = true;
} }
} else { } else {
if (right_pos < RightMax && string[i]!='"') { if (right_pos < RightMax && string[i]!='"')
{
right[right_pos] = string[i]; right[right_pos] = string[i];
if (right[right_pos] == '\'') {
if (right[right_pos] == '\'')
{
right[right_pos] = hold; right[right_pos] = hold;
} }
right_pos++; right_pos++;
} }
} }
} }
left[left_pos] = '\0'; left[left_pos] = '\0';
right[right_pos] = '\0'; right[right_pos] = '\0';
set_amxstring(amx, params[2], left, params[3]); 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 len;
int pos = params[3]; int pos = params[3];
if (pos < 0){
amx_RaiseError(amx,AMX_ERR_NATIVE); if (pos < 0)
{
amx_RaiseError(amx, AMX_ERR_NATIVE);
return 0; 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) 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) 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) 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) 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) static cell AMX_NATIVE_CALL amx_ucfirst(AMX *amx, cell *params)
{ {
int len = 0; int len = 0;
cell *str = get_amxaddr(amx, params[1]); 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; return 0;
str[0] &= ~(1<<5); str[0] &= ~(1<<5);
return 1; return 1;
} }
@ -679,7 +792,8 @@ static cell AMX_NATIVE_CALL amx_trim(AMX *amx, cell *params)
while (*cptr++) len++; while (*cptr++) len++;
int flag = 0, incr = 0; int flag = 0, incr = 0;
register int i = 0; register int i = 0;
for (i=len-1; i>=0; i--)
for (i = len - 1; i >= 0; i--)
{ {
if (!isspace(asdf[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) if (isspace(asdf[i]) && !flag)
{ {
incr++; incr++;
if (incr+i<len) if (incr + i < len)
asdf[i] = asdf[incr+i]; asdf[i] = asdf[incr + i];
} else { } else {
if (!flag) if (!flag)
flag = 1; flag = 1;
@ -709,20 +823,23 @@ static cell AMX_NATIVE_CALL amx_trim(AMX *amx, cell *params)
return incr; 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]); cdest = get_amxaddr(amx, params[1]);
csrc = get_amxaddr(amx, params[2]); csrc = get_amxaddr(amx, params[2]);
int num = params[3]; int num = params[3];
while (*cdest && num) while (*cdest && num)
{ {
cdest++; cdest++;
num--; num--;
} }
if (!num) if (!num)
return 0; return 0;
while (*csrc && num) while (*csrc && num)
{ {
*cdest++ = *csrc++; *cdest++ = *csrc++;
@ -754,22 +871,25 @@ static cell AMX_NATIVE_CALL n_strfind(AMX *amx, cell *params)
bool found = false; bool found = false;
bool igcase = params[3] ? true : false; bool igcase = params[3] ? true : false;
if (igcase) if (igcase)
{ {
for (int i=0; i<len; i++) for (int i = 0; i < len; i++)
{ {
if (str[i] & (1<<5)) if (str[i] & (1<<5))
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)) if (str[i] & (1<<5))
str[i] &= ~(1<<5); str[i] &= ~(1<<5);
} }
} }
if (params[4] > len) if (params[4] > len)
return -1; return -1;
char *pos = &(str[ params[4] ]);
char *pos = &(str[params[4]]);
char *find = strstr(str, sub); char *find = strstr(str, sub);
if (!find) if (!find)
@ -778,39 +898,39 @@ static cell AMX_NATIVE_CALL n_strfind(AMX *amx, cell *params)
return (find - str); return (find - str);
} }
AMX_NATIVE_INFO string_Natives[] = { AMX_NATIVE_INFO string_Natives[] =
{ "add", add }, {
{ "contain", contain }, {"add", add},
{ "containi", containi }, {"contain", contain},
{ "copy", copy }, {"containi", containi},
{ "copyc", copyc }, {"copy", copy},
{ "equal", equal }, {"copyc", copyc},
{ "equali", equali }, {"equal", equal},
{ "format", format }, {"equali", equali},
{ "format_args", format_args }, {"format", format},
{ "isdigit", is_digit }, {"format_args", format_args},
{ "isalnum", is_alnum }, {"isdigit", is_digit},
{ "isspace", is_space }, {"isalnum", is_alnum},
{ "isalpha", is_alpha }, {"isspace", is_space},
{ "num_to_str", numtostr }, {"isalpha", is_alpha},
{ "numtostr", numtostr }, {"num_to_str", numtostr},
{ "parse", parse }, {"numtostr", numtostr},
{ "replace", replace }, {"parse", parse},
{ "setc", setc }, {"replace", replace},
{ "strbreak", strbreak}, {"setc", setc},
{ "strtolower", strtolower }, {"strbreak", strbreak},
{ "strtoupper", strtoupper }, {"strtolower", strtolower},
{ "str_to_num", strtonum }, {"strtoupper", strtoupper},
{ "strtonum", strtonum }, {"str_to_num", strtonum},
{ "trim", amx_trim }, {"strtonum", strtonum},
{ "ucfirst", amx_ucfirst }, {"trim", amx_trim},
{ "strtok", amx_strtok }, {"ucfirst", amx_ucfirst},
{ "strlen", amx_strlen }, {"strtok", amx_strtok},
{ "strcat", n_strcat }, {"strlen", amx_strlen},
{ "strfind", n_strfind }, {"strcat", n_strcat},
{ "strcmp", n_strcmp }, {"strfind", n_strfind},
{ "str_to_float", str_to_float }, {"strcmp", n_strcmp},
{ "float_to_str", float_to_str }, {"str_to_float", str_to_float},
{"float_to_str", float_to_str},
{ NULL, NULL } {NULL, NULL }
}; };

View File

@ -30,11 +30,10 @@
*/ */
#include <time.h> #include <time.h>
#include "amxmodx.h" #include "amxmodx.h"
#ifdef __linux__ #ifdef __linux__
#define _vsnprintf vsnprintf #define _vsnprintf vsnprintf
#endif #endif
char *UTIL_VarArgs(const char *fmt, ...) char *UTIL_VarArgs(const char *fmt, ...)
@ -52,40 +51,47 @@ char *UTIL_VarArgs(const char *fmt, ...)
int UTIL_ReadFlags(const char* c) int UTIL_ReadFlags(const char* c)
{ {
int flags = 0; int flags = 0;
while (*c) flags |= ( 1 << ( *c++ - 'a' ) );
while (*c)
flags |= (1<<(*c++ - 'a'));
return flags; return flags;
} }
void UTIL_GetFlags(char* f,int a) void UTIL_GetFlags(char* f, int a)
{ {
for(int i='a';i<='z';++i){ for (int i = 'a'; i <= 'z'; ++i)
if ( a & 1 ) *f++ = i; {
if (a & 1) *f++ = i;
a >>= 1; a >>= 1;
} }
*f = 0; *f = 0;
} }
/* warning - don't pass here const string */ /* 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 *n = menu;
char c = 0; char c = 0;
int a; int a;
if (!gmsgShowMenu) if (!gmsgShowMenu)
return; // some games don't support ShowMenu (Firearms) return; // some games don't support ShowMenu (Firearms)
while ( *n ) { while (*n)
{
a = mlen; a = mlen;
if ( a > 175 ) a = 175; if (a > 175) a = 175;
mlen -= a; mlen -= a;
c = *(n+=a); c = *(n+=a);
*n = 0; *n = 0;
MESSAGE_BEGIN( MSG_ONE , gmsgShowMenu, NULL, pEdict );
WRITE_SHORT( slots ); MESSAGE_BEGIN(MSG_ONE, gmsgShowMenu, NULL, pEdict);
WRITE_CHAR( time ); WRITE_SHORT(slots);
WRITE_BYTE( c ? TRUE : FALSE); WRITE_CHAR(time);
WRITE_STRING( menu ); WRITE_BYTE(c ? TRUE : FALSE);
WRITE_STRING(menu);
MESSAGE_END(); MESSAGE_END();
*n = c; *n = c;
menu = n; 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 */ /* 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) if (!gmsgMOTD)
return; // :TODO: Maybe output a warning log? return; // :TODO: Maybe output a warning log?
if (gmsgServerName) if (gmsgServerName)
{ {
MESSAGE_BEGIN( MSG_ONE , gmsgServerName, NULL, client ); MESSAGE_BEGIN(MSG_ONE, gmsgServerName, NULL, client);
WRITE_STRING(name); WRITE_STRING(name);
MESSAGE_END(); MESSAGE_END();
} }
@ -109,15 +115,17 @@ void UTIL_ShowMOTD( edict_t *client , char *motd, int mlen, const char *name)
char c = 0; char c = 0;
int a; int a;
while ( *n ) { while (*n)
{
a = mlen; a = mlen;
if ( a > 175 ) a = 175; if (a > 175) a = 175;
mlen -= a; mlen -= a;
c = *(n+=a); c = *(n += a);
*n = 0; *n = 0;
MESSAGE_BEGIN( MSG_ONE , gmsgMOTD, NULL, client );
WRITE_BYTE( c ? FALSE : TRUE ); MESSAGE_BEGIN(MSG_ONE, gmsgMOTD, NULL, client);
WRITE_STRING( motd ); WRITE_BYTE(c ? FALSE : TRUE);
WRITE_STRING(motd);
MESSAGE_END(); MESSAGE_END();
*n = c; *n = c;
motd = n; motd = n;
@ -125,42 +133,52 @@ void UTIL_ShowMOTD( edict_t *client , char *motd, int mlen, const char *name)
if (gmsgServerName) if (gmsgServerName)
{ {
MESSAGE_BEGIN( MSG_ONE , gmsgServerName, NULL, client ); MESSAGE_BEGIN(MSG_ONE, gmsgServerName, NULL, client);
WRITE_STRING( hostname->string ); WRITE_STRING(hostname->string);
MESSAGE_END(); MESSAGE_END();
} }
} }
void UTIL_IntToString(int value, char *output) 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 ", "five ", "six ","seven ","eight ","nine ","ten ",
"eleven ","twelve ","thirteen ","fourteen ","fifteen ", "eleven ","twelve ","thirteen ","fourteen ","fifteen ",
"sixteen ","seventeen ","eighteen ","nineteen ", "sixteen ","seventeen ","eighteen ","nineteen ",
"twenty ","thirty ","fourty ", "fifty ","sixty ", "twenty ","thirty ","fourty ", "fifty ","sixty ",
"seventy ","eighty ","ninety ", "seventy ","eighty ","ninety ",
"hundred ","thousand "}; "hundred ","thousand "};
*output = 0; *output = 0;
if (value < 0) value = -value; if (value < 0) value = -value;
int tho = value / 1000; int tho = value / 1000;
int aaa = 0; int aaa = 0;
if (tho){
aaa += sprintf(&output[aaa], words[ tho ] ); if (tho)
aaa += sprintf(&output[aaa], words[29] ); {
aaa += sprintf(&output[aaa], words[tho]);
aaa += sprintf(&output[aaa], words[29]);
value = value % 1000; value = value % 1000;
} }
int hun = value / 100; int hun = value / 100;
if (hun) {
aaa += sprintf(&output[aaa], words[ hun ] ); if (hun)
aaa += sprintf(&output[aaa], words[28] ); {
aaa += sprintf(&output[aaa], words[hun]);
aaa += sprintf(&output[aaa], words[28]);
value = value % 100; value = value % 100;
} }
int ten = value / 10; int ten = value / 10;
int unit = value % 10; int unit = value % 10;
if ( ten )
aaa += sprintf(&output[aaa], words[ ( ten > 1 ) ? ( ten + 18 ) : ( unit + 10 ) ] ); if (ten)
if ( ten != 1 && ( unit || (!value && !hun && !tho) ) ) aaa += sprintf(&output[aaa], words[(ten > 1) ? (ten + 18) : (unit + 10)]);
sprintf(&output[aaa], words[ unit ] );
if (ten != 1 && (unit || (!value && !hun && !tho)))
sprintf(&output[aaa], words[unit]);
} }
char* UTIL_SplitHudMessage(const char *src) char* UTIL_SplitHudMessage(const char *src)
@ -168,50 +186,57 @@ char* UTIL_SplitHudMessage(const char *src)
static char message[512]; static char message[512];
short b = 0, d = 0, e = 0, c = -1; short b = 0, d = 0, e = 0, c = -1;
while ( src[ d ] && e < 480 ) { while (src[d] && e < 480)
if ( src[ d ] == ' ' ) { {
if (src[d] == ' ')
{
c = e; c = e;
} }
else if ( src[ d ] == '\n' ) { else if (src[d] == '\n')
{
c = -1; c = -1;
b = 0; b = 0;
} }
message[ e++ ] = src[ d++ ];
if ( ++b == 69 ) { message[e++] = src[d++];
if ( c == -1 ) {
message[ e++ ] = '\n'; if (++b == 69)
{
if (c == -1)
{
message[e++] = '\n';
b = 0; b = 0;
} } else {
else { message[c] = '\n';
message[ c ] = '\n';
b = e - c - 1; b = e - c - 1;
c = -1; c = -1;
} }
} }
} }
message[ e ] = 0;
message[e] = 0;
return message; return message;
} }
unsigned short FixedUnsigned16( float value, float scale ) unsigned short FixedUnsigned16(float value, float scale)
{ {
int output = (int)(value * scale); int output = (int)(value * scale);
if ( output < 0 ) if (output < 0)
output = 0; output = 0;
else if ( output > 0xFFFF ) else if (output > 0xFFFF)
output = 0xFFFF; output = 0xFFFF;
return (unsigned short)output; return (unsigned short)output;
} }
short FixedSigned16( float value, float scale ) short FixedSigned16(float value, float scale)
{ {
int output = (int)(value * scale); int output = (int)(value * scale);
if ( output > 32767 ) if (output > 32767)
output = 32767; output = 32767;
else if ( output < -32768 ) else if (output < -32768)
output = -32768; output = -32768;
return (short)output; 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) void UTIL_HudMessage(edict_t *pEntity, const hudtextparms_t &textparms, char *pMessage)
{ {
if ( pEntity ) if (pEntity)
MESSAGE_BEGIN( MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, NULL, pEntity ); MESSAGE_BEGIN(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, NULL, pEntity);
else else
MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); MESSAGE_BEGIN(MSG_BROADCAST, SVC_TEMPENTITY);
WRITE_BYTE(29); WRITE_BYTE(29);
WRITE_BYTE(textparms.channel & 0xFF); WRITE_BYTE(textparms.channel & 0xFF);
WRITE_SHORT(FixedSigned16(textparms.x, (1<<13) )); WRITE_SHORT(FixedSigned16(textparms.x, (1<<13)));
WRITE_SHORT(FixedSigned16(textparms.y, (1<<13) )); WRITE_SHORT(FixedSigned16(textparms.y, (1<<13)));
WRITE_BYTE(textparms.effect); WRITE_BYTE(textparms.effect);
WRITE_BYTE(textparms.r1); WRITE_BYTE(textparms.r1);
WRITE_BYTE(textparms.g1); 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(255);
WRITE_BYTE(250); WRITE_BYTE(250);
WRITE_BYTE(0); WRITE_BYTE(0);
WRITE_SHORT(FixedUnsigned16(textparms.fadeinTime, (1<<8) )); WRITE_SHORT(FixedUnsigned16(textparms.fadeinTime, (1<<8)));
WRITE_SHORT(FixedUnsigned16(textparms.fadeoutTime, (1<<8) )); WRITE_SHORT(FixedUnsigned16(textparms.fadeoutTime, (1<<8)));
WRITE_SHORT(FixedUnsigned16(textparms.holdTime, (1<<8) )); WRITE_SHORT(FixedUnsigned16(textparms.holdTime, (1<<8)));
if (textparms.effect==2)
WRITE_SHORT(FixedUnsigned16(textparms.fxTime, (1<<8) ) ); if (textparms.effect == 2)
WRITE_SHORT(FixedUnsigned16(textparms.fxTime, (1<<8)));
WRITE_STRING(pMessage); WRITE_STRING(pMessage);
MESSAGE_END(); MESSAGE_END();
} }
/* warning - buffer of msg must be longer than 190 chars! /* warning - buffer of msg must be longer than 190 chars!
(here in AMX it is always longer) */ (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) if (!gmsgTextMsg)
return; // :TODO: Maybe output a warning log? return; // :TODO: Maybe output a warning log?
char c = msg[190]; char c = msg[190];
msg[190] = 0; // truncate without checking with strlen() msg[190] = 0; // truncate without checking with strlen()
if ( pEntity )
MESSAGE_BEGIN( MSG_ONE, gmsgTextMsg, NULL, pEntity ); if (pEntity)
MESSAGE_BEGIN(MSG_ONE, gmsgTextMsg, NULL, pEntity);
else else
MESSAGE_BEGIN( MSG_BROADCAST , gmsgTextMsg); MESSAGE_BEGIN(MSG_BROADCAST, gmsgTextMsg);
WRITE_BYTE( msg_dest );
WRITE_STRING( msg ); WRITE_BYTE(msg_dest);
WRITE_STRING(msg);
MESSAGE_END(); MESSAGE_END();
msg[190] = c; 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) void UTIL_FakeClientCommand(edict_t *pEdict, const char *cmd, const char *arg1, const char *arg2)
{ {
if (!cmd) if (!cmd)
return; // no command return; // no command
// store command // store command
g_fakecmd.argv[0] = cmd; g_fakecmd.argv[0] = cmd;
@ -304,7 +333,7 @@ void UTIL_FakeClientCommand(edict_t *pEdict, const char *cmd, const char *arg1,
// store argument // store argument
g_fakecmd.argv[1] = arg1; g_fakecmd.argv[1] = arg1;
// build argument line // 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 // if snprintf reached 255 chars limit, this will make sure there will be no access violation
g_fakecmd.args[255] = 0; g_fakecmd.args[255] = 0;
} }

View File

@ -34,52 +34,49 @@
Vault g_vault; 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.put(get_amxstring(amx, params[1], 0, iLen), get_amxstring(amx, params[2], 1, iLen));
g_vault.saveVault(); 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 g_vault.get_number(key);
return set_amxstring( amx , params[2] , g_vault.get( key ) , params[3] );
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.remove(get_amxstring(amx, params[1], 0, iLen));
g_vault.saveVault(); 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; int iLen;
return g_vault.exists(get_amxstring(amx, params[1], 0, iLen)) ? 1 : 0;
return g_vault.exists( get_amxstring(amx,params[1],0,iLen) ) ? 1 : 0;
} }
AMX_NATIVE_INFO vault_Natives[] = { AMX_NATIVE_INFO vault_Natives[] =
{ "set_vaultdata", set_vaultdata }, {
{ "get_vaultdata", get_vaultdata }, {"set_vaultdata", set_vaultdata},
{ "remove_vaultdata", remove_vaultdata }, {"get_vaultdata", get_vaultdata},
{ "delete_vaultdata", remove_vaultdata }, {"remove_vaultdata", remove_vaultdata},
{ "vaultdata_exists", vaultdata_exists }, {"delete_vaultdata", remove_vaultdata},
{ 0, 0 } {"vaultdata_exists", vaultdata_exists},
{0, 0}
}; };