mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-06 09:09:40 +02:00
Remove usage of ConstTransitivePtr from CTown
This commit is contained in:
@@ -202,7 +202,7 @@ BuildingInfo BuildAnalyzer::getBuildingOrPrerequisite(
|
||||
BuildingID building = toBuild;
|
||||
auto townInfo = town->getTown();
|
||||
|
||||
const CBuilding * buildPtr = townInfo->buildings.at(building);
|
||||
const auto & buildPtr = townInfo->buildings.at(building);
|
||||
const CCreature * creature = nullptr;
|
||||
CreatureID baseCreatureID;
|
||||
|
||||
@@ -234,7 +234,7 @@ BuildingInfo BuildAnalyzer::getBuildingOrPrerequisite(
|
||||
creature = creatureID.toCreature();
|
||||
}
|
||||
|
||||
auto info = BuildingInfo(buildPtr, creature, baseCreatureID, town, ai);
|
||||
auto info = BuildingInfo(buildPtr.get(), creature, baseCreatureID, town, ai);
|
||||
|
||||
//logAi->trace("checking %s buildInfo %s", info.name, info.toString());
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ BuildThis::BuildThis(BuildingID Bid, const CGTownInstance * tid)
|
||||
: ElementarGoal(Goals::BUILD_STRUCTURE)
|
||||
{
|
||||
buildingInfo = BuildingInfo(
|
||||
tid->getTown()->buildings.at(Bid),
|
||||
tid->getTown()->buildings.at(Bid).get(),
|
||||
nullptr,
|
||||
CreatureID::NONE,
|
||||
tid,
|
||||
|
||||
@@ -29,7 +29,7 @@ bool BuildingManager::tryBuildThisStructure(const CGTownInstance * t, BuildingID
|
||||
if (t->hasBuilt(building)) //Already built? Shouldn't happen in general
|
||||
return true;
|
||||
|
||||
const CBuilding * buildPtr = t->getTown()->buildings.at(building);
|
||||
const auto & buildPtr = t->getTown()->buildings.at(building);
|
||||
|
||||
auto toBuild = buildPtr->requirements.getFulfillmentCandidates([&](const BuildingID & buildID)
|
||||
{
|
||||
@@ -51,7 +51,7 @@ bool BuildingManager::tryBuildThisStructure(const CGTownInstance * t, BuildingID
|
||||
|
||||
for (const auto & buildID : toBuild)
|
||||
{
|
||||
const CBuilding * b = t->getTown()->buildings.at(buildID);
|
||||
const auto & b = t->getTown()->buildings.at(buildID);
|
||||
|
||||
EBuildingState canBuild = cb->canBuildStructure(t, buildID);
|
||||
if (canBuild == EBuildingState::ALLOWED)
|
||||
@@ -220,7 +220,7 @@ bool BuildingManager::getBuildingOptions(const CGTownInstance * t)
|
||||
|
||||
//at the end, try to get and build any extra buildings with nonstandard slots (for example HotA 3rd level dwelling)
|
||||
std::vector<BuildingID> extraBuildings;
|
||||
for (auto buildingInfo : t->getTown()->buildings)
|
||||
for (const auto & buildingInfo : t->getTown()->buildings)
|
||||
{
|
||||
if (buildingInfo.first.isDwelling() && BuildingID::getUpgradedFromDwelling(buildingInfo.first) > 1)
|
||||
extraBuildings.push_back(buildingInfo.first);
|
||||
|
||||
@@ -310,7 +310,7 @@ std::string CComponent::getSubtitle() const
|
||||
case ComponentType::BUILDING:
|
||||
{
|
||||
auto index = data.subType.as<BuildingTypeUniqueID>();
|
||||
auto building = (*LIBRARY->townh)[index.getFaction()]->town->buildings[index.getBuilding()];
|
||||
const auto & building = (*LIBRARY->townh)[index.getFaction()]->town->buildings[index.getBuilding()];
|
||||
if(!building)
|
||||
{
|
||||
logGlobal->error("Town of faction %s has no building #%d", (*LIBRARY->townh)[index.getFaction()]->town->faction->getNameTranslated(), index.getBuilding().getNum());
|
||||
|
||||
@@ -112,7 +112,7 @@ const CBuilding * CBuildingRect::getBuilding()
|
||||
return nullptr;
|
||||
|
||||
if (str->hiddenUpgrade) // hidden upgrades, e.g. hordes - return base (dwelling for hordes)
|
||||
return town->getTown()->buildings.at(str->building->getBase());
|
||||
return town->getTown()->buildings.at(str->building->getBase()).get();
|
||||
|
||||
return str->building;
|
||||
}
|
||||
@@ -161,7 +161,7 @@ void CBuildingRect::showPopupWindow(const Point & cursorPosition)
|
||||
return;
|
||||
|
||||
BuildingID bid = getBuilding()->bid;
|
||||
const CBuilding *bld = town->getTown()->buildings.at(bid);
|
||||
const CBuilding *bld = town->getTown()->buildings.at(bid).get();
|
||||
if (!bid.isDwelling())
|
||||
{
|
||||
CRClickPopup::createAndPush(CInfoWindow::genText(bld->getNameTranslated(), bld->getDescriptionTranslated()),
|
||||
@@ -685,22 +685,22 @@ void CCastleBuildings::recreate()
|
||||
}
|
||||
}
|
||||
|
||||
for(const CStructure * structure : town->getTown()->clientInfo.structures)
|
||||
for(const auto & structure : town->getTown()->clientInfo.structures)
|
||||
{
|
||||
if(!structure->building)
|
||||
{
|
||||
buildings.push_back(std::make_shared<CBuildingRect>(this, town, structure));
|
||||
buildings.push_back(std::make_shared<CBuildingRect>(this, town, structure.get()));
|
||||
continue;
|
||||
}
|
||||
if(vstd::contains(buildingsCopy, structure->building->bid))
|
||||
{
|
||||
groups[structure->building->getBase()].push_back(structure);
|
||||
groups[structure->building->getBase()].push_back(structure.get());
|
||||
}
|
||||
}
|
||||
|
||||
for(auto & entry : groups)
|
||||
{
|
||||
const CBuilding * build = town->getTown()->buildings.at(entry.first);
|
||||
const CBuilding * build = town->getTown()->buildings.at(entry.first).get();
|
||||
|
||||
const CStructure * toAdd = *boost::max_element(entry.second, [=](const CStructure * a, const CStructure * b)
|
||||
{
|
||||
@@ -819,7 +819,7 @@ void CCastleBuildings::buildingClicked(BuildingID building)
|
||||
|
||||
for(BuildingID buildingToEnter = building;;)
|
||||
{
|
||||
const CBuilding *b = town->getTown()->buildings.find(buildingToEnter)->second;
|
||||
const auto &b = town->getTown()->buildings.find(buildingToEnter)->second;
|
||||
|
||||
buildingsToTest.push_back(buildingToEnter);
|
||||
if (!b->upgrade.hasValue())
|
||||
@@ -840,7 +840,7 @@ void CCastleBuildings::buildingClicked(BuildingID building)
|
||||
bool CCastleBuildings::buildingTryActivateCustomUI(BuildingID buildingToTest, BuildingID buildingTarget)
|
||||
{
|
||||
logGlobal->trace("You've clicked on %d", (int)buildingToTest.toEnum());
|
||||
const CBuilding *b = town->getTown()->buildings.at(buildingToTest);
|
||||
const auto & b = town->getTown()->buildings.at(buildingToTest);
|
||||
|
||||
if (town->getWarMachineInBuilding(buildingToTest).hasValue())
|
||||
{
|
||||
@@ -1382,7 +1382,7 @@ CTownInfo::CTownInfo(int posX, int posY, const CGTownInstance * Town, bool townH
|
||||
return;//FIXME: suspicious statement, fix or comment
|
||||
picture = std::make_shared<CAnimImage>(AnimationPath::builtin("ITMCL.DEF"), town->fortLevel()-1);
|
||||
}
|
||||
building = town->getTown()->buildings.at(BuildingID(buildID));
|
||||
building = town->getTown()->buildings.at(BuildingID(buildID)).get();
|
||||
pos = picture->pos;
|
||||
}
|
||||
|
||||
@@ -1737,7 +1737,7 @@ CHallInterface::CHallInterface(const CGTownInstance * Town):
|
||||
continue;
|
||||
}
|
||||
|
||||
const CBuilding * current = town->getTown()->buildings.at(buildingID);
|
||||
const CBuilding * current = town->getTown()->buildings.at(buildingID).get();
|
||||
if(town->hasBuilt(buildingID))
|
||||
{
|
||||
building = current;
|
||||
@@ -1922,7 +1922,7 @@ CFortScreen::CFortScreen(const CGTownInstance * town):
|
||||
fortSize--;
|
||||
fortSize = std::min(fortSize, static_cast<ui32>(GameConstants::CREATURES_PER_TOWN)); // for 8 creatures + portal of summoning
|
||||
|
||||
const CBuilding * fortBuilding = town->getTown()->buildings.at(BuildingID(town->fortLevel()+6));
|
||||
const auto & fortBuilding = town->getTown()->buildings.at(BuildingID(town->fortLevel()+6));
|
||||
title = std::make_shared<CLabel>(400, 12, FONT_BIG, ETextAlignment::CENTER, Colors::WHITE, fortBuilding->getNameTranslated());
|
||||
|
||||
std::string text = boost::str(boost::format(LIBRARY->generaltexth->fcommands[6]) % fortBuilding->getNameTranslated());
|
||||
@@ -2067,11 +2067,11 @@ const CBuilding * CFortScreen::RecruitArea::getMyBuilding()
|
||||
if (!town->getTown()->buildings.count(myID))
|
||||
return nullptr;
|
||||
|
||||
const CBuilding * build = town->getTown()->buildings.at(myID);
|
||||
const CBuilding * build = town->getTown()->buildings.at(myID).get();
|
||||
while (town->getTown()->buildings.count(myID))
|
||||
{
|
||||
if (town->hasBuilt(myID))
|
||||
build = town->getTown()->buildings.at(myID);
|
||||
build = town->getTown()->buildings.at(myID).get();
|
||||
BuildingID::advanceDwelling(myID);
|
||||
}
|
||||
|
||||
|
||||
@@ -192,7 +192,8 @@ std::string CMarketWindow::getMarketTitle(const ObjectInstanceID marketId, const
|
||||
{
|
||||
for(const auto & buildingId : town->getBuildings())
|
||||
{
|
||||
if(const auto building = town->getTown()->buildings.at(buildingId); vstd::contains(building->marketModes, mode))
|
||||
const auto & building = town->getTown()->buildings.at(buildingId);
|
||||
if(vstd::contains(building->marketModes, mode))
|
||||
return building->getNameTranslated();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
#include "bonuses/Bonus.h"
|
||||
#include "bonuses/CBonusSystemNode.h"
|
||||
#include "ConstTransitivePtr.h"
|
||||
#include "GameConstants.h"
|
||||
#include "IHandlerBase.h"
|
||||
#include "serializer/Serializeable.h"
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
#include "bonuses/CBonusSystemNode.h"
|
||||
#include "GameConstants.h"
|
||||
#include "ConstTransitivePtr.h"
|
||||
#include "CArtHandler.h"
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
#include "bonuses/Bonus.h"
|
||||
#include "bonuses/CBonusSystemNode.h"
|
||||
#include "ConstTransitivePtr.h"
|
||||
#include "ResourceSet.h"
|
||||
#include "GameConstants.h"
|
||||
#include "IHandlerBase.h"
|
||||
|
||||
@@ -476,13 +476,12 @@ std::vector <const CGObjectInstance *> CGameInfoCallback::getVisitableObjs(int3
|
||||
if(!getPlayerID().has_value() || obj->ID != Obj::EVENT) //hide events from players
|
||||
ret.push_back(obj);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::vector<ConstTransitivePtr<CGObjectInstance>> CGameInfoCallback::getAllVisitableObjs() const
|
||||
std::vector<const CGObjectInstance *> CGameInfoCallback::getAllVisitableObjs() const
|
||||
{
|
||||
std::vector<ConstTransitivePtr<CGObjectInstance>> ret;
|
||||
std::vector<const CGObjectInstance *> ret;
|
||||
for(auto & obj : gs->map->objects)
|
||||
if(obj && obj->isVisitable() && obj->ID != Obj::EVENT && isVisible(obj))
|
||||
ret.push_back(obj);
|
||||
@@ -589,8 +588,7 @@ EBuildingState CGameInfoCallback::canBuildStructure( const CGTownInstance *t, Bu
|
||||
if(!t->getTown()->buildings.count(ID))
|
||||
return EBuildingState::BUILDING_ERROR;
|
||||
|
||||
const CBuilding * building = t->getTown()->buildings.at(ID);
|
||||
|
||||
const auto & building = t->getTown()->buildings.at(ID);
|
||||
|
||||
if(t->hasBuilt(ID)) //already built
|
||||
return EBuildingState::ALREADY_PRESENT;
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
#include "int3.h"
|
||||
#include "ResourceSet.h" // for Res
|
||||
#include "ConstTransitivePtr.h"
|
||||
|
||||
#define ASSERT_IF_CALLED_WITH_PLAYER if(!getPlayerID()) {logGlobal->error(BOOST_CURRENT_FUNCTION); assert(0);}
|
||||
|
||||
@@ -188,11 +187,11 @@ public:
|
||||
|
||||
//objects
|
||||
const CGObjectInstance * getObj(ObjectInstanceID objid, bool verbose = true) const override;
|
||||
virtual std::vector <const CGObjectInstance * > getBlockingObjs(int3 pos)const;
|
||||
std::vector <const CGObjectInstance * > getVisitableObjs(int3 pos, bool verbose = true) const override;
|
||||
std::vector<ConstTransitivePtr<CGObjectInstance>> getAllVisitableObjs() const;
|
||||
virtual std::vector <const CGObjectInstance * > getFlaggableObjects(int3 pos) const;
|
||||
virtual const CGObjectInstance * getTopObj (int3 pos) const;
|
||||
virtual std::vector<const CGObjectInstance *> getBlockingObjs(int3 pos) const;
|
||||
std::vector<const CGObjectInstance *> getVisitableObjs(int3 pos, bool verbose = true) const override;
|
||||
std::vector<const CGObjectInstance *> getAllVisitableObjs() const;
|
||||
virtual std::vector<const CGObjectInstance *> getFlaggableObjects(int3 pos) const;
|
||||
virtual const CGObjectInstance * getTopObj(int3 pos) const;
|
||||
virtual PlayerColor getOwner(ObjectInstanceID heroID) const;
|
||||
virtual const IMarket * getMarket(ObjectInstanceID objid) const;
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ BuildingID CBuilding::getBase() const
|
||||
const CBuilding * build = this;
|
||||
while (build->upgrade != BuildingID::NONE)
|
||||
{
|
||||
build = build->town->buildings.at(build->upgrade);
|
||||
build = build->town->buildings.at(build->upgrade).get();
|
||||
}
|
||||
|
||||
return build->bid;
|
||||
@@ -81,11 +81,11 @@ BuildingID CBuilding::getBase() const
|
||||
|
||||
si32 CBuilding::getDistance(const BuildingID & buildID) const
|
||||
{
|
||||
const CBuilding * build = town->buildings.at(buildID);
|
||||
const CBuilding * build = town->buildings.at(buildID).get();
|
||||
int distance = 0;
|
||||
while (build->upgrade != BuildingID::NONE && build != this)
|
||||
{
|
||||
build = build->town->buildings.at(build->upgrade);
|
||||
build = build->town->buildings.at(build->upgrade).get();
|
||||
distance++;
|
||||
}
|
||||
if (build == this)
|
||||
|
||||
@@ -22,14 +22,7 @@ CTown::CTown()
|
||||
{
|
||||
}
|
||||
|
||||
CTown::~CTown()
|
||||
{
|
||||
for(auto & build : buildings)
|
||||
build.second.dellNull();
|
||||
|
||||
for(auto & str : clientInfo.structures)
|
||||
str.dellNull();
|
||||
}
|
||||
CTown::~CTown() = default;
|
||||
|
||||
std::string CTown::getRandomNameTextID(size_t index) const
|
||||
{
|
||||
@@ -67,7 +60,7 @@ const CBuilding * CTown::getSpecialBuilding(BuildingSubID::EBuildingSubID subID)
|
||||
for(const auto & kvp : buildings)
|
||||
{
|
||||
if(kvp.second->subId == subID)
|
||||
return buildings.at(kvp.first);
|
||||
return buildings.at(kvp.first).get();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "../building/TownFortifications.h"
|
||||
#include "../../ConstTransitivePtr.h"
|
||||
#include "../../Point.h"
|
||||
#include "../../constants/EntityIdentifiers.h"
|
||||
#include "../../constants/Enumerations.h"
|
||||
@@ -26,8 +25,8 @@ class CBuilding;
|
||||
/// Should be moved from lib to client
|
||||
struct DLL_LINKAGE CStructure
|
||||
{
|
||||
CBuilding * building; // base building. If null - this structure will be always present on screen
|
||||
CBuilding * buildable; // building that will be used to determine built building and visible cost. Usually same as "building"
|
||||
const CBuilding * building; // base building. If null - this structure will be always present on screen
|
||||
const CBuilding * buildable; // building that will be used to determine built building and visible cost. Usually same as "building"
|
||||
|
||||
int3 pos;
|
||||
AnimationPath defName;
|
||||
@@ -58,10 +57,9 @@ public:
|
||||
CFaction * faction;
|
||||
|
||||
/// level -> list of creatures on this tier
|
||||
// TODO: replace with pointers to CCreature
|
||||
std::vector<std::vector<CreatureID> > creatures;
|
||||
|
||||
std::map<BuildingID, ConstTransitivePtr<CBuilding> > buildings;
|
||||
std::map<BuildingID, std::unique_ptr<const CBuilding>> buildings;
|
||||
|
||||
std::vector<std::string> dwellings; //defs for adventure map dwellings for new towns, [0] means tier 1 creatures etc.
|
||||
std::vector<std::string> dwellingNames;
|
||||
@@ -99,7 +97,7 @@ public:
|
||||
|
||||
/// list of town screen structures.
|
||||
/// NOTE: index in vector is meaningless. Vector used instead of list for a bit faster access
|
||||
std::vector<ConstTransitivePtr<CStructure> > structures;
|
||||
std::vector<std::unique_ptr<const CStructure>> structures;
|
||||
|
||||
std::string siegePrefix;
|
||||
std::vector<Point> siegePositions;
|
||||
|
||||
@@ -385,7 +385,7 @@ void CTownHandler::loadBuilding(CTown * town, const std::string & stringID, cons
|
||||
else
|
||||
ret->upgrade = BuildingID::NONE;
|
||||
|
||||
ret->town->buildings[ret->bid] = ret;
|
||||
ret->town->buildings[ret->bid].reset(ret);
|
||||
for(const auto & element : source["marketModes"].Vector())
|
||||
{
|
||||
if(MappedKeys::MARKET_NAMES_TO_TYPES.count(element.String()))
|
||||
@@ -413,21 +413,21 @@ void CTownHandler::loadStructure(CTown &town, const std::string & stringID, cons
|
||||
|
||||
LIBRARY->identifiers()->tryRequestIdentifier( source.getModScope(), "building." + town.faction->getJsonKey(), stringID, [=, &town](si32 identifier) mutable
|
||||
{
|
||||
ret->building = town.buildings[BuildingID(identifier)];
|
||||
ret->building = town.buildings[BuildingID(identifier)].get();
|
||||
});
|
||||
|
||||
if (source["builds"].isNull())
|
||||
{
|
||||
LIBRARY->identifiers()->tryRequestIdentifier( source.getModScope(), "building." + town.faction->getJsonKey(), stringID, [=, &town](si32 identifier) mutable
|
||||
{
|
||||
ret->building = town.buildings[BuildingID(identifier)];
|
||||
ret->building = town.buildings[BuildingID(identifier)].get();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
LIBRARY->identifiers()->requestIdentifier("building." + town.faction->getJsonKey(), source["builds"], [=, &town](si32 identifier) mutable
|
||||
{
|
||||
ret->buildable = town.buildings[BuildingID(identifier)];
|
||||
ret->buildable = town.buildings[BuildingID(identifier)].get();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -677,7 +677,7 @@ void CGameStateCampaign::initTowns()
|
||||
|
||||
town->addBuilding(newBuilding);
|
||||
|
||||
auto building = town->getTown()->buildings.at(newBuilding);
|
||||
const auto & building = town->getTown()->buildings.at(newBuilding);
|
||||
newBuilding = building->upgrade;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "../bonuses/BonusCache.h"
|
||||
#include "../entities/hero/EHeroGender.h"
|
||||
#include "../CArtHandler.h" // For CArtifactSet
|
||||
#include "../ConstTransitivePtr.h"
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
|
||||
@@ -769,7 +769,7 @@ void CGTownInstance::recreateBuildingsBonuses()
|
||||
if (bonusesReplacedByUpgrade)
|
||||
continue;
|
||||
|
||||
auto building = getTown()->buildings.at(bid);
|
||||
const auto & building = getTown()->buildings.at(bid);
|
||||
|
||||
if(building->buildingBonuses.empty())
|
||||
continue;
|
||||
@@ -960,7 +960,7 @@ TResources CGTownInstance::getBuildingCost(const BuildingID & buildingID) const
|
||||
|
||||
CBuilding::TRequired CGTownInstance::genBuildingRequirements(const BuildingID & buildID, bool deep) const
|
||||
{
|
||||
const CBuilding * building = getTown()->buildings.at(buildID);
|
||||
const auto & building = getTown()->buildings.at(buildID);
|
||||
|
||||
//TODO: find better solution to prevent infinite loops
|
||||
std::set<BuildingID> processed;
|
||||
@@ -974,7 +974,7 @@ CBuilding::TRequired CGTownInstance::genBuildingRequirements(const BuildingID &
|
||||
return CBuilding::TRequired::OperatorAll();
|
||||
}
|
||||
|
||||
const CBuilding * build = getTown()->buildings.at(id);
|
||||
const auto & build = getTown()->buildings.at(id);
|
||||
CBuilding::TRequired::OperatorAll requirements;
|
||||
|
||||
if (!hasBuilt(id))
|
||||
@@ -999,7 +999,7 @@ CBuilding::TRequired CGTownInstance::genBuildingRequirements(const BuildingID &
|
||||
CBuilding::TRequired::OperatorAll requirements;
|
||||
if (building->upgrade != BuildingID::NONE)
|
||||
{
|
||||
const CBuilding * upgr = getTown()->buildings.at(building->upgrade);
|
||||
const auto & upgr = getTown()->buildings.at(building->upgrade);
|
||||
|
||||
requirements.expressions.push_back(dependTest(upgr->bid));
|
||||
processed.clear();
|
||||
@@ -1095,7 +1095,7 @@ void CGTownInstance::serializeJsonOptions(JsonSerializeFormat & handler)
|
||||
if(id == BuildingID::DEFAULT)
|
||||
continue;
|
||||
|
||||
const CBuilding * building = getTown()->buildings.at(id);
|
||||
const auto & building = getTown()->buildings.at(id);
|
||||
|
||||
if(building->mode == CBuilding::BUILD_AUTO)
|
||||
continue;
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include "IMarket.h"
|
||||
#include "CGDwelling.h"
|
||||
#include "../ConstTransitivePtr.h"
|
||||
#include "../entities/faction/CFaction.h" // TODO: remove
|
||||
#include "../entities/faction/CTown.h" // TODO: remove
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ TownRewardableBuildingInstance::TownRewardableBuildingInstance(CGTownInstance *
|
||||
Rewardable::Configuration TownRewardableBuildingInstance::generateConfiguration(vstd::RNG & rand) const
|
||||
{
|
||||
Rewardable::Configuration result;
|
||||
auto building = town->getTown()->buildings.at(getBuildingType());
|
||||
const auto & building = town->getTown()->buildings.at(getBuildingType());
|
||||
|
||||
building->rewardableObjectInfo.configureObject(result, rand, cb);
|
||||
for(auto & rewardInfo : result.info)
|
||||
@@ -165,7 +165,7 @@ bool TownRewardableBuildingInstance::wasVisitedBefore(const CGHeroInstance * con
|
||||
return false; //not supported
|
||||
case Rewardable::VISIT_BONUS:
|
||||
{
|
||||
const auto building = town->getTown()->buildings.at(getBuildingType());
|
||||
const auto & building = town->getTown()->buildings.at(getBuildingType());
|
||||
if (building->mapObjectLikeBonuses.hasValue())
|
||||
return contextHero->hasBonusFrom(BonusSource::OBJECT_TYPE, BonusSourceID(building->mapObjectLikeBonuses));
|
||||
else
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#include <vcmi/spells/Service.h>
|
||||
#include <vcmi/spells/Magic.h>
|
||||
#include "../IHandlerBase.h"
|
||||
#include "../ConstTransitivePtr.h"
|
||||
#include "../int3.h"
|
||||
#include "../bonuses/Bonus.h"
|
||||
#include "../filesystem/ResourcePath.h"
|
||||
|
||||
@@ -142,7 +142,7 @@ TownBuildingsWidget::~TownBuildingsWidget()
|
||||
QStandardItem * TownBuildingsWidget::addBuilding(const CTown & ctown, int bId, std::set<si32> & remaining)
|
||||
{
|
||||
BuildingID buildingId(bId);
|
||||
const CBuilding * building = ctown.buildings.at(buildingId);
|
||||
const auto & building = ctown.buildings.at(buildingId);
|
||||
if(!building)
|
||||
{
|
||||
remaining.erase(bId);
|
||||
@@ -175,7 +175,7 @@ QStandardItem * TownBuildingsWidget::addBuilding(const CTown & ctown, int bId, s
|
||||
}
|
||||
else
|
||||
{
|
||||
QStandardItem * parent = getBuildingParentFromTreeModel(building, model);
|
||||
QStandardItem * parent = getBuildingParentFromTreeModel(building.get(), model);
|
||||
|
||||
if(!parent)
|
||||
parent = addBuilding(ctown, building->upgrade.getNum(), remaining);
|
||||
|
||||
@@ -118,7 +118,7 @@ void TownEventDialog::initBuildings()
|
||||
QStandardItem * TownEventDialog::addBuilding(const CTown& ctown, BuildingID buildingId, std::set<si32>& remaining)
|
||||
{
|
||||
auto bId = buildingId.num;
|
||||
const CBuilding * building = ctown.buildings.at(buildingId);
|
||||
const auto & building = ctown.buildings.at(buildingId);
|
||||
|
||||
QString name = QString::fromStdString(building->getNameTranslated());
|
||||
|
||||
@@ -141,7 +141,7 @@ QStandardItem * TownEventDialog::addBuilding(const CTown& ctown, BuildingID buil
|
||||
}
|
||||
else
|
||||
{
|
||||
QStandardItem * parent = getBuildingParentFromTreeModel(building, buildingsModel);
|
||||
QStandardItem * parent = getBuildingParentFromTreeModel(building.get(), buildingsModel);
|
||||
|
||||
if (!parent)
|
||||
parent = addBuilding(ctown, building->upgrade.getNum(), remaining);
|
||||
|
||||
@@ -2048,7 +2048,7 @@ bool CGameHandler::buildStructure(ObjectInstanceID tid, BuildingID requestedID,
|
||||
if(t->hasBuilt(requestedID))
|
||||
COMPLAIN_RETF("Building %s is already built in %s", t->getTown()->buildings.at(requestedID)->getNameTranslated() % t->getNameTranslated());
|
||||
|
||||
const CBuilding * requestedBuilding = t->getTown()->buildings.at(requestedID);
|
||||
const auto & requestedBuilding = t->getTown()->buildings.at(requestedID);
|
||||
|
||||
//Vector with future list of built building and buildings in auto-mode that are not yet built.
|
||||
std::vector<const CBuilding*> remainingAutoBuildings;
|
||||
@@ -2144,7 +2144,7 @@ bool CGameHandler::buildStructure(ObjectInstanceID tid, BuildingID requestedID,
|
||||
else
|
||||
{
|
||||
if(build.second->mode == CBuilding::BUILD_AUTO) //not built auto building
|
||||
remainingAutoBuildings.push_back(build.second);
|
||||
remainingAutoBuildings.push_back(build.second.get());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2154,7 +2154,7 @@ bool CGameHandler::buildStructure(ObjectInstanceID tid, BuildingID requestedID,
|
||||
ns.built = force ? t->built : (t->built+1);
|
||||
|
||||
std::queue<const CBuilding*> buildingsToAdd;
|
||||
buildingsToAdd.push(requestedBuilding);
|
||||
buildingsToAdd.push(requestedBuilding.get());
|
||||
|
||||
while(!buildingsToAdd.empty())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user