mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-26 22:57:00 +02:00
Fix map object appearance serialization
This commit is contained in:
parent
0de1a37d65
commit
8e3e574900
@ -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
|
/// Human-readable name of this object, used for objects like banks and dwellings, if set
|
||||||
boost::optional<std::string> objectName;
|
boost::optional<std::string> objectName;
|
||||||
|
|
||||||
si32 type;
|
|
||||||
si32 subtype;
|
|
||||||
|
|
||||||
std::string typeName;
|
|
||||||
std::string subTypeName;
|
|
||||||
|
|
||||||
JsonNode base; /// describes base template
|
JsonNode base; /// describes base template
|
||||||
|
|
||||||
std::vector<ObjectTemplate> templates;
|
std::vector<ObjectTemplate> templates;
|
||||||
@ -117,6 +111,12 @@ protected:
|
|||||||
/// initialization for classes that inherit this one
|
/// initialization for classes that inherit this one
|
||||||
virtual void initTypeData(const JsonNode & input);
|
virtual void initTypeData(const JsonNode & input);
|
||||||
public:
|
public:
|
||||||
|
std::string typeName;
|
||||||
|
std::string subTypeName;
|
||||||
|
|
||||||
|
si32 type;
|
||||||
|
si32 subtype;
|
||||||
|
|
||||||
virtual ~AObjectTypeHandler(){}
|
virtual ~AObjectTypeHandler(){}
|
||||||
|
|
||||||
void setType(si32 type, si32 subtype);
|
void setType(si32 type, si32 subtype);
|
||||||
|
@ -779,8 +779,11 @@ void CMapLoaderJson::MapObjectLoader::construct()
|
|||||||
ObjectTemplate appearance;
|
ObjectTemplate appearance;
|
||||||
|
|
||||||
appearance.readJson(configuration["template"], false);
|
appearance.readJson(configuration["template"], false);
|
||||||
|
appearance.id = Obj(handler->type);
|
||||||
|
appearance.subid = handler->subtype;
|
||||||
|
|
||||||
instance = handler->create(appearance);
|
instance = handler->create(appearance);
|
||||||
|
|
||||||
instance->id = ObjectInstanceID(owner->map->objects.size());
|
instance->id = ObjectInstanceID(owner->map->objects.size());
|
||||||
instance->instanceName = jsonKey;
|
instance->instanceName = jsonKey;
|
||||||
instance->pos = pos;
|
instance->pos = pos;
|
||||||
|
@ -116,6 +116,16 @@ void checkEqual(const DisposedHero & actual, const DisposedHero & expected)
|
|||||||
VCMI_CHECK_FIELD_EQUAL(portrait);
|
VCMI_CHECK_FIELD_EQUAL(portrait);
|
||||||
VCMI_CHECK_FIELD_EQUAL(name);
|
VCMI_CHECK_FIELD_EQUAL(name);
|
||||||
VCMI_CHECK_FIELD_EQUAL(players);
|
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)
|
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);
|
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(actualFullID, expectedFullID);
|
||||||
BOOST_CHECK_EQUAL(actual->pos, expected->pos);
|
|
||||||
|
|
||||||
|
VCMI_CHECK_FIELD_EQUAL_P(pos);
|
||||||
|
checkEqual(actual->appearance, expected->appearance);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapComparer::compareObjects()
|
void MapComparer::compareObjects()
|
||||||
|
Loading…
Reference in New Issue
Block a user