diff --git a/CCallback.cpp b/CCallback.cpp index 77542f1a5..fce1487b1 100644 --- a/CCallback.cpp +++ b/CCallback.cpp @@ -102,6 +102,16 @@ bool CCallback::moveHero(int ID, CPath * path, int idtype, int pathType) { hero->pos = endpos; }*/ + for(int xd=0; xdac->map.width; ++xd) //revealing part of map around heroes + { + for(int yd=0; ydac->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) { //performing move hero->movement-=CGI->mh->getCost(stpos, endpos, hero); diff --git a/CMT.cpp b/CMT.cpp index 2b61fec9c..483a993db 100644 --- a/CMT.cpp +++ b/CMT.cpp @@ -145,17 +145,30 @@ void initGameState(CGameInfo * cgi) for(std::map::iterator k=cgi->state->players.begin(); k!=cgi->state->players.end(); ++k) { k->second.fogOfWarMap.resize(cgi->ac->map.width, Woff); - for(int g=0; gac->map.width; ++g) + for(int g=-Woff; gac->map.width+Woff; ++g) k->second.fogOfWarMap[g].resize(cgi->ac->map.height, Hoff); - for(int g=0; gac->map.width; ++g) - for(int h=0; hac->map.height; ++h) + for(int g=-Woff; gac->map.width+Woff; ++g) + for(int h=-Hoff; hac->map.height+Hoff; ++h) k->second.fogOfWarMap[g][h].resize(cgi->ac->map.twoLevel+1, 0); - for(int g=0; gac->map.width; ++g) - for(int h=0; hac->map.height; ++h) + for(int g=-Woff; gac->map.width+Woff; ++g) + for(int h=-Hoff; hac->map.height+Hoff; ++h) for(int v=0; vac->map.twoLevel+1; ++v) - k->second.fogOfWarMap[g][h][v] = 1; + k->second.fogOfWarMap[g][h][v] = 0; + for(int xd=0; xdac->map.width; ++xd) //revealing part of map around heroes + { + for(int yd=0; ydac->map.height; ++yd) + { + for(int ch=0; chsecond.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************************************************/ for (int i=0;itownh->townInstances.size();i++) @@ -167,6 +180,25 @@ void initGameState(CGameInfo * cgi) cgi->state->players[vti->owner].towns.push_back(vti); } + + for(std::map::iterator k=cgi->state->players.begin(); k!=cgi->state->players.end(); ++k) + { + if(k->first==-1 || k->first==255) + continue; + for(int xd=0; xdac->map.width; ++xd) //revealing part of map around towns + { + for(int yd=0; ydac->map.height; ++yd) + { + for(int ch=0; chsecond.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[]) diff --git a/hch/CHeroHandler.cpp b/hch/CHeroHandler.cpp index f85fd5cf1..3d8e39607 100644 --- a/hch/CHeroHandler.cpp +++ b/hch/CHeroHandler.cpp @@ -535,4 +535,9 @@ void CHeroHandler::initTerrainCosts() } } inp.close(); -} \ No newline at end of file +} + +int CHeroInstance::getSightDistance() const //TODO: finish +{ + return 6; +} diff --git a/hch/CHeroHandler.h b/hch/CHeroHandler.h index 776fc4b5d..5b433bd24 100644 --- a/hch/CHeroHandler.h +++ b/hch/CHeroHandler.h @@ -72,6 +72,7 @@ public: unsigned float getMultiplicativeMoveBonus(); 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' + int getSightDistance() const; //returns sight distance of this hero void setPosition(int3 Pos, bool h3m); //as above, but sets position bool canWalkOnSea() const; diff --git a/hch/CTownHandler.cpp b/hch/CTownHandler.cpp index 638888d85..d2c45ef0b 100644 --- a/hch/CTownHandler.cpp +++ b/hch/CTownHandler.cpp @@ -71,4 +71,9 @@ CTownInstance::CTownInstance() garrisonHero=NULL; owner=-1; town=NULL; -} \ No newline at end of file +} + +int CTownInstance::getSightDistance() const //TODO: finish +{ + return 10; +} diff --git a/hch/CTownHandler.h b/hch/CTownHandler.h index 810fc2b01..3aa48f707 100644 --- a/hch/CTownHandler.h +++ b/hch/CTownHandler.h @@ -57,6 +57,8 @@ public: std::vector possibleSpells, obligatorySpells, availableSpells; + int getSightDistance() const; //returns sight distance + CTownInstance(); }; diff --git a/mapHandler.cpp b/mapHandler.cpp index abfe2d27d..3ba8ee25f 100644 --- a/mapHandler.cpp +++ b/mapHandler.cpp @@ -1000,199 +1000,199 @@ SDL_Surface * CMapHandler::undTerrBitmap(int x, int y) return ttiles[x+Woff][y+Hoff][0].terbitmap[1]; } -SDL_Surface * CMapHandler::getVisBitmap(int x, int y, const PseudoV< PseudoV< PseudoV > > & visibilityMap, int lvl) +SDL_Surface * CMapHandler::getVisBitmap(int x, int y, PseudoV< PseudoV< PseudoV > > & 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 } - 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 } - 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 } - 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 } - 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 } - 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[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].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].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].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].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 } - 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 } - 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].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 } - 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 } - 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 } - 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 } - 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 } - 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 } - 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 } - 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 } - 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 } - 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 } - 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 } - 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 } - 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 } - 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 } - 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 } - 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 } - 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 } - 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 } - 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 } - 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 } - 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 } - 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 } - 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 } - 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 } - 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 } - 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 } - 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 } - 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 } - 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 } - 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 } - 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 } - 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 } - 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 } @@ -1225,7 +1225,7 @@ std::vector < std::string > CMapHandler::getObjDescriptions(int3 pos) std::vector ret; for(int g=0; gpos.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 ) //checking position blocking { diff --git a/mapHandler.h b/mapHandler.h index 2295182b6..b51b06451 100644 --- a/mapHandler.h +++ b/mapHandler.h @@ -74,7 +74,7 @@ public: char & visAccess(int x, int y); char & undVisAccess(int x, int y); SDL_Surface mirrorImage(SDL_Surface *src); //what is this?? - SDL_Surface * getVisBitmap(int x, int y, const PseudoV< PseudoV< PseudoV > > & visibilityMap, int lvl); + SDL_Surface * getVisBitmap(int x, int y, PseudoV< PseudoV< PseudoV > > & visibilityMap, int lvl); int getCost(int3 & a, int3 & b, const CHeroInstance * hero); std::vector< std::string > getObjDescriptions(int3 pos); //returns desriptions of objects blocking given position