Browse Source

Fixed mapping of hota objects

Ivan Savenko 2 years ago
parent
commit
312b703a78

+ 1 - 0
lib/mapObjects/CRewardableConstructor.cpp

@@ -57,6 +57,7 @@ void CRewardableConstructor::configureObject(CGObjectInstance * object, CRandomG
 					rewardInfo.reward.extraComponents.emplace_back(Component::EComponentType::LUCK, 0, bonus.val, 0);
 			}
 		}
+		assert(!rewardableObject->configuration.info.empty());
 	}
 }
 

+ 2 - 1
lib/mapObjects/CommonConstructors.cpp

@@ -338,7 +338,8 @@ CGObjectInstance * MarketInstanceConstructor::create(std::shared_ptr<const Objec
 	if(!title.empty())
 		market->title = VLC->generaltexth->translate(title);
 	
-	market->speech = VLC->generaltexth->translate(speech);
+	if (!speech.empty())
+		market->speech = VLC->generaltexth->translate(speech);
 	
 	return market;
 }

+ 1 - 2
lib/mapping/MapFormatH3M.cpp

@@ -922,8 +922,7 @@ void CMapLoaderH3M::readObjectTemplates()
 	// Read custom defs
 	for(int defID = 0; defID < defAmount; ++defID)
 	{
-		auto tmpl = std::make_shared<ObjectTemplate>();
-		tmpl->readMap(reader->getInternalReader());
+		auto tmpl = reader->readObjectTemplate();
 		templates.push_back(tmpl);
 
 		if (!CResourceHandler::get()->existsResource(ResourceID( "SPRITES/" + tmpl->animationFile, EResType::ANIMATION)))

+ 2 - 2
lib/mapping/MapIdentifiersH3M.cpp

@@ -54,8 +54,8 @@ void MapIdentifiersH3M::loadMapping(const JsonNode & mapping)
 
 	for (auto entryTemplate : mapping["templates"].Struct())
 	{
-		std::string h3mName = entryTemplate.second.String();
-		std::string vcmiName = entryTemplate.first;
+		std::string h3mName = boost::to_lower_copy(entryTemplate.second.String());
+		std::string vcmiName = boost::to_lower_copy(entryTemplate.first);
 
 		if (!CResourceHandler::get()->existsResource(ResourceID( "SPRITES/" + vcmiName, EResType::ANIMATION)))
 			logMod->warn("Template animation file %s was not found!", vcmiName);

+ 9 - 0
lib/mapping/MapReaderH3M.cpp

@@ -13,6 +13,7 @@
 
 #include "../filesystem/CBinaryReader.h"
 #include "../int3.h"
+#include "../mapObjects/ObjectTemplate.h"
 
 VCMI_LIB_NAMESPACE_BEGIN
 
@@ -315,6 +316,14 @@ int3 MapReaderH3M::readInt3()
 	return p;
 }
 
+std::shared_ptr<ObjectTemplate> MapReaderH3M::readObjectTemplate()
+{
+	auto tmpl = std::make_shared<ObjectTemplate>();
+	tmpl->readMap(*reader);
+	remapper.remapTemplate(*tmpl);
+	return tmpl;
+}
+
 void MapReaderH3M::skipUnused(size_t amount)
 {
 	reader->skip(amount);

+ 2 - 0
lib/mapping/MapReaderH3M.h

@@ -59,6 +59,8 @@ public:
 
 	int3 readInt3();
 
+	std::shared_ptr<ObjectTemplate> readObjectTemplate();
+
 	void skipUnused(size_t amount);
 	void skipZero(size_t amount);