mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-28 08:48:48 +02:00
Fixed crash caused by hiding tiles around AI heroes.
This commit is contained in:
parent
54390ea81c
commit
bf567c9e50
@ -6254,6 +6254,21 @@ void CGameHandler::changeFogOfWar(int3 center, ui32 radius, PlayerColor player,
|
||||
{
|
||||
std::unordered_set<int3, ShashInt3> tiles;
|
||||
getTilesInRange(tiles, center, radius, player, hide? -1 : 1);
|
||||
if (hide)
|
||||
{
|
||||
std::unordered_set<int3, ShashInt3> observedTiles; //do not hide tiles observed by heroes. May lead to disastrous AI problems
|
||||
auto p = gs->getPlayer(player);
|
||||
for (auto h : p->heroes)
|
||||
{
|
||||
getTilesInRange(observedTiles, h->getSightCenter(), h->getSightRadious(), h->tempOwner, -1);
|
||||
}
|
||||
for (auto t : p->towns)
|
||||
{
|
||||
getTilesInRange(observedTiles, t->getSightCenter(), t->getSightRadious(), t->tempOwner, -1);
|
||||
}
|
||||
for (auto tile : observedTiles)
|
||||
vstd::erase_if_present (tiles, tile);
|
||||
}
|
||||
changeFogOfWar(tiles, player, hide);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user