1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-29 21:56:54 +02:00

Invalidate unavailable tiles as obstacle candidates

This commit is contained in:
Dydzio 2017-07-13 17:55:49 +02:00
parent ee3f6c9b88
commit 18f2e0ed96
2 changed files with 18 additions and 2 deletions

View File

@ -352,6 +352,7 @@ BattleInfo * BattleInfo::setupBattle(int3 tile, ETerrainType terrain, BFieldType
catch(RangeGenerator::ExhaustedPossibilities &)
{
//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");
}
}
@ -359,7 +360,8 @@ BattleInfo * BattleInfo::setupBattle(int3 tile, ETerrainType terrain, BFieldType
try
{
while(tilesToBlock > 0)
{
{
auto tileAccessibility = curB->getAccesibility();
const int obid = obidgen.getSuchNumber(appropriateUsualObstacle);
const CObstacleInfo &obi = VLC->heroh->obstacles[obid];
@ -376,6 +378,8 @@ BattleInfo * BattleInfo::setupBattle(int3 tile, ETerrainType terrain, BFieldType
for(BattleHex blocked : obi.getBlocked(pos))
{
if(tileAccessibility[blocked] == EAccessibility::UNAVAILABLE) //for ship-to-ship battlefield - exclude hardcoded unavailable tiles
return false;
if(vstd::contains(blockedTiles, blocked))
return false;
int x = blocked.getX();
@ -401,6 +405,7 @@ BattleInfo * BattleInfo::setupBattle(int3 tile, ETerrainType terrain, BFieldType
}
catch(RangeGenerator::ExhaustedPossibilities &)
{
logGlobal->debug("RangeGenerator::ExhaustedPossibilities exception occured - cannot place usual obstacle");
}
}

View File

@ -860,7 +860,18 @@ AccessibilityInfo CBattleInfoCallback::getAccesibility() const
switch(battleGetBattlefieldType().num)
{
case BFieldType::SHIP_TO_SHIP:
impassableHexes = { 6, 7, 8, 9, 24, 25, 26, 58, 59, 60, 75, 76, 77, 92, 93, 94, 109, 110, 111, 126, 127, 128, 159, 160, 161, 162, 163, 176, 177, 178, 179, 180 };
impassableHexes =
{
6, 7, 8, 9,
24, 25, 26,
58, 59, 60,
75, 76, 77,
92, 93, 94,
109, 110, 111,
126, 127, 128,
159, 160, 161, 162, 163,
176, 177, 178, 179, 180
};
break;
}
for(auto hex : impassableHexes)