From b6000841f10732740e53cf1346363eea17902e29 Mon Sep 17 00:00:00 2001 From: Michael <13953785+Laserlicht@users.noreply.github.com> Date: Tue, 29 Aug 2023 21:08:18 +0200 Subject: [PATCH] code review --- client/lobby/OptionsTab.cpp | 6 +++--- client/lobby/OptionsTab.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/client/lobby/OptionsTab.cpp b/client/lobby/OptionsTab.cpp index 9c08b23fe..f9de0b3f3 100644 --- a/client/lobby/OptionsTab.cpp +++ b/client/lobby/OptionsTab.cpp @@ -620,7 +620,7 @@ OptionsTab::SelectionWindow::SelectionWindow(PlayerColor _color, SelType _type) for(auto & player : SEL->getStartInfo()->playerInfos) { if(player.first != color && (int)player.second.hero > PlayerSettings::RANDOM) - unusableHeroes.push_back(player.second.hero); + unusableHeroes.insert(player.second.hero); } allowedBonus.push_back(-1); // random @@ -817,7 +817,7 @@ void OptionsTab::SelectionWindow::genContentHeroes() std::string image = "lobby/townBorderBig"; if(selectedHero == elem) image = "lobby/townBorderBigActivated"; - if(std::find(unusableHeroes.begin(), unusableHeroes.end(), elem) != unusableHeroes.end()) + if(unusableHeroes.count(elem)) image = "lobby/townBorderBigGrayedOut"; components.push_back(std::make_shared(image, x * (ICON_BIG_WIDTH-1), y * (ICON_BIG_HEIGHT-1))); heroes.push_back(elem); @@ -900,7 +900,7 @@ void OptionsTab::SelectionWindow::setElement(int elem, bool doApply) set.hero = PlayerSettings::RANDOM; } - if(doApply && std::find(unusableHeroes.begin(), unusableHeroes.end(), heroes[elem]) != unusableHeroes.end()) + if(doApply && unusableHeroes.count(heroes[elem])) return; if(set.hero.getNum() != PlayerSettings::NONE) diff --git a/client/lobby/OptionsTab.h b/client/lobby/OptionsTab.h index 10c4c64c7..b3d9f7e9a 100644 --- a/client/lobby/OptionsTab.h +++ b/client/lobby/OptionsTab.h @@ -114,8 +114,8 @@ private: std::vector factions; std::vector heroes; - std::vector unusableHeroes; - + std::set unusableHeroes; + FactionID initialFaction; HeroTypeID initialHero; int initialBonus;