mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-25 14:25:38 +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);
|
||||
return;
|
||||
}
|
||||
iter++;
|
||||
++iter;
|
||||
}
|
||||
|
||||
// was not found, add it
|
||||
|
@ -170,13 +170,12 @@ CLangMngr::CLang::~CLang()
|
||||
|
||||
void CLangMngr::CLang::Clear()
|
||||
{
|
||||
THash<int, defentry>::iterator iter;
|
||||
for (iter=m_LookUpTable.begin(); iter!=m_LookUpTable.end(); iter++)
|
||||
for (auto &element : m_LookUpTable)
|
||||
{
|
||||
if (iter->val.definition)
|
||||
if (element.val.definition)
|
||||
{
|
||||
delete iter->val.definition;
|
||||
iter->val.definition = NULL;
|
||||
delete element.val.definition;
|
||||
element.val.definition = NULL;
|
||||
}
|
||||
}
|
||||
m_LookUpTable.clear();
|
||||
|
@ -80,8 +80,6 @@ int CPluginMngr::loadPluginsFromFile(const char* filename, bool warn)
|
||||
|
||||
char line[512];
|
||||
|
||||
List<ke::AString *>::iterator block_iter;
|
||||
|
||||
while (!feof(fp))
|
||||
{
|
||||
pluginName[0] = '\0';
|
||||
@ -116,11 +114,9 @@ int CPluginMngr::loadPluginsFromFile(const char* filename, bool warn)
|
||||
}
|
||||
|
||||
bool skip = false;
|
||||
for (block_iter = m_BlockList.begin();
|
||||
block_iter != m_BlockList.end();
|
||||
block_iter++)
|
||||
for (const auto &block : m_BlockList)
|
||||
{
|
||||
if ((*block_iter)->compare(pluginName) == 0)
|
||||
if (block->compare(pluginName) == 0)
|
||||
{
|
||||
skip = true;
|
||||
break;
|
||||
@ -489,12 +485,8 @@ AutoConfig *CPluginMngr::CPlugin::GetConfig(size_t i)
|
||||
|
||||
char *CPluginMngr::ReadIntoOrFromCache(const char *file, size_t &bufsize)
|
||||
{
|
||||
List<plcache_entry *>::iterator iter;
|
||||
plcache_entry *pl;
|
||||
|
||||
for (iter=m_plcache.begin(); iter!=m_plcache.end(); iter++)
|
||||
for (const auto *pl : m_plcache)
|
||||
{
|
||||
pl = (*iter);
|
||||
if (pl->path.compare(file) == 0)
|
||||
{
|
||||
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->buffer = NULL;
|
||||
@ -539,12 +531,8 @@ char *CPluginMngr::ReadIntoOrFromCache(const char *file, size_t &bufsize)
|
||||
|
||||
void CPluginMngr::InvalidateCache()
|
||||
{
|
||||
List<plcache_entry *>::iterator iter;
|
||||
plcache_entry *pl;
|
||||
|
||||
for (iter=m_plcache.begin(); iter!=m_plcache.end(); iter++)
|
||||
for (auto *pl : m_plcache)
|
||||
{
|
||||
pl = (*iter);
|
||||
delete [] pl->buffer;
|
||||
delete pl->file;
|
||||
delete pl;
|
||||
@ -558,7 +546,7 @@ void CPluginMngr::InvalidateFileInCache(const char *file, bool freebuf)
|
||||
List<plcache_entry *>::iterator iter;
|
||||
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);
|
||||
if (pl->path.compare(file) == 0)
|
||||
|
@ -307,11 +307,11 @@ CvarInfo* CvarManager::FindCvar(size_t index)
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
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.
|
||||
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()
|
||||
{
|
||||
// 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)->hooks.clear();
|
||||
cvar->binds.clear();
|
||||
cvar->hooks.clear();
|
||||
}
|
||||
|
||||
// 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);
|
||||
count++;
|
||||
} else {
|
||||
iter++;
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
|
||||
@ -157,7 +157,7 @@ size_t RemoveLibraries(void *parent)
|
||||
iter = g_libraries.erase(iter);
|
||||
count++;
|
||||
} else {
|
||||
iter++;
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
|
||||
@ -166,12 +166,8 @@ size_t RemoveLibraries(void *parent)
|
||||
|
||||
bool FindLibrary(const char *name, LibType type)
|
||||
{
|
||||
List<Library *>::iterator iter;
|
||||
Library *lib;
|
||||
|
||||
for (iter = g_libraries.begin(); iter != g_libraries.end(); iter++)
|
||||
for (auto *lib : g_libraries)
|
||||
{
|
||||
lib = (*iter);
|
||||
if (lib->type != type)
|
||||
continue;
|
||||
if (strcasecmp(lib->name.chars(), name) == 0)
|
||||
@ -201,7 +197,7 @@ LibError RunLibCommand(const LibDecoder *enc)
|
||||
expect = LibType_Class;
|
||||
|
||||
/** see if it exists */
|
||||
for (; iter != end; iter++)
|
||||
for (; iter != end; ++iter)
|
||||
{
|
||||
lib = (*iter);
|
||||
if (lib->type != expect)
|
||||
@ -231,7 +227,7 @@ LibError RunLibCommand(const LibDecoder *enc)
|
||||
expect = LibType_Class;
|
||||
|
||||
/** see if it exists */
|
||||
for (; iter != end; iter++)
|
||||
for (; iter != end; ++iter)
|
||||
{
|
||||
lib = (*iter);
|
||||
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);
|
||||
if (g_auth_funcs.size())
|
||||
{
|
||||
List<AUTHORIZEFUNC>::iterator iter, end=g_auth_funcs.end();
|
||||
AUTHORIZEFUNC fn;
|
||||
for (iter=g_auth_funcs.begin(); iter!=end; iter++)
|
||||
for (auto &fn : g_auth_funcs)
|
||||
{
|
||||
fn = (*iter);
|
||||
fn(pPlayer->index, authid);
|
||||
}
|
||||
}
|
||||
@ -989,11 +986,8 @@ void C_ClientUserInfoChanged_Post(edict_t *pEntity, char *infobuffer)
|
||||
const char* authid = GETPLAYERAUTHID(pEntity);
|
||||
if (g_auth_funcs.size())
|
||||
{
|
||||
List<AUTHORIZEFUNC>::iterator iter, end=g_auth_funcs.end();
|
||||
AUTHORIZEFUNC fn;
|
||||
for (iter=g_auth_funcs.begin(); iter!=end; iter++)
|
||||
for (auto &fn : g_auth_funcs)
|
||||
{
|
||||
fn = (*iter);
|
||||
fn(pPlayer->index, authid);
|
||||
}
|
||||
}
|
||||
@ -1193,11 +1187,8 @@ void C_StartFrame_Post(void)
|
||||
(*player)->Authorize();
|
||||
if (g_auth_funcs.size())
|
||||
{
|
||||
List<AUTHORIZEFUNC>::iterator iter, end=g_auth_funcs.end();
|
||||
AUTHORIZEFUNC fn;
|
||||
for (iter=g_auth_funcs.begin(); iter!=end; iter++)
|
||||
for (auto &fn : g_auth_funcs)
|
||||
{
|
||||
fn = (*iter);
|
||||
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();
|
||||
ClientCvarQuery_Info *info;
|
||||
for (iter=pPlayer->queries.begin(); iter!=end; iter++)
|
||||
for (iter=pPlayer->queries.begin(); iter!=end; ++iter)
|
||||
{
|
||||
info = (*iter);
|
||||
if ( info->requestId == requestId )
|
||||
|
Loading…
Reference in New Issue
Block a user