Merge pull request #528 from diamante0018/develop

got -> itr
This commit is contained in:
Edo 2022-10-15 15:34:17 +01:00 committed by GitHub
commit 77345f9944
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 30 additions and 41 deletions

View File

@ -46,9 +46,9 @@ namespace Components
Command::ServerParams params; Command::ServerParams params;
const auto command = Utils::String::ToLower(params.get(0)); 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, &params); itr->second(ent, &params);
return; return;
} }

View File

@ -157,9 +157,9 @@ namespace Components
ClientParams params; ClientParams params;
const auto command = Utils::String::ToLower(params[0]); 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(&params); itr->second(&params);
} }
} }
@ -168,9 +168,9 @@ namespace Components
ServerParams params; ServerParams params;
const auto command = Utils::String::ToLower(params[0]); 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(&params); itr->second(&params);
} }
} }
} }

View File

@ -72,15 +72,15 @@ namespace Components
const auto* op = Game::Scr_GetString(1); const auto* op = Game::Scr_GetString(1);
const auto b = GetInt64Arg(2, true); 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; 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; return;
} }

View File

@ -297,13 +297,11 @@ namespace Components
{ {
if (pName != nullptr) 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 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; *type = itr->second.type;
return got->second.actionFunc; return itr->second.actionFunc;
} }
} }
else else
@ -321,13 +319,11 @@ namespace Components
{ {
if (pName != nullptr) 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 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; *type = itr->second.type;
return got->second.actionFunc; return itr->second.actionFunc;
} }
} }
else else

View File

@ -51,11 +51,9 @@ namespace Components
if (classnum == Game::ClassNum::CLASS_NUM_ENTITY) if (classnum == Game::ClassNum::CLASS_NUM_ENTITY)
{ {
const auto entity_offset = static_cast<std::uint16_t>(offset); const auto entity_offset = static_cast<std::uint16_t>(offset);
if (const auto itr = CustomEntityFields.find(entity_offset); itr != CustomEntityFields.end())
const auto got =CustomEntityFields.find(entity_offset);
if (got != CustomEntityFields.end())
{ {
got->second.setter(&Game::g_entities[entnum], offset); itr->second.setter(&Game::g_entities[entnum], offset);
return 1; return 1;
} }
} }
@ -68,11 +66,9 @@ namespace Components
void ScriptExtension::Scr_SetClientFieldStub(Game::gclient_s* client, int offset) void ScriptExtension::Scr_SetClientFieldStub(Game::gclient_s* client, int offset)
{ {
const auto client_offset = static_cast<std::uint16_t>(offset); const auto client_offset = static_cast<std::uint16_t>(offset);
if (const auto itr = CustomClientFields.find(client_offset); itr != CustomClientFields.end())
const auto got = CustomClientFields.find(client_offset);
if (got != CustomClientFields.end())
{ {
got->second.setter(client, &got->second); itr->second.setter(client, &itr->second);
return; 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 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) if (Game::g_entities[entnum].client != nullptr)
{ {
const auto client_offset = static_cast<std::uint16_t>(offset & ~Game::ENTFIELD_MASK); const auto client_offset = static_cast<std::uint16_t>(offset & ~Game::ENTFIELD_MASK);
if (const auto itr = CustomClientFields.find(client_offset); itr != CustomClientFields.end())
const auto got =CustomClientFields.find(client_offset);
if (got != CustomClientFields.end())
{ {
// Game functions probably don't ever need to use the reference to client_fields_s... // 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; return;
} }
} }
@ -102,10 +96,9 @@ namespace Components
// Regular entity offsets can be searched directly in our custom handler // Regular entity offsets can be searched directly in our custom handler
const auto entity_offset = static_cast<std::uint16_t>(offset); const auto entity_offset = static_cast<std::uint16_t>(offset);
const auto got = CustomEntityFields.find(entity_offset); if (const auto itr = CustomEntityFields.find(entity_offset); itr != CustomEntityFields.end())
if (got != CustomEntityFields.end())
{ {
got->second.getter(&Game::g_entities[entnum], offset); itr->second.getter(&Game::g_entities[entnum], offset);
return; return;
} }

View File

@ -61,10 +61,10 @@ namespace Components
bool UIScript::RunMenuScript(const char* name, const char** args) 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); const auto* info = UIScript::UI_GetClientInfo(0);
got->second(UIScript::Token(args), info); itr->second(UIScript::Token(args), info);
return true; return true;
} }

View File

@ -242,8 +242,8 @@ namespace Components
return; return;
} }
const auto got = VoteCommands.find(params->get(1)); const auto itr = VoteCommands.find(params->get(1));
if (got == VoteCommands.end()) 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("%c \"GAME_INVALIDVOTESTRING\"", 0x65));
Game::SV_GameSendServerCommand(ent - Game::g_entities, Game::SV_CMD_CAN_IGNORE, VA(CallVoteDesc, 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)); 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) if (shouldDisplay)
{ {
DisplayVote(ent); DisplayVote(ent);