From a22de743237250c999d91b8d8d77b43fb4ce5546 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Thu, 10 Oct 2024 09:50:56 +0000 Subject: [PATCH] Fixes for loading 1.5 mods in vcmi 1.6 --- lib/entities/faction/CTownHandler.cpp | 4 ++-- lib/mapObjectConstructors/CObjectClassesHandler.cpp | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/entities/faction/CTownHandler.cpp b/lib/entities/faction/CTownHandler.cpp index 3ed640afc..09a99ed71 100644 --- a/lib/entities/faction/CTownHandler.cpp +++ b/lib/entities/faction/CTownHandler.cpp @@ -883,8 +883,8 @@ void CTownHandler::beforeValidate(JsonNode & object) if (building.second.Struct().count("onVisitBonuses")) { building.second["configuration"]["visitMode"] = JsonNode("bonus"); - building.second["configuration"]["visitMode"]["rewards"][0]["message"] = building.second["description"]; - building.second["configuration"]["visitMode"]["rewards"][0]["bonuses"] = building.second["onVisitBonuses"]; + building.second["configuration"]["rewards"][0]["message"] = building.second["description"]; + building.second["configuration"]["rewards"][0]["bonuses"] = building.second["onVisitBonuses"]; } } } diff --git a/lib/mapObjectConstructors/CObjectClassesHandler.cpp b/lib/mapObjectConstructors/CObjectClassesHandler.cpp index de28a4a0f..f8939be58 100644 --- a/lib/mapObjectConstructors/CObjectClassesHandler.cpp +++ b/lib/mapObjectConstructors/CObjectClassesHandler.cpp @@ -207,8 +207,13 @@ TObjectTypeHandler CObjectClassesHandler::loadSubObjectFromJson(const std::strin // Compatibility with 1.5 mods for 1.6. To be removed in 1.7 // Detect banks that use old format and load them using old bank hander - if (baseObject->id == Obj::CREATURE_BANK && entry.Struct().count("levels") && !entry.Struct().count("rewards")) - handler = "bank"; + if (baseObject->id == Obj::CREATURE_BANK) + { + if (entry.Struct().count("levels") && !entry.Struct().count("rewards")) + handler = "bank"; + else + handler = "configurable"; + } auto createdObject = handlerConstructors.at(handler)();