From ad8a6c55d7f57d62caba084ca0c6305ce4bc973f Mon Sep 17 00:00:00 2001 From: Fay Date: Sat, 24 Jan 2015 21:24:23 +0100 Subject: [PATCH 1/2] 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; --- client/CPreGame.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/CPreGame.cpp b/client/CPreGame.cpp index 950a8b113..6a95a8da2 100644 --- a/client/CPreGame.cpp +++ b/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(); From 551925b6d712969bdef0629c2fd696f5dcf4c125 Mon Sep 17 00:00:00 2001 From: Fay Date: Sat, 24 Jan 2015 23:12:17 +0100 Subject: [PATCH 2/2] Added comments; --- client/CPreGame.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/CPreGame.cpp b/client/CPreGame.cpp index 6a95a8da2..44aab9b7a 100644 --- a/client/CPreGame.cpp +++ b/client/CPreGame.cpp @@ -2318,7 +2318,7 @@ 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); + usedHeroes.erase(s.hero); // restore previously selected hero back to available pool s.hero = PlayerSettings::RANDOM; } if(cur < 0 && s.bonus == PlayerSettings::RESOURCE) @@ -2355,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, -1, s.hero, 1, dir); + s.hero = nextAllowedHero(player, -1, s.hero, 1, dir); // min needs to be -1 -- hero at index 0 would be skipped otherwise } if(old != s.hero) @@ -2533,7 +2533,7 @@ void OptionsTab::flagPressed( PlayerColor color ) usedHeroes.erase(old->hero); old->hero = entries[old->color]->pi.defaultHero(); - entries[old->color]->update(); + entries[old->color]->update(); // update previous frame images in case entries were auto-updated } SEL->propagateOptions();