mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Support for Cover of Darkness
This commit is contained in:
parent
6b447a4ae9
commit
2ed69d3f4d
@ -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; ii<wo; ii++)
|
||||
{
|
||||
for (int jj=0; jj<ho; jj++)
|
||||
{
|
||||
if ((pos.x*wo+ii<this->pos.w) && (pos.y*ho+jj<this->pos.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 )
|
||||
|
@ -913,6 +913,8 @@ void CPlayerInterface::tileHidden(const std::set<int3> &pos)
|
||||
boost::unique_lock<boost::recursive_mutex> un(*pim);
|
||||
for(std::set<int3>::const_iterator i=pos.begin(); i!=pos.end();i++)
|
||||
adventureInt->minimap.hideTile(*i);
|
||||
if(pos.size())
|
||||
GH.totalRedraw();
|
||||
}
|
||||
|
||||
void CPlayerInterface::openHeroWindow(const CGHeroInstance *hero)
|
||||
|
@ -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
|
||||
|
@ -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<int3> 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();
|
||||
|
Loading…
Reference in New Issue
Block a user