From 50dfe05cd1b0899a73e30df96a08c4a6bb53e391 Mon Sep 17 00:00:00 2001 From: AlexVinS Date: Fri, 27 Jun 2014 13:04:47 +0400 Subject: [PATCH 1/2] [C::B] Small projects fix --- client/VCMI_client.cbp | 1 - lib/VCMI_lib.cbp | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/client/VCMI_client.cbp b/client/VCMI_client.cbp index 36d340ee6..488fd2776 100644 --- a/client/VCMI_client.cbp +++ b/client/VCMI_client.cbp @@ -101,7 +101,6 @@ - diff --git a/lib/VCMI_lib.cbp b/lib/VCMI_lib.cbp index a1cdd70e0..83a15af5b 100644 --- a/lib/VCMI_lib.cbp +++ b/lib/VCMI_lib.cbp @@ -108,6 +108,7 @@ + From db221829aab558ee108ecfbea956168b2c82b9ad Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Mon, 30 Jun 2014 17:11:25 +0300 Subject: [PATCH 2/2] Modding-related bugfixes: - hero classes will be loaded correctly - objects without index will have correctly assigned ID's --- lib/CHeroHandler.cpp | 2 +- lib/CModHandler.cpp | 1 + lib/mapObjects/CObjectClassesHandler.cpp | 7 ++++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/CHeroHandler.cpp b/lib/CHeroHandler.cpp index 1a8414dbd..25c43d4a4 100644 --- a/lib/CHeroHandler.cpp +++ b/lib/CHeroHandler.cpp @@ -199,7 +199,7 @@ void CHeroClassHandler::loadObject(std::string scope, std::string name, const Js VLC->modh->identifiers.requestIdentifier(scope, "object", "hero", [=](si32 index) { - JsonNode classConf; + JsonNode classConf = data["mapObject"]; classConf["heroClass"].String() = name; classConf.setMeta(scope); VLC->objtypeh->loadSubObject(name, classConf, index, object->id); diff --git a/lib/CModHandler.cpp b/lib/CModHandler.cpp index 9cd4b8072..9f5422566 100644 --- a/lib/CModHandler.cpp +++ b/lib/CModHandler.cpp @@ -310,6 +310,7 @@ bool CContentHandler::ContentTypeHandler::preloadModData(std::string modName, st if (remoteName == modName) logGlobal->warnStream() << "Redundant namespace definition for " << objectName; + logGlobal->traceStream() << "Patching object " << objectName << " (" << remoteName << ") from " << modName; JsonNode & remoteConf = modData[remoteName].patches[objectName]; JsonUtils::merge(remoteConf, entry.second); diff --git a/lib/mapObjects/CObjectClassesHandler.cpp b/lib/mapObjects/CObjectClassesHandler.cpp index 1e1ccc4f5..8c276e05a 100644 --- a/lib/mapObjects/CObjectClassesHandler.cpp +++ b/lib/mapObjects/CObjectClassesHandler.cpp @@ -140,7 +140,7 @@ si32 selectNextID(const JsonNode & fixedID, const Map & map, si32 defaultID) if (map.empty()) return defaultID; // no objects loaded, keep gap for H3M objects - if (map.rbegin()->first > defaultID) + if (map.rbegin()->first >= defaultID) return map.rbegin()->first + 1; // some modded objects loaded, return next available return defaultID; // some H3M objects loaded, first modded found @@ -172,9 +172,10 @@ void CObjectClassesHandler::loadObjectEntry(const JsonNode & entry, ObjectContai } legacyTemplates.erase(range.first, range.second); } - - obj->objects[id] = handler; + logGlobal->debugStream() << "Loaded object " << obj->id << ":" << id; + assert(!obj->objects.count(id)); // DO NOT override + obj->objects[id] = handler; } CObjectClassesHandler::ObjectContainter * CObjectClassesHandler::loadFromJson(const JsonNode & json)