Skip to content

Use C++11 range based loops #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions amx-deps/src/CFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ int CFunctions::amxLoadPlugin(lua_State *luaVM) {
#endif

HMODULE hPlugin = loadLib(pluginPath.c_str());

if(!hPlugin) {
lua_pushboolean(luaVM, 0);
return 1;
Expand Down Expand Up @@ -184,8 +184,8 @@ int CFunctions::amxLoad(lua_State *luaVM) {
amx_TimeInit(amx);
amx_FileInit(amx);
err = amx_SAMPInit(amx);
for(map< string, SampPlugin* >::iterator it = loadedPlugins.begin(); it != loadedPlugins.end(); it++) {
AmxLoad_t* pfnAmxLoad = it->second->AmxLoad;
for (const auto& plugin : loadedPlugins) {
AmxLoad_t* pfnAmxLoad = plugin.second->AmxLoad;
if (pfnAmxLoad) {
err = pfnAmxLoad(amx);
}
Expand Down Expand Up @@ -290,8 +290,8 @@ int CFunctions::amxCall(lua_State *luaVM) {
cell ret;
int err = amx_Exec(amx, &ret, fnIndex);
// Release string arguments
for(vector<cell>::iterator it = stringsToRelease.begin(); it != stringsToRelease.end(); it++) {
amx_Release(amx, *it);
for (const auto& amxStringAddr : stringsToRelease) {
amx_Release(amx, amxStringAddr);
}
if(err != AMX_ERR_NONE) {
if(err == AMX_ERR_SLEEP)
Expand Down Expand Up @@ -377,16 +377,16 @@ int CFunctions::amxUnload(lua_State *luaVM) {
return 1;
}
// Call all plugins' AmxUnload function
for(map< string, SampPlugin* >::iterator piIt = loadedPlugins.begin(); piIt != loadedPlugins.end(); piIt++) {
AmxUnload_t *pfnAmxUnload = piIt->second->AmxUnload;
for (const auto& plugin : loadedPlugins) {
AmxUnload_t *pfnAmxUnload = plugin.second->AmxUnload;
if (pfnAmxUnload) {
pfnAmxUnload(amx);
}
}
// Close any open databases
if(loadedDBs.find(amx) != loadedDBs.end()) {
for(map< int, sqlite3 * >::iterator dbIt = loadedDBs[amx].begin(); dbIt != loadedDBs[amx].end(); dbIt++)
sqlite3_close(dbIt->second);
for (const auto& db : loadedDBs[amx])
sqlite3_close(db.second);
loadedDBs.erase(amx);
}
// Unload
Expand All @@ -402,13 +402,13 @@ int CFunctions::amxUnload(lua_State *luaVM) {

// amxUnloadAllPlugins()
int CFunctions::amxUnloadAllPlugins(lua_State *luaVM) {
for (map< string, SampPlugin* >::iterator it = loadedPlugins.begin(); it != loadedPlugins.end(); it++) {
Unload_t* Unload = it->second->Unload;
for (const auto& plugin : loadedPlugins) {
Unload_t* Unload = it.second->Unload;
if (Unload) {
Unload();
}
freeLib(it->second->pPluginPointer);
delete it->second;
freeLib(it.second->pPluginPointer);
delete it.second;
}
loadedPlugins.clear();
vecPfnProcessTick.clear();
Expand Down Expand Up @@ -492,9 +492,9 @@ int CFunctions::pawn(lua_State *luaVM) {

int fnIndex;
AMX *amx = NULL;
for(vector<AMX *>::iterator it = amxs.begin(); it != amxs.end(); it++) {
if(amx_FindPublic(*it, fnName, &fnIndex) == AMX_ERR_NONE) {
amx = *it;
for (const auto& it : amxs) {
if(amx_FindPublic(it, fnName, &fnIndex) == AMX_ERR_NONE) {
amx = it;
break;
}
}
Expand Down
16 changes: 8 additions & 8 deletions amx-deps/src/ml_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ void logprintf(char *fmt, ...) {
int AMXCallPublicFilterScript(char *fnName) {
int fnIndex = -1;
cell ret = 0;
for(map< AMX *, AMXPROPS >::iterator it = loadedAMXs.begin(); it != loadedAMXs.end(); it++) {
if(amx_FindPublic(it->first, "OnFilterScriptInit", &fnIndex) != AMX_ERR_NONE)
for (const auto& it : loadedAMXs) {
if(amx_FindPublic(it.first, "OnFilterScriptInit", &fnIndex) != AMX_ERR_NONE)
continue;
if(amx_FindPublic(it->first, fnName, &fnIndex) != AMX_ERR_NONE)
if(amx_FindPublic(it.first, fnName, &fnIndex) != AMX_ERR_NONE)
continue;
amx_Exec(it->first, &ret, fnIndex);
amx_Exec(it.first, &ret, fnIndex);
return ret;
}
return 0;
Expand All @@ -130,12 +130,12 @@ int AMXCallPublicFilterScript(char *fnName) {
int AMXCallPublicGameMode(char *fnName) {
int fnIndex = -1;
cell ret = 0;
for(map< AMX *, AMXPROPS >::iterator it = loadedAMXs.begin(); it != loadedAMXs.end(); it++) {
if(amx_FindPublic(it->first, "OnGameModeInit", &fnIndex) != AMX_ERR_NONE)
for(const auto& it : loadedAMXs) {
if(amx_FindPublic(it.first, "OnGameModeInit", &fnIndex) != AMX_ERR_NONE)
continue;
if(amx_FindPublic(it->first, fnName, &fnIndex) != AMX_ERR_NONE)
if(amx_FindPublic(it.first, fnName, &fnIndex) != AMX_ERR_NONE)
continue;
amx_Exec(it->first, &ret, fnIndex);
amx_Exec(it.first, &ret, fnIndex);
return ret;
}
return 0;
Expand Down
6 changes: 3 additions & 3 deletions amx-deps/src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,9 @@ void lua_pushremotevalues(lua_State *localVM, lua_State *remoteVM, int num) {

vector<AMX *> getResourceAMXs(lua_State *luaVM) {
vector<AMX *> amxs;
for(map< AMX *, AMXPROPS >::iterator it = loadedAMXs.begin(); it != loadedAMXs.end(); it++) {
if(it->second.resourceVM == luaVM)
amxs.push_back(it->first);
for (const auto& it : loadedAMXs) {
if (it.second.resourceVM == luaVM)
amxs.push_back(it.first);
}
return amxs;
}
Expand Down