|
@@ -495,38 +495,34 @@ void CTownHandler::addBonusesForVanilaBuilding(CBuilding * building) const
|
|
|
std::shared_ptr<Bonus> b;
|
|
|
static TPropagatorPtr playerPropagator = std::make_shared<CPropagatorNodeType>(CBonusSystemNode::ENodeTypes::PLAYER);
|
|
|
|
|
|
- if(building->subId == BuildingSubID::NONE)
|
|
|
+ if(building->bid == BuildingID::TAVERN)
|
|
|
{
|
|
|
- if(building->bid == BuildingID::TAVERN)
|
|
|
- {
|
|
|
- b = createBonus(building, Bonus::MORALE, +1);
|
|
|
- }
|
|
|
+ b = createBonus(building, Bonus::MORALE, +1);
|
|
|
}
|
|
|
- else
|
|
|
+
|
|
|
+ switch(building->subId)
|
|
|
{
|
|
|
- switch(building->subId)
|
|
|
- {
|
|
|
- case BuildingSubID::BROTHERHOOD_OF_SWORD:
|
|
|
- b = createBonus(building, Bonus::MORALE, +2);
|
|
|
- building->overrideBids.insert(BuildingID::TAVERN);
|
|
|
- break;
|
|
|
- case BuildingSubID::FOUNTAIN_OF_FORTUNE:
|
|
|
- b = createBonus(building, Bonus::LUCK, +2);
|
|
|
- break;
|
|
|
- case BuildingSubID::SPELL_POWER_GARRISON_BONUS:
|
|
|
- b = createBonus(building, Bonus::PRIMARY_SKILL, +2, PrimarySkill::SPELL_POWER);
|
|
|
- break;
|
|
|
- case BuildingSubID::ATTACK_GARRISON_BONUS:
|
|
|
- b = createBonus(building, Bonus::PRIMARY_SKILL, +2, PrimarySkill::ATTACK);
|
|
|
- break;
|
|
|
- case BuildingSubID::DEFENSE_GARRISON_BONUS:
|
|
|
- b = createBonus(building, Bonus::PRIMARY_SKILL, +2, PrimarySkill::DEFENSE);
|
|
|
- break;
|
|
|
- case BuildingSubID::LIGHTHOUSE:
|
|
|
- b = createBonus(building, Bonus::MOVEMENT, +500, playerPropagator, 0);
|
|
|
- break;
|
|
|
- }
|
|
|
+ case BuildingSubID::BROTHERHOOD_OF_SWORD:
|
|
|
+ b = createBonus(building, Bonus::MORALE, +2);
|
|
|
+ building->overrideBids.insert(BuildingID::TAVERN);
|
|
|
+ break;
|
|
|
+ case BuildingSubID::FOUNTAIN_OF_FORTUNE:
|
|
|
+ b = createBonus(building, Bonus::LUCK, +2);
|
|
|
+ break;
|
|
|
+ case BuildingSubID::SPELL_POWER_GARRISON_BONUS:
|
|
|
+ b = createBonus(building, Bonus::PRIMARY_SKILL, +2, PrimarySkill::SPELL_POWER);
|
|
|
+ break;
|
|
|
+ case BuildingSubID::ATTACK_GARRISON_BONUS:
|
|
|
+ b = createBonus(building, Bonus::PRIMARY_SKILL, +2, PrimarySkill::ATTACK);
|
|
|
+ break;
|
|
|
+ case BuildingSubID::DEFENSE_GARRISON_BONUS:
|
|
|
+ b = createBonus(building, Bonus::PRIMARY_SKILL, +2, PrimarySkill::DEFENSE);
|
|
|
+ break;
|
|
|
+ case BuildingSubID::LIGHTHOUSE:
|
|
|
+ b = createBonus(building, Bonus::MOVEMENT, +500, playerPropagator, 0);
|
|
|
+ break;
|
|
|
}
|
|
|
+
|
|
|
if(b)
|
|
|
building->addNewBonus(b, building->buildingBonuses);
|
|
|
}
|
|
@@ -584,22 +580,20 @@ void CTownHandler::loadBuilding(CTown * town, const std::string & stringID, cons
|
|
|
auto * ret = new CBuilding();
|
|
|
ret->bid = getMappedValue<BuildingID, std::string>(stringID, BuildingID::NONE, MappedKeys::BUILDING_NAMES_TO_TYPES, false);
|
|
|
|
|
|
- if(ret->bid == BuildingID::NONE)
|
|
|
+ if(ret->bid == BuildingID::NONE && !source["id"].isNull())
|
|
|
+ {
|
|
|
+ logMod->warn("Building %s: id field is deprecated", stringID);
|
|
|
ret->bid = source["id"].isNull() ? BuildingID(BuildingID::NONE) : BuildingID(source["id"].Float());
|
|
|
+ }
|
|
|
|
|
|
if (ret->bid == BuildingID::NONE)
|
|
|
- logMod->error("Error: Building '%s' has not internal ID and won't work properly. Correct the typo or update VCMI.", stringID);
|
|
|
+ logMod->error("Building '%s' isn't recognized and won't work properly. Correct the typo or update VCMI.", stringID);
|
|
|
|
|
|
ret->mode = ret->bid == BuildingID::GRAIL
|
|
|
? CBuilding::BUILD_GRAIL
|
|
|
: getMappedValue<CBuilding::EBuildMode>(source["mode"], CBuilding::BUILD_NORMAL, CBuilding::MODES);
|
|
|
|
|
|
- ret->subId = getMappedValue<BuildingSubID::EBuildingSubID>(source["type"], BuildingSubID::NONE, MappedKeys::SPECIAL_BUILDINGS);
|
|
|
- ret->height = CBuilding::HEIGHT_NO_TOWER;
|
|
|
-
|
|
|
- if(ret->subId == BuildingSubID::LOOKOUT_TOWER
|
|
|
- || ret->bid == BuildingID::GRAIL)
|
|
|
- ret->height = getMappedValue<CBuilding::ETowerHeight>(source["height"], CBuilding::HEIGHT_NO_TOWER, CBuilding::TOWER_TYPES);
|
|
|
+ ret->height = getMappedValue<CBuilding::ETowerHeight>(source["height"], CBuilding::HEIGHT_NO_TOWER, CBuilding::TOWER_TYPES);
|
|
|
|
|
|
ret->identifier = stringID;
|
|
|
ret->modScope = source.meta;
|
|
@@ -618,7 +612,10 @@ void CTownHandler::loadBuilding(CTown * town, const std::string & stringID, cons
|
|
|
loadSpecialBuildingBonuses(source["bonuses"], ret->buildingBonuses, ret);
|
|
|
|
|
|
if(ret->buildingBonuses.empty())
|
|
|
+ {
|
|
|
+ ret->subId = getMappedValue<BuildingSubID::EBuildingSubID>(source["type"], BuildingSubID::NONE, MappedKeys::SPECIAL_BUILDINGS);
|
|
|
addBonusesForVanilaBuilding(ret);
|
|
|
+ }
|
|
|
|
|
|
loadSpecialBuildingBonuses(source["onVisitBonuses"], ret->onVisitBonuses, ret);
|
|
|
|
|
@@ -687,11 +684,12 @@ void CTownHandler::loadBuilding(CTown * town, const std::string & stringID, cons
|
|
|
|
|
|
void CTownHandler::loadBuildings(CTown * town, const JsonNode & source)
|
|
|
{
|
|
|
- for(const auto & node : source.Struct())
|
|
|
+ if(source.isStruct())
|
|
|
{
|
|
|
- if (!node.second.isNull())
|
|
|
+ for(const auto & node : source.Struct())
|
|
|
{
|
|
|
- loadBuilding(town, node.first, node.second);
|
|
|
+ if (!node.second.isNull())
|
|
|
+ loadBuilding(town, node.first, node.second);
|
|
|
}
|
|
|
}
|
|
|
}
|