mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Rename town building types to more clear names
This commit is contained in:
parent
abfb467f68
commit
2f3f3c21df
@ -122,7 +122,7 @@ set(lib_MAIN_SRCS
|
||||
mapObjects/CGMarket.cpp
|
||||
mapObjects/CGObjectInstance.cpp
|
||||
mapObjects/CGPandoraBox.cpp
|
||||
mapObjects/CGTownBuilding.cpp
|
||||
mapObjects/TownBuildingInstance.cpp
|
||||
mapObjects/CGTownInstance.cpp
|
||||
mapObjects/CObjectHandler.cpp
|
||||
mapObjects/CQuest.cpp
|
||||
@ -496,7 +496,7 @@ set(lib_MAIN_HEADERS
|
||||
mapObjects/CGMarket.h
|
||||
mapObjects/CGObjectInstance.h
|
||||
mapObjects/CGPandoraBox.h
|
||||
mapObjects/CGTownBuilding.h
|
||||
mapObjects/TownBuildingInstance.h
|
||||
mapObjects/CGTownInstance.h
|
||||
mapObjects/CObjectHandler.h
|
||||
mapObjects/CQuest.h
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "mapObjectConstructors/AObjectTypeHandler.h"
|
||||
#include "mapObjectConstructors/CObjectClassesHandler.h"
|
||||
#include "mapObjects/CGMarket.h"
|
||||
#include "mapObjects/CGTownBuilding.h"
|
||||
#include "mapObjects/TownBuildingInstance.h"
|
||||
#include "mapObjects/CGTownInstance.h"
|
||||
#include "mapObjects/CObjectHandler.h"
|
||||
#include "mapObjects/CQuest.h"
|
||||
|
@ -10,7 +10,8 @@
|
||||
|
||||
#include "StdInc.h"
|
||||
#include "CGTownInstance.h"
|
||||
#include "CGTownBuilding.h"
|
||||
|
||||
#include "TownBuildingInstance.h"
|
||||
#include "../spells/CSpellHandler.h"
|
||||
#include "../bonuses/Bonus.h"
|
||||
#include "../battle/IBattleInfoCallback.h"
|
||||
@ -59,13 +60,13 @@ void CGTownInstance::setPropertyDer(ObjProperty what, ObjPropertyID identifier)
|
||||
switch (what)
|
||||
{
|
||||
case ObjProperty::STRUCTURE_ADD_VISITING_HERO:
|
||||
bonusingBuildings[identifier.getNum()]->setProperty(ObjProperty::VISITORS, visitingHero->id);
|
||||
rewardableBuildings.at(identifier.getNum())->setProperty(ObjProperty::VISITORS, visitingHero->id);
|
||||
break;
|
||||
case ObjProperty::STRUCTURE_CLEAR_VISITORS:
|
||||
bonusingBuildings[identifier.getNum()]->setProperty(ObjProperty::STRUCTURE_CLEAR_VISITORS, NumericID(0));
|
||||
rewardableBuildings.at(identifier.getNum())->setProperty(ObjProperty::STRUCTURE_CLEAR_VISITORS, NumericID(0));
|
||||
break;
|
||||
case ObjProperty::STRUCTURE_ADD_GARRISONED_HERO: //add garrisoned hero to visitors
|
||||
bonusingBuildings[identifier.getNum()]->setProperty(ObjProperty::VISITORS, garrisonHero->id);
|
||||
rewardableBuildings.at(identifier.getNum())->setProperty(ObjProperty::VISITORS, garrisonHero->id);
|
||||
break;
|
||||
case ObjProperty::BONUS_VALUE_FIRST:
|
||||
bonusValue.first = identifier.getNum();
|
||||
@ -254,8 +255,8 @@ CGTownInstance::CGTownInstance(IGameCallback *cb):
|
||||
|
||||
CGTownInstance::~CGTownInstance()
|
||||
{
|
||||
for (auto & elem : bonusingBuildings)
|
||||
delete elem;
|
||||
for (auto & elem : rewardableBuildings)
|
||||
delete elem.second;
|
||||
}
|
||||
|
||||
int CGTownInstance::spellsAtLevel(int level, bool checkGuild) const
|
||||
@ -283,8 +284,8 @@ void CGTownInstance::setOwner(const PlayerColor & player) const
|
||||
|
||||
void CGTownInstance::blockingDialogAnswered(const CGHeroInstance *hero, int32_t answer) const
|
||||
{
|
||||
for (auto building : bonusingBuildings)
|
||||
building->blockingDialogAnswered(hero, answer);
|
||||
for (auto building : rewardableBuildings)
|
||||
building.second->blockingDialogAnswered(hero, answer); // FIXME: why call for every building?
|
||||
}
|
||||
|
||||
void CGTownInstance::onHeroVisit(const CGHeroInstance * h) const
|
||||
@ -369,23 +370,12 @@ bool CGTownInstance::townEnvisagesBuilding(BuildingSubID::EBuildingSubID subId)
|
||||
return town->getBuildingType(subId) != BuildingID::NONE;
|
||||
}
|
||||
|
||||
void CGTownInstance::initOverriddenBids()
|
||||
{
|
||||
for(const auto & bid : builtBuildings)
|
||||
{
|
||||
const auto & overrideThem = town->buildings.at(bid)->overrideBids;
|
||||
|
||||
for(const auto & overrideIt : overrideThem)
|
||||
overriddenBuildings.insert(overrideIt);
|
||||
}
|
||||
}
|
||||
|
||||
void CGTownInstance::initializeConfigurableBuildings(vstd::RNG & rand)
|
||||
{
|
||||
for(const auto & kvp : town->buildings)
|
||||
{
|
||||
if(!kvp.second->rewardableObjectInfo.getParameters().isNull())
|
||||
bonusingBuildings.push_back(new CTownRewardableBuilding(this, kvp.second->bid, rand));
|
||||
rewardableBuildings[kvp.first] = new TownRewardableBuildingInstance(this, kvp.second->bid, rand);
|
||||
}
|
||||
}
|
||||
|
||||
@ -425,26 +415,6 @@ DamageRange CGTownInstance::getKeepDamageRange() const
|
||||
};
|
||||
}
|
||||
|
||||
void CGTownInstance::deleteTownBonus(BuildingID bid)
|
||||
{
|
||||
size_t i = 0;
|
||||
CGTownBuilding * freeIt = nullptr;
|
||||
|
||||
for(i = 0; i != bonusingBuildings.size(); i++)
|
||||
{
|
||||
if(bonusingBuildings[i]->getBuildingType() == bid)
|
||||
{
|
||||
freeIt = bonusingBuildings[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(freeIt == nullptr)
|
||||
return;
|
||||
|
||||
bonusingBuildings.erase(bonusingBuildings.begin() + i);
|
||||
delete freeIt;
|
||||
}
|
||||
|
||||
FactionID CGTownInstance::randomizeFaction(vstd::RNG & rand)
|
||||
{
|
||||
if(getOwner().isValidPlayer())
|
||||
@ -499,7 +469,6 @@ void CGTownInstance::initObj(vstd::RNG & rand) ///initialize town structures
|
||||
creatures[level].second.push_back(town->creatures[level][upgradeNum]);
|
||||
}
|
||||
}
|
||||
initOverriddenBids();
|
||||
initializeConfigurableBuildings(rand);
|
||||
recreateBuildingsBonuses();
|
||||
updateAppearance();
|
||||
@ -576,8 +545,8 @@ void CGTownInstance::newTurn(vstd::RNG & rand) const
|
||||
}
|
||||
}
|
||||
|
||||
for(const auto * rewardableBuilding : bonusingBuildings)
|
||||
rewardableBuilding->newTurn(rand);
|
||||
for(const auto & building : rewardableBuildings)
|
||||
building.second->newTurn(rand);
|
||||
|
||||
if(hasBuilt(BuildingSubID::BANK) && bonusValue.second > 0)
|
||||
{
|
||||
@ -824,8 +793,9 @@ void CGTownInstance::recreateBuildingsBonuses()
|
||||
|
||||
for(const auto & bid : builtBuildings)
|
||||
{
|
||||
if(vstd::contains(overriddenBuildings, bid)) //tricky! -> checks tavern only if no bratherhood of sword
|
||||
continue;
|
||||
// FIXME: Restore
|
||||
//if(vstd::contains(overriddenBuildings, bid)) //tricky! -> checks tavern only if no bratherhood of sword
|
||||
// continue;
|
||||
|
||||
auto building = town->buildings.at(bid);
|
||||
|
||||
@ -1256,8 +1226,21 @@ void CGTownInstance::fillUpgradeInfo(UpgradeInfo & info, const CStackInstance &s
|
||||
void CGTownInstance::postDeserialize()
|
||||
{
|
||||
setNodeType(CBonusSystemNode::TOWN);
|
||||
for(auto * bonusingBuilding : bonusingBuildings)
|
||||
bonusingBuilding->town = this;
|
||||
for(auto & building : rewardableBuildings)
|
||||
building.second->town = this;
|
||||
}
|
||||
|
||||
std::map<BuildingID, TownRewardableBuildingInstance*> CGTownInstance::convertOldBuildings(std::vector<TownRewardableBuildingInstance*> oldVector)
|
||||
{
|
||||
std::map<BuildingID, TownRewardableBuildingInstance*> result;
|
||||
|
||||
for(auto & building : oldVector)
|
||||
{
|
||||
result[building->getBuildingType()] = new TownRewardableBuildingInstance(*building);
|
||||
delete building;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
VCMI_LIB_NAMESPACE_END
|
||||
|
@ -18,7 +18,8 @@ VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
class CCastleEvent;
|
||||
class CTown;
|
||||
class CGTownBuilding;
|
||||
class TownBuildingInstance;
|
||||
class TownRewardableBuildingInstance;
|
||||
struct DamageRange;
|
||||
|
||||
template<typename ContainedClass>
|
||||
@ -49,6 +50,8 @@ struct DLL_LINKAGE GrowthInfo
|
||||
class DLL_LINKAGE CGTownInstance : public CGDwelling, public IShipyard, public IMarket, public INativeTerrainProvider, public ICreatureUpgrader
|
||||
{
|
||||
std::string nameTextId; // name of town
|
||||
|
||||
std::map<BuildingID, TownRewardableBuildingInstance*> convertOldBuildings(std::vector<TownRewardableBuildingInstance*> oldVector);
|
||||
public:
|
||||
using CGDwelling::getPosition;
|
||||
|
||||
@ -63,8 +66,7 @@ public:
|
||||
PlayerColor alignmentToPlayer; // if set to non-neutral, random town will have same faction as specified player
|
||||
std::set<BuildingID> forbiddenBuildings;
|
||||
std::set<BuildingID> builtBuildings;
|
||||
std::set<BuildingID> overriddenBuildings; ///buildings which bonuses are overridden and should not be applied
|
||||
std::vector<CGTownBuilding*> bonusingBuildings;
|
||||
std::map<BuildingID, TownRewardableBuildingInstance*> rewardableBuildings;
|
||||
std::vector<SpellID> possibleSpells, obligatorySpells;
|
||||
std::vector<std::vector<SpellID> > spells; //spells[level] -> vector of spells, first will be available in guild
|
||||
std::vector<CCastleEvent> events;
|
||||
@ -88,7 +90,17 @@ public:
|
||||
h & obligatorySpells;
|
||||
h & spells;
|
||||
h & events;
|
||||
h & bonusingBuildings;
|
||||
|
||||
if (h.version >= Handler::Version::NEW_TOWN_BUILDINGS)
|
||||
{
|
||||
h & rewardableBuildings;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<TownRewardableBuildingInstance*> oldVector;
|
||||
h & oldVector;
|
||||
rewardableBuildings = convertOldBuildings(oldVector);
|
||||
}
|
||||
|
||||
if (h.saving)
|
||||
{
|
||||
@ -105,7 +117,11 @@ public:
|
||||
h & townAndVis;
|
||||
BONUS_TREE_DESERIALIZATION_FIX
|
||||
|
||||
h & overriddenBuildings;
|
||||
if (h.version < Handler::Version::NEW_TOWN_BUILDINGS)
|
||||
{
|
||||
std::set<BuildingID> overriddenBuildings;
|
||||
h & overriddenBuildings;
|
||||
}
|
||||
|
||||
if(!h.saving)
|
||||
postDeserialize();
|
||||
@ -217,7 +233,6 @@ private:
|
||||
void onTownCaptured(const PlayerColor & winner) const;
|
||||
int getDwellingBonus(const std::vector<CreatureID>& creatureIds, const std::vector<ConstTransitivePtr<CGDwelling> >& dwellings) const;
|
||||
bool townEnvisagesBuilding(BuildingSubID::EBuildingSubID bid) const;
|
||||
void initOverriddenBids();
|
||||
void initializeConfigurableBuildings(vstd::RNG & rand);
|
||||
};
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* CGTownBuilding.cpp, part of VCMI engine
|
||||
* TownBuildingInstance.cpp, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
@ -9,7 +9,8 @@
|
||||
*/
|
||||
|
||||
#include "StdInc.h"
|
||||
#include "CGTownBuilding.h"
|
||||
#include "TownBuildingInstance.h"
|
||||
|
||||
#include "CGTownInstance.h"
|
||||
#include "../texts/CGeneralTextHandler.h"
|
||||
#include "../IGameCallback.h"
|
||||
@ -23,59 +24,59 @@
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
CGTownBuilding::CGTownBuilding(IGameCallback * cb)
|
||||
TownBuildingInstance::TownBuildingInstance(IGameCallback * cb)
|
||||
: IObjectInterface(cb)
|
||||
, town(nullptr)
|
||||
{}
|
||||
|
||||
CGTownBuilding::CGTownBuilding(CGTownInstance * town, const BuildingID & index)
|
||||
TownBuildingInstance::TownBuildingInstance(CGTownInstance * town, const BuildingID & index)
|
||||
: IObjectInterface(town->cb)
|
||||
, town(town)
|
||||
, bID(index)
|
||||
{}
|
||||
|
||||
PlayerColor CGTownBuilding::getOwner() const
|
||||
PlayerColor TownBuildingInstance::getOwner() const
|
||||
{
|
||||
return town->getOwner();
|
||||
}
|
||||
|
||||
MapObjectID CGTownBuilding::getObjGroupIndex() const
|
||||
MapObjectID TownBuildingInstance::getObjGroupIndex() const
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
MapObjectSubID CGTownBuilding::getObjTypeIndex() const
|
||||
MapObjectSubID TownBuildingInstance::getObjTypeIndex() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int3 CGTownBuilding::visitablePos() const
|
||||
int3 TownBuildingInstance::visitablePos() const
|
||||
{
|
||||
return town->visitablePos();
|
||||
}
|
||||
|
||||
int3 CGTownBuilding::getPosition() const
|
||||
int3 TownBuildingInstance::getPosition() const
|
||||
{
|
||||
return town->getPosition();
|
||||
}
|
||||
|
||||
CTownRewardableBuilding::CTownRewardableBuilding(IGameCallback *cb)
|
||||
: CGTownBuilding(cb)
|
||||
TownRewardableBuildingInstance::TownRewardableBuildingInstance(IGameCallback *cb)
|
||||
: TownBuildingInstance(cb)
|
||||
{}
|
||||
|
||||
CTownRewardableBuilding::CTownRewardableBuilding(CGTownInstance * town, const BuildingID & index, vstd::RNG & rand)
|
||||
: CGTownBuilding(town, index)
|
||||
TownRewardableBuildingInstance::TownRewardableBuildingInstance(CGTownInstance * town, const BuildingID & index, vstd::RNG & rand)
|
||||
: TownBuildingInstance(town, index)
|
||||
{
|
||||
initObj(rand);
|
||||
}
|
||||
|
||||
void CTownRewardableBuilding::initObj(vstd::RNG & rand)
|
||||
void TownRewardableBuildingInstance::initObj(vstd::RNG & rand)
|
||||
{
|
||||
assert(town && town->town);
|
||||
configuration = generateConfiguration(rand);
|
||||
}
|
||||
|
||||
Rewardable::Configuration CTownRewardableBuilding::generateConfiguration(vstd::RNG & rand) const
|
||||
Rewardable::Configuration TownRewardableBuildingInstance::generateConfiguration(vstd::RNG & rand) const
|
||||
{
|
||||
Rewardable::Configuration result;
|
||||
auto building = town->town->buildings.at(getBuildingType());
|
||||
@ -92,7 +93,7 @@ Rewardable::Configuration CTownRewardableBuilding::generateConfiguration(vstd::R
|
||||
return result;
|
||||
}
|
||||
|
||||
void CTownRewardableBuilding::newTurn(vstd::RNG & rand) const
|
||||
void TownRewardableBuildingInstance::newTurn(vstd::RNG & rand) const
|
||||
{
|
||||
if (configuration.resetParameters.period != 0 && cb->getDate(Date::DAY) > 1 && ((cb->getDate(Date::DAY)-1) % configuration.resetParameters.period) == 0)
|
||||
{
|
||||
@ -106,7 +107,7 @@ void CTownRewardableBuilding::newTurn(vstd::RNG & rand) const
|
||||
}
|
||||
}
|
||||
|
||||
void CTownRewardableBuilding::setProperty(ObjProperty what, ObjPropertyID identifier)
|
||||
void TownRewardableBuildingInstance::setProperty(ObjProperty what, ObjPropertyID identifier)
|
||||
{
|
||||
switch (what)
|
||||
{
|
||||
@ -122,12 +123,12 @@ void CTownRewardableBuilding::setProperty(ObjProperty what, ObjPropertyID identi
|
||||
}
|
||||
}
|
||||
|
||||
void CTownRewardableBuilding::heroLevelUpDone(const CGHeroInstance *hero) const
|
||||
void TownRewardableBuildingInstance::heroLevelUpDone(const CGHeroInstance *hero) const
|
||||
{
|
||||
grantRewardAfterLevelup(cb, configuration.info.at(selectedReward), town, hero);
|
||||
}
|
||||
|
||||
void CTownRewardableBuilding::blockingDialogAnswered(const CGHeroInstance *hero, int32_t answer) const
|
||||
void TownRewardableBuildingInstance::blockingDialogAnswered(const CGHeroInstance *hero, int32_t answer) const
|
||||
{
|
||||
if(answer == 0)
|
||||
return; // player refused
|
||||
@ -146,7 +147,7 @@ void CTownRewardableBuilding::blockingDialogAnswered(const CGHeroInstance *hero,
|
||||
}
|
||||
}
|
||||
|
||||
void CTownRewardableBuilding::grantReward(ui32 rewardID, const CGHeroInstance * hero) const
|
||||
void TownRewardableBuildingInstance::grantReward(ui32 rewardID, const CGHeroInstance * hero) const
|
||||
{
|
||||
town->addHeroToStructureVisitors(hero, getBuildingType());
|
||||
|
||||
@ -159,7 +160,7 @@ void CTownRewardableBuilding::grantReward(ui32 rewardID, const CGHeroInstance *
|
||||
}
|
||||
}
|
||||
|
||||
bool CTownRewardableBuilding::wasVisitedBefore(const CGHeroInstance * contextHero) const
|
||||
bool TownRewardableBuildingInstance::wasVisitedBefore(const CGHeroInstance * contextHero) const
|
||||
{
|
||||
switch (configuration.visitMode)
|
||||
{
|
||||
@ -183,7 +184,7 @@ bool CTownRewardableBuilding::wasVisitedBefore(const CGHeroInstance * contextHer
|
||||
}
|
||||
}
|
||||
|
||||
void CTownRewardableBuilding::onHeroVisit(const CGHeroInstance *h) const
|
||||
void TownRewardableBuildingInstance::onHeroVisit(const CGHeroInstance *h) const
|
||||
{
|
||||
auto grantRewardWithMessage = [&](int index) -> void
|
||||
{
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* CGTownBuilding.h, part of VCMI engine
|
||||
* TownBuildingInstance.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
@ -18,17 +18,15 @@ VCMI_LIB_NAMESPACE_BEGIN
|
||||
class CGTownInstance;
|
||||
class CBuilding;
|
||||
|
||||
class DLL_LINKAGE CGTownBuilding : public IObjectInterface
|
||||
class DLL_LINKAGE TownBuildingInstance : public IObjectInterface
|
||||
{
|
||||
///basic class for town structures handled as map objects
|
||||
public:
|
||||
CGTownBuilding(CGTownInstance * town, const BuildingID & index);
|
||||
CGTownBuilding(IGameCallback *cb);
|
||||
TownBuildingInstance(CGTownInstance * town, const BuildingID & index);
|
||||
TownBuildingInstance(IGameCallback *cb);
|
||||
|
||||
|
||||
CGTownInstance * town;
|
||||
|
||||
STRONG_INLINE
|
||||
const BuildingID & getBuildingType() const
|
||||
{
|
||||
return bID;
|
||||
@ -44,18 +42,13 @@ public:
|
||||
template <typename Handler> void serialize(Handler &h)
|
||||
{
|
||||
h & bID;
|
||||
if (h.version >= Handler::Version::NEW_TOWN_BUILDINGS)
|
||||
{
|
||||
// no-op
|
||||
}
|
||||
else
|
||||
if (h.version < Handler::Version::NEW_TOWN_BUILDINGS)
|
||||
{
|
||||
// compatibility code
|
||||
si32 indexOnTV = 0; //identifies its index on towns vector
|
||||
BuildingSubID::EBuildingSubID bType = BuildingSubID::NONE;
|
||||
|
||||
h & indexOnTV;
|
||||
h & bType;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,19 +56,16 @@ private:
|
||||
BuildingID bID; //from building list
|
||||
};
|
||||
|
||||
class DLL_LINKAGE CTownRewardableBuilding : public CGTownBuilding, public Rewardable::Interface
|
||||
class DLL_LINKAGE TownRewardableBuildingInstance : public TownBuildingInstance, public Rewardable::Interface
|
||||
{
|
||||
/// reward selected by player, no serialize
|
||||
ui16 selectedReward = 0;
|
||||
|
||||
std::set<ObjectInstanceID> visitors;
|
||||
|
||||
bool wasVisitedBefore(const CGHeroInstance * contextHero) const;
|
||||
|
||||
void grantReward(ui32 rewardID, const CGHeroInstance * hero) const;
|
||||
|
||||
bool wasVisitedBefore(const CGHeroInstance * contextHero) const;
|
||||
void grantReward(ui32 rewardID, const CGHeroInstance * hero) const;
|
||||
Rewardable::Configuration generateConfiguration(vstd::RNG & rand) const;
|
||||
|
||||
|
||||
public:
|
||||
void setProperty(ObjProperty what, ObjPropertyID identifier) override;
|
||||
void onHeroVisit(const CGHeroInstance * h) const override;
|
||||
@ -90,57 +80,30 @@ public:
|
||||
/// applies player selection of reward
|
||||
void blockingDialogAnswered(const CGHeroInstance *hero, int32_t answer) const override;
|
||||
|
||||
CTownRewardableBuilding(CGTownInstance * town, const BuildingID & index, vstd::RNG & rand);
|
||||
CTownRewardableBuilding(IGameCallback *cb);
|
||||
TownRewardableBuildingInstance(CGTownInstance * town, const BuildingID & index, vstd::RNG & rand);
|
||||
TownRewardableBuildingInstance(IGameCallback *cb);
|
||||
|
||||
template <typename Handler> void serialize(Handler &h)
|
||||
{
|
||||
h & static_cast<CGTownBuilding&>(*this);
|
||||
h & static_cast<Rewardable::Interface&>(*this);
|
||||
h & static_cast<TownBuildingInstance&>(*this);
|
||||
if (h.version >= Handler::Version::NEW_TOWN_BUILDINGS)
|
||||
h & static_cast<Rewardable::Interface&>(*this);
|
||||
h & visitors;
|
||||
}
|
||||
};
|
||||
|
||||
/// Compatibility for old code
|
||||
class DLL_LINKAGE CTownCompatBuilding1 : public CTownRewardableBuilding
|
||||
class DLL_LINKAGE CTownCompatBuilding1 : public TownRewardableBuildingInstance
|
||||
{
|
||||
public:
|
||||
using CTownRewardableBuilding::CTownRewardableBuilding;
|
||||
|
||||
template <typename Handler> void serialize(Handler &h)
|
||||
{
|
||||
if (h.version >= Handler::Version::NEW_TOWN_BUILDINGS)
|
||||
{
|
||||
h & static_cast<CTownRewardableBuilding&>(*this);
|
||||
}
|
||||
else
|
||||
{
|
||||
h & static_cast<CGTownBuilding&>(*this);
|
||||
std::set<ObjectInstanceID> visitors;
|
||||
h & visitors;
|
||||
}
|
||||
}
|
||||
using TownRewardableBuildingInstance::TownRewardableBuildingInstance;
|
||||
};
|
||||
|
||||
/// Compatibility for old code
|
||||
class DLL_LINKAGE CTownCompatBuilding2 : public CTownRewardableBuilding
|
||||
class DLL_LINKAGE CTownCompatBuilding2 : public TownRewardableBuildingInstance
|
||||
{
|
||||
public:
|
||||
using CTownRewardableBuilding::CTownRewardableBuilding;
|
||||
|
||||
template <typename Handler> void serialize(Handler &h)
|
||||
{
|
||||
if (h.version >= Handler::Version::NEW_TOWN_BUILDINGS)
|
||||
{
|
||||
h & static_cast<CTownRewardableBuilding&>(*this);
|
||||
}
|
||||
else
|
||||
{
|
||||
h & static_cast<CGTownBuilding&>(*this);
|
||||
std::set<ObjectInstanceID> visitors;
|
||||
h & visitors;
|
||||
}
|
||||
}
|
||||
using TownRewardableBuildingInstance::TownRewardableBuildingInstance;
|
||||
};
|
||||
|
||||
VCMI_LIB_NAMESPACE_END
|
@ -36,7 +36,7 @@
|
||||
#include "mapObjects/CBank.h"
|
||||
#include "mapObjects/CGCreature.h"
|
||||
#include "mapObjects/CGMarket.h"
|
||||
#include "mapObjects/CGTownBuilding.h"
|
||||
#include "mapObjects/TownBuildingInstance.h"
|
||||
#include "mapObjects/CGTownInstance.h"
|
||||
#include "mapObjects/CQuest.h"
|
||||
#include "mapObjects/MiscObjects.h"
|
||||
@ -1333,18 +1333,8 @@ void NewStructures::applyGs(CGameState *gs)
|
||||
{
|
||||
assert(t->town->buildings.at(id) != nullptr);
|
||||
t->builtBuildings.insert(id);
|
||||
t->updateAppearance();
|
||||
auto currentBuilding = t->town->buildings.at(id);
|
||||
|
||||
if(currentBuilding->overrideBids.empty())
|
||||
continue;
|
||||
|
||||
for(const auto & overrideBid : currentBuilding->overrideBids)
|
||||
{
|
||||
t->overriddenBuildings.insert(overrideBid);
|
||||
t->deleteTownBonus(overrideBid);
|
||||
}
|
||||
}
|
||||
t->updateAppearance();
|
||||
t->built = built;
|
||||
t->recreateBuildingsBonuses();
|
||||
}
|
||||
@ -2442,13 +2432,13 @@ void SetRewardableConfiguration::applyGs(CGameState * gs)
|
||||
else
|
||||
{
|
||||
auto * townPtr = dynamic_cast<CGTownInstance*>(objectPtr);
|
||||
CGTownBuilding * buildingPtr = nullptr;
|
||||
TownBuildingInstance * buildingPtr = nullptr;
|
||||
|
||||
for (CGTownBuilding * building : townPtr->bonusingBuildings)
|
||||
if (building->getBuildingType() == buildingID)
|
||||
buildingPtr = building;
|
||||
for (auto & building : townPtr->rewardableBuildings)
|
||||
if (building.second->getBuildingType() == buildingID)
|
||||
buildingPtr = building.second;
|
||||
|
||||
auto * rewardablePtr = dynamic_cast<CTownRewardableBuilding *>(buildingPtr);
|
||||
auto * rewardablePtr = dynamic_cast<TownRewardableBuildingInstance *>(buildingPtr);
|
||||
assert(rewardablePtr);
|
||||
rewardablePtr->configuration = configuration;
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include "../mapObjectConstructors/CBankInstanceConstructor.h"
|
||||
#include "../mapObjects/MapObjects.h"
|
||||
#include "../mapObjects/CGCreature.h"
|
||||
#include "../mapObjects/CGTownBuilding.h"
|
||||
#include "../mapObjects/TownBuildingInstance.h"
|
||||
#include "../mapObjects/ObjectTemplate.h"
|
||||
#include "../battle/BattleInfo.h"
|
||||
#include "../battle/CObstacleInstance.h"
|
||||
@ -86,10 +86,10 @@ void registerTypesMapObjects(Serializer &s)
|
||||
//order of type registration is critical for loading old savegames
|
||||
|
||||
//Other object-related
|
||||
s.template registerType<IObjectInterface, CGTownBuilding>();
|
||||
s.template registerType<CGTownBuilding, CTownCompatBuilding1>();
|
||||
s.template registerType<CGTownBuilding, CTownCompatBuilding2>();
|
||||
s.template registerType<CGTownBuilding, CTownRewardableBuilding>();
|
||||
s.template registerType<IObjectInterface, TownBuildingInstance>();
|
||||
s.template registerType<TownBuildingInstance, TownRewardableBuildingInstance>();
|
||||
s.template registerType<TownBuildingInstance, CTownCompatBuilding1>();
|
||||
s.template registerType<TownBuildingInstance, CTownCompatBuilding2>();
|
||||
|
||||
s.template registerType<CGObjectInstance, CRewardableObject>();
|
||||
|
||||
|
@ -57,7 +57,7 @@
|
||||
|
||||
#include "../lib/mapObjects/CGCreature.h"
|
||||
#include "../lib/mapObjects/CGMarket.h"
|
||||
#include "../lib/mapObjects/CGTownBuilding.h"
|
||||
#include "../lib/mapObjects/TownBuildingInstance.h"
|
||||
#include "../lib/mapObjects/CGTownInstance.h"
|
||||
#include "../lib/mapObjects/MiscObjects.h"
|
||||
#include "../lib/mapObjectConstructors/AObjectTypeHandler.h"
|
||||
@ -1536,8 +1536,8 @@ void CGameHandler::heroVisitCastle(const CGTownInstance * obj, const CGHeroInsta
|
||||
|
||||
void CGameHandler::visitCastleObjects(const CGTownInstance * t, const CGHeroInstance * h)
|
||||
{
|
||||
for (auto building : t->bonusingBuildings)
|
||||
building->onHeroVisit(h);
|
||||
for (auto & building : t->rewardableBuildings)
|
||||
building.second->onHeroVisit(h);
|
||||
}
|
||||
|
||||
void CGameHandler::stopHeroVisitCastle(const CGTownInstance * obj, const CGHeroInstance * hero)
|
||||
|
Loading…
Reference in New Issue
Block a user