1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

Split CTownHandler into smaller chunks

This commit is contained in:
Ivan Savenko 2024-07-21 10:49:40 +00:00
parent 4533271692
commit 4aa73b40c9
91 changed files with 923 additions and 783 deletions

View File

@ -12,6 +12,7 @@
#include "../../lib/ArtifactUtils.h"
#include "../../lib/UnlockGuard.h"
#include "../../lib/StartInfo.h"
#include "../../lib/entities/building/CBuilding.h"
#include "../../lib/mapObjects/MapObjects.h"
#include "../../lib/mapObjects/ObjectTemplate.h"
#include "../../lib/mapObjects/CGHeroInstance.h"

View File

@ -16,9 +16,7 @@
#include "../../lib/CThreadHelper.h"
#include "../../lib/GameConstants.h"
#include "../../lib/VCMI_Lib.h"
#include "../../lib/CBuildingHandler.h"
#include "../../lib/CCreatureHandler.h"
#include "../../lib/CTownHandler.h"
#include "../../lib/mapObjects/MiscObjects.h"
#include "../../lib/spells/CSpellHandler.h"
#include "Pathfinding/AIPathfinder.h"

View File

@ -40,9 +40,7 @@
/*********************** TBB.h ********************/
#include "../../lib/VCMI_Lib.h"
#include "../../lib/CBuildingHandler.h"
#include "../../lib/CCreatureHandler.h"
#include "../../lib/CTownHandler.h"
#include "../../lib/spells/CSpellHandler.h"
#include "../../lib/CStopWatch.h"
#include "../../lib/mapObjects/CGHeroInstance.h"

View File

@ -14,8 +14,6 @@
#include "../../../lib/GameConstants.h"
#include "../../../lib/VCMI_Lib.h"
#include "../../../lib/CTownHandler.h"
#include "../../../lib/CBuildingHandler.h"
namespace NKAI
{

View File

@ -10,6 +10,7 @@
#include "../StdInc.h"
#include "../Engine/Nullkiller.h"
#include "../Engine/Nullkiller.h"
#include "../../../lib/entities/building/CBuilding.h"
namespace NKAI
{

View File

@ -14,8 +14,6 @@
#include "../../../lib/GameConstants.h"
#include "../../../lib/VCMI_Lib.h"
#include "../../../lib/CTownHandler.h"
#include "../../../lib/CBuildingHandler.h"
namespace NKAI
{

View File

@ -12,7 +12,7 @@
#include "../AIGateway.h"
#include "../AIUtility.h"
#include "../../../lib/constants/StringConstants.h"
#include "../../../lib/entities/building/CBuilding.h"
namespace NKAI
{

View File

@ -13,8 +13,6 @@
#include "../../../lib/GameConstants.h"
#include "../../../lib/VCMI_Lib.h"
#include "../../../lib/CTownHandler.h"
#include "../../../lib/CBuildingHandler.h"
namespace NKAI
{

View File

@ -13,8 +13,6 @@
#include "../../../lib/GameConstants.h"
#include "../../../lib/VCMI_Lib.h"
#include "../../../lib/CTownHandler.h"
#include "../../../lib/CBuildingHandler.h"
#include "../Goals/AbstractGoal.h"
namespace NKAI

View File

@ -10,9 +10,7 @@
#pragma once
#include "../../lib/VCMI_Lib.h"
#include "../../lib/CBuildingHandler.h"
#include "../../lib/CCreatureHandler.h"
#include "../../lib/CTownHandler.h"
#include "../../lib/spells/CSpellHandler.h"
#include "../../lib/CStopWatch.h"
#include "../../lib/mapObjects/CGHeroInstance.h"

View File

@ -14,8 +14,6 @@
#include "../../lib/GameConstants.h"
#include "../../lib/VCMI_Lib.h"
#include "../../lib/CTownHandler.h"
#include "../../lib/CBuildingHandler.h"
#include "VCAI.h"
struct SlotInfo

View File

@ -13,6 +13,7 @@
#include "../../CCallback.h"
#include "../../lib/mapObjects/MapObjects.h"
#include "../../lib/entities/building/CBuilding.h"
bool BuildingManager::tryBuildThisStructure(const CGTownInstance * t, BuildingID building, unsigned int maxDays)
{

View File

@ -14,8 +14,6 @@
#include "../../lib/GameConstants.h"
#include "../../lib/VCMI_Lib.h"
#include "../../lib/CTownHandler.h"
#include "../../lib/CBuildingHandler.h"
#include "VCAI.h"
struct DLL_EXPORT PotentialBuilding

View File

@ -10,9 +10,7 @@
#pragma once
#include "../../../lib/VCMI_Lib.h"
#include "../../../lib/CBuildingHandler.h"
#include "../../../lib/CCreatureHandler.h"
#include "../../../lib/CTownHandler.h"
#include "../AIUtility.h"
struct HeroPtr;

View File

@ -17,6 +17,7 @@
#include "../BuildingManager.h"
#include "../../../lib/mapObjects/CGTownInstance.h"
#include "../../../lib/constants/StringConstants.h"
#include "../../../lib/entities/building/CBuilding.h"
using namespace Goals;

View File

@ -26,6 +26,7 @@
#include "../../lib/bonuses/Limiters.h"
#include "../../lib/bonuses/Updaters.h"
#include "../../lib/bonuses/Propagators.h"
#include "../../lib/entities/building/CBuilding.h"
#include "../../lib/networkPacks/PacksForClient.h"
#include "../../lib/networkPacks/PacksForClientBattle.h"
#include "../../lib/networkPacks/PacksForServer.h"

View File

@ -18,9 +18,7 @@
#include "../../lib/GameConstants.h"
#include "../../lib/VCMI_Lib.h"
#include "../../lib/CBuildingHandler.h"
#include "../../lib/CCreatureHandler.h"
#include "../../lib/CTownHandler.h"
#include "../../lib/mapObjects/MiscObjects.h"
#include "../../lib/spells/CSpellHandler.h"
#include "Pathfinding/AIPathfinder.h"

View File

@ -17,7 +17,6 @@
#include "lib/mapping/CMap.h"
#include "lib/mapObjects/CGHeroInstance.h"
#include "lib/mapObjects/CGTownInstance.h"
#include "lib/CBuildingHandler.h"
#include "lib/texts/CGeneralTextHandler.h"
#include "lib/CHeroHandler.h"
#include "lib/CArtHandler.h"

View File

@ -20,7 +20,6 @@ class CHeroHandler;
class CCreatureHandler;
class CSpellHandler;
class CSkillHandler;
class CBuildingHandler;
class CObjectHandler;
class CObjectClassesHandler;
class CTownHandler;

View File

@ -74,7 +74,6 @@
#include "../lib/CStack.h"
#include "../lib/CStopWatch.h"
#include "../lib/CThreadHelper.h"
#include "../lib/CTownHandler.h"
#include "../lib/GameConstants.h"
#include "../lib/RoadHandler.h"
#include "../lib/StartInfo.h"

View File

@ -53,7 +53,6 @@
#include "../../lib/gameState/InfoAboutArmy.h"
#include "../../lib/texts/CGeneralTextHandler.h"
#include "../../lib/texts/TextOperations.h"
#include "../../lib/CTownHandler.h"
#include "../../lib/CHeroHandler.h"
#include "../../lib/StartInfo.h"
#include "../../lib/mapObjects/CGTownInstance.h"

View File

@ -38,16 +38,18 @@
#include "../gui/Shortcut.h"
#include "../gui/WindowHandler.h"
#include "../../lib/CConfigHandler.h"
#include "../../lib/CCreatureHandler.h"
#include "../../lib/CHeroHandler.h"
#include "../../lib/CSkillHandler.h"
#include "../../lib/StartInfo.h"
#include "../../lib/entities/building/CBuilding.h"
#include "../../lib/entities/building/CBuildingHandler.h"
#include "../../lib/entities/faction/CFaction.h"
#include "../../lib/entities/faction/CTown.h"
#include "../../lib/entities/faction/CTownHandler.h"
#include "../../lib/filesystem/Filesystem.h"
#include "../../lib/texts/CGeneralTextHandler.h"
#include "../../lib/CConfigHandler.h"
#include "../../lib/CBuildingHandler.h"
#include "../../lib/CConfigHandler.h"
#include "../../lib/CSkillHandler.h"
#include "../../lib/CTownHandler.h"
#include "../../lib/CHeroHandler.h"
#include "../../lib/CCreatureHandler.h"
#include "../../lib/StartInfo.h"
#include "../../lib/campaign/CampaignState.h"
#include "../../lib/mapping/CMapService.h"

View File

@ -43,15 +43,17 @@
#include "../render/IFont.h"
#include "../render/IRenderHandler.h"
#include "../../lib/texts/CGeneralTextHandler.h"
#include "../../lib/CHeroHandler.h"
#include "../../lib/CTownHandler.h"
#include "../../lib/CRandomGenerator.h"
#include "../../lib/CThreadHelper.h"
#include "../../lib/filesystem/Filesystem.h"
#include "../../lib/mapping/CMapHeader.h"
#include "../../lib/mapping/CMapInfo.h"
#include "../../lib/networkPacks/PacksForLobby.h"
#include "../../lib/texts/CGeneralTextHandler.h"
#include "../../lib/entities/faction/CFaction.h"
#include "../../lib/entities/faction/CTown.h"
#include "../../lib/entities/faction/CTownHandler.h"
ISelectionScreenInfo::ISelectionScreenInfo(ESelectionScreen ScreenType)
: screenType(ScreenType)

View File

@ -34,12 +34,14 @@
#include "../windows/CHeroOverview.h"
#include "../eventsSDL/InputHandler.h"
#include "../../lib/entities/faction/CFaction.h"
#include "../../lib/entities/faction/CTown.h"
#include "../../lib/entities/faction/CTownHandler.h"
#include "../../lib/filesystem/Filesystem.h"
#include "../../lib/networkPacks/PacksForLobby.h"
#include "../../lib/texts/CGeneralTextHandler.h"
#include "../../lib/CArtHandler.h"
#include "../../lib/CConfigHandler.h"
#include "../../lib/CTownHandler.h"
#include "../../lib/CHeroHandler.h"
#include "../../lib/mapping/CMapInfo.h"
#include "../../lib/mapping/CMapHeader.h"

View File

@ -34,11 +34,9 @@
#include "../../lib/texts/CGeneralTextHandler.h"
#include "../../lib/CArtHandler.h"
#include "../../lib/CBuildingHandler.h"
#include "../../lib/spells/CSpellHandler.h"
#include "../../lib/CConfigHandler.h"
#include "../../lib/CSkillHandler.h"
#include "../../lib/CTownHandler.h"
#include "../../lib/CHeroHandler.h"
#include "../../lib/CCreatureHandler.h"

View File

@ -15,8 +15,10 @@
#include "../gui/CGuiHandler.h"
#include "../renderSDL/SDLRWwrapper.h"
#include "../../lib/entities/faction/CFaction.h"
#include "../../lib/entities/faction/CTown.h"
#include "../../lib/entities/faction/CTownHandler.h"
#include "../../lib/CRandomGenerator.h"
#include "../../lib/CTownHandler.h"
#include "../../lib/TerrainHandler.h"
#include "../../lib/filesystem/Filesystem.h"

View File

@ -28,8 +28,11 @@
#include "../CGameInfo.h"
#include "../../lib/ArtifactUtils.h"
#include "../../lib/CTownHandler.h"
#include "../../lib/CHeroHandler.h"
#include "../../lib/entities/building/CBuilding.h"
#include "../../lib/entities/faction/CFaction.h"
#include "../../lib/entities/faction/CTown.h"
#include "../../lib/entities/faction/CTownHandler.h"
#include "../../lib/networkPacks/Component.h"
#include "../../lib/spells/CSpellHandler.h"
#include "../../lib/CCreatureHandler.h"

View File

@ -32,8 +32,9 @@
#include "../../CCallback.h"
#include "../../lib/CConfigHandler.h"
#include "../../lib/gameState/InfoAboutArmy.h"
#include "../../lib/GameSettings.h"
#include "../../lib/entities/faction/CTownHandler.h"
#include "../../lib/gameState/InfoAboutArmy.h"
#include "../../lib/mapObjects/CGCreature.h"
#include "../../lib/mapObjects/CGHeroInstance.h"
#include "../../lib/mapObjects/CGTownInstance.h"

View File

@ -21,10 +21,12 @@
#include "../../../CCallback.h"
#include "../../../lib/texts/CGeneralTextHandler.h"
#include "../../../lib/entities/building/CBuilding.h"
#include "../../../lib/entities/faction/CTownHandler.h"
#include "../../../lib/mapObjects/CGHeroInstance.h"
#include "../../../lib/mapObjects/CGMarket.h"
#include "../../../lib/mapObjects/CGTownInstance.h"
#include "../../../lib/texts/CGeneralTextHandler.h"
CArtifactsBuying::CArtifactsBuying(const IMarket * market, const CGHeroInstance * hero)
: CMarketBase(market, hero)

View File

@ -22,10 +22,12 @@
#include "../../../CCallback.h"
#include "../../../lib/CArtifactInstance.h"
#include "../../../lib/texts/CGeneralTextHandler.h"
#include "../../../lib/entities/building/CBuilding.h"
#include "../../../lib/entities/faction/CTownHandler.h"
#include "../../../lib/mapObjects/CGHeroInstance.h"
#include "../../../lib/mapObjects/CGMarket.h"
#include "../../../lib/mapObjects/CGTownInstance.h"
#include "../../../lib/texts/CGeneralTextHandler.h"
CArtifactsSelling::CArtifactsSelling(const IMarket * market, const CGHeroInstance * hero)
: CMarketBase(market, hero)

View File

@ -42,17 +42,16 @@
#include "../../CCallback.h"
#include "../../lib/CArtHandler.h"
#include "../../lib/CBuildingHandler.h"
#include "../../lib/CConfigHandler.h"
#include "../../lib/CSoundBase.h"
#include "../../lib/CCreatureHandler.h"
#include "../../lib/texts/CGeneralTextHandler.h"
#include "../../lib/GameSettings.h"
#include "../../lib/spells/CSpellHandler.h"
#include "../../lib/CTownHandler.h"
#include "../../lib/GameConstants.h"
#include "../../lib/StartInfo.h"
#include "../../lib/campaign/CampaignState.h"
#include "../../lib/entities/building/CBuilding.h"
#include "../../lib/mapObjects/CGHeroInstance.h"
#include "../../lib/mapObjects/CGTownInstance.h"

View File

@ -37,7 +37,6 @@
#include "../../lib/CHeroHandler.h"
#include "../../lib/GameSettings.h"
#include "../../lib/CSkillHandler.h"
#include "../../lib/CTownHandler.h"
#include "../../lib/mapObjects/CGHeroInstance.h"
#include "../../lib/mapObjects/CGTownInstance.h"
#include "../../lib/mapObjects/MiscObjects.h"

View File

@ -23,8 +23,9 @@
#include "../widgets/TextControls.h"
#include "../../CCallback.h"
#include "../../lib/entities/faction/CFaction.h"
#include "../../lib/entities/faction/CTownHandler.h"
#include "../../lib/texts/CGeneralTextHandler.h"
#include "../../lib/CTownHandler.h"
#include "../../lib/StartInfo.h"
CPuzzleWindow::CPuzzleWindow(const int3 & GrailPos, double discoveredRatio)

View File

@ -41,6 +41,8 @@
#include "../../CCallback.h"
#include "../lib/entities/building/CBuilding.h"
#include "../lib/entities/faction/CTownHandler.h"
#include "../lib/mapObjectConstructors/CObjectClassesHandler.h"
#include "../lib/mapObjectConstructors/CommonConstructors.h"
#include "../lib/mapObjects/CGHeroInstance.h"

View File

@ -11,9 +11,10 @@
#include "CCreatureHandler.h"
#include "ResourceSet.h"
#include "entities/faction/CFaction.h"
#include "entities/faction/CTownHandler.h"
#include "filesystem/Filesystem.h"
#include "VCMI_Lib.h"
#include "CTownHandler.h"
#include "GameSettings.h"
#include "constants/StringConstants.h"
#include "bonuses/Limiters.h"

View File

@ -10,6 +10,7 @@
#include "StdInc.h"
#include "CGameInfoCallback.h"
#include "entities/building/CBuilding.h"
#include "gameState/CGameState.h"
#include "gameState/InfoAboutArmy.h"
#include "gameState/SThievesGuildInfo.h"

View File

@ -16,11 +16,13 @@
#include "battle/BattleHex.h"
#include "CCreatureHandler.h"
#include "GameSettings.h"
#include "CTownHandler.h"
#include "CSkillHandler.h"
#include "BattleFieldHandler.h"
#include "bonuses/Limiters.h"
#include "bonuses/Updaters.h"
#include "entities/faction/CFaction.h"
#include "entities/faction/CTown.h"
#include "entities/faction/CTownHandler.h"
#include "json/JsonBonus.h"
#include "json/JsonUtils.h"
#include "mapObjectConstructors/AObjectTypeHandler.h"

View File

@ -81,6 +81,12 @@ set(lib_MAIN_SRCS
constants/EntityIdentifiers.cpp
entities/building/CBuilding.cpp
entities/building/CBuildingHandler.cpp
entities/faction/CFaction.cpp
entities/faction/CTown.cpp
entities/faction/CTownHandler.cpp
events/ApplyDamage.cpp
events/GameResumed.cpp
events/ObjectVisitEnded.cpp
@ -254,7 +260,6 @@ set(lib_MAIN_SRCS
CArtHandler.cpp
CArtifactInstance.cpp
CBonusTypeHandler.cpp
CBuildingHandler.cpp
CCreatureHandler.cpp
CCreatureSet.cpp
CGameInfoCallback.cpp
@ -265,7 +270,6 @@ set(lib_MAIN_SRCS
CScriptingModule.cpp
CSkillHandler.cpp
CStack.cpp
CTownHandler.cpp
GameSettings.cpp
IGameCallback.cpp
IHandlerBase.cpp
@ -440,6 +444,12 @@ set(lib_MAIN_HEADERS
constants/NumericConstants.h
constants/StringConstants.h
entities/building/CBuilding.h
entities/building/CBuildingHandler.h
entities/faction/CFaction.h
entities/faction/CTown.h
entities/faction/CTownHandler.h
events/ApplyDamage.h
events/GameResumed.h
events/ObjectVisitEnded.h
@ -658,7 +668,6 @@ set(lib_MAIN_HEADERS
CArtHandler.h
CArtifactInstance.h
CBonusTypeHandler.h
CBuildingHandler.h
CCreatureHandler.h
CCreatureSet.h
CGameInfoCallback.h
@ -673,7 +682,6 @@ set(lib_MAIN_HEADERS
CSoundBase.h
CStack.h
CStopWatch.h
CTownHandler.h
ExceptionsCommon.h
ExtraOptionsInfo.h
FunctionList.h

View File

@ -1,358 +0,0 @@
/*
* CTownHandler.h, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
#pragma once
#include <vcmi/Faction.h>
#include <vcmi/FactionService.h>
#include "ConstTransitivePtr.h"
#include "ResourceSet.h"
#include "int3.h"
#include "GameConstants.h"
#include "IHandlerBase.h"
#include "LogicalExpression.h"
#include "battle/BattleHex.h"
#include "bonuses/Bonus.h"
#include "bonuses/BonusList.h"
#include "Point.h"
#include "rewardable/Info.h"
#include "filesystem/ResourcePath.h"
VCMI_LIB_NAMESPACE_BEGIN
class CLegacyConfigParser;
class JsonNode;
class CTown;
class CFaction;
struct BattleHex;
class JsonSerializeFormat;
/// a typical building encountered in every castle ;]
/// this is structure available to both client and server
/// contains all mechanics-related data about town structures
class DLL_LINKAGE CBuilding
{
std::string modScope;
std::string identifier;
public:
using TRequired = LogicalExpression<BuildingID>;
CTown * town; // town this building belongs to
TResources resources;
TResources produce;
TRequired requirements;
BuildingID bid; //structure ID
BuildingID upgrade; /// indicates that building "upgrade" can be improved by this, -1 = empty
BuildingSubID::EBuildingSubID subId; /// subtype for special buildings, -1 = the building is not special
std::set<BuildingID> overrideBids; /// the building which bonuses should be overridden with bonuses of the current building
BonusList buildingBonuses;
BonusList onVisitBonuses;
Rewardable::Info rewardableObjectInfo; ///configurable rewards for special buildings
enum EBuildMode
{
BUILD_NORMAL, // 0 - normal, default
BUILD_AUTO, // 1 - auto - building appears when all requirements are built
BUILD_SPECIAL, // 2 - special - building can not be built normally
BUILD_GRAIL // 3 - grail - building requires grail to be built
} mode;
enum ETowerHeight // for lookup towers and some grails
{
HEIGHT_NO_TOWER = 5, // building has not 'lookout tower' ability
HEIGHT_LOW = 10, // low lookout tower, but castle without lookout tower gives radius 5
HEIGHT_AVERAGE = 15,
HEIGHT_HIGH = 20, // such tower is in the Tower town
HEIGHT_SKYSHIP = std::numeric_limits<int>::max() // grail, open entire map
} height;
static const std::map<std::string, CBuilding::EBuildMode> MODES;
static const std::map<std::string, CBuilding::ETowerHeight> TOWER_TYPES;
CBuilding() : town(nullptr), mode(BUILD_NORMAL) {};
const BuildingTypeUniqueID getUniqueTypeID() const;
std::string getJsonKey() const;
std::string getNameTranslated() const;
std::string getDescriptionTranslated() const;
std::string getBaseTextID() const;
std::string getNameTextID() const;
std::string getDescriptionTextID() const;
//return base of upgrade(s) or this
BuildingID getBase() const;
// returns how many times build has to be upgraded to become build
si32 getDistance(const BuildingID & build) const;
STRONG_INLINE
bool IsTradeBuilding() const
{
return bid == BuildingID::MARKETPLACE || subId == BuildingSubID::ARTIFACT_MERCHANT || subId == BuildingSubID::FREELANCERS_GUILD;
}
STRONG_INLINE
bool IsWeekBonus() const
{
return subId == BuildingSubID::STABLES || subId == BuildingSubID::MANA_VORTEX;
}
STRONG_INLINE
bool IsVisitingBonus() const
{
return subId == BuildingSubID::ATTACK_VISITING_BONUS ||
subId == BuildingSubID::DEFENSE_VISITING_BONUS ||
subId == BuildingSubID::SPELL_POWER_VISITING_BONUS ||
subId == BuildingSubID::KNOWLEDGE_VISITING_BONUS ||
subId == BuildingSubID::EXPERIENCE_VISITING_BONUS ||
subId == BuildingSubID::CUSTOM_VISITING_BONUS;
}
void addNewBonus(const std::shared_ptr<Bonus> & b, BonusList & bonusList) const;
friend class CTownHandler;
};
/// This is structure used only by client
/// Consists of all gui-related data about town structures
/// 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"
int3 pos;
AnimationPath defName;
ImagePath borderName;
ImagePath areaName;
std::string identifier;
bool hiddenUpgrade; // used only if "building" is upgrade, if true - structure on town screen will behave exactly like parent (mouse clicks, hover texts, etc)
};
struct DLL_LINKAGE SPuzzleInfo
{
ui16 number; //type of puzzle
si16 x, y; //position
ui16 whenUncovered; //determines the sequence of discovering (the lesser it is the sooner puzzle will be discovered)
ImagePath filename; //file with graphic of this puzzle
};
class DLL_LINKAGE CFaction : public Faction
{
friend class CTownHandler;
friend class CBuilding;
friend class CTown;
std::string modScope;
std::string identifier;
FactionID index = FactionID::NEUTRAL;
FactionID getFaction() const override; //This function should not be used
public:
TerrainId nativeTerrain;
EAlignment alignment = EAlignment::NEUTRAL;
bool preferUndergroundPlacement = false;
bool special = false;
/// Boat that will be used by town shipyard (if any)
/// and for placing heroes directly on boat (in map editor, water prisons & taverns)
BoatId boatType = BoatId::CASTLE;
CTown * town = nullptr; //NOTE: can be null
ImagePath creatureBg120;
ImagePath creatureBg130;
std::vector<SPuzzleInfo> puzzleMap;
CFaction() = default;
~CFaction();
int32_t getIndex() const override;
int32_t getIconIndex() const override;
std::string getJsonKey() const override;
void registerIcons(const IconRegistar & cb) const override;
FactionID getId() const override;
std::string getNameTranslated() const override;
std::string getNameTextID() const override;
std::string getDescriptionTranslated() const;
std::string getDescriptionTextID() const;
bool hasTown() const override;
TerrainId getNativeTerrain() const override;
EAlignment getAlignment() const override;
BoatId getBoatType() const override;
void updateFrom(const JsonNode & data);
void serializeJson(JsonSerializeFormat & handler);
};
class DLL_LINKAGE CTown
{
friend class CTownHandler;
size_t namesCount = 0;
public:
CTown();
~CTown();
std::string getBuildingScope() const;
std::set<si32> getAllBuildings() const;
const CBuilding * getSpecialBuilding(BuildingSubID::EBuildingSubID subID) const;
std::string getGreeting(BuildingSubID::EBuildingSubID subID) const;
void setGreeting(BuildingSubID::EBuildingSubID subID, const std::string & message) const; //may affect only mutable field
BuildingID getBuildingType(BuildingSubID::EBuildingSubID subID) const;
std::string getRandomNameTextID(size_t index) const;
size_t getRandomNamesCount() const;
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::vector<std::string> dwellings; //defs for adventure map dwellings for new towns, [0] means tier 1 creatures etc.
std::vector<std::string> dwellingNames;
// should be removed at least from configs in favor of auto-detection
std::map<int,int> hordeLvl; //[0] - first horde building creature level; [1] - second horde building (-1 if not present)
ui32 mageLevel; //max available mage guild level
GameResID primaryRes;
ArtifactID warMachine;
SpellID moatAbility;
// default chance for hero of specific class to appear in tavern, if field "tavern" was not set
// resulting chance = sqrt(town.chance * heroClass.chance)
ui32 defaultTavernChance;
// Client-only data. Should be moved away from lib
struct ClientInfo
{
//icons [fort is present?][build limit reached?] -> index of icon in def files
int icons[2][2];
std::string iconSmall[2][2]; /// icon names used during loading
std::string iconLarge[2][2];
VideoPath tavernVideo;
std::vector<AudioPath> musicTheme;
ImagePath townBackground;
ImagePath guildBackground;
ImagePath guildWindow;
AnimationPath buildingsIcons;
ImagePath hallBackground;
/// vector[row][column] = list of buildings in this slot
std::vector< std::vector< std::vector<BuildingID> > > hallSlots;
/// 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::string siegePrefix;
std::vector<Point> siegePositions;
CreatureID siegeShooter; // shooter creature ID
std::string towerIconSmall;
std::string towerIconLarge;
} clientInfo;
private:
///generated bonusing buildings messages for all towns of this type.
mutable std::map<BuildingSubID::EBuildingSubID, const std::string> specialMessages; //may be changed by CGTownBuilding::getVisitingBonusGreeting() const
};
class DLL_LINKAGE CTownHandler : public CHandlerBase<FactionID, Faction, CFaction, FactionService>
{
struct BuildingRequirementsHelper
{
JsonNode json;
CBuilding * building;
CTown * town;
};
std::map<CTown *, JsonNode> warMachinesToLoad;
std::vector<BuildingRequirementsHelper> requirementsToLoad;
std::vector<BuildingRequirementsHelper> overriddenBidsToLoad; //list of buildings, which bonuses should be overridden.
static const TPropagatorPtr & emptyPropagator();
void initializeRequirements();
void initializeOverridden();
void initializeWarMachines();
/// loads CBuilding's into town
void loadBuildingRequirements(CBuilding * building, const JsonNode & source, std::vector<BuildingRequirementsHelper> & bidsToLoad) const;
void loadBuilding(CTown * town, const std::string & stringID, const JsonNode & source);
void loadBuildings(CTown * town, const JsonNode & source);
std::shared_ptr<Bonus> createBonus(CBuilding * build, BonusType type, int val) const;
std::shared_ptr<Bonus> createBonus(CBuilding * build, BonusType type, int val, BonusSubtypeID subtype) const;
std::shared_ptr<Bonus> createBonus(CBuilding * build, BonusType type, int val, BonusSubtypeID subtype, const TPropagatorPtr & prop) const;
/// loads CStructure's into town
void loadStructure(CTown & town, const std::string & stringID, const JsonNode & source) const;
void loadStructures(CTown & town, const JsonNode & source) const;
/// loads town hall vector (hallSlots)
void loadTownHall(CTown & town, const JsonNode & source) const;
void loadSiegeScreen(CTown & town, const JsonNode & source) const;
void loadClientData(CTown & town, const JsonNode & source) const;
void loadTown(CTown * town, const JsonNode & source);
void loadPuzzle(CFaction & faction, const JsonNode & source) const;
void loadRandomFaction();
public:
template<typename R, typename K>
static R getMappedValue(const K key, const R defval, const std::map<K, R> & map, bool required = true);
template<typename R>
static R getMappedValue(const JsonNode & node, const R defval, const std::map<std::string, R> & map, bool required = true);
CTown * randomTown;
CFaction * randomFaction;
CTownHandler();
~CTownHandler();
std::vector<JsonNode> loadLegacyData() override;
void loadObject(std::string scope, std::string name, const JsonNode & data) override;
void loadObject(std::string scope, std::string name, const JsonNode & data, size_t index) override;
void addBonusesForVanilaBuilding(CBuilding * building) const;
void loadCustom() override;
void afterLoadFinalization() override;
std::set<FactionID> getDefaultAllowed() const;
std::set<FactionID> getAllowedFactions(bool withTown = true) const;
static void loadSpecialBuildingBonuses(const JsonNode & source, BonusList & bonusList, CBuilding * building);
protected:
const std::vector<std::string> & getTypeNames() const override;
std::shared_ptr<CFaction> loadFromJson(const std::string & scope, const JsonNode & data, const std::string & identifier, size_t index) override;
};
VCMI_LIB_NAMESPACE_END

View File

@ -19,7 +19,7 @@
#include "bonuses/Limiters.h"
#include "bonuses/Propagators.h"
#include "bonuses/Updaters.h"
#include "entities/building/CBuilding.h"
#include "networkPacks/ArtifactLocation.h"
#include "serializer/CLoadFile.h"
#include "serializer/CSaveFile.h"

View File

@ -11,9 +11,10 @@
#include "StartInfo.h"
#include "texts/CGeneralTextHandler.h"
#include "CTownHandler.h"
#include "CHeroHandler.h"
#include "VCMI_Lib.h"
#include "entities/faction/CFaction.h"
#include "entities/faction/CTownHandler.h"
#include "rmg/CMapGenOptions.h"
#include "mapping/CMapInfo.h"
#include "campaign/CampaignState.h"

View File

@ -15,15 +15,14 @@
#include "CBonusTypeHandler.h"
#include "CCreatureHandler.h"
#include "CHeroHandler.h"
#include "CTownHandler.h"
#include "CConfigHandler.h"
#include "RoadHandler.h"
#include "RiverHandler.h"
#include "TerrainHandler.h"
#include "CBuildingHandler.h"
#include "spells/CSpellHandler.h"
#include "spells/effects/Registry.h"
#include "CSkillHandler.h"
#include "entities/faction/CTownHandler.h"
#include "texts/CGeneralTextHandler.h"
#include "modding/CModHandler.h"
#include "modding/CModInfo.h"

View File

@ -20,7 +20,6 @@ class CHeroClassHandler;
class CCreatureHandler;
class CSpellHandler;
class CSkillHandler;
class CBuildingHandler;
class CObjectHandler;
class CObjectClassesHandler;
class ObstacleSetHandler;

View File

@ -10,7 +10,6 @@
#include "StdInc.h"
#include "CObstacleInstance.h"
#include "../CHeroHandler.h"
#include "../CTownHandler.h"
#include "../ObstacleHandler.h"
#include "../VCMI_Lib.h"

View File

@ -19,7 +19,6 @@
#include "../CCreatureHandler.h"
#include "../CCreatureSet.h"
#include "../CHeroHandler.h"
#include "../CTownHandler.h"
#include "../texts/CGeneralTextHandler.h"
#include "../CSkillHandler.h"
#include "../CArtHandler.h"

View File

@ -12,11 +12,12 @@
#include "Limiters.h"
#include "../VCMI_Lib.h"
#include "../entities/faction/CFaction.h"
#include "../entities/faction/CTownHandler.h"
#include "../spells/CSpellHandler.h"
#include "../CCreatureHandler.h"
#include "../CCreatureSet.h"
#include "../CHeroHandler.h"
#include "../CTownHandler.h"
#include "../texts/CGeneralTextHandler.h"
#include "../CSkillHandler.h"
#include "../CStack.h"

View File

@ -34,6 +34,7 @@
#include "CCreatureHandler.h"//todo: remove
#include "spells/CSpellHandler.h" //todo: remove
#include "CSkillHandler.h"//todo: remove
#include "entities/faction/CFaction.h"
#include "mapObjectConstructors/AObjectTypeHandler.h"
#include "constants/StringConstants.h"
#include "texts/CGeneralTextHandler.h"
@ -42,7 +43,6 @@
#include "RoadHandler.h"
#include "BattleFieldHandler.h"
#include "ObstacleHandler.h"
#include "CTownHandler.h"
#include "mapObjectConstructors/CObjectClassesHandler.h"
VCMI_LIB_NAMESPACE_BEGIN
@ -125,6 +125,25 @@ namespace GameConstants
#endif
}
BuildingTypeUniqueID::BuildingTypeUniqueID(FactionID factionID, BuildingID buildingID ):
BuildingTypeUniqueID(factionID.getNum() * 0x10000 + buildingID.getNum())
{
assert(factionID.getNum() >= 0);
assert(factionID.getNum() < 0x10000);
assert(buildingID.getNum() >= 0);
assert(buildingID.getNum() < 0x10000);
}
BuildingID BuildingTypeUniqueID::getBuilding() const
{
return BuildingID(getNum() % 0x10000);
}
FactionID BuildingTypeUniqueID::getFaction() const
{
return FactionID(getNum() / 0x10000);
}
int32_t IdentifierBase::resolveIdentifier(const std::string & entityType, const std::string identifier)
{
if (identifier.empty())

View File

@ -0,0 +1,101 @@
/*
* CBuilding.cpp, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
#include "StdInc.h"
#include "CBuilding.h"
#include "../../VCMI_Lib.h"
#include "../../texts/CGeneralTextHandler.h"
#include "../faction/CFaction.h"
#include "../faction/CTown.h"
VCMI_LIB_NAMESPACE_BEGIN
const std::map<std::string, CBuilding::EBuildMode> CBuilding::MODES =
{
{ "normal", CBuilding::BUILD_NORMAL },
{ "auto", CBuilding::BUILD_AUTO },
{ "special", CBuilding::BUILD_SPECIAL },
{ "grail", CBuilding::BUILD_GRAIL }
};
const std::map<std::string, CBuilding::ETowerHeight> CBuilding::TOWER_TYPES =
{
{ "low", CBuilding::HEIGHT_LOW },
{ "average", CBuilding::HEIGHT_AVERAGE },
{ "high", CBuilding::HEIGHT_HIGH },
{ "skyship", CBuilding::HEIGHT_SKYSHIP }
};
const BuildingTypeUniqueID CBuilding::getUniqueTypeID() const
{
return BuildingTypeUniqueID(town->faction->getId(), bid);
}
std::string CBuilding::getJsonKey() const
{
return modScope + ':' + identifier;
}
std::string CBuilding::getNameTranslated() const
{
return VLC->generaltexth->translate(getNameTextID());
}
std::string CBuilding::getDescriptionTranslated() const
{
return VLC->generaltexth->translate(getDescriptionTextID());
}
std::string CBuilding::getBaseTextID() const
{
return TextIdentifier("building", modScope, town->faction->identifier, identifier).get();
}
std::string CBuilding::getNameTextID() const
{
return TextIdentifier(getBaseTextID(), "name").get();
}
std::string CBuilding::getDescriptionTextID() const
{
return TextIdentifier(getBaseTextID(), "description").get();
}
BuildingID CBuilding::getBase() const
{
const CBuilding * build = this;
while (build->upgrade != BuildingID::NONE)
{
build = build->town->buildings.at(build->upgrade);
}
return build->bid;
}
si32 CBuilding::getDistance(const BuildingID & buildID) const
{
const CBuilding * build = town->buildings.at(buildID);
int distance = 0;
while (build->upgrade != BuildingID::NONE && build != this)
{
build = build->town->buildings.at(build->upgrade);
distance++;
}
if (build == this)
return distance;
return -1;
}
void CBuilding::addNewBonus(const std::shared_ptr<Bonus> & b, BonusList & bonusList) const
{
bonusList.push_back(b);
}
VCMI_LIB_NAMESPACE_END

View File

@ -0,0 +1,114 @@
/*
* CBuilding.h, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
#pragma once
#include "../../constants/EntityIdentifiers.h"
#include "../../LogicalExpression.h"
#include "../../ResourceSet.h"
#include "../../bonuses/BonusList.h"
#include "../../rewardable/Info.h"
VCMI_LIB_NAMESPACE_BEGIN
class CTown;
/// a typical building encountered in every castle ;]
/// this is structure available to both client and server
/// contains all mechanics-related data about town structures
class DLL_LINKAGE CBuilding
{
std::string modScope;
std::string identifier;
public:
using TRequired = LogicalExpression<BuildingID>;
CTown * town; // town this building belongs to
TResources resources;
TResources produce;
TRequired requirements;
BuildingID bid; //structure ID
BuildingID upgrade; /// indicates that building "upgrade" can be improved by this, -1 = empty
BuildingSubID::EBuildingSubID subId; /// subtype for special buildings, -1 = the building is not special
std::set<BuildingID> overrideBids; /// the building which bonuses should be overridden with bonuses of the current building
BonusList buildingBonuses;
BonusList onVisitBonuses;
Rewardable::Info rewardableObjectInfo; ///configurable rewards for special buildings
enum EBuildMode
{
BUILD_NORMAL, // 0 - normal, default
BUILD_AUTO, // 1 - auto - building appears when all requirements are built
BUILD_SPECIAL, // 2 - special - building can not be built normally
BUILD_GRAIL // 3 - grail - building requires grail to be built
} mode;
enum ETowerHeight // for lookup towers and some grails
{
HEIGHT_NO_TOWER = 5, // building has not 'lookout tower' ability
HEIGHT_LOW = 10, // low lookout tower, but castle without lookout tower gives radius 5
HEIGHT_AVERAGE = 15,
HEIGHT_HIGH = 20, // such tower is in the Tower town
HEIGHT_SKYSHIP = std::numeric_limits<int>::max() // grail, open entire map
} height;
static const std::map<std::string, CBuilding::EBuildMode> MODES;
static const std::map<std::string, CBuilding::ETowerHeight> TOWER_TYPES;
CBuilding() : town(nullptr), mode(BUILD_NORMAL) {};
const BuildingTypeUniqueID getUniqueTypeID() const;
std::string getJsonKey() const;
std::string getNameTranslated() const;
std::string getDescriptionTranslated() const;
std::string getBaseTextID() const;
std::string getNameTextID() const;
std::string getDescriptionTextID() const;
//return base of upgrade(s) or this
BuildingID getBase() const;
// returns how many times build has to be upgraded to become build
si32 getDistance(const BuildingID & build) const;
STRONG_INLINE
bool IsTradeBuilding() const
{
return bid == BuildingID::MARKETPLACE || subId == BuildingSubID::ARTIFACT_MERCHANT || subId == BuildingSubID::FREELANCERS_GUILD;
}
STRONG_INLINE
bool IsWeekBonus() const
{
return subId == BuildingSubID::STABLES || subId == BuildingSubID::MANA_VORTEX;
}
STRONG_INLINE
bool IsVisitingBonus() const
{
return subId == BuildingSubID::ATTACK_VISITING_BONUS ||
subId == BuildingSubID::DEFENSE_VISITING_BONUS ||
subId == BuildingSubID::SPELL_POWER_VISITING_BONUS ||
subId == BuildingSubID::KNOWLEDGE_VISITING_BONUS ||
subId == BuildingSubID::EXPERIENCE_VISITING_BONUS ||
subId == BuildingSubID::CUSTOM_VISITING_BONUS;
}
void addNewBonus(const std::shared_ptr<Bonus> & b, BonusList & bonusList) const;
friend class CTownHandler;
};
VCMI_LIB_NAMESPACE_END

View File

@ -81,5 +81,4 @@ BuildingID CBuildingHandler::campToERMU(int camp, FactionID townType, const std:
return BuildingID::NONE; //not found
}
VCMI_LIB_NAMESPACE_END

View File

@ -9,7 +9,7 @@
*/
#pragma once
#include "GameConstants.h"
#include "../../constants/EntityIdentifiers.h"
VCMI_LIB_NAMESPACE_BEGIN

View File

@ -0,0 +1,125 @@
/*
* CFaction.cpp, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
#include "StdInc.h"
#include "CFaction.h"
#include "CTown.h"
#include "../../VCMI_Lib.h"
#include "../../texts/CGeneralTextHandler.h"
VCMI_LIB_NAMESPACE_BEGIN
CFaction::~CFaction()
{
if (town)
{
delete town;
town = nullptr;
}
}
int32_t CFaction::getIndex() const
{
return index.getNum();
}
int32_t CFaction::getIconIndex() const
{
return index.getNum(); //???
}
std::string CFaction::getJsonKey() const
{
return modScope + ':' + identifier;
}
void CFaction::registerIcons(const IconRegistar & cb) const
{
if(town)
{
auto & info = town->clientInfo;
cb(info.icons[0][0], 0, "ITPT", info.iconLarge[0][0]);
cb(info.icons[0][1], 0, "ITPT", info.iconLarge[0][1]);
cb(info.icons[1][0], 0, "ITPT", info.iconLarge[1][0]);
cb(info.icons[1][1], 0, "ITPT", info.iconLarge[1][1]);
cb(info.icons[0][0] + 2, 0, "ITPA", info.iconSmall[0][0]);
cb(info.icons[0][1] + 2, 0, "ITPA", info.iconSmall[0][1]);
cb(info.icons[1][0] + 2, 0, "ITPA", info.iconSmall[1][0]);
cb(info.icons[1][1] + 2, 0, "ITPA", info.iconSmall[1][1]);
cb(index.getNum(), 1, "CPRSMALL", info.towerIconSmall);
cb(index.getNum(), 1, "TWCRPORT", info.towerIconLarge);
}
}
std::string CFaction::getNameTranslated() const
{
return VLC->generaltexth->translate(getNameTextID());
}
std::string CFaction::getNameTextID() const
{
return TextIdentifier("faction", modScope, identifier, "name").get();
}
std::string CFaction::getDescriptionTranslated() const
{
return VLC->generaltexth->translate(getDescriptionTextID());
}
std::string CFaction::getDescriptionTextID() const
{
return TextIdentifier("faction", modScope, identifier, "description").get();
}
FactionID CFaction::getId() const
{
return FactionID(index);
}
FactionID CFaction::getFaction() const
{
return FactionID(index);
}
bool CFaction::hasTown() const
{
return town != nullptr;
}
EAlignment CFaction::getAlignment() const
{
return alignment;
}
BoatId CFaction::getBoatType() const
{
return boatType;
}
TerrainId CFaction::getNativeTerrain() const
{
return nativeTerrain;
}
void CFaction::updateFrom(const JsonNode & data)
{
}
void CFaction::serializeJson(JsonSerializeFormat & handler)
{
}
VCMI_LIB_NAMESPACE_END

View File

@ -0,0 +1,83 @@
/*
* CFaction.h, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
#pragma once
#include <vcmi/Faction.h>
#include "../../constants/EntityIdentifiers.h"
#include "../../constants/Enumerations.h"
#include "../../filesystem/ResourcePath.h"
VCMI_LIB_NAMESPACE_BEGIN
class CTown;
struct DLL_LINKAGE SPuzzleInfo
{
ui16 number; //type of puzzle
si16 x, y; //position
ui16 whenUncovered; //determines the sequence of discovering (the lesser it is the sooner puzzle will be discovered)
ImagePath filename; //file with graphic of this puzzle
};
class DLL_LINKAGE CFaction : public Faction
{
friend class CTownHandler;
friend class CBuilding;
friend class CTown;
std::string modScope;
std::string identifier;
FactionID index = FactionID::NEUTRAL;
FactionID getFaction() const override; //This function should not be used
public:
TerrainId nativeTerrain;
EAlignment alignment = EAlignment::NEUTRAL;
bool preferUndergroundPlacement = false;
bool special = false;
/// Boat that will be used by town shipyard (if any)
/// and for placing heroes directly on boat (in map editor, water prisons & taverns)
BoatId boatType = BoatId::CASTLE;
CTown * town = nullptr; //NOTE: can be null
ImagePath creatureBg120;
ImagePath creatureBg130;
std::vector<SPuzzleInfo> puzzleMap;
CFaction() = default;
~CFaction();
int32_t getIndex() const override;
int32_t getIconIndex() const override;
std::string getJsonKey() const override;
void registerIcons(const IconRegistar & cb) const override;
FactionID getId() const override;
std::string getNameTranslated() const override;
std::string getNameTextID() const override;
std::string getDescriptionTranslated() const;
std::string getDescriptionTextID() const;
bool hasTown() const override;
TerrainId getNativeTerrain() const override;
EAlignment getAlignment() const override;
BoatId getBoatType() const override;
void updateFrom(const JsonNode & data);
void serializeJson(JsonSerializeFormat & handler);
};
VCMI_LIB_NAMESPACE_END

View File

@ -0,0 +1,91 @@
/*
* CTownHandler.cpp, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
#include "StdInc.h"
#include "CTown.h"
#include "CFaction.h"
#include "CTownHandler.h"
#include "../building/CBuilding.h"
#include "../../texts/TextIdentifier.h"
VCMI_LIB_NAMESPACE_BEGIN
CTown::CTown()
: faction(nullptr), mageLevel(0), primaryRes(0), moatAbility(SpellID::NONE), defaultTavernChance(0)
{
}
CTown::~CTown()
{
for(auto & build : buildings)
build.second.dellNull();
for(auto & str : clientInfo.structures)
str.dellNull();
}
std::string CTown::getRandomNameTextID(size_t index) const
{
return TextIdentifier("faction", faction->modScope, faction->identifier, "randomName", index).get();
}
size_t CTown::getRandomNamesCount() const
{
return namesCount;
}
std::string CTown::getBuildingScope() const
{
if(faction == nullptr)
//no faction == random faction
return "building";
else
return "building." + faction->getJsonKey();
}
std::set<si32> CTown::getAllBuildings() const
{
std::set<si32> res;
for(const auto & b : buildings)
{
res.insert(b.first.num);
}
return res;
}
const CBuilding * CTown::getSpecialBuilding(BuildingSubID::EBuildingSubID subID) const
{
for(const auto & kvp : buildings)
{
if(kvp.second->subId == subID)
return buildings.at(kvp.first);
}
return nullptr;
}
BuildingID CTown::getBuildingType(BuildingSubID::EBuildingSubID subID) const
{
const auto * building = getSpecialBuilding(subID);
return building == nullptr ? BuildingID::NONE : building->bid.num;
}
std::string CTown::getGreeting(BuildingSubID::EBuildingSubID subID) const
{
return CTownHandler::getMappedValue<const std::string, BuildingSubID::EBuildingSubID>(subID, std::string(), specialMessages, false);
}
void CTown::setGreeting(BuildingSubID::EBuildingSubID subID, const std::string & message) const
{
specialMessages.insert(std::pair<BuildingSubID::EBuildingSubID, const std::string>(subID, message));
}
VCMI_LIB_NAMESPACE_END

View File

@ -0,0 +1,115 @@
/*
* CTown.h, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
#pragma once
#include "../../ConstTransitivePtr.h"
#include "../../Point.h"
#include "../../constants/EntityIdentifiers.h"
#include "../../constants/Enumerations.h"
#include "../../filesystem/ResourcePath.h"
#include "../../int3.h"
VCMI_LIB_NAMESPACE_BEGIN
class CBuilding;
/// This is structure used only by client
/// Consists of all gui-related data about town structures
/// 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"
int3 pos;
AnimationPath defName;
ImagePath borderName;
ImagePath areaName;
std::string identifier;
bool hiddenUpgrade; // used only if "building" is upgrade, if true - structure on town screen will behave exactly like parent (mouse clicks, hover texts, etc)
};
class DLL_LINKAGE CTown
{
friend class CTownHandler;
size_t namesCount = 0;
public:
CTown();
~CTown();
std::string getBuildingScope() const;
std::set<si32> getAllBuildings() const;
const CBuilding * getSpecialBuilding(BuildingSubID::EBuildingSubID subID) const;
std::string getGreeting(BuildingSubID::EBuildingSubID subID) const;
void setGreeting(BuildingSubID::EBuildingSubID subID, const std::string & message) const; //may affect only mutable field
BuildingID getBuildingType(BuildingSubID::EBuildingSubID subID) const;
std::string getRandomNameTextID(size_t index) const;
size_t getRandomNamesCount() const;
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::vector<std::string> dwellings; //defs for adventure map dwellings for new towns, [0] means tier 1 creatures etc.
std::vector<std::string> dwellingNames;
// should be removed at least from configs in favor of auto-detection
std::map<int,int> hordeLvl; //[0] - first horde building creature level; [1] - second horde building (-1 if not present)
ui32 mageLevel; //max available mage guild level
GameResID primaryRes;
ArtifactID warMachine;
SpellID moatAbility;
// default chance for hero of specific class to appear in tavern, if field "tavern" was not set
// resulting chance = sqrt(town.chance * heroClass.chance)
ui32 defaultTavernChance;
// Client-only data. Should be moved away from lib
struct ClientInfo
{
//icons [fort is present?][build limit reached?] -> index of icon in def files
int icons[2][2];
std::string iconSmall[2][2]; /// icon names used during loading
std::string iconLarge[2][2];
VideoPath tavernVideo;
std::vector<AudioPath> musicTheme;
ImagePath townBackground;
ImagePath guildBackground;
ImagePath guildWindow;
AnimationPath buildingsIcons;
ImagePath hallBackground;
/// vector[row][column] = list of buildings in this slot
std::vector< std::vector< std::vector<BuildingID> > > hallSlots;
/// 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::string siegePrefix;
std::vector<Point> siegePositions;
CreatureID siegeShooter; // shooter creature ID
std::string towerIconSmall;
std::string towerIconLarge;
} clientInfo;
private:
///generated bonusing buildings messages for all towns of this type.
mutable std::map<BuildingSubID::EBuildingSubID, const std::string> specialMessages; //may be changed by CGTownBuilding::getVisitingBonusGreeting() const
};
VCMI_LIB_NAMESPACE_END

View File

@ -10,307 +10,31 @@
#include "StdInc.h"
#include "CTownHandler.h"
#include "VCMI_Lib.h"
#include "constants/StringConstants.h"
#include "CCreatureHandler.h"
#include "CHeroHandler.h"
#include "CArtHandler.h"
#include "GameSettings.h"
#include "TerrainHandler.h"
#include "spells/CSpellHandler.h"
#include "filesystem/Filesystem.h"
#include "bonuses/Bonus.h"
#include "bonuses/Propagators.h"
#include "json/JsonBonus.h"
#include "ResourceSet.h"
#include "mapObjectConstructors/AObjectTypeHandler.h"
#include "mapObjectConstructors/CObjectClassesHandler.h"
#include "modding/IdentifierStorage.h"
#include "modding/ModScope.h"
#include "texts/CGeneralTextHandler.h"
#include "texts/CLegacyConfigParser.h"
#include "CTown.h"
#include "CFaction.h"
#include "../building/CBuilding.h"
#include "../../CCreatureHandler.h"
#include "../../CHeroHandler.h"
#include "../../GameSettings.h"
#include "../../TerrainHandler.h"
#include "../../VCMI_Lib.h"
#include "../../bonuses/Propagators.h"
#include "../../constants/StringConstants.h"
#include "../../mapObjectConstructors/AObjectTypeHandler.h"
#include "../../mapObjectConstructors/CObjectClassesHandler.h"
#include "../../modding/IdentifierStorage.h"
#include "../../modding/ModScope.h"
#include "../../spells/CSpellHandler.h"
#include "../../texts/CGeneralTextHandler.h"
#include "../../texts/CLegacyConfigParser.h"
#include "../../json/JsonBonus.h"
VCMI_LIB_NAMESPACE_BEGIN
const int NAMES_PER_TOWN=16; // number of town names per faction in H3 files. Json can define any number
const std::map<std::string, CBuilding::EBuildMode> CBuilding::MODES =
{
{ "normal", CBuilding::BUILD_NORMAL },
{ "auto", CBuilding::BUILD_AUTO },
{ "special", CBuilding::BUILD_SPECIAL },
{ "grail", CBuilding::BUILD_GRAIL }
};
const std::map<std::string, CBuilding::ETowerHeight> CBuilding::TOWER_TYPES =
{
{ "low", CBuilding::HEIGHT_LOW },
{ "average", CBuilding::HEIGHT_AVERAGE },
{ "high", CBuilding::HEIGHT_HIGH },
{ "skyship", CBuilding::HEIGHT_SKYSHIP }
};
BuildingTypeUniqueID::BuildingTypeUniqueID(FactionID factionID, BuildingID buildingID ):
BuildingTypeUniqueID(factionID.getNum() * 0x10000 + buildingID.getNum())
{
assert(factionID.getNum() >= 0);
assert(factionID.getNum() < 0x10000);
assert(buildingID.getNum() >= 0);
assert(buildingID.getNum() < 0x10000);
}
BuildingID BuildingTypeUniqueID::getBuilding() const
{
return BuildingID(getNum() % 0x10000);
}
FactionID BuildingTypeUniqueID::getFaction() const
{
return FactionID(getNum() / 0x10000);
}
const BuildingTypeUniqueID CBuilding::getUniqueTypeID() const
{
return BuildingTypeUniqueID(town->faction->getId(), bid);
}
std::string CBuilding::getJsonKey() const
{
return modScope + ':' + identifier;
}
std::string CBuilding::getNameTranslated() const
{
return VLC->generaltexth->translate(getNameTextID());
}
std::string CBuilding::getDescriptionTranslated() const
{
return VLC->generaltexth->translate(getDescriptionTextID());
}
std::string CBuilding::getBaseTextID() const
{
return TextIdentifier("building", modScope, town->faction->identifier, identifier).get();
}
std::string CBuilding::getNameTextID() const
{
return TextIdentifier(getBaseTextID(), "name").get();
}
std::string CBuilding::getDescriptionTextID() const
{
return TextIdentifier(getBaseTextID(), "description").get();
}
BuildingID CBuilding::getBase() const
{
const CBuilding * build = this;
while (build->upgrade != BuildingID::NONE)
{
build = build->town->buildings.at(build->upgrade);
}
return build->bid;
}
si32 CBuilding::getDistance(const BuildingID & buildID) const
{
const CBuilding * build = town->buildings.at(buildID);
int distance = 0;
while (build->upgrade != BuildingID::NONE && build != this)
{
build = build->town->buildings.at(build->upgrade);
distance++;
}
if (build == this)
return distance;
return -1;
}
void CBuilding::addNewBonus(const std::shared_ptr<Bonus> & b, BonusList & bonusList) const
{
bonusList.push_back(b);
}
CFaction::~CFaction()
{
if (town)
{
delete town;
town = nullptr;
}
}
int32_t CFaction::getIndex() const
{
return index.getNum();
}
int32_t CFaction::getIconIndex() const
{
return index.getNum(); //???
}
std::string CFaction::getJsonKey() const
{
return modScope + ':' + identifier;
}
void CFaction::registerIcons(const IconRegistar & cb) const
{
if(town)
{
auto & info = town->clientInfo;
cb(info.icons[0][0], 0, "ITPT", info.iconLarge[0][0]);
cb(info.icons[0][1], 0, "ITPT", info.iconLarge[0][1]);
cb(info.icons[1][0], 0, "ITPT", info.iconLarge[1][0]);
cb(info.icons[1][1], 0, "ITPT", info.iconLarge[1][1]);
cb(info.icons[0][0] + 2, 0, "ITPA", info.iconSmall[0][0]);
cb(info.icons[0][1] + 2, 0, "ITPA", info.iconSmall[0][1]);
cb(info.icons[1][0] + 2, 0, "ITPA", info.iconSmall[1][0]);
cb(info.icons[1][1] + 2, 0, "ITPA", info.iconSmall[1][1]);
cb(index.getNum(), 1, "CPRSMALL", info.towerIconSmall);
cb(index.getNum(), 1, "TWCRPORT", info.towerIconLarge);
}
}
std::string CFaction::getNameTranslated() const
{
return VLC->generaltexth->translate(getNameTextID());
}
std::string CFaction::getNameTextID() const
{
return TextIdentifier("faction", modScope, identifier, "name").get();
}
std::string CFaction::getDescriptionTranslated() const
{
return VLC->generaltexth->translate(getDescriptionTextID());
}
std::string CFaction::getDescriptionTextID() const
{
return TextIdentifier("faction", modScope, identifier, "description").get();
}
FactionID CFaction::getId() const
{
return FactionID(index);
}
FactionID CFaction::getFaction() const
{
return FactionID(index);
}
bool CFaction::hasTown() const
{
return town != nullptr;
}
EAlignment CFaction::getAlignment() const
{
return alignment;
}
BoatId CFaction::getBoatType() const
{
return boatType;
}
TerrainId CFaction::getNativeTerrain() const
{
return nativeTerrain;
}
void CFaction::updateFrom(const JsonNode & data)
{
}
void CFaction::serializeJson(JsonSerializeFormat & handler)
{
}
CTown::CTown()
: faction(nullptr), mageLevel(0), primaryRes(0), moatAbility(SpellID::NONE), defaultTavernChance(0)
{
}
CTown::~CTown()
{
for(auto & build : buildings)
build.second.dellNull();
for(auto & str : clientInfo.structures)
str.dellNull();
}
std::string CTown::getRandomNameTextID(size_t index) const
{
return TextIdentifier("faction", faction->modScope, faction->identifier, "randomName", index).get();
}
size_t CTown::getRandomNamesCount() const
{
return namesCount;
}
std::string CTown::getBuildingScope() const
{
if(faction == nullptr)
//no faction == random faction
return "building";
else
return "building." + faction->getJsonKey();
}
std::set<si32> CTown::getAllBuildings() const
{
std::set<si32> res;
for(const auto & b : buildings)
{
res.insert(b.first.num);
}
return res;
}
const CBuilding * CTown::getSpecialBuilding(BuildingSubID::EBuildingSubID subID) const
{
for(const auto & kvp : buildings)
{
if(kvp.second->subId == subID)
return buildings.at(kvp.first);
}
return nullptr;
}
BuildingID CTown::getBuildingType(BuildingSubID::EBuildingSubID subID) const
{
const auto * building = getSpecialBuilding(subID);
return building == nullptr ? BuildingID::NONE : building->bid.num;
}
std::string CTown::getGreeting(BuildingSubID::EBuildingSubID subID) const
{
return CTownHandler::getMappedValue<const std::string, BuildingSubID::EBuildingSubID>(subID, std::string(), specialMessages, false);
}
void CTown::setGreeting(BuildingSubID::EBuildingSubID subID, const std::string & message) const
{
specialMessages.insert(std::pair<BuildingSubID::EBuildingSubID, const std::string>(subID, message));
}
CTownHandler::CTownHandler():
randomTown(new CTown()),
randomFaction(new CFaction())
@ -516,27 +240,6 @@ void CTownHandler::loadBuildingRequirements(CBuilding * building, const JsonNode
bidsToLoad.push_back(hlp);
}
template<typename R, typename K>
R CTownHandler::getMappedValue(const K key, const R defval, const std::map<K, R> & map, bool required)
{
auto it = map.find(key);
if(it != map.end())
return it->second;
if(required)
logMod->warn("Warning: Property: '%s' is unknown. Correct the typo or update VCMI.", key);
return defval;
}
template<typename R>
R CTownHandler::getMappedValue(const JsonNode & node, const R defval, const std::map<std::string, R> & map, bool required)
{
if(!node.isNull() && node.getType() == JsonNode::JsonType::DATA_STRING)
return getMappedValue<R, std::string>(node.String(), defval, map, required);
return defval;
}
void CTownHandler::addBonusesForVanilaBuilding(CBuilding * building) const
{
std::shared_ptr<Bonus> b;
@ -1287,7 +990,6 @@ std::set<FactionID> CTownHandler::getAllowedFactions(bool withTown) const
result.insert(town->getId());
return result;
}
const std::vector<std::string> & CTownHandler::getTypeNames() const
@ -1296,5 +998,4 @@ const std::vector<std::string> & CTownHandler::getTypeNames() const
return typeNames;
}
VCMI_LIB_NAMESPACE_END

View File

@ -0,0 +1,122 @@
/*
* CTownHandler.h, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
#pragma once
#include <vcmi/FactionService.h>
#include "CFaction.h"
#include "../../IHandlerBase.h"
#include "../../bonuses/Bonus.h"
#include "../../constants/EntityIdentifiers.h"
#include "../../json/JsonNode.h"
VCMI_LIB_NAMESPACE_BEGIN
class CBuilding;
class CTown;
class DLL_LINKAGE CTownHandler : public CHandlerBase<FactionID, Faction, CFaction, FactionService>
{
struct BuildingRequirementsHelper
{
JsonNode json;
CBuilding * building;
CTown * town;
};
std::map<CTown *, JsonNode> warMachinesToLoad;
std::vector<BuildingRequirementsHelper> requirementsToLoad;
std::vector<BuildingRequirementsHelper> overriddenBidsToLoad; //list of buildings, which bonuses should be overridden.
static const TPropagatorPtr & emptyPropagator();
void initializeRequirements();
void initializeOverridden();
void initializeWarMachines();
/// loads CBuilding's into town
void loadBuildingRequirements(CBuilding * building, const JsonNode & source, std::vector<BuildingRequirementsHelper> & bidsToLoad) const;
void loadBuilding(CTown * town, const std::string & stringID, const JsonNode & source);
void loadBuildings(CTown * town, const JsonNode & source);
std::shared_ptr<Bonus> createBonus(CBuilding * build, BonusType type, int val) const;
std::shared_ptr<Bonus> createBonus(CBuilding * build, BonusType type, int val, BonusSubtypeID subtype) const;
std::shared_ptr<Bonus> createBonus(CBuilding * build, BonusType type, int val, BonusSubtypeID subtype, const TPropagatorPtr & prop) const;
/// loads CStructure's into town
void loadStructure(CTown & town, const std::string & stringID, const JsonNode & source) const;
void loadStructures(CTown & town, const JsonNode & source) const;
/// loads town hall vector (hallSlots)
void loadTownHall(CTown & town, const JsonNode & source) const;
void loadSiegeScreen(CTown & town, const JsonNode & source) const;
void loadClientData(CTown & town, const JsonNode & source) const;
void loadTown(CTown * town, const JsonNode & source);
void loadPuzzle(CFaction & faction, const JsonNode & source) const;
void loadRandomFaction();
public:
template<typename R, typename K>
static R getMappedValue(const K key, const R defval, const std::map<K, R> & map, bool required = true);
template<typename R>
static R getMappedValue(const JsonNode & node, const R defval, const std::map<std::string, R> & map, bool required = true);
CTown * randomTown;
CFaction * randomFaction;
CTownHandler();
~CTownHandler();
std::vector<JsonNode> loadLegacyData() override;
void loadObject(std::string scope, std::string name, const JsonNode & data) override;
void loadObject(std::string scope, std::string name, const JsonNode & data, size_t index) override;
void addBonusesForVanilaBuilding(CBuilding * building) const;
void loadCustom() override;
void afterLoadFinalization() override;
std::set<FactionID> getDefaultAllowed() const;
std::set<FactionID> getAllowedFactions(bool withTown = true) const;
static void loadSpecialBuildingBonuses(const JsonNode & source, BonusList & bonusList, CBuilding * building);
protected:
const std::vector<std::string> & getTypeNames() const override;
std::shared_ptr<CFaction> loadFromJson(const std::string & scope, const JsonNode & data, const std::string & identifier, size_t index) override;
};
template<typename R, typename K>
R CTownHandler::getMappedValue(const K key, const R defval, const std::map<K, R> & map, bool required)
{
auto it = map.find(key);
if(it != map.end())
return it->second;
if(required)
logMod->warn("Warning: Property: '%s' is unknown. Correct the typo or update VCMI.", key);
return defval;
}
template<typename R>
R CTownHandler::getMappedValue(const JsonNode & node, const R defval, const std::map<std::string, R> & map, bool required)
{
if(!node.isNull() && node.getType() == JsonNode::JsonType::DATA_STRING)
return getMappedValue<R, std::string>(node.String(), defval, map, required);
return defval;
}
VCMI_LIB_NAMESPACE_END

View File

@ -17,7 +17,6 @@
#include "SThievesGuildInfo.h"
#include "../ArtifactUtils.h"
#include "../CBuildingHandler.h"
#include "../texts/CGeneralTextHandler.h"
#include "../CHeroHandler.h"
#include "../CPlayerState.h"
@ -30,6 +29,7 @@
#include "../battle/BattleInfo.h"
#include "../campaign/CampaignState.h"
#include "../constants/StringConstants.h"
#include "../entities/faction/CTownHandler.h"
#include "../filesystem/ResourcePath.h"
#include "../json/JsonBonus.h"
#include "../json/JsonUtils.h"

View File

@ -14,6 +14,8 @@
#include "QuestInfo.h"
#include "../campaign/CampaignState.h"
#include "../entities/building/CBuilding.h"
#include "../entities/building/CBuildingHandler.h"
#include "../mapping/CMapEditManager.h"
#include "../mapObjects/CGHeroInstance.h"
#include "../mapObjects/CGTownInstance.h"
@ -21,7 +23,6 @@
#include "../mapObjectConstructors/AObjectTypeHandler.h"
#include "../mapObjectConstructors/CObjectClassesHandler.h"
#include "../StartInfo.h"
#include "../CBuildingHandler.h"
#include "../CHeroHandler.h"
#include "../mapping/CMap.h"
#include "../ArtifactUtils.h"

View File

@ -12,13 +12,13 @@
#include "../texts/CGeneralTextHandler.h"
#include "../CHeroHandler.h"
#include "../CTownHandler.h"
#include "../IGameCallback.h"
#include "../json/JsonRandom.h"
#include "../constants/StringConstants.h"
#include "../TerrainHandler.h"
#include "../VCMI_Lib.h"
#include "../entities/faction/CTownHandler.h"
#include "../mapObjects/CGHeroInstance.h"
#include "../mapObjects/CGMarket.h"
#include "../mapObjects/CGTownInstance.h"

View File

@ -11,11 +11,13 @@
#include "StdInc.h"
#include "CArmedInstance.h"
#include "../CTownHandler.h"
#include "../CCreatureHandler.h"
#include "../texts/CGeneralTextHandler.h"
#include "../gameState/CGameState.h"
#include "../CPlayerState.h"
#include "../entities/faction/CFaction.h"
#include "../entities/faction/CTown.h"
#include "../entities/faction/CTownHandler.h"
#include "../gameState/CGameState.h"
#include "../texts/CGeneralTextHandler.h"
VCMI_LIB_NAMESPACE_BEGIN

View File

@ -11,6 +11,7 @@
#include "StdInc.h"
#include "CGDwelling.h"
#include "../serializer/JsonSerializeFormat.h"
#include "../entities/faction/CTownHandler.h"
#include "../mapping/CMap.h"
#include "../mapObjectConstructors/AObjectTypeHandler.h"
#include "../mapObjectConstructors/CObjectClassesHandler.h"
@ -20,7 +21,6 @@
#include "../networkPacks/StackLocation.h"
#include "../networkPacks/PacksForClient.h"
#include "../networkPacks/PacksForClientBattle.h"
#include "../CTownHandler.h"
#include "../IGameCallback.h"
#include "../gameState/CGameState.h"
#include "../CPlayerState.h"

View File

@ -27,10 +27,10 @@
#include "../IGameCallback.h"
#include "../gameState/CGameState.h"
#include "../CCreatureHandler.h"
#include "../CTownHandler.h"
#include "../mapping/CMap.h"
#include "../StartInfo.h"
#include "CGTownInstance.h"
#include "../entities/faction/CTownHandler.h"
#include "../campaign/CampaignState.h"
#include "../json/JsonBonus.h"
#include "../pathfinder/TurnInfo.h"

View File

@ -16,6 +16,8 @@
#include "../gameState/CGameState.h"
#include "../mapObjects/CGHeroInstance.h"
#include "../networkPacks/PacksForClient.h"
#include "../entities/building/CBuilding.h"
#include <vstd/RNG.h>

View File

@ -22,6 +22,8 @@
#include "../CPlayerState.h"
#include "../StartInfo.h"
#include "../TerrainHandler.h"
#include "../entities/building/CBuilding.h"
#include "../entities/faction/CTownHandler.h"
#include "../mapObjectConstructors/AObjectTypeHandler.h"
#include "../mapObjectConstructors/CObjectClassesHandler.h"
#include "../mapObjects/CGHeroInstance.h"

View File

@ -12,8 +12,9 @@
#include "IMarket.h"
#include "CGDwelling.h"
#include "CGTownBuilding.h"
#include "../CTownHandler.h" // For CTown
#include "../LogicalExpression.h"
#include "../entities/faction/CFaction.h" // TODO: remove
#include "../entities/faction/CTown.h" // TODO: remove
VCMI_LIB_NAMESPACE_BEGIN
@ -177,7 +178,7 @@ public:
bool armedGarrison() const; //true if town has creatures in garrison or garrisoned hero
int getTownLevel() const;
CBuilding::TRequired genBuildingRequirements(const BuildingID & build, bool deep = false) const;
LogicalExpression<BuildingID> genBuildingRequirements(const BuildingID & build, bool deep = false) const;
void mergeGarrisonOnSiege() const; // merge garrison into army of visiting hero
void removeCapitols(const PlayerColor & owner) const;

View File

@ -13,7 +13,6 @@
#include "../CArtHandler.h"
#include "../VCMI_Lib.h"
#include "../CCreatureHandler.h"
#include "../CTownHandler.h"
#include "../CHeroHandler.h"
#include "../RiverHandler.h"
#include "../RoadHandler.h"

View File

@ -12,13 +12,13 @@
#include "MapFormat.h"
#include "../CHeroHandler.h"
#include "../VCMI_Lib.h"
#include "../CTownHandler.h"
#include "../texts/CGeneralTextHandler.h"
#include "../entities/faction/CTownHandler.h"
#include "../json/JsonUtils.h"
#include "../modding/CModHandler.h"
#include "../texts/CGeneralTextHandler.h"
#include "../texts/Languages.h"
#include "../CHeroHandler.h"
VCMI_LIB_NAMESPACE_BEGIN

View File

@ -18,11 +18,11 @@
#include "MapFormat.h"
#include "../ArtifactUtils.h"
#include "../CHeroHandler.h"
#include "../CTownHandler.h"
#include "../VCMI_Lib.h"
#include "../RiverHandler.h"
#include "../RoadHandler.h"
#include "../TerrainHandler.h"
#include "../entities/faction/CTownHandler.h"
#include "../mapObjectConstructors/AObjectTypeHandler.h"
#include "../mapObjectConstructors/CObjectClassesHandler.h"
#include "../mapObjects/ObjectTemplate.h"

View File

@ -12,8 +12,9 @@
#include "MapIdentifiersH3M.h"
#include "../VCMI_Lib.h"
#include "../CTownHandler.h"
#include "../CHeroHandler.h"
#include "../entities/faction/CFaction.h"
#include "../entities/faction/CTownHandler.h"
#include "../filesystem/Filesystem.h"
#include "../mapObjectConstructors/AObjectTypeHandler.h"
#include "../mapObjectConstructors/CObjectClassesHandler.h"

View File

@ -17,11 +17,11 @@
#include "../BattleFieldHandler.h"
#include "../CArtHandler.h"
#include "../CCreatureHandler.h"
#include "../entities/faction/CTownHandler.h"
#include "../texts/CGeneralTextHandler.h"
#include "../CHeroHandler.h"
#include "../CSkillHandler.h"
#include "../CStopWatch.h"
#include "../CTownHandler.h"
#include "../GameSettings.h"
#include "../IHandlerBase.h"
#include "../ObstacleHandler.h"

View File

@ -28,11 +28,11 @@
#include "gameState/TavernHeroesPool.h"
#include "CStack.h"
#include "battle/BattleInfo.h"
#include "CTownHandler.h"
#include "mapping/CMapInfo.h"
#include "StartInfo.h"
#include "CPlayerState.h"
#include "TerrainHandler.h"
#include "entities/building/CBuilding.h"
#include "mapObjects/CBank.h"
#include "mapObjects/CGCreature.h"
#include "mapObjects/CGMarket.h"

View File

@ -11,11 +11,12 @@
#include "StdInc.h"
#include "CMapGenOptions.h"
#include "../entities/faction/CTownHandler.h"
#include "../entities/faction/CFaction.h"
#include "../mapping/CMapHeader.h"
#include "CRmgTemplateStorage.h"
#include "CRmgTemplate.h"
#include "../VCMI_Lib.h"
#include "../CTownHandler.h"
#include "serializer/JsonSerializeFormat.h"
#include <vstd/RNG.h>

View File

@ -15,11 +15,12 @@
#include "../VCMI_Lib.h"
#include "../texts/CGeneralTextHandler.h"
#include "../CRandomGenerator.h"
#include "../entities/faction/CTownHandler.h"
#include "../entities/faction/CFaction.h"
#include "../mapObjectConstructors/AObjectTypeHandler.h"
#include "../mapObjectConstructors/CObjectClassesHandler.h"
#include "../mapping/CMapEditManager.h"
#include "../CArtHandler.h"
#include "../CTownHandler.h"
#include "../CHeroHandler.h"
#include "../constants/StringConstants.h"
#include "../filesystem/Filesystem.h"

View File

@ -14,12 +14,12 @@
#include "CRmgTemplate.h"
#include "Functions.h"
#include "../VCMI_Lib.h"
#include "../CTownHandler.h"
#include "../TerrainHandler.h"
#include "../serializer/JsonSerializeFormat.h"
#include "../modding/ModScope.h"
#include "../VCMI_Lib.h"
#include "../constants/StringConstants.h"
#include "../entities/faction/CTownHandler.h"
#include "../modding/ModScope.h"
#include "../serializer/JsonSerializeFormat.h"
VCMI_LIB_NAMESPACE_BEGIN

View File

@ -11,8 +11,9 @@
#include "StdInc.h"
#include "CZonePlacer.h"
#include "../CTownHandler.h"
#include "../TerrainHandler.h"
#include "../entities/faction/CFaction.h"
#include "../entities/faction/CTownHandler.h"
#include "../mapping/CMap.h"
#include "../mapping/CMapEditManager.h"
#include "../VCMI_Lib.h"

View File

@ -15,7 +15,6 @@
#include "TileInfo.h"
#include "RmgPath.h"
#include "../TerrainHandler.h"
#include "../CTownHandler.h"
#include "../mapping/CMap.h"
#include "../mapObjectConstructors/AObjectTypeHandler.h"
#include "../mapObjectConstructors/CObjectClassesHandler.h"

View File

@ -13,9 +13,9 @@
#include "TileInfo.h"
#include "CMapGenOptions.h"
#include "Zone.h"
#include "../entities/faction/CTownHandler.h"
#include "../mapping/CMapEditManager.h"
#include "../mapping/CMap.h"
#include "../CTownHandler.h"
#include "../VCMI_Lib.h"
#include "modificators/ObjectManager.h"
#include "modificators/RoadPlacer.h"

View File

@ -20,12 +20,12 @@
#include "../RmgMap.h"
#include "../CMapGenerator.h"
#include "../Functions.h"
#include "../../entities/faction/CFaction.h"
#include "../../mapping/CMapEditManager.h"
#include "../../mapping/CMap.h"
#include "../../mapping/ObstacleProxy.h"
#include "../../mapObjects/CGObjectInstance.h"
#include "../../mapObjects/ObstacleSetHandler.h"
#include "../../CTownHandler.h"
VCMI_LIB_NAMESPACE_BEGIN

View File

@ -20,7 +20,8 @@
#include "../RmgMap.h"
#include "../../VCMI_Lib.h"
#include "../../TerrainHandler.h"
#include "../../CTownHandler.h"
#include "../../entities/faction/CFaction.h"
#include "../../entities/faction/CTownHandler.h"
#include <vstd/RNG.h>

View File

@ -12,6 +12,7 @@
#include "TownPlacer.h"
#include "../CMapGenerator.h"
#include "../RmgMap.h"
#include "../../entities/faction/CTownHandler.h"
#include "../../mapObjectConstructors/AObjectTypeHandler.h"
#include "../../mapObjectConstructors/CObjectClassesHandler.h"
#include "../../mapObjects/CGTownInstance.h"

View File

@ -14,6 +14,7 @@
#include "Registry.h"
#include "../ISpellMechanics.h"
#include "../../entities/building/CBuilding.h"
#include "../../mapObjects/CGTownInstance.h"
#include "../../bonuses/Limiters.h"
#include "../../battle/IBattleState.h"

View File

@ -10,6 +10,8 @@
#include "StdInc.h"
#include "townbuildingswidget.h"
#include "ui_townbuildingswidget.h"
#include "../lib/entities/building/CBuilding.h"
#include "../lib/entities/faction/CTownHandler.h"
#include "../lib/texts/CGeneralTextHandler.h"
std::string defaultBuildingIdConversion(BuildingID bId)

View File

@ -20,7 +20,6 @@
#include "../lib/mapObjects/ObjectTemplate.h"
#include "../lib/mapObjects/MiscObjects.h"
#include "../lib/CHeroHandler.h"
#include "../lib/CTownHandler.h"
#include "../lib/GameConstants.h"
const int tileSize = 32;

View File

@ -13,7 +13,6 @@
#include "../mapcontroller.h"
#include "../../lib/mapObjects/CGHeroInstance.h"
#include "../../lib/mapObjects/CGCreature.h"
#include "../../lib/CTownHandler.h"
#include "../../lib/CHeroHandler.h"
#include "../../lib/mapObjects/CGCreature.h"

View File

@ -11,9 +11,11 @@
#include "victoryconditions.h"
#include "ui_victoryconditions.h"
#include "../mapcontroller.h"
#include "../lib/texts/CGeneralTextHandler.h"
#include "../lib/constants/StringConstants.h"
#include "../../lib/constants/StringConstants.h"
#include "../../lib/entities/faction/CTownHandler.h"
#include "../../lib/mapObjects/CGCreature.h"
#include "../../lib/texts/CGeneralTextHandler.h"
#include "../inspector/townbuildingswidget.h" //to convert BuildingID to string

View File

@ -12,9 +12,8 @@
#include "playerparams.h"
#include "ui_playerparams.h"
#include "mapsettings/abstractsettings.h"
#include "../lib/CTownHandler.h"
#include "../lib/constants/StringConstants.h"
#include "../lib/entities/faction/CTownHandler.h"
#include "../lib/mapping/CMap.h"
PlayerParams::PlayerParams(MapController & ctrl, int playerId, QWidget *parent) :

View File

@ -23,7 +23,6 @@
#include "../lib/ArtifactUtils.h"
#include "../lib/CArtHandler.h"
#include "../lib/CBuildingHandler.h"
#include "../lib/CConfigHandler.h"
#include "../lib/CCreatureHandler.h"
#include "../lib/CCreatureSet.h"
@ -33,7 +32,6 @@
#include "../lib/CRandomGenerator.h"
#include "../lib/CSoundBase.h"
#include "../lib/CThreadHelper.h"
#include "../lib/CTownHandler.h"
#include "../lib/GameConstants.h"
#include "../lib/UnlockGuard.h"
#include "../lib/GameSettings.h"
@ -45,20 +43,29 @@
#include "../lib/int3.h"
#include "../lib/battle/BattleInfo.h"
#include "../lib/entities/building/CBuilding.h"
#include "../lib/entities/faction/CTownHandler.h"
#include "../lib/filesystem/FileInfo.h"
#include "../lib/filesystem/Filesystem.h"
#include "../lib/gameState/CGameState.h"
#include "../lib/mapping/CMap.h"
#include "../lib/mapping/CMapService.h"
#include "../lib/mapObjects/CGCreature.h"
#include "../lib/mapObjects/CGMarket.h"
#include "../lib/mapObjects/CGTownInstance.h"
#include "../lib/mapObjects/MiscObjects.h"
#include "../lib/mapObjectConstructors/AObjectTypeHandler.h"
#include "../lib/mapObjectConstructors/CObjectClassesHandler.h"
#include "../lib/modding/ModIncompatibility.h"
#include "../lib/networkPacks/StackLocation.h"
#include "../lib/pathfinder/CPathfinder.h"
#include "../lib/pathfinder/PathfinderOptions.h"
#include "../lib/pathfinder/TurnInfo.h"

View File

@ -17,10 +17,11 @@
#include "../lib/CRandomGenerator.h"
#include "../lib/campaign/CampaignState.h"
#include "../lib/entities/faction/CTownHandler.h"
#include "../lib/entities/faction/CFaction.h"
#include "../lib/serializer/Connection.h"
#include "../lib/mapping/CMapInfo.h"
#include "../lib/mapping/CMapHeader.h"
#include "../lib/CTownHandler.h"
void ClientPermissionsCheckerNetPackVisitor::visitForLobby(CPackForLobby & pack)
{

View File

@ -19,6 +19,7 @@
#include "../../lib/CHeroHandler.h"
#include "../../lib/CPlayerState.h"
#include "../../lib/StartInfo.h"
#include "../../lib/entities/building/CBuilding.h"
#include "../../lib/gameState/CGameState.h"
#include "../../lib/mapObjects/CGTownInstance.h"
#include "../../lib/mapObjects/CGHeroInstance.h"

View File

@ -9,7 +9,8 @@
*/
#include "StdInc.h"
#include "../../lib/CTownHandler.h"
#include "../../lib/entities/faction/CTown.h"
#include "../../lib/entities/faction/CFaction.h"
namespace test
{