mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Code review
This commit is contained in:
parent
b9c4a56360
commit
37d9e862c2
@ -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",
|
||||
|
@ -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;
|
||||
|
@ -380,13 +380,9 @@ void ApplyOnServerNetPackVisitor::visitLobbyPvPAction(LobbyPvPAction & pack)
|
||||
{
|
||||
std::vector<FactionID> 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<FactionID> randomFaction1;
|
||||
std::sample(allowedTowns.begin(), allowedTowns.end(), std::back_inserter(randomFaction1), 1, std::mt19937{std::random_device{}()});
|
||||
|
Loading…
Reference in New Issue
Block a user