From 82cd96aef62adf19a522aa1ac949052dfc6a5f34 Mon Sep 17 00:00:00 2001 From: Benoist <14257866+Kenzzer@users.noreply.github.com> Date: Thu, 17 Sep 2026 20:56:47 -0400 Subject: [PATCH] Strip sourcehook containers (#2578) --- bridge/include/IExtensionBridge.h | 11 ++- bridge/include/IScriptManager.h | 17 +++-- core/ConCmdManager.cpp | 20 +++--- core/ConCmdManager.h | 10 ++- core/ConVarManager.cpp | 26 ++++--- core/ConVarManager.h | 10 ++- core/ConsoleDetours.cpp | 6 +- core/CoreConfig.cpp | 18 +++-- core/EventManager.cpp | 19 +++--- core/EventManager.h | 12 ++-- core/HalfLife2.cpp | 8 +-- core/HalfLife2.h | 12 ++-- core/MenuManager.h | 9 ++- core/MenuStyle_Radio.cpp | 4 +- core/MenuStyle_Radio.h | 10 +-- core/MenuStyle_Valve.cpp | 2 +- core/MenuVoting.h | 5 +- core/NextMap.cpp | 7 +- core/NextMap.h | 4 +- core/PlayerManager.cpp | 49 +++++--------- core/PlayerManager.h | 20 +++--- core/TimerSys.cpp | 34 +++++----- core/TimerSys.h | 17 ++--- core/UserMessagePBHelpers.h | 4 +- core/UserMessages.cpp | 22 +++--- core/UserMessages.h | 14 ++-- core/concmd_cleaner.cpp | 11 ++- core/logic/AdminCache.cpp | 22 +++--- core/logic/AdminCache.h | 12 ++-- core/logic/BaseWorker.cpp | 3 +- core/logic/BaseWorker.h | 4 +- core/logic/Database.cpp | 2 +- core/logic/Database.h | 11 ++- core/logic/ExtensionSys.cpp | 93 +++++++++++--------------- core/logic/ExtensionSys.h | 27 ++++---- core/logic/GameConfigs.cpp | 15 ++--- core/logic/MemoryUtils.h | 5 +- core/logic/NativeOwner.cpp | 10 +-- core/logic/NativeOwner.h | 8 +-- core/logic/PhraseCollection.h | 5 +- core/logic/PluginSys.cpp | 15 ++--- core/logic/PluginSys.h | 24 +++---- core/logic/RootConsoleMenu.cpp | 11 ++- core/logic/RootConsoleMenu.h | 11 ++- core/logic/ShareSys.cpp | 2 +- core/logic/ShareSys.h | 6 +- core/logic/Translator.h | 17 +++-- core/logic/smn_core.cpp | 4 +- core/logic/smn_database.cpp | 2 +- core/logic/smn_maplists.cpp | 14 ++-- core/logic/smn_menus.cpp | 17 ++--- core/logic/smn_players.cpp | 19 +++--- core/logic/smn_timers.cpp | 15 ++--- core/smn_console.cpp | 17 ++--- core/smn_keyvalues.cpp | 28 ++++---- core/smn_keyvalues.h | 4 +- core/smn_nextmap.cpp | 3 +- core/smn_usermsgs.cpp | 18 +++-- core/sourcemod.cpp | 6 +- core/sourcemod.h | 8 +-- extensions/dhooks/natives.cpp | 2 +- extensions/dhooks/vhook.h | 5 +- extensions/pgsql/pgsql/PgDatabase.h | 10 +-- extensions/pgsql/pgsql/PgDriver.cpp | 9 +-- extensions/pgsql/pgsql/PgDriver.h | 8 +-- extensions/sdkhooks/extension.cpp | 6 +- extensions/sdkhooks/extension.h | 4 +- extensions/sdktools/extension.cpp | 6 +- extensions/sdktools/output.cpp | 16 ++--- extensions/sdktools/output.h | 8 +-- extensions/sdktools/outputnatives.cpp | 24 +++---- extensions/sdktools/teamnatives.cpp | 4 +- extensions/sdktools/tempents.cpp | 3 +- extensions/sdktools/tempents.h | 12 ++-- extensions/sdktools/tenatives.cpp | 14 ++-- extensions/sdktools/vcallbuilder.cpp | 4 +- extensions/sdktools/vcallbuilder.h | 4 +- extensions/sdktools/vnatives.cpp | 48 ++++++------- extensions/sdktools/vnatives.h | 4 +- extensions/sdktools/vsound.cpp | 21 +++--- extensions/sdktools/vsound.h | 8 +-- extensions/sqlite/driver/SqDatabase.h | 2 +- extensions/sqlite/driver/SqDriver.cpp | 9 +-- extensions/sqlite/driver/SqDriver.h | 9 ++- extensions/sqlite/driver/SqQuery.h | 3 +- extensions/sqlite/driver/SqResults.cpp | 2 +- extensions/sqlite/driver/SqResults.h | 2 +- extensions/topmenus/TopMenu.cpp | 14 ++-- extensions/topmenus/TopMenu.h | 23 +++---- extensions/topmenus/TopMenuManager.cpp | 18 ++--- extensions/topmenus/TopMenuManager.h | 5 +- extensions/updater/Updater.h | 8 +-- extensions/updater/extension.cpp | 19 +++--- public/sm_queue.h | 10 ++- 94 files changed, 512 insertions(+), 671 deletions(-) diff --git a/bridge/include/IExtensionBridge.h b/bridge/include/IExtensionBridge.h index 4b41795f..3a2c661a 100644 --- a/bridge/include/IExtensionBridge.h +++ b/bridge/include/IExtensionBridge.h @@ -29,13 +29,12 @@ #include #include -#include +#include struct edict_t; namespace SourceMod { -using namespace SourceHook; using namespace SourcePawn; class SMPlugin; @@ -51,8 +50,8 @@ public: virtual IExtension *GetExtensionFromIdent(IdentityToken_t *token) = 0; virtual void BindChildPlugin(IExtension *ext, SMPlugin *plugin) = 0; virtual void AddRawDependency(IExtension *myself, IdentityToken_t *token, void *iface) = 0; - virtual const CVector *ListExtensions() = 0; - virtual void FreeExtensionList(const CVector *list) = 0; + virtual const std::vector *ListExtensions() = 0; + virtual void FreeExtensionList(const std::vector *list) = 0; virtual void CallOnCoreMapEnd() = 0; }; @@ -67,13 +66,13 @@ public: { extensions_->FreeExtensionList(list_); } - const CVector *operator ->() + const std::vector *operator ->() { return list_; } private: IExtensionSys *extensions_; - const CVector *list_; + const std::vector *list_; }; } // namespace SourceMod diff --git a/bridge/include/IScriptManager.h b/bridge/include/IScriptManager.h index beff47b4..408a021a 100644 --- a/bridge/include/IScriptManager.h +++ b/bridge/include/IScriptManager.h @@ -29,12 +29,11 @@ #include #include -#include -#include +#include +#include namespace SourceMod { -using namespace SourceHook; using namespace SourcePawn; class IChangeableForward; @@ -47,8 +46,8 @@ enum LibraryAction struct AutoConfig { - SourceHook::String autocfg; - SourceHook::String folder; + std::string autocfg; + std::string folder; bool create; }; @@ -81,8 +80,8 @@ public: virtual SMPlugin *FindPluginByConsoleArg(const char *text) = 0; virtual SMPlugin *FindPluginByHandle(Handle_t hndl, HandleError *errp) = 0; virtual bool UnloadPlugin(IPlugin *plugin) = 0; - virtual const CVector *ListPlugins() = 0; - virtual void FreePluginList(const CVector *list) = 0; + virtual const std::vector *ListPlugins() = 0; + virtual void FreePluginList(const std::vector *list) = 0; virtual void AddFunctionsToForward(const char *name, IChangeableForward *fwd) = 0; }; @@ -97,13 +96,13 @@ public: { scripts_->FreePluginList(list_); } - const CVector *operator ->() + const std::vector *operator ->() { return list_; } private: IScriptManager *scripts_; - const CVector *list_; + const std::vector *list_; }; } // namespace SourceMod diff --git a/core/ConCmdManager.cpp b/core/ConCmdManager.cpp index 5c20205d..f51f0b9c 100644 --- a/core/ConCmdManager.cpp +++ b/core/ConCmdManager.cpp @@ -76,7 +76,7 @@ void ConCmdManager::OnUnlinkConCommandBase(ConCommandBase *pBase, const char *na if (!m_Cmds.retrieve(name, &pInfo)) return; - CmdHookList::iterator iter = pInfo->hooks.begin(); + auto iter = pInfo->hooks.begin(); while (iter != pInfo->hooks.end()) { CmdHook *hook = *iter; @@ -87,7 +87,7 @@ void ConCmdManager::OnUnlinkConCommandBase(ConCommandBase *pBase, const char *na // The list is guaranteed to exist. PluginHookList *list; pPlugin->GetProperty("CommandList", (void **)&list, false); - for (PluginHookList::iterator hiter = list->begin(); hiter != list->end(); hiter++) + for (auto hiter = list->begin(); hiter != list->end(); hiter++) { if (*hiter == hook) { @@ -112,7 +112,7 @@ void ConCmdManager::OnPluginDestroyed(IPlugin *plugin) if (!plugin->GetProperty("CommandList", (void **)&pList, true)) return; - PluginHookList::iterator iter = pList->begin(); + auto iter = pList->begin(); while (iter != pList->end()) { CmdHook *hook = *iter; @@ -163,7 +163,7 @@ ResultType ConCmdManager::DispatchClientCommand(int client, const char *cmd, int } cell_t result = type; - for (CmdHookList::iterator iter = pInfo->hooks.begin(); iter != pInfo->hooks.end(); iter++) + for (auto iter = pInfo->hooks.begin(); iter != pInfo->hooks.end(); iter++) { CmdHook *hook = *iter; @@ -235,7 +235,7 @@ bool ConCmdManager::InternalDispatch(int client, const ICommandArgs *args) : client; int dedicatedClient = engine->IsDedicatedServer() ? 0 : g_Players.ListenClient(); - for (CmdHookList::iterator iter = pInfo->hooks.begin(); iter != pInfo->hooks.end(); iter++) + for (auto iter = pInfo->hooks.begin(); iter != pInfo->hooks.end(); iter++) { CmdHook *hook = *iter; @@ -398,7 +398,7 @@ void RegisterInPlugin(CmdHook *hook) const char *orig = hook->info->pCmd->GetName(); /* Insert this into the help list, SORTED alphabetically. */ - PluginHookList::iterator iter = pList->begin(); + auto iter = pList->begin(); while (iter != pList->end()) { const char *cmd = (*iter)->info->pCmd->GetName(); @@ -415,7 +415,7 @@ void RegisterInPlugin(CmdHook *hook) void ConCmdManager::AddToCmdList(ConCmdInfo *info) { - List::iterator iter = m_CmdList.begin(); + auto iter = m_CmdList.begin(); ConCmdInfo *pInfo; bool inserted = false; const char *orig = NULL; @@ -451,7 +451,7 @@ void ConCmdManager::UpdateAdminCmdFlags(const char *cmd, OverrideType type, Flag if (!m_Cmds.retrieve(cmd, &pInfo)) return; - for (CmdHookList::iterator iter = pInfo->hooks.begin(); iter != pInfo->hooks.end(); iter++) + for (auto iter = pInfo->hooks.begin(); iter != pInfo->hooks.end(); iter++) { if (!iter->admin) continue; @@ -471,7 +471,7 @@ void ConCmdManager::UpdateAdminCmdFlags(const char *cmd, OverrideType type, Flag RefPtr group(r->value); - for (PluginHookList::iterator iter = group->hooks.begin(); iter != group->hooks.end(); iter++) + for (auto iter = group->hooks.begin(); iter != group->hooks.end(); iter++) { CmdHook *hook = *iter; if (!remove) @@ -613,7 +613,7 @@ void ConCmdManager::OnRootConsoleCommand(const char *cmdname, const ICommandArgs const char *help; UTIL_ConsolePrint("[SM] Listing commands for: %s", plname); UTIL_ConsolePrint(" %-17.16s %-8.7s %s", "[Name]", "[Type]", "[Help]"); - for (PluginHookList::iterator iter = pList->begin(); iter != pList->end(); iter++) + for (auto iter = pList->begin(); iter != pList->end(); iter++) { CmdHook *hook = *iter; if (hook->type == CmdHook::Server) diff --git a/core/ConCmdManager.h b/core/ConCmdManager.h index f3b882e2..20ce2608 100644 --- a/core/ConCmdManager.h +++ b/core/ConCmdManager.h @@ -43,16 +43,14 @@ #include "sm_globals.h" #include "sourcemm_api.h" #include -#include -#include +#include +#include #include #include #include "concmd_cleaner.h" #include "GameHooks.h" #include -using namespace SourceHook; - struct CmdHook; struct ConCmdInfo; @@ -137,7 +135,7 @@ struct ConCmdInfo }; }; -typedef List ConCmdList; +typedef std::list ConCmdList; class ConCmdManager : public SMGlobalClass, @@ -180,7 +178,7 @@ private: bool CheckAccess(int client, const char *cmd, AdminCmdInfo *pAdmin); ConCmdInfo *FindInTrie(const char *name); public: - inline const List & GetCommandList() + inline const std::list & GetCommandList() { return m_CmdList; } diff --git a/core/ConVarManager.cpp b/core/ConVarManager.cpp index 9f4e0a40..58ae6e4f 100644 --- a/core/ConVarManager.cpp +++ b/core/ConVarManager.cpp @@ -30,7 +30,7 @@ #include "ConVarManager.h" #include "HalfLife2.h" #include "sm_stringutil.h" -#include +#include #include #include "logic_bridge.h" #include "sourcemod.h" @@ -40,7 +40,7 @@ ConVarManager g_ConVarManager; const ParamType CONVARCHANGE_PARAMS[] = {Param_Cell, Param_String, Param_String}; -typedef List ConVarList; +typedef std::list ConVarList; NameHashSet convar_cache; enum { @@ -114,7 +114,7 @@ void ConVarManager::OnSourceModAllInitialized() void ConVarManager::OnSourceModShutdown() { - List::iterator iter = m_ConVars.begin(); + auto iter = m_ConVars.begin(); HandleSecurity sec(NULL, g_pCoreIdent); /* Iterate list of ConVarInfo structures, remove every one of them */ @@ -217,7 +217,7 @@ void ConVarManager::OnPluginUnloaded(IPlugin *plugin) } /* Clear any references to this plugin as the convar creator */ - for (List::iterator iter = m_ConVars.begin(); iter != m_ConVars.end(); ++iter) + for (auto iter = m_ConVars.begin(); iter != m_ConVars.end(); ++iter) { ConVarInfo *pInfo = (*iter); @@ -230,7 +230,7 @@ void ConVarManager::OnPluginUnloaded(IPlugin *plugin) const IPluginRuntime * pRuntime = plugin->GetRuntime(); /* Remove convar queries for this plugin that haven't returned results yet */ - for (List::iterator iter = m_ConVarQueries.begin(); iter != m_ConVarQueries.end();) + for (auto iter = m_ConVarQueries.begin(); iter != m_ConVarQueries.end();) { ConVarQuery &query = (*iter); if (query.pCallback->GetParentRuntime() == pRuntime) @@ -246,7 +246,7 @@ void ConVarManager::OnPluginUnloaded(IPlugin *plugin) void ConVarManager::OnClientDisconnected(int client) { /* Remove convar queries for this client that haven't returned results yet */ - for (List::iterator iter = m_ConVarQueries.begin(); iter != m_ConVarQueries.end();) + for (auto iter = m_ConVarQueries.begin(); iter != m_ConVarQueries.end();) { ConVarQuery &query = (*iter); if (query.client == client) @@ -311,7 +311,6 @@ void ConVarManager::OnRootConsoleCommand(const char *cmdname, const ICommandArgs const char *plname = IS_STR_FILLED(plinfo->name) ? plinfo->name : plugin->GetFilename(); ConVarList *pConVarList; - ConVarList::iterator iter; /* If no convar list... */ if (!plugin->GetProperty("ConVarList", (void **)&pConVarList)) @@ -327,7 +326,7 @@ void ConVarManager::OnRootConsoleCommand(const char *cmdname, const ICommandArgs } /* Iterate convar list and display/reset each one */ - for (iter = pConVarList->begin(); iter != pConVarList->end(); iter++) + for (auto iter = pConVarList->begin(); iter != pConVarList->end(); iter++) { /*const */ConVar *pConVar = const_cast(*iter); if (!wantReset) @@ -589,7 +588,6 @@ QueryCvarCookie_t ConVarManager::QueryClientConVar(edict_t *pPlayer, const char void ConVarManager::AddConVarToPluginList(IPlugin *plugin, const ConVar *pConVar) { ConVarList *pConVarList; - ConVarList::iterator iter; bool inserted = false; const char *orig = pConVar->GetName(); @@ -599,14 +597,14 @@ void ConVarManager::AddConVarToPluginList(IPlugin *plugin, const ConVar *pConVar pConVarList = new ConVarList(); plugin->SetProperty("ConVarList", pConVarList); } - else if (pConVarList->find(pConVar) != pConVarList->end()) + else if (std::find(pConVarList->begin(), pConVarList->end(), pConVar) != pConVarList->end()) { /* If convar is already in list, then don't add it */ return; } /* Insert convar into list which is sorted alphabetically */ - for (iter = pConVarList->begin(); iter != pConVarList->end(); iter++) + for (auto iter = pConVarList->begin(); iter != pConVarList->end(); iter++) { if (strcmp(orig, (*iter)->GetName()) < 0) { @@ -678,9 +676,9 @@ void ConVarManager::OnClientQueryFinished(QueryCvarCookie_t cookie, { IPluginFunction *pCallback = NULL; cell_t value = 0; - List::iterator iter; - for (iter = m_ConVarQueries.begin(); iter != m_ConVarQueries.end(); iter++) + auto iter = m_ConVarQueries.begin(); + for (; iter != m_ConVarQueries.end(); iter++) { ConVarQuery &query = (*iter); if (query.cookie == cookie) @@ -691,7 +689,7 @@ void ConVarManager::OnClientQueryFinished(QueryCvarCookie_t cookie, } } - if (pCallback) + if (pCallback && iter != m_ConVarQueries.end()) { cell_t ret; diff --git a/core/ConVarManager.h b/core/ConVarManager.h index a613aa43..21c2b26a 100644 --- a/core/ConVarManager.h +++ b/core/ConVarManager.h @@ -34,7 +34,7 @@ #include "sm_globals.h" #include "sourcemm_api.h" -#include +#include #include #include #include @@ -45,8 +45,6 @@ #include "PlayerManager.h" #include -using namespace SourceHook; - class IConVarChangeListener { public: @@ -63,7 +61,7 @@ struct ConVarInfo IChangeableForward *pChangeForward; /**< Forward associated with convar */ ConVar *pVar; /**< The actual convar */ IPlugin *pPlugin; /**< Originally owning plugin */ - List changeListeners; + std::list changeListeners; struct ConVarPolicy { @@ -175,8 +173,8 @@ private: static void AddConVarToPluginList(IPlugin *plugin, const ConVar *pConVar); private: HandleType_t m_ConVarType; - List m_ConVars; - List m_ConVarQueries; + std::list m_ConVars; + std::list m_ConVarQueries; }; extern ConVarManager g_ConVarManager; diff --git a/core/ConsoleDetours.cpp b/core/ConsoleDetours.cpp index 69badc43..d7a4a65d 100644 --- a/core/ConsoleDetours.cpp +++ b/core/ConsoleDetours.cpp @@ -76,7 +76,7 @@ class GenericCommandHooker : public IConCommandLinkListener int hook; unsigned int refcount; }; - CVector vtables; + std::vector vtables; bool enabled; SourceHook::MemFuncInfo dispatch; @@ -144,7 +144,7 @@ class GenericCommandHooker : public IConCommandLinkListener vtables[i].refcount = 0; for (ConCommandBaseIterator iter; iter.IsValid(); iter.Next()) MakeHookable(iter.Get()); - CVector::iterator iter = vtables.begin(); + auto iter = vtables.begin(); while (iter != vtables.end()) { if ((*iter).refcount) @@ -191,7 +191,7 @@ class GenericCommandHooker : public IConCommandLinkListener if (vtables[index].refcount == 0) { SH_REMOVE_HOOK_ID(vtables[index].hook); - vtables.erase(vtables.iterAt(index)); + vtables.erase(vtables.begin() + index); } } diff --git a/core/CoreConfig.cpp b/core/CoreConfig.cpp index 678f9a4e..71ecb058 100644 --- a/core/CoreConfig.cpp +++ b/core/CoreConfig.cpp @@ -41,13 +41,11 @@ #include #include #include -#include +#include #include #include #include -using namespace SourceHook; - #ifdef PLATFORM_WINDOWS ConVar sm_corecfgfile("sm_corecfgfile", "addons\\sourcemod\\configs\\core.cfg", 0, "SourceMod core configuration file"); #elif defined PLATFORM_LINUX || defined PLATFORM_APPLE @@ -399,9 +397,9 @@ inline bool SM_CvarExistsInConfig(ke::HashMap &convars, const char *cvar_name) +bool SM_CvarExistsInPlugin(std::list &convars, const char *cvar_name) { - for (List::iterator iter = convars.begin(); iter != convars.end(); iter++) + for (auto iter = convars.begin(); iter != convars.end(); iter++) { const ConVar *cvar = (*iter); #if SOURCE_ENGINE >= SE_ORANGEBOX @@ -425,7 +423,7 @@ bool SM_CvarExistsInPlugin(List &convars, const char *cvar_name) bool SM_ConfigCheckRegeneration( const char *file, ke::HashMap &existing_cvars, - List &convars) + std::list &convars) { FILE *fp = fopen(file, "rt"); if (!fp) @@ -438,7 +436,7 @@ bool SM_ConfigCheckRegeneration( fclose(fp); /* #1. Check if the plugin's cvar list has a cvar that doesn't exist in the config file. */ - for (List::iterator iter = convars.begin(); iter != convars.end(); iter++) + for (auto iter = convars.begin(); iter != convars.end(); iter++) { const ConVar *cvar = (*iter); #if SOURCE_ENGINE >= SE_ORANGEBOX @@ -478,7 +476,7 @@ inline void SM_ExecuteConfigFile(const char *file) bool SM_GenerateConfigFile( IPlugin *pl, const char *file, - List &convars, + std::list &convars, bool needs_regeneration = false, ke::HashMap *existing_cvars = NULL) { @@ -510,7 +508,7 @@ bool SM_GenerateConfigFile( fprintf(fp, "\n\n"); float x; - for (List::iterator iter = convars.begin(); iter != convars.end(); iter++) + for (auto iter = convars.begin(); iter != convars.end(); iter++) { const ConVar *cvar = (*iter); #if SOURCE_ENGINE >= SE_ORANGEBOX @@ -683,7 +681,7 @@ bool SM_ExecuteConfig(IPlugin *pl, AutoConfig *cfg, bool can_create) return can_create; } - List *convars = NULL; + std::list *convars = NULL; if (!pl->GetProperty("ConVarList", (void **)&convars, false) || !convars) { if (file_exists) diff --git a/core/EventManager.cpp b/core/EventManager.cpp index 077d28c0..79088b38 100644 --- a/core/EventManager.cpp +++ b/core/EventManager.cpp @@ -41,7 +41,7 @@ EventManager g_EventManager; SH_DECL_HOOK2(IGameEventManager2, FireEvent, SH_NOATTRIB, 0, bool, IGameEvent *, bool); const ParamType GAMEEVENT_PARAMS[] = {Param_Cell, Param_String, Param_Cell}; -typedef List EventHookList; +typedef std::list EventHookList; class EventForwardFilter : public IForwardFilter { @@ -64,13 +64,10 @@ EventManager::EventManager() : m_EventType(0) EventManager::~EventManager() { /* Free memory used by EventInfo structs if any */ - CStack::iterator iter; - for (iter = m_FreeEvents.begin(); iter != m_FreeEvents.end(); iter++) - { - delete (*iter); + while (!m_FreeEvents.empty()) { + delete m_FreeEvents.top(); + m_FreeEvents.pop(); } - - m_FreeEvents.popall(); } void EventManager::OnSourceModAllInitialized() @@ -306,7 +303,7 @@ EventHookError EventManager::UnhookEvent(const char *name, IPluginFunction *pFun } /* Make sure the event was actually being hooked */ - if (pHookList->find(pHook) == pHookList->end()) + if (std::find(pHookList->begin(), pHookList->end(), pHook) == pHookList->end()) { return EventHookErr_NotActive; } @@ -335,7 +332,7 @@ EventInfo *EventManager::CreateEvent(IPluginContext *pContext, const char *name, { pInfo = new EventInfo(); } else { - pInfo = m_FreeEvents.front(); + pInfo = m_FreeEvents.top(); m_FreeEvents.pop(); } @@ -464,7 +461,7 @@ bool EventManager::OnFireEvent_Post(IGameEvent *pEvent, bool bDontBroadcast) RETURN_META_VALUE(MRES_IGNORED, false); } - pHook = m_EventStack.front(); + pHook = m_EventStack.top(); if (pHook != NULL) { @@ -475,7 +472,7 @@ bool EventManager::OnFireEvent_Post(IGameEvent *pEvent, bool bDontBroadcast) if (pHook->postCopy) { info.bDontBroadcast = bDontBroadcast; - info.pEvent = m_EventCopies.front(); + info.pEvent = m_EventCopies.top(); info.pOwner = NULL; hndl = handlesys->CreateHandle(m_EventType, &info, NULL, g_pCoreIdent, NULL); diff --git a/core/EventManager.h b/core/EventManager.h index b1492314..c3710269 100644 --- a/core/EventManager.h +++ b/core/EventManager.h @@ -35,16 +35,14 @@ #include "sm_globals.h" #include "sourcemm_api.h" #include -#include -#include +#include +#include #include #include #include class IClient; -using namespace SourceHook; - struct EventInfo { EventInfo() @@ -140,9 +138,9 @@ private: // IGameEventManager2 hooks private: HandleType_t m_EventType; NameHashSet m_EventHooks; - CStack m_FreeEvents; - CStack m_EventStack; - CStack m_EventCopies; + std::stack m_FreeEvents; + std::stack m_EventStack; + std::stack m_EventCopies; }; extern EventManager g_EventManager; diff --git a/core/HalfLife2.cpp b/core/HalfLife2.cpp index 84109f75..ba6885e2 100644 --- a/core/HalfLife2.cpp +++ b/core/HalfLife2.cpp @@ -827,7 +827,7 @@ void CHalfLife2::AddToFakeCliCmdQueue(int client, int userid, const char *cmd) { pFake = new DelayedFakeCliCmd; } else { - pFake = m_FreeCmds.front(); + pFake = m_FreeCmds.top(); m_FreeCmds.pop(); } @@ -923,7 +923,7 @@ const ICommandArgs *CHalfLife2::PeekCommandStack() return NULL; } - return m_CommandStack.front().args; + return m_CommandStack.top().args; } void CHalfLife2::PopCommandStack() @@ -934,9 +934,9 @@ void CHalfLife2::PopCommandStack() const char *CHalfLife2::CurrentCommandName() { #if SOURCE_ENGINE >= SE_ORANGEBOX - return m_CommandStack.front().args->Arg(0); + return m_CommandStack.top().args->Arg(0); #else - return m_CommandStack.front().cmd; + return m_CommandStack.top().cmd; #endif } diff --git a/core/HalfLife2.h b/core/HalfLife2.h index 5496a337..bf24f12c 100644 --- a/core/HalfLife2.h +++ b/core/HalfLife2.h @@ -32,9 +32,8 @@ #ifndef _INCLUDE_SOURCEMOD_CHALFLIFE2_H_ #define _INCLUDE_SOURCEMOD_CHALFLIFE2_H_ -#include -#include -#include +#include +#include #include #include #include @@ -54,7 +53,6 @@ namespace SourceMod { class ICommandArgs; } // namespace SourceMod -using namespace SourceHook; using namespace SourceMod; static const int ENTREF_MASK = (1 << 31); @@ -153,7 +151,7 @@ typedef NameHashSet DataMapCache; struct DelayedFakeCliCmd { - String cmd; + std::string cmd; int client; int userid; }; @@ -288,8 +286,8 @@ private: int m_SayTextMsg; int m_VGUIMenu; Queue m_CmdQueue; - CStack m_FreeCmds; - CStack m_CommandStack; + std::stack m_FreeCmds; + std::stack m_CommandStack; Queue m_DelayedKicks; void *m_pGetCommandLine; #if SOURCE_ENGINE == SE_CSGO diff --git a/core/MenuManager.h b/core/MenuManager.h index 3c75347e..e7a8381a 100644 --- a/core/MenuManager.h +++ b/core/MenuManager.h @@ -33,14 +33,13 @@ #define _INCLUDE_SOURCEMOD_MENUMANAGER_H_ #include -#include -#include -#include +#include +#include +#include #include "sm_globals.h" #include using namespace SourceMod; -using namespace SourceHook; class MenuManager : public IMenuManager, @@ -102,7 +101,7 @@ protected: private: int m_ShowMenu; IMenuStyle *m_pDefaultStyle; - CVector m_Styles; + std::vector m_Styles; HandleType_t m_StyleType; HandleType_t m_MenuType; std::string m_SelectSound = ""; diff --git a/core/MenuStyle_Radio.cpp b/core/MenuStyle_Radio.cpp index 035219e3..0ca5ebf9 100644 --- a/core/MenuStyle_Radio.cpp +++ b/core/MenuStyle_Radio.cpp @@ -144,7 +144,7 @@ void CRadioStyle::OnSourceModShutdown() while (!m_FreeDisplays.empty()) { - delete m_FreeDisplays.front(); + delete m_FreeDisplays.top(); m_FreeDisplays.pop(); } } @@ -261,7 +261,7 @@ CRadioDisplay *CRadioStyle::MakeRadioDisplay(CRadioMenu *menu) } else { - display = m_FreeDisplays.front(); + display = m_FreeDisplays.top(); m_FreeDisplays.pop(); display->Reset(); } diff --git a/core/MenuStyle_Radio.h b/core/MenuStyle_Radio.h index afb356ef..0febb831 100644 --- a/core/MenuStyle_Radio.h +++ b/core/MenuStyle_Radio.h @@ -39,8 +39,8 @@ #include #include "UserMessages.h" #include "sm_fastlink.h" -#include -#include +#include +#include #include #include "logic/common_logic.h" #include "AutoHandleRooter.h" @@ -106,7 +106,7 @@ public: CRadioMenuPlayer *GetRadioMenuPlayer(int client); private: CRadioMenuPlayer *m_players; - CStack m_FreeDisplays; + std::stack m_FreeDisplays; }; class CRadioDisplay : public IMenuPanel @@ -133,8 +133,8 @@ public: //IMenuPanel unsigned int GetApproxMemUsage(); bool DirectSet(const char *str); private: - String m_BufferText; - String m_Title; + std::string m_BufferText; + std::string m_Title; unsigned int m_NextPos; int keys; }; diff --git a/core/MenuStyle_Valve.cpp b/core/MenuStyle_Valve.cpp index 89272098..102ad113 100644 --- a/core/MenuStyle_Valve.cpp +++ b/core/MenuStyle_Valve.cpp @@ -40,7 +40,7 @@ SH_DECL_HOOK4_void(IServerPluginHelpers, CreateMessage, SH_NOATTRIB, false, edic ValveMenuStyle g_ValveMenuStyle; extern const char *g_OptionNumTable[]; extern const char *g_OptionCmdTable[]; -CallClass *g_pSPHCC = NULL; +SourceHook::CallClass *g_pSPHCC = NULL; ValveMenuStyle::ValveMenuStyle() : m_players(new CValveMenuPlayer[256+1]) { diff --git a/core/MenuVoting.h b/core/MenuVoting.h index 7660b294..11f29931 100644 --- a/core/MenuVoting.h +++ b/core/MenuVoting.h @@ -34,11 +34,10 @@ #include #include -#include +#include #include "sm_globals.h" #include -using namespace SourceHook; using namespace SourceMod; class VoteMenuHandler : @@ -97,7 +96,7 @@ private: unsigned int m_Clients; unsigned int m_TotalClients; unsigned int m_Items; - CVector m_Votes; + std::vector m_Votes; IBaseMenu *m_pCurMenu; bool m_bStarted; bool m_bCancelled; diff --git a/core/NextMap.cpp b/core/NextMap.cpp index 16b6b25a..33931e83 100644 --- a/core/NextMap.cpp +++ b/core/NextMap.cpp @@ -82,8 +82,7 @@ void NextMapManager::OnSourceModShutdown() SH_REMOVE_HOOK(ConCommand, Dispatch, changeLevelCmd, SH_STATIC(CmdChangeLevelCallback), false); } - SourceHook::List::iterator iter; - iter = m_mapHistory.begin(); + auto iter = m_mapHistory.begin(); while (iter != m_mapHistory.end()) { @@ -186,7 +185,7 @@ void NextMapManager::OnSourceModLevelChange( const char *mapName ) historydiff = (m_mapHistory.size() * -1); } - for (SourceHook::List::iterator iter = m_mapHistory.begin(); historydiff++ < 0; iter = m_mapHistory.erase(iter)) + for (auto iter = m_mapHistory.begin(); historydiff++ < 0; iter = m_mapHistory.erase(iter)) { delete (MapChangeData *)*iter; } @@ -213,7 +212,7 @@ void NextMapManager::ForceChangeLevel( const char *mapName, const char* changeRe NextMapManager::NextMapManager() { m_tempChangeInfo = MapChangeData(); - m_mapHistory = SourceHook::List(); + m_mapHistory = std::list(); } #if SOURCE_ENGINE >= SE_ORANGEBOX diff --git a/core/NextMap.h b/core/NextMap.h index 2f6c0523..24653ccf 100644 --- a/core/NextMap.h +++ b/core/NextMap.h @@ -34,7 +34,7 @@ #include "sm_globals.h" #include -#include "sh_list.h" +#include #include "sm_stringutil.h" #include @@ -92,7 +92,7 @@ public: #endif public: - SourceHook::List m_mapHistory; + std::list m_mapHistory; private: MapChangeData m_tempChangeInfo; diff --git a/core/PlayerManager.cpp b/core/PlayerManager.cpp index da346282..de696194 100644 --- a/core/PlayerManager.cpp +++ b/core/PlayerManager.cpp @@ -65,7 +65,7 @@ IForward *ServerExitHibernation = NULL; const unsigned int *g_NumPlayersToAuth = NULL; int lifestate_offset = -1; -List target_processors; +std::list target_processors; ConVar sm_debug_connect("sm_debug_connect", "1", 0, "Log Debug information about potential connection issues."); @@ -348,8 +348,7 @@ void PlayerManager::OnServerActivate(edict_t *pEdictList, int edictCount, int cl m_onActivate->Execute(NULL); m_onActivate2->Execute(NULL); - List::iterator iter; - for (iter = m_hooks.begin(); iter != m_hooks.end(); iter++) + for (auto iter = m_hooks.begin(); iter != m_hooks.end(); iter++) { if ((*iter)->GetClientListenerVersion() >= 5) { @@ -451,9 +450,8 @@ void PlayerManager::RunAuthChecks() const char *steamId = pPlayer->GetSteam2Id(); /* Send to extensions */ - List::iterator iter; IClientListener *pListener; - for (iter=m_hooks.begin(); iter!=m_hooks.end(); iter++) + for (auto iter=m_hooks.begin(); iter!=m_hooks.end(); iter++) { pListener = (*iter); pListener->OnClientAuthorized(client, steamId ? steamId : authstr); @@ -565,9 +563,8 @@ bool PlayerManager::OnClientConnect(edict_t *pEntity, const char *pszName, const pPlayer->m_OriginalLangId = pPlayer->m_LangId; } - List::iterator iter; IClientListener *pListener = NULL; - for (iter=m_hooks.begin(); iter!=m_hooks.end(); iter++) + for (auto iter=m_hooks.begin(); iter!=m_hooks.end(); iter++) { pListener = (*iter); if (!pListener->InterceptClientConnect(client, reject, maxrejectlen)) @@ -611,9 +608,8 @@ bool PlayerManager::OnClientConnect_Post(edict_t *pEntity, const char *pszName, if (orig_value) { - List::iterator iter; IClientListener *pListener = NULL; - for (iter=m_hooks.begin(); iter!=m_hooks.end(); iter++) + for (auto iter=m_hooks.begin(); iter!=m_hooks.end(); iter++) { pListener = (*iter); pListener->OnClientConnected(client); @@ -726,9 +722,8 @@ void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername /* :TODO: kick the bot if it's rejected */ return; } - List::iterator iter; IClientListener *pListener = NULL; - for (iter=m_hooks.begin(); iter!=m_hooks.end(); iter++) + for (auto iter=m_hooks.begin(); iter!=m_hooks.end(); iter++) { pListener = (*iter); pListener->OnClientConnected(client); @@ -748,7 +743,7 @@ void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername const char *steamId = pPlayer->GetSteam2Id(); /* Now do authorization */ - for (iter=m_hooks.begin(); iter!=m_hooks.end(); iter++) + for (auto iter=m_hooks.begin(); iter!=m_hooks.end(); iter++) { pListener = (*iter); pListener->OnClientAuthorized(client, steamId ? steamId : pPlayer->m_AuthID.c_str()); @@ -779,9 +774,8 @@ void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername pPlayer->Connect(); m_PlayerCount++; - List::iterator iter; IClientListener *pListener = NULL; - for (iter=m_hooks.begin(); iter!=m_hooks.end(); iter++) + for (auto iter=m_hooks.begin(); iter!=m_hooks.end(); iter++) { pListener = (*iter); pListener->OnClientPutInServer(client); @@ -862,9 +856,8 @@ void PlayerManager::OnClientDisconnect(edict_t *pEntity) m_PlayerCount--; } - List::iterator iter; IClientListener *pListener = NULL; - for (iter=m_hooks.begin(); iter!=m_hooks.end(); iter++) + for (auto iter=m_hooks.begin(); iter!=m_hooks.end(); iter++) { pListener = (*iter); pListener->OnClientDisconnecting(client); @@ -893,9 +886,8 @@ void PlayerManager::OnClientDisconnect_Post(edict_t *pEntity) m_cldisconnect_post->PushCell(client); m_cldisconnect_post->Execute(&res, NULL); - List::iterator iter; IClientListener *pListener = NULL; - for (iter=m_hooks.begin(); iter!=m_hooks.end(); iter++) + for (auto iter=m_hooks.begin(); iter!=m_hooks.end(); iter++) { pListener = (*iter); pListener->OnClientDisconnected(client); @@ -1073,7 +1065,7 @@ void ListPluginsToClient(CPlayer *player, const CCommand &args) return; } - SourceHook::List m_FailList; + std::list m_FailList; size_t i = 0; for (; i < plugins->size(); i++) @@ -1240,7 +1232,7 @@ void PlayerManager::OnClientCommandKeyValues(edict_t *pEntity, KeyValues *pComma KeyValueStack *pStk = new KeyValueStack; pStk->pBase = pCommand; - pStk->pCurRoot.push(pStk->pBase); + pStk->pCurRoot.push_front(pStk->pBase); pStk->m_bDeleteOnDestroy = false; Handle_t hndl = handlesys->CreateHandle(g_KeyValueType, pStk, g_pCoreIdent, g_pCoreIdent, NULL); @@ -1285,7 +1277,7 @@ void PlayerManager::OnClientCommandKeyValues_Post(edict_t *pEntity, KeyValues *p KeyValueStack *pStk = new KeyValueStack; pStk->pBase = pCommand; - pStk->pCurRoot.push(pStk->pBase); + pStk->pCurRoot.push_front(pStk->pBase); pStk->m_bDeleteOnDestroy = false; Handle_t hndl = handlesys->CreateHandle(g_KeyValueType, pStk, g_pCoreIdent, g_pCoreIdent, NULL); @@ -1381,9 +1373,8 @@ void PlayerManager::OnClientSettingsChanged(edict_t *pEntity) } /* Notify Extensions */ - List::iterator iter; IClientListener *pListener = NULL; - for (iter=m_hooks.begin(); iter!=m_hooks.end(); iter++) + for (auto iter=m_hooks.begin(); iter!=m_hooks.end(); iter++) { pListener = (*iter); if (pListener->GetClientListenerVersion() >= 13) @@ -1892,8 +1883,7 @@ void PlayerManager::ProcessCommandTarget(cmd_target_info_t *info) } } - List::iterator iter; - for (iter = target_processors.begin(); iter != target_processors.end(); iter++) + for (auto iter = target_processors.begin(); iter != target_processors.end(); iter++) { ICommandTargetProcessor *pProcessor = (*iter); if (pProcessor->ProcessCommandTarget(info)) @@ -1976,9 +1966,8 @@ void PlayerManager::MaxPlayersChanged( int newvalue /*= -1*/ ) } /* Notify Extensions */ - List::iterator iter; IClientListener *pListener = NULL; - for (iter=m_hooks.begin(); iter!=m_hooks.end(); iter++) + for (auto iter=m_hooks.begin(); iter!=m_hooks.end(); iter++) { pListener = (*iter); if (pListener->GetClientListenerVersion() >= 8) @@ -2501,8 +2490,7 @@ void CPlayer::DoPostConnectAuthorization() { bool delay = false; - List::iterator iter; - for (iter = g_Players.m_hooks.begin(); + for (auto iter = g_Players.m_hooks.begin(); iter != g_Players.m_hooks.end(); iter++) { @@ -2561,8 +2549,7 @@ void CPlayer::NotifyPostAdminChecks() /* Block beforehand so they can't double-call */ m_bAdminCheckSignalled = true; - List::iterator iter; - for (iter = g_Players.m_hooks.begin(); + for (auto iter = g_Players.m_hooks.begin(); iter != g_Players.m_hooks.end(); iter++) { diff --git a/core/PlayerManager.h b/core/PlayerManager.h index 6107c427..f8f20fda 100644 --- a/core/PlayerManager.h +++ b/core/PlayerManager.h @@ -39,17 +39,15 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include #include #include "ConVarManager.h" #include -using namespace SourceHook; - class IClient; #define PLAYER_LIFE_UNKNOWN 0 @@ -131,9 +129,9 @@ private: bool m_IsInGame = false; bool m_IsAuthorized = false; bool m_bIsInKickQueue = false; - String m_Name; - String m_Ip; - String m_IpNoPort; + std::string m_Name; + std::string m_Ip; + std::string m_IpNoPort; std::string m_AuthID; std::string m_Steam2Id; std::string m_Steam3Id; @@ -142,7 +140,7 @@ private: edict_t *m_pEdict = nullptr; IPlayerInfo *m_Info = nullptr; IClient *m_pIClient = nullptr; - String m_LastPassword; + std::string m_LastPassword; bool m_bAdminCheckSignalled = false; int m_iIndex; unsigned int m_LangId = SOURCEMOD_LANGUAGE_ENGLISH; @@ -252,7 +250,7 @@ private: void OnServerActivate(edict_t *pEdictList, int edictCount, int clientMax); void InvalidatePlayer(CPlayer *pPlayer); private: - List m_hooks; + std::list m_hooks; IForward *m_clconnect; IForward *m_clconnect_post; IForward *m_cldisconnect; @@ -273,7 +271,7 @@ private: int m_PlayersSinceActive; bool m_bServerActivated; unsigned int *m_AuthQueue; - String m_PassInfoVar; + std::string m_PassInfoVar; bool m_QueryLang; bool m_bAuthstringValidation; // are we validating admins with steam before authorizing? bool m_bIsListenServer; diff --git a/core/TimerSys.cpp b/core/TimerSys.cpp index 3e560708..04e3ca42 100644 --- a/core/TimerSys.cpp +++ b/core/TimerSys.cpp @@ -178,12 +178,11 @@ TimerSystem::TimerSystem() TimerSystem::~TimerSystem() { - CStack::iterator iter; - for (iter=m_FreeTimers.begin(); iter!=m_FreeTimers.end(); iter++) + while (!m_FreeTimers.empty()) { - delete (*iter); + delete m_FreeTimers.top(); + m_FreeTimers.pop(); } - m_FreeTimers.popall(); } void TimerSystem::OnSourceModAllInitialized() @@ -251,13 +250,12 @@ void TimerSystem::GameFrame(bool simulating) } } -void TimerSystem::ProcessRepeatTimers(double curtime, List& timerList) +void TimerSystem::ProcessRepeatTimers(double curtime, std::list& timerList) { ITimer *pTimer; - TimerIter iter; ResultType res; - for (iter=timerList.begin(); iter!=timerList.end(); ) + for (auto iter=timerList.begin(); iter!=timerList.end(); ) { pTimer = (*iter); if (curtime >= pTimer->m_ToExec) @@ -284,8 +282,7 @@ void TimerSystem::RunFrame(bool timerThink) //// One-off timers ITimer *pTimer; - TimerIter iter; - for (iter=m_SingleTimers.begin(); iter!=m_SingleTimers.end(); ) + for (auto iter=m_SingleTimers.begin(); iter!=m_SingleTimers.end(); ) { pTimer = (*iter); @@ -323,14 +320,13 @@ void TimerSystem::RunFrame(bool timerThink) ITimer *TimerSystem::CreateTimer(ITimedEvent *pCallbacks, float fInterval, void *pData, int flags) { ITimer *pTimer; - TimerIter iter; const double to_exec = GetSimulatedTime() + fInterval; if (m_FreeTimers.empty()) { pTimer = new ITimer; } else { - pTimer = m_FreeTimers.front(); + pTimer = m_FreeTimers.top(); m_FreeTimers.pop(); } @@ -338,21 +334,21 @@ ITimer *TimerSystem::CreateTimer(ITimedEvent *pCallbacks, float fInterval, void if (flags & TIMER_FLAG_REPEAT) { - List& timerList = pTimer->m_Flags & TIMER_FLAG_TICK_PRECISE ? m_HighSpeedLoopTimers : m_LowSpeedLoopTimers; + std::list& timerList = pTimer->m_Flags & TIMER_FLAG_TICK_PRECISE ? m_HighSpeedLoopTimers : m_LowSpeedLoopTimers; timerList.push_back(pTimer); goto return_timer; } if (m_SingleTimers.size() >= 1) { - iter = --m_SingleTimers.end(); + auto iter = --m_SingleTimers.end(); if ((*iter)->m_ToExec <= to_exec) { goto normal_insert_end; } } - for (iter=m_SingleTimers.begin(); iter!=m_SingleTimers.end(); iter++) + for (auto iter=m_SingleTimers.begin(); iter!=m_SingleTimers.end(); iter++) { if ((*iter)->m_ToExec >= to_exec) { @@ -398,7 +394,7 @@ void TimerSystem::FireTimerOnce(ITimer *pTimer, bool delayExec) return; } - List& timerList = pTimer->m_Flags & TIMER_FLAG_TICK_PRECISE ? m_HighSpeedLoopTimers : m_LowSpeedLoopTimers; + std::list& timerList = pTimer->m_Flags & TIMER_FLAG_TICK_PRECISE ? m_HighSpeedLoopTimers : m_LowSpeedLoopTimers; pTimer->m_Listener->OnTimerEnd(pTimer, pTimer->m_pData); timerList.remove(pTimer); m_FreeTimers.push(pTimer); @@ -423,7 +419,7 @@ void TimerSystem::KillTimer(ITimer *pTimer) if (pTimer->m_Flags & TIMER_FLAG_REPEAT) { - List& timerList = pTimer->m_Flags & TIMER_FLAG_TICK_PRECISE ? m_HighSpeedLoopTimers : m_LowSpeedLoopTimers; + std::list& timerList = pTimer->m_Flags & TIMER_FLAG_TICK_PRECISE ? m_HighSpeedLoopTimers : m_LowSpeedLoopTimers; timerList.remove(pTimer); } else { m_SingleTimers.remove(pTimer); @@ -432,10 +428,10 @@ void TimerSystem::KillTimer(ITimer *pTimer) m_FreeTimers.push(pTimer); } -CStack s_tokill; +std::stack s_tokill; void TimerSystem::RemoveMapChangeTimers() { - const auto KillMapchangeTimers = [](List& timerList) { + const auto KillMapchangeTimers = [](std::list& timerList) { for (ITimer* pTimer : timerList) { if (pTimer->m_Flags & TIMER_FLAG_NO_MAPCHANGE) @@ -452,7 +448,7 @@ void TimerSystem::RemoveMapChangeTimers() while (!s_tokill.empty()) { - KillTimer(s_tokill.front()); + KillTimer(s_tokill.top()); s_tokill.pop(); } } diff --git a/core/TimerSys.h b/core/TimerSys.h index ba521be3..cd8cdca7 100644 --- a/core/TimerSys.h +++ b/core/TimerSys.h @@ -33,16 +33,13 @@ #define _INCLUDE_SOURCEMOD_CTIMERSYS_H_ #include -#include -#include +#include +#include #include "sourcemm_api.h" #include "sm_globals.h" -using namespace SourceHook; using namespace SourceMod; -typedef List::iterator TimerIter; - class SourceMod::ITimer { public: @@ -83,12 +80,12 @@ public: void RemoveMapChangeTimers(); void GameFrame(bool simulating); private: - void ProcessRepeatTimers(double curtime, List& timerList); + void ProcessRepeatTimers(double curtime, std::list& timerList); private: - List m_SingleTimers; - List m_LowSpeedLoopTimers; - List m_HighSpeedLoopTimers; - CStack m_FreeTimers; + std::list m_SingleTimers; + std::list m_LowSpeedLoopTimers; + std::list m_HighSpeedLoopTimers; + std::stack m_FreeTimers; IMapTimer *m_pMapTimer; /* This is stuff for our manual ticking escapades. */ diff --git a/core/UserMessagePBHelpers.h b/core/UserMessagePBHelpers.h index 2a12cd3c..fcbe554e 100644 --- a/core/UserMessagePBHelpers.h +++ b/core/UserMessagePBHelpers.h @@ -85,7 +85,7 @@ return false; \ } -typedef List PBHandleList; +typedef std::list PBHandleList; class SMProtobufMessage { @@ -97,7 +97,7 @@ public: ~SMProtobufMessage() { - PBHandleList::iterator iter = childHandles.begin(); + auto iter = childHandles.begin(); while (iter != childHandles.end()) { Handle_t &hndl = (*iter); diff --git a/core/UserMessages.cpp b/core/UserMessages.cpp index 413ae785..ecef9f9d 100644 --- a/core/UserMessages.cpp +++ b/core/UserMessages.cpp @@ -72,12 +72,11 @@ UserMessages::UserMessages() UserMessages::~UserMessages() { - CStack::iterator iter; - for (iter=m_FreeListeners.begin(); iter!=m_FreeListeners.end(); iter++) + while (!m_FreeListeners.empty()) { - delete (*iter); + delete m_FreeListeners.top(); + m_FreeListeners.pop(); } - m_FreeListeners.popall(); } void UserMessages::OnSourceModStartup(bool late) @@ -413,7 +412,7 @@ bool UserMessages::InternalHook(int msg_id, IBitBufUserMessageListener *pListene { pInfo = new ListenerInfo; } else { - pInfo = m_FreeListeners.front(); + pInfo = m_FreeListeners.top(); m_FreeListeners.pop(); } @@ -465,7 +464,6 @@ bool UserMessages::InternalUnhook(int msg_id, IBitBufUserMessageListener *pListe #endif { MsgList *pList; - MsgIter iter; ListenerInfo *pInfo; bool deleted = false; @@ -475,7 +473,7 @@ bool UserMessages::InternalUnhook(int msg_id, IBitBufUserMessageListener *pListe } pList = (intercept) ? &m_msgIntercepts[msg_id] : &m_msgHooks[msg_id]; - for (iter=pList->begin(); iter!=pList->end(); iter++) + for (auto iter=pList->begin(); iter!=pList->end(); iter++) { pInfo = (*iter); if (pInfo->Callback == pListener && pInfo->IsNew == isNew) @@ -645,13 +643,12 @@ void UserMessages::OnMessageEnd_Post() } MsgList *pList; - MsgIter iter; ListenerInfo *pInfo; m_InHook = false; pList = &m_msgIntercepts[m_CurId]; - for (iter=pList->begin(); iter!=pList->end(); ) + for (auto iter=pList->begin(); iter!=pList->end(); ) { pInfo = (*iter); if (m_BlockEndPost && !pInfo->IsNew) @@ -678,7 +675,7 @@ void UserMessages::OnMessageEnd_Post() } pList = &m_msgHooks[m_CurId]; - for (iter=pList->begin(); iter!=pList->end(); ) + for (auto iter=pList->begin(); iter!=pList->end(); ) { pInfo = (*iter); if (m_BlockEndPost && !pInfo->IsNew) @@ -713,7 +710,6 @@ void UserMessages::OnMessageEnd_Pre() } MsgList *pList; - MsgIter iter; ListenerInfo *pInfo; ResultType res; @@ -721,7 +717,7 @@ void UserMessages::OnMessageEnd_Pre() bool handled = false; pList = &m_msgIntercepts[m_CurId]; - for (iter=pList->begin(); iter!=pList->end(); ) + for (auto iter=pList->begin(); iter!=pList->end(); ) { pInfo = (*iter); pInfo->IsHooked = true; @@ -805,7 +801,7 @@ void UserMessages::OnMessageEnd_Pre() #endif pList = &m_msgHooks[m_CurId]; - for (iter=pList->begin(); iter!=pList->end(); ) + for (auto iter=pList->begin(); iter!=pList->end(); ) { pInfo = (*iter); pInfo->IsHooked = true; diff --git a/core/UserMessages.h b/core/UserMessages.h index 77cc201b..02bf9e82 100644 --- a/core/UserMessages.h +++ b/core/UserMessages.h @@ -38,10 +38,9 @@ #include "sm_stringutil.h" #include "CellRecipientFilter.h" #include "sm_globals.h" -#include -#include +#include +#include -using namespace SourceHook; using namespace SourceMod; #if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV @@ -72,8 +71,7 @@ struct ListenerInfo bool IsNew; }; -typedef List MsgList; -typedef List::iterator MsgIter; +typedef std::list MsgList; class UserMessages : public IUserMessages, @@ -130,9 +128,9 @@ private: #endif void _DecRefCounter(); private: - List m_msgHooks[255]; - List m_msgIntercepts[255]; - CStack m_FreeListeners; + std::list m_msgHooks[255]; + std::list m_msgIntercepts[255]; + std::stack m_FreeListeners; IRecipientFilter *m_CurRecFilter; #ifndef USE_PROTOBUF_USERMESSAGES unsigned char m_pBase[2500]; diff --git a/core/concmd_cleaner.cpp b/core/concmd_cleaner.cpp index 3488495b..40de83f3 100644 --- a/core/concmd_cleaner.cpp +++ b/core/concmd_cleaner.cpp @@ -26,7 +26,7 @@ // or . #include "sm_globals.h" -#include +#include #include #include "concmd_cleaner.h" #include "sm_stringutil.h" @@ -45,8 +45,6 @@ SH_DECL_HOOK1_void(ICvar, RegisterConCommand, SH_NOATTRIB, 0, ConCommandBase *); SH_DECL_HOOK1_void(ICvar, RegisterConCommandBase, SH_NOATTRIB, 0, ConCommandBase *); #endif -using namespace SourceHook; - struct ConCommandInfo { ConCommandBase *pBase; @@ -54,7 +52,7 @@ struct ConCommandInfo char name[64]; }; -List tracked_bases; +std::list tracked_bases; IConCommandLinkListener *IConCommandLinkListener::head = NULL; ConCommandBase *FindConCommandBase(const char *name); @@ -99,7 +97,7 @@ public: void UnlinkConCommandBase(ConCommandBase *pBase) { ConCommandInfo *pInfo; - List::iterator iter = tracked_bases.begin(); + auto iter = tracked_bases.begin(); IConCommandLinkListener *listener = IConCommandLinkListener::head; while (listener) @@ -137,10 +135,9 @@ public: void RemoveTarget(ConCommandBase *pBase, IConCommandTracker *cls) { - List::iterator iter; ConCommandInfo *pInfo; - iter = tracked_bases.begin(); + auto iter = tracked_bases.begin(); while (iter != tracked_bases.end()) { pInfo = (*iter); diff --git a/core/logic/AdminCache.cpp b/core/logic/AdminCache.cpp index 6cf9ac38..d9f4d812 100644 --- a/core/logic/AdminCache.cpp +++ b/core/logic/AdminCache.cpp @@ -233,8 +233,7 @@ AdminCache::~AdminCache() DumpAdminCache(AdminCache_Overrides, false); DumpAdminCache(AdminCache_Groups, false); - List::iterator iter; - for (iter=m_AuthMethods.begin(); + for (auto iter=m_AuthMethods.begin(); iter!=m_AuthMethods.end(); iter++) { @@ -759,8 +758,7 @@ bool AdminCache::GetGroupCommandOverride(GroupId id, const char *name, OverrideT AuthMethod *AdminCache::GetMethodByIndex(unsigned int index) { - List::iterator iter; - for (iter=m_AuthMethods.begin(); + for (auto iter=m_AuthMethods.begin(); iter!=m_AuthMethods.end(); iter++) { @@ -974,8 +972,7 @@ void AdminCache::InvalidateAdminCache(bool unlink_admins) } } /* Wipe the identity cache first */ - List::iterator iter; - for (iter=m_AuthMethods.begin(); + for (auto iter=m_AuthMethods.begin(); iter!=m_AuthMethods.end(); iter++) { @@ -998,7 +995,6 @@ void AdminCache::InvalidateAdminCache(bool unlink_admins) void AdminCache::DumpAdminCache(AdminCachePart part, bool rebuild) { - List::iterator iter; IAdminListener *pListener; if (part == AdminCache_Overrides) @@ -1007,7 +1003,7 @@ void AdminCache::DumpAdminCache(AdminCachePart part, bool rebuild) DumpCommandOverrideCache(Override_CommandGroup); if (rebuild && !m_destroying) { - for (iter=m_hooks.begin(); iter!=m_hooks.end(); iter++) + for (auto iter=m_hooks.begin(); iter!=m_hooks.end(); iter++) { pListener = (*iter); pListener->OnRebuildOverrideCache(); @@ -1021,7 +1017,7 @@ void AdminCache::DumpAdminCache(AdminCachePart part, bool rebuild) InvalidateGroupCache(); if (rebuild && !m_destroying) { - for (iter=m_hooks.begin(); iter!=m_hooks.end(); iter++) + for (auto iter=m_hooks.begin(); iter!=m_hooks.end(); iter++) { pListener = (*iter); pListener->OnRebuildGroupCache(); @@ -1033,7 +1029,7 @@ void AdminCache::DumpAdminCache(AdminCachePart part, bool rebuild) InvalidateAdminCache(true); if (rebuild && !m_destroying) { - for (iter=m_hooks.begin(); iter!=m_hooks.end(); iter++) + for (auto iter=m_hooks.begin(); iter!=m_hooks.end(); iter++) { pListener = (*iter); pListener->OnRebuildAdminCache((part == AdminCache_Groups)); @@ -1058,9 +1054,8 @@ const char *AdminCache::GetAdminName(AdminId id) bool AdminCache::GetMethodIndex(const char *name, unsigned int *_index) { - List::iterator iter; unsigned int index = 0; - for (iter=m_AuthMethods.begin(); + for (auto iter=m_AuthMethods.begin(); iter!=m_AuthMethods.end(); iter++,index++) { @@ -1962,8 +1957,7 @@ AdminUser *AdminCache::GetUser(AdminId aid) const char *AdminCache::GetMethodName(unsigned int index) { - List::iterator iter; - for (iter=m_AuthMethods.begin(); + for (auto iter=m_AuthMethods.begin(); iter!=m_AuthMethods.end(); iter++) { diff --git a/core/logic/AdminCache.h b/core/logic/AdminCache.h index daecd951..a1e74441 100644 --- a/core/logic/AdminCache.h +++ b/core/logic/AdminCache.h @@ -36,14 +36,12 @@ #include #include "sm_memtable.h" #include -#include -#include +#include +#include #include #include #include -using namespace SourceHook; - #define GRP_MAGIC_SET 0xDEADFADE #define GRP_MAGIC_UNSET 0xFACEFACE #define USR_MAGIC_SET 0xDEADFACE @@ -70,7 +68,7 @@ struct AdminGroup struct AuthMethod { - String name; + std::string name; StringHashMap identities; AuthMethod(const char *name) @@ -214,8 +212,8 @@ public: int m_LastGroup; int m_FreeGroupList; StringHashMap m_Groups; - List m_hooks; - List m_AuthMethods; + std::list m_hooks; + std::list m_AuthMethods; NameHashSet m_AuthTables; IForward *m_pCacheFwd; int m_FirstUser; diff --git a/core/logic/BaseWorker.cpp b/core/logic/BaseWorker.cpp index 342d4cc3..db1be478 100644 --- a/core/logic/BaseWorker.cpp +++ b/core/logic/BaseWorker.cpp @@ -109,10 +109,9 @@ SWThreadHandle *BaseWorker::PopThreadFromQueue() if (!m_ThreadQueue.size()) return NULL; - SourceHook::List::iterator begin; SWThreadHandle *swt; - begin = m_ThreadQueue.begin(); + auto begin = m_ThreadQueue.begin(); swt = (*begin); m_ThreadQueue.erase(begin); diff --git a/core/logic/BaseWorker.h b/core/logic/BaseWorker.h index 5e87ed63..f7299348 100644 --- a/core/logic/BaseWorker.h +++ b/core/logic/BaseWorker.h @@ -32,7 +32,7 @@ #ifndef _INCLUDE_SOURCEMOD_BASEWORKER_H #define _INCLUDE_SOURCEMOD_BASEWORKER_H -#include "sh_list.h" +#include #include "ThreadSupport.h" #define SM_DEFAULT_THREADS_PER_FRAME 1 @@ -96,7 +96,7 @@ public: //BaseWorker virtual void AddThreadToQueue(SWThreadHandle *pHandle); virtual SWThreadHandle *PopThreadFromQueue(); protected: - SourceHook::List m_ThreadQueue; + std::list m_ThreadQueue; unsigned int m_perFrame; volatile WorkerState m_state; IThreadWorkerCallbacks *m_pHooks; diff --git a/core/logic/Database.cpp b/core/logic/Database.cpp index daac03d0..e7a6e343 100644 --- a/core/logic/Database.cpp +++ b/core/logic/Database.cpp @@ -205,7 +205,7 @@ void DBManager::RemoveDriver(IDBDriver *pDriver) { if (m_drivers[i] == pDriver) { - m_drivers.erase(m_drivers.iterAt(i)); + m_drivers.erase(m_drivers.begin() + i); break; } } diff --git a/core/logic/Database.h b/core/logic/Database.h index d76f4dfb..8faee815 100644 --- a/core/logic/Database.h +++ b/core/logic/Database.h @@ -33,9 +33,9 @@ #define _INCLUDE_DATABASE_MANAGER_H_ #include "common_logic.h" -#include +#include #include -#include +#include #include #include #include @@ -48,9 +48,6 @@ #include #include "DatabaseConfBuilder.h" -using namespace SourceHook; - - class DBManager : public IDBManager, public SMGlobalClass, @@ -105,12 +102,12 @@ private: void CancelPluginOperations(IdentityToken_t *identity); void FinalizeOperation(IDBThreadOperation *op, bool driver_unloading); private: - CVector m_drivers; + std::vector m_drivers; /* Threading stuff */ PrioQueue m_OpQueue; Queue m_ThinkQueue; - CVector m_drSafety; /* which drivers are safe? */ + std::vector m_drSafety; /* which drivers are safe? */ std::unique_ptr m_Worker; std::condition_variable m_QueueEvent; std::mutex m_ThinkLock; diff --git a/core/logic/ExtensionSys.cpp b/core/logic/ExtensionSys.cpp index d2b1913d..90c01fdc 100644 --- a/core/logic/ExtensionSys.cpp +++ b/core/logic/ExtensionSys.cpp @@ -356,7 +356,7 @@ void CExtension::MarkAllLoaded() void CExtension::AddPlugin(CPlugin *pPlugin) { /* Unfortunately we have to do this :( */ - if (m_Dependents.find(pPlugin) == m_Dependents.end()) + if (std::find(m_Dependents.begin(), m_Dependents.end(), pPlugin) == m_Dependents.end()) { m_Dependents.push_back(pPlugin); } @@ -399,7 +399,7 @@ bool CLocalExtension::IsLoaded() void CExtension::AddDependency(const IfaceInfo *pInfo) { - if (m_Deps.find(*pInfo) == m_Deps.end()) + if (std::find(m_Deps.begin(), m_Deps.end(), *pInfo) == m_Deps.end()) { m_Deps.push_back(*pInfo); } @@ -411,8 +411,7 @@ void CExtension::AddChildDependent(CExtension *pOther, SMInterface *iface) info.iface = iface; info.owner = pOther; - List::iterator iter; - for (iter = m_ChildDeps.begin(); + for (auto iter = m_ChildDeps.begin(); iter != m_ChildDeps.end(); iter++) { @@ -492,11 +491,9 @@ void CExtensionManager::OnSourceModShutdown() void CExtensionManager::Shutdown() { - List::iterator iter; - - while ((iter = m_Libs.begin()) != m_Libs.end()) + while (m_Libs.begin() != m_Libs.end()) { - UnloadExtension((*iter)); + UnloadExtension((*m_Libs.begin())); } } @@ -585,14 +582,13 @@ IExtension *CExtensionManager::LoadAutoExtension(const char *path, bool bErrorOn IExtension *CExtensionManager::FindExtensionByFile(const char *file) { - List::iterator iter; CExtension *pExt; /* Chomp off the path */ char lookup[PLATFORM_MAX_PATH]; libsys->GetFileFromPath(lookup, sizeof(lookup), file); - for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++) + for (auto iter=m_Libs.begin(); iter!=m_Libs.end(); iter++) { pExt = (*iter); if (pExt->IsSameFile(lookup)) @@ -606,12 +602,11 @@ IExtension *CExtensionManager::FindExtensionByFile(const char *file) IExtension *CExtensionManager::FindExtensionByName(const char *ext) { - List::iterator iter; CExtension *pExt; IExtensionInterface *pAPI; const char *name; - for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++) + for (auto iter=m_Libs.begin(); iter!=m_Libs.end(); iter++) { pExt = (*iter); if (!pExt->IsLoaded()) @@ -720,9 +715,7 @@ void CExtensionManager::BindChildPlugin(IExtension *pParent, SMPlugin *pPlugin) void CExtensionManager::OnPluginDestroyed(IPlugin *plugin) { - List::iterator iter; - - for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++) + for (auto iter=m_Libs.begin(); iter!=m_Libs.end(); iter++) { (*iter)->DropRefsTo(static_cast(plugin)); } @@ -735,7 +728,7 @@ CExtension *CExtensionManager::FindByOrder(unsigned int num) return NULL; } - List::iterator iter = m_Libs.begin(); + auto iter = m_Libs.begin(); while (iter != m_Libs.end()) { @@ -756,7 +749,8 @@ bool CExtensionManager::UnloadExtension(IExtension *_pExt) CExtension *pExt = (CExtension *)_pExt; - if (m_Libs.find(pExt) == m_Libs.end()) + auto iter = std::find(m_Libs.begin(), m_Libs.end(), pExt); + if (iter == m_Libs.end()) return false; /* Tell it to unload */ @@ -770,13 +764,13 @@ bool CExtensionManager::UnloadExtension(IExtension *_pExt) g_ShareSys.RemoveInterfaces(_pExt); m_Libs.remove(pExt); - List UnloadQueue; + std::list UnloadQueue; /* Handle dependencies */ if (pExt->IsLoaded()) { /* Unload any dependent plugins */ - List::iterator p_iter = pExt->m_Dependents.begin(); + auto p_iter = pExt->m_Dependents.begin(); while (p_iter != pExt->m_Dependents.end()) { /* We have to manually unlink ourselves here, since we're no longer being managed */ @@ -784,8 +778,7 @@ bool CExtensionManager::UnloadExtension(IExtension *_pExt) p_iter = pExt->m_Dependents.erase(p_iter); } - List::iterator s_iter; - for (s_iter = pExt->m_Libraries.begin(); + for (auto s_iter = pExt->m_Libraries.begin(); s_iter != pExt->m_Libraries.end(); s_iter++) { @@ -793,10 +786,9 @@ bool CExtensionManager::UnloadExtension(IExtension *_pExt) } /* Notify and/or unload all dependencies */ - List::iterator c_iter; CExtension *pDep; IExtensionInterface *pAPI; - for (c_iter = m_Libs.begin(); c_iter != m_Libs.end(); c_iter++) + for (auto c_iter = m_Libs.begin(); c_iter != m_Libs.end(); c_iter++) { pDep = (*c_iter); if ((pAPI=pDep->GetAPI()) == NULL) @@ -805,7 +797,7 @@ bool CExtensionManager::UnloadExtension(IExtension *_pExt) continue; /* Now, get its dependency list */ bool dropped = false; - List::iterator i_iter = pDep->m_Deps.begin(); + auto i_iter = pDep->m_Deps.begin(); while (i_iter != pDep->m_Deps.end()) { if ((*i_iter).owner == _pExt) @@ -860,8 +852,7 @@ bool CExtensionManager::UnloadExtension(IExtension *_pExt) pExt->Unload(); delete pExt; - List::iterator iter; - for (iter=UnloadQueue.begin(); iter!=UnloadQueue.end(); iter++) + for (auto iter=UnloadQueue.begin(); iter!=UnloadQueue.end(); iter++) { /* NOTE: This is safe because the unload function backs out of anything not present */ UnloadExtension((*iter)); @@ -872,10 +863,9 @@ bool CExtensionManager::UnloadExtension(IExtension *_pExt) void CExtensionManager::MarkAllLoaded() { - List::iterator iter; CExtension *pExt; - for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++) + for (auto iter=m_Libs.begin(); iter!=m_Libs.end(); iter++) { pExt = (*iter); if (!pExt->IsLoaded()) @@ -910,7 +900,6 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const ICommand const char *cmd = command->Arg(2); if (strcmp(cmd, "list") == 0) { - List::iterator iter; CExtension *pExt; unsigned int num = 1; @@ -932,7 +921,7 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const ICommand break; } } - for (iter = m_Libs.begin(); iter != m_Libs.end(); iter++,num++) + for (auto iter = m_Libs.begin(); iter != m_Libs.end(); iter++,num++) { pExt = (*iter); if (pExt->IsLoaded()) @@ -1021,7 +1010,7 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const ICommand return; } - List::iterator iter = m_Libs.begin(); + auto iter = m_Libs.begin(); CExtension *pExt = NULL; while (iter != m_Libs.end()) { @@ -1124,23 +1113,21 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const ICommand } else { - List plugins; + std::list plugins; if (pExt->m_ChildDeps.size()) { rootmenu->ConsolePrint("[SM] Unloading %s will unload the following extensions: ", pExt->GetFilename()); - List::iterator iter; CExtension *pOther; /* Get list of all extensions */ - for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++) + for (auto iter=m_Libs.begin(); iter!=m_Libs.end(); iter++) { - List::iterator i_iter; pOther = (*iter); if (!pOther->IsLoaded() || pOther == pExt) { continue; } /* Get their dependencies */ - for (i_iter=pOther->m_Deps.begin(); + for (auto i_iter=pOther->m_Deps.begin(); i_iter!=pOther->m_Deps.end(); i_iter++) { @@ -1154,12 +1141,12 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const ICommand { rootmenu->ConsolePrint(" -> %s", pOther->GetFilename()); /* Add to plugin unload list */ - List::iterator p_iter; - for (p_iter=pOther->m_Dependents.begin(); + for (auto p_iter=pOther->m_Dependents.begin(); p_iter!=pOther->m_Dependents.end(); p_iter++) { - if (plugins.find((*p_iter)) == plugins.end()) + auto lookup = std::find(plugins.begin(), plugins.end(), (*p_iter)); + if (lookup == plugins.end()) { plugins.push_back((*p_iter)); } @@ -1171,17 +1158,17 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const ICommand if (pExt->m_Dependents.size()) { rootmenu->ConsolePrint("[SM] Unloading %s will unload the following plugins: ", pExt->GetFilename()); - List::iterator iter; CPlugin *pPlugin; - for (iter = pExt->m_Dependents.begin(); iter != pExt->m_Dependents.end(); iter++) + for (auto iter = pExt->m_Dependents.begin(); iter != pExt->m_Dependents.end(); iter++) { pPlugin = (*iter); - if (plugins.find(pPlugin) == plugins.end()) + auto lookup = std::find(plugins.begin(), plugins.end(), pPlugin); + if (lookup == plugins.end()) { plugins.push_back(pPlugin); } } - for (iter = plugins.begin(); iter != plugins.end(); iter++) + for (auto iter = plugins.begin(); iter != plugins.end(); iter++) { pPlugin = (*iter); rootmenu->ConsolePrint(" -> %s", pPlugin->GetFilename()); @@ -1277,12 +1264,12 @@ bool CExtensionManager::LibraryExists(const char *library) { CExtension *pExt; - for (List::iterator iter = m_Libs.begin(); + for (auto iter = m_Libs.begin(); iter != m_Libs.end(); iter++) { pExt = (*iter); - for (List::iterator s_iter = pExt->m_Libraries.begin(); + for (auto s_iter = pExt->m_Libraries.begin(); s_iter != pExt->m_Libraries.end(); s_iter++) { @@ -1325,9 +1312,8 @@ IExtension *CExtensionManager::LoadExternal(IExtensionInterface *pInterface, void CExtensionManager::CallOnCoreMapStart(edict_t *pEdictList, int edictCount, int clientMax) { IExtensionInterface *pAPI; - List::iterator iter; - for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++) + for (auto iter=m_Libs.begin(); iter!=m_Libs.end(); iter++) { if ((pAPI = (*iter)->GetAPI()) == NULL) { @@ -1343,9 +1329,8 @@ void CExtensionManager::CallOnCoreMapStart(edict_t *pEdictList, int edictCount, void CExtensionManager::CallOnCoreMapEnd() { IExtensionInterface *pAPI; - List::iterator iter; - for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++) + for (auto iter=m_Libs.begin(); iter!=m_Libs.end(); iter++) { if ((pAPI = (*iter)->GetAPI()) == NULL) { @@ -1358,17 +1343,17 @@ void CExtensionManager::CallOnCoreMapEnd() } } -const CVector *CExtensionManager::ListExtensions() +const std::vector *CExtensionManager::ListExtensions() { - CVector *list = new CVector(); - for (List::iterator iter = m_Libs.begin(); iter != m_Libs.end(); iter++) + std::vector *list = new std::vector(); + for (auto iter = m_Libs.begin(); iter != m_Libs.end(); iter++) list->push_back(*iter); return list; } -void CExtensionManager::FreeExtensionList(const CVector *list) +void CExtensionManager::FreeExtensionList(const std::vector *list) { - delete const_cast *>(list); + delete const_cast *>(list); } bool CLocalExtension::IsSameFile(const char *file) diff --git a/core/logic/ExtensionSys.h b/core/logic/ExtensionSys.h index 6687057c..64d978a2 100644 --- a/core/logic/ExtensionSys.h +++ b/core/logic/ExtensionSys.h @@ -34,8 +34,8 @@ #include #include -#include -#include +#include +#include #include "common_logic.h" #include #include @@ -46,7 +46,6 @@ class CPlayer; using namespace SourceMod; -using namespace SourceHook; class CExtension; @@ -95,14 +94,14 @@ protected: protected: IdentityToken_t *m_pIdentToken; IExtensionInterface *m_pAPI; - String m_File; - String m_RealFile; - String m_Path; - String m_Error; - List m_Deps; /** Dependencies */ - List m_ChildDeps; /** Children who might depend on us */ - List m_Interfaces; - List m_Libraries; + std::string m_File; + std::string m_RealFile; + std::string m_Path; + std::string m_Error; + std::list m_Deps; /** Dependencies */ + std::list m_ChildDeps; /** Children who might depend on us */ + std::list m_Interfaces; + std::list m_Libraries; unsigned int unload_code; bool m_bFullyLoaded; bool m_bRequired; @@ -178,8 +177,8 @@ public: void CallOnCoreMapStart(edict_t *pEdictList, int edictCount, int clientMax); void CallOnCoreMapEnd(); void AddRawDependency(IExtension *ext, IdentityToken_t *other, void *iface); - const CVector *ListExtensions(); - void FreeExtensionList(const CVector *list); + const std::vector *ListExtensions(); + void FreeExtensionList(const std::vector *list); public: CExtension *GetExtensionFromIdent(IdentityToken_t *ptr); void Shutdown(); @@ -191,7 +190,7 @@ public: private: CExtension *FindByOrder(unsigned int num); private: - List m_Libs; + std::list m_Libs; }; extern CExtensionManager g_Extensions; diff --git a/core/logic/GameConfigs.cpp b/core/logic/GameConfigs.cpp index b141335c..abe2407e 100644 --- a/core/logic/GameConfigs.cpp +++ b/core/logic/GameConfigs.cpp @@ -31,8 +31,8 @@ #include #include #include -#include -#include +#include +#include #include "GameConfigs.h" #include "stringutil.h" #include @@ -53,8 +53,6 @@ #include #endif -using namespace SourceHook; - GameConfigManager g_GameConfigs; IGameConfig *g_pGameConf = NULL; static char g_Game[256]; @@ -791,7 +789,7 @@ public: (!had_game && matched_engine) || (matched_engine && matched_game)) { - if (fileList->find(cur_file) == fileList->end()) + if (std::find(fileList->begin(), fileList->end(), cur_file) == fileList->end()) { fileList->push_back(cur_file); } @@ -806,7 +804,7 @@ public: return SMCResult_Continue; } public: - List *fileList; + std::list *fileList; unsigned int state; unsigned int ignoreLevel; char cur_file[PLATFORM_MAX_PATH]; @@ -857,7 +855,7 @@ bool CGameConfig::Reparse(char *error, size_t maxlength) /* Otherwise, it's time to parse the master. */ SMCError err; SMCStates state = {0, 0}; - List fileList; + std::list fileList; master_reader.fileList = &fileList; const char *pEngine[2] = { m_pBaseEngine, m_pEngine }; @@ -885,8 +883,7 @@ bool CGameConfig::Reparse(char *error, size_t maxlength) } /* Go through each file we found and parse it. */ - List::iterator iter; - for (iter = fileList.begin(); iter != fileList.end(); iter++) + for (auto iter = fileList.begin(); iter != fileList.end(); iter++) { ke::SafeSprintf(path, sizeof(path), "%s/%s", m_File, (*iter).c_str()); if (!EnterFile(path, error, maxlength)) diff --git a/core/logic/MemoryUtils.h b/core/logic/MemoryUtils.h index 9df556bf..6c997215 100644 --- a/core/logic/MemoryUtils.h +++ b/core/logic/MemoryUtils.h @@ -36,10 +36,7 @@ #include #include #if defined PLATFORM_LINUX || defined PLATFORM_APPLE -#include #include "sm_symtable.h" - -using namespace SourceHook; #endif using namespace SourceMod; @@ -89,7 +86,7 @@ public: const DynLibInfo *GetLibraryInfo(const void *libPtr); #if defined PLATFORM_LINUX || defined PLATFORM_APPLE private: - CVector m_SymTables; + std::vector m_SymTables; #ifdef PLATFORM_APPLE struct dyld_all_image_infos *m_ImageList; SInt32 m_OSXMajor; diff --git a/core/logic/NativeOwner.cpp b/core/logic/NativeOwner.cpp index ef0cd67a..0de9c4fe 100644 --- a/core/logic/NativeOwner.cpp +++ b/core/logic/NativeOwner.cpp @@ -49,7 +49,7 @@ unsigned int CNativeOwner::GetMarkSerial() void CNativeOwner::AddDependent(CPlugin *pPlugin) { - if (m_Dependents.find(pPlugin) == m_Dependents.end()) + if (std::find(m_Dependents.begin(), m_Dependents.end(), pPlugin) == m_Dependents.end()) m_Dependents.push_back(pPlugin); } @@ -78,10 +78,8 @@ void CNativeOwner::UnbindWeakRef(const WeakNative &ref) void CNativeOwner::DropEverything() { - List::iterator iter; - /* Unbind and remove all weak references to us */ - iter = m_WeakRefs.begin(); + auto iter = m_WeakRefs.begin(); while (iter != m_WeakRefs.end()) { UnbindWeakRef((*iter)); @@ -103,9 +101,7 @@ void CNativeOwner::DropEverything() void CNativeOwner::DropWeakRefsTo(CPlugin *pPlugin) { - List::iterator iter; - - iter = m_WeakRefs.begin(); + auto iter = m_WeakRefs.begin(); while (iter != m_WeakRefs.end()) { WeakNative & ref = (*iter); diff --git a/core/logic/NativeOwner.h b/core/logic/NativeOwner.h index 5f0339b3..88b62e6b 100644 --- a/core/logic/NativeOwner.h +++ b/core/logic/NativeOwner.h @@ -32,7 +32,7 @@ #define _INCLUDE_SOURCEMOD_NATIVE_OWNER_H_ #include -#include +#include #include #include "common_logic.h" #include "Native.h" @@ -55,8 +55,6 @@ struct WeakNative uint32_t idx; }; -using namespace SourceHook; - class CNativeOwner { public: @@ -76,9 +74,9 @@ private: void DropWeakRefsTo(CPlugin *pPlugin); void UnbindWeakRef(const WeakNative & ref); protected: - List m_Dependents; + std::list m_Dependents; unsigned int m_nMarkSerial; - List m_WeakRefs; + std::list m_WeakRefs; std::vector m_natives; std::vector > m_fakes; }; diff --git a/core/logic/PhraseCollection.h b/core/logic/PhraseCollection.h index bf14e190..315d53da 100644 --- a/core/logic/PhraseCollection.h +++ b/core/logic/PhraseCollection.h @@ -33,10 +33,9 @@ #define _INCLUDE_SOURCEMOD_PHRASECOLLECTION_H_ #include -#include +#include #include -using namespace SourceHook; using namespace SourceMod; class CPhraseCollection : public IPhraseCollection @@ -60,7 +59,7 @@ public: size_t *pOutLength, const char **pFailPhrase); private: - CVector m_Files; + std::vector m_Files; }; #endif //_INCLUDE_SOURCEMOD_PHRASECOLLECTION_H_ diff --git a/core/logic/PluginSys.cpp b/core/logic/PluginSys.cpp index 61f83545..86e17266 100644 --- a/core/logic/PluginSys.cpp +++ b/core/logic/PluginSys.cpp @@ -705,7 +705,7 @@ void CPlugin::DependencyDropped(CPlugin *pOwner) return; for (auto lib_iter=pOwner->m_Libraries.begin(); lib_iter!=pOwner->m_Libraries.end(); lib_iter++) { - if (m_RequiredLibs.find(*lib_iter) != m_RequiredLibs.end()) { + if (std::find(m_RequiredLibs.begin(), m_RequiredLibs.end(), *lib_iter) != m_RequiredLibs.end()) { m_LibraryMissing = true; break; } @@ -776,10 +776,9 @@ void CPlugin::AddConfig(bool autoCreate, const char *cfg, const char *folder) void CPlugin::DropEverything() { CPlugin *pOther; - List::iterator wk_iter; /* Tell everyone that depends on us that we're about to drop */ - for (List::iterator iter = m_Dependents.begin(); + for (auto iter = m_Dependents.begin(); iter != m_Dependents.end(); iter++) { @@ -1293,7 +1292,7 @@ void CPlugin::ForEachLibrary(ke::Function callback) void CPlugin::AddRequiredLib(const char *name) { - if (m_RequiredLibs.find(name) == m_RequiredLibs.end()) + if (std::find(m_RequiredLibs.begin(), m_RequiredLibs.end(), name) == m_RequiredLibs.end()) m_RequiredLibs.push_back(name); } @@ -2378,9 +2377,9 @@ void CPluginManager::SyncMaxClients(int max_clients) (*iter)->SyncMaxClients(max_clients); } -const CVector *CPluginManager::ListPlugins() +const std::vector *CPluginManager::ListPlugins() { - CVector *list = new CVector(); + std::vector *list = new std::vector(); for (PluginIter iter(m_plugins); !iter.done(); iter.next()) list->push_back((*iter)); @@ -2388,9 +2387,9 @@ const CVector *CPluginManager::ListPlugins() return list; } -void CPluginManager::FreePluginList(const CVector *list) +void CPluginManager::FreePluginList(const std::vector *list) { - delete const_cast *>(list); + delete const_cast *>(list); } void CPluginManager::ForEachPlugin(ke::Function callback) diff --git a/core/logic/PluginSys.h b/core/logic/PluginSys.h index f6547332..de731ea2 100644 --- a/core/logic/PluginSys.h +++ b/core/logic/PluginSys.h @@ -41,10 +41,10 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include "common_logic.h" #include #include @@ -61,8 +61,6 @@ class CPlayer; -using namespace SourceHook; - enum LoadRes { LoadRes_Successful, @@ -195,7 +193,7 @@ public: m_Libraries.push_back(name); } inline bool HasLibrary(const char *name) { - return m_Libraries.find(name) != m_Libraries.end(); + return std::find(m_Libraries.begin(), m_Libraries.end(), name) != m_Libraries.end(); } void LibraryActions(LibraryAction action); void SyncMaxClients(int max_clients); @@ -274,13 +272,13 @@ private: IPluginContext *m_pContext; sp_pubvar_t *m_MaxClientsVar; StringHashMap m_Props; - CVector m_configs; - List m_Libraries; + std::vector m_configs; + std::list m_Libraries; bool m_bGotAllLoaded; int m_FileVersion; // Information that survives past eviction. - List m_RequiredLibs; + std::list m_RequiredLibs; IdentityToken_t *m_ident; time_t m_LastFileModTime; Handle_t m_handle; @@ -348,8 +346,8 @@ public: //IScriptManager SMPlugin *FindPluginByHandle(Handle_t hndl, HandleError *errp) { return static_cast(PluginFromHandle(hndl, errp)); } - const CVector *ListPlugins(); - void FreePluginList(const CVector *plugins); + const std::vector *ListPlugins(); + void FreePluginList(const std::vector *plugins); public: //SMGlobalClass void OnSourceModAllInitialized(); @@ -506,7 +504,7 @@ private: IdentityToken_t *m_MyIdent; /* Dynamic native stuff */ - List m_Natives; + std::list m_Natives; bool m_LoadingLocked; diff --git a/core/logic/RootConsoleMenu.cpp b/core/logic/RootConsoleMenu.cpp index 12bf2afc..cb55b4bd 100644 --- a/core/logic/RootConsoleMenu.cpp +++ b/core/logic/RootConsoleMenu.cpp @@ -43,8 +43,7 @@ RootConsoleMenu::RootConsoleMenu() RootConsoleMenu::~RootConsoleMenu() { - List::iterator iter; - for (iter=m_Menu.begin(); iter!=m_Menu.end(); iter++) + for (auto iter=m_Menu.begin(); iter!=m_Menu.end(); iter++) { delete (*iter); } @@ -101,7 +100,7 @@ bool RootConsoleMenu::AddRootConsoleCommand3(const char *cmd, return false; /* Sort this into the menu */ - List::iterator iter = m_Menu.begin(); + auto iter = m_Menu.begin(); ConsoleEntry *pEntry; bool inserted = false; while (iter != m_Menu.end()) @@ -138,9 +137,8 @@ bool RootConsoleMenu::RemoveRootConsoleCommand(const char *cmd, IRootConsoleComm { m_Commands.remove(cmd); - List::iterator iter; ConsoleEntry *pEntry; - for (iter=m_Menu.begin(); iter!=m_Menu.end(); iter++) + for (auto iter=m_Menu.begin(); iter!=m_Menu.end(); iter++) { pEntry = (*iter); if (pEntry->command.compare(cmd) == 0) @@ -201,9 +199,8 @@ void RootConsoleMenu::GotRootCmd(const ICommandArgs *cmd) ConsolePrint("SourceMod Menu:"); ConsolePrint("Usage: sm [arguments]"); - List::iterator iter; ConsoleEntry *pEntry; - for (iter=m_Menu.begin(); iter!=m_Menu.end(); iter++) + for (auto iter=m_Menu.begin(); iter!=m_Menu.end(); iter++) { pEntry = (*iter); DrawGenericOption(pEntry->command.c_str(), pEntry->description.c_str()); diff --git a/core/logic/RootConsoleMenu.h b/core/logic/RootConsoleMenu.h index c240a488..e3ad6f1a 100644 --- a/core/logic/RootConsoleMenu.h +++ b/core/logic/RootConsoleMenu.h @@ -29,17 +29,16 @@ #include "common_logic.h" #include -#include -#include +#include +#include #include using namespace SourceMod; -using namespace SourceHook; struct ConsoleEntry { - String command; - String description; + std::string command; + std::string description; IRootConsoleCommand *cmd; static inline bool matches(const char *name, const ConsoleEntry *entry) @@ -84,7 +83,7 @@ public: void GotRootCmd(const ICommandArgs *cmd); private: NameHashSet m_Commands; - List m_Menu; + std::list m_Menu; }; extern RootConsoleMenu g_RootMenu; diff --git a/core/logic/ShareSys.cpp b/core/logic/ShareSys.cpp index 010a5889..196485d6 100644 --- a/core/logic/ShareSys.cpp +++ b/core/logic/ShareSys.cpp @@ -233,7 +233,7 @@ void ShareSystem::DestroyIdentType(IdentityType_t type) void ShareSystem::RemoveInterfaces(IExtension *pExtension) { - List::iterator iter = m_Interfaces.begin(); + auto iter = m_Interfaces.begin(); while (iter != m_Interfaces.end()) { diff --git a/core/logic/ShareSys.h b/core/logic/ShareSys.h index cc431cb7..78f132d3 100644 --- a/core/logic/ShareSys.h +++ b/core/logic/ShareSys.h @@ -37,14 +37,12 @@ #include #include #include -#include +#include #include #include #include "common_logic.h" #include "Native.h" -using namespace SourceHook; - namespace SourceMod { struct IdentityToken_t @@ -133,7 +131,7 @@ private: private: typedef NameHashSet, Native> NativeCache; - List m_Interfaces; + std::list m_Interfaces; HandleType_t m_TypeRoot; IdentityToken_t m_IdentRoot; HandleType_t m_IfaceType; diff --git a/core/logic/Translator.h b/core/logic/Translator.h index 5cd57dfb..d89fc581 100644 --- a/core/logic/Translator.h +++ b/core/logic/Translator.h @@ -34,8 +34,8 @@ #include "common_logic.h" #include -#include -#include +#include +#include #include "sm_memtable.h" #include "ITextParsers.h" #include @@ -44,7 +44,6 @@ /* :TODO: write a templatized version of tries? */ using namespace SourceMod; -using namespace SourceHook; class Translator; enum PhraseParseState @@ -83,15 +82,15 @@ private: void ParseWarning(const char *message, ...); private: StringHashMap m_PhraseLookup; - String m_File; + std::string m_File; Translator *m_pTranslator; PhraseParseState m_ParseState; int m_CurPhrase; BaseMemTable *m_pMemory; BaseStringTable *m_pStringTab; unsigned int m_LangCount; - String m_ParseError; - String m_LastPhraseString; + std::string m_ParseError; + std::string m_LastPhraseString; bool m_FileLogged; }; @@ -152,13 +151,13 @@ public: //ITranslator private: bool AddLanguage(const char *langcode, const char *description); private: - CVector m_Languages; - CVector m_Files; + std::vector m_Languages; + std::vector m_Files; BaseStringTable *m_pStringTab; StringHashMap m_LCodeLookup; StringHashMap m_LAliases; bool m_InLanguageSection; - String m_CustomError; + std::string m_CustomError; unsigned int m_ServerLang; char m_InitialLang[4]; }; diff --git a/core/logic/smn_core.cpp b/core/logic/smn_core.cpp index 59ad2bd5..b6762531 100644 --- a/core/logic/smn_core.cpp +++ b/core/logic/smn_core.cpp @@ -60,7 +60,7 @@ #include #include #include -#include +#include using namespace SourceMod; using namespace SourcePawn; @@ -129,7 +129,7 @@ class CMMPluginIterator public IPluginsListener { public: - CMMPluginIterator(const CVector *list) + CMMPluginIterator(const std::vector *list) : m_hasStarted(false) { for(auto iter = list->begin(); iter != list->end(); ++iter) { diff --git a/core/logic/smn_database.cpp b/core/logic/smn_database.cpp index 8e10179d..dd49eb56 100644 --- a/core/logic/smn_database.cpp +++ b/core/logic/smn_database.cpp @@ -285,7 +285,7 @@ public: private: IDatabase *m_pDatabase; IPluginFunction *m_pFunction; - String m_Query; + std::string m_Query; cell_t m_Data; IdentityToken_t *m_Identity; IQuery *m_pQuery; diff --git a/core/logic/smn_maplists.cpp b/core/logic/smn_maplists.cpp index 2a1e1f17..071e8700 100644 --- a/core/logic/smn_maplists.cpp +++ b/core/logic/smn_maplists.cpp @@ -29,7 +29,7 @@ * Version: $Id$ */ -#include +#include #include #include "common_logic.h" #include "CellArray.h" @@ -42,8 +42,6 @@ #include #include -using namespace SourceHook; - struct maplist_info_t { bool bIsCompat; @@ -168,7 +166,7 @@ public: m_pMapCycleFile = bridge->FindConVar("mapcyclefile"); /* Dump everything we know about. */ - List compat; + std::list compat; DumpCache(&compat); /* All this is to add the default entry back in. */ @@ -206,7 +204,7 @@ public: } /* Now, re-add compat stuff back in if we can. */ - List::iterator iter = compat.begin(); + auto iter = compat.begin(); while (iter != compat.end()) { if (m_ListLookup.contains((*iter)->name)) @@ -666,11 +664,11 @@ private: return true; } - void DumpCache(List *compat_list) + void DumpCache(std::list *compat_list) { m_ListLookup.clear(); - List::iterator iter = m_MapLists.begin(); + auto iter = m_MapLists.begin(); while (iter != m_MapLists.end()) { if (compat_list != NULL && (*iter)->bIsCompat) @@ -690,7 +688,7 @@ private: time_t m_ConfigLastChanged; ConVar *m_pMapCycleFile; NameHashSet m_ListLookup; - List m_MapLists; + std::list m_MapLists; MapListState m_CurState; unsigned int m_IgnoreLevel; maplist_info_t *m_pCurMapList; diff --git a/core/logic/smn_menus.cpp b/core/logic/smn_menus.cpp index 85ea9f0a..2c6411cd 100644 --- a/core/logic/smn_menus.cpp +++ b/core/logic/smn_menus.cpp @@ -30,7 +30,8 @@ */ #include "common_logic.h" -#include +#include +#include #include #include #include "DebugReporter.h" @@ -175,13 +176,13 @@ public: while (!m_FreePanelHandlers.empty()) { - delete m_FreePanelHandlers.front(); + delete m_FreePanelHandlers.top(); m_FreePanelHandlers.pop(); } while (!m_FreeMenuHandlers.empty()) { - delete m_FreeMenuHandlers.front(); + delete m_FreeMenuHandlers.top(); m_FreeMenuHandlers.pop(); } } @@ -241,7 +242,7 @@ public: handler = new CPanelHandler; m_PanelHandlers.push_back(handler); } else { - handler = m_FreePanelHandlers.front(); + handler = m_FreePanelHandlers.top(); m_FreePanelHandlers.pop(); } handler->m_pFunc = pFunction; @@ -263,7 +264,7 @@ public: { handler = new CMenuHandler(pFunction, flags); } else { - handler = m_FreeMenuHandlers.front(); + handler = m_FreeMenuHandlers.top(); m_FreeMenuHandlers.pop(); handler->m_pBasic = pFunction; handler->m_Flags = flags; @@ -280,9 +281,9 @@ public: private: HandleType_t m_PanelType; HandleType_t m_TempPanelType; - CStack m_FreePanelHandlers; - CStack m_FreeMenuHandlers; - CVector m_PanelHandlers; + std::stack m_FreePanelHandlers; + std::stack m_FreeMenuHandlers; + std::vector m_PanelHandlers; } g_MenuHelpers; /** diff --git a/core/logic/smn_players.cpp b/core/logic/smn_players.cpp index ce45ba9b..59a56b2f 100644 --- a/core/logic/smn_players.cpp +++ b/core/logic/smn_players.cpp @@ -35,8 +35,8 @@ #include #include #include -#include -#include +#include +#include #include "GameConfigs.h" #include "CellArray.h" #include "AutoHandleRooter.h" @@ -46,7 +46,6 @@ #include #include -using namespace SourceHook; using namespace SourceMod; #ifndef PRIu64 @@ -75,9 +74,9 @@ class PlayerLogicHelpers : struct SimpleMultiTargetFilter { IPlugin *plugin; - SourceHook::String pattern; + std::string pattern; IPluginFunction *fun; - SourceHook::String phrase; + std::string phrase; bool phraseIsML; SimpleMultiTargetFilter(IPlugin *plugin, const char *pattern, IPluginFunction *fun, @@ -87,7 +86,7 @@ class PlayerLogicHelpers : } }; - List simpleMultis; + std::list simpleMultis; bool filterEnabled; public: @@ -107,7 +106,7 @@ public: void RemoveMultiTargetFilter(const char *pattern, IPluginFunction *fun) { - List::iterator iter = simpleMultis.begin(); + auto iter = simpleMultis.begin(); while (iter != simpleMultis.end()) { if ((*iter)->fun == fun && strcmp((*iter)->pattern.c_str(), pattern) == 0) { @@ -127,9 +126,7 @@ public: public: //ICommandTargetProcessor bool ProcessCommandTarget(cmd_target_info_t *info) { - List::iterator iter; - - for (iter = simpleMultis.begin(); iter != simpleMultis.end(); iter++) { + for (auto iter = simpleMultis.begin(); iter != simpleMultis.end(); iter++) { SimpleMultiTargetFilter *smtf = (*iter); if (strcmp(smtf->pattern.c_str(), info->pattern) == 0) { CellArray *array = new CellArray(1); @@ -206,7 +203,7 @@ public: //IPluginsListener void OnPluginDestroyed(IPlugin *plugin) { - List::iterator iter = simpleMultis.begin(); + auto iter = simpleMultis.begin(); while (iter != simpleMultis.end()) { if ((*iter)->plugin != plugin) { diff --git a/core/logic/smn_timers.cpp b/core/logic/smn_timers.cpp index 631d4d41..855f87a6 100644 --- a/core/logic/smn_timers.cpp +++ b/core/logic/smn_timers.cpp @@ -34,12 +34,10 @@ #include #include #include -#include +#include #include "DebugReporter.h" #include -using namespace SourceHook; - #define TIMER_DATA_HNDL_CLOSE (1<<9) #define TIMER_HNDL_CLOSE (1<<9) @@ -74,17 +72,16 @@ public: TimerInfo *CreateTimerInfo(); void DeleteTimerInfo(TimerInfo *pInfo); private: - CStack m_FreeTimers; + std::stack m_FreeTimers; }; TimerNatives::~TimerNatives() { - CStack::iterator iter; - for (iter=m_FreeTimers.begin(); iter!=m_FreeTimers.end(); iter++) + while (!m_FreeTimers.empty()) { - delete (*iter); + delete m_FreeTimers.top(); + m_FreeTimers.pop(); } - m_FreeTimers.popall(); } void TimerNatives::OnSourceModAllInitialized() @@ -118,7 +115,7 @@ TimerInfo *TimerNatives::CreateTimerInfo() { pInfo = new TimerInfo; } else { - pInfo = m_FreeTimers.front(); + pInfo = m_FreeTimers.top(); m_FreeTimers.pop(); } diff --git a/core/smn_console.cpp b/core/smn_console.cpp index cc3ff6d6..3e3d92ff 100644 --- a/core/smn_console.cpp +++ b/core/smn_console.cpp @@ -79,7 +79,7 @@ HandleType_t htConCmdIter = 0; struct GlobCmdIter { bool started; - List::iterator iter; + std::list::iterator iter; }; class ConsoleHelpers : @@ -1056,7 +1056,7 @@ static cell_t ReadCommandIterator(IPluginContext *pContext, const cell_t *params return pContext->ThrowNativeError("Invalid GlobCmdIter Handle %x", params[1]); } - const List &cmds = g_ConCmds.GetCommandList(); + std::list& cmds = const_cast(g_ConCmds.GetCommandList()); if (!iter->started) { @@ -1395,7 +1395,7 @@ static cell_t sm_CommandIteratorNext(IPluginContext *pContext, const cell_t *par return pContext->ThrowNativeError("Invalid CommandIterator Handle %x", params[1]); } - const List &cmds = g_ConCmds.GetCommandList(); + std::list& cmds = const_cast(g_ConCmds.GetCommandList()); if (!iter->started) { @@ -1427,7 +1427,7 @@ static cell_t sm_CommandIteratorAdminFlags(IPluginContext *pContext, const cell_ { return pContext->ThrowNativeError("Invalid CommandIterator Handle %x", params[1]); } - const List &cmds = g_ConCmds.GetCommandList(); + const std::list &cmds = g_ConCmds.GetCommandList(); if (!iter->started || iter->iter == cmds.end()) { return pContext->ThrowNativeError("Invalid CommandIterator position"); @@ -1448,7 +1448,7 @@ static cell_t sm_CommandIteratorConVarFlags(IPluginContext *pContext, const cell { return pContext->ThrowNativeError("Invalid CommandIterator Handle %x", params[1]); } - const List &cmds = g_ConCmds.GetCommandList(); + const std::list &cmds = g_ConCmds.GetCommandList(); if (!iter->started || iter->iter == cmds.end()) { return pContext->ThrowNativeError("Invalid CommandIterator position"); @@ -1469,7 +1469,7 @@ static cell_t sm_CommandIteratorGetDesc(IPluginContext *pContext, const cell_t * { return pContext->ThrowNativeError("Invalid CommandIterator Handle %x", params[1]); } - const List &cmds = g_ConCmds.GetCommandList(); + const std::list &cmds = g_ConCmds.GetCommandList(); if (!iter->started || iter->iter == cmds.end()) { return pContext->ThrowNativeError("Invalid CommandIterator position"); @@ -1492,7 +1492,7 @@ static cell_t sm_CommandIteratorGetName(IPluginContext *pContext, const cell_t * { return pContext->ThrowNativeError("Invalid CommandIterator Handle %x", params[1]); } - const List &cmds = g_ConCmds.GetCommandList(); + const std::list &cmds = g_ConCmds.GetCommandList(); if (!iter->started || iter->iter == cmds.end()) { return pContext->ThrowNativeError("Invalid CommandIterator position"); @@ -1515,7 +1515,8 @@ static cell_t sm_CommandIteratorPlugin(IPluginContext *pContext, const cell_t *p { return pContext->ThrowNativeError("Invalid CommandIterator Handle %x", params[1]); } - const List &cmds = g_ConCmds.GetCommandList(); + + const std::list &cmds = g_ConCmds.GetCommandList(); if (!iter->started || iter->iter == cmds.end()) { return pContext->ThrowNativeError("Invalid CommandIterator position"); diff --git a/core/smn_keyvalues.cpp b/core/smn_keyvalues.cpp index 5e20709d..f3fe0702 100644 --- a/core/smn_keyvalues.cpp +++ b/core/smn_keyvalues.cpp @@ -537,7 +537,7 @@ static cell_t smn_CreateKeyValues(IPluginContext *pCtx, const cell_t *params) is_empty = (firstkey[0] == '\0'); pStk = new KeyValueStack; pStk->pBase = new KeyValues(name, is_empty ? NULL : firstkey, (is_empty||(firstvalue[0]=='\0')) ? NULL : firstvalue); - pStk->pCurRoot.push(pStk->pBase); + pStk->pCurRoot.push_front(pStk->pBase); return handlesys->CreateHandle(g_KeyValueType, pStk, pCtx->GetIdentity(), g_pCoreIdent, NULL); } @@ -566,7 +566,7 @@ static cell_t smn_KeyValuesFromAddress(IPluginContext *pCtx, const cell_t *param */ KeyValueStack *pStk = new KeyValueStack; pStk->pBase = reinterpret_cast(addr); - pStk->pCurRoot.push(pStk->pBase); + pStk->pCurRoot.push_front(pStk->pBase); pStk->m_bDeleteOnDestroy = false; return handlesys->CreateHandle(g_KeyValueType, pStk, pCtx->GetIdentity(), g_pCoreIdent, NULL); @@ -597,7 +597,7 @@ static cell_t smn_KvJumpToKey(IPluginContext *pCtx, const cell_t *params) { return 0; } - pStk->pCurRoot.push(pSubKey); + pStk->pCurRoot.push_front(pSubKey); return 1; } @@ -624,7 +624,7 @@ static cell_t smn_KvJumpToKeySymbol(IPluginContext *pCtx, const cell_t *params) { return 0; } - pStk->pCurRoot.push(pSubKey); + pStk->pCurRoot.push_front(pSubKey); return 1; } @@ -658,7 +658,7 @@ static cell_t smn_KvGotoFirstSubKey(IPluginContext *pCtx, const cell_t *params) { return 0; } - pStk->pCurRoot.push(pFirstSubKey); + pStk->pCurRoot.push_front(pFirstSubKey); return 1; } @@ -690,8 +690,8 @@ static cell_t smn_KvGotoNextKey(IPluginContext *pCtx, const cell_t *params) { return 0; } - pStk->pCurRoot.pop(); - pStk->pCurRoot.push(pSubKey); + pStk->pCurRoot.pop_front(); + pStk->pCurRoot.push_front(pSubKey); return 1; } @@ -716,7 +716,7 @@ static cell_t smn_KvGoBack(IPluginContext *pCtx, const cell_t *params) { return 0; } - pStk->pCurRoot.pop(); + pStk->pCurRoot.pop_front(); return 1; } @@ -742,7 +742,7 @@ static cell_t smn_KvRewind(IPluginContext *pCtx, const cell_t *params) { while (pStk->pCurRoot.size() > 1) { - pStk->pCurRoot.pop(); + pStk->pCurRoot.pop_front(); } } else @@ -750,7 +750,7 @@ static cell_t smn_KvRewind(IPluginContext *pCtx, const cell_t *params) auto root = pStk->pCurRoot.begin(); if (root != pStk->pCurRoot.end()) { - pStk->pCurRoot.push(*root); + pStk->pCurRoot.push_front(*root); } } @@ -965,7 +965,7 @@ static cell_t smn_KvDeleteThis(IPluginContext *pContext, const cell_t *params) } KeyValues *pValues = pStk->pCurRoot.front(); - pStk->pCurRoot.pop(); + pStk->pCurRoot.pop_front(); KeyValues *pRoot = pStk->pCurRoot.front(); /* We have to manually verify this since Valve sucks @@ -982,7 +982,7 @@ static cell_t smn_KvDeleteThis(IPluginContext *pContext, const cell_t *params) pValues->deleteThis(); if (pNext) { - pStk->pCurRoot.push(pNext); + pStk->pCurRoot.push_front(pNext); return 1; } else { return -1; @@ -992,7 +992,7 @@ static cell_t smn_KvDeleteThis(IPluginContext *pContext, const cell_t *params) } /* Push this back on :( */ - pStk->pCurRoot.push(pValues); + pStk->pCurRoot.push_front(pValues); return 0; } @@ -1056,7 +1056,7 @@ static cell_t smn_KvSavePosition(IPluginContext *pContext, const cell_t *params) } KeyValues *pValues = pStk->pCurRoot.front(); - pStk->pCurRoot.push(pValues); + pStk->pCurRoot.push_front(pValues); return 1; } diff --git a/core/smn_keyvalues.h b/core/smn_keyvalues.h index 61e83f3a..d799d7cc 100644 --- a/core/smn_keyvalues.h +++ b/core/smn_keyvalues.h @@ -33,7 +33,7 @@ #define _INCLUDE_SOURCEMOD_KVWRAPPER_H_ #include -#include +#include using namespace SourceMod; @@ -42,7 +42,7 @@ class KeyValues; struct KeyValueStack { KeyValues *pBase; - SourceHook::CStack pCurRoot; + std::deque pCurRoot; bool m_bDeleteOnDestroy = true; }; diff --git a/core/smn_nextmap.cpp b/core/smn_nextmap.cpp index ef6f4ab2..c9a64055 100644 --- a/core/smn_nextmap.cpp +++ b/core/smn_nextmap.cpp @@ -79,8 +79,7 @@ static cell_t sm_GetMapHistory(IPluginContext *pCtx, const cell_t *params) return pCtx->ThrowNativeError("Invalid Map History Index"); } - SourceHook::List::iterator iter; - iter = g_NextMap.m_mapHistory.end(); + auto iter = g_NextMap.m_mapHistory.end(); iter--; for (int i=0; i MsgWrapperList; -typedef List::iterator MsgWrapperIter; +typedef std::list MsgWrapperList; +typedef MsgWrapperList::iterator MsgWrapperIter; class UsrMessageNatives : public SMGlobalClass, @@ -72,17 +72,15 @@ public: bool FindListener(int msgid, IPluginContext *pCtx, IPluginFunction *pHook, bool intercept, MsgWrapperIter *iter); bool DeleteListener(IPluginContext *pCtx, MsgWrapperIter iter); private: - CStack m_FreeListeners; + std::stack m_FreeListeners; }; UsrMessageNatives::~UsrMessageNatives() { - CStack::iterator iter; - for (iter=m_FreeListeners.begin(); iter!=m_FreeListeners.end(); iter++) - { - delete (*iter); + while (!m_FreeListeners.empty()) { + delete m_FreeListeners.top(); + m_FreeListeners.pop(); } - m_FreeListeners.popall(); } void UsrMessageNatives::OnSourceModAllInitialized() @@ -175,13 +173,13 @@ MsgListenerWrapper *UsrMessageNatives::CreateListener(IPluginContext *pCtx) { pListener = new MsgListenerWrapper; } else { - pListener = m_FreeListeners.front(); + pListener = m_FreeListeners.top(); m_FreeListeners.pop(); } if (!pl->GetProperty("MsgListeners", reinterpret_cast(&pList))) { - pList = new List; + pList = new std::list; pl->SetProperty("MsgListeners", pList); } diff --git a/core/sourcemod.cpp b/core/sourcemod.cpp index fce21af3..8d5c6bf0 100644 --- a/core/sourcemod.cpp +++ b/core/sourcemod.cpp @@ -32,7 +32,7 @@ #include #include "sourcemod.h" #include "sourcemm_api.h" -#include +#include #include "CoreConfig.h" #include "Logger.h" #include "sm_stringutil.h" @@ -58,7 +58,7 @@ SH_DECL_HOOK0(IVEngineServer, GetMapEntitiesString, SH_NOATTRIB, 0, const char * SourceModBase g_SourceMod; -SourceHook::String g_BaseDir; +std::string g_BaseDir; ISourcePawnEnvironment *g_pPawnEnv = NULL; IdentityToken_t *g_pCoreIdent = NULL; IForward *g_pOnMapInit = nullptr; @@ -667,7 +667,7 @@ void SourceModBase::RemoveGameFrameHook(GAME_FRAME_HOOK hook) { if (m_frame_hooks[i] == hook) { - m_frame_hooks.erase(m_frame_hooks.iterAt(i)); + m_frame_hooks.erase(m_frame_hooks.begin() + i); return; } } diff --git a/core/sourcemod.h b/core/sourcemod.h index 3667f227..61176358 100644 --- a/core/sourcemod.h +++ b/core/sourcemod.h @@ -34,10 +34,8 @@ #include "sm_globals.h" #include -#include -#include - -using namespace SourceHook; +#include +#include #if defined _DEBUG # define IF_DEBUG_SPEW @@ -147,7 +145,7 @@ private: bool m_ExecOnMapEnd; unsigned int m_target; bool m_GotBasePath; - CVector m_frame_hooks; + std::vector m_frame_hooks; }; void UTIL_ConsolePrintVa(const char *fmt, va_list ap); diff --git a/extensions/dhooks/natives.cpp b/extensions/dhooks/natives.cpp index 92254ba6..f52c95a1 100644 --- a/extensions/dhooks/natives.cpp +++ b/extensions/dhooks/natives.cpp @@ -42,7 +42,7 @@ enum SDKFuncConfSource SDKConf_Address }; -using ParamVector = SourceHook::CVector; +using ParamVector = std::vector; bool GetHandleIfValidOrError(HandleType_t type, void **object, IPluginContext *pContext, cell_t param) { diff --git a/extensions/dhooks/vhook.h b/extensions/dhooks/vhook.h index fc095047..8cba430f 100644 --- a/extensions/dhooks/vhook.h +++ b/extensions/dhooks/vhook.h @@ -34,7 +34,6 @@ #include "extension.h" #include -#include #include #include #include @@ -153,7 +152,7 @@ public: class DHooksInfo { public: - SourceHook::CVector params; + std::vector params; int offset; unsigned int returnFlag; ReturnType returnType; @@ -273,7 +272,7 @@ public: HookType hookType; CallingConvention callConv; ThisPointerType thisType; - SourceHook::CVector params; + std::vector params; int offset; void *funcAddr; IPluginFunction *callback; diff --git a/extensions/pgsql/pgsql/PgDatabase.h b/extensions/pgsql/pgsql/PgDatabase.h index d1d3a102..2a911a7b 100644 --- a/extensions/pgsql/pgsql/PgDatabase.h +++ b/extensions/pgsql/pgsql/PgDatabase.h @@ -81,11 +81,11 @@ private: /* ---------- */ DatabaseInfo m_Info; - String m_Host; - String m_Database; - String m_User; - String m_Pass; - String m_Schema; + std::string m_Host; + std::string m_Database; + std::string m_User; + std::string m_Pass; + std::string m_Schema; bool m_bPersistent; }; diff --git a/extensions/pgsql/pgsql/PgDriver.cpp b/extensions/pgsql/pgsql/PgDriver.cpp index e056210b..61c74a25 100644 --- a/extensions/pgsql/pgsql/PgDriver.cpp +++ b/extensions/pgsql/pgsql/PgDriver.cpp @@ -40,10 +40,9 @@ PgDriver::PgDriver() m_Handle = BAD_HANDLE; } -void CloseDBList(List &l) +void CloseDBList(std::list &l) { - List::iterator iter; - for (iter=l.begin(); iter!=l.end(); iter++) + for (auto iter=l.begin(); iter!=l.end(); iter++) { PgDatabase *db = (*iter); while (!db->Close()) @@ -56,7 +55,6 @@ void CloseDBList(List &l) void PgDriver::Shutdown() { - List::iterator iter; CloseDBList(m_PermDbs); if (m_Handle != BAD_HANDLE) @@ -191,8 +189,7 @@ IDatabase *PgDriver::Connect(const DatabaseInfo *info, bool persistent, char *er if (persistent) { /* Try to find a matching persistent connection */ - List::iterator iter; - for (iter=m_PermDbs.begin(); + for (auto iter=m_PermDbs.begin(); iter!=m_PermDbs.end(); iter++) { diff --git a/extensions/pgsql/pgsql/PgDriver.h b/extensions/pgsql/pgsql/PgDriver.h index 5a59fe01..47740ccd 100644 --- a/extensions/pgsql/pgsql/PgDriver.h +++ b/extensions/pgsql/pgsql/PgDriver.h @@ -41,13 +41,11 @@ #include -#include -#include - +#include +#include #include using namespace SourceMod; -using namespace SourceHook; #define M_CLIENT_MULTI_RESULTS ((1) << 17) /* Enable/disable multi-results */ @@ -72,7 +70,7 @@ public: private: std::mutex m_Lock; Handle_t m_Handle; - List m_PermDbs; + std::list m_PermDbs; }; extern PgDriver g_PgDriver; diff --git a/extensions/sdkhooks/extension.cpp b/extensions/sdkhooks/extension.cpp index 98a10f62..be521479 100644 --- a/extensions/sdkhooks/extension.cpp +++ b/extensions/sdkhooks/extension.cpp @@ -1854,9 +1854,8 @@ void SDKHooks::HandleEntityCreated(CBaseEntity *pEntity, int index, cell_t ref) cell_t bcompatRef = gamehelpers->EntityToBCompatRef(pEntity); // Send OnEntityCreated to SM listeners - SourceHook::List::iterator iter; ISMEntityListener *pListener = NULL; - for (iter = m_EntListeners.begin(); iter != m_EntListeners.end(); iter++) + for (auto iter = m_EntListeners.begin(); iter != m_EntListeners.end(); iter++) { pListener = (*iter); pListener->OnEntityCreated(pEntity, pName ? pName : ""); @@ -1875,9 +1874,8 @@ void SDKHooks::HandleEntityDeleted(CBaseEntity *pEntity) cell_t bcompatRef = gamehelpers->EntityToBCompatRef(pEntity); // Send OnEntityDestroyed to SM listeners - SourceHook::List::iterator iter; ISMEntityListener *pListener = NULL; - for (iter = m_EntListeners.begin(); iter != m_EntListeners.end(); iter++) + for (auto iter = m_EntListeners.begin(); iter != m_EntListeners.end(); iter++) { pListener = (*iter); pListener->OnEntityDestroyed(pEntity); diff --git a/extensions/sdkhooks/extension.h b/extensions/sdkhooks/extension.h index e502c609..fe2dfcd8 100644 --- a/extensions/sdkhooks/extension.h +++ b/extensions/sdkhooks/extension.h @@ -6,7 +6,7 @@ #include "smsdk_ext.h" #include #include -#include +#include #include #include @@ -262,7 +262,7 @@ public: // ISDKHooks public: // IServerGameDLL void LevelShutdown(); private: - SourceHook::List m_EntListeners; + std::list m_EntListeners; public: /** diff --git a/extensions/sdktools/extension.cpp b/extensions/sdktools/extension.cpp index 66ff208c..5cb6cba6 100644 --- a/extensions/sdktools/extension.cpp +++ b/extensions/sdktools/extension.cpp @@ -237,8 +237,7 @@ void SDKTools::OnHandleDestroy(HandleType_t type, void *object) void SDKTools::SDK_OnUnload() { - SourceHook::List::iterator iter; - for (iter = g_RegCalls.begin(); + for (auto iter = g_RegCalls.begin(); iter != g_RegCalls.end(); iter++) { @@ -395,8 +394,7 @@ bool SDKTools::QueryInterfaceDrop(SMInterface *pInterface) void SDKTools::NotifyInterfaceDrop(SMInterface *pInterface) { - SourceHook::List::iterator iter; - for (iter = g_RegCalls.begin(); + for (auto iter = g_RegCalls.begin(); iter != g_RegCalls.end(); iter++) { diff --git a/extensions/sdktools/output.cpp b/extensions/sdktools/output.cpp index a5e803bc..cbc7edde 100644 --- a/extensions/sdktools/output.cpp +++ b/extensions/sdktools/output.cpp @@ -33,6 +33,8 @@ #include "output.h" #include "am-string.h" +#include + ISourcePawnEngine *spengine = NULL; EntityOutputManager g_OutputManager; CDetour *fireOutputDetour = NULL; @@ -138,11 +140,9 @@ bool EntityOutputManager::FireEventDetour(void *pOutput, CBaseEntity *pActivator if (!pOutputName->hooks.empty()) { - SourceHook::List::iterator _iter; - omg_hooks *hook; - _iter = pOutputName->hooks.begin(); + auto _iter = pOutputName->hooks.begin(); // by default we'll call the game's output func, unless a plugin overrides it bool fireOriginal = true; @@ -221,7 +221,7 @@ omg_hooks *EntityOutputManager::NewHook() } else { - hook = g_OutputManager.FreeHooks.front(); + hook = g_OutputManager.FreeHooks.top(); g_OutputManager.FreeHooks.pop(); } @@ -256,14 +256,14 @@ void EntityOutputManager::CleanUpHook(omg_hooks *hook) OnHookRemoved(); IPlugin *pPlugin = plsys->FindPluginByContext(hook->pf->GetParentContext()); - SourceHook::List *pList = NULL; + std::list *pList = NULL; if (!pPlugin->GetProperty("OutputHookList", (void **)&pList, false) || !pList) { return; } - SourceHook::List::iterator p_iter = pList->begin(); + auto p_iter = pList->begin(); omg_hooks *pluginHook; @@ -283,11 +283,11 @@ void EntityOutputManager::CleanUpHook(omg_hooks *hook) void EntityOutputManager::OnPluginDestroyed(IPlugin *plugin) { - SourceHook::List *pList = NULL; + std::list *pList = NULL; if (plugin->GetProperty("OutputHookList", (void **)&pList, true)) { - SourceHook::List::iterator p_iter = pList->begin(); + auto p_iter = pList->begin(); omg_hooks *hook; while (p_iter != pList->end()) diff --git a/extensions/sdktools/output.h b/extensions/sdktools/output.h index 02ec9da5..4ce03402 100644 --- a/extensions/sdktools/output.h +++ b/extensions/sdktools/output.h @@ -34,8 +34,8 @@ #include #include -#include "sh_list.h" -#include "sh_stack.h" +#include +#include #include "sm_trie_tpl.h" #include "CDetour/detours.h" @@ -62,7 +62,7 @@ struct omg_hooks */ struct OutputNameStruct { - SourceHook::List hooks; + std::list hooks; char Name[50]; }; @@ -124,7 +124,7 @@ private: // Maps classname to a ClassNameStruct IBasicTrie *ClassNames; - SourceHook::CStack FreeHooks; //Stores hook pointers to avoid calls to new + std::stack FreeHooks; //Stores hook pointers to avoid calls to new int HookCount; diff --git a/extensions/sdktools/outputnatives.cpp b/extensions/sdktools/outputnatives.cpp index 8fcb2eb6..211f5103 100644 --- a/extensions/sdktools/outputnatives.cpp +++ b/extensions/sdktools/outputnatives.cpp @@ -65,14 +65,12 @@ cell_t HookSingleEntityOutput(IPluginContext *pContext, const cell_t *params) OutputNameStruct *pOutputName = g_OutputManager.FindOutputPointer((const char *)classname, outputname, true); //Check for an existing identical hook - SourceHook::List::iterator _iter; - omg_hooks *hook; IPluginFunction *pFunction; pFunction = pContext->GetFunctionById(params[3]); - for (_iter=pOutputName->hooks.begin(); _iter!=pOutputName->hooks.end(); _iter++) + for (auto _iter=pOutputName->hooks.begin(); _iter!=pOutputName->hooks.end(); _iter++) { hook = (omg_hooks *)*_iter; if (hook->pf == pFunction && hook->entity_ref == gamehelpers->EntityToReference(pEntity)) @@ -95,11 +93,11 @@ cell_t HookSingleEntityOutput(IPluginContext *pContext, const cell_t *params) g_OutputManager.OnHookAdded(); IPlugin *pPlugin = plsys->FindPluginByContext(pContext); - SourceHook::List *pList = NULL; + std::list *pList = NULL; if (!pPlugin->GetProperty("OutputHookList", (void **)&pList, false) || !pList) { - pList = new SourceHook::List; + pList = new std::list; pPlugin->SetProperty("OutputHookList", pList); } @@ -126,14 +124,12 @@ cell_t HookEntityOutput(IPluginContext *pContext, const cell_t *params) OutputNameStruct *pOutputName = g_OutputManager.FindOutputPointer((const char *)classname, outputname, true); //Check for an existing identical hook - SourceHook::List::iterator _iter; - omg_hooks *hook; IPluginFunction *pFunction; pFunction = pContext->GetFunctionById(params[3]); - for (_iter=pOutputName->hooks.begin(); _iter!=pOutputName->hooks.end(); _iter++) + for (auto _iter=pOutputName->hooks.begin(); _iter!=pOutputName->hooks.end(); _iter++) { hook = (omg_hooks *)*_iter; if (hook->pf == pFunction && hook->entity_ref == -1) @@ -158,11 +154,11 @@ cell_t HookEntityOutput(IPluginContext *pContext, const cell_t *params) g_OutputManager.OnHookAdded(); IPlugin *pPlugin = plsys->FindPluginByContext(pContext); - SourceHook::List *pList = NULL; + std::list *pList = NULL; if (!pPlugin->GetProperty("OutputHookList", (void **)&pList, false) || !pList) { - pList = new SourceHook::List; + pList = new std::list; pPlugin->SetProperty("OutputHookList", pList); } @@ -193,14 +189,12 @@ cell_t UnHookEntityOutput(IPluginContext *pContext, const cell_t *params) } //Check for an existing identical hook - SourceHook::List::iterator _iter; - omg_hooks *hook; IPluginFunction *pFunction; pFunction = pContext->GetFunctionById(params[3]); - for (_iter=pOutputName->hooks.begin(); _iter!=pOutputName->hooks.end(); _iter++) + for (auto _iter=pOutputName->hooks.begin(); _iter!=pOutputName->hooks.end(); _iter++) { hook = (omg_hooks *)*_iter; if (hook->pf == pFunction && hook->entity_ref == -1) @@ -250,14 +244,12 @@ cell_t UnHookSingleEntityOutput(IPluginContext *pContext, const cell_t *params) } //Check for an existing identical hook - SourceHook::List::iterator _iter; - omg_hooks *hook; IPluginFunction *pFunction; pFunction = pContext->GetFunctionById(params[3]); - for (_iter=pOutputName->hooks.begin(); _iter!=pOutputName->hooks.end(); _iter++) + for (auto _iter=pOutputName->hooks.begin(); _iter!=pOutputName->hooks.end(); _iter++) { hook = (omg_hooks *)*_iter; /* We're not serial checking and just removing by index here - This was always allowed so is left for bcompat */ diff --git a/extensions/sdktools/teamnatives.cpp b/extensions/sdktools/teamnatives.cpp index c35bb0b5..dbe03b15 100644 --- a/extensions/sdktools/teamnatives.cpp +++ b/extensions/sdktools/teamnatives.cpp @@ -31,7 +31,7 @@ #include "extension.h" #include "vhelpers.h" -#include +#include struct TeamInfo { @@ -41,7 +41,7 @@ struct TeamInfo char m_iScore[64] = { 0 }; -SourceHook::CVector g_Teams; +std::vector g_Teams; void InitTeamNatives() { diff --git a/extensions/sdktools/tempents.cpp b/extensions/sdktools/tempents.cpp index 53d711b0..1de21dd9 100644 --- a/extensions/sdktools/tempents.cpp +++ b/extensions/sdktools/tempents.cpp @@ -419,8 +419,7 @@ void TempEntityManager::Shutdown() return; } - SourceHook::List::iterator iter; - for (iter=m_TEList.begin(); iter!=m_TEList.end(); iter++) + for (auto iter=m_TEList.begin(); iter!=m_TEList.end(); iter++) { delete (*iter); } diff --git a/extensions/sdktools/tempents.h b/extensions/sdktools/tempents.h index fddb8614..250ef780 100644 --- a/extensions/sdktools/tempents.h +++ b/extensions/sdktools/tempents.h @@ -34,8 +34,8 @@ #include "extension.h" #include -#include -#include +#include +#include #include class TempEntityInfo @@ -61,7 +61,7 @@ private: private: void *m_Me; ServerClass *m_Sc; - SourceHook::String m_Name; + std::string m_Name; }; class TempEntityManager @@ -79,7 +79,7 @@ public: void DumpList(); void DumpProps(FILE *fp); private: - SourceHook::List m_TEList; + std::list m_TEList; IBasicTrie *m_TempEntInfo; void *m_ListHead; int m_NameOffs; @@ -91,7 +91,7 @@ private: struct TEHookInfo { TempEntityInfo *te; - SourceHook::List lst; + std::list lst; }; class TempEntHooks : public IPluginsListener @@ -110,7 +110,7 @@ private: size_t _FillInPlayers(int *pl_array, IRecipientFilter *pFilter); private: IBasicTrie *m_TEHooks; - SourceHook::List m_HookInfo; + std::list m_HookInfo; size_t m_HookCount; }; diff --git a/extensions/sdktools/tenatives.cpp b/extensions/sdktools/tenatives.cpp index 014538ae..a792747b 100644 --- a/extensions/sdktools/tenatives.cpp +++ b/extensions/sdktools/tenatives.cpp @@ -61,8 +61,7 @@ void TempEntHooks::Shutdown() } plsys->RemovePluginsListener(this); - SourceHook::List::iterator iter; - for (iter=m_HookInfo.begin(); iter!=m_HookInfo.end(); iter++) + for (auto iter=m_HookInfo.begin(); iter!=m_HookInfo.end(); iter++) { delete (*iter); } @@ -77,13 +76,13 @@ void TempEntHooks::Shutdown() void TempEntHooks::OnPluginUnloaded(IPlugin *plugin) { - SourceHook::List::iterator iter = m_HookInfo.begin(); + auto iter = m_HookInfo.begin(); IPluginContext *pContext = plugin->GetBaseContext(); /* For each hook list... */ while (iter != m_HookInfo.end()) { - SourceHook::List::iterator f_iter = (*iter)->lst.begin(); + auto f_iter = (*iter)->lst.begin(); /* Find the hooks on the given temp entity */ while (f_iter != (*iter)->lst.end()) @@ -177,8 +176,8 @@ bool TempEntHooks::RemoveHook(const char *name, IPluginFunction *pFunc) if (m_TEHooks->Retrieve(name, reinterpret_cast(&pInfo))) { - SourceHook::List::iterator iter; - if ((iter=pInfo->lst.find(pFunc)) != pInfo->lst.end()) + auto iter = std::find(pInfo->lst.begin(), pInfo->lst.end(), pFunc); + if (iter != pInfo->lst.end()) { pInfo->lst.erase(iter); if (pInfo->lst.empty()) @@ -205,7 +204,6 @@ void TempEntHooks::OnPlaybackTempEntity(IRecipientFilter &filter, float delay, c if (m_TEHooks->Retrieve(name, reinterpret_cast(&pInfo))) { - SourceHook::List::iterator iter; IPluginFunction *pFunc; size_t size; cell_t res = static_cast(Pl_Continue); @@ -214,7 +212,7 @@ void TempEntHooks::OnPlaybackTempEntity(IRecipientFilter &filter, float delay, c g_CurrentTE = pInfo->te; size = _FillInPlayers(g_TEPlayers, &filter); - for (iter=pInfo->lst.begin(); iter!=pInfo->lst.end(); iter++) + for (auto iter=pInfo->lst.begin(); iter!=pInfo->lst.end(); iter++) { pFunc = (*iter); pFunc->PushString(name); diff --git a/extensions/sdktools/vcallbuilder.cpp b/extensions/sdktools/vcallbuilder.cpp index 36d3a1f5..17c6231c 100644 --- a/extensions/sdktools/vcallbuilder.cpp +++ b/extensions/sdktools/vcallbuilder.cpp @@ -46,7 +46,7 @@ ValveCall::~ValveCall() { while (!stk.empty()) { - unsigned char *ptr = stk.front(); + unsigned char *ptr = stk.top(); delete [] ptr; stk.pop(); } @@ -65,7 +65,7 @@ unsigned char *ValveCall::stk_get() { ptr = new unsigned char[stackSize]; } else { - ptr = stk.front(); + ptr = stk.top(); stk.pop(); } return ptr; diff --git a/extensions/sdktools/vcallbuilder.h b/extensions/sdktools/vcallbuilder.h index 3237fe5d..2a63cd87 100644 --- a/extensions/sdktools/vcallbuilder.h +++ b/extensions/sdktools/vcallbuilder.h @@ -32,7 +32,7 @@ #ifndef _INCLUDE_SOURCEMOD_VALVE_CALLER_H_ #define _INCLUDE_SOURCEMOD_VALVE_CALLER_H_ -#include +#include #include #include "vdecoder.h" @@ -51,7 +51,7 @@ struct ValveCall size_t stackSize; /**< Stack size */ size_t stackEnd; /**< End of the bintools stack */ unsigned char *retbuf; /**< Return buffer */ - SourceHook::CStack stk; /**< Parameter stack */ + std::stack stk; /**< Parameter stack */ unsigned char *stk_get(); void stk_put(unsigned char *ptr); diff --git a/extensions/sdktools/vnatives.cpp b/extensions/sdktools/vnatives.cpp index 558724be..fdd5a2c3 100644 --- a/extensions/sdktools/vnatives.cpp +++ b/extensions/sdktools/vnatives.cpp @@ -30,7 +30,7 @@ */ #include -#include +#include #include "extension.h" #include "vcallbuilder.h" #include "vnatives.h" @@ -43,8 +43,8 @@ #include "am-string.h" #include -SourceHook::List g_RegCalls; -SourceHook::List g_CallWraps; +std::list g_RegCalls; +std::list g_CallWraps; #define ENTINDEX_TO_CBASEENTITY(ref, buffer) \ buffer = gamehelpers->ReferenceToEntity(ref); \ @@ -626,31 +626,31 @@ static cell_t SetClientViewEntity(IPluginContext *pContext, const cell_t *params return pContext->ThrowNativeError("Entity %d is not valid", params[2]); } - CBaseEntity *pClientEntity = player->GetEdict()->GetUnknown()->GetBaseEntity(); - sm_sendprop_info_t info; - ServerClass *pServerClass = gamehelpers->FindEntityServerClass(pClientEntity); - if (pServerClass && gamehelpers->FindSendPropInfo(pServerClass->GetName(), "m_hViewEntity", &info)) - { - CBaseHandle &hViewEntity = *(CBaseHandle *)((char *)pClientEntity + info.actual_offset); - gamehelpers->SetHandleEntity(hViewEntity, pEdict); - gamehelpers->SetEdictStateChanged(player->GetEdict(), info.actual_offset); - } - else - { - sm_datatable_info_t info; - if (gamehelpers->FindDataMapInfo(gamehelpers->GetDataMap(pClientEntity), "m_hViewEntity", &info)) - { - CBaseHandle &hViewEntity = *(CBaseHandle *)((char *)pClientEntity + info.actual_offset); - gamehelpers->SetHandleEntity(hViewEntity, pEdict); - } - } - + CBaseEntity *pClientEntity = player->GetEdict()->GetUnknown()->GetBaseEntity(); + sm_sendprop_info_t info; + ServerClass *pServerClass = gamehelpers->FindEntityServerClass(pClientEntity); + if (pServerClass && gamehelpers->FindSendPropInfo(pServerClass->GetName(), "m_hViewEntity", &info)) + { + CBaseHandle &hViewEntity = *(CBaseHandle *)((char *)pClientEntity + info.actual_offset); + gamehelpers->SetHandleEntity(hViewEntity, pEdict); + gamehelpers->SetEdictStateChanged(player->GetEdict(), info.actual_offset); + } + else + { + sm_datatable_info_t info; + if (gamehelpers->FindDataMapInfo(gamehelpers->GetDataMap(pClientEntity), "m_hViewEntity", &info)) + { + CBaseHandle &hViewEntity = *(CBaseHandle *)((char *)pClientEntity + info.actual_offset); + gamehelpers->SetHandleEntity(hViewEntity, pEdict); + } + } + engine->SetView(player->GetEdict(), pEdict); return 1; } -static SourceHook::String *g_lightstyle[MAX_LIGHTSTYLES] = {NULL}; +static std::string *g_lightstyle[MAX_LIGHTSTYLES] = {NULL}; static cell_t SetLightStyle(IPluginContext *pContext, const cell_t *params) { int style = params[1]; @@ -666,7 +666,7 @@ static cell_t SetLightStyle(IPluginContext *pContext, const cell_t *params) * this or not on shutdown, but for ~4K of memory MAX, it doesn't seem worth it yet. * So, it's a :TODO:! */ - g_lightstyle[style] = new SourceHook::String(); + g_lightstyle[style] = new std::string(); } char *str; diff --git a/extensions/sdktools/vnatives.h b/extensions/sdktools/vnatives.h index 74612360..faacdafd 100644 --- a/extensions/sdktools/vnatives.h +++ b/extensions/sdktools/vnatives.h @@ -32,9 +32,9 @@ #ifndef _INCLUDE_SDKTOOLS_VNATIVES_H_ #define _INCLUDE_SDKTOOLS_VNATIVES_H_ -#include +#include -extern SourceHook::List g_RegCalls; +extern std::list g_RegCalls; extern sp_nativeinfo_t g_Natives[]; extern sp_nativeinfo_t g_SoundNatives[]; diff --git a/extensions/sdktools/vsound.cpp b/extensions/sdktools/vsound.cpp index 29d50edc..e9096d64 100644 --- a/extensions/sdktools/vsound.cpp +++ b/extensions/sdktools/vsound.cpp @@ -139,12 +139,11 @@ void SoundHooks::Shutdown() void SoundHooks::OnPluginUnloaded(IPlugin *plugin) { - SoundHookIter iter; IPluginContext *pContext = plugin->GetBaseContext(); if (m_AmbientCount) { - for (iter=m_AmbientFuncs.begin(); iter!=m_AmbientFuncs.end(); ) + for (auto iter=m_AmbientFuncs.begin(); iter!=m_AmbientFuncs.end(); ) { if ((*iter)->GetParentContext() == pContext) { @@ -159,7 +158,7 @@ void SoundHooks::OnPluginUnloaded(IPlugin *plugin) } if (m_NormalCount) { - for (iter=m_NormalFuncs.begin(); iter!=m_NormalFuncs.end(); ) + for (auto iter=m_NormalFuncs.begin(); iter!=m_NormalFuncs.end(); ) { if ((*iter)->GetParentContext() == pContext) { @@ -190,10 +189,10 @@ void SoundHooks::AddHook(int type, IPluginFunction *pFunc) bool SoundHooks::RemoveHook(int type, IPluginFunction *pFunc) { - SoundHookIter iter; if (type == NORMAL_SOUND_HOOK) { - if ((iter=m_NormalFuncs.find(pFunc)) != m_NormalFuncs.end()) + auto iter = std::find(m_NormalFuncs.begin(), m_NormalFuncs.end(), pFunc); + if (iter != m_NormalFuncs.end()) { m_NormalFuncs.erase(iter); _DecRefCounter(NORMAL_SOUND_HOOK); @@ -206,7 +205,8 @@ bool SoundHooks::RemoveHook(int type, IPluginFunction *pFunc) } else if (type == AMBIENT_SOUND_HOOK) { - if ((iter=m_AmbientFuncs.find(pFunc)) != m_AmbientFuncs.end()) + auto iter = std::find(m_AmbientFuncs.begin(), m_AmbientFuncs.end(), pFunc); + if (iter != m_AmbientFuncs.end()) { m_AmbientFuncs.erase(iter); _DecRefCounter(AMBIENT_SOUND_HOOK); @@ -224,14 +224,13 @@ bool SoundHooks::RemoveHook(int type, IPluginFunction *pFunc) void SoundHooks::OnEmitAmbientSound(int entindex, const Vector &pos, const char *samp, float vol, soundlevel_t soundlevel, int fFlags, int pitch, float delay) { - SoundHookIter iter; IPluginFunction *pFunc; cell_t vec[3] = {sp_ftoc(pos.x), sp_ftoc(pos.y), sp_ftoc(pos.z)}; cell_t res = static_cast(Pl_Continue); char buffer[PLATFORM_MAX_PATH]; ke::SafeStrcpy(buffer, sizeof(buffer), samp); - for (iter=m_AmbientFuncs.begin(); iter!=m_AmbientFuncs.end(); iter++) + for (auto iter=m_AmbientFuncs.begin(); iter!=m_AmbientFuncs.end(); iter++) { pFunc = (*iter); pFunc->PushStringEx(buffer, sizeof(buffer), SM_PARAM_STRING_COPY, SM_PARAM_COPYBACK); @@ -340,7 +339,6 @@ void SoundHooks::OnEmitSound(IRecipientFilter &filter, int iEntIndex, int iChann float soundtime, int speakerentity) #endif { - SoundHookIter iter; IPluginFunction *pFunc; cell_t res = static_cast(Pl_Continue); char buffer[PLATFORM_MAX_PATH]; @@ -355,7 +353,7 @@ void SoundHooks::OnEmitSound(IRecipientFilter &filter, int iEntIndex, int iChann int nSeed = 0; #endif - for (iter=m_NormalFuncs.begin(); iter!=m_NormalFuncs.end(); iter++) + for (auto iter=m_NormalFuncs.begin(); iter!=m_NormalFuncs.end(); iter++) { int players[SM_MAXPLAYERS], size; size = _FillInPlayers(players, &filter); @@ -503,7 +501,6 @@ void SoundHooks::OnEmitSound2(IRecipientFilter &filter, int iEntIndex, int iChan float soundtime, int speakerentity) #endif { - SoundHookIter iter; IPluginFunction *pFunc; cell_t res = static_cast(Pl_Continue); cell_t sndlevel = static_cast(ATTN_TO_SNDLVL(flAttenuation)); @@ -519,7 +516,7 @@ void SoundHooks::OnEmitSound2(IRecipientFilter &filter, int iEntIndex, int iChan int nSeed = 0; #endif - for (iter=m_NormalFuncs.begin(); iter!=m_NormalFuncs.end(); iter++) + for (auto iter=m_NormalFuncs.begin(); iter!=m_NormalFuncs.end(); iter++) { int players[SM_MAXPLAYERS], size; size = _FillInPlayers(players, &filter); diff --git a/extensions/sdktools/vsound.h b/extensions/sdktools/vsound.h index 11f277aa..8e434b20 100644 --- a/extensions/sdktools/vsound.h +++ b/extensions/sdktools/vsound.h @@ -32,15 +32,13 @@ #ifndef _INCLUDE_SOURCEMOD_VSOUND_H_ #define _INCLUDE_SOURCEMOD_VSOUND_H_ -#include +#include #include "extension.h" #include "CellRecipientFilter.h" #define NORMAL_SOUND_HOOK 0 #define AMBIENT_SOUND_HOOK 1 -typedef SourceHook::List::iterator SoundHookIter; - class SoundHooks : public IPluginsListener { public: //IPluginsListener @@ -99,8 +97,8 @@ private: void _IncRefCounter(int type); void _DecRefCounter(int type); private: - SourceHook::List m_AmbientFuncs; - SourceHook::List m_NormalFuncs; + std::list m_AmbientFuncs; + std::list m_NormalFuncs; size_t m_NormalCount; size_t m_AmbientCount; }; diff --git a/extensions/sqlite/driver/SqDatabase.h b/extensions/sqlite/driver/SqDatabase.h index ee4d49ac..dab02ba8 100644 --- a/extensions/sqlite/driver/SqDatabase.h +++ b/extensions/sqlite/driver/SqDatabase.h @@ -72,7 +72,7 @@ private: sqlite3 *m_sq3; std::recursive_mutex m_FullLock; bool m_Persistent; - String m_LastError; + std::string m_LastError; int m_LastErrorCode; }; diff --git a/extensions/sqlite/driver/SqDriver.cpp b/extensions/sqlite/driver/SqDriver.cpp index 3b4ffbaf..9b72e1ef 100644 --- a/extensions/sqlite/driver/SqDriver.cpp +++ b/extensions/sqlite/driver/SqDriver.cpp @@ -77,9 +77,8 @@ SqDriver::~SqDriver() { std::lock_guard lock(m_OpenLock); - List::iterator iter; SqDatabase *sqdb; - for (iter = m_Cache.begin(); iter != m_Cache.end(); iter++) + for (auto iter = m_Cache.begin(); iter != m_Cache.end(); iter++) { // Don't let SqDatabase try to remove itself from m_Cache // now that we're gone. @@ -258,8 +257,7 @@ IDatabase *SqDriver::Connect(const DatabaseInfo *info, bool persistent, char *er if (persistent) { /* See if anything in the cache matches */ - List::iterator iter; - for (iter = m_Cache.begin(); iter != m_Cache.end(); iter++) + for (auto iter = m_Cache.begin(); iter != m_Cache.end(); iter++) { if ((*iter).path.compare(fullpath) == 0) { @@ -298,8 +296,7 @@ void SqDriver::RemovePersistent(IDatabase *pdb) { std::lock_guard lock(m_OpenLock); - List::iterator iter; - for (iter = m_Cache.begin(); iter != m_Cache.end(); iter++) + for (auto iter = m_Cache.begin(); iter != m_Cache.end(); iter++) { if ((*iter).db == pdb) { diff --git a/extensions/sqlite/driver/SqDriver.h b/extensions/sqlite/driver/SqDriver.h index e41c9e70..6d2f0e48 100644 --- a/extensions/sqlite/driver/SqDriver.h +++ b/extensions/sqlite/driver/SqDriver.h @@ -34,17 +34,16 @@ #define SOURCEMOD_SQL_DRIVER_CODE #include -#include -#include +#include +#include #include #include "sqlite-source/sqlite3.h" using namespace SourceMod; -using namespace SourceHook; struct SqDbInfo { - String path; + std::string path; IDatabase *db; }; @@ -73,7 +72,7 @@ public: private: Handle_t m_Handle; std::mutex m_OpenLock; - List m_Cache; + std::list m_Cache; bool m_bThreadSafe; bool m_bShutdown; }; diff --git a/extensions/sqlite/driver/SqQuery.h b/extensions/sqlite/driver/SqQuery.h index 2881d2d6..30dedc65 100644 --- a/extensions/sqlite/driver/SqQuery.h +++ b/extensions/sqlite/driver/SqQuery.h @@ -35,6 +35,7 @@ #include #include "SqDatabase.h" #include "SqResults.h" +#include class SqQuery : public IPreparedQuery @@ -86,7 +87,7 @@ private: sqlite3_stmt *m_pStmt; SqResults *m_pResults; unsigned int m_ParamCount; - String m_LastError; + std::string m_LastError; int m_LastErrorCode; unsigned int m_AffectedRows; unsigned int m_InsertID; diff --git a/extensions/sqlite/driver/SqResults.cpp b/extensions/sqlite/driver/SqResults.cpp index 3bd0be38..75a40b3c 100644 --- a/extensions/sqlite/driver/SqResults.cpp +++ b/extensions/sqlite/driver/SqResults.cpp @@ -42,7 +42,7 @@ SqResults::SqResults(SqQuery *query) : m_ColCount = sqlite3_column_count(m_pStmt); if (m_ColCount) { - m_ColNames = new String[m_ColCount]; + m_ColNames = new std::string[m_ColCount]; for (unsigned int i=0; iobj_list[i] == obj) { - parent_cat->obj_list.erase(parent_cat->obj_list.iterAt(i)); + parent_cat->obj_list.erase(parent_cat->obj_list.begin() + i); /* If this category now has no items, mark root as changed * so clients won't get the category drawn anymore. @@ -936,7 +936,7 @@ void TopMenu::SortCategoryIfNeeded(unsigned int category) return; } - CVector to_sort; + std::vector to_sort; for (size_t i = 0; i < cat->obj_list.size(); i++) { to_sort.push_back(i); @@ -966,7 +966,7 @@ void TopMenu::SortCategoryIfNeeded(unsigned int category) { /* Place in the final list, then remove from the temporary list */ cat->sorted.push_back(cat->obj_list[to_sort[j]]); - to_sort.erase(to_sort.iterAt(j)); + to_sort.erase(to_sort.begin() + j); break; } } @@ -999,7 +999,7 @@ void TopMenu::SortCategoriesIfNeeded() return; } - CVector to_sort; + std::vector to_sort; for (unsigned int i = 0; i < (unsigned int)m_Categories.size(); i++) { to_sort.push_back(i); @@ -1016,7 +1016,7 @@ void TopMenu::SortCategoriesIfNeeded() { /* Add to the real list and remove from the temporary */ m_SortedCats.push_back(to_sort[j]); - to_sort.erase(to_sort.iterAt(j)); + to_sort.erase(to_sort.begin() + j); break; } } @@ -1089,7 +1089,7 @@ bool TopMenu::LoadConfiguration(const char *file, char *error, size_t maxlength) bool TopMenu::OnIdentityRemoval(IdentityToken_t *owner) { /* First sweep the categories owned by us */ - CVector obj_list; + std::vector obj_list; for (size_t i = 0; i < m_Categories.size(); i++) { if (m_Categories[i]->obj->owner == owner) diff --git a/extensions/topmenus/TopMenu.h b/extensions/topmenus/TopMenu.h index 298c7f58..e2e6e053 100644 --- a/extensions/topmenus/TopMenu.h +++ b/extensions/topmenus/TopMenu.h @@ -32,14 +32,13 @@ #ifndef _INCLUDE_SOURCEMOD_TOP_MENU_H_ #define _INCLUDE_SOURCEMOD_TOP_MENU_H_ -#include -#include +#include +#include #include #include "smsdk_ext.h" #include "sm_memtable.h" #include -using namespace SourceHook; using namespace SourceMod; #define TOPMENU_DISPLAY_BUFFER_SIZE 128 @@ -47,7 +46,7 @@ using namespace SourceMod; struct config_category_t { int name; - CVector commands; + std::vector commands; }; struct config_root_t @@ -56,7 +55,7 @@ struct config_root_t { } BaseStringTable strings; - CVector cats; + std::vector cats; }; struct topmenu_object_t @@ -85,9 +84,9 @@ struct topmenu_object_t struct topmenu_category_t { - CVector obj_list; /** Full object list */ - CVector sorted; /** Sorted items */ - CVector unsorted; /** Unsorted items */ + std::vector obj_list; /** Full object list */ + std::vector sorted; /** Sorted items */ + std::vector unsorted; /** Unsorted items */ topmenu_object_t *obj; /** Bound object */ unsigned int serial; /** Serial number */ bool reorder; /** Whether ordering needs updating */ @@ -181,10 +180,10 @@ private: private: config_root_t m_Config; /* Configuration from file */ topmenu_player_t *m_clients; /* Client array */ - CVector m_SortedCats; /* Sorted categories */ - CVector m_UnsortedCats; /* Un-sorted categories */ - CVector m_Categories; /* Category array */ - CVector m_Objects; /* Object array */ + std::vector m_SortedCats; /* Sorted categories */ + std::vector m_UnsortedCats; /* Un-sorted categories */ + std::vector m_Categories; /* Category array */ + std::vector m_Objects; /* Object array */ NameHashSet m_ObjLookup; /* Object lookup trie */ unsigned int m_SerialNo; /* Serial number for updating */ ITopMenuObjectCallbacks *m_pTitle; /* Title callbacks */ diff --git a/extensions/topmenus/TopMenuManager.cpp b/extensions/topmenus/TopMenuManager.cpp index 8b611473..debf1234 100644 --- a/extensions/topmenus/TopMenuManager.cpp +++ b/extensions/topmenus/TopMenuManager.cpp @@ -56,9 +56,7 @@ ITopMenu *TopMenuManager::CreateTopMenu(ITopMenuObjectCallbacks *callbacks) void TopMenuManager::OnClientConnected(int client) { - List::iterator iter; - - for (iter = m_TopMenus.begin(); iter != m_TopMenus.end(); iter++) + for (auto iter = m_TopMenus.begin(); iter != m_TopMenus.end(); iter++) { (*iter)->OnClientConnected(client); } @@ -66,9 +64,7 @@ void TopMenuManager::OnClientConnected(int client) void TopMenuManager::OnClientDisconnected(int client) { - List::iterator iter; - - for (iter = m_TopMenus.begin(); iter != m_TopMenus.end(); iter++) + for (auto iter = m_TopMenus.begin(); iter != m_TopMenus.end(); iter++) { (*iter)->OnClientDisconnected(client); } @@ -81,9 +77,7 @@ void TopMenuManager::OnServerActivated(int max_clients) return; } - List::iterator iter; - - for (iter = m_TopMenus.begin(); iter != m_TopMenus.end(); iter++) + for (auto iter = m_TopMenus.begin(); iter != m_TopMenus.end(); iter++) { (*iter)->OnServerActivated(max_clients); } @@ -93,7 +87,7 @@ void TopMenuManager::OnServerActivated(int max_clients) void TopMenuManager::OnPluginUnloaded(IPlugin *plugin) { - List::iterator iter = m_TopMenus.begin(); + auto iter = m_TopMenus.begin(); while (iter != m_TopMenus.end()) { @@ -120,9 +114,7 @@ void TopMenuManager::DestroyTopMenu(ITopMenu *topmenu) void TopMenuManager::OnMaxPlayersChanged( int newvalue ) { - List::iterator iter; - - for (iter = m_TopMenus.begin(); iter != m_TopMenus.end(); iter++) + for (auto iter = m_TopMenus.begin(); iter != m_TopMenus.end(); iter++) { (*iter)->OnMaxPlayersChanged(newvalue); } diff --git a/extensions/topmenus/TopMenuManager.h b/extensions/topmenus/TopMenuManager.h index 3225a753..d5423ae8 100644 --- a/extensions/topmenus/TopMenuManager.h +++ b/extensions/topmenus/TopMenuManager.h @@ -36,10 +36,9 @@ #include #include #include -#include +#include using namespace SourceMod; -using namespace SourceHook; class TopMenu; @@ -60,7 +59,7 @@ public: void OnPluginUnloaded(IPlugin *plugin); void OnMaxPlayersChanged(int newvalue); private: - List m_TopMenus; + std::list m_TopMenus; }; extern TopMenuManager g_TopMenus; diff --git a/extensions/updater/Updater.h b/extensions/updater/Updater.h index 247b8231..ca6f1e56 100644 --- a/extensions/updater/Updater.h +++ b/extensions/updater/Updater.h @@ -34,11 +34,9 @@ #include #include -#include +#include #include "MemoryDownloader.h" -using namespace SourceHook; - struct UpdatePart { UpdatePart* next; @@ -72,8 +70,8 @@ namespace SourceMod MemoryDownloader mdl; unsigned int ustate; unsigned int ignoreLevel; - SourceHook::String curfile; - SourceHook::String url; + std::string curfile; + std::string url; char checksum[33]; UpdatePart *partFirst; UpdatePart *partLast; diff --git a/extensions/updater/extension.cpp b/extensions/updater/extension.cpp index 4fcdbbc4..3fd5f261 100644 --- a/extensions/updater/extension.cpp +++ b/extensions/updater/extension.cpp @@ -36,20 +36,18 @@ #include #include "extension.h" #include "Updater.h" -#include -#include +#include +#include #define DEFAULT_UPDATE_URL "http://www.sourcemod.net/update/" -using namespace SourceHook; - SmUpdater g_Updater; /**< Global singleton for extension's main interface */ SMEXT_LINK(&g_Updater); IWebternet *webternet; -static List update_errors; +static std::list update_errors; static IThreadHandle *update_thread; -static String update_url; +static std::string update_url; bool SmUpdater::SDK_OnLoad(char *error, size_t maxlength, bool late) { @@ -90,7 +88,7 @@ void SmUpdater::SDK_OnUnload() } /* Clear message tables */ - List::iterator iter = update_errors.begin(); + auto iter = update_errors.begin(); while (iter != update_errors.end()) { iter = update_errors.erase(iter); @@ -120,9 +118,8 @@ void SmUpdater::NotifyInterfaceDrop(SMInterface *pInterface) static void PumpUpdate(void *data) { - String *str; + std::string *str; bool new_files = false; - List::iterator iter; char path[PLATFORM_MAX_PATH]; UpdatePart *temp; @@ -185,7 +182,7 @@ skip_create: { smutils->LogError(myself, "--- BEGIN ERRORS FROM AUTOMATIC UPDATER ---"); - for (iter = update_errors.begin(); + for (auto iter = update_errors.begin(); iter != update_errors.end(); iter++) { @@ -244,7 +241,7 @@ void AddUpdateError(const char *fmt, ...) smutils->FormatArgs(buffer, sizeof(buffer), fmt, ap); va_end(ap); - update_errors.push_back(new String(buffer)); + update_errors.push_back(new std::string(buffer)); } const char *SmUpdater::GetExtensionVerString() diff --git a/public/sm_queue.h b/public/sm_queue.h index ff46a583..fa76fede 100644 --- a/public/sm_queue.h +++ b/public/sm_queue.h @@ -34,9 +34,7 @@ #include #include -#include - -using namespace SourceHook; +#include /* A circular, doubly-linked List with one sentinel node @@ -109,7 +107,7 @@ public: while (!m_FreeNodes.empty()) { - free(m_FreeNodes.front()); + free(m_FreeNodes.top()); m_FreeNodes.pop(); } } @@ -122,7 +120,7 @@ public: { node = (QueueNode *)malloc(sizeof(QueueNode)); } else { - node = m_FreeNodes.front(); + node = m_FreeNodes.top(); m_FreeNodes.pop(); } @@ -169,7 +167,7 @@ public: private: QueueNode *m_Head; size_t m_Size; - CStack m_FreeNodes; + std::stack m_FreeNodes; public: class iterator {