From 2c88e357492c5694fad7b20e6e30c3c5553aedad Mon Sep 17 00:00:00 2001 From: nordsoft Date: Sun, 27 Nov 2022 00:04:14 +0400 Subject: [PATCH 1/2] Fix obstacles generation --- lib/battle/BattleInfo.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/battle/BattleInfo.cpp b/lib/battle/BattleInfo.cpp index 72842f944..93d99dac4 100644 --- a/lib/battle/BattleInfo.cpp +++ b/lib/battle/BattleInfo.cpp @@ -261,13 +261,12 @@ BattleInfo * BattleInfo::setupBattle(const int3 & tile, TerrainId terrain, const auto * info = Obstacle(id).getInfo(); return info && !info->isAbsoluteObstacle && info->isAppropriate(curB->terrainType, battlefieldType); }; - - RangeGenerator obidgen(0, VLC->obstacleHandler->objects.size() - 1, ourRand); if(r.rand(1,100) <= 40) //put cliff-like obstacle { try { + RangeGenerator obidgen(0, VLC->obstacleHandler->objects.size() - 1, ourRand); auto obstPtr = std::make_shared(); obstPtr->obstacleType = CObstacleInstance::ABSOLUTE_OBSTACLE; obstPtr->ID = obidgen.getSuchNumber(appropriateAbsoluteObstacle); @@ -282,6 +281,8 @@ BattleInfo * BattleInfo::setupBattle(const int3 & tile, TerrainId terrain, const { //silently ignore, if we can't place absolute obstacle, we'll go with the usual ones logGlobal->debug("RangeGenerator::ExhaustedPossibilities exception occured - cannot place absolute obstacle"); + + // } } @@ -289,6 +290,7 @@ BattleInfo * BattleInfo::setupBattle(const int3 & tile, TerrainId terrain, const { while(tilesToBlock > 0) { + RangeGenerator obidgen(0, VLC->obstacleHandler->objects.size() - 1, ourRand); auto tileAccessibility = curB->getAccesibility(); const int obid = obidgen.getSuchNumber(appropriateUsualObstacle); const ObstacleInfo &obi = *Obstacle(obid).getInfo(); From 8e324603bf32d1d9ba633c0cdb3d84cc65332953 Mon Sep 17 00:00:00 2001 From: nordsoft Date: Sun, 27 Nov 2022 00:08:47 +0400 Subject: [PATCH 2/2] Remove extra lines --- lib/battle/BattleInfo.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/battle/BattleInfo.cpp b/lib/battle/BattleInfo.cpp index 93d99dac4..d1a418caf 100644 --- a/lib/battle/BattleInfo.cpp +++ b/lib/battle/BattleInfo.cpp @@ -281,8 +281,6 @@ BattleInfo * BattleInfo::setupBattle(const int3 & tile, TerrainId terrain, const { //silently ignore, if we can't place absolute obstacle, we'll go with the usual ones logGlobal->debug("RangeGenerator::ExhaustedPossibilities exception occured - cannot place absolute obstacle"); - - // } }