1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-07 00:58:39 +02:00

Fix: Terrain description should be shown correctly

This commit is contained in:
Dmitry Orlov
2021-11-06 00:08:48 +03:00
committed by Andrii Danylchenko
parent 7cfd1fe0ca
commit 0427fa45dd
4 changed files with 63 additions and 24 deletions

View File

@ -1394,30 +1394,52 @@ CMapHandler::CMapHandler()
egdeAnimation->preload();
}
void CMapHandler::getTerrainDescr( const int3 &pos, std::string & out, bool terName )
bool CMapHandler::hasObjectHole(const int3 & pos) const
{
out.clear();
TerrainTile2 & tt = ttiles[pos.x][pos.y][pos.z];
const TerrainTile &t = map->getTile(pos);
const TerrainTile2 & tt = ttiles[pos.x][pos.y][pos.z];
for(auto & elem : tt.objects)
{
if(elem.obj && elem.obj->ID == Obj::HOLE) //Hole
{
out = elem.obj->getObjectName();
return;
}
if(elem.obj && elem.obj->ID == Obj::HOLE)
return true;
}
return false;
}
void CMapHandler::getTerrainDescr(const int3 & pos, std::string & out, bool isRMB) const
{
const TerrainTile & t = map->getTile(pos);
if(t.hasFavorableWinds())
out = CGI->objtypeh->getObjectName(Obj::FAVORABLE_WINDS);
else if(terName)
{
out = CGI->generaltexth->terrainNames[t.terType];
if(t.getDiggingStatus(false) == EDiggingStatus::CAN_DIG)
out = CGI->objtypeh->getObjectName(Obj::FAVORABLE_WINDS);
return;
}
const TerrainTile2 & tt = ttiles[pos.x][pos.y][pos.z];
bool isTile2Terrain = false;
out.clear();
for(auto & elem : tt.objects)
{
if(elem.obj)
{
out = boost::str(boost::format("%s %s") % out % CGI->generaltexth->allTexts[330]); /// digging ok
out = elem.obj->getObjectName();
if(elem.obj->ID == Obj::HOLE)
return;
isTile2Terrain = elem.obj->isTile2Terrain();
break;
}
}
if(!isTile2Terrain || out.empty())
out = CGI->generaltexth->terrainNames[t.terType];
if(t.getDiggingStatus(false) == EDiggingStatus::CAN_DIG)
{
out = boost::str(boost::format(isRMB ? "%s\r\n%s" : "%s %s") // New line for the Message Box, space for the Status Bar
% out
% CGI->generaltexth->allTexts[330]); // 'digging ok'
}
}
void CMapHandler::discardWorldViewCache()