1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-15 00:05:02 +02:00

Advance map header serialization

This commit is contained in:
AlexVinS
2016-02-21 20:58:09 +03:00
parent b6103167f7
commit 53b5587c2e
16 changed files with 230 additions and 75 deletions

View File

@ -192,7 +192,7 @@ std::vector<JsonNode> CHeroClassHandler::loadLegacyData(size_t dataSize)
void CHeroClassHandler::loadObject(std::string scope, std::string name, const JsonNode & data)
{
auto object = loadFromJson(data, name);
auto object = loadFromJson(data, normalizeIdentifier(scope, "core", name));
object->id = heroClasses.size();
heroClasses.push_back(object);
@ -205,19 +205,12 @@ void CHeroClassHandler::loadObject(std::string scope, std::string name, const Js
VLC->objtypeh->loadSubObject(name, classConf, index, object->id);
});
// VLC->modh->identifiers.requestIdentifier(scope, "object", "prison", [=](si32 index)
// {
// JsonNode conf;
// conf.setMeta(scope);
// VLC->objtypeh->loadSubObject(name, conf, index, object->id);
// });
VLC->modh->identifiers.registerObject(scope, "heroClass", name, object->id);
}
void CHeroClassHandler::loadObject(std::string scope, std::string name, const JsonNode & data, size_t index)
{
auto object = loadFromJson(data, name);
auto object = loadFromJson(data, normalizeIdentifier(scope, "core", name));
object->id = index;
assert(heroClasses[index] == nullptr); // ensure that this id was not loaded before
@ -547,7 +540,7 @@ std::vector<JsonNode> CHeroHandler::loadLegacyData(size_t dataSize)
void CHeroHandler::loadObject(std::string scope, std::string name, const JsonNode & data)
{
auto object = loadFromJson(data, name);
auto object = loadFromJson(data, normalizeIdentifier(scope, "core", name));
object->ID = HeroTypeID(heroes.size());
object->imageIndex = heroes.size() + 30; // 2 special frames + some extra portraits
@ -558,7 +551,7 @@ void CHeroHandler::loadObject(std::string scope, std::string name, const JsonNod
void CHeroHandler::loadObject(std::string scope, std::string name, const JsonNode & data, size_t index)
{
auto object = loadFromJson(data, name);
auto object = loadFromJson(data, normalizeIdentifier(scope, "core", name));
object->ID = HeroTypeID(index);
object->imageIndex = index;
@ -618,3 +611,17 @@ std::vector<bool> CHeroHandler::getDefaultAllowedAbilities() const
allowedAbilities.resize(GameConstants::SKILL_QUANTITY, true);
return allowedAbilities;
}
si32 CHeroHandler::decodeSkill(const std::string& identifier)
{
auto rawId = VLC->modh->identifiers.getIdentifier("core", "skill", identifier);
if(rawId)
return rawId.get();
else
return -1;
}
std::string CHeroHandler::encodeSkill(const si32 index)
{
return NSecondarySkill::names[index];
}