diff --git a/client/Client.cpp b/client/Client.cpp index f31e6db53..fdfd691e6 100644 --- a/client/Client.cpp +++ b/client/Client.cpp @@ -430,18 +430,23 @@ void CClient::initPlayerEnvironments() void CClient::initPlayerInterfaces() { - for(auto & elem : gs->scenarioOps->playerInfos) + for(auto & playerInfo : gs->scenarioOps->playerInfos) { - PlayerColor color = elem.first; + PlayerColor color = playerInfo.first; if(!vstd::contains(CSH->getAllClientPlayers(CSH->c->connectionID), color)) continue; if(!vstd::contains(playerint, color)) { logNetwork->info("Preparing interface for player %s", color.getStr()); - if(elem.second.isControlledByAI()) + if(playerInfo.second.isControlledByAI()) { - auto AiToGive = aiNameForPlayer(elem.second, false); + bool alliedToHuman = false; + for(auto & allyInfo : gs->scenarioOps->playerInfos) + if (gs->getPlayerTeam(allyInfo.first) == gs->getPlayerTeam(playerInfo.first) && allyInfo.second.isControlledByHuman()) + alliedToHuman = true; + + auto AiToGive = aiNameForPlayer(playerInfo.second, false, alliedToHuman); logNetwork->info("Player %s will be lead by %s", color.getStr(), AiToGive); installNewPlayerInterface(CDynLibHandler::getNewAI(AiToGive), color); } @@ -464,7 +469,7 @@ void CClient::initPlayerInterfaces() logNetwork->trace("Initialized player interfaces %d ms", CSH->th->getDiff()); } -std::string CClient::aiNameForPlayer(const PlayerSettings & ps, bool battleAI) +std::string CClient::aiNameForPlayer(const PlayerSettings & ps, bool battleAI, bool alliedToHuman) { if(ps.name.size()) { @@ -473,13 +478,15 @@ std::string CClient::aiNameForPlayer(const PlayerSettings & ps, bool battleAI) return ps.name; } - return aiNameForPlayer(battleAI); + return aiNameForPlayer(battleAI, alliedToHuman); } -std::string CClient::aiNameForPlayer(bool battleAI) +std::string CClient::aiNameForPlayer(bool battleAI, bool alliedToHuman) { const int sensibleAILimit = settings["session"]["oneGoodAI"].Bool() ? 1 : PlayerColor::PLAYER_LIMIT_I; - std::string goodAI = battleAI ? settings["server"]["neutralAI"].String() : settings["server"]["playerAI"].String(); + std::string goodAdventureAI = alliedToHuman ? settings["server"]["alliedAI"].String() : settings["server"]["playerAI"].String(); + std::string goodBattleAI = settings["server"]["neutralAI"].String(); + std::string goodAI = battleAI ? goodBattleAI : goodAdventureAI; std::string badAI = battleAI ? "StupidAI" : "EmptyAI"; //TODO what about human players diff --git a/client/Client.h b/client/Client.h index 0daac5afa..234074dec 100644 --- a/client/Client.h +++ b/client/Client.h @@ -161,8 +161,8 @@ public: void initMapHandler(); void initPlayerEnvironments(); void initPlayerInterfaces(); - std::string aiNameForPlayer(const PlayerSettings & ps, bool battleAI); //empty means no AI -> human - std::string aiNameForPlayer(bool battleAI); + std::string aiNameForPlayer(const PlayerSettings & ps, bool battleAI, bool alliedToHuman); //empty means no AI -> human + std::string aiNameForPlayer(bool battleAI, bool alliedToHuman); void installNewPlayerInterface(std::shared_ptr gameInterface, PlayerColor color, bool battlecb = false); void installNewBattleInterface(std::shared_ptr battleInterface, PlayerColor color, bool needCallback = true); diff --git a/client/ClientCommandManager.cpp b/client/ClientCommandManager.cpp index 23f23e4f4..c2c2fa461 100644 --- a/client/ClientCommandManager.cpp +++ b/client/ClientCommandManager.cpp @@ -94,7 +94,7 @@ void ClientCommandManager::handleGoSoloCommand() { if(elem.second.human) { - auto AiToGive = CSH->client->aiNameForPlayer(*CSH->client->getPlayerSettings(elem.first), false); + auto AiToGive = CSH->client->aiNameForPlayer(*CSH->client->getPlayerSettings(elem.first), false, false); printCommandMessage("Player " + elem.first.getStr() + " will be lead by " + AiToGive, ELogLevel::INFO); CSH->client->installNewPlayerInterface(CDynLibHandler::getNewAI(AiToGive), elem.first); } diff --git a/launcher/firstLaunch/firstlaunch_moc.cpp b/launcher/firstLaunch/firstlaunch_moc.cpp index 2836cf41f..8f1d43ecd 100644 --- a/launcher/firstLaunch/firstlaunch_moc.cpp +++ b/launcher/firstLaunch/firstlaunch_moc.cpp @@ -107,13 +107,9 @@ void FirstLaunchView::enterSetup() void FirstLaunchView::setSetupProgress(int progress) { - int value = std::max(progress, ui->setupProgressBar->value()); - - ui->setupProgressBar->setValue(value); - - ui->buttonTabLanguage->setDisabled(value < 1); - ui->buttonTabHeroesData->setDisabled(value < 2); - ui->buttonTabModPreset->setDisabled(value < 3); + ui->buttonTabLanguage->setDisabled(progress < 1); + ui->buttonTabHeroesData->setDisabled(progress < 2); + ui->buttonTabModPreset->setDisabled(progress < 3); } void FirstLaunchView::activateTabLanguage() diff --git a/launcher/firstLaunch/firstlaunch_moc.ui b/launcher/firstLaunch/firstlaunch_moc.ui index 7664d50c3..0e39e72cd 100644 --- a/launcher/firstLaunch/firstlaunch_moc.ui +++ b/launcher/firstLaunch/firstlaunch_moc.ui @@ -93,25 +93,6 @@ - - - - 0 - - - 3 - - - 0 - - - true - - - Step %v out of %m - - - diff --git a/lib/StartInfo.cpp b/lib/StartInfo.cpp index 5d8f8220f..c722c80d5 100644 --- a/lib/StartInfo.cpp +++ b/lib/StartInfo.cpp @@ -22,7 +22,7 @@ VCMI_LIB_NAMESPACE_BEGIN PlayerSettings::PlayerSettings() - : bonus(RANDOM), castle(NONE), hero(RANDOM), heroPortrait(RANDOM), color(0), handicap(NO_HANDICAP), team(0), compOnly(false) + : bonus(RANDOM), castle(NONE), hero(RANDOM), heroPortrait(RANDOM), color(0), handicap(NO_HANDICAP), compOnly(false) { } diff --git a/lib/StartInfo.h b/lib/StartInfo.h index c36b1ee02..495892d82 100644 --- a/lib/StartInfo.h +++ b/lib/StartInfo.h @@ -43,7 +43,6 @@ struct DLL_LINKAGE PlayerSettings PlayerColor color; //from 0 - enum EHandicap {NO_HANDICAP, MILD, SEVERE}; EHandicap handicap;//0-no, 1-mild, 2-severe - TeamID team; std::string name; std::set connectedPlayerIDs; //Empty - AI, or connectrd player ids @@ -60,7 +59,6 @@ struct DLL_LINKAGE PlayerSettings h & handicap; h & name; h & connectedPlayerIDs; - h & team; h & compOnly; } diff --git a/lib/gameState/CGameState.cpp b/lib/gameState/CGameState.cpp index 796182010..52c0ebc53 100644 --- a/lib/gameState/CGameState.cpp +++ b/lib/gameState/CGameState.cpp @@ -658,7 +658,6 @@ void CGameState::initNewGame(const IMapService * mapService, bool allowSavingRan { PlayerSettings & playerSettings = scenarioOps->playerInfos[PlayerColor(i)]; playerSettings.compOnly = !playerInfo.canHumanPlay; - playerSettings.team = playerInfo.team; playerSettings.castle = playerInfo.defaultCastle(); if(playerSettings.isControlledByAI() && playerSettings.name.empty()) {