mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-28 08:48:48 +02:00
get rid of building id
This commit is contained in:
parent
cc4277748d
commit
3df0ce229e
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -604,16 +604,43 @@ namespace MappedKeys
|
||||
{ "special2", BuildingID::SPECIAL_2 },
|
||||
{ "special3", BuildingID::SPECIAL_3 },
|
||||
{ "special4", BuildingID::SPECIAL_4 },
|
||||
{ "grail", BuildingID::GRAIL }
|
||||
};
|
||||
|
||||
static const std::map<BuildingID, std::string> BUILDING_TYPES_TO_NAMES =
|
||||
{
|
||||
{ BuildingID::SPECIAL_1, "special1", },
|
||||
{ BuildingID::SPECIAL_2, "special2" },
|
||||
{ BuildingID::SPECIAL_3, "special3" },
|
||||
{ BuildingID::SPECIAL_4, "special4" },
|
||||
{ BuildingID::GRAIL, "grail"}
|
||||
{ "grail", BuildingID::GRAIL },
|
||||
{ "mageGuild1", BuildingID::MAGES_GUILD_1 },
|
||||
{ "mageGuild2", BuildingID::MAGES_GUILD_2 },
|
||||
{ "mageGuild3", BuildingID::MAGES_GUILD_3 },
|
||||
{ "mageGuild4", BuildingID::MAGES_GUILD_4 },
|
||||
{ "mageGuild5", BuildingID::MAGES_GUILD_5 },
|
||||
{ "tavern", BuildingID::TAVERN },
|
||||
{ "shipyard", BuildingID::SHIPYARD },
|
||||
{ "fort", BuildingID::FORT },
|
||||
{ "citadel", BuildingID::CITADEL },
|
||||
{ "castle", BuildingID::CASTLE },
|
||||
{ "villageHall", BuildingID::VILLAGE_HALL },
|
||||
{ "townHall", BuildingID::TOWN_HALL },
|
||||
{ "cityHall", BuildingID::CITY_HALL },
|
||||
{ "capitol", BuildingID::CAPITOL },
|
||||
{ "marketplace", BuildingID::MARKETPLACE },
|
||||
{ "resourceSilo", BuildingID::RESOURCE_SILO },
|
||||
{ "blacksmith", BuildingID::BLACKSMITH },
|
||||
{ "horde1", BuildingID::HORDE_1 },
|
||||
{ "horde1Upgr", BuildingID::HORDE_1_UPGR },
|
||||
{ "horde2", BuildingID::HORDE_2 },
|
||||
{ "horde2Upgr", BuildingID::HORDE_2_UPGR },
|
||||
{ "ship", BuildingID::SHIP },
|
||||
{ "dwellingLvl1", BuildingID::DWELL_LVL_1 },
|
||||
{ "dwellingLvl2", BuildingID::DWELL_LVL_2 },
|
||||
{ "dwellingLvl3", BuildingID::DWELL_LVL_3 },
|
||||
{ "dwellingLvl4", BuildingID::DWELL_LVL_4 },
|
||||
{ "dwellingLvl5", BuildingID::DWELL_LVL_5 },
|
||||
{ "dwellingLvl6", BuildingID::DWELL_LVL_6 },
|
||||
{ "dwellingLvl7", BuildingID::DWELL_LVL_7 },
|
||||
{ "dwellingUpLvl1", BuildingID::DWELL_LVL_1_UP },
|
||||
{ "dwellingUpLvl2", BuildingID::DWELL_LVL_2_UP },
|
||||
{ "dwellingUpLvl3", BuildingID::DWELL_LVL_3_UP },
|
||||
{ "dwellingUpLvl4", BuildingID::DWELL_LVL_4_UP },
|
||||
{ "dwellingUpLvl5", BuildingID::DWELL_LVL_5_UP },
|
||||
{ "dwellingUpLvl6", BuildingID::DWELL_LVL_6_UP },
|
||||
{ "dwellingUpLvl7", BuildingID::DWELL_LVL_7_UP },
|
||||
};
|
||||
|
||||
static const std::map<std::string, BuildingSubID::EBuildingSubID> SPECIAL_BUILDINGS =
|
||||
|
Loading…
Reference in New Issue
Block a user