mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
Merge branch 'rmg-refactor-enums' into rmg-no-monster-zone
This commit is contained in:
@@ -93,9 +93,9 @@ RandomMapTab::RandomMapTab():
|
|||||||
addCallback("setMonsterStrength", [&](int btnId)
|
addCallback("setMonsterStrength", [&](int btnId)
|
||||||
{
|
{
|
||||||
if(btnId < 0)
|
if(btnId < 0)
|
||||||
mapGenOptions->setMonsterStrength(EMonsterStrength::RANDOM);
|
mapGenOptions->setMonsterStrength(EGlobalMonsterStrength::RANDOM);
|
||||||
else
|
else
|
||||||
mapGenOptions->setMonsterStrength(static_cast<EMonsterStrength::EMonsterStrength>(btnId)); //value 2 to 4
|
mapGenOptions->setMonsterStrength(static_cast<EGlobalMonsterStrength::EGlobalMonsterStrength>(btnId)); //value 2 to 4
|
||||||
updateMapInfoByHost();
|
updateMapInfoByHost();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -23,7 +23,7 @@ VCMI_LIB_NAMESPACE_BEGIN
|
|||||||
CMapGenOptions::CMapGenOptions()
|
CMapGenOptions::CMapGenOptions()
|
||||||
: width(CMapHeader::MAP_SIZE_MIDDLE), height(CMapHeader::MAP_SIZE_MIDDLE), hasTwoLevels(true),
|
: width(CMapHeader::MAP_SIZE_MIDDLE), height(CMapHeader::MAP_SIZE_MIDDLE), hasTwoLevels(true),
|
||||||
playerCount(RANDOM_SIZE), teamCount(RANDOM_SIZE), compOnlyPlayerCount(RANDOM_SIZE), compOnlyTeamCount(RANDOM_SIZE),
|
playerCount(RANDOM_SIZE), teamCount(RANDOM_SIZE), compOnlyPlayerCount(RANDOM_SIZE), compOnlyTeamCount(RANDOM_SIZE),
|
||||||
waterContent(EWaterContent::RANDOM), monsterStrength(EMonsterStrength::RANDOM), mapTemplate(nullptr)
|
waterContent(EWaterContent::RANDOM), monsterStrength(EGlobalMonsterStrength::RANDOM), mapTemplate(nullptr)
|
||||||
{
|
{
|
||||||
resetPlayersMap();
|
resetPlayersMap();
|
||||||
}
|
}
|
||||||
@@ -122,12 +122,12 @@ void CMapGenOptions::setWaterContent(EWaterContent::EWaterContent value)
|
|||||||
waterContent = value;
|
waterContent = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
EMonsterStrength::EMonsterStrength CMapGenOptions::getMonsterStrength() const
|
EGlobalMonsterStrength::EGlobalMonsterStrength CMapGenOptions::getMonsterStrength() const
|
||||||
{
|
{
|
||||||
return monsterStrength;
|
return monsterStrength;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMapGenOptions::setMonsterStrength(EMonsterStrength::EMonsterStrength value)
|
void CMapGenOptions::setMonsterStrength(EGlobalMonsterStrength::EGlobalMonsterStrength value)
|
||||||
{
|
{
|
||||||
monsterStrength = value;
|
monsterStrength = value;
|
||||||
}
|
}
|
||||||
@@ -308,13 +308,13 @@ void CMapGenOptions::finalize(CRandomGenerator & rand)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(monsterStrength == EMonsterStrength::RANDOM)
|
if(monsterStrength == EGlobalMonsterStrength::RANDOM)
|
||||||
{
|
{
|
||||||
monsterStrength = static_cast<EMonsterStrength::EMonsterStrength>(rand.nextInt(EMonsterStrength::GLOBAL_WEAK, EMonsterStrength::GLOBAL_STRONG));
|
monsterStrength = static_cast<EGlobalMonsterStrength::EGlobalMonsterStrength>(rand.nextInt(EGlobalMonsterStrength::WEAK, EGlobalMonsterStrength::STRONG));
|
||||||
}
|
}
|
||||||
|
|
||||||
assert (vstd::iswithin(waterContent, EWaterContent::NONE, EWaterContent::ISLANDS));
|
assert (vstd::iswithin(waterContent, EWaterContent::NONE, EWaterContent::ISLANDS));
|
||||||
assert (vstd::iswithin(monsterStrength, EMonsterStrength::GLOBAL_WEAK, EMonsterStrength::GLOBAL_STRONG));
|
assert (vstd::iswithin(monsterStrength, EGlobalMonsterStrength::WEAK, EGlobalMonsterStrength::STRONG));
|
||||||
|
|
||||||
|
|
||||||
//rectangular maps are the future of gaming
|
//rectangular maps are the future of gaming
|
||||||
|
@@ -110,8 +110,8 @@ public:
|
|||||||
EWaterContent::EWaterContent getWaterContent() const;
|
EWaterContent::EWaterContent getWaterContent() const;
|
||||||
void setWaterContent(EWaterContent::EWaterContent value);
|
void setWaterContent(EWaterContent::EWaterContent value);
|
||||||
|
|
||||||
EMonsterStrength::EMonsterStrength getMonsterStrength() const;
|
EGlobalMonsterStrength::EGlobalMonsterStrength getMonsterStrength() const;
|
||||||
void setMonsterStrength(EMonsterStrength::EMonsterStrength value);
|
void setMonsterStrength(EGlobalMonsterStrength::EGlobalMonsterStrength value);
|
||||||
|
|
||||||
bool isRoadEnabled(const std::string & roadName) const;
|
bool isRoadEnabled(const std::string & roadName) const;
|
||||||
void setRoadEnabled(const std::string & roadName, bool enable);
|
void setRoadEnabled(const std::string & roadName, bool enable);
|
||||||
@@ -157,7 +157,7 @@ private:
|
|||||||
bool hasTwoLevels;
|
bool hasTwoLevels;
|
||||||
si8 playerCount, teamCount, compOnlyPlayerCount, compOnlyTeamCount;
|
si8 playerCount, teamCount, compOnlyPlayerCount, compOnlyTeamCount;
|
||||||
EWaterContent::EWaterContent waterContent;
|
EWaterContent::EWaterContent waterContent;
|
||||||
EMonsterStrength::EMonsterStrength monsterStrength;
|
EGlobalMonsterStrength::EGlobalMonsterStrength monsterStrength;
|
||||||
std::map<PlayerColor, CPlayerSettings> players;
|
std::map<PlayerColor, CPlayerSettings> players;
|
||||||
std::set<std::string> disabledRoads;
|
std::set<std::string> disabledRoads;
|
||||||
|
|
||||||
|
@@ -151,7 +151,7 @@ std::string CMapGenerator::getMapDescription() const
|
|||||||
const std::string waterContentStr[3] = { "none", "normal", "islands" };
|
const std::string waterContentStr[3] = { "none", "normal", "islands" };
|
||||||
const std::string monsterStrengthStr[3] = { "weak", "normal", "strong" };
|
const std::string monsterStrengthStr[3] = { "weak", "normal", "strong" };
|
||||||
|
|
||||||
int monsterStrengthIndex = mapGenOptions.getMonsterStrength() - EMonsterStrength::GLOBAL_WEAK; //does not start from 0
|
int monsterStrengthIndex = mapGenOptions.getMonsterStrength() - EGlobalMonsterStrength::WEAK; //does not start from 0
|
||||||
const auto * mapTemplate = mapGenOptions.getMapTemplate();
|
const auto * mapTemplate = mapGenOptions.getMapTemplate();
|
||||||
|
|
||||||
if(!mapTemplate)
|
if(!mapTemplate)
|
||||||
|
@@ -140,7 +140,7 @@ ZoneOptions::ZoneOptions():
|
|||||||
owner(std::nullopt),
|
owner(std::nullopt),
|
||||||
matchTerrainToTown(true),
|
matchTerrainToTown(true),
|
||||||
townsAreSameType(false),
|
townsAreSameType(false),
|
||||||
zoneMonsterStrength(EMonsterStrength::ZONE_NORMAL),
|
monsterStrength(EZoneMonsterStrength::NORMAL),
|
||||||
minesLikeZone(NO_ZONE),
|
minesLikeZone(NO_ZONE),
|
||||||
terrainTypeLikeZone(NO_ZONE),
|
terrainTypeLikeZone(NO_ZONE),
|
||||||
treasureLikeZone(NO_ZONE)
|
treasureLikeZone(NO_ZONE)
|
||||||
@@ -378,7 +378,7 @@ void ZoneOptions::serializeJson(JsonSerializeFormat & handler)
|
|||||||
|
|
||||||
{
|
{
|
||||||
//TODO: add support for std::map to serializeEnum
|
//TODO: add support for std::map to serializeEnum
|
||||||
static const std::vector<std::string> STRENGTH =
|
static const std::vector<std::string> zoneMonsterStrengths =
|
||||||
{
|
{
|
||||||
"none",
|
"none",
|
||||||
"weak",
|
"weak",
|
||||||
@@ -386,18 +386,7 @@ void ZoneOptions::serializeJson(JsonSerializeFormat & handler)
|
|||||||
"strong"
|
"strong"
|
||||||
};
|
};
|
||||||
|
|
||||||
si32 rawStrength = 0;
|
handler.serializeEnum("monsters", monsterStrength, EZoneMonsterStrength::NORMAL, zoneMonsterStrengths); // default is normal monsters
|
||||||
if(handler.saving)
|
|
||||||
{
|
|
||||||
rawStrength = static_cast<decltype(rawStrength)>(zoneMonsterStrength);
|
|
||||||
rawStrength++;
|
|
||||||
}
|
|
||||||
handler.serializeEnum("monsters", rawStrength, EMonsterStrength::ZONE_NORMAL + 1, STRENGTH);
|
|
||||||
if(!handler.saving)
|
|
||||||
{
|
|
||||||
rawStrength--;
|
|
||||||
zoneMonsterStrength = static_cast<decltype(zoneMonsterStrength)>(rawStrength);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(treasureLikeZone == NO_ZONE)
|
if(treasureLikeZone == NO_ZONE)
|
||||||
|
@@ -41,12 +41,12 @@ namespace EWaterContent
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace EMonsterStrength
|
namespace EMonsterStrength // used as int in monster generation procedure and in map description for the generated random map
|
||||||
{
|
{
|
||||||
enum EMonsterStrength
|
enum EMonsterStrength
|
||||||
{
|
{
|
||||||
RANDOM = -3,
|
ZONE_NONE = -3,
|
||||||
ZONE_NONE = -2,
|
RANDOM = -2,
|
||||||
ZONE_WEAK = -1,
|
ZONE_WEAK = -1,
|
||||||
ZONE_NORMAL = 0,
|
ZONE_NORMAL = 0,
|
||||||
ZONE_STRONG = 1,
|
ZONE_STRONG = 1,
|
||||||
|
@@ -413,7 +413,7 @@ CGCreature * ObjectManager::chooseGuard(si32 strength, bool zoneGuard)
|
|||||||
return nullptr; //no guards inside this zone
|
return nullptr; //no guards inside this zone
|
||||||
|
|
||||||
int mapMonsterStrength = map.getMapGenOptions().getMonsterStrength();
|
int mapMonsterStrength = map.getMapGenOptions().getMonsterStrength();
|
||||||
int monsterStrength = (zoneGuard ? 0 : zone.zoneMonsterStrength) + mapMonsterStrength - 1; //array index from 0 to 4
|
int monsterStrength = (zoneGuard ? 0 : zone.monsterStrength - EZoneMonsterStrength::NORMAL) + mapMonsterStrength - 1; //array index from 0 to 4
|
||||||
static const std::array<int, 5> value1{2500, 1500, 1000, 500, 0};
|
static const std::array<int, 5> value1{2500, 1500, 1000, 500, 0};
|
||||||
static const std::array<int, 5> value2{7500, 7500, 7500, 5000, 5000};
|
static const std::array<int, 5> value2{7500, 7500, 7500, 5000, 5000};
|
||||||
static const std::array<float, 5> multiplier1{0.5, 0.75, 1.0, 1.5, 1.5};
|
static const std::array<float, 5> multiplier1{0.5, 0.75, 1.0, 1.5, 1.5};
|
||||||
|
@@ -141,13 +141,13 @@ void WindowNewMap::loadUserSettings()
|
|||||||
{
|
{
|
||||||
switch (monsterStrength.toInt())
|
switch (monsterStrength.toInt())
|
||||||
{
|
{
|
||||||
case EMonsterStrength::RANDOM:
|
case EGlobalMonsterStrength::RANDOM:
|
||||||
ui->monsterOpt1->setChecked(true); break;
|
ui->monsterOpt1->setChecked(true); break;
|
||||||
case EMonsterStrength::GLOBAL_WEAK:
|
case EGlobalMonsterStrength::WEAK:
|
||||||
ui->monsterOpt2->setChecked(true); break;
|
ui->monsterOpt2->setChecked(true); break;
|
||||||
case EMonsterStrength::GLOBAL_NORMAL:
|
case EGlobalMonsterStrength::NORMAL:
|
||||||
ui->monsterOpt3->setChecked(true); break;
|
ui->monsterOpt3->setChecked(true); break;
|
||||||
case EMonsterStrength::GLOBAL_STRONG:
|
case EGlobalMonsterStrength::STRONG:
|
||||||
ui->monsterOpt4->setChecked(true); break;
|
ui->monsterOpt4->setChecked(true); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -195,15 +195,15 @@ void WindowNewMap::saveUserSettings()
|
|||||||
water = EWaterContent::ISLANDS;
|
water = EWaterContent::ISLANDS;
|
||||||
s.setValue(newMapWaterContent, static_cast<int>(water));
|
s.setValue(newMapWaterContent, static_cast<int>(water));
|
||||||
|
|
||||||
EMonsterStrength::EMonsterStrength monster = EMonsterStrength::RANDOM;
|
EGlobalMonsterStrength::EGlobalMonsterStrength monster = EGlobalMonsterStrength::RANDOM;
|
||||||
if(ui->monsterOpt1->isChecked())
|
if(ui->monsterOpt1->isChecked())
|
||||||
monster = EMonsterStrength::RANDOM;
|
monster = EGlobalMonsterStrength::RANDOM;
|
||||||
else if(ui->monsterOpt2->isChecked())
|
else if(ui->monsterOpt2->isChecked())
|
||||||
monster = EMonsterStrength::GLOBAL_WEAK;
|
monster = EGlobalMonsterStrength::WEAK;
|
||||||
else if(ui->monsterOpt3->isChecked())
|
else if(ui->monsterOpt3->isChecked())
|
||||||
monster = EMonsterStrength::GLOBAL_NORMAL;
|
monster = EGlobalMonsterStrength::NORMAL;
|
||||||
else if(ui->monsterOpt4->isChecked())
|
else if(ui->monsterOpt4->isChecked())
|
||||||
monster = EMonsterStrength::GLOBAL_STRONG;
|
monster = EGlobalMonsterStrength::STRONG;
|
||||||
s.setValue(newMapMonsterStrength, static_cast<int>(monster));
|
s.setValue(newMapMonsterStrength, static_cast<int>(monster));
|
||||||
|
|
||||||
auto templateName = ui->templateCombo->currentText();
|
auto templateName = ui->templateCombo->currentText();
|
||||||
@@ -240,7 +240,7 @@ std::unique_ptr<CMap> generateEmptyMap(CMapGenOptions & options)
|
|||||||
void WindowNewMap::on_okButton_clicked()
|
void WindowNewMap::on_okButton_clicked()
|
||||||
{
|
{
|
||||||
EWaterContent::EWaterContent water = EWaterContent::RANDOM;
|
EWaterContent::EWaterContent water = EWaterContent::RANDOM;
|
||||||
EMonsterStrength::EMonsterStrength monster = EMonsterStrength::RANDOM;
|
EGlobalMonsterStrength::EGlobalMonsterStrength monster = EGlobalMonsterStrength::RANDOM;
|
||||||
if(ui->waterOpt1->isChecked())
|
if(ui->waterOpt1->isChecked())
|
||||||
water = EWaterContent::RANDOM;
|
water = EWaterContent::RANDOM;
|
||||||
if(ui->waterOpt2->isChecked())
|
if(ui->waterOpt2->isChecked())
|
||||||
@@ -250,13 +250,13 @@ void WindowNewMap::on_okButton_clicked()
|
|||||||
if(ui->waterOpt4->isChecked())
|
if(ui->waterOpt4->isChecked())
|
||||||
water = EWaterContent::ISLANDS;
|
water = EWaterContent::ISLANDS;
|
||||||
if(ui->monsterOpt1->isChecked())
|
if(ui->monsterOpt1->isChecked())
|
||||||
monster = EMonsterStrength::RANDOM;
|
monster = EGlobalMonsterStrength::RANDOM;
|
||||||
if(ui->monsterOpt2->isChecked())
|
if(ui->monsterOpt2->isChecked())
|
||||||
monster = EMonsterStrength::GLOBAL_WEAK;
|
monster = EGlobalMonsterStrength::WEAK;
|
||||||
if(ui->monsterOpt3->isChecked())
|
if(ui->monsterOpt3->isChecked())
|
||||||
monster = EMonsterStrength::GLOBAL_NORMAL;
|
monster = EGlobalMonsterStrength::NORMAL;
|
||||||
if(ui->monsterOpt4->isChecked())
|
if(ui->monsterOpt4->isChecked())
|
||||||
monster = EMonsterStrength::GLOBAL_STRONG;
|
monster = EGlobalMonsterStrength::STRONG;
|
||||||
|
|
||||||
mapGenOptions.setWaterContent(water);
|
mapGenOptions.setWaterContent(water);
|
||||||
mapGenOptions.setMonsterStrength(monster);
|
mapGenOptions.setMonsterStrength(monster);
|
||||||
|
Reference in New Issue
Block a user