From 06d17f709dd5c09abd78389d19a2bff98d6f96b0 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Mon, 23 Jun 2014 19:37:26 +0300 Subject: [PATCH] fixed compatibility code for resource-granting buildings --- lib/CTownHandler.cpp | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/lib/CTownHandler.cpp b/lib/CTownHandler.cpp index 10c9bc2cd..84ccec8c2 100644 --- a/lib/CTownHandler.cpp +++ b/lib/CTownHandler.cpp @@ -308,33 +308,32 @@ void CTownHandler::loadBuilding(CTown &town, const std::string & stringID, const ret->resources = TResources(source["cost"]); ret->produce = TResources(source["produce"]); - //for compatibility with older town mods + //MODS COMPATIBILITY FOR 0.96 if(!ret->produce.nonZero()) { - if (ret->bid == BuildingID::VILLAGE_HALL) ret->produce[Res::GOLD] = 500; - - if (ret->bid == BuildingID::TOWN_HALL) ret->produce[Res::GOLD] = 1000; - - if (ret->bid == BuildingID::CITY_HALL) ret->produce[Res::GOLD] = 2000; - - if (ret->bid == BuildingID::CAPITOL) ret->produce[Res::GOLD] = 4000; - - if (ret->bid == BuildingID::GRAIL) ret->produce[Res::GOLD] = 5000; - // - if (ret->bid == BuildingID::RESOURCE_SILO) - { - if ((ret->town->primaryRes != Res::WOOD) && (ret->town->primaryRes != Res::ORE) && (ret->town->primaryRes != Res::GOLD)) - ret->produce[ret->town->primaryRes] = 1; - else - { - if (ret->town->primaryRes == Res::GOLD) ret->produce[ret->town->primaryRes] = 500; - else + switch (ret->bid) { + break; case BuildingID::VILLAGE_HALL: ret->produce[Res::GOLD] = 500; + break; case BuildingID::TOWN_HALL : ret->produce[Res::GOLD] = 1000; + break; case BuildingID::CITY_HALL : ret->produce[Res::GOLD] = 2000; + break; case BuildingID::CAPITOL : ret->produce[Res::GOLD] = 4000; + break; case BuildingID::GRAIL : ret->produce[Res::GOLD] = 5000; + break; case BuildingID::RESOURCE_SILO : { - ret->produce[Res::WOOD] = 1; - ret->produce[Res::ORE] = 1; + switch (ret->town->primaryRes) + { + case Res::GOLD: + ret->produce[ret->town->primaryRes] = 500; + break; + case Res::WOOD_AND_ORE: + ret->produce[Res::WOOD] = 1; + ret->produce[Res::ORE] = 1; + break; + default: + ret->produce[ret->town->primaryRes] = 1; + break; + } } } - } } loadBuildingRequirements(town, *ret, source["requires"]);