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:
@@ -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 "";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user