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

Merge branch 'rmg-split-enum-monster-strength' into rmg-no-monster-zone

This commit is contained in:
Warzyw647 2023-05-20 17:29:07 +02:00
commit 7afcc3b350
5 changed files with 34 additions and 40 deletions

View File

@ -191,7 +191,7 @@ void CMapGenOptions::setStartingTownForPlayer(const PlayerColor & color, si32 to
it->second.setStartingTown(town);
}
void CMapGenOptions::setPlayerTypeForStandardPlayer(const PlayerColor & color, EPlayerType::EPlayerType playerType)
void CMapGenOptions::setPlayerTypeForStandardPlayer(const PlayerColor & color, EPlayerType playerType)
{
assert(playerType != EPlayerType::COMP_ONLY);
auto it = players.find(color);
@ -526,12 +526,12 @@ void CMapGenOptions::CPlayerSettings::setStartingTown(si32 value)
startingTown = value;
}
EPlayerType::EPlayerType CMapGenOptions::CPlayerSettings::getPlayerType() const
EPlayerType CMapGenOptions::CPlayerSettings::getPlayerType() const
{
return playerType;
}
void CMapGenOptions::CPlayerSettings::setPlayerType(EPlayerType::EPlayerType value)
void CMapGenOptions::CPlayerSettings::setPlayerType(EPlayerType value)
{
playerType = value;
}

View File

@ -17,15 +17,12 @@ VCMI_LIB_NAMESPACE_BEGIN
class CRandomGenerator;
namespace EPlayerType
enum class EPlayerType
{
enum EPlayerType
{
HUMAN,
AI,
COMP_ONLY
};
}
HUMAN,
AI,
COMP_ONLY
};
/// The map gen options class holds values about general map generation settings
/// e.g. the size of the map, the count of players,...
@ -49,8 +46,8 @@ public:
void setStartingTown(si32 value);
/// The default value is EPlayerType::AI.
EPlayerType::EPlayerType getPlayerType() const;
void setPlayerType(EPlayerType::EPlayerType value);
EPlayerType getPlayerType() const;
void setPlayerType(EPlayerType value);
/// Team id for this player. TeamID::NO_TEAM by default - team will be randomly assigned
TeamID getTeam() const;
@ -62,7 +59,7 @@ public:
private:
PlayerColor color;
si32 startingTown;
EPlayerType::EPlayerType playerType;
EPlayerType playerType;
TeamID team;
public:
@ -122,7 +119,7 @@ public:
void setStartingTownForPlayer(const PlayerColor & color, si32 town);
/// Sets a player type for a standard player. A standard player is the opposite of a computer only player. The
/// values which can be chosen for the player type are EPlayerType::AI or EPlayerType::HUMAN.
void setPlayerTypeForStandardPlayer(const PlayerColor & color, EPlayerType::EPlayerType playerType);
void setPlayerTypeForStandardPlayer(const PlayerColor & color, EPlayerType playerType);
void setPlayerTeam(const PlayerColor & color, const TeamID & team = TeamID::NO_TEAM);

View File

@ -185,7 +185,7 @@ void CMapGenerator::addPlayerInfo()
{
// Calculate which team numbers exist
enum ETeams {CPHUMAN = 0, CPUONLY = 1, AFTER_LAST = 2};
enum ETeams {CPHUMAN = 0, CPUONLY = 1, AFTER_LAST = 2}; // Used as a kind of a local named array index, so left as enum, not enum class
std::array<std::list<int>, 2> teamNumbers;
std::set<int> teamsTotal;

View File

@ -162,12 +162,12 @@ void ZoneOptions::setId(TRmgTemplateZoneId value)
id = value;
}
ETemplateZoneType::ETemplateZoneType ZoneOptions::getType() const
ETemplateZoneType ZoneOptions::getType() const
{
return type;
}
void ZoneOptions::setType(ETemplateZoneType::ETemplateZoneType value)
void ZoneOptions::setType(ETemplateZoneType value)
{
type = value;
}
@ -467,7 +467,7 @@ bool CRmgTemplate::matchesSize(const int3 & value) const
bool CRmgTemplate::isWaterContentAllowed(EWaterContent::EWaterContent waterContent) const
{
return waterContent == EWaterContent::EWaterContent::RANDOM || allowedWaterContent.count(waterContent);
return waterContent == EWaterContent::RANDOM || allowedWaterContent.count(waterContent);
}
const std::set<EWaterContent::EWaterContent> & CRmgTemplate::getWaterContentAllowed() const
@ -755,13 +755,13 @@ void CRmgTemplate::afterLoad()
zone2->addConnection(id1);
}
if(allowedWaterContent.empty() || allowedWaterContent.count(EWaterContent::EWaterContent::RANDOM))
if(allowedWaterContent.empty() || allowedWaterContent.count(EWaterContent::RANDOM))
{
allowedWaterContent.insert(EWaterContent::EWaterContent::NONE);
allowedWaterContent.insert(EWaterContent::EWaterContent::NORMAL);
allowedWaterContent.insert(EWaterContent::EWaterContent::ISLANDS);
allowedWaterContent.insert(EWaterContent::NONE);
allowedWaterContent.insert(EWaterContent::NORMAL);
allowedWaterContent.insert(EWaterContent::ISLANDS);
}
allowedWaterContent.erase(EWaterContent::EWaterContent::RANDOM);
allowedWaterContent.erase(EWaterContent::RANDOM);
}
void CRmgTemplate::serializeSize(JsonSerializeFormat & handler, int3 & value, const std::string & fieldName)

View File

@ -18,21 +18,18 @@ VCMI_LIB_NAMESPACE_BEGIN
class JsonSerializeFormat;
namespace ETemplateZoneType
enum class ETemplateZoneType
{
enum ETemplateZoneType
{
PLAYER_START,
CPU_START,
TREASURE,
JUNCTION,
WATER
};
}
PLAYER_START,
CPU_START,
TREASURE,
JUNCTION,
WATER
};
namespace EWaterContent
{
enum EWaterContent
namespace EWaterContent // Not enum class, because it's used in method RandomMapTab::setMapGenOptions
{ // defined in client\lobby\RandomMapTab.cpp and probably in other similar places
enum EWaterContent // as an argument of CToggleGroup::setSelected(int id) from \client\widgets\Buttons.cpp
{
RANDOM = -1,
NONE,
@ -120,8 +117,8 @@ public:
TRmgTemplateZoneId getId() const;
void setId(TRmgTemplateZoneId value);
ETemplateZoneType::ETemplateZoneType getType() const;
void setType(ETemplateZoneType::ETemplateZoneType value);
ETemplateZoneType getType() const;
void setType(ETemplateZoneType value);
int getSize() const;
void setSize(int value);
@ -164,7 +161,7 @@ public:
protected:
TRmgTemplateZoneId id;
ETemplateZoneType::ETemplateZoneType type;
ETemplateZoneType type;
int size;
ui32 maxTreasureValue;
std::optional<int> owner;