1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-04-15 11:46:56 +02:00

Fixed crash due to incorrect RMG options.

This commit is contained in:
DjWarmonger 2014-09-18 14:29:57 +02:00
parent e0e83b6a0b
commit 495c39304d
3 changed files with 11 additions and 2 deletions

View File

@ -212,6 +212,7 @@ void CMapHandler::roadsRiverTerrainInit()
} }
// Create enough room for the whole map and its frame // Create enough room for the whole map and its frame
ttiles.resize(sizes.x, frameW, frameW); ttiles.resize(sizes.x, frameW, frameW);
for (int i=0-frameW;i<ttiles.size()-frameW;i++) for (int i=0-frameW;i<ttiles.size()-frameW;i++)
{ {

View File

@ -183,8 +183,8 @@ void CMapGenOptions::finalize(CRandomGenerator & rand)
if(!mapTemplate) if(!mapTemplate)
{ {
mapTemplate = getPossibleTemplate(rand); mapTemplate = getPossibleTemplate(rand);
assert(mapTemplate);
} }
assert(mapTemplate);
if(playerCount == RANDOM_SIZE) if(playerCount == RANDOM_SIZE)
{ {
@ -220,6 +220,9 @@ void CMapGenOptions::finalize(CRandomGenerator & rand)
monsterStrength = static_cast<EMonsterStrength::EMonsterStrength>(rand.nextInt(EMonsterStrength::GLOBAL_WEAK, EMonsterStrength::GLOBAL_STRONG)); monsterStrength = static_cast<EMonsterStrength::EMonsterStrength>(rand.nextInt(EMonsterStrength::GLOBAL_WEAK, EMonsterStrength::GLOBAL_STRONG));
} }
assert (vstd::iswithin(waterContent, EWaterContent::NONE, EWaterContent::ISLANDS));
assert (vstd::iswithin(monsterStrength, EMonsterStrength::GLOBAL_WEAK, EMonsterStrength::GLOBAL_STRONG));
//rectangular maps are the future of gaming //rectangular maps are the future of gaming
//setHeight(20); //setHeight(20);
//setWidth(50); //setWidth(50);

View File

@ -112,15 +112,20 @@ std::unique_ptr<CMap> CMapGenerator::generate(CMapGenOptions * mapGenOptions, in
std::string CMapGenerator::getMapDescription() const std::string CMapGenerator::getMapDescription() const
{ {
assert(mapGenOptions);
assert(map);
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
std::stringstream ss; std::stringstream ss;
ss << boost::str(boost::format(std::string("Map created by the Random Map Generator.\nTemplate was %s, Random seed was %d, size %dx%d") + ss << boost::str(boost::format(std::string("Map created by the Random Map Generator.\nTemplate was %s, Random seed was %d, size %dx%d") +
", levels %s, humans %d, computers %d, water %s, monster %s, second expansion map") % mapGenOptions->getMapTemplate()->getName() % ", levels %s, humans %d, computers %d, water %s, monster %s, second expansion map") % mapGenOptions->getMapTemplate()->getName() %
randomSeed % map->width % map->height % (map->twoLevel ? "2" : "1") % static_cast<int>(mapGenOptions->getPlayerCount()) % randomSeed % map->width % map->height % (map->twoLevel ? "2" : "1") % static_cast<int>(mapGenOptions->getPlayerCount()) %
static_cast<int>(mapGenOptions->getCompOnlyPlayerCount()) % waterContentStr[mapGenOptions->getWaterContent()] % static_cast<int>(mapGenOptions->getCompOnlyPlayerCount()) % waterContentStr[mapGenOptions->getWaterContent()] %
monsterStrengthStr[mapGenOptions->getMonsterStrength()]); monsterStrengthStr[monsterStrengthIndex]);
for(const auto & pair : mapGenOptions->getPlayersSettings()) for(const auto & pair : mapGenOptions->getPlayersSettings())
{ {