mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
1.Support for Skyship - revealing entire map
2.Reorganization of visible tiles processing 3.Turned off revealing the map at build structure as it caused odd conflict
This commit is contained in:
parent
2b1f395c70
commit
e1c793068d
@ -396,7 +396,10 @@ int CGObjectInstance::getSightRadious() const
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
void CGObjectInstance::getSightTiles(std::set<int3> &tiles) const //returns reference to the set
|
||||
{
|
||||
cb->getTilesInRange(tiles, pos, getSightRadious(), tempOwner, 1);
|
||||
}
|
||||
int3 CGObjectInstance::getVisitableOffset() const
|
||||
{
|
||||
for(int y = 0; y < 6; y++)
|
||||
@ -1422,7 +1425,7 @@ int CGTownInstance::getSightRadious() const //returns sight distance
|
||||
if (subID == 2) //tower
|
||||
{
|
||||
if ((builtBuildings.find(17)) != builtBuildings.end()) //skyship
|
||||
return cb->getMapSize().x + cb->getMapSize().y;
|
||||
return -1; //entire map
|
||||
else if ((builtBuildings.find(21)) != builtBuildings.end()) //lookout tower
|
||||
return 20;
|
||||
}
|
||||
|
@ -144,6 +144,7 @@ public:
|
||||
|
||||
virtual int3 getSightCenter() const; //"center" tile from which the sight distance is calculated
|
||||
virtual int getSightRadious() const; //sight distance (should be used if player-owned structure)
|
||||
void getSightTiles(std::set<int3> &tiles) const; //returns reference to the set
|
||||
int getOwner() const;
|
||||
void setOwner(int ow);
|
||||
int getWidth() const; //returns width of object graphic in tiles
|
||||
|
@ -1394,9 +1394,11 @@ void CGameState::init(StartInfo * si, Mapa * map, int Seed)
|
||||
BOOST_FOREACH(CGObjectInstance *obj, map->objects)
|
||||
{
|
||||
if(obj->tempOwner != k->first) continue; //not a flagged object
|
||||
|
||||
/*
|
||||
int3 objCenter = obj->getSightCenter();
|
||||
int radious = obj->getSightRadious();
|
||||
if (radious == -1) //maybe better handle it via getTilesInRange as below?
|
||||
radious = map->width + map->height;
|
||||
|
||||
for (int xd = std::max<int>(objCenter.x - radious , 0); xd <= std::min<int>(objCenter.x + radious, map->width - 1); xd++)
|
||||
{
|
||||
@ -1407,6 +1409,13 @@ void CGameState::init(StartInfo * si, Mapa * map, int Seed)
|
||||
k->second.fogOfWarMap[xd][yd][objCenter.z] = 1;
|
||||
}
|
||||
}
|
||||
*/
|
||||
std::set<int3> tiles;
|
||||
obj->getSightTiles(tiles);
|
||||
BOOST_FOREACH(int3 tile, tiles)
|
||||
{
|
||||
k->second.fogOfWarMap[tile.x][tile.y][tile.z] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
//for(int xd=0; xd<map->width; ++xd) //revealing part of map around heroes
|
||||
|
@ -100,19 +100,24 @@ void IGameCallback::getTilesInRange( std::set<int3> &tiles, int3 pos, int radiou
|
||||
tlog1 << "Illegal call to getTilesInRange!\n";
|
||||
return;
|
||||
}
|
||||
|
||||
for (int xd = std::max<int>(pos.x - radious , 0); xd <= std::min<int>(pos.x + radious, gs->map->width - 1); xd++)
|
||||
if (radious == -1) //reveal entire map
|
||||
getAllTiles (tiles, player, -1, 0);
|
||||
else
|
||||
{
|
||||
for (int yd = std::max<int>(pos.y - radious, 0); yd <= std::min<int>(pos.y + radious, gs->map->height - 1); yd++)
|
||||
PlayerState * plr = &gs->players.find(player)->second;
|
||||
for (int xd = std::max<int>(pos.x - radious , 0); xd <= std::min<int>(pos.x + radious, gs->map->width - 1); xd++)
|
||||
{
|
||||
double distance = pos.dist2d(int3(xd,yd,pos.z)) - 0.5;
|
||||
if(distance <= radious)
|
||||
for (int yd = std::max<int>(pos.y - radious, 0); yd <= std::min<int>(pos.y + radious, gs->map->height - 1); yd++)
|
||||
{
|
||||
if(player < 0
|
||||
|| (mode == 1 && gs->players.find(player)->second.fogOfWarMap[xd][yd][pos.z]==0)
|
||||
|| (mode == -1 && gs->players.find(player)->second.fogOfWarMap[xd][yd][pos.z]==1)
|
||||
)
|
||||
tiles.insert(int3(xd,yd,pos.z));
|
||||
double distance = pos.dist2d(int3(xd,yd,pos.z)) - 0.5;
|
||||
if(distance <= radious)
|
||||
{
|
||||
if(player < 0
|
||||
|| (mode == 1 && plr->fogOfWarMap[xd][yd][pos.z]==0)
|
||||
|| (mode == -1 && plr->fogOfWarMap[xd][yd][pos.z]==1)
|
||||
)
|
||||
tiles.insert(int3(xd,yd,pos.z));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -122,7 +127,7 @@ void IGameCallback::getAllTiles (std::set<int3> &tiles, int player/*=-1*/, int l
|
||||
{
|
||||
if(player >= PLAYER_LIMIT)
|
||||
{
|
||||
tlog1 << "Illegal call to getTilesInRange!\n";
|
||||
tlog1 << "Illegal call to getAllTiles !\n";
|
||||
return;
|
||||
}
|
||||
bool water = surface == 0 || surface == 2,
|
||||
|
@ -2039,9 +2039,16 @@ bool CGameHandler::buildStructure( si32 tid, si32 bid )
|
||||
sendAndApply(&ssi);
|
||||
}
|
||||
|
||||
//reveal ground for lookout tower
|
||||
/* sdl conflict
|
||||
ns.bid.insert(bid);
|
||||
ns.builded = t->builded + 1;
|
||||
sendAndApply(&ns);
|
||||
*/
|
||||
|
||||
FoWChange fw;
|
||||
t->getSightTiles(fw.tiles);
|
||||
sendAndApply(&fw);
|
||||
|
||||
SetResources sr;
|
||||
sr.player = t->tempOwner;
|
||||
@ -2061,12 +2068,6 @@ bool CGameHandler::buildStructure( si32 tid, si32 bid )
|
||||
vistiCastleObjects (t, t->visitingHero);
|
||||
if(t->garrisonHero)
|
||||
vistiCastleObjects (t, t->garrisonHero);
|
||||
//reveal ground for lookout tower
|
||||
FoWChange fw;
|
||||
fw.player = t->tempOwner;
|
||||
fw.mode = 1;
|
||||
getTilesInRange(fw.tiles, t->pos, t->getSightRadious(), t->tempOwner,1);
|
||||
sendAndApply(&fw);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user