mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-26 06:45:37 +03:00
Fix iterators
This commit is contained in:
parent
7794f27dc2
commit
2df1cb5e21
@ -234,7 +234,7 @@ void CFlagManager::LookupOrAdd(const char *Command, int &Flags, AMX *Plugin)
|
|||||||
m_FlagList.push_back(Entry);
|
m_FlagList.push_back(Entry);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
iter++;
|
++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
// was not found, add it
|
// was not found, add it
|
||||||
|
@ -170,13 +170,12 @@ CLangMngr::CLang::~CLang()
|
|||||||
|
|
||||||
void CLangMngr::CLang::Clear()
|
void CLangMngr::CLang::Clear()
|
||||||
{
|
{
|
||||||
THash<int, defentry>::iterator iter;
|
for (auto &element : m_LookUpTable)
|
||||||
for (iter=m_LookUpTable.begin(); iter!=m_LookUpTable.end(); iter++)
|
|
||||||
{
|
{
|
||||||
if (iter->val.definition)
|
if (element.val.definition)
|
||||||
{
|
{
|
||||||
delete iter->val.definition;
|
delete element.val.definition;
|
||||||
iter->val.definition = NULL;
|
element.val.definition = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_LookUpTable.clear();
|
m_LookUpTable.clear();
|
||||||
|
@ -80,8 +80,6 @@ int CPluginMngr::loadPluginsFromFile(const char* filename, bool warn)
|
|||||||
|
|
||||||
char line[512];
|
char line[512];
|
||||||
|
|
||||||
List<ke::AString *>::iterator block_iter;
|
|
||||||
|
|
||||||
while (!feof(fp))
|
while (!feof(fp))
|
||||||
{
|
{
|
||||||
pluginName[0] = '\0';
|
pluginName[0] = '\0';
|
||||||
@ -116,11 +114,9 @@ int CPluginMngr::loadPluginsFromFile(const char* filename, bool warn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool skip = false;
|
bool skip = false;
|
||||||
for (block_iter = m_BlockList.begin();
|
for (const auto &block : m_BlockList)
|
||||||
block_iter != m_BlockList.end();
|
|
||||||
block_iter++)
|
|
||||||
{
|
{
|
||||||
if ((*block_iter)->compare(pluginName) == 0)
|
if (block->compare(pluginName) == 0)
|
||||||
{
|
{
|
||||||
skip = true;
|
skip = true;
|
||||||
break;
|
break;
|
||||||
@ -489,12 +485,8 @@ AutoConfig *CPluginMngr::CPlugin::GetConfig(size_t i)
|
|||||||
|
|
||||||
char *CPluginMngr::ReadIntoOrFromCache(const char *file, size_t &bufsize)
|
char *CPluginMngr::ReadIntoOrFromCache(const char *file, size_t &bufsize)
|
||||||
{
|
{
|
||||||
List<plcache_entry *>::iterator iter;
|
for (const auto *pl : m_plcache)
|
||||||
plcache_entry *pl;
|
|
||||||
|
|
||||||
for (iter=m_plcache.begin(); iter!=m_plcache.end(); iter++)
|
|
||||||
{
|
{
|
||||||
pl = (*iter);
|
|
||||||
if (pl->path.compare(file) == 0)
|
if (pl->path.compare(file) == 0)
|
||||||
{
|
{
|
||||||
bufsize = pl->bufsize;
|
bufsize = pl->bufsize;
|
||||||
@ -502,7 +494,7 @@ char *CPluginMngr::ReadIntoOrFromCache(const char *file, size_t &bufsize)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pl = new plcache_entry;
|
auto *pl = new plcache_entry;
|
||||||
|
|
||||||
pl->file = new CAmxxReader(file, sizeof(cell));
|
pl->file = new CAmxxReader(file, sizeof(cell));
|
||||||
pl->buffer = NULL;
|
pl->buffer = NULL;
|
||||||
@ -539,12 +531,8 @@ char *CPluginMngr::ReadIntoOrFromCache(const char *file, size_t &bufsize)
|
|||||||
|
|
||||||
void CPluginMngr::InvalidateCache()
|
void CPluginMngr::InvalidateCache()
|
||||||
{
|
{
|
||||||
List<plcache_entry *>::iterator iter;
|
for (auto *pl : m_plcache)
|
||||||
plcache_entry *pl;
|
|
||||||
|
|
||||||
for (iter=m_plcache.begin(); iter!=m_plcache.end(); iter++)
|
|
||||||
{
|
{
|
||||||
pl = (*iter);
|
|
||||||
delete [] pl->buffer;
|
delete [] pl->buffer;
|
||||||
delete pl->file;
|
delete pl->file;
|
||||||
delete pl;
|
delete pl;
|
||||||
@ -558,7 +546,7 @@ void CPluginMngr::InvalidateFileInCache(const char *file, bool freebuf)
|
|||||||
List<plcache_entry *>::iterator iter;
|
List<plcache_entry *>::iterator iter;
|
||||||
plcache_entry *pl;
|
plcache_entry *pl;
|
||||||
|
|
||||||
for (iter=m_plcache.begin(); iter!=m_plcache.end(); iter++)
|
for (iter=m_plcache.begin(); iter!=m_plcache.end(); ++iter)
|
||||||
{
|
{
|
||||||
pl = (*iter);
|
pl = (*iter);
|
||||||
if (pl->path.compare(file) == 0)
|
if (pl->path.compare(file) == 0)
|
||||||
|
@ -307,11 +307,11 @@ CvarInfo* CvarManager::FindCvar(size_t index)
|
|||||||
|
|
||||||
size_t iter_id = 0;
|
size_t iter_id = 0;
|
||||||
|
|
||||||
for (CvarsList::iterator iter = m_Cvars.begin(); iter != m_Cvars.end(); iter++)
|
for (auto *element : m_Cvars)
|
||||||
{
|
{
|
||||||
if (iter->amxmodx && iter_id++ == index)
|
if (element->amxmodx && iter_id++ == index)
|
||||||
{
|
{
|
||||||
return *(iter);
|
return element;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -533,10 +533,8 @@ void CvarManager::OnConsoleCommand()
|
|||||||
print_srvconsole(" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \n");
|
print_srvconsole(" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \n");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (CvarsList::iterator iter = m_Cvars.begin(); iter != m_Cvars.end(); iter++)
|
for (const auto *ci : m_Cvars)
|
||||||
{
|
{
|
||||||
CvarInfo* ci = (*iter);
|
|
||||||
|
|
||||||
// List any cvars having a status either created, hooked or bound by a plugin.
|
// List any cvars having a status either created, hooked or bound by a plugin.
|
||||||
bool in_list = ci->amxmodx || !ci->binds.empty() || !ci->hooks.empty() || ci->bound.hasMin || ci->bound.hasMax;
|
bool in_list = ci->amxmodx || !ci->binds.empty() || !ci->hooks.empty() || ci->bound.hasMin || ci->bound.hasMax;
|
||||||
|
|
||||||
@ -610,25 +608,25 @@ void CvarManager::OnConsoleCommand()
|
|||||||
void CvarManager::OnPluginUnloaded()
|
void CvarManager::OnPluginUnloaded()
|
||||||
{
|
{
|
||||||
// Clear only plugin hooks list.
|
// Clear only plugin hooks list.
|
||||||
for (CvarsList::iterator cvar = m_Cvars.begin(); cvar != m_Cvars.end(); cvar++)
|
for (auto *cvar : m_Cvars)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < (*cvar)->binds.length(); ++i)
|
for (size_t i = 0; i < cvar->binds.length(); ++i)
|
||||||
{
|
{
|
||||||
delete (*cvar)->binds[i];
|
delete cvar->binds[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < (*cvar)->hooks.length(); ++i)
|
for (size_t i = 0; i < cvar->hooks.length(); ++i)
|
||||||
{
|
{
|
||||||
delete (*cvar)->hooks[i];
|
delete cvar->hooks[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((*cvar)->amxmodx) // Mark registered cvars so we can refresh default datas at next map.
|
if (cvar->amxmodx) // Mark registered cvars so we can refresh default datas at next map.
|
||||||
{
|
{
|
||||||
(*cvar)->pluginId = -1;
|
cvar->pluginId = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
(*cvar)->binds.clear();
|
cvar->binds.clear();
|
||||||
(*cvar)->hooks.clear();
|
cvar->hooks.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// There is no point to enable hook if at next map change
|
// There is no point to enable hook if at next map change
|
||||||
|
@ -134,7 +134,7 @@ size_t ClearLibraries(LibSource src)
|
|||||||
iter = g_libraries.erase(iter);
|
iter = g_libraries.erase(iter);
|
||||||
count++;
|
count++;
|
||||||
} else {
|
} else {
|
||||||
iter++;
|
++iter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,7 +157,7 @@ size_t RemoveLibraries(void *parent)
|
|||||||
iter = g_libraries.erase(iter);
|
iter = g_libraries.erase(iter);
|
||||||
count++;
|
count++;
|
||||||
} else {
|
} else {
|
||||||
iter++;
|
++iter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,12 +166,8 @@ size_t RemoveLibraries(void *parent)
|
|||||||
|
|
||||||
bool FindLibrary(const char *name, LibType type)
|
bool FindLibrary(const char *name, LibType type)
|
||||||
{
|
{
|
||||||
List<Library *>::iterator iter;
|
for (auto *lib : g_libraries)
|
||||||
Library *lib;
|
|
||||||
|
|
||||||
for (iter = g_libraries.begin(); iter != g_libraries.end(); iter++)
|
|
||||||
{
|
{
|
||||||
lib = (*iter);
|
|
||||||
if (lib->type != type)
|
if (lib->type != type)
|
||||||
continue;
|
continue;
|
||||||
if (strcasecmp(lib->name.chars(), name) == 0)
|
if (strcasecmp(lib->name.chars(), name) == 0)
|
||||||
@ -201,7 +197,7 @@ LibError RunLibCommand(const LibDecoder *enc)
|
|||||||
expect = LibType_Class;
|
expect = LibType_Class;
|
||||||
|
|
||||||
/** see if it exists */
|
/** see if it exists */
|
||||||
for (; iter != end; iter++)
|
for (; iter != end; ++iter)
|
||||||
{
|
{
|
||||||
lib = (*iter);
|
lib = (*iter);
|
||||||
if (lib->type != expect)
|
if (lib->type != expect)
|
||||||
@ -231,7 +227,7 @@ LibError RunLibCommand(const LibDecoder *enc)
|
|||||||
expect = LibType_Class;
|
expect = LibType_Class;
|
||||||
|
|
||||||
/** see if it exists */
|
/** see if it exists */
|
||||||
for (; iter != end; iter++)
|
for (; iter != end; ++iter)
|
||||||
{
|
{
|
||||||
lib = (*iter);
|
lib = (*iter);
|
||||||
if (lib->type != expect)
|
if (lib->type != expect)
|
||||||
|
@ -846,11 +846,8 @@ BOOL C_ClientConnect_Post(edict_t *pEntity, const char *pszName, const char *psz
|
|||||||
const char* authid = GETPLAYERAUTHID(pEntity);
|
const char* authid = GETPLAYERAUTHID(pEntity);
|
||||||
if (g_auth_funcs.size())
|
if (g_auth_funcs.size())
|
||||||
{
|
{
|
||||||
List<AUTHORIZEFUNC>::iterator iter, end=g_auth_funcs.end();
|
for (auto &fn : g_auth_funcs)
|
||||||
AUTHORIZEFUNC fn;
|
|
||||||
for (iter=g_auth_funcs.begin(); iter!=end; iter++)
|
|
||||||
{
|
{
|
||||||
fn = (*iter);
|
|
||||||
fn(pPlayer->index, authid);
|
fn(pPlayer->index, authid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -989,11 +986,8 @@ void C_ClientUserInfoChanged_Post(edict_t *pEntity, char *infobuffer)
|
|||||||
const char* authid = GETPLAYERAUTHID(pEntity);
|
const char* authid = GETPLAYERAUTHID(pEntity);
|
||||||
if (g_auth_funcs.size())
|
if (g_auth_funcs.size())
|
||||||
{
|
{
|
||||||
List<AUTHORIZEFUNC>::iterator iter, end=g_auth_funcs.end();
|
for (auto &fn : g_auth_funcs)
|
||||||
AUTHORIZEFUNC fn;
|
|
||||||
for (iter=g_auth_funcs.begin(); iter!=end; iter++)
|
|
||||||
{
|
{
|
||||||
fn = (*iter);
|
|
||||||
fn(pPlayer->index, authid);
|
fn(pPlayer->index, authid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1193,11 +1187,8 @@ void C_StartFrame_Post(void)
|
|||||||
(*player)->Authorize();
|
(*player)->Authorize();
|
||||||
if (g_auth_funcs.size())
|
if (g_auth_funcs.size())
|
||||||
{
|
{
|
||||||
List<AUTHORIZEFUNC>::iterator iter, end=g_auth_funcs.end();
|
for (auto &fn : g_auth_funcs)
|
||||||
AUTHORIZEFUNC fn;
|
|
||||||
for (iter=g_auth_funcs.begin(); iter!=end; iter++)
|
|
||||||
{
|
{
|
||||||
fn = (*iter);
|
|
||||||
fn((*player)->index, auth);
|
fn((*player)->index, auth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1489,7 +1480,7 @@ void C_CvarValue2(const edict_t *pEdict, int requestId, const char *cvar, const
|
|||||||
|
|
||||||
List<ClientCvarQuery_Info *>::iterator iter, end=pPlayer->queries.end();
|
List<ClientCvarQuery_Info *>::iterator iter, end=pPlayer->queries.end();
|
||||||
ClientCvarQuery_Info *info;
|
ClientCvarQuery_Info *info;
|
||||||
for (iter=pPlayer->queries.begin(); iter!=end; iter++)
|
for (iter=pPlayer->queries.begin(); iter!=end; ++iter)
|
||||||
{
|
{
|
||||||
info = (*iter);
|
info = (*iter);
|
||||||
if ( info->requestId == requestId )
|
if ( info->requestId == requestId )
|
||||||
|
Loading…
Reference in New Issue
Block a user