|
@@ -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)
|