1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-23 00:28:08 +02:00

* WIP on event condition format

* Hero portrait serialization
* Fix town spells serialization

* Added support for float exponential part in Json
* Added support for int64 in Json
* Added basic Hero definitions serialization
* Added rumors serialization
* Advanced player info serialization.
* Added Disposed heroes serialization, (!) not covered with tests yet
* Added Local event serialization
* Added Pandoras box serialization
* Added Seer hut reward serialization
* Added CQuest serialization
* Added API for map object instance names serialization.
* Added random dwelling options serialization
* Advanced town options serialization
* Advanced hero options serialization
* More map format tests
* A lot of fixes, cleanup and refactoring
This commit is contained in:
AlexVinS
2016-11-13 13:38:42 +03:00
parent 5127061e28
commit a85b4cf2a5
70 changed files with 18728 additions and 687 deletions

View File

@ -12,6 +12,7 @@
#include "ResourceSet.h"
#include "StringConstants.h"
#include "JsonNode.h"
#include "serializer/JsonSerializeFormat.h"
Res::ResourceSet::ResourceSet()
{
@ -25,6 +26,19 @@ Res::ResourceSet::ResourceSet(const JsonNode & node)
push_back(node[name].Float());
}
void Res::ResourceSet::serializeJson(JsonSerializeFormat & handler, const std::string & fieldName)
{
if(!handler.saving)
resize(GameConstants::RESOURCE_QUANTITY, 0);
if(handler.saving && !nonZero())
return;
auto s = handler.enterStruct(fieldName);
//TODO: add proper support for mithril to map format
for(int idx = 0; idx < GameConstants::RESOURCE_QUANTITY - 1; idx ++)
handler.serializeInt(GameConstants::RESOURCE_NAMES[idx], this->operator[](idx), 0);
}
bool Res::ResourceSet::nonZero() const
{
for(auto & elem : *this)