Browse Source

code review

Michael 2 years ago
parent
commit
b6000841f1
2 changed files with 5 additions and 5 deletions
  1. 3 3
      client/lobby/OptionsTab.cpp
  2. 2 2
      client/lobby/OptionsTab.h

+ 3 - 3
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<CPicture>(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)

+ 2 - 2
client/lobby/OptionsTab.h

@@ -114,8 +114,8 @@ private:
 
 		std::vector<FactionID> factions;
 		std::vector<HeroTypeID> heroes;
-		std::vector<HeroTypeID> unusableHeroes;
-		
+		std::set<HeroTypeID> unusableHeroes;
+
 		FactionID initialFaction;
 		HeroTypeID initialHero;
 		int initialBonus;