From 53dc49e92ac2a4db60df231a2f3de28a36eb63d2 Mon Sep 17 00:00:00 2001 From: AlexVinS Date: Tue, 9 Feb 2016 09:17:20 +0300 Subject: [PATCH] CGShipyard, CGShrine serialization --- lib/mapObjects/CObjectHandler.cpp | 10 ---------- lib/mapObjects/MiscObjects.cpp | 19 +++++++++++++------ 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/lib/mapObjects/CObjectHandler.cpp b/lib/mapObjects/CObjectHandler.cpp index 045b24366..1d7895724 100644 --- a/lib/mapObjects/CObjectHandler.cpp +++ b/lib/mapObjects/CObjectHandler.cpp @@ -367,20 +367,10 @@ void CGObjectInstance::readJson(const JsonNode & json) void CGObjectInstance::writeJsonOptions(JsonNode & json) const { json.setType(JsonNode::DATA_STRUCT); - -// //todo: move up to descendants -// if(tempOwner != PlayerColor::UNFLAGGABLE) -// { -// PlayerColor p (tempOwner); -// if(p.isValidPlayer()) -// json["owner"].String() = GameConstants::PLAYER_COLOR_NAMES[p.getNum()]; -// } } void CGObjectInstance::readJsonOptions(const JsonNode & json) { -// if(json["owner"].getType() == JsonNode::DATA_STRING) -// tempOwner = PlayerColor(vstd::find_pos(GameConstants::PLAYER_COLOR_NAMES, json["owner"].String())); } void CGObjectInstance::writeOwner(JsonNode & json) const diff --git a/lib/mapObjects/MiscObjects.cpp b/lib/mapObjects/MiscObjects.cpp index 1cf689c64..c8550183b 100644 --- a/lib/mapObjects/MiscObjects.cpp +++ b/lib/mapObjects/MiscObjects.cpp @@ -1660,15 +1660,23 @@ std::string CGShrine::getHoverText(const CGHeroInstance * hero) const void CGShrine::writeJsonOptions(JsonNode& json) const { - + if(spell != SpellID::NONE) + { + json["spell"].String() = spell.toSpell()->identifier; + } } void CGShrine::readJsonOptions(const JsonNode& json) { - + spell = SpellID::NONE; + if(json["spell"].String() != "") + { + auto raw = VLC->modh->identifiers.getIdentifier("core", "spell",json["spell"].String()); + if(raw) + spell = SpellID(raw.get()); + } } - void CGSignBottle::initObj() { //if no text is set than we pick random from the predefined ones @@ -2017,15 +2025,14 @@ void CGShipyard::onHeroVisit( const CGHeroInstance * h ) const void CGShipyard::writeJsonOptions(JsonNode& json) const { - + CGObjectInstance::writeOwner(json); } void CGShipyard::readJsonOptions(const JsonNode& json) { - + CGObjectInstance::readOwner(json); } - void CCartographer::onHeroVisit( const CGHeroInstance * h ) const { //if player has not bought map of this subtype yet and underground exist for stalagmite cartographer