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

Advance Json serializer

* added bool, numeric and string support
* added some enum support
* PoC implementation of logical id condition
* Refactoring
This commit is contained in:
AlexVinS
2016-02-14 14:22:46 +03:00
parent 67b03b9658
commit ec760632a6
11 changed files with 517 additions and 248 deletions

View File

@@ -526,7 +526,7 @@ void CTownHandler::loadClientData(CTown &town, const JsonNode & source)
info.tavernVideo = source["tavernVideo"].String();
else
info.tavernVideo = "TAVERN.BIK";
//end of legacy assignment
//end of legacy assignment
loadTownHall(town, source["hallSlots"]);
loadStructures(town, source["structures"]);
@@ -795,3 +795,33 @@ std::set<TFaction> CTownHandler::getAllowedFactions(bool withTown /*=true*/) con
return allowedFactions;
}
si32 CTownHandler::decodeFaction(const std::string & identifier)
{
auto rawId = VLC->modh->identifiers.getIdentifier("core", "faction", identifier);
if(rawId)
return rawId.get();
else
return -1;
}
std::string CTownHandler::encodeFaction(const si32 index)
{
return VLC->townh->factions[index]->identifier;
}
si32 CTownHandler::decodeBuilding(const std::string & identifier)
{
//FIXME: CTownHandler::decodeBuilding
auto rawId = VLC->modh->identifiers.getIdentifier("core", "building", identifier); //???
if(rawId)
return rawId.get();
else
return -1;
}
std::string CTownHandler::encodeBuilding(const si32 index)
{
//FIXME: CTownHandler::encodeBuilding
return "";
}