mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
- Fixed mantis #1421
- Fixed initial map selection in campaign bonus screen
This commit is contained in:
parent
d1002f7e8f
commit
61fc216a6f
@ -3186,16 +3186,20 @@ void CBonusSelection::init()
|
||||
bonuses = new CHighlightableButtonsGroup(bind(&CBonusSelection::selectBonus, this, _1));
|
||||
|
||||
//set left part of window
|
||||
for (int g=0; g<ourCampaign->camp->scenarios.size(); ++g)
|
||||
bool isCurrentMapConquerable = ourCampaign->currentMap && ourCampaign->camp->conquerable(*ourCampaign->currentMap);
|
||||
for(int g = 0; g < ourCampaign->camp->scenarios.size(); ++g)
|
||||
{
|
||||
if(ourCampaign->camp->conquerable(g))
|
||||
{
|
||||
regions.push_back(new CRegion(this, true, true, g));
|
||||
regions[regions.size()-1]->rclickText = ourCampaign->camp->scenarios[g].regionText;
|
||||
if (highlightedRegion == nullptr)
|
||||
if(highlightedRegion == nullptr)
|
||||
{
|
||||
highlightedRegion = regions.back();
|
||||
selectMap(g, true);
|
||||
if(!isCurrentMapConquerable || (isCurrentMapConquerable && g == *ourCampaign->currentMap))
|
||||
{
|
||||
highlightedRegion = regions.back();
|
||||
selectMap(g, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (ourCampaign->camp->scenarios[g].conquered) //display as striped
|
||||
|
@ -1469,33 +1469,39 @@ void CGameHandler::run(bool resume)
|
||||
return;
|
||||
}
|
||||
|
||||
while (!end2)
|
||||
{
|
||||
if(!resume)
|
||||
newTurn();
|
||||
auto playerTurnOrder = generatePlayerTurnOrder();
|
||||
|
||||
std::map<PlayerColor,PlayerState>::iterator i;
|
||||
if(!resume)
|
||||
i = gs->players.begin();
|
||||
while(!end2)
|
||||
{
|
||||
if(!resume) newTurn();
|
||||
|
||||
std::list<PlayerColor>::iterator it;
|
||||
if(resume)
|
||||
{
|
||||
it = std::find(playerTurnOrder.begin(), playerTurnOrder.end(), gs->currentPlayer);
|
||||
}
|
||||
else
|
||||
i = gs->players.find(gs->currentPlayer);
|
||||
{
|
||||
it = playerTurnOrder.begin();
|
||||
}
|
||||
|
||||
resume = false;
|
||||
for(; i != gs->players.end(); i++)
|
||||
for(; it != playerTurnOrder.end(); it++)
|
||||
{
|
||||
if(i->second.status == EPlayerStatus::INGAME)
|
||||
auto playerColor = *it;
|
||||
if(gs->players[playerColor].status == EPlayerStatus::INGAME)
|
||||
{
|
||||
states.setFlag(i->first,&PlayerStatus::makingTurn,true);
|
||||
states.setFlag(playerColor, &PlayerStatus::makingTurn, true);
|
||||
|
||||
YourTurn yt;
|
||||
yt.player = i->first;
|
||||
yt.player = playerColor;
|
||||
applyAndSend(&yt);
|
||||
|
||||
checkVictoryLossConditionsForAll();
|
||||
|
||||
//wait till turn is done
|
||||
boost::unique_lock<boost::mutex> lock(states.mx);
|
||||
while(states.players.at(i->first).makingTurn && !end2)
|
||||
while(states.players.at(playerColor).makingTurn && !end2)
|
||||
{
|
||||
static time_duration p = milliseconds(200);
|
||||
states.cv.timed_wait(lock,p);
|
||||
@ -1507,6 +1513,27 @@ void CGameHandler::run(bool resume)
|
||||
boost::this_thread::sleep(boost::posix_time::milliseconds(5)); //give time client to close socket
|
||||
}
|
||||
|
||||
std::list<PlayerColor> CGameHandler::generatePlayerTurnOrder() const
|
||||
{
|
||||
// Generate player turn order
|
||||
std::list<PlayerColor> playerTurnOrder;
|
||||
|
||||
bool playCampaign = gs->scenarioOps->campState != nullptr;
|
||||
for(const auto & player : gs->players) // add human players for campaign only first OR all players for normal game
|
||||
{
|
||||
if(player.second.human || !playCampaign) playerTurnOrder.push_back(player.first);
|
||||
}
|
||||
if(playCampaign)
|
||||
{
|
||||
for(const auto & player : gs->players) // then add non-human players for campaign
|
||||
{
|
||||
if(!player.second.human) playerTurnOrder.push_back(player.first);
|
||||
}
|
||||
}
|
||||
|
||||
return std::move(playerTurnOrder);
|
||||
}
|
||||
|
||||
void CGameHandler::setupBattle( int3 tile, const CArmedInstance *armies[2], const CGHeroInstance *heroes[2], bool creatureBank, const CGTownInstance *town )
|
||||
{
|
||||
battleResult.set(nullptr);
|
||||
|
@ -289,6 +289,7 @@ public:
|
||||
friend class CScriptCallback;
|
||||
|
||||
private:
|
||||
std::list<PlayerColor> generatePlayerTurnOrder() const;
|
||||
void makeStackDoNothing(const CStack * next);
|
||||
void getVictoryLossMessage(PlayerColor player, EVictoryLossCheckResult victoryLossCheckResult, InfoWindow & out) const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user