mirror of
https://github.com/vcmi/vcmi.git
synced 2025-12-07 23:33:15 +02:00
Replace bonus string description with metastring that can properly
handle translations
This commit is contained in:
@@ -575,20 +575,9 @@ std::shared_ptr<Bonus> CTownHandler::createBonus(CBuilding * build, BonusType ty
|
||||
|
||||
std::shared_ptr<Bonus> CTownHandler::createBonus(CBuilding * build, BonusType type, int val, BonusSubtypeID subtype, const TPropagatorPtr & prop) const
|
||||
{
|
||||
std::ostringstream descr;
|
||||
descr << build->getNameTranslated();
|
||||
return createBonusImpl(build->bid, build->town->faction->getId(), type, val, prop, descr.str(), subtype);
|
||||
}
|
||||
auto b = std::make_shared<Bonus>(BonusDuration::PERMANENT, type, BonusSource::TOWN_STRUCTURE, val, build->getUniqueTypeID(), subtype);
|
||||
|
||||
std::shared_ptr<Bonus> CTownHandler::createBonusImpl(const BuildingID & building,
|
||||
const FactionID & faction,
|
||||
BonusType type,
|
||||
int val,
|
||||
const TPropagatorPtr & prop,
|
||||
const std::string & description,
|
||||
BonusSubtypeID subtype) const
|
||||
{
|
||||
auto b = std::make_shared<Bonus>(BonusDuration::PERMANENT, type, BonusSource::TOWN_STRUCTURE, val, BuildingTypeUniqueID(faction, building), subtype, description);
|
||||
b->description.appendTextID(build->getNameTextID());
|
||||
|
||||
if(prop)
|
||||
b->addPropagator(prop);
|
||||
@@ -600,12 +589,13 @@ void CTownHandler::loadSpecialBuildingBonuses(const JsonNode & source, BonusList
|
||||
{
|
||||
for(const auto & b : source.Vector())
|
||||
{
|
||||
auto bonus = JsonUtils::parseBuildingBonus(b, building->town->faction->getId(), building->bid, building->getNameTranslated());
|
||||
auto bonus = std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::NONE, BonusSource::TOWN_STRUCTURE, 0, BonusSourceID(building->getUniqueTypeID()));
|
||||
|
||||
if(bonus == nullptr)
|
||||
if(!JsonUtils::parseBonus(b, bonus.get()))
|
||||
continue;
|
||||
|
||||
bonus->sid = BonusSourceID(building->getUniqueTypeID());
|
||||
bonus->description.appendTextID(building->getNameTextID());
|
||||
|
||||
//JsonUtils::parseBuildingBonus produces UNKNOWN type propagator instead of empty.
|
||||
if(bonus->propagator != nullptr
|
||||
&& bonus->propagator->getPropagatorType() == CBonusSystemNode::ENodeTypes::UNKNOWN)
|
||||
|
||||
Reference in New Issue
Block a user