Przeglądaj źródła

CGCreature serialization. Added rewardResources.

AlexVinS 9 lat temu
rodzic
commit
a6c719ee11
1 zmienionych plików z 9 dodań i 0 usunięć
  1. 9 0
      lib/mapObjects/MiscObjects.cpp

+ 9 - 0
lib/mapObjects/MiscObjects.cpp

@@ -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