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

Fix Cover of Darkness

This commit is contained in:
Ivan Savenko
2023-10-18 18:04:01 +03:00
parent 8f33fdcd83
commit 901fd77699

View File

@@ -13,8 +13,10 @@
#include "../CHeroHandler.h"
#include "../TerrainHandler.h"
#include "../CPlayerState.h"
#include "../CSoundBase.h"
#include "../NetPacks.h"
#include "../gameState/CGameState.h"
#include "../spells/CSpellHandler.h"
#include "../spells/ISpellMechanics.h"
#include "../mapObjects/MiscObjects.h"
@@ -50,14 +52,6 @@ void Rewardable::Interface::grantRewardBeforeLevelup(IGameCallback * cb, const R
if (info.reward.revealTiles)
{
const auto & props = *info.reward.revealTiles;
FoWChange fw;
if (props.hide)
fw.mode = ETileVisibility::HIDDEN;
else
fw.mode = ETileVisibility::REVEALED;
fw.player = hero->tempOwner;
const auto functor = [&props](const TerrainTile * tile)
{
@@ -77,20 +71,34 @@ void Rewardable::Interface::grantRewardBeforeLevelup(IGameCallback * cb, const R
return score > 0;
};
std::unordered_set<int3> tiles;
if (props.radius > 0)
{
cb->getTilesInRange(fw.tiles, hero->getSightCenter(), props.radius, ETileVisibility::HIDDEN, hero->tempOwner);
vstd::erase_if(fw.tiles, [&](const int3 & coord){
cb->getTilesInRange(tiles, hero->getSightCenter(), props.radius, ETileVisibility::HIDDEN, hero->getOwner());
if (props.hide)
cb->getTilesInRange(tiles, hero->getSightCenter(), props.radius, ETileVisibility::REVEALED, hero->getOwner());
vstd::erase_if(tiles, [&](const int3 & coord){
return !functor(cb->getTile(coord));
});
}
else
{
cb->getAllTiles(fw.tiles, hero->tempOwner, -1, functor);
cb->getAllTiles(tiles, hero->tempOwner, -1, functor);
}
cb->sendAndApply(&fw);
if (props.hide)
{
for (auto & player : cb->gameState()->players)
{
if (cb->getPlayerStatus(player.first) == EPlayerStatus::INGAME && cb->getPlayerRelations(player.first, hero->getOwner()) == PlayerRelations::ENEMIES)
cb->changeFogOfWar(tiles, player.first, ETileVisibility::HIDDEN);
}
}
else
{
cb->changeFogOfWar(tiles, hero->getOwner(), ETileVisibility::REVEALED);
}
}
for(const auto & entry : info.reward.secondary)