1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-27 22:49:25 +02:00

Merge branch 'develop' into randomize_optional_roads

This commit is contained in:
Tomasz Zieliński
2025-08-01 20:05:03 +02:00
1215 changed files with 124487 additions and 48895 deletions

View File

@@ -12,6 +12,7 @@
#include "../int3.h"
#include "../GameConstants.h"
#include "../Point.h"
#include "../ResourceSet.h"
#include "ObjectInfo.h"
#include "ObjectConfig.h"
@@ -21,6 +22,7 @@ VCMI_LIB_NAMESPACE_BEGIN
class JsonSerializeFormat;
struct CompoundMapObjectID;
class TemplateEditor;
enum class ETemplateZoneType
{
@@ -93,6 +95,10 @@ enum class ERoadOption
class DLL_LINKAGE ZoneConnection
{
#ifdef ENABLE_TEMPLATE_EDITOR
friend class ::TemplateEditor;
#endif
public:
ZoneConnection();
@@ -122,11 +128,18 @@ private:
class DLL_LINKAGE ZoneOptions
{
#ifdef ENABLE_TEMPLATE_EDITOR
friend class ::TemplateEditor;
#endif
public:
static const TRmgTemplateZoneId NO_ZONE;
class DLL_LINKAGE CTownInfo
{
#ifdef ENABLE_TEMPLATE_EDITOR
friend class ::TemplateEditor;
#endif
public:
CTownInfo();
@@ -144,7 +157,22 @@ public:
int castleDensity;
// TODO: Copy from another zone once its randomized
TRmgTemplateZoneId sourceZone = NO_ZONE;
TRmgTemplateZoneId townTypesLikeZone = NO_ZONE;
TRmgTemplateZoneId townTypesNotLikeZone = NO_ZONE;
TRmgTemplateZoneId townTypesRelatedToZoneTerrain = NO_ZONE;
};
class DLL_LINKAGE CTownHints
{
public:
CTownHints();
// TODO: Make private
TRmgTemplateZoneId likeZone = NO_ZONE;
std::vector<TRmgTemplateZoneId> notLikeZone;
TRmgTemplateZoneId relatedToZoneTerrain = NO_ZONE;
void serializeJson(JsonSerializeFormat & handler);
};
ZoneOptions();
@@ -164,12 +192,21 @@ public:
std::set<TerrainId> getDefaultTerrainTypes() const;
const CTownInfo & getPlayerTowns() const;
void setPlayerTowns(const CTownInfo & value);
const CTownInfo & getNeutralTowns() const;
std::set<FactionID> getDefaultTownTypes() const;
void setNeutralTowns(const CTownInfo & value);
bool isMatchTerrainToTown() const;
void setMatchTerrainToTown(bool value);
const std::vector<CTownHints> & getTownHints() const;
void setTownHints(const std::vector<CTownHints> & value);
std::set<FactionID> getTownTypes() const;
void setTownTypes(const std::set<FactionID> & value);
std::set<FactionID> getBannedTownTypes() const;
void setBannedTownTypes(const std::set<FactionID> & value);
std::set<FactionID> getDefaultTownTypes() const;
std::set<FactionID> getMonsterTypes() const;
void setTownTypes(const std::set<FactionID> & value);
void setMonsterTypes(const std::set<FactionID> & value);
void setMinesInfo(const std::map<TResource, ui16> & value);
@@ -198,7 +235,6 @@ public:
EMonsterStrength::EMonsterStrength monsterStrength;
bool areTownsSameType() const;
bool isMatchTerrainToTown() const;
// Get a group of configured objects
const std::vector<CompoundMapObjectID> & getBannedObjects() const;
@@ -208,7 +244,14 @@ public:
// Copy whole custom object config from another zone
ObjectConfig getCustomObjects() const;
void setCustomObjects(const ObjectConfig & value);
TRmgTemplateZoneId getCustomObjectsLikeZone() const;
TRmgTemplateZoneId getCustomObjectsLikeZone() const;
TRmgTemplateZoneId getTownsLikeZone() const;
Point getVisiblePosition() const;
void setVisiblePosition(Point value);
float getVisibleSize() const;
void setVisibleSize(float value);
protected:
TRmgTemplateZoneId id;
@@ -217,6 +260,9 @@ protected:
ui32 maxTreasureValue;
std::optional<int> owner;
Point visiblePosition;
float visibleSize;
ObjectConfig objectConfig;
CTownInfo playerTowns;
CTownInfo neutralTowns;
@@ -224,6 +270,7 @@ protected:
std::set<TerrainId> terrainTypes;
std::set<TerrainId> bannedTerrains;
bool townsAreSameType;
std::vector<CTownHints> townHints; // For every town present on map
std::set<FactionID> townTypes;
std::set<FactionID> bannedTownTypes;
@@ -237,6 +284,7 @@ protected:
std::vector<TRmgTemplateZoneId> connectedZoneIds; //list of adjacent zone ids
std::vector<ZoneConnection> connectionDetails; //list of connections linked to that zone
TRmgTemplateZoneId townsLikeZone;
TRmgTemplateZoneId minesLikeZone;
TRmgTemplateZoneId terrainTypeLikeZone;
TRmgTemplateZoneId treasureLikeZone;
@@ -248,11 +296,18 @@ protected:
/// The CRmgTemplate describes a random map template.
class DLL_LINKAGE CRmgTemplate : boost::noncopyable
{
#ifdef ENABLE_TEMPLATE_EDITOR
friend class ::TemplateEditor;
#endif
public:
using Zones = std::map<TRmgTemplateZoneId, std::shared_ptr<rmg::ZoneOptions>>;
class DLL_LINKAGE CPlayerCountRange
{
#ifdef ENABLE_TEMPLATE_EDITOR
friend class ::TemplateEditor;
#endif
public:
void addRange(int lower, int upper);
void addNumber(int value);
@@ -289,6 +344,11 @@ public:
const JsonNode & getMapSettings() const;
const std::vector<rmg::ZoneConnection> & getConnectedZoneIds() const;
const std::set<SpellID> & getBannedSpells() const { return bannedSpells; }
const std::set<ArtifactID> & getBannedArtifacts() const { return bannedArtifacts; }
const std::set<SecondarySkill> & getBannedSkills() const { return bannedSkills; }
const std::set<HeroTypeID> & getBannedHeroes() const { return bannedHeroes; }
void validate() const; /// Tests template on validity and throws exception on failure
void serializeJson(JsonSerializeFormat & handler);
@@ -307,12 +367,16 @@ private:
std::set<EWaterContent::EWaterContent> allowedWaterContent;
std::unique_ptr<JsonNode> mapSettings;
std::set<SpellID> bannedSpells;
std::set<ArtifactID> bannedArtifacts;
std::set<SecondarySkill> bannedSkills;
std::set<HeroTypeID> bannedHeroes;
std::set<TerrainId> inheritTerrainType(std::shared_ptr<rmg::ZoneOptions> zone, uint32_t iteration = 0);
std::map<TResource, ui16> inheritMineTypes(std::shared_ptr<rmg::ZoneOptions> zone, uint32_t iteration = 0);
std::vector<CTreasureInfo> inheritTreasureInfo(std::shared_ptr<rmg::ZoneOptions> zone, uint32_t iteration = 0);
// TODO: Copy custom object settings
// TODO: Copy town type after source town is actually randomized
void inheritTownProperties(std::shared_ptr<rmg::ZoneOptions> zone, uint32_t iteration = 0);
void serializeSize(JsonSerializeFormat & handler, int3 & value, const std::string & fieldName);
void serializePlayers(JsonSerializeFormat & handler, CPlayerCountRange & value, const std::string & fieldName);
@@ -327,4 +391,4 @@ private:
};
VCMI_LIB_NAMESPACE_END
VCMI_LIB_NAMESPACE_END