1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-26 22:57:00 +02:00

CGCreature serialization. Added rewardResources.

This commit is contained in:
AlexVinS 2016-02-04 08:44:46 +03:00
parent 1bc41b3ba3
commit a6c719ee11

View File

@ -613,6 +613,12 @@ void CGCreature::writeJsonOptions(JsonNode& json) const
json["neverFlees"].Bool() = neverFlees;
json["rewardMessage"].String() = message;
json["rewardArtifact"].String() = (gainedArtifact == ArtifactID(ArtifactID::NONE) ? "" : gainedArtifact.toArtifact()->identifier);
if(resources.nonZero())
{
for(size_t idx = 0; idx < resources.size(); idx++)
json["rewardResources"][GameConstants::RESOURCE_NAMES[idx]].Float() = resources[idx];
}
}
void CGCreature::readJsonOptions(const JsonNode& json)
@ -637,6 +643,9 @@ void CGCreature::readJsonOptions(const JsonNode& json)
if(artid)
gainedArtifact = ArtifactID(artid.get());
}
TResources tmp(json["rewardResources"]);
std::swap(tmp,resources);
}
//CGMine