Selaa lähdekoodia

Fixes #2016 (heroes not possible to be chosen in pregame after switching town selection);
Fixes skipping first hero selection when switching them with left arrow;
Fixes redrawing random hero portrait correctly after switching that player to AI;

Fay 10 vuotta sitten
vanhempi
sitoutus
ad8a6c55d7
1 muutettua tiedostoa jossa 5 lisäystä ja 1 poistoa
  1. 5 1
      client/CPreGame.cpp

+ 5 - 1
client/CPreGame.cpp

@@ -2317,7 +2317,10 @@ void OptionsTab::nextCastle( PlayerColor player, int dir )
 	}
 
 	if(s.hero >= 0 && !SEL->current->mapHeader->players[s.color.getNum()].hasCustomMainHero()) // remove hero unless it set to fixed one in map editor
+	{
+		usedHeroes.erase(s.hero);
 		s.hero =  PlayerSettings::RANDOM;
+	}
 	if(cur < 0  &&  s.bonus == PlayerSettings::RESOURCE)
 		s.bonus = PlayerSettings::RANDOM;
 
@@ -2352,7 +2355,7 @@ void OptionsTab::nextHero( PlayerColor player, int dir )
 		if(dir > 0)
 			s.hero = nextAllowedHero(player, s.hero, CGI->heroh->heroes.size(), 1, dir);
 		else
-			s.hero = nextAllowedHero(player,  0, s.hero, 1, dir);
+			s.hero = nextAllowedHero(player, -1, s.hero, 1, dir);
 	}
 
 	if(old != s.hero)
@@ -2530,6 +2533,7 @@ void OptionsTab::flagPressed( PlayerColor color )
 			usedHeroes.erase(old->hero);
 
 		old->hero = entries[old->color]->pi.defaultHero();
+		entries[old->color]->update();
 	}
 
 	SEL->propagateOptions();