latest cleaned files for today (i cant read more :o )

This commit is contained in:
Borja Ferrer 2005-09-10 03:39:23 +00:00
parent 16ad8739e7
commit 52b1d67ca2
5 changed files with 598 additions and 465 deletions

View File

@ -35,7 +35,9 @@
// ***************************************************** // *****************************************************
// class CmdMngr // class CmdMngr
// ***************************************************** // *****************************************************
CmdMngr::CmdMngr() {
CmdMngr::CmdMngr()
{
memset(sortedlists, 0, sizeof(sortedlists)); memset(sortedlists, 0, sizeof(sortedlists));
srvcmdlist = 0; srvcmdlist = 0;
clcmdlist = 0; clcmdlist = 0;
@ -49,10 +51,9 @@ CmdMngr::CmdMngr() {
} }
CmdMngr::Command::Command( CPluginMngr::CPlugin* pplugin,const char* pcmd, CmdMngr::Command::Command(CPluginMngr::CPlugin* pplugin, const char* pcmd, const char* pinfo, int pflags,
const char* pinfo , int pflags , int pfunc, int pfunc, bool pviewable, CmdMngr* pparent) : commandline(pcmd), info(pinfo)
bool pviewable, CmdMngr* pparent ) : commandline(pcmd) , info(pinfo) { {
char szCmd[64], szArg[64]; char szCmd[64], szArg[64];
*szCmd = 0; *szArg = 0; *szCmd = 0; *szArg = 0;
sscanf(pcmd, "%s %s", szCmd, szArg); sscanf(pcmd, "%s %s", szCmd, szArg);
@ -78,17 +79,21 @@ CmdMngr::Command* CmdMngr::registerCommand( CPluginMngr::CPlugin* plugin , int
Command* b = new Command(plugin, cmd, info, level, func, listable, this); Command* b = new Command(plugin, cmd, info, level, func, listable, this);
if (b == 0) return 0; if (b == 0) return 0;
setCmdLink(&sortedlists[0], b); setCmdLink(&sortedlists[0], b);
return b; return b;
} }
CmdMngr::Command* CmdMngr::getCmd(long int id, int type, int access) CmdMngr::Command* CmdMngr::getCmd(long int id, int type, int access)
{ {
//if (id >= 1024 || id < 0) return (Command*)id; //if (id >= 1024 || id < 0) return (Command*)id;
if ( id < 0 ){ if (id < 0)
for (CmdMngr::iterator a = begin( type ); a ; ++a){ {
for (CmdMngr::iterator a = begin(type); a ; ++a)
{
if ((*a).id == id) if ((*a).id == id)
return &(*a); return &(*a);
} }
return 0; return 0;
} }
@ -98,9 +103,7 @@ CmdMngr::Command* CmdMngr::getCmd( long int id ,int type, int access )
buf_cmdaccess = access; buf_cmdaccess = access;
buf_cmdtype = type; buf_cmdtype = type;
buf_cmdid = id; buf_cmdid = id;
} } else {
else
{
int a = id; int a = id;
id -= buf_cmdid; id -= buf_cmdid;
buf_cmdid = a; buf_cmdid = a;
@ -108,17 +111,12 @@ 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);
} }
++buf_cmdptr; ++buf_cmdptr;
} }
@ -138,10 +136,7 @@ int CmdMngr::getCmdNum( int type, int access )
while (a) while (a)
{ {
if ((*a).gotAccess(access) && (*a).getPlugin()->isExecutable((*a).getFunction()) && (*a).isViewable())
if ( (*a).gotAccess( access ) &&
(*a).getPlugin()->isExecutable( (*a).getFunction() )
&& (*a).isViewable() )
++buf_num; ++buf_num;
++a; ++a;
} }
@ -169,20 +164,18 @@ void CmdMngr::setCmdLink( CmdLink** a , Command* c, bool sorted )
np->next = *a; np->next = *a;
*a = np; *a = np;
} } else {
else
{
while (*a) a = &(*a)->next; while (*a) a = &(*a)->next;
*a = np; *a = np;
} }
} }
void CmdMngr::clearCmdLink(CmdLink** phead, bool pclear) void CmdMngr::clearCmdLink(CmdLink** phead, bool pclear)
{ {
while( *phead ){ while (*phead)
{
CmdLink* pp = (*phead)->next; CmdLink* pp = (*phead)->next;
if (pclear) delete (*phead)->cmd; if (pclear) delete (*phead)->cmd;
delete *phead; delete *phead;
*phead = pp; *phead = pp;
@ -191,39 +184,50 @@ 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;
case CMD_ServerCommand: cmdtype |= 2; break; case CMD_ServerCommand: cmdtype |= 2; break;
} }
if ( cmdtype & 1 ) { // ClientCommand
if (cmdtype & 1) // ClientCommand
{
parent->setCmdLink(&parent->sortedlists[1], this); parent->setCmdLink(&parent->sortedlists[1], this);
if (!parent->registerCmdPrefix(this)) if (!parent->registerCmdPrefix(this))
parent->setCmdLink(&parent->clcmdlist, this, false); parent->setCmdLink(&parent->clcmdlist, this, false);
} }
if ( cmdtype & 2 ) { // ServerCommand
if (cmdtype & 2) // ServerCommand
{
parent->setCmdLink(&parent->sortedlists[2], this); parent->setCmdLink(&parent->sortedlists[2], this);
parent->setCmdLink(&parent->srvcmdlist, this, false); parent->setCmdLink(&parent->srvcmdlist, this, false);
} }
} }
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";
case 3: return "console"; case 3: return "console";
} }
return "unknown"; return "unknown";
} }
bool CmdMngr::registerCmdPrefix(Command* cc) bool CmdMngr::registerCmdPrefix(Command* cc)
{ {
CmdPrefix** b = findPrefix(cc->getCommand()); CmdPrefix** b = findPrefix(cc->getCommand());
if (*b){
if (*b)
{
setCmdLink(&(*b)->list, cc, false); setCmdLink(&(*b)->list, cc, false);
cc->prefix = (*b)->name.size(); cc->prefix = (*b)->name.size();
return true; return true;
} }
return false; return false;
} }
@ -231,22 +235,29 @@ void CmdMngr::registerPrefix( const char* nn )
{ {
if (*nn == 0) return; if (*nn == 0) return;
CmdPrefix** b = findPrefix(nn); CmdPrefix** b = findPrefix(nn);
if (*b) return; if (*b) return;
*b = new CmdPrefix(nn, this); *b = new CmdPrefix(nn, this);
} }
CmdMngr::CmdPrefix** CmdMngr::findPrefix( const char* nn ){ CmdMngr::CmdPrefix** CmdMngr::findPrefix(const char* nn)
{
CmdPrefix** aa = &prefixHead; CmdPrefix** aa = &prefixHead;
while(*aa){
while (*aa)
{
if (!strncmp((*aa)->name.c_str(), nn, (*aa)->name.size())) if (!strncmp((*aa)->name.c_str(), nn, (*aa)->name.size()))
break; break;
aa = &(*aa)->next; aa = &(*aa)->next;
} }
return aa; return aa;
} }
void CmdMngr::clearPrefix(){ void CmdMngr::clearPrefix()
while(prefixHead){ {
while (prefixHead)
{
CmdPrefix* a = prefixHead->next; CmdPrefix* a = prefixHead->next;
delete prefixHead; delete prefixHead;
prefixHead = a; prefixHead = a;
@ -264,7 +275,8 @@ void CmdMngr::clear()
clearBufforedInfo(); clearBufforedInfo();
} }
void CmdMngr::clearBufforedInfo() { void CmdMngr::clearBufforedInfo()
{
buf_type = -1; buf_type = -1;
buf_access = 0; buf_access = 0;
buf_id = -1; buf_id = -1;
@ -274,4 +286,3 @@ void CmdMngr::clearBufforedInfo() {
} }
int CmdMngr::Command::uniqueid = 0; int CmdMngr::Command::uniqueid = 0;

View File

@ -48,6 +48,7 @@ EventsMngr::ClEvent::ClEvent(CPluginMngr::CPlugin* plugin, int func, int flags)
m_FlagWorld = (flags & 1) ? true : false; // flag a m_FlagWorld = (flags & 1) ? true : false; // flag a
m_FlagPlayer = (flags & 2) ? true : false; // flag b m_FlagPlayer = (flags & 2) ? true : false; // flag b
m_FlagOnce = (flags & 4) ? true : false; // flag c m_FlagOnce = (flags & 4) ? true : false; // flag c
if (flags & 24) if (flags & 24)
{ {
m_FlagAlive = (flags & 16) ? true : false; // flag e m_FlagAlive = (flags & 16) ? true : false; // flag e
@ -64,12 +65,14 @@ EventsMngr::ClEvent::~ClEvent()
{ {
cond_t *tmp1 = m_Conditions; cond_t *tmp1 = m_Conditions;
cond_t *tmp2 = NULL; cond_t *tmp2 = NULL;
while (tmp1) while (tmp1)
{ {
tmp2 = tmp1->next; tmp2 = tmp1->next;
delete tmp1; delete tmp1;
tmp1 = tmp2; tmp1 = tmp2;
} }
m_Conditions = NULL; m_Conditions = NULL;
} }
@ -82,14 +85,17 @@ void EventsMngr::NextParam()
MsgDataEntry *tmp = NULL; MsgDataEntry *tmp = NULL;
int tmpSize = 0; int tmpSize = 0;
if (m_ParseVault) if (m_ParseVault)
{ {
// copy to tmp // copy to tmp
tmp = new MsgDataEntry[m_ParseVaultSize]; tmp = new MsgDataEntry[m_ParseVaultSize];
if (!tmp) if (!tmp)
{ {
return; // :TODO: Error report !! return; // :TODO: Error report !!
} }
memcpy(tmp, m_ParseVault, m_ParseVaultSize * sizeof(MsgDataEntry)); memcpy(tmp, m_ParseVault, m_ParseVaultSize * sizeof(MsgDataEntry));
tmpSize = m_ParseVaultSize; tmpSize = m_ParseVaultSize;
delete [] m_ParseVault; delete [] m_ParseVault;
@ -102,6 +108,7 @@ void EventsMngr::NextParam()
m_ParseVaultSize = INITIAL_PARSEVAULT_SIZE; m_ParseVaultSize = INITIAL_PARSEVAULT_SIZE;
m_ParseVault = new MsgDataEntry[m_ParseVaultSize]; m_ParseVault = new MsgDataEntry[m_ParseVaultSize];
if (tmp) if (tmp)
{ {
memcpy(m_ParseVault, tmp, tmpSize * sizeof(MsgDataEntry)); memcpy(m_ParseVault, tmp, tmpSize * sizeof(MsgDataEntry));
@ -178,10 +185,11 @@ void EventsMngr::ClEvent::registerFilter(char *filter)
if (m_Conditions) if (m_Conditions)
{ {
cond_t *tmp = m_Conditions; cond_t *tmp = m_Conditions;
while (tmp->next) while (tmp->next)
tmp = tmp->next; tmp = tmp->next;
tmp->next = tmpCond;
tmp->next = tmpCond;
} }
else else
m_Conditions = tmpCond; m_Conditions = tmpCond;
@ -194,6 +202,7 @@ EventsMngr::ClEvent* EventsMngr::registerEvent(CPluginMngr::CPlugin* plugin, int
return NULL; return NULL;
ClEvent *event = new ClEvent(plugin, func, flags); ClEvent *event = new ClEvent(plugin, func, flags);
if (!event) if (!event)
return NULL; return NULL;
@ -221,7 +230,6 @@ void EventsMngr::parserInit(int msg_type, float* timer, CPlayer* pPlayer, int in
if ((*iter).m_Done) if ((*iter).m_Done)
continue; continue;
if (!(*iter).m_Plugin->isExecutable((*iter).m_Func)) if (!(*iter).m_Plugin->isExecutable((*iter).m_Func))
{ {
(*iter).m_Done = true; (*iter).m_Done = true;
@ -247,6 +255,7 @@ void EventsMngr::parserInit(int msg_type, float* timer, CPlayer* pPlayer, int in
(*iter).m_Done = true; (*iter).m_Done = true;
continue; continue;
} }
m_ParseNotDone = true; m_ParseNotDone = true;
} }
@ -257,6 +266,7 @@ void EventsMngr::parserInit(int msg_type, float* timer, CPlayer* pPlayer, int in
m_ParseVault[0].type = MSG_INTEGER; m_ParseVault[0].type = MSG_INTEGER;
m_ParseVault[0].iValue = index; m_ParseVault[0].iValue = index;
} }
m_ParseFun = &m_Events[msg_type]; m_ParseFun = &m_Events[msg_type];
} }
@ -266,7 +276,6 @@ void EventsMngr::parseValue(int iValue)
if (!m_ParseNotDone || !m_ParseFun) if (!m_ParseNotDone || !m_ParseFun)
return; return;
// grow if needed // grow if needed
++m_ParsePos; ++m_ParsePos;
NextParam(); NextParam();
@ -284,6 +293,7 @@ void EventsMngr::parseValue(int iValue)
// loop through conditions // loop through conditions
bool execute = false; bool execute = false;
bool anyConditions = false; bool anyConditions = false;
for (ClEvent::cond_t *condIter = (*iter).m_Conditions; condIter; condIter = condIter->next) for (ClEvent::cond_t *condIter = (*iter).m_Conditions; condIter; condIter = condIter->next)
{ {
if (condIter->paramId == m_ParsePos) if (condIter->paramId == m_ParsePos)
@ -312,7 +322,6 @@ void EventsMngr::parseValue(float fValue)
if (!m_ParseNotDone || !m_ParseFun) if (!m_ParseNotDone || !m_ParseFun)
return; return;
// grow if needed // grow if needed
++m_ParsePos; ++m_ParsePos;
NextParam(); NextParam();
@ -330,6 +339,7 @@ void EventsMngr::parseValue(float fValue)
// loop through conditions // loop through conditions
bool execute = false; bool execute = false;
bool anyConditions = false; bool anyConditions = false;
for (ClEvent::cond_t *condIter = (*iter).m_Conditions; condIter; condIter = condIter->next) for (ClEvent::cond_t *condIter = (*iter).m_Conditions; condIter; condIter = condIter->next)
{ {
if (condIter->paramId == m_ParsePos) if (condIter->paramId == m_ParsePos)
@ -374,6 +384,7 @@ void EventsMngr::parseValue(const char *sz)
// loop through conditions // loop through conditions
bool execute = false; bool execute = false;
bool anyConditions = false; bool anyConditions = false;
for (ClEvent::cond_t *condIter = (*iter).m_Conditions; condIter; condIter = condIter->next) for (ClEvent::cond_t *condIter = (*iter).m_Conditions; condIter; condIter = condIter->next)
{ {
if (condIter->paramId == m_ParsePos) if (condIter->paramId == m_ParsePos)
@ -408,6 +419,7 @@ void EventsMngr::executeEvents()
(*iter).m_Done = false; (*iter).m_Done = false;
continue; continue;
} }
(*iter).m_Stamp = (float)*m_Timer; (*iter).m_Stamp = (float)*m_Timer;
executeForwards((*iter).m_Func, m_ParseVault ? m_ParseVault[0].iValue : 0); executeForwards((*iter).m_Func, m_ParseVault ? m_ParseVault[0].iValue : 0);
} }
@ -479,6 +491,7 @@ void EventsMngr::clearEvents(void)
{ {
m_Events[i].clear(); m_Events[i].clear();
} }
// delete parsevault // delete parsevault
if (m_ParseVault) if (m_ParseVault)
{ {
@ -506,6 +519,7 @@ int EventsMngr::getEventId(const char* msg)
// if msg is a number, return it // if msg is a number, return it
int pos = atoi(msg); int pos = atoi(msg);
if (pos != 0) if (pos != 0)
return pos; return pos;

View File

@ -36,6 +36,7 @@
// ***************************************************** // *****************************************************
// class File // class File
// ***************************************************** // *****************************************************
File::File(const char* n, const char* m) File::File(const char* n, const char* m)
{ {
fp = fopen(n, m); fp = fopen(n, m);
@ -70,7 +71,6 @@ File& operator<<( File& f, int n )
return f; return f;
} }
File& operator<<(File& f, const char& c) File& operator<<(File& f, const char& c)
{ {
if (f) fputc(c, f.fp); if (f) fputc(c, f.fp);
@ -96,6 +96,7 @@ int File::getline( char* buf, int sz )
{ {
int a = sz; int a = sz;
char *origBuf = buf; char *origBuf = buf;
if (*this) if (*this)
{ {
int c; int c;
@ -123,4 +124,3 @@ File& File::skipWs( )
ungetc(c, fp); ungetc(c, fp);
return *this; return *this;
} }

View File

@ -184,6 +184,7 @@ size_t CLangMngr::strip(char *str, char *newstr, bool makelower)
} }
newstr[pos] = 0; newstr[pos] = 0;
return ptr - str + 1; return ptr - str + 1;
} }
@ -305,6 +306,7 @@ void CLangMngr::CLang::Clear()
if (m_LookUpTable[i]) if (m_LookUpTable[i])
delete m_LookUpTable[i]; delete m_LookUpTable[i];
} }
m_LookUpTable.clear(); m_LookUpTable.clear();
} }
@ -332,11 +334,13 @@ void CLangMngr::CLang::MergeDefinitions(CQueue<sKeyDef*> &vec)
{ {
const char *def = 0; const char *def = 0;
int key = -1; int key = -1;
while (!vec.empty()) while (!vec.empty())
{ {
key = vec.front()->key; key = vec.front()->key;
def = vec.front()->def->c_str(); def = vec.front()->def->c_str();
LangEntry *entry = GetEntry(key); LangEntry *entry = GetEntry(key);
if (entry->GetDefHash() != MakeHash(def)) if (entry->GetDefHash() != MakeHash(def))
{ {
if (entry->GetCache()) if (entry->GetCache())
@ -348,6 +352,7 @@ void CLangMngr::CLang::MergeDefinitions(CQueue<sKeyDef*> &vec)
//AMXXLOG_Log("[AMXX] Language key %s[%s] defined twice", m_LMan->GetKey(key), m_LanguageName); //AMXXLOG_Log("[AMXX] Language key %s[%s] defined twice", m_LMan->GetKey(key), m_LanguageName);
} }
} }
delete vec.front(); delete vec.front();
vec.pop(); vec.pop();
} }
@ -357,20 +362,22 @@ const char * CLangMngr::CLang::GetDef(const char *key)
{ {
static char nfind[1024] = "ML_NOTFOUND(KEY)"; static char nfind[1024] = "ML_NOTFOUND(KEY)";
int ikey = m_LMan->GetKeyEntry(key); int ikey = m_LMan->GetKeyEntry(key);
if (ikey == -1) if (ikey == -1)
{ {
sprintf(nfind, "ML_NOTFOUND: %s", key); sprintf(nfind, "ML_NOTFOUND: %s", key);
return nfind; return nfind;
} }
for (unsigned int i = 0; i < m_LookUpTable.size(); i++) for (unsigned int i = 0; i < m_LookUpTable.size(); i++)
{ {
if (m_LookUpTable[i]->GetKey() == ikey) if (m_LookUpTable[i]->GetKey() == ikey)
return m_LookUpTable[i]->GetDef(); return m_LookUpTable[i]->GetDef();
} }
return NULL; return NULL;
} }
struct OffsetPair struct OffsetPair
{ {
uint32_t defOffset; uint32_t defOffset;
@ -381,6 +388,7 @@ struct OffsetPair
bool CLangMngr::CLang::SaveDefinitions(FILE *fp, uint32_t &curOffset) bool CLangMngr::CLang::SaveDefinitions(FILE *fp, uint32_t &curOffset)
{ {
unsigned short defLen = 0; unsigned short defLen = 0;
for (unsigned int i = 0; i < m_LookUpTable.size(); i++) for (unsigned int i = 0; i < m_LookUpTable.size(); i++)
{ {
defLen = m_LookUpTable[i]->GetDefLength(); defLen = m_LookUpTable[i]->GetDefLength();
@ -423,7 +431,6 @@ bool CLangMngr::CLang::Save(FILE *fp, int &defOffset, uint32_t &curOffset)
// assumes fp is set to the right position // assumes fp is set to the right position
bool CLangMngr::CLang::Load(FILE *fp) bool CLangMngr::CLang::Load(FILE *fp)
{ {
return true; return true;
} }
@ -464,6 +471,7 @@ int CLangMngr::GetKeyEntry(const char *key)
for (i = 0; i < KeyList.size(); i++) for (i = 0; i < KeyList.size(); i++)
{ {
cmpKey = KeyList[i]->hash; cmpKey = KeyList[i]->hash;
if (hKey == cmpKey) if (hKey == cmpKey)
{ {
return i; return i;
@ -521,6 +529,7 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
{ {
// number of parameters ( for NEXT_PARAM macro ) // number of parameters ( for NEXT_PARAM macro )
int paramCount = *params / sizeof(cell); int paramCount = *params / sizeof(cell);
// the output buffer // the output buffer
static char outbuf[4096]; static char outbuf[4096];
char *outptr = outbuf; char *outptr = outbuf;
@ -538,6 +547,7 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
cell *pAmxLangName = get_amxaddr(amx, params[parm++]); // other cases cell *pAmxLangName = get_amxaddr(amx, params[parm++]); // other cases
const char *cpLangName=NULL; const char *cpLangName=NULL;
// Handle player ids (1-32) and server language // Handle player ids (1-32) and server language
if (*pAmxLangName == LANG_PLAYER) // LANG_PLAYER if (*pAmxLangName == LANG_PLAYER) // LANG_PLAYER
{ {
if ((int)CVAR_GET_FLOAT("amx_client_languages") == 0) if ((int)CVAR_GET_FLOAT("amx_client_languages") == 0)
@ -546,9 +556,11 @@ 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)
{ {
cpLangName = g_vault.get("server_language"); cpLangName = g_vault.get("server_language");
@ -559,12 +571,15 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
int tmplen = 0; int tmplen = 0;
cpLangName = get_amxstring(amx, langName, 2, tmplen); cpLangName = get_amxstring(amx, langName, 2, tmplen);
} }
if (!cpLangName || strlen(cpLangName) < 1) if (!cpLangName || strlen(cpLangName) < 1)
cpLangName = "en"; cpLangName = "en";
int tmplen = 0; int tmplen = 0;
NEXT_PARAM(); NEXT_PARAM();
char *key = get_amxstring(amx, params[parm++], 1, tmplen); char *key = get_amxstring(amx, params[parm++], 1, tmplen);
const char *def = GetDef(cpLangName, key); const char *def = GetDef(cpLangName, key);
if (def == NULL) if (def == NULL)
{ {
if (*pAmxLangName != LANG_SERVER) if (*pAmxLangName != LANG_SERVER)
@ -583,6 +598,7 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
def = buf; def = buf;
} }
} }
while (*def) while (*def)
{ {
if (*def == '%') if (*def == '%')
@ -592,9 +608,7 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
{ {
*outptr++ = '%'; *outptr++ = '%';
++def; ++def;
} } else {
else
{
static char format[32]; static char format[32];
format[0] = '%'; format[0] = '%';
char *ptr = format+1; char *ptr = format+1;
@ -604,6 +618,7 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
ZEROTERM(format); ZEROTERM(format);
*ptr = 0; *ptr = 0;
switch (*(ptr - 1)) switch (*(ptr - 1))
{ {
case 's': case 's':
@ -644,12 +659,14 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
break; break;
} }
} }
outptr += strlen(outptr); outptr += strlen(outptr);
} }
} }
else if (*def == '^') else if (*def == '^')
{ {
++def; ++def;
switch (*def) switch (*def)
{ {
case 'n': case 'n':
@ -670,22 +687,20 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
*outptr++ = *def; *outptr++ = *def;
break; break;
} }
++def; ++def;
} } else {
else
{
CHECK_OUTPTR(1); CHECK_OUTPTR(1);
*outptr++ = *def++; *outptr++ = *def++;
} }
} }
} } else {
else
{
static char tmpString[4096]; static char tmpString[4096];
char *tmpPtr = tmpString; char *tmpPtr = tmpString;
int tmpLen = 0; int tmpLen = 0;
static char format[32] = {'%'}; static char format[32] = {'%'};
char *ptr = format+1; char *ptr = format+1;
if (*src != '%') if (*src != '%')
{ {
while (*src != 0 && ptr-format<sizeof(format) && !isalpha(*ptr++ = static_cast<char>(*src++))) while (*src != 0 && ptr-format<sizeof(format) && !isalpha(*ptr++ = static_cast<char>(*src++)))
@ -693,6 +708,7 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
*ptr = 0; *ptr = 0;
ZEROTERM(format); ZEROTERM(format);
--src; --src;
switch (*(ptr - 1)) switch (*(ptr - 1))
{ {
case 's': case 's':
@ -728,23 +744,24 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
break; break;
} }
} }
outptr += strlen(outptr); outptr += strlen(outptr);
} else { } else {
CHECK_OUTPTR(1); CHECK_OUTPTR(1);
*outptr++ = '%'; *outptr++ = '%';
} }
} }
} } else {
else
{
CHECK_OUTPTR(1); CHECK_OUTPTR(1);
*outptr++ = static_cast<char>(*src); *outptr++ = static_cast<char>(*src);
} }
++src; ++src;
} }
len = outptr - outbuf; len = outptr - outbuf;
CHECK_OUTPTR(1); CHECK_OUTPTR(1);
*outptr++ = 0; *outptr++ = 0;
return outbuf; return outbuf;
} }
@ -754,6 +771,7 @@ const char *CLangMngr::Format(const char *fmt, ...)
va_start(ap, fmt); va_start(ap, fmt);
const char *retVal = FormatString(fmt, ap); const char *retVal = FormatString(fmt, ap);
va_end(ap); va_end(ap);
return retVal; return retVal;
} }
@ -788,6 +806,7 @@ char *CLangMngr::FormatString(const char *fmt, va_list &ap)
const char *pAmxLangName = va_arg(ap, const char*); const char *pAmxLangName = va_arg(ap, const char*);
const char *cpLangName=NULL; const char *cpLangName=NULL;
// Handle player ids (1-32) and server language // Handle player ids (1-32) and server language
if (pAmxLangName == (const char *)LANG_PLAYER) // LANG_PLAYER if (pAmxLangName == (const char *)LANG_PLAYER) // LANG_PLAYER
{ {
if ((int)CVAR_GET_FLOAT("amx_client_languages")) if ((int)CVAR_GET_FLOAT("amx_client_languages"))
@ -796,9 +815,11 @@ 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"))
{ {
cpLangName = g_vault.get("server_language"); cpLangName = g_vault.get("server_language");
@ -809,11 +830,14 @@ char *CLangMngr::FormatString(const char *fmt, va_list &ap)
int tmplen = 0; int tmplen = 0;
cpLangName = pAmxLangName; cpLangName = pAmxLangName;
} }
if (!cpLangName || strlen(cpLangName) < 1) if (!cpLangName || strlen(cpLangName) < 1)
cpLangName = "en"; cpLangName = "en";
int tmplen = 0; int tmplen = 0;
const char *key = va_arg(ap, const char *); const char *key = va_arg(ap, const char *);
const char *def = GetDef(cpLangName, key); const char *def = GetDef(cpLangName, key);
if (def == NULL) if (def == NULL)
{ {
if (pAmxLangName != LANG_SERVER) if (pAmxLangName != LANG_SERVER)
@ -832,6 +856,7 @@ char *CLangMngr::FormatString(const char *fmt, va_list &ap)
def = buf; def = buf;
} }
} }
while (*def) while (*def)
{ {
if (*def == '%') if (*def == '%')
@ -847,6 +872,7 @@ char *CLangMngr::FormatString(const char *fmt, va_list &ap)
*ptr = 0; *ptr = 0;
vsprintf(outptr, format, ap); vsprintf(outptr, format, ap);
// vsprintf doesnt alter the ap, increment here // vsprintf doesnt alter the ap, increment here
switch (*(ptr - 1)) switch (*(ptr - 1))
{ {
case 'f': case 'f':
@ -862,11 +888,13 @@ char *CLangMngr::FormatString(const char *fmt, va_list &ap)
va_arg(ap, int); va_arg(ap, int);
break; break;
} }
outptr += strlen(outptr); outptr += strlen(outptr);
} }
else if (*def == '^') else if (*def == '^')
{ {
++def; ++def;
switch (*def) switch (*def)
{ {
case 'n': case 'n':
@ -887,19 +915,17 @@ char *CLangMngr::FormatString(const char *fmt, va_list &ap)
*outptr++ = *def; *outptr++ = *def;
break; break;
} }
++def; ++def;
} } else {
else
{
CHECK_OUTPTR(1); CHECK_OUTPTR(1);
*outptr++ = *def++; *outptr++ = *def++;
} }
} }
} } else {
else
{
static char format[32] = {'%'}; static char format[32] = {'%'};
char *ptr = format+1; char *ptr = format+1;
if (*src != '%') if (*src != '%')
{ {
while (*src != 0 && ptr-format < sizeof(format) && !isalpha(*ptr++ = *src++)) while (*src != 0 && ptr-format < sizeof(format) && !isalpha(*ptr++ = *src++))
@ -909,6 +935,7 @@ char *CLangMngr::FormatString(const char *fmt, va_list &ap)
--src; --src;
vsprintf(outptr, format, ap); vsprintf(outptr, format, ap);
// vsprintf doesnt alter the ap, increment here // vsprintf doesnt alter the ap, increment here
switch (*(ptr - 1)) switch (*(ptr - 1))
{ {
case 'f': case 'f':
@ -924,22 +951,23 @@ char *CLangMngr::FormatString(const char *fmt, va_list &ap)
va_arg(ap, int); va_arg(ap, int);
break; break;
} }
outptr += strlen(outptr); outptr += strlen(outptr);
} else { } else {
CHECK_OUTPTR(1); CHECK_OUTPTR(1);
*outptr++ = '%'; *outptr++ = '%';
} }
} }
} } else {
else
{
CHECK_OUTPTR(1); CHECK_OUTPTR(1);
*outptr++ = *src; *outptr++ = *src;
} }
++src; ++src;
} }
CHECK_OUTPTR(1); CHECK_OUTPTR(1);
*outptr++ = 0; *outptr++ = 0;
return outbuf; return outbuf;
} }
void CLangMngr::MergeDefinitions(const char *lang, CQueue<sKeyDef*> &tmpVec) void CLangMngr::MergeDefinitions(const char *lang, CQueue<sKeyDef*> &tmpVec)
@ -969,6 +997,7 @@ int CLangMngr::MergeDefinitionFile(const char *file)
AMXXLOG_Log("[AMXX] Failed to open dictionary file: %s", file); AMXXLOG_Log("[AMXX] Failed to open dictionary file: %s", file);
return 0; return 0;
} }
MD5 md5; MD5 md5;
md5.update(fp); // closes for us md5.update(fp); // closes for us
md5.finalize(); md5.finalize();
@ -1022,6 +1051,7 @@ int CLangMngr::MergeDefinitionFile(const char *file)
buf.trim(); buf.trim();
if (buf[0] == 0) if (buf[0] == 0)
continue; continue;
if (buf[0] == '[' && buf.size() >= 3) if (buf[0] == '[' && buf.size() >= 3)
{ {
if (multiline) if (multiline)
@ -1031,10 +1061,12 @@ int CLangMngr::MergeDefinitionFile(const char *file)
delete tmpEntry; delete tmpEntry;
tmpEntry = 0; tmpEntry = 0;
} }
if (!Defq.empty()) if (!Defq.empty())
{ {
MergeDefinitions(language, Defq); MergeDefinitions(language, Defq);
} }
language[0] = buf[1]; language[0] = buf[1];
language[1] = buf[2]; language[1] = buf[2];
language[2] = 0; language[2] = 0;
@ -1042,6 +1074,7 @@ int CLangMngr::MergeDefinitionFile(const char *file)
if (!multiline) if (!multiline)
{ {
pos = buf.find('='); pos = buf.find('=');
if (pos > String::npos) if (pos > String::npos)
{ {
tmpEntry = new sKeyDef; tmpEntry = new sKeyDef;
@ -1062,6 +1095,7 @@ int CLangMngr::MergeDefinitionFile(const char *file)
tmpEntry = 0; tmpEntry = 0;
} else { } else {
pos = buf.find(':'); pos = buf.find(':');
if (pos > String::npos) if (pos > String::npos)
{ {
tmpEntry = new sKeyDef; tmpEntry = new sKeyDef;
@ -1264,7 +1298,6 @@ bool CLangMngr::LoadCache(const char *filename)
fread((void*)&dictCount, sizeof(short), 1, fp); fread((void*)&dictCount, sizeof(short), 1, fp);
md5Pair *p = 0; md5Pair *p = 0;
for (int i = 1; i <= dictCount; i++) for (int i = 1; i <= dictCount; i++)
{ {
fread((void*)&len, sizeof(char), 1, fp); fread((void*)&len, sizeof(char), 1, fp);
@ -1311,6 +1344,7 @@ bool CLangMngr::Load(const char *filename)
uint32_t *LangOffsets = new uint32_t[langCount]; uint32_t *LangOffsets = new uint32_t[langCount];
char langname[3]; char langname[3];
for (unsigned int i = 0; i < langCount; i++) for (unsigned int i = 0; i < langCount; i++)
{ {
fread(langname, sizeof(char), 2, fp); fread(langname, sizeof(char), 2, fp);
@ -1324,6 +1358,7 @@ bool CLangMngr::Load(const char *filename)
keyEntry *e = 0; keyEntry *e = 0;
unsigned char keylen; unsigned char keylen;
uint32_t keyoffset, save; uint32_t keyoffset, save;
for (unsigned i = 0; i < keycount; i++) for (unsigned i = 0; i < keycount; i++)
{ {
e = new keyEntry; e = new keyEntry;
@ -1347,9 +1382,11 @@ bool CLangMngr::Load(const char *filename)
uint32_t defhash; uint32_t defhash;
uint32_t defoffset; uint32_t defoffset;
unsigned short deflen; unsigned short deflen;
for (unsigned int i = 0; i < langCount; i++) for (unsigned int i = 0; i < langCount; i++)
{ {
fread((void*)&numentries, sizeof(uint32_t), 1, fp); fread((void*)&numentries, sizeof(uint32_t), 1, fp);
for (unsigned int j = 0; j < numentries; j++) for (unsigned int j = 0; j < numentries; j++)
{ {
fread((void *)&keynum, sizeof(uint32_t), 1, fp); fread((void *)&keynum, sizeof(uint32_t), 1, fp);
@ -1383,6 +1420,7 @@ CLangMngr::~CLangMngr()
void CLangMngr::Clear() void CLangMngr::Clear()
{ {
unsigned int i = 0; unsigned int i = 0;
for (i = 0; i < m_Languages.size(); i++) for (i = 0; i < m_Languages.size(); i++)
{ {
if (m_Languages[i]) if (m_Languages[i])
@ -1415,6 +1453,7 @@ const char *CLangMngr::GetLangName(int langId)
{ {
int i = 0; int i = 0;
LangVecIter iter; LangVecIter iter;
for (iter = m_Languages.begin(); iter != m_Languages.end(); ++iter) for (iter = m_Languages.begin(); iter != m_Languages.end(); ++iter)
{ {
if (i == langId) if (i == langId)
@ -1423,6 +1462,7 @@ const char *CLangMngr::GetLangName(int langId)
} }
i++; i++;
} }
return ""; return "";
} }
@ -1430,6 +1470,7 @@ bool CLangMngr::LangExists(const char *langName)
{ {
char buf[3] = {0}; char buf[3] = {0};
int i = 0; int i = 0;
while (buf[i] = tolower(*langName++)) while (buf[i] = tolower(*langName++))
{ {
if (++i == 2) if (++i == 2)
@ -1437,11 +1478,13 @@ bool CLangMngr::LangExists(const char *langName)
} }
LangVecIter iter; LangVecIter iter;
for (iter = m_Languages.begin(); iter != m_Languages.end(); ++iter) for (iter = m_Languages.begin(); iter != m_Languages.end(); ++iter)
{ {
if (strcmp((*iter)->GetName(), buf) == 0) if (strcmp((*iter)->GetName(), buf) == 0)
return true; return true;
} }
return false; return false;
} }

View File

@ -35,102 +35,136 @@
// ***************************************************** // *****************************************************
// class LogEventsMngr // class LogEventsMngr
// ***************************************************** // *****************************************************
LogEventsMngr::LogEventsMngr() {
LogEventsMngr::LogEventsMngr()
{
logCurrent = logCounter = 0; logCurrent = logCounter = 0;
logcmplist = 0; logcmplist = 0;
arelogevents = false; arelogevents = false;
memset(logevents, 0, sizeof(logevents)); memset(logevents, 0, sizeof(logevents));
} }
LogEventsMngr::~LogEventsMngr() { LogEventsMngr::~LogEventsMngr()
{
clearLogEvents(); clearLogEvents();
} }
int LogEventsMngr::CLogCmp::compareCondition(const char* string){ int LogEventsMngr::CLogCmp::compareCondition(const char* string)
{
if (logid == parent->logCounter) if (logid == parent->logCounter)
return result; return result;
logid = parent->logCounter; logid = parent->logCounter;
if (in) return result = strstr(string, text.c_str()) ? 0 : 1; if (in) return result = strstr(string, text.c_str()) ? 0 : 1;
return result = strcmp(string,text.c_str()); return result = strcmp(string,text.c_str());
} }
LogEventsMngr::CLogCmp* LogEventsMngr::registerCondition(char* filter){ LogEventsMngr::CLogCmp* LogEventsMngr::registerCondition(char* filter)
{
char* temp = filter; char* temp = filter;
// expand "1=message" // expand "1=message"
while (isdigit(*filter)) while (isdigit(*filter))
++filter; ++filter;
bool in = (*filter=='&'); bool in = (*filter=='&');
*filter++ = 0; *filter++ = 0;
int pos = atoi(temp); int pos = atoi(temp);
if (pos < 0 || pos >= MAX_LOGARGS) pos = 0; if (pos < 0 || pos >= MAX_LOGARGS) pos = 0;
CLogCmp* c = logcmplist; CLogCmp* c = logcmplist;
while( c ) {
while (c)
{
if ((c->pos == pos) && (c->in == in) && !strcmp(c->text.c_str(), filter)) if ((c->pos == pos) && (c->in == in) && !strcmp(c->text.c_str(), filter))
return c; return c;
c = c->next; c = c->next;
} }
return logcmplist = new CLogCmp(filter, in, pos, logcmplist, this); return logcmplist = new CLogCmp(filter, in, pos, logcmplist, this);
} }
void LogEventsMngr::CLogEvent::registerFilter( char* filter ){ void LogEventsMngr::CLogEvent::registerFilter(char* filter)
{
CLogCmp *cmp = parent->registerCondition(filter); CLogCmp *cmp = parent->registerCondition(filter);
if (cmp == 0) return; if (cmp == 0) return;
for(LogCond* c = filters; c ; c = c->next){
if ( c->argnum == cmp->pos ){ for (LogCond* c = filters; c; c = c->next)
{
if (c->argnum == cmp->pos)
{
c->list = new LogCondEle(cmp, c->list); c->list = new LogCondEle(cmp, c->list);
return; return;
} }
} }
LogCondEle* aa = new LogCondEle(cmp, 0); LogCondEle* aa = new LogCondEle(cmp, 0);
if (aa == 0) return; if (aa == 0) return;
filters = new LogCond(cmp->pos, aa, filters); filters = new LogCond(cmp->pos, aa, filters);
} }
void LogEventsMngr::setLogString( char* frmt, va_list& vaptr ) { void LogEventsMngr::setLogString(char* frmt, va_list& vaptr)
{
++logCounter; ++logCounter;
int len = vsnprintf(logString, 255, frmt, vaptr); int len = vsnprintf(logString, 255, frmt, vaptr);
if ( len == - 1) {
if (len == - 1)
{
len = 255; len = 255;
logString[len] = 0; logString[len] = 0;
} }
if (len) logString[--len] = 0; if (len) logString[--len] = 0;
logArgc = 0; logArgc = 0;
} }
void LogEventsMngr::setLogString( char* frmt, ... ) { void LogEventsMngr::setLogString(char* frmt, ...)
{
++logCounter; ++logCounter;
va_list logArgPtr; va_list logArgPtr;
va_start(logArgPtr, frmt); va_start(logArgPtr, frmt);
int len = vsnprintf(logString, 255, frmt, logArgPtr); int len = vsnprintf(logString, 255, frmt, logArgPtr);
if ( len == - 1) {
if (len == - 1)
{
len = 255; len = 255;
logString[len] = 0; logString[len] = 0;
} }
va_end(logArgPtr); va_end(logArgPtr);
if (len) logString[--len] = 0; if (len) logString[--len] = 0;
logArgc = 0; logArgc = 0;
} }
void LogEventsMngr::parseLogString( ) { void LogEventsMngr::parseLogString()
{
register const char* b = logString; register const char* b = logString;
register int a; register int a;
while( *b && logArgc < MAX_LOGARGS ){
while (*b && logArgc < MAX_LOGARGS)
{
a = 0; a = 0;
if ( *b == '"' ) {
if (*b == '"')
{
++b; ++b;
while (*b && *b != '"' && a < 127) while (*b && *b != '"' && a < 127)
logArgs[logArgc][a++] = *b++; logArgs[logArgc][a++] = *b++;
logArgs[logArgc++][a] = 0; logArgs[logArgc++][a] = 0;
if (*b) b+=2; // thanks to double terminator if (*b) b+=2; // thanks to double terminator
} }
else if ( *b == '(' ) { else if (*b == '(')
{
++b; ++b;
while (*b && *b != ')' && a < 127) while (*b && *b != ')' && a < 127)
logArgs[logArgc][a++] = *b++; logArgs[logArgc][a++] = *b++;
logArgs[logArgc++][a] = 0; logArgs[logArgc++][a] = 0;
if (*b) b+=2; if (*b) b+=2;
} } else {
else {
while (*b && *b != '(' && *b != '"' && a < 127) while (*b && *b != '(' && *b != '"' && a < 127)
logArgs[logArgc][a++] = *b++; logArgs[logArgc][a++] = *b++;
if (*b) --a; if (*b) --a;
@ -143,27 +177,35 @@ LogEventsMngr::CLogEvent* LogEventsMngr::registerLogEvent( CPluginMngr::CPlugin*
{ {
if (pos < 1 || pos > MAX_LOGARGS) if (pos < 1 || pos > MAX_LOGARGS)
return 0; return 0;
arelogevents = true; arelogevents = true;
CLogEvent** d = &logevents[pos]; CLogEvent** d = &logevents[pos];
while (*d) d = &(*d)->next; while (*d) d = &(*d)->next;
return *d = new CLogEvent(plugin, func, this); return *d = new CLogEvent(plugin, func, this);
} }
void LogEventsMngr::executeLogEvents() void LogEventsMngr::executeLogEvents()
{ {
bool valid; bool valid;
for (CLogEvent* a = logevents[logArgc]; a; a = a->next) for (CLogEvent* a = logevents[logArgc]; a; a = a->next)
{ {
valid = true; valid = true;
for (CLogEvent::LogCond* b = a->filters; b; b = b->next) for (CLogEvent::LogCond* b = a->filters; b; b = b->next)
{ {
valid = false; valid = false;
for( CLogEvent::LogCondEle* c = b->list; c ; c = c->next) {
if ( c->cmp->compareCondition( logArgs[b->argnum] ) == 0 ){ for (CLogEvent::LogCondEle* c = b->list; c; c = c->next)
{
if (c->cmp->compareCondition(logArgs[b->argnum]) == 0)
{
valid = true; valid = true;
break; break;
} }
} }
if (!valid) if (!valid)
break; break;
} }
@ -175,38 +217,49 @@ void LogEventsMngr::executeLogEvents()
} }
} }
void LogEventsMngr::clearLogEvents(){ void LogEventsMngr::clearLogEvents()
{
logCurrent = logCounter = 0; logCurrent = logCounter = 0;
arelogevents = false; arelogevents = false;
for(int i = 0; i < MAX_LOGARGS + 1; ++i){
for (int i = 0; i < MAX_LOGARGS + 1; ++i)
{
CLogEvent **a = &logevents[i]; CLogEvent **a = &logevents[i];
while(*a){ while (*a)
{
CLogEvent* bb = (*a)->next; CLogEvent* bb = (*a)->next;
delete *a; delete *a;
*a = bb; *a = bb;
} }
} }
clearConditions(); clearConditions();
} }
void LogEventsMngr::clearConditions() { void LogEventsMngr::clearConditions()
while (logcmplist){ {
while (logcmplist)
{
CLogCmp* a = logcmplist->next; CLogCmp* a = logcmplist->next;
delete logcmplist; delete logcmplist;
logcmplist = a; logcmplist = a;
} }
} }
LogEventsMngr::CLogEvent::LogCond::~LogCond() { LogEventsMngr::CLogEvent::LogCond::~LogCond()
while( list ) { {
while (list)
{
LogCondEle* cc = list->next; LogCondEle* cc = list->next;
delete list; delete list;
list = cc; list = cc;
} }
} }
LogEventsMngr::CLogEvent::~CLogEvent() { LogEventsMngr::CLogEvent::~CLogEvent()
while( filters ) { {
while (filters)
{
LogCond* cc = filters->next; LogCond* cc = filters->next;
delete filters; delete filters;
filters = cc; filters = cc;
@ -216,23 +269,35 @@ LogEventsMngr::CLogEvent::~CLogEvent() {
LogEventsMngr::CLogEvent *LogEventsMngr::getValidLogEvent(CLogEvent * a) LogEventsMngr::CLogEvent *LogEventsMngr::getValidLogEvent(CLogEvent * a)
{ {
bool valid; bool valid;
while(a){
while (a)
{
valid = true; valid = true;
for( CLogEvent::LogCond* b = a->filters; b ; b = b->next){
for (CLogEvent::LogCond* b = a->filters; b; b = b->next)
{
valid = false; valid = false;
for( CLogEvent::LogCondEle* c = b->list; c ; c = c->next) {
if ( c->cmp->compareCondition( logArgs[b->argnum] ) == 0 ){ for (CLogEvent::LogCondEle* c = b->list; c; c = c->next)
{
if (c->cmp->compareCondition(logArgs[b->argnum]) == 0)
{
valid = true; valid = true;
break; break;
} }
} }
if (!valid) break; if (!valid) break;
} }
if (!valid){
if (!valid)
{
a = a->next; a = a->next;
continue; continue;
} }
return a; return a;
} }
return 0; return 0;
} }