From b7e6662e6be536d0e4c25fff14970a823012d69c Mon Sep 17 00:00:00 2001 From: FutureRave Date: Fri, 14 Oct 2022 22:56:09 +0100 Subject: [PATCH] got -> itr --- src/Components/Modules/ClientCommand.cpp | 4 +-- src/Components/Modules/Command.cpp | 8 +++--- src/Components/Modules/GSC/Int64.cpp | 8 +++--- src/Components/Modules/GSC/Script.cpp | 16 +++++------- .../Modules/GSC/ScriptExtension.cpp | 25 +++++++------------ src/Components/Modules/UIScript.cpp | 4 +-- src/Components/Modules/Vote.cpp | 6 ++--- 7 files changed, 30 insertions(+), 41 deletions(-) diff --git a/src/Components/Modules/ClientCommand.cpp b/src/Components/Modules/ClientCommand.cpp index ec316bed..fd6c3cc6 100644 --- a/src/Components/Modules/ClientCommand.cpp +++ b/src/Components/Modules/ClientCommand.cpp @@ -46,9 +46,9 @@ namespace Components Command::ServerParams params; const auto command = Utils::String::ToLower(params.get(0)); - if (const auto got = HandlersSV.find(command); got != HandlersSV.end()) + if (const auto itr = HandlersSV.find(command); itr != HandlersSV.end()) { - got->second(ent, ¶ms); + itr->second(ent, ¶ms); return; } diff --git a/src/Components/Modules/Command.cpp b/src/Components/Modules/Command.cpp index af2327e6..9afca701 100644 --- a/src/Components/Modules/Command.cpp +++ b/src/Components/Modules/Command.cpp @@ -157,9 +157,9 @@ namespace Components ClientParams params; const auto command = Utils::String::ToLower(params[0]); - if (const auto got = FunctionMap.find(command); got != FunctionMap.end()) + if (const auto itr = FunctionMap.find(command); itr != FunctionMap.end()) { - got->second(¶ms); + itr->second(¶ms); } } @@ -168,9 +168,9 @@ namespace Components ServerParams params; const auto command = Utils::String::ToLower(params[0]); - if (const auto got = FunctionMapSV.find(command); got != FunctionMapSV.end()) + if (const auto itr = FunctionMapSV.find(command); itr != FunctionMapSV.end()) { - got->second(¶ms); + itr->second(¶ms); } } } diff --git a/src/Components/Modules/GSC/Int64.cpp b/src/Components/Modules/GSC/Int64.cpp index c2fc4eee..1d4247b2 100644 --- a/src/Components/Modules/GSC/Int64.cpp +++ b/src/Components/Modules/GSC/Int64.cpp @@ -72,15 +72,15 @@ namespace Components const auto* op = Game::Scr_GetString(1); const auto b = GetInt64Arg(2, true); - if (const auto got = Operations.find(op); got != Operations.end()) + if (const auto itr = Operations.find(op); itr != Operations.end()) { - Game::Scr_AddString(Utils::String::VA("%lld", got->second(a, b))); + Game::Scr_AddString(Utils::String::VA("%lld", itr->second(a, b))); return; } - if (const auto got = Comparisons.find(op); got != Comparisons.end()) + if (const auto itr = Comparisons.find(op); itr != Comparisons.end()) { - Game::Scr_AddBool(got->second(a, b)); + Game::Scr_AddBool(itr->second(a, b)); return; } diff --git a/src/Components/Modules/GSC/Script.cpp b/src/Components/Modules/GSC/Script.cpp index b87c9b17..4b53c825 100644 --- a/src/Components/Modules/GSC/Script.cpp +++ b/src/Components/Modules/GSC/Script.cpp @@ -297,13 +297,11 @@ namespace Components { if (pName != nullptr) { - const auto got = Script::CustomScrFunctions.find(Utils::String::ToLower(*pName)); - // If no function was found let's call game's function - if (got != Script::CustomScrFunctions.end()) + if (const auto itr = Script::CustomScrFunctions.find(Utils::String::ToLower(*pName)); itr != Script::CustomScrFunctions.end()) { - *type = got->second.type; - return got->second.actionFunc; + *type = itr->second.type; + return itr->second.actionFunc; } } else @@ -321,13 +319,11 @@ namespace Components { if (pName != nullptr) { - const auto got = Script::CustomScrMethods.find(Utils::String::ToLower(*pName)); - // If no method was found let's call game's function - if (got != Script::CustomScrMethods.end()) + if (const auto itr = Script::CustomScrMethods.find(Utils::String::ToLower(*pName)); itr != Script::CustomScrMethods.end()) { - *type = got->second.type; - return got->second.actionFunc; + *type = itr->second.type; + return itr->second.actionFunc; } } else diff --git a/src/Components/Modules/GSC/ScriptExtension.cpp b/src/Components/Modules/GSC/ScriptExtension.cpp index ffa09e6c..94e08aa3 100644 --- a/src/Components/Modules/GSC/ScriptExtension.cpp +++ b/src/Components/Modules/GSC/ScriptExtension.cpp @@ -51,11 +51,9 @@ namespace Components if (classnum == Game::ClassNum::CLASS_NUM_ENTITY) { const auto entity_offset = static_cast(offset); - - const auto got =CustomEntityFields.find(entity_offset); - if (got != CustomEntityFields.end()) + if (const auto itr = CustomEntityFields.find(entity_offset); itr != CustomEntityFields.end()) { - got->second.setter(&Game::g_entities[entnum], offset); + itr->second.setter(&Game::g_entities[entnum], offset); return 1; } } @@ -68,11 +66,9 @@ namespace Components void ScriptExtension::Scr_SetClientFieldStub(Game::gclient_s* client, int offset) { const auto client_offset = static_cast(offset); - - const auto got = CustomClientFields.find(client_offset); - if (got != CustomClientFields.end()) + if (const auto itr = CustomClientFields.find(client_offset); itr != CustomClientFields.end()) { - got->second.setter(client, &got->second); + itr->second.setter(client, &itr->second); return; } @@ -87,13 +83,11 @@ namespace Components // If we have a ENTFIELD_CLIENT offset we need to check g_entity is actually a fully connected client if (Game::g_entities[entnum].client != nullptr) { - const auto client_offset = static_cast(offset & ~Game::ENTFIELD_MASK); - - const auto got =CustomClientFields.find(client_offset); - if (got != CustomClientFields.end()) + const auto client_offset = static_cast(offset & ~Game::ENTFIELD_MASK); + if (const auto itr = CustomClientFields.find(client_offset); itr != CustomClientFields.end()) { // Game functions probably don't ever need to use the reference to client_fields_s... - got->second.getter(Game::g_entities[entnum].client, &got->second); + itr->second.getter(Game::g_entities[entnum].client, &itr->second); return; } } @@ -102,10 +96,9 @@ namespace Components // Regular entity offsets can be searched directly in our custom handler const auto entity_offset = static_cast(offset); - const auto got = CustomEntityFields.find(entity_offset); - if (got != CustomEntityFields.end()) + if (const auto itr = CustomEntityFields.find(entity_offset); itr != CustomEntityFields.end()) { - got->second.getter(&Game::g_entities[entnum], offset); + itr->second.getter(&Game::g_entities[entnum], offset); return; } diff --git a/src/Components/Modules/UIScript.cpp b/src/Components/Modules/UIScript.cpp index 9f00d097..835d4682 100644 --- a/src/Components/Modules/UIScript.cpp +++ b/src/Components/Modules/UIScript.cpp @@ -61,10 +61,10 @@ namespace Components bool UIScript::RunMenuScript(const char* name, const char** args) { - if (const auto got = UIScript::UIScripts.find(name); got != UIScript::UIScripts.end()) + if (const auto itr = UIScript::UIScripts.find(name); itr != UIScript::UIScripts.end()) { const auto* info = UIScript::UI_GetClientInfo(0); - got->second(UIScript::Token(args), info); + itr->second(UIScript::Token(args), info); return true; } diff --git a/src/Components/Modules/Vote.cpp b/src/Components/Modules/Vote.cpp index 67eebbdd..3a74336b 100644 --- a/src/Components/Modules/Vote.cpp +++ b/src/Components/Modules/Vote.cpp @@ -242,8 +242,8 @@ namespace Components return; } - const auto got = VoteCommands.find(params->get(1)); - if (got == VoteCommands.end()) + const auto itr = VoteCommands.find(params->get(1)); + if (itr == VoteCommands.end()) { Game::SV_GameSendServerCommand(ent - Game::g_entities, Game::SV_CMD_CAN_IGNORE, VA("%c \"GAME_INVALIDVOTESTRING\"", 0x65)); Game::SV_GameSendServerCommand(ent - Game::g_entities, Game::SV_CMD_CAN_IGNORE, VA(CallVoteDesc, 0x65)); @@ -256,7 +256,7 @@ namespace Components Game::Cbuf_AddText(0, VA("%s\n", Game::level->voteString)); } - const auto shouldDisplay = got->second(ent, params); + const auto shouldDisplay = itr->second(ent, params); if (shouldDisplay) { DisplayVote(ent);