mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-06 09:09:40 +02:00
Mod system improvement Part I : Special buildings should work in the modders towns
This commit is contained in:
@@ -97,16 +97,31 @@ class DLL_LINKAGE CGTownBuilding : public IObjectInterface
|
||||
{
|
||||
///basic class for town structures handled as map objects
|
||||
public:
|
||||
BuildingID ID; //from buildig list
|
||||
si32 id; //identifies its index on towns vector
|
||||
si32 indexOnTV; //identifies its index on towns vector
|
||||
CGTownInstance *town;
|
||||
CGTownBuilding() : bType(BuildingSubID::NONE), indexOnTV(0), town(nullptr) {};
|
||||
|
||||
STRONG_INLINE
|
||||
BuildingSubID::EBuildingSubID getBuildingSubtype() const
|
||||
{
|
||||
return bType;
|
||||
}
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & ID;
|
||||
h & id;
|
||||
h & bID;
|
||||
h & indexOnTV;
|
||||
|
||||
if(version >= 792)
|
||||
h & bType;
|
||||
else if(!h.saving)
|
||||
bType = BuildingSubID::NONE;
|
||||
}
|
||||
protected:
|
||||
BuildingID bID; //from buildig list
|
||||
BuildingSubID::EBuildingSubID bType;
|
||||
};
|
||||
|
||||
class DLL_LINKAGE COPWBonus : public CGTownBuilding
|
||||
{///used for OPW bonusing structures
|
||||
public:
|
||||
@@ -114,8 +129,9 @@ public:
|
||||
void setProperty(ui8 what, ui32 val) override;
|
||||
void onHeroVisit (const CGHeroInstance * h) const override;
|
||||
|
||||
COPWBonus (BuildingID index, CGTownInstance *TOWN);
|
||||
COPWBonus (){ID = BuildingID::NONE; town = nullptr;};
|
||||
COPWBonus (BuildingID index, BuildingSubID::EBuildingSubID subId, CGTownInstance *TOWN);
|
||||
COPWBonus () {};
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & static_cast<CGTownBuilding&>(*this);
|
||||
@@ -133,7 +149,8 @@ public:
|
||||
void onHeroVisit (const CGHeroInstance * h) const override;
|
||||
|
||||
CTownBonus (BuildingID index, CGTownInstance *TOWN);
|
||||
CTownBonus (){ID = BuildingID::NONE; town = nullptr;};
|
||||
CTownBonus () {};
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & static_cast<CGTownBuilding&>(*this);
|
||||
@@ -231,6 +248,7 @@ public:
|
||||
void updateMoraleBonusFromArmy() override;
|
||||
void deserializationFix();
|
||||
void recreateBuildingsBonuses();
|
||||
bool addBonusIfBuilt(BuildingSubID::EBuildingSubID building, Bonus::BonusType type, int val, int subtype = -1);
|
||||
bool addBonusIfBuilt(BuildingID building, Bonus::BonusType type, int val, TPropagatorPtr &prop, int subtype = -1); //returns true if building is built and bonus has been added
|
||||
bool addBonusIfBuilt(BuildingID building, Bonus::BonusType type, int val, int subtype = -1); //convienence version of above
|
||||
void setVisitingHero(CGHeroInstance *h);
|
||||
@@ -262,9 +280,13 @@ public:
|
||||
GrowthInfo getGrowthInfo(int level) const;
|
||||
bool hasFort() const;
|
||||
bool hasCapitol() const;
|
||||
const CGTownBuilding * getBonusingBuilding(BuildingSubID::EBuildingSubID subId) const;
|
||||
//checks if special building with type buildingID is constructed
|
||||
bool hasBuilt(BuildingSubID::EBuildingSubID buildingID) const;
|
||||
//checks if building is constructed and town has same subID
|
||||
bool hasBuilt(BuildingID buildingID) const;
|
||||
bool hasBuilt(BuildingID buildingID, int townID) const;
|
||||
|
||||
TResources getBuildingCost(BuildingID buildingID) const;
|
||||
TResources dailyIncome() const; //calculates daily income of this town
|
||||
int spellsAtLevel(int level, bool checkGuild) const; //levels are counted from 1 (1 - 5)
|
||||
@@ -276,7 +298,8 @@ public:
|
||||
void mergeGarrisonOnSiege() const; // merge garrison into army of visiting hero
|
||||
void removeCapitols (PlayerColor owner) const;
|
||||
void clearArmy() const;
|
||||
void addHeroToStructureVisitors(const CGHeroInstance *h, si32 structureInstanceID) const; //hero must be visiting or garrisoned in town
|
||||
void addHeroToStructureVisitors(const CGHeroInstance *h, si64 structureInstanceID) const; //hero must be visiting or garrisoned in town
|
||||
bool townEnvisagesSpecialBuilding(BuildingSubID::EBuildingSubID bid) const;
|
||||
|
||||
const CTown * getTown() const ;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user