mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	Fix map object appearance serialization
This commit is contained in:
		| @@ -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); | ||||
|   | ||||
| @@ -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; | ||||
|   | ||||
| @@ -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() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user