diff --git a/lib/mapObjects/CRewardableConstructor.cpp b/lib/mapObjects/CRewardableConstructor.cpp index dfd453403..ad01e9874 100644 --- a/lib/mapObjects/CRewardableConstructor.cpp +++ b/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()); } } diff --git a/lib/mapObjects/CommonConstructors.cpp b/lib/mapObjects/CommonConstructors.cpp index 43b7eb5d7..651a586d1 100644 --- a/lib/mapObjects/CommonConstructors.cpp +++ b/lib/mapObjects/CommonConstructors.cpp @@ -338,7 +338,8 @@ CGObjectInstance * MarketInstanceConstructor::create(std::shared_ptrtitle = VLC->generaltexth->translate(title); - market->speech = VLC->generaltexth->translate(speech); + if (!speech.empty()) + market->speech = VLC->generaltexth->translate(speech); return market; } diff --git a/lib/mapping/MapFormatH3M.cpp b/lib/mapping/MapFormatH3M.cpp index 81dbd90fa..d118ff945 100644 --- a/lib/mapping/MapFormatH3M.cpp +++ b/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(); - tmpl->readMap(reader->getInternalReader()); + auto tmpl = reader->readObjectTemplate(); templates.push_back(tmpl); if (!CResourceHandler::get()->existsResource(ResourceID( "SPRITES/" + tmpl->animationFile, EResType::ANIMATION))) diff --git a/lib/mapping/MapIdentifiersH3M.cpp b/lib/mapping/MapIdentifiersH3M.cpp index 5988388b7..6b2453401 100644 --- a/lib/mapping/MapIdentifiersH3M.cpp +++ b/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); diff --git a/lib/mapping/MapReaderH3M.cpp b/lib/mapping/MapReaderH3M.cpp index 42aff1077..c45dd492f 100644 --- a/lib/mapping/MapReaderH3M.cpp +++ b/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 MapReaderH3M::readObjectTemplate() +{ + auto tmpl = std::make_shared(); + tmpl->readMap(*reader); + remapper.remapTemplate(*tmpl); + return tmpl; +} + void MapReaderH3M::skipUnused(size_t amount) { reader->skip(amount); diff --git a/lib/mapping/MapReaderH3M.h b/lib/mapping/MapReaderH3M.h index 11026a79f..ce2827ae6 100644 --- a/lib/mapping/MapReaderH3M.h +++ b/lib/mapping/MapReaderH3M.h @@ -59,6 +59,8 @@ public: int3 readInt3(); + std::shared_ptr readObjectTemplate(); + void skipUnused(size_t amount); void skipZero(size_t amount);