From 58f1a2169fa9a70c7a82614fbf778a529cffe8a7 Mon Sep 17 00:00:00 2001 From: mateuszb Date: Thu, 6 Dec 2007 18:55:58 +0000 Subject: [PATCH] faster FoW in minimap, does not work, compiler errors --- AI/EmptyAI/CEmptyAI.h | 2 + AI/EmptyAI/Z_EmptyAI.vcproj | 266 ------------------------------------ CAdvmapInterface.cpp | 55 ++++---- CAdvmapInterface.h | 4 +- CCallback.cpp | 6 +- CCallback.h | 2 +- CCursorHandler.cpp | 68 ++++----- CGameInterface.h | 2 + CMT.cpp | 61 ++++++++- CPlayerInterface.cpp | 122 +++++++++-------- CPlayerInterface.h | 2 + CScreenHandler.cpp | 4 +- SDL_Extensions.cpp | 4 +- 13 files changed, 204 insertions(+), 394 deletions(-) delete mode 100644 AI/EmptyAI/Z_EmptyAI.vcproj diff --git a/AI/EmptyAI/CEmptyAI.h b/AI/EmptyAI/CEmptyAI.h index 6fb4d793b..f0d6c7b7a 100644 --- a/AI/EmptyAI/CEmptyAI.h +++ b/AI/EmptyAI/CEmptyAI.h @@ -10,6 +10,8 @@ public: void heroCreated(const CHeroInstance *); void heroMoved(const HeroMoveDetails &); void heroPrimarySkillChanged(const CGHeroInstance * hero, int which, int val) {}; + void tileRevealed(int3 pos){}; + void tileHidden(int3 pos){}; }; #define NAME "EmptyAI 0.1" \ No newline at end of file diff --git a/AI/EmptyAI/Z_EmptyAI.vcproj b/AI/EmptyAI/Z_EmptyAI.vcproj deleted file mode 100644 index 4bd4971f6..000000000 --- a/AI/EmptyAI/Z_EmptyAI.vcproj +++ /dev/null @@ -1,266 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/CAdvmapInterface.cpp b/CAdvmapInterface.cpp index 32e63b9b6..3beb8f512 100644 --- a/CAdvmapInterface.cpp +++ b/CAdvmapInterface.cpp @@ -636,47 +636,49 @@ void CMinimap::draw() blitAt(map[LOCPLINT->adventureInt->position.z],0,0,temps); //draw heroes - std::vector * hh = LOCPLINT->cb->getHeroesInfo(false); + std::vector hh = LOCPLINT->cb->getHeroesInfo(false); int mw = map[0]->w, mh = map[0]->h, wo = mw/CGI->mh->sizes.x, ho = mh/CGI->mh->sizes.y; - for (int i=0; isize();i++) + + for (int i=0; igetPosition(false); + int3 hpos = hh[i]->getPosition(false); float zawx = ((float)hpos.x/CGI->mh->sizes.x), zawy = ((float)hpos.y/CGI->mh->sizes.y); int3 maplgp ( zawx*mw, zawy*mh, hpos.z ); for (int ii=0; iiplayerColors[(*hh)[i]->getOwner()].r,CGI->playerColors[(*hh)[i]->getOwner()].g,CGI->playerColors[(*hh)[i]->getOwner()].b); + SDL_PutPixel(temps,maplgp.x+ii,maplgp.y+jj,CGI->playerColors[hh[i]->getOwner()].r,CGI->playerColors[hh[i]->getOwner()].g,CGI->playerColors[hh[i]->getOwner()].b); } } } SDL_UpdateRect(ekran,pos.x,pos.y,pos.w,pos.h); - delete hh; //draw FoW - for (int i=0; imh->sizes.x); - pp.y = (((float)j/mh)*CGI->mh->sizes.y); - pp.z = LOCPLINT->adventureInt->position.z; - if ( !LOCPLINT->cb->isVisible(pp) ) - { - for (int ii=0; iimh->sizes.x), (((float)j/mh)*CGI->mh->sizes.y), LOCPLINT->adventureInt->position.z); + // /*pp.x = (((float)i/mw)*CGI->mh->sizes.x); + // pp.y = (((float)j/mh)*CGI->mh->sizes.y); + // pp.z = LOCPLINT->adventureInt->position.z;*/ + // if ( !LOCPLINT->cb->isVisible(pp) ) + // { + // for (int ii=0; iiadventureInt->position.z],0,0,temps); //draw radar int bx = (((float)LOCPLINT->adventureInt->position.x)/(((float)CGI->mh->sizes.x)))*pos.w, @@ -707,6 +709,7 @@ void CMinimap::redraw(int level)// (level==-1) => redraw all levels } } map.push_back(pom); + } } void CMinimap::updateRadar() diff --git a/CAdvmapInterface.h b/CAdvmapInterface.h index 13c5145c3..c7fe158af 100644 --- a/CAdvmapInterface.h +++ b/CAdvmapInterface.h @@ -128,7 +128,7 @@ public: SDL_Surface * temps; std::map colors; std::map colorsBlocked; - std::vector map; //one bitmap for each level + std::vector map, FoW; //one bitmap for each level (terrain, Fog of War) //TODO flagged buildings std::string statusbarTxt, rcText; @@ -143,6 +143,8 @@ public: void mouseMoved (SDL_MouseMotionEvent & sEvent); void activate(); // makes button active void deactivate(); // makes button inactive (but don't deletes) + void hideTile(int3 pos); //puts FoW + void showTile(int3 pos); //removes FoW }; class CTerrainRect : public ClickableL, public ClickableR, public Hoverable, public virtual CIntObject, public KeyInterested, diff --git a/CCallback.cpp b/CCallback.cpp index 0e4c7806c..5781ee86a 100644 --- a/CCallback.cpp +++ b/CCallback.cpp @@ -325,16 +325,16 @@ bool CCallback::isVisible(int3 pos, int Player) return gs->players[Player].fogOfWarMap[pos.x][pos.y][pos.z]; } -std::vector < const CGHeroInstance *> * CCallback::getHeroesInfo(bool onlyOur) +std::vector < const CGHeroInstance *> CCallback::getHeroesInfo(bool onlyOur) { - std::vector < const CGHeroInstance *> * ret = new std::vector < const CGHeroInstance *>(); + std::vector < const CGHeroInstance *> ret = std::vector < const CGHeroInstance *>(); for ( std::map::iterator i=gs->players.begin() ; i!=gs->players.end();i++) { for (int j=0;j<(*i).second.heroes.size();j++) { if ( ( isVisible((*i).second.heroes[j]->getPosition(false),player) ) || (*i).first==player) { - ret->push_back((*i).second.heroes[j]); + ret.push_back((*i).second.heroes[j]); } } } // for ( std::map::iterator i=gs->players.begin() ; i!=gs->players.end();i++) diff --git a/CCallback.h b/CCallback.h index 6eda5eda0..4a293059e 100644 --- a/CCallback.h +++ b/CCallback.h @@ -69,7 +69,7 @@ public: const CGTownInstance * getTownInfo(int val, bool mode); //mode = 0 -> val = serial; mode = 1 -> val = ID int howManyTowns(); std::vector < std::string > getObjDescriptions(int3 pos); //returns descriptions of objects at pos in order from the lowest to the highest - std::vector < const CGHeroInstance *> * getHeroesInfo(bool onlyOur=true); + std::vector < const CGHeroInstance *> getHeroesInfo(bool onlyOur=true); bool isVisible(int3 pos); int getMyColor(); int getMySerial(); diff --git a/CCursorHandler.cpp b/CCursorHandler.cpp index 4e81c629c..b057b7f69 100644 --- a/CCursorHandler.cpp +++ b/CCursorHandler.cpp @@ -180,58 +180,58 @@ static SDL_Cursor *init_system_cursor(const char *image[]) void CCursorHandler::initCursor() { -#if SDL_BYTEORDER == SDL_BIG_ENDIAN - int rmask = 0xff000000; - int gmask = 0x00ff0000; - int bmask = 0x0000ff00; - int amask = 0x000000ff; -#else - int rmask = 0x000000ff; - int gmask = 0x0000ff00; - int bmask = 0x00ff0000; - int amask = 0xff000000; -#endif - curVisible = true; - xpos = ypos = 0; - behindCur = SDL_CreateRGBSurface(SDL_SWSURFACE, 32, 32, 32, rmask, gmask, bmask, amask); - xbef = ybef = 0; - adventure = CGI->spriteh->giveDef("CRADVNTR.DEF"); - combat = CGI->spriteh->giveDef("CRCOMBAT.DEF"); - deflt = CGI->spriteh->giveDef("CRDEFLT.DEF"); - spell = CGI->spriteh->giveDef("CRSPELL.DEF"); - //SDL_SetCursor(init_system_cursor(arrow)); - //SDL_Thread * myth = SDL_CreateThread(&cursorHandlerFunc, this); +//#if SDL_BYTEORDER == SDL_BIG_ENDIAN +// int rmask = 0xff000000; +// int gmask = 0x00ff0000; +// int bmask = 0x0000ff00; +// int amask = 0x000000ff; +//#else +// int rmask = 0x000000ff; +// int gmask = 0x0000ff00; +// int bmask = 0x00ff0000; +// int amask = 0xff000000; +//#endif +// curVisible = true; +// xpos = ypos = 0; +// behindCur = SDL_CreateRGBSurface(SDL_SWSURFACE, 32, 32, 32, rmask, gmask, bmask, amask); +// xbef = ybef = 0; +// adventure = CGI->spriteh->giveDef("CRADVNTR.DEF"); +// combat = CGI->spriteh->giveDef("CRCOMBAT.DEF"); +// deflt = CGI->spriteh->giveDef("CRDEFLT.DEF"); +// spell = CGI->spriteh->giveDef("CRSPELL.DEF"); +// //SDL_SetCursor(init_system_cursor(arrow)); +// //SDL_Thread * myth = SDL_CreateThread(&cursorHandlerFunc, this); } void CCursorHandler::changeGraphic(int type, int no) { - mode = type; - number = no; + //mode = type; + //number = no; } void CCursorHandler::cursorMove(int x, int y) { - xbef = xpos; - ybef = ypos; - xpos = x; - ypos = y; + //xbef = xpos; + //ybef = ypos; + //xpos = x; + //ypos = y; } void CCursorHandler::hardwareCursor() { - curVisible = false; - SDL_SetCursor(init_system_cursor(arrow2)); + //curVisible = false; + //SDL_SetCursor(init_system_cursor(arrow2)); } void CCursorHandler::hideCursor() { - curVisible = false; - SDL_SetCursor(init_system_cursor(arrow)); + //curVisible = false; + //SDL_SetCursor(init_system_cursor(arrow)); } void CCursorHandler::showGraphicCursor() { - curVisible = true; - SDL_SetCursor(init_system_cursor(arrow)); - changeGraphic(0, 0); + //curVisible = true; + //SDL_SetCursor(init_system_cursor(arrow)); + //changeGraphic(0, 0); } \ No newline at end of file diff --git a/CGameInterface.h b/CGameInterface.h index f0c7cd4bf..1540a5f08 100644 --- a/CGameInterface.h +++ b/CGameInterface.h @@ -21,6 +21,8 @@ public: virtual void heroCreated(const CGHeroInstance*)=0{}; virtual void heroPrimarySkillChanged(const CGHeroInstance * hero, int which, int val)=0{}; virtual void heroMoved(const HeroMoveDetails & details)=0{}; + virtual void tileRevealed(int3 pos)=0{}; + virtual void tileHidden(int3 pos)=0{}; virtual void receivedResource(int type, int val){}; }; class CAIHandler diff --git a/CMT.cpp b/CMT.cpp index 220a1d733..b84bba4ec 100644 --- a/CMT.cpp +++ b/CMT.cpp @@ -46,6 +46,7 @@ #include "CPlayerInterface.h" #include "CLuaHandler.h" #include "CLua.h" +#include "CAdvmapInterface.h" #if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__) # include # include @@ -213,7 +214,6 @@ void initGameState(CGameInfo * cgi) } } } - /****************************SCRIPTS************************************************/ std::map > * skrypty = &cgi->state->objscr; //alias for easier access /****************************C++ OBJECT SCRIPTS************************************************/ @@ -309,8 +309,9 @@ int _tmain(int argc, _TCHAR* argv[]) // well, there's no music, but most games don't break without music... }*/ - screen2 = SDL_SetVideoMode(800,600,24,SDL_SWSURFACE|SDL_DOUBLEBUF/*|SDL_FULLSCREEN*/); - screen = SDL_ConvertSurface(screen2, screen2->format, SDL_SWSURFACE); + //screen2 = SDL_SetVideoMode(800,600,24,SDL_SWSURFACE|SDL_DOUBLEBUF/*|SDL_FULLSCREEN*/); + screen = SDL_SetVideoMode(800,600,24,SDL_SWSURFACE|SDL_DOUBLEBUF/*|SDL_FULLSCREEN*/); + //screen = SDL_ConvertSurface(screen2, screen2->format, SDL_SWSURFACE); ekran = screen; SDL_WM_SetCaption(NAME,""); //set window title @@ -736,6 +737,60 @@ int _tmain(int argc, _TCHAR* argv[]) ((CPlayerInterface*)(cgi->playerint[i]))->init(new CCallback(cgi->state,cgi->scenarioOps.playerInfos[i].color)); } } + ///claculating FoWs for minimap + /****************************Minimaps' FoW******************************************/ + for(int g=0; gplayerint.size(); ++g) + { + if(!cgi->playerint[g]->human) + continue; + CMinimap & mm = ((CPlayerInterface*)cgi->playerint[g])->adventureInt->minimap; + + int mw = mm.map[0]->w, mh = mm.map[0]->h, + wo = mw/CGI->mh->sizes.x, ho = mh/CGI->mh->sizes.y; + + + for(int d=0; dmh->reader->map.twoLevel+1; ++d) + { +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + int rmask = 0xff000000; + int gmask = 0x00ff0000; + int bmask = 0x0000ff00; + int amask = 0x000000ff; +#else + int rmask = 0x000000ff; + int gmask = 0x0000ff00; + int bmask = 0x00ff0000; + int amask = 0xff000000; +#endif + SDL_Surface * pt = SDL_CreateRGBSurface(SDL_SWSURFACE, mm.pos.w, mm.pos.h, 32, rmask, gmask, bmask, amask); + + for (int i=0; imh->sizes.x), (((float)j/mh)*CGI->mh->sizes.y), d); + /*pp.x = (((float)i/mw)*CGI->mh->sizes.x); + pp.y = (((float)j/mh)*CGI->mh->sizes.y); + pp.z = LOCPLINT->adventureInt->position.z;*/ + if ( !((CPlayerInterface*)cgi->playerint[g])->cb->isVisible(pp) ) + { + for (int ii=0; iimh->ttiles[x][y][z].objects.size(); ++h) - if(CGI->mh->ttiles[x][y][z].objects[h].first->id==hid) + TerrainTile2 & hlp = CGI->mh->ttiles[x][y][z]; + for(int h=0; hid==hid) { - CGI->mh->ttiles[x][y][z].objects[h].second.first = r; - break; + hlp.objects[h].second.first = r; + return; } } inline void delObjRect(const int & x, const int & y, const int & z, const int & hid) { - for(int h=0; hmh->ttiles[x][y][z].objects.size(); ++h) - if(CGI->mh->ttiles[x][y][z].objects[h].first->id==hid) + TerrainTile2 & hlp = CGI->mh->ttiles[x][y][z]; + for(int h=0; hid==hid) { - CGI->mh->ttiles[x][y][z].objects.erase(CGI->mh->ttiles[x][y][z].objects.begin()+h); - break; + hlp.objects.erase(hlp.objects.begin()+h); + return; } } int getDir(int3 src, int3 dst) @@ -487,14 +489,14 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details) std::stable_sort(CGI->mh->ttiles[hp.x][hp.y-2][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y-2][hp.z].objects.end(), ocmptwo_cgin); std::stable_sort(CGI->mh->ttiles[hp.x-3][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-3][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); std::stable_sort(CGI->mh->ttiles[hp.x-3][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-3][hp.y][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.end(), ocmptwo_cgin); } else if(details.dst.x == details.src.x && details.dst.y+1 == details.src.y) //t { @@ -516,13 +518,13 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details) std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y-2][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y-2][hp.z].objects.end(), ocmptwo_cgin); std::stable_sort(CGI->mh->ttiles[hp.x][hp.y-2][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y-2][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.end(), ocmptwo_cgin); } else if(details.dst.x-1 == details.src.x && details.dst.y+1 == details.src.y) //tr { @@ -548,14 +550,14 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details) std::stable_sort(CGI->mh->ttiles[hp.x][hp.y-2][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y-2][hp.z].objects.end(), ocmptwo_cgin); std::stable_sort(CGI->mh->ttiles[hp.x+1][hp.y-2][hp.z].objects.begin(), CGI->mh->ttiles[hp.x+1][hp.y-2][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); std::stable_sort(CGI->mh->ttiles[hp.x+1][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x+1][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.end(), ocmptwo_cgin); std::stable_sort(CGI->mh->ttiles[hp.x+1][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x+1][hp.y][hp.z].objects.end(), ocmptwo_cgin); } else if(details.dst.x-1 == details.src.x && details.dst.y == details.src.y) //r @@ -572,14 +574,14 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details) subRect(hp.x, hp.y, hp.z, genRect(32, 32, 63, 32), ho->id); CGI->mh->ttiles[hp.x+1][hp.y][hp.z].objects.push_back(std::make_pair(ho, std::make_pair(genRect(32, 32, 95, 32), std::vector>()))); - std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); std::stable_sort(CGI->mh->ttiles[hp.x+1][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x+1][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.end(), ocmptwo_cgin); std::stable_sort(CGI->mh->ttiles[hp.x+1][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x+1][hp.y][hp.z].objects.end(), ocmptwo_cgin); } else if(details.dst.x-1 == details.src.x && details.dst.y-1 == details.src.y) //br @@ -601,14 +603,14 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details) CGI->mh->ttiles[hp.x][hp.y+1][hp.z].objects.push_back(std::make_pair(ho, std::make_pair(genRect(32, 32, 63, 63), std::vector>()))); CGI->mh->ttiles[hp.x+1][hp.y+1][hp.z].objects.push_back(std::make_pair(ho, std::make_pair(genRect(32, 32, 95, 63), std::vector>()))); - std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); std::stable_sort(CGI->mh->ttiles[hp.x+1][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x+1][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.end(), ocmptwo_cgin); std::stable_sort(CGI->mh->ttiles[hp.x+1][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x+1][hp.y][hp.z].objects.end(), ocmptwo_cgin); std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y+1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y+1][hp.z].objects.end(), ocmptwo_cgin); @@ -632,13 +634,13 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details) CGI->mh->ttiles[hp.x-1][hp.y+1][hp.z].objects.push_back(std::make_pair(ho, std::make_pair(genRect(32, 32, 32, 63), std::vector>()))); CGI->mh->ttiles[hp.x][hp.y+1][hp.z].objects.push_back(std::make_pair(ho, std::make_pair(genRect(32, 32, 64, 63), std::vector>()))); - std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.end(), ocmptwo_cgin); std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y+1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y+1][hp.z].objects.end(), ocmptwo_cgin); std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y+1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y+1][hp.z].objects.end(), ocmptwo_cgin); @@ -664,14 +666,14 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details) CGI->mh->ttiles[hp.x][hp.y+1][hp.z].objects.push_back(std::make_pair(ho, std::make_pair(genRect(32, 32, 65, 63), std::vector>()))); std::stable_sort(CGI->mh->ttiles[hp.x-3][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-3][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); std::stable_sort(CGI->mh->ttiles[hp.x-3][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-3][hp.y][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.end(), ocmptwo_cgin); std::stable_sort(CGI->mh->ttiles[hp.x-3][hp.y+1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-3][hp.y+1][hp.z].objects.end(), ocmptwo_cgin); std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y+1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y+1][hp.z].objects.end(), ocmptwo_cgin); @@ -693,14 +695,14 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details) subRect(hp.x, hp.y, hp.z, genRect(32, 32, 65, 32), ho->id); std::stable_sort(CGI->mh->ttiles[hp.x-3][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-3][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y-1][hp.z].objects.end(), ocmptwo_cgin); std::stable_sort(CGI->mh->ttiles[hp.x-3][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-3][hp.y][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y][hp.z].objects.end(), ocmptwo_cgin); - std::stable_sort(CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y][hp.z].objects.end(), ocmptwo_cgin); + //std::stable_sort(CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.end(), ocmptwo_cgin); } //first initializing done SDL_framerateDelay(mainFPSmng); // after first move @@ -1282,4 +1284,10 @@ void CPlayerInterface::removeObjToBlit(IShowable* obj) objsToBlit.erase (std::find(objsToBlit.begin(),objsToBlit.end(),obj)); //delete obj; -} \ No newline at end of file +} +void CPlayerInterface::tileRevealed(int3 pos) +{ +} +void CPlayerInterface::tileHidden(int3 pos) +{ +} diff --git a/CPlayerInterface.h b/CPlayerInterface.h index 12f7263bb..cd6c77ea3 100644 --- a/CPlayerInterface.h +++ b/CPlayerInterface.h @@ -171,6 +171,8 @@ public: //overloaded funcs from Interface void yourTurn(); void heroMoved(const HeroMoveDetails & details); + void tileRevealed(int3 pos); + void tileHidden(int3 pos); void heroKilled(const CGHeroInstance*); void heroCreated(const CGHeroInstance*); void heroPrimarySkillChanged(const CGHeroInstance * hero, int which, int val); diff --git a/CScreenHandler.cpp b/CScreenHandler.cpp index c74b4f783..eb26a8938 100644 --- a/CScreenHandler.cpp +++ b/CScreenHandler.cpp @@ -17,7 +17,7 @@ void CScreenHandler::initScreen() void CScreenHandler::updateScreen() { - blitAt(screen, 0, 0, screen2); + /*blitAt(screen, 0, 0, screen2); switch(CGI->curh->mode) { case 0: @@ -41,5 +41,5 @@ void CScreenHandler::updateScreen() break; } } - CSDL_Ext::update(screen2); + CSDL_Ext::update(screen2);*/ } \ No newline at end of file diff --git a/SDL_Extensions.cpp b/SDL_Extensions.cpp index 19af36fc1..eea1df7aa 100644 --- a/SDL_Extensions.cpp +++ b/SDL_Extensions.cpp @@ -23,7 +23,7 @@ bool isItIn(const SDL_Rect * rect, int x, int y) return true; else return false; } -SDL_Rect genRect(int hh, int ww, int xx, int yy) +inline SDL_Rect genRect(int hh, int ww, int xx, int yy) { SDL_Rect ret; ret.h=hh; @@ -167,6 +167,8 @@ void CSDL_Ext::SDL_PutPixelWithoutRefresh(SDL_Surface *ekran, int x, int y, Uint p[0] = R; p[1] = G; p[2] = B; + if(ekran->format->BytesPerPixel==4) + p[3] = A; #endif }