mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-31 22:05:10 +02:00
Merge pull request #340 from dydzio0614/navalbattlefieldfix2
Add proper handling for ship-to-ship battlefield
This commit is contained in:
commit
77ca27b90b
@ -352,6 +352,7 @@ BattleInfo * BattleInfo::setupBattle(int3 tile, ETerrainType terrain, BFieldType
|
|||||||
catch(RangeGenerator::ExhaustedPossibilities &)
|
catch(RangeGenerator::ExhaustedPossibilities &)
|
||||||
{
|
{
|
||||||
//silently ignore, if we can't place absolute obstacle, we'll go with the usual ones
|
//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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -360,6 +361,7 @@ BattleInfo * BattleInfo::setupBattle(int3 tile, ETerrainType terrain, BFieldType
|
|||||||
{
|
{
|
||||||
while(tilesToBlock > 0)
|
while(tilesToBlock > 0)
|
||||||
{
|
{
|
||||||
|
auto tileAccessibility = curB->getAccesibility();
|
||||||
const int obid = obidgen.getSuchNumber(appropriateUsualObstacle);
|
const int obid = obidgen.getSuchNumber(appropriateUsualObstacle);
|
||||||
const CObstacleInfo &obi = VLC->heroh->obstacles[obid];
|
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))
|
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))
|
if(vstd::contains(blockedTiles, blocked))
|
||||||
return false;
|
return false;
|
||||||
int x = blocked.getX();
|
int x = blocked.getX();
|
||||||
@ -401,6 +405,7 @@ BattleInfo * BattleInfo::setupBattle(int3 tile, ETerrainType terrain, BFieldType
|
|||||||
}
|
}
|
||||||
catch(RangeGenerator::ExhaustedPossibilities &)
|
catch(RangeGenerator::ExhaustedPossibilities &)
|
||||||
{
|
{
|
||||||
|
logGlobal->debug("RangeGenerator::ExhaustedPossibilities exception occured - cannot place usual obstacle");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -855,6 +855,26 @@ AccessibilityInfo CBattleInfoCallback::getAccesibility() const
|
|||||||
ret[BattleHex(0, y)] = EAccessibility::SIDE_COLUMN;
|
ret[BattleHex(0, y)] = EAccessibility::SIDE_COLUMN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//special battlefields with logically unavailable tiles
|
||||||
|
std::vector<BattleHex> impassableHexes;
|
||||||
|
if(battleGetBattlefieldType().num == 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
|
||||||
|
};
|
||||||
|
}
|
||||||
|
for(auto hex : impassableHexes)
|
||||||
|
ret[hex] = EAccessibility::UNAVAILABLE;
|
||||||
|
|
||||||
//gate -> should be before stacks
|
//gate -> should be before stacks
|
||||||
if(battleGetSiegeLevel() > 0)
|
if(battleGetSiegeLevel() > 0)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user