mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
Added hacks for hero identification.
This commit is contained in:
parent
e0af4a665a
commit
709dd833d5
@ -1472,13 +1472,35 @@ bool CGHeroInstance::hasVisions(const CGObjectInstance * target, const int subty
|
||||
|
||||
void CGHeroInstance::writeJsonOptions(JsonNode& json) const
|
||||
{
|
||||
if(type)
|
||||
{
|
||||
json["type"].String() = type->identifier;
|
||||
}
|
||||
else
|
||||
{
|
||||
json["type"].String() = VLC->heroh->heroes[subID]->identifier;
|
||||
}
|
||||
|
||||
CCreatureSet::writeJson(json["army"]);
|
||||
CGObjectInstance::writeOwner(json);
|
||||
CArtifactSet::writeJson(json["artifacts"]);
|
||||
|
||||
}
|
||||
|
||||
void CGHeroInstance::readJsonOptions(const JsonNode& json)
|
||||
{
|
||||
if(ID == Obj::HERO || ID == Obj::PRISON)
|
||||
{
|
||||
auto typeName = json["type"].String();
|
||||
|
||||
auto rawId = VLC->modh->identifiers.getIdentifier("core", "hero", typeName);
|
||||
|
||||
if(rawId)
|
||||
subID = rawId.get();
|
||||
else
|
||||
subID = 0; //fallback to Orrin, throw error instead?
|
||||
}
|
||||
|
||||
CCreatureSet::readJson(json["army"]);
|
||||
CGObjectInstance::readOwner(json);
|
||||
CArtifactSet::readJson(json["artifacts"]);
|
||||
|
Loading…
Reference in New Issue
Block a user