1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

* resolving #41 and #36

* small improvements
This commit is contained in:
mateuszb 2007-10-17 20:05:49 +00:00
parent 97f4fbcce8
commit c1e9e9b750
8 changed files with 114 additions and 59 deletions

View File

@ -102,6 +102,16 @@ bool CCallback::moveHero(int ID, CPath * path, int idtype, int pathType)
{ {
hero->pos = endpos; hero->pos = endpos;
}*/ }*/
for(int xd=0; xd<CGI->ac->map.width; ++xd) //revealing part of map around heroes
{
for(int yd=0; yd<CGI->ac->map.height; ++yd)
{
int deltaX = (endpos.x-xd)*(endpos.x-xd);
int deltaY = (endpos.y-yd)*(endpos.y-yd);
if(deltaX+deltaY<=hero->getSightDistance()*hero->getSightDistance())
gs->players[player].fogOfWarMap[xd][yd][endpos.z] = 1;
}
}
if((hero->movement>=CGI->mh->getCost(stpos, endpos, hero)) || player==-1) if((hero->movement>=CGI->mh->getCost(stpos, endpos, hero)) || player==-1)
{ //performing move { //performing move
hero->movement-=CGI->mh->getCost(stpos, endpos, hero); hero->movement-=CGI->mh->getCost(stpos, endpos, hero);

44
CMT.cpp
View File

@ -145,17 +145,30 @@ void initGameState(CGameInfo * cgi)
for(std::map<int, PlayerState>::iterator k=cgi->state->players.begin(); k!=cgi->state->players.end(); ++k) for(std::map<int, PlayerState>::iterator k=cgi->state->players.begin(); k!=cgi->state->players.end(); ++k)
{ {
k->second.fogOfWarMap.resize(cgi->ac->map.width, Woff); k->second.fogOfWarMap.resize(cgi->ac->map.width, Woff);
for(int g=0; g<cgi->ac->map.width; ++g) for(int g=-Woff; g<cgi->ac->map.width+Woff; ++g)
k->second.fogOfWarMap[g].resize(cgi->ac->map.height, Hoff); k->second.fogOfWarMap[g].resize(cgi->ac->map.height, Hoff);
for(int g=0; g<cgi->ac->map.width; ++g) for(int g=-Woff; g<cgi->ac->map.width+Woff; ++g)
for(int h=0; h<cgi->ac->map.height; ++h) for(int h=-Hoff; h<cgi->ac->map.height+Hoff; ++h)
k->second.fogOfWarMap[g][h].resize(cgi->ac->map.twoLevel+1, 0); k->second.fogOfWarMap[g][h].resize(cgi->ac->map.twoLevel+1, 0);
for(int g=0; g<cgi->ac->map.width; ++g) for(int g=-Woff; g<cgi->ac->map.width+Woff; ++g)
for(int h=0; h<cgi->ac->map.height; ++h) for(int h=-Hoff; h<cgi->ac->map.height+Hoff; ++h)
for(int v=0; v<cgi->ac->map.twoLevel+1; ++v) for(int v=0; v<cgi->ac->map.twoLevel+1; ++v)
k->second.fogOfWarMap[g][h][v] = 1; k->second.fogOfWarMap[g][h][v] = 0;
for(int xd=0; xd<cgi->ac->map.width; ++xd) //revealing part of map around heroes
{
for(int yd=0; yd<cgi->ac->map.height; ++yd)
{
for(int ch=0; ch<k->second.heroes.size(); ++ch)
{
int deltaX = (k->second.heroes[ch]->getPosition(false).x-xd)*(k->second.heroes[ch]->getPosition(false).x-xd);
int deltaY = (k->second.heroes[ch]->getPosition(false).y-yd)*(k->second.heroes[ch]->getPosition(false).y-yd);
if(deltaX+deltaY<=k->second.heroes[ch]->getSightDistance()*k->second.heroes[ch]->getSightDistance())
k->second.fogOfWarMap[xd][yd][k->second.heroes[ch]->getPosition(false).z] = 1;
}
}
}
} }
/****************************TOWNS************************************************/ /****************************TOWNS************************************************/
for (int i=0;i<cgi->townh->townInstances.size();i++) for (int i=0;i<cgi->townh->townInstances.size();i++)
@ -167,6 +180,25 @@ void initGameState(CGameInfo * cgi)
cgi->state->players[vti->owner].towns.push_back(vti); cgi->state->players[vti->owner].towns.push_back(vti);
} }
for(std::map<int, PlayerState>::iterator k=cgi->state->players.begin(); k!=cgi->state->players.end(); ++k)
{
if(k->first==-1 || k->first==255)
continue;
for(int xd=0; xd<cgi->ac->map.width; ++xd) //revealing part of map around towns
{
for(int yd=0; yd<cgi->ac->map.height; ++yd)
{
for(int ch=0; ch<k->second.towns.size(); ++ch)
{
int deltaX = (k->second.towns[ch]->pos.x-xd)*(k->second.towns[ch]->pos.x-xd);
int deltaY = (k->second.towns[ch]->pos.y-yd)*(k->second.towns[ch]->pos.y-yd);
if(deltaX+deltaY<=k->second.towns[ch]->getSightDistance()*k->second.towns[ch]->getSightDistance())
k->second.fogOfWarMap[xd][yd][k->second.towns[ch]->pos.z] = 1;
}
}
}
}
} }
int _tmain(int argc, _TCHAR* argv[]) int _tmain(int argc, _TCHAR* argv[])

View File

@ -536,3 +536,8 @@ void CHeroHandler::initTerrainCosts()
} }
inp.close(); inp.close();
} }
int CHeroInstance::getSightDistance() const //TODO: finish
{
return 6;
}

View File

@ -72,6 +72,7 @@ public:
unsigned float getMultiplicativeMoveBonus(); unsigned float getMultiplicativeMoveBonus();
static int3 convertPosition(int3 src, bool toh3m); //toh3m=true: manifest->h3m; toh3m=false: h3m->manifest static int3 convertPosition(int3 src, bool toh3m); //toh3m=true: manifest->h3m; toh3m=false: h3m->manifest
int3 getPosition(bool h3m) const; //h3m=true - returns position of hero object; h3m=false - returns position of hero 'manifestation' int3 getPosition(bool h3m) const; //h3m=true - returns position of hero object; h3m=false - returns position of hero 'manifestation'
int getSightDistance() const; //returns sight distance of this hero
void setPosition(int3 Pos, bool h3m); //as above, but sets position void setPosition(int3 Pos, bool h3m); //as above, but sets position
bool canWalkOnSea() const; bool canWalkOnSea() const;

View File

@ -72,3 +72,8 @@ CTownInstance::CTownInstance()
owner=-1; owner=-1;
town=NULL; town=NULL;
} }
int CTownInstance::getSightDistance() const //TODO: finish
{
return 10;
}

View File

@ -57,6 +57,8 @@ public:
std::vector<CSpell *> possibleSpells, obligatorySpells, availableSpells; std::vector<CSpell *> possibleSpells, obligatorySpells, availableSpells;
int getSightDistance() const; //returns sight distance
CTownInstance(); CTownInstance();
}; };

View File

@ -1000,199 +1000,199 @@ SDL_Surface * CMapHandler::undTerrBitmap(int x, int y)
return ttiles[x+Woff][y+Hoff][0].terbitmap[1]; return ttiles[x+Woff][y+Hoff][0].terbitmap[1];
} }
SDL_Surface * CMapHandler::getVisBitmap(int x, int y, const PseudoV< PseudoV< PseudoV<unsigned char> > > & visibilityMap, int lvl) SDL_Surface * CMapHandler::getVisBitmap(int x, int y, PseudoV< PseudoV< PseudoV<unsigned char> > > & visibilityMap, int lvl)
{ {
if(visibility[x][y+1][lvl] && visibility[x+1][y][lvl] && visibility[x-1][y][lvl] && visibility[x][y-1][lvl] && visibility[x-1][y-1][lvl] && visibility[x+1][y+1][lvl] && visibility[x+1][y-1][lvl] && visibility[x-1][y+1][lvl]) if(!visibilityMap[x][y+1][lvl] && !visibilityMap[x+1][y][lvl] && !visibilityMap[x-1][y][lvl] && !visibilityMap[x][y-1][lvl] && !visibilityMap[x-1][y-1][lvl] && !visibilityMap[x+1][y+1][lvl] && !visibilityMap[x+1][y-1][lvl] && !visibilityMap[x-1][y+1][lvl])
{ {
return fullHide->ourImages[rand()%fullHide->ourImages.size()].bitmap; //fully hidden return fullHide->ourImages[rand()%fullHide->ourImages.size()].bitmap; //fully hidden
} }
else if(visibility[x][y+1][lvl] && visibility[x+1][y][lvl] && visibility[x-1][y][lvl] && visibility[x][y-1][lvl] && visibility[x-1][y-1][lvl] && !visibility[x+1][y+1][lvl] && visibility[x+1][y-1][lvl] && visibility[x-1][y+1][lvl]) else if(!visibilityMap[x][y+1][lvl] && !visibilityMap[x+1][y][lvl] && !visibilityMap[x-1][y][lvl] && !visibilityMap[x][y-1][lvl] && !visibilityMap[x-1][y-1][lvl] && visibilityMap[x+1][y+1][lvl] && !visibilityMap[x+1][y-1][lvl] && !visibilityMap[x-1][y+1][lvl])
{ {
return partialHide->ourImages[22].bitmap; //visible right bottom corner return partialHide->ourImages[22].bitmap; //visible right bottom corner
} }
else if(visibility[x][y+1][lvl] && visibility[x+1][y][lvl] && visibility[x-1][y][lvl] && visibility[x][y-1][lvl] && visibility[x-1][y-1][lvl] && visibility[x+1][y+1][lvl] && !visibility[x+1][y-1][lvl] && visibility[x-1][y+1][lvl]) else if(!visibilityMap[x][y+1][lvl] && !visibilityMap[x+1][y][lvl] && !visibilityMap[x-1][y][lvl] && !visibilityMap[x][y-1][lvl] && !visibilityMap[x-1][y-1][lvl] && !visibilityMap[x+1][y+1][lvl] && visibilityMap[x+1][y-1][lvl] && !visibilityMap[x-1][y+1][lvl])
{ {
return partialHide->ourImages[15].bitmap; //visible right top corner return partialHide->ourImages[15].bitmap; //visible right top corner
} }
else if(visibility[x][y+1][lvl] && visibility[x+1][y][lvl] && visibility[x-1][y][lvl] && visibility[x][y-1][lvl] && visibility[x-1][y-1][lvl] && visibility[x+1][y+1][lvl] && visibility[x+1][y-1][lvl] && !visibility[x-1][y+1][lvl]) else if(!visibilityMap[x][y+1][lvl] && !visibilityMap[x+1][y][lvl] && !visibilityMap[x-1][y][lvl] && !visibilityMap[x][y-1][lvl] && !visibilityMap[x-1][y-1][lvl] && !visibilityMap[x+1][y+1][lvl] && !visibilityMap[x+1][y-1][lvl] && visibilityMap[x-1][y+1][lvl])
{ {
return CSDL_Ext::rotate01(partialHide->ourImages[22].bitmap); //visible left bottom corner return CSDL_Ext::rotate01(partialHide->ourImages[22].bitmap); //visible left bottom corner
} }
else if(visibility[x][y+1][lvl] && visibility[x+1][y][lvl] && visibility[x-1][y][lvl] && visibility[x][y-1][lvl] && !visibility[x-1][y-1][lvl] && visibility[x+1][y+1][lvl] && visibility[x+1][y-1][lvl] && visibility[x-1][y+1][lvl]) else if(!visibilityMap[x][y+1][lvl] && !visibilityMap[x+1][y][lvl] && !visibilityMap[x-1][y][lvl] && !visibilityMap[x][y-1][lvl] && visibilityMap[x-1][y-1][lvl] && !visibilityMap[x+1][y+1][lvl] && !visibilityMap[x+1][y-1][lvl] && !visibilityMap[x-1][y+1][lvl])
{ {
return CSDL_Ext::rotate01(partialHide->ourImages[15].bitmap); //visible left top corner return CSDL_Ext::rotate01(partialHide->ourImages[15].bitmap); //visible left top corner
} }
else if(visibility[x][y+1][lvl] && visibility[x+1][y][lvl] && visibility[x-1][y][lvl] && !visibility[x][y-1][lvl] && !visibility[x-1][y-1][lvl] && visibility[x+1][y+1][lvl] && !visibility[x+1][y-1][lvl] && visibility[x-1][y+1][lvl]) else if(!visibilityMap[x][y+1][lvl] && !visibilityMap[x+1][y][lvl] && !visibilityMap[x-1][y][lvl] && visibilityMap[x][y-1][lvl] && visibilityMap[x-1][y-1][lvl] && !visibilityMap[x+1][y+1][lvl] && visibilityMap[x+1][y-1][lvl] && !visibilityMap[x-1][y+1][lvl])
{ {
//return partialHide->ourImages[rand()%2].bitmap; //visible top //return partialHide->ourImages[rand()%2].bitmap; //visible top
return partialHide->ourImages[0].bitmap; //visible top return partialHide->ourImages[0].bitmap; //visible top
} }
else if(!visibility[x][y+1][lvl] && visibility[x+1][y][lvl] && visibility[x-1][y][lvl] && visibility[x][y-1][lvl] && visibility[x-1][y-1][lvl] && !visibility[x+1][y+1][lvl] && visibility[x+1][y-1][lvl] && !visibility[x-1][y+1][lvl]) else if(visibilityMap[x][y+1][lvl] && !visibilityMap[x+1][y][lvl] && !visibilityMap[x-1][y][lvl] && !visibilityMap[x][y-1][lvl] && !visibilityMap[x-1][y-1][lvl] && visibilityMap[x+1][y+1][lvl] && !visibilityMap[x+1][y-1][lvl] && visibilityMap[x-1][y+1][lvl])
{ {
//return partialHide->ourImages[4+rand()%2].bitmap; //visble bottom //return partialHide->ourImages[4+rand()%2].bitmap; //visble bottom
return partialHide->ourImages[4].bitmap; //visble bottom return partialHide->ourImages[4].bitmap; //visble bottom
} }
else if(visibility[x][y+1][lvl] && visibility[x+1][y][lvl] && !visibility[x-1][y][lvl] && visibility[x][y-1][lvl] && !visibility[x-1][y-1][lvl] && visibility[x+1][y+1][lvl] && visibility[x+1][y-1][lvl] && !visibility[x-1][y+1][lvl]) else if(!visibilityMap[x][y+1][lvl] && !visibilityMap[x+1][y][lvl] && visibilityMap[x-1][y][lvl] && !visibilityMap[x][y-1][lvl] && visibilityMap[x-1][y-1][lvl] && !visibilityMap[x+1][y+1][lvl] && !visibilityMap[x+1][y-1][lvl] && visibilityMap[x-1][y+1][lvl])
{ {
//return CSDL_Ext::rotate01(partialHide->ourImages[2+rand()%2].bitmap); //visible left //return CSDL_Ext::rotate01(partialHide->ourImages[2+rand()%2].bitmap); //visible left
return CSDL_Ext::rotate01(partialHide->ourImages[2].bitmap); //visible left return CSDL_Ext::rotate01(partialHide->ourImages[2].bitmap); //visible left
} }
else if(visibility[x][y+1][lvl] && !visibility[x+1][y][lvl] && visibility[x-1][y][lvl] && visibility[x][y-1][lvl] && visibility[x-1][y-1][lvl] && !visibility[x+1][y+1][lvl] && !visibility[x+1][y-1][lvl] && visibility[x-1][y+1][lvl]) else if(!visibilityMap[x][y+1][lvl] && visibilityMap[x+1][y][lvl] && !visibilityMap[x-1][y][lvl] && !visibilityMap[x][y-1][lvl] && !visibilityMap[x-1][y-1][lvl] && visibilityMap[x+1][y+1][lvl] && visibilityMap[x+1][y-1][lvl] && !visibilityMap[x-1][y+1][lvl])
{ {
//return partialHide->ourImages[2+rand()%2].bitmap; //visible right //return partialHide->ourImages[2+rand()%2].bitmap; //visible right
return partialHide->ourImages[2].bitmap; //visible right return partialHide->ourImages[2].bitmap; //visible right
} }
else if(!visibility[x][y+1][lvl] && !visibility[x+1][y][lvl] && visibility[x-1][y][lvl] && visibility[x][y-1][lvl] && visibility[x-1][y-1][lvl]) else if(visibilityMap[x][y+1][lvl] && visibilityMap[x+1][y][lvl] && !visibilityMap[x-1][y][lvl] && !visibilityMap[x][y-1][lvl] && !visibilityMap[x-1][y-1][lvl])
{ {
//return partialHide->ourImages[12+2*(rand()%2)].bitmap; //visible bottom, right - bottom, right; left top corner hidden //return partialHide->ourImages[12+2*(rand()%2)].bitmap; //visible bottom, right - bottom, right; left top corner hidden
return partialHide->ourImages[12].bitmap; //visible bottom, right - bottom, right; left top corner hidden return partialHide->ourImages[12].bitmap; //visible bottom, right - bottom, right; left top corner hidden
} }
else if(visibility[x][y+1][lvl] && !visibility[x+1][y][lvl] && visibility[x-1][y][lvl] && !visibility[x][y-1][lvl] && visibility[x-1][y+1][lvl]) else if(!visibilityMap[x][y+1][lvl] && visibilityMap[x+1][y][lvl] && !visibilityMap[x-1][y][lvl] && visibilityMap[x][y-1][lvl] && !visibilityMap[x-1][y+1][lvl])
{ {
return partialHide->ourImages[13].bitmap; //visible right, right - top; left bottom corner hidden return partialHide->ourImages[13].bitmap; //visible right, right - top; left bottom corner hidden
} }
else if(visibility[x][y+1][lvl] && visibility[x+1][y][lvl] && !visibility[x-1][y][lvl] && !visibility[x][y-1][lvl] && visibility[x+1][y+1][lvl]) else if(!visibilityMap[x][y+1][lvl] && !visibilityMap[x+1][y][lvl] && visibilityMap[x-1][y][lvl] && visibilityMap[x][y-1][lvl] && !visibilityMap[x+1][y+1][lvl])
{ {
return CSDL_Ext::rotate01(partialHide->ourImages[13].bitmap); //visible top, top - left, left; right bottom corner hidden return CSDL_Ext::rotate01(partialHide->ourImages[13].bitmap); //visible top, top - left, left; right bottom corner hidden
} }
else if(!visibility[x][y+1][lvl] && visibility[x+1][y][lvl] && !visibility[x-1][y][lvl] && visibility[x][y-1][lvl] && visibility[x+1][y-1][lvl]) else if(visibilityMap[x][y+1][lvl] && !visibilityMap[x+1][y][lvl] && visibilityMap[x-1][y][lvl] && !visibilityMap[x][y-1][lvl] && !visibilityMap[x+1][y-1][lvl])
{ {
//return CSDL_Ext::rotate01(partialHide->ourImages[12+2*(rand()%2)].bitmap); //visible left, left - bottom, bottom; right top corner hidden //return CSDL_Ext::rotate01(partialHide->ourImages[12+2*(rand()%2)].bitmap); //visible left, left - bottom, bottom; right top corner hidden
return CSDL_Ext::rotate01(partialHide->ourImages[12].bitmap); //visible left, left - bottom, bottom; right top corner hidden return CSDL_Ext::rotate01(partialHide->ourImages[12].bitmap); //visible left, left - bottom, bottom; right top corner hidden
} }
else if(!visibility[x][y+1][lvl] && !visibility[x+1][y][lvl] && !visibility[x-1][y][lvl] && !visibility[x][y-1][lvl] && !visibility[x-1][y-1][lvl] && !visibility[x+1][y+1][lvl] && !visibility[x+1][y-1][lvl] && !visibility[x-1][y+1][lvl]) else if(visibilityMap[x][y+1][lvl] && visibilityMap[x+1][y][lvl] && visibilityMap[x-1][y][lvl] && visibilityMap[x][y-1][lvl] && visibilityMap[x-1][y-1][lvl] && visibilityMap[x+1][y+1][lvl] && visibilityMap[x+1][y-1][lvl] && visibilityMap[x-1][y+1][lvl])
{ {
return partialHide->ourImages[10].bitmap; //visible left, right, bottom and top return partialHide->ourImages[10].bitmap; //visible left, right, bottom and top
} }
if(visibility[x][y+1][lvl] && visibility[x+1][y][lvl] && visibility[x-1][y][lvl] && visibility[x][y-1][lvl] && visibility[x-1][y-1][lvl] && !visibility[x+1][y+1][lvl] && !visibility[x+1][y-1][lvl] && visibility[x-1][y+1][lvl]) if(!visibilityMap[x][y+1][lvl] && !visibilityMap[x+1][y][lvl] && !visibilityMap[x-1][y][lvl] && !visibilityMap[x][y-1][lvl] && !visibilityMap[x-1][y-1][lvl] && visibilityMap[x+1][y+1][lvl] && visibilityMap[x+1][y-1][lvl] && !visibilityMap[x-1][y+1][lvl])
{ {
return partialHide->ourImages[16].bitmap; //visible right corners return partialHide->ourImages[16].bitmap; //visible right corners
} }
if(visibility[x][y+1][lvl] && visibility[x+1][y][lvl] && visibility[x-1][y][lvl] && visibility[x][y-1][lvl] && !visibility[x-1][y-1][lvl] && visibility[x+1][y+1][lvl] && !visibility[x+1][y-1][lvl] && visibility[x-1][y+1][lvl]) if(!visibilityMap[x][y+1][lvl] && !visibilityMap[x+1][y][lvl] && !visibilityMap[x-1][y][lvl] && !visibilityMap[x][y-1][lvl] && visibilityMap[x-1][y-1][lvl] && !visibilityMap[x+1][y+1][lvl] && visibilityMap[x+1][y-1][lvl] && !visibilityMap[x-1][y+1][lvl])
{ {
return partialHide->ourImages[18].bitmap; //visible top corners return partialHide->ourImages[18].bitmap; //visible top corners
} }
if(visibility[x][y+1][lvl] && visibility[x+1][y][lvl] && visibility[x-1][y][lvl] && visibility[x][y-1][lvl] && !visibility[x-1][y-1][lvl] && visibility[x+1][y+1][lvl] && visibility[x+1][y-1][lvl] && !visibility[x-1][y+1][lvl]) if(!visibilityMap[x][y+1][lvl] && !visibilityMap[x+1][y][lvl] && !visibilityMap[x-1][y][lvl] && !visibilityMap[x][y-1][lvl] && visibilityMap[x-1][y-1][lvl] && !visibilityMap[x+1][y+1][lvl] && !visibilityMap[x+1][y-1][lvl] && visibilityMap[x-1][y+1][lvl])
{ {
return CSDL_Ext::rotate01(partialHide->ourImages[16].bitmap); //visible left corners return CSDL_Ext::rotate01(partialHide->ourImages[16].bitmap); //visible left corners
} }
if(visibility[x][y+1][lvl] && visibility[x+1][y][lvl] && visibility[x-1][y][lvl] && visibility[x][y-1][lvl] && visibility[x-1][y-1][lvl] && !visibility[x+1][y+1][lvl] && visibility[x+1][y-1][lvl] && !visibility[x-1][y+1][lvl]) if(!visibilityMap[x][y+1][lvl] && !visibilityMap[x+1][y][lvl] && !visibilityMap[x-1][y][lvl] && !visibilityMap[x][y-1][lvl] && !visibilityMap[x-1][y-1][lvl] && visibilityMap[x+1][y+1][lvl] && !visibilityMap[x+1][y-1][lvl] && visibilityMap[x-1][y+1][lvl])
{ {
return CSDL_Ext::hFlip(partialHide->ourImages[18].bitmap); //visible bottom corners return CSDL_Ext::hFlip(partialHide->ourImages[18].bitmap); //visible bottom corners
} }
if(visibility[x][y+1][lvl] && visibility[x+1][y][lvl] && visibility[x-1][y][lvl] && visibility[x][y-1][lvl] && visibility[x-1][y-1][lvl] && visibility[x+1][y+1][lvl] && !visibility[x+1][y-1][lvl] && !visibility[x-1][y+1][lvl]) if(!visibilityMap[x][y+1][lvl] && !visibilityMap[x+1][y][lvl] && !visibilityMap[x-1][y][lvl] && !visibilityMap[x][y-1][lvl] && !visibilityMap[x-1][y-1][lvl] && !visibilityMap[x+1][y+1][lvl] && visibilityMap[x+1][y-1][lvl] && visibilityMap[x-1][y+1][lvl])
{ {
return partialHide->ourImages[17].bitmap; //visible right - top and bottom - left corners return partialHide->ourImages[17].bitmap; //visible right - top and bottom - left corners
} }
if(visibility[x][y+1][lvl] && visibility[x+1][y][lvl] && visibility[x-1][y][lvl] && visibility[x][y-1][lvl] && !visibility[x-1][y-1][lvl] && !visibility[x+1][y+1][lvl] && visibility[x+1][y-1][lvl] && visibility[x-1][y+1][lvl]) if(!visibilityMap[x][y+1][lvl] && !visibilityMap[x+1][y][lvl] && !visibilityMap[x-1][y][lvl] && !visibilityMap[x][y-1][lvl] && visibilityMap[x-1][y-1][lvl] && visibilityMap[x+1][y+1][lvl] && !visibilityMap[x+1][y-1][lvl] && !visibilityMap[x-1][y+1][lvl])
{ {
return CSDL_Ext::hFlip(partialHide->ourImages[17].bitmap); //visible top - left and bottom - right corners return CSDL_Ext::hFlip(partialHide->ourImages[17].bitmap); //visible top - left and bottom - right corners
} }
if(visibility[x][y+1][lvl] && visibility[x+1][y][lvl] && visibility[x-1][y][lvl] && visibility[x][y-1][lvl] && visibility[x-1][y-1][lvl] && !visibility[x+1][y+1][lvl] && !visibility[x+1][y-1][lvl] && !visibility[x-1][y+1][lvl]) if(!visibilityMap[x][y+1][lvl] && !visibilityMap[x+1][y][lvl] && !visibilityMap[x-1][y][lvl] && !visibilityMap[x][y-1][lvl] && !visibilityMap[x-1][y-1][lvl] && visibilityMap[x+1][y+1][lvl] && visibilityMap[x+1][y-1][lvl] && visibilityMap[x-1][y+1][lvl])
{ {
return partialHide->ourImages[19].bitmap; //visible corners without left top return partialHide->ourImages[19].bitmap; //visible corners without left top
} }
if(visibility[x][y+1][lvl] && visibility[x+1][y][lvl] && visibility[x-1][y][lvl] && visibility[x][y-1][lvl] && !visibility[x-1][y-1][lvl] && !visibility[x+1][y+1][lvl] && !visibility[x+1][y-1][lvl] && visibility[x-1][y+1][lvl]) if(!visibilityMap[x][y+1][lvl] && !visibilityMap[x+1][y][lvl] && !visibilityMap[x-1][y][lvl] && !visibilityMap[x][y-1][lvl] && visibilityMap[x-1][y-1][lvl] && visibilityMap[x+1][y+1][lvl] && visibilityMap[x+1][y-1][lvl] && !visibilityMap[x-1][y+1][lvl])
{ {
return partialHide->ourImages[20].bitmap; //visible corners without left bottom return partialHide->ourImages[20].bitmap; //visible corners without left bottom
} }
if(visibility[x][y+1][lvl] && visibility[x+1][y][lvl] && visibility[x-1][y][lvl] && visibility[x][y-1][lvl] && !visibility[x-1][y-1][lvl] && visibility[x+1][y+1][lvl] && !visibility[x+1][y-1][lvl] && !visibility[x-1][y+1][lvl]) if(!visibilityMap[x][y+1][lvl] && !visibilityMap[x+1][y][lvl] && !visibilityMap[x-1][y][lvl] && !visibilityMap[x][y-1][lvl] && visibilityMap[x-1][y-1][lvl] && !visibilityMap[x+1][y+1][lvl] && visibilityMap[x+1][y-1][lvl] && visibilityMap[x-1][y+1][lvl])
{ {
return CSDL_Ext::rotate01(partialHide->ourImages[20].bitmap); //visible corners without right bottom return CSDL_Ext::rotate01(partialHide->ourImages[20].bitmap); //visible corners without right bottom
} }
if(visibility[x][y+1][lvl] && visibility[x+1][y][lvl] && visibility[x-1][y][lvl] && visibility[x][y-1][lvl] && !visibility[x-1][y-1][lvl] && !visibility[x+1][y+1][lvl] && visibility[x+1][y-1][lvl] && !visibility[x-1][y+1][lvl]) if(!visibilityMap[x][y+1][lvl] && !visibilityMap[x+1][y][lvl] && !visibilityMap[x-1][y][lvl] && !visibilityMap[x][y-1][lvl] && visibilityMap[x-1][y-1][lvl] && visibilityMap[x+1][y+1][lvl] && !visibilityMap[x+1][y-1][lvl] && visibilityMap[x-1][y+1][lvl])
{ {
return CSDL_Ext::rotate01(partialHide->ourImages[19].bitmap); //visible corners without right top return CSDL_Ext::rotate01(partialHide->ourImages[19].bitmap); //visible corners without right top
} }
if(visibility[x][y+1][lvl] && visibility[x+1][y][lvl] && visibility[x-1][y][lvl] && visibility[x][y-1][lvl] && !visibility[x-1][y-1][lvl] && !visibility[x+1][y+1][lvl] && !visibility[x+1][y-1][lvl] && !visibility[x-1][y+1][lvl]) if(!visibilityMap[x][y+1][lvl] && !visibilityMap[x+1][y][lvl] && !visibilityMap[x-1][y][lvl] && !visibilityMap[x][y-1][lvl] && visibilityMap[x-1][y-1][lvl] && visibilityMap[x+1][y+1][lvl] && visibilityMap[x+1][y-1][lvl] && visibilityMap[x-1][y+1][lvl])
{ {
return partialHide->ourImages[21].bitmap; //visible all corners only return partialHide->ourImages[21].bitmap; //visible all corners only
} }
if(!visibility[x][y+1][lvl] && !visibility[x+1][y][lvl] && !visibility[x-1][y][lvl] && visibility[x][y-1][lvl]) if(visibilityMap[x][y+1][lvl] && visibilityMap[x+1][y][lvl] && visibilityMap[x-1][y][lvl] && !visibilityMap[x][y-1][lvl])
{ {
return partialHide->ourImages[6].bitmap; //hidden top return partialHide->ourImages[6].bitmap; //hidden top
} }
if(!visibility[x][y+1][lvl] && visibility[x+1][y][lvl] && !visibility[x-1][y][lvl] && !visibility[x][y-1][lvl]) if(visibilityMap[x][y+1][lvl] && !visibilityMap[x+1][y][lvl] && visibilityMap[x-1][y][lvl] && visibilityMap[x][y-1][lvl])
{ {
return partialHide->ourImages[7].bitmap; //hidden right return partialHide->ourImages[7].bitmap; //hidden right
} }
if(visibility[x][y+1][lvl] && !visibility[x+1][y][lvl] && !visibility[x-1][y][lvl] && !visibility[x][y-1][lvl]) if(!visibilityMap[x][y+1][lvl] && visibilityMap[x+1][y][lvl] && visibilityMap[x-1][y][lvl] && visibilityMap[x][y-1][lvl])
{ {
return partialHide->ourImages[8].bitmap; //hidden bottom return partialHide->ourImages[8].bitmap; //hidden bottom
} }
if(!visibility[x][y+1][lvl] && !visibility[x+1][y][lvl] && visibility[x-1][y][lvl] && !visibility[x][y-1][lvl]) if(visibilityMap[x][y+1][lvl] && visibilityMap[x+1][y][lvl] && !visibilityMap[x-1][y][lvl] && visibilityMap[x][y-1][lvl])
{ {
return CSDL_Ext::rotate01(partialHide->ourImages[6].bitmap); //hidden left return CSDL_Ext::rotate01(partialHide->ourImages[7].bitmap); //hidden left
} }
if(visibility[x][y+1][lvl] && !visibility[x+1][y][lvl] && !visibility[x-1][y][lvl] && !visibility[x][y-1][lvl]) if(!visibilityMap[x][y+1][lvl] && visibilityMap[x+1][y][lvl] && visibilityMap[x-1][y][lvl] && visibilityMap[x][y-1][lvl])
{ {
return partialHide->ourImages[9].bitmap; //hidden top and bottom return partialHide->ourImages[9].bitmap; //hidden top and bottom
} }
if(!visibility[x][y+1][lvl] && !visibility[x+1][y][lvl] && visibility[x-1][y][lvl] && !visibility[x][y-1][lvl]) if(visibilityMap[x][y+1][lvl] && visibilityMap[x+1][y][lvl] && !visibilityMap[x-1][y][lvl] && visibilityMap[x][y-1][lvl])
{ {
return partialHide->ourImages[29].bitmap; //hidden left and right return partialHide->ourImages[29].bitmap; //hidden left and right
} }
if(visibility[x][y+1][lvl] && visibility[x+1][y][lvl] && visibility[x-1][y][lvl] && !visibility[x][y-1][lvl] && !visibility[x+1][y+1][lvl] && visibility[x-1][y+1][lvl]) if(!visibilityMap[x][y+1][lvl] && !visibilityMap[x+1][y][lvl] && !visibilityMap[x-1][y][lvl] && visibilityMap[x][y-1][lvl] && visibilityMap[x+1][y+1][lvl] && !visibilityMap[x-1][y+1][lvl])
{ {
return partialHide->ourImages[24].bitmap; //visible top and right bottom corner return partialHide->ourImages[24].bitmap; //visible top and right bottom corner
} }
if(visibility[x][y+1][lvl] && visibility[x+1][y][lvl] && visibility[x-1][y][lvl] && !visibility[x][y-1][lvl] && visibility[x+1][y+1][lvl] && !visibility[x-1][y+1][lvl]) if(!visibilityMap[x][y+1][lvl] && !visibilityMap[x+1][y][lvl] && !visibilityMap[x-1][y][lvl] && visibilityMap[x][y-1][lvl] && !visibilityMap[x+1][y+1][lvl] && visibilityMap[x-1][y+1][lvl])
{ {
return CSDL_Ext::rotate01(partialHide->ourImages[24].bitmap); //visible top and left bottom corner return CSDL_Ext::rotate01(partialHide->ourImages[24].bitmap); //visible top and left bottom corner
} }
if(visibility[x][y+1][lvl] && visibility[x+1][y][lvl] && visibility[x-1][y][lvl] && !visibility[x][y-1][lvl] && !visibility[x+1][y+1][lvl] && !visibility[x-1][y+1][lvl]) if(!visibilityMap[x][y+1][lvl] && !visibilityMap[x+1][y][lvl] && !visibilityMap[x-1][y][lvl] && visibilityMap[x][y-1][lvl] && visibilityMap[x+1][y+1][lvl] && visibilityMap[x-1][y+1][lvl])
{ {
return partialHide->ourImages[33].bitmap; //visible top and bottom corners return partialHide->ourImages[33].bitmap; //visible top and bottom corners
} }
if(visibility[x][y+1][lvl] && visibility[x+1][y][lvl] && !visibility[x-1][y][lvl] && visibility[x][y-1][lvl] && visibility[x+1][y+1][lvl] && !visibility[x+1][y-1][lvl]) if(!visibilityMap[x][y+1][lvl] && !visibilityMap[x+1][y][lvl] && visibilityMap[x-1][y][lvl] && !visibilityMap[x][y-1][lvl] && !visibilityMap[x+1][y+1][lvl] && visibilityMap[x+1][y-1][lvl])
{ {
return CSDL_Ext::rotate01(partialHide->ourImages[26].bitmap); //visible left and right top corner return CSDL_Ext::rotate01(partialHide->ourImages[26].bitmap); //visible left and right top corner
} }
if(visibility[x][y+1][lvl] && visibility[x+1][y][lvl] && !visibility[x-1][y][lvl] && visibility[x][y-1][lvl] && !visibility[x+1][y+1][lvl] && visibility[x+1][y-1][lvl]) if(!visibilityMap[x][y+1][lvl] && !visibilityMap[x+1][y][lvl] && visibilityMap[x-1][y][lvl] && !visibilityMap[x][y-1][lvl] && visibilityMap[x+1][y+1][lvl] && !visibilityMap[x+1][y-1][lvl])
{ {
return CSDL_Ext::rotate01(partialHide->ourImages[25].bitmap); //visible left and right bottom corner return CSDL_Ext::rotate01(partialHide->ourImages[25].bitmap); //visible left and right bottom corner
} }
if(visibility[x][y+1][lvl] && visibility[x+1][y][lvl] && !visibility[x-1][y][lvl] && visibility[x][y-1][lvl] && !visibility[x+1][y+1][lvl] && !visibility[x+1][y-1][lvl]) if(!visibilityMap[x][y+1][lvl] && !visibilityMap[x+1][y][lvl] && visibilityMap[x-1][y][lvl] && !visibilityMap[x][y-1][lvl] && visibilityMap[x+1][y+1][lvl] && visibilityMap[x+1][y-1][lvl])
{ {
return partialHide->ourImages[32].bitmap; //visible left and right corners return partialHide->ourImages[32].bitmap; //visible left and right corners
} }
if(!visibility[x][y+1][lvl] && visibility[x+1][y][lvl] && visibility[x-1][y][lvl] && visibility[x][y-1][lvl] && !visibility[x-1][y-1][lvl] && visibility[x+1][y-1][lvl]) if(visibilityMap[x][y+1][lvl] && !visibilityMap[x+1][y][lvl] && !visibilityMap[x-1][y][lvl] && !visibilityMap[x][y-1][lvl] && visibilityMap[x-1][y-1][lvl] && !visibilityMap[x+1][y-1][lvl])
{ {
return CSDL_Ext::rotate01(partialHide->ourImages[30].bitmap); //visible bottom and left top corner return CSDL_Ext::rotate01(partialHide->ourImages[30].bitmap); //visible bottom and left top corner
} }
if(!visibility[x][y+1][lvl] && visibility[x+1][y][lvl] && visibility[x-1][y][lvl] && visibility[x][y-1][lvl] && visibility[x-1][y-1][lvl] && !visibility[x+1][y-1][lvl]) if(visibilityMap[x][y+1][lvl] && !visibilityMap[x+1][y][lvl] && !visibilityMap[x-1][y][lvl] && !visibilityMap[x][y-1][lvl] && !visibilityMap[x-1][y-1][lvl] && visibilityMap[x+1][y-1][lvl])
{ {
return partialHide->ourImages[30].bitmap; //visible bottom and right top corner return partialHide->ourImages[30].bitmap; //visible bottom and right top corner
} }
if(!visibility[x][y+1][lvl] && visibility[x+1][y][lvl] && visibility[x-1][y][lvl] && visibility[x][y-1][lvl] && !visibility[x-1][y-1][lvl] && !visibility[x+1][y-1][lvl]) if(visibilityMap[x][y+1][lvl] && !visibilityMap[x+1][y][lvl] && !visibilityMap[x-1][y][lvl] && !visibilityMap[x][y-1][lvl] && visibilityMap[x-1][y-1][lvl] && visibilityMap[x+1][y-1][lvl])
{ {
return partialHide->ourImages[31].bitmap; //visible bottom and top corners return partialHide->ourImages[31].bitmap; //visible bottom and top corners
} }
if(visibility[x][y+1][lvl] && !visibility[x+1][y][lvl] && visibility[x-1][y][lvl] && visibility[x][y-1][lvl] && visibility[x-1][y-1][lvl] && !visibility[x-1][y+1][lvl]) if(!visibilityMap[x][y+1][lvl] && visibilityMap[x+1][y][lvl] && !visibilityMap[x-1][y][lvl] && !visibilityMap[x][y-1][lvl] && !visibilityMap[x-1][y-1][lvl] && visibilityMap[x-1][y+1][lvl])
{ {
return partialHide->ourImages[25].bitmap; //visible right and left bottom corner return partialHide->ourImages[25].bitmap; //visible right and left bottom corner
} }
if(visibility[x][y+1][lvl] && !visibility[x+1][y][lvl] && visibility[x-1][y][lvl] && visibility[x][y-1][lvl] && !visibility[x-1][y-1][lvl] && visibility[x-1][y+1][lvl]) if(!visibilityMap[x][y+1][lvl] && visibilityMap[x+1][y][lvl] && !visibilityMap[x-1][y][lvl] && !visibilityMap[x][y-1][lvl] && visibilityMap[x-1][y-1][lvl] && !visibilityMap[x-1][y+1][lvl])
{ {
return partialHide->ourImages[26].bitmap; //visible right and left top corner return partialHide->ourImages[26].bitmap; //visible right and left top corner
} }
if(visibility[x][y+1][lvl] && !visibility[x+1][y][lvl] && visibility[x-1][y][lvl] && visibility[x][y-1][lvl] && !visibility[x-1][y-1][lvl] && !visibility[x-1][y+1][lvl]) if(!visibilityMap[x][y+1][lvl] && visibilityMap[x+1][y][lvl] && !visibilityMap[x-1][y][lvl] && !visibilityMap[x][y-1][lvl] && visibilityMap[x-1][y-1][lvl] && visibilityMap[x-1][y+1][lvl])
{ {
return CSDL_Ext::rotate01(partialHide->ourImages[32].bitmap); //visible right and left cornres return CSDL_Ext::rotate01(partialHide->ourImages[32].bitmap); //visible right and left cornres
} }
if(!visibility[x][y+1][lvl] && !visibility[x+1][y][lvl] && visibility[x-1][y][lvl] && visibility[x][y-1][lvl] && !visibility[x-1][y-1][lvl]) if(visibilityMap[x][y+1][lvl] && visibilityMap[x+1][y][lvl] && !visibilityMap[x-1][y][lvl] && !visibilityMap[x][y-1][lvl] && visibilityMap[x-1][y-1][lvl])
{ {
return partialHide->ourImages[28].bitmap; //visible bottom, right - bottom, right; left top corner visible return partialHide->ourImages[28].bitmap; //visible bottom, right - bottom, right; left top corner visible
} }
else if(visibility[x][y+1][lvl] && !visibility[x+1][y][lvl] && visibility[x-1][y][lvl] && !visibility[x][y-1][lvl] && !visibility[x-1][y+1][lvl]) else if(!visibilityMap[x][y+1][lvl] && visibilityMap[x+1][y][lvl] && !visibilityMap[x-1][y][lvl] && visibilityMap[x][y-1][lvl] && visibilityMap[x-1][y+1][lvl])
{ {
return partialHide->ourImages[27].bitmap; //visible right, right - top; left bottom corner visible return partialHide->ourImages[27].bitmap; //visible right, right - top; left bottom corner visible
} }
else if(visibility[x][y+1][lvl] && visibility[x+1][y][lvl] && !visibility[x-1][y][lvl] && !visibility[x][y-1][lvl] && !visibility[x+1][y+1][lvl]) else if(!visibilityMap[x][y+1][lvl] && !visibilityMap[x+1][y][lvl] && visibilityMap[x-1][y][lvl] && visibilityMap[x][y-1][lvl] && visibilityMap[x+1][y+1][lvl])
{ {
return CSDL_Ext::rotate01(partialHide->ourImages[27].bitmap); //visible top, top - left, left; right bottom corner visible return CSDL_Ext::rotate01(partialHide->ourImages[27].bitmap); //visible top, top - left, left; right bottom corner visible
} }
else if(!visibility[x][y+1][lvl] && visibility[x+1][y][lvl] && !visibility[x-1][y][lvl] && visibility[x][y-1][lvl] && !visibility[x+1][y-1][lvl]) else if(visibilityMap[x][y+1][lvl] && !visibilityMap[x+1][y][lvl] && visibilityMap[x-1][y][lvl] && !visibilityMap[x][y-1][lvl] && visibilityMap[x+1][y-1][lvl])
{ {
return CSDL_Ext::rotate01(partialHide->ourImages[28].bitmap); //visible left, left - bottom, bottom; right top corner visible return CSDL_Ext::rotate01(partialHide->ourImages[28].bitmap); //visible left, left - bottom, bottom; right top corner visible
} }
@ -1225,7 +1225,7 @@ std::vector < std::string > CMapHandler::getObjDescriptions(int3 pos)
std::vector<std::string> ret; std::vector<std::string> ret;
for(int g=0; g<objs.size(); ++g) for(int g=0; g<objs.size(); ++g)
{ {
if( (5-(objs[g].first->pos.y-pos.y-1)) >= 0 && (5-(objs[g].first->pos.y-pos.y-1)) < 6 && (objs[g].first->pos.x-pos.x-1) >= 0 && (objs[g].first->pos.x-pos.x-1)<7 && objs[g].first->defObjInfoNumber!=-1 && if( (5-(objs[g].first->pos.y-pos.y)) >= 0 && (5-(objs[g].first->pos.y-pos.y)) < 6 && (objs[g].first->pos.x-pos.x) >= 0 && (objs[g].first->pos.x-pos.x)<7 && objs[g].first->defObjInfoNumber!=-1 &&
(((CGI->dobjinfo->objs[objs[g].first->defObjInfoNumber].blockMap[5-(objs[g].first->pos.y-pos.y-1)])>>((objs[g].first->pos.x-pos.x-1)))&1)==0 (((CGI->dobjinfo->objs[objs[g].first->defObjInfoNumber].blockMap[5-(objs[g].first->pos.y-pos.y-1)])>>((objs[g].first->pos.x-pos.x-1)))&1)==0
) //checking position blocking ) //checking position blocking
{ {

View File

@ -74,7 +74,7 @@ public:
char & visAccess(int x, int y); char & visAccess(int x, int y);
char & undVisAccess(int x, int y); char & undVisAccess(int x, int y);
SDL_Surface mirrorImage(SDL_Surface *src); //what is this?? SDL_Surface mirrorImage(SDL_Surface *src); //what is this??
SDL_Surface * getVisBitmap(int x, int y, const PseudoV< PseudoV< PseudoV<unsigned char> > > & visibilityMap, int lvl); SDL_Surface * getVisBitmap(int x, int y, PseudoV< PseudoV< PseudoV<unsigned char> > > & visibilityMap, int lvl);
int getCost(int3 & a, int3 & b, const CHeroInstance * hero); int getCost(int3 & a, int3 & b, const CHeroInstance * hero);
std::vector< std::string > getObjDescriptions(int3 pos); //returns desriptions of objects blocking given position std::vector< std::string > getObjDescriptions(int3 pos); //returns desriptions of objects blocking given position