diff --git a/client/CAdvmapInterface.cpp b/client/CAdvmapInterface.cpp index f01df7829..29fa24011 100644 --- a/client/CAdvmapInterface.cpp +++ b/client/CAdvmapInterface.cpp @@ -429,6 +429,18 @@ void CMinimap::showVisibleTiles(int level) void CMinimap::hideTile(const int3 &pos) { + int3 mapSizes = LOCPLINT->cb->getMapSize(); + //drawing terrain + int mw = map[0]->w, mh = map[0]->h; + double wo = ((double)mw)/mapSizes.x, ho = ((double)mh)/mapSizes.y; + for (int ii=0; iipos.w) && (pos.y*ho+jjpos.h)) + CSDL_Ext::SDL_PutPixelWithoutRefresh(FoW[pos.z],pos.x*wo+ii,pos.y*ho+jj,0,0,0,0); + } + } } void CMinimap::show( SDL_Surface * to ) diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index ae9bd3fbe..d4e70bfbb 100644 --- a/client/CPlayerInterface.cpp +++ b/client/CPlayerInterface.cpp @@ -913,6 +913,8 @@ void CPlayerInterface::tileHidden(const std::set &pos) boost::unique_lock un(*pim); for(std::set::const_iterator i=pos.begin(); i!=pos.end();i++) adventureInt->minimap.hideTile(*i); + if(pos.size()) + GH.totalRedraw(); } void CPlayerInterface::openHeroWindow(const CGHeroInstance *hero) diff --git a/hch/CObjectHandler.cpp b/hch/CObjectHandler.cpp index 9c04a7512..a1113de7c 100644 --- a/hch/CObjectHandler.cpp +++ b/hch/CObjectHandler.cpp @@ -4377,16 +4377,40 @@ void CGEvent::activated( const CGHeroInstance * h ) const void CGObservatory::onHeroVisit( const CGHeroInstance * h ) const { InfoWindow iw; - iw.soundID = soundBase::LIGHTHOUSE; iw.player = h->tempOwner; - iw.text.addTxt(MetaString::ADVOB_TXT,98 + (ID==60)); - cb->showInfoDialog(&iw); + switch (ID) + { + case 58://redwood observatory + case 60://pillar of fire + { + iw.soundID = soundBase::LIGHTHOUSE; + iw.text.addTxt(MetaString::ADVOB_TXT,98 + (ID==60)); - FoWChange fw; - fw.player = h->tempOwner; - fw.mode = 1; - cb->getTilesInRange(fw.tiles,pos,20,h->tempOwner,1); - cb->sendAndApply(&fw); + FoWChange fw; + fw.player = h->tempOwner; + fw.mode = 1; + cb->getTilesInRange (fw.tiles, pos, 20, h->tempOwner, 1); + cb->sendAndApply (&fw); + break; + } + case 15://cover of darkness + { + iw.text.addTxt (MetaString::ADVOB_TXT, 31); + for (int i = 0; i < cb->gameState()->players.size(); ++i) + { + if ((h->tempOwner != i) && (cb->gameState()->getPlayer(i)->status == PlayerState::INGAME)) //TODO: team support + { + FoWChange fw; + fw.mode = 0; + fw.player = i; + cb->getTilesInRange (fw.tiles, pos, 20, i, -1); + cb->sendAndApply (&fw); + } + } + break; + } + } + cb->showInfoDialog(&iw); } void CGShrine::onHeroVisit( const CGHeroInstance * h ) const diff --git a/lib/NetPacksLib.cpp b/lib/NetPacksLib.cpp index 24cfa18ea..d360a61fe 100644 --- a/lib/NetPacksLib.cpp +++ b/lib/NetPacksLib.cpp @@ -164,10 +164,30 @@ DLL_EXPORT void SetMovePoints::applyGs( CGameState *gs ) DLL_EXPORT void FoWChange::applyGs( CGameState *gs ) { - BOOST_FOREACH(int3 t, tiles) + BOOST_FOREACH(int3 t, tiles) gs->getPlayer(player)->fogOfWarMap[t.x][t.y][t.z] = mode; + if (mode == 0) //do not hide too much + { + std::set tilesRevealed; + for (size_t i = 0; i < gs->map->objects.size(); i++) + { + if(gs->map->objects[i] && gs->map->objects[i]->tempOwner == player) //check owned observators + { + switch(gs->map->objects[i]->ID) + { + case 34://hero + case 53://mine + case 98://town + case 220: + gs->map->objects[i]->getSightTiles(tilesRevealed); + break; + } + } + } + BOOST_FOREACH(int3 t, tilesRevealed) //probably not the most optimal solution ever + gs->getPlayer(player)->fogOfWarMap[t.x][t.y][t.z] = 1; + } } - DLL_EXPORT void SetAvailableHeroes::applyGs( CGameState *gs ) { gs->getPlayer(player)->availableHeroes.clear();