diff --git a/Mods/vcmi/config/vcmi/english.json b/Mods/vcmi/config/vcmi/english.json index f7ded1cae..d539f0c4d 100644 --- a/Mods/vcmi/config/vcmi/english.json +++ b/Mods/vcmi/config/vcmi/english.json @@ -129,9 +129,9 @@ "vcmi.lobby.pvp.coin.hover" : "Coin", "vcmi.lobby.pvp.coin.help" : "Flips a coin", "vcmi.lobby.pvp.randomTown.hover" : "Random town", - "vcmi.lobby.pvp.randomTown.help" : "Write a random city in the chat", + "vcmi.lobby.pvp.randomTown.help" : "Write a random town in the chat", "vcmi.lobby.pvp.randomTownVs.hover" : "Random town vs.", - "vcmi.lobby.pvp.randomTownVs.help" : "Write two random cities in the chat", + "vcmi.lobby.pvp.randomTownVs.help" : "Write two random towns in the chat", "vcmi.lobby.pvp.versus" : "vs.", "vcmi.client.errors.invalidMap" : "{Invalid map or campaign}\n\nFailed to start game! Selected map or campaign might be invalid or corrupted. Reason:\n%s", diff --git a/client/lobby/CSelectionBase.cpp b/client/lobby/CSelectionBase.cpp index a811a4c8c..3851f32e6 100644 --- a/client/lobby/CSelectionBase.cpp +++ b/client/lobby/CSelectionBase.cpp @@ -444,12 +444,11 @@ TownSelector::TownSelector(const Point & loc) setRedrawParent(true); int count = 0; - CGI->factions()->forEach([this, &count](const Faction *entity, bool &stop){ - if(!entity->hasTown()) - return; - townsEnabled[entity->getFaction()] = true; + for(auto const & factionID : VLC->townh->getDefaultAllowed()) + { + townsEnabled[factionID] = true; count++; - }); + }; auto divisionRoundUp = [](int x, int y){ return (x + (y - 1)) / y; }; @@ -472,7 +471,8 @@ void TownSelector::updateListItems() towns.clear(); townsArea.clear(); - int x = 0, y = 0; + int x = 0; + int y = 0; CGI->factions()->forEach([this, &x, &y, line, x_offset](const Faction *entity, bool &stop){ if(!entity->hasTown()) return; diff --git a/server/NetPacksLobbyServer.cpp b/server/NetPacksLobbyServer.cpp index f32d2fe63..89a8bc45e 100644 --- a/server/NetPacksLobbyServer.cpp +++ b/server/NetPacksLobbyServer.cpp @@ -380,13 +380,9 @@ void ApplyOnServerNetPackVisitor::visitLobbyPvPAction(LobbyPvPAction & pack) { std::vector allowedTowns; - VLC->townh->forEach([pack, &allowedTowns](const Faction *entity, bool &stop){ - if(!entity->hasTown()) - return; - if(std::find(pack.bannedTowns.begin(), pack.bannedTowns.end(), entity->getId()) == pack.bannedTowns.end()) { - allowedTowns.push_back(entity->getId()); - } - }); + for (auto const & factionID : VLC->townh->getDefaultAllowed()) + if(std::find(pack.bannedTowns.begin(), pack.bannedTowns.end(), factionID) == pack.bannedTowns.end()) + allowedTowns.push_back(factionID); std::vector randomFaction1; std::sample(allowedTowns.begin(), allowedTowns.end(), std::back_inserter(randomFaction1), 1, std::mt19937{std::random_device{}()});