1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

Serialize tempOwner

This commit is contained in:
AlexVinS 2015-11-15 18:07:15 +03:00
parent 8a979d016f
commit e7359c9a36
2 changed files with 11 additions and 2 deletions

View File

@ -18,6 +18,7 @@
#include "../filesystem/ResourceID.h"
#include "../IGameCallback.h"
#include "../CGameState.h"
#include "../StringConstants.h"
#include "../mapping/CMap.h"
#include "CObjectClassesHandler.h"
@ -363,11 +364,19 @@ void CGObjectInstance::readJson(const JsonNode & json, bool withState)
void CGObjectInstance::writeJsonOptions(JsonNode & json) const
{
json.setType(JsonNode::DATA_STRUCT);
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::writeJsonState(JsonNode & json) const
@ -380,7 +389,6 @@ void CGObjectInstance::readJsonState(const JsonNode & json)
}
CGObjectInstanceBySubIdFinder::CGObjectInstanceBySubIdFinder(CGObjectInstance * obj) : obj(obj)
{

View File

@ -158,6 +158,7 @@ void MapComparer::compareObject(const CGObjectInstance * actual, const CGObjectI
BOOST_CHECK_EQUAL(actualFullID, expectedFullID);
BOOST_CHECK_EQUAL(actual->pos, expected->pos);
BOOST_CHECK_EQUAL(actual->tempOwner,expected->tempOwner);
}
void MapComparer::compareObjects()