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

Fix map object appearance serialization

This commit is contained in:
AlexVinS 2016-02-26 02:03:14 +03:00
parent 0de1a37d65
commit 8e3e574900
3 changed files with 21 additions and 7 deletions

View File

@ -101,12 +101,6 @@ class DLL_LINKAGE AObjectTypeHandler : public boost::noncopyable
/// Human-readable name of this object, used for objects like banks and dwellings, if set
boost::optional<std::string> objectName;
si32 type;
si32 subtype;
std::string typeName;
std::string subTypeName;
JsonNode base; /// describes base template
std::vector<ObjectTemplate> templates;
@ -117,6 +111,12 @@ protected:
/// initialization for classes that inherit this one
virtual void initTypeData(const JsonNode & input);
public:
std::string typeName;
std::string subTypeName;
si32 type;
si32 subtype;
virtual ~AObjectTypeHandler(){}
void setType(si32 type, si32 subtype);

View File

@ -779,8 +779,11 @@ void CMapLoaderJson::MapObjectLoader::construct()
ObjectTemplate appearance;
appearance.readJson(configuration["template"], false);
appearance.id = Obj(handler->type);
appearance.subid = handler->subtype;
instance = handler->create(appearance);
instance->id = ObjectInstanceID(owner->map->objects.size());
instance->instanceName = jsonKey;
instance->pos = pos;

View File

@ -116,6 +116,16 @@ void checkEqual(const DisposedHero & actual, const DisposedHero & expected)
VCMI_CHECK_FIELD_EQUAL(portrait);
VCMI_CHECK_FIELD_EQUAL(name);
VCMI_CHECK_FIELD_EQUAL(players);
}
void checkEqual(const ObjectTemplate & actual, const ObjectTemplate & expected)
{
VCMI_CHECK_FIELD_EQUAL(id);
VCMI_CHECK_FIELD_EQUAL(subid);
VCMI_CHECK_FIELD_EQUAL(printPriority);
VCMI_CHECK_FIELD_EQUAL(animationFile);
//VCMI_CHECK_FIELD_EQUAL(stringID);
}
void checkEqual(const TerrainTile & actual, const TerrainTile & expected)
@ -196,8 +206,9 @@ void MapComparer::compareObject(const CGObjectInstance * actual, const CGObjectI
std::string expectedFullID = boost::to_string(boost::format("%s(%d)|%s(%d) %d") % expected->typeName % expected->ID % expected->subTypeName % expected->subID % expected->tempOwner);
BOOST_CHECK_EQUAL(actualFullID, expectedFullID);
BOOST_CHECK_EQUAL(actual->pos, expected->pos);
VCMI_CHECK_FIELD_EQUAL_P(pos);
checkEqual(actual->appearance, expected->appearance);
}
void MapComparer::compareObjects()