1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Removed remaining usages of std::vector<bool>

This commit is contained in:
Ivan Savenko
2023-11-05 15:24:26 +02:00
parent a9f868b379
commit 0842f5afee
54 changed files with 140 additions and 317 deletions

View File

@@ -389,28 +389,19 @@ RoadType * CMapFormatJson::getRoadByCode(const std::string & code)
void CMapFormatJson::serializeAllowedFactions(JsonSerializeFormat & handler, std::set<FactionID> & value) const
{
//TODO: unify allowed factions with others - make them std::vector<bool>
std::vector<bool> temp;
temp.resize(VLC->townh->size(), false);
auto standard = VLC->townh->getDefaultAllowed();
std::set<FactionID> temp;
if(handler.saving)
{
for(auto faction : VLC->townh->objects)
if(faction->town && vstd::contains(value, faction->getId()))
temp[static_cast<std::size_t>(faction->getIndex())] = true;
temp.insert(faction->getId());
}
handler.serializeLIC("allowedFactions", &FactionID::decode, &FactionID::encode, standard, temp);
handler.serializeLIC("allowedFactions", &FactionID::decode, &FactionID::encode, VLC->townh->getDefaultAllowed(), temp);
if(!handler.saving)
{
value.clear();
for (std::size_t i=0; i<temp.size(); i++)
if(temp[i])
value.insert(static_cast<FactionID>(i));
}
value = temp;
}
void CMapFormatJson::serializeHeader(JsonSerializeFormat & handler)