1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-15 20:03:15 +02:00

Fix obstacles generation

This commit is contained in:
nordsoft
2022-11-27 00:04:14 +04:00
parent 0ccb706782
commit 2c88e35749

View File

@@ -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<CObstacleInstance>();
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();