From b07b1ec7dcb5fd047f1d94c81e73ccd15f65090e Mon Sep 17 00:00:00 2001 From: mateuszb Date: Thu, 25 Oct 2007 16:14:43 +0000 Subject: [PATCH] * displaying flags * significant speed-ups and warningfixing --- CCallback.cpp | 1 + CGameInterface.cpp | 38 +++++++++++++++++------------- CPreGame.cpp | Bin 122404 -> 122452 bytes SDL_Extensions.cpp | 17 ++++++++++++++ SDL_Extensions.h | 1 + hch/CDefObjInfoHandler.cpp | 10 ++++++++ hch/CDefObjInfoHandler.h | 1 + hch/CSemiDefHandler.cpp | 1 + mapHandler.cpp | 46 ++++++++++++++++++++++++++++--------- 9 files changed, 88 insertions(+), 27 deletions(-) diff --git a/CCallback.cpp b/CCallback.cpp index 725ac91bf..e16189839 100644 --- a/CCallback.cpp +++ b/CCallback.cpp @@ -212,6 +212,7 @@ int CCallback::getDate(int mode) return ((gs->day-1)/28)+1; break; } + return 0; } bool CCallback::verifyPath(CPath * path, bool blockSea) { diff --git a/CGameInterface.cpp b/CGameInterface.cpp index 3d519eebd..31ec029a7 100644 --- a/CGameInterface.cpp +++ b/CGameInterface.cpp @@ -269,14 +269,20 @@ inline void subRect(const int & x, const int & y, const int & z, SDL_Rect & r, c { for(int h=0; hmh->ttiles[x][y][z].objects.size(); ++h) if(CGI->mh->ttiles[x][y][z].objects[h].first->id==hid) + { CGI->mh->ttiles[x][y][z].objects[h].second.first = r; + break; + } } 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) + { CGI->mh->ttiles[x][y][z].objects.erase(CGI->mh->ttiles[x][y][z].objects.begin()+h); + break; + } } void CPlayerInterface::heroMoved(const HeroMoveDetails & details) @@ -559,7 +565,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details) subRect(hp.x-1, hp.y, hp.z, genRect(32, 32, 33+i, 33+i), ho->id); subRect(hp.x, hp.y, hp.z, genRect(32, 32, 65+i, 33+i), ho->id); - std::stable_sort(CGI->mh->ttiles[hp.x-3][hp.y-2][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-3][hp.y-2][hp.z].objects.end(), ocmptwo_cgin); + /*std::stable_sort(CGI->mh->ttiles[hp.x-3][hp.y-2][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-3][hp.y-2][hp.z].objects.end(), ocmptwo_cgin); std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y-2][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][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][hp.y-2][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y-2][hp.z].objects.end(), ocmptwo_cgin); @@ -572,7 +578,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details) 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][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 { @@ -588,7 +594,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details) subRect(hp.x-1, hp.y, hp.z, genRect(32, 32, 32, 33+i), ho->id); subRect(hp.x, hp.y, hp.z, genRect(32, 32, 64, 33+i), ho->id); - std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y-2][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y-2][hp.z].objects.end(), ocmptwo_cgin); + /*std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y-2][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][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][hp.y-2][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y-2][hp.z].objects.end(), ocmptwo_cgin); @@ -598,7 +604,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details) 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][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 { @@ -617,7 +623,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details) subRect(hp.x, hp.y, hp.z, genRect(32, 32, 63-i, 33+i), ho->id); subRect(hp.x+1, hp.y, hp.z, genRect(32, 32, 95-i, 33+i), ho->id); - std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y-2][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y-2][hp.z].objects.end(), ocmptwo_cgin); + /*std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y-2][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][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][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); @@ -630,7 +636,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details) 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+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 { @@ -644,7 +650,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details) subRect(hp.x, hp.y, hp.z, genRect(32, 32, 63-i, 32), ho->id); subRect(hp.x+1, hp.y, hp.z, genRect(32, 32, 95-i, 32), ho->id); - 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-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); @@ -652,7 +658,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details) 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+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 { @@ -671,7 +677,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details) subRect(hp.x, hp.y+1, hp.z, genRect(32, 32, 63-i, 63-i), ho->id); subRect(hp.x+1, hp.y+1, hp.z, genRect(32, 32, 95-i, 63-i), ho->id); - 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-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); @@ -684,7 +690,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details) 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+1][hp.y+1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x+1][hp.y+1][hp.z].objects.end(), ocmptwo_cgin);*/ } else if(details.dst.x == details.src.x && details.dst.y-1 == details.src.y) //b { @@ -700,7 +706,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details) subRect(hp.x-1, hp.y+1, hp.z, genRect(32, 32, 32, 63-i), ho->id); subRect(hp.x, hp.y+1, hp.z, genRect(32, 32, 64, 63-i), ho->id); - 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-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); @@ -710,7 +716,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details) 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][hp.y+1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y+1][hp.z].objects.end(), ocmptwo_cgin);*/ } else if(details.dst.x+1 == details.src.x && details.dst.y-1 == details.src.y) //bl { @@ -729,7 +735,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details) subRect(hp.x-1, hp.y+1, hp.z, genRect(32, 32, 33+i, 63-i), ho->id); subRect(hp.x, hp.y+1, hp.z, genRect(32, 32, 65+i, 63-i), 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-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); @@ -742,7 +748,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details) 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][hp.y+1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y+1][hp.z].objects.end(), ocmptwo_cgin);*/ } else if(details.dst.x+1 == details.src.x && details.dst.y == details.src.y) //l { @@ -756,7 +762,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details) subRect(hp.x-1, hp.y, hp.z, genRect(32, 32, 33+i, 32), ho->id); subRect(hp.x, hp.y, hp.z, genRect(32, 32, 65+i, 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-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); @@ -764,7 +770,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details) 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][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.end(), ocmptwo_cgin);*/ } LOCPLINT->adventureInt->update(); //updating screen CGI->screenh->updateScreen(); diff --git a/CPreGame.cpp b/CPreGame.cpp index 59a26589847cbfd9f39ef141ab0f45ea6c114ef1..d6abc62d8fcc1b535e6c9d6d6b2fdba8dad587a3 100644 GIT binary patch delta 39 xcmV+?0NDSeya&|02Y|Ez6xNeSln|5B(-@O<7Z{h|RRI*2PJ#glw?Nhbpixels + y * ekran->pitch + x * ekran->format->BytesPerPixel-myC; + if(SDL_BYTEORDER == SDL_BIG_ENDIAN) + { + p[0] = B; + p[1] = G; + p[2] = R; + } + else + { + p[0] = R; + p[1] = G; + p[2] = B; + } +} + ///**************/ ///Reverses the toRot surface by the vertical axis ///**************/ diff --git a/SDL_Extensions.h b/SDL_Extensions.h index 76f127ddf..13ee0380e 100644 --- a/SDL_Extensions.h +++ b/SDL_Extensions.h @@ -15,6 +15,7 @@ SDL_Rect genRect(int hh, int ww, int xx, int yy); namespace CSDL_Ext { void SDL_PutPixel(SDL_Surface *ekran, int x, int y, Uint8 R, Uint8 G, Uint8 B, int myC=0, Uint8 A = 255); //myC influences the start of reading pixels + void SDL_PutPixelWithoutRefresh(SDL_Surface *ekran, int x, int y, Uint8 R, Uint8 G, Uint8 B, int myC=0, Uint8 A = 255); //myC influences the start of reading pixels ; without refreshing SDL_Surface * rotate01(SDL_Surface * toRot, int myC = 2); //vertical flip SDL_Surface * hFlip(SDL_Surface * toRot); //horizontal flip SDL_Surface * rotate02(SDL_Surface * toRot); //rotate 90 degrees left diff --git a/hch/CDefObjInfoHandler.cpp b/hch/CDefObjInfoHandler.cpp index 689705ee1..9a95e0c53 100644 --- a/hch/CDefObjInfoHandler.cpp +++ b/hch/CDefObjInfoHandler.cpp @@ -54,3 +54,13 @@ void CDefObjInfoHandler::load() objs.push_back(nobj); } } + +bool DefObjInfo::isVisitable() const +{ + for(int g=0; g<6; ++g) + { + if(visitMap[g]!=0) + return true; + } + return false; +} diff --git a/hch/CDefObjInfoHandler.h b/hch/CDefObjInfoHandler.h index b15e6877b..587709377 100644 --- a/hch/CDefObjInfoHandler.h +++ b/hch/CDefObjInfoHandler.h @@ -12,6 +12,7 @@ struct DefObjInfo unsigned char visitMap[6]; unsigned char blockMap[6]; bool operator==(const std::string & por) const; + bool isVisitable() const; }; class CDefObjInfoHandler diff --git a/hch/CSemiDefHandler.cpp b/hch/CSemiDefHandler.cpp index b15e92a17..00be4c28f 100644 --- a/hch/CSemiDefHandler.cpp +++ b/hch/CSemiDefHandler.cpp @@ -57,6 +57,7 @@ std::string CSemiDefHandler::nameFromType (EterrainType typ) break; } } + return std::string(); } void CSemiDefHandler::openDef(std::string name, std::string lodName, int dist) { diff --git a/mapHandler.cpp b/mapHandler.cpp index 4a75f46fc..c19bf731d 100644 --- a/mapHandler.cpp +++ b/mapHandler.cpp @@ -416,20 +416,29 @@ void CMapHandler::init() cr.y = fy*32; std::pair>>> toAdd = std::make_pair(CGI->objh->objInstances[f], std::make_pair(cr, std::vector>())); ///initializing places that will be coloured by blitting (flag colour / player colour positions) - toAdd.second.second.resize(CGI->mh->reader->map.defy[toAdd.first->defNumber].handler->ourImages.size()); - for(int no = 0; nomh->reader->map.defy[toAdd.first->defNumber].handler->ourImages.size(); ++no) + if(toAdd.first->defObjInfoNumber>=0 && CGI->dobjinfo->objs[toAdd.first->defObjInfoNumber].isVisitable()) { - for(int dx=0; dx<32; ++dx) + toAdd.second.second.resize(CGI->mh->reader->map.defy[toAdd.first->defNumber].handler->ourImages.size()); + for(int no = 0; nomh->reader->map.defy[toAdd.first->defNumber].handler->ourImages.size(); ++no) { - for(int dy=0; dy<32; ++dy) + bool breakNow = true; + for(int dx=0; dx<32; ++dx) { - SDL_Surface * curs = CGI->mh->reader->map.defy[toAdd.first->defNumber].handler->ourImages[no].bitmap; - Uint32* point = (Uint32*)( (Uint8*)curs->pixels + curs->pitch * (fy*32+dy) + curs->format->BytesPerPixel*(fx*32+dx)); - Uint8* r = new Uint8, *g = new Uint8, *b = new Uint8, *a = new Uint8; - SDL_GetRGBA(*point, curs->format, r, g, b, a); - if(*r==255 && *g==255 && *b==0) - toAdd.second.second[no].push_back(int3((fx*32+dx), (fy*32+dy), 0)); + for(int dy=0; dy<32; ++dy) + { + SDL_Surface * curs = CGI->mh->reader->map.defy[toAdd.first->defNumber].handler->ourImages[no].bitmap; + Uint32* point = (Uint32*)( (Uint8*)curs->pixels + curs->pitch * (fy*32+dy) + curs->format->BytesPerPixel*(fx*32+dx)); + Uint8 r, g, b, a; + SDL_GetRGBA(*point, curs->format, &r, &g, &b, &a); + if(r==255 && g==255 && b==0) + { + toAdd.second.second[no].push_back(int3((fx*32+dx), (fy*32+dy), 0)); + breakNow = false; + } + } } + if(breakNow) + break; } } if((CGI->objh->objInstances[f]->pos.x + fx - curd->ourImages[0].bitmap->w/32+1)>=0 && (CGI->objh->objInstances[f]->pos.x + fx - curd->ourImages[0].bitmap->w/32+1)objh->objInstances[f]->pos.y + fy - curd->ourImages[0].bitmap->h/32+1)>=0 && (CGI->objh->objInstances[f]->pos.y + fy - curd->ourImages[0].bitmap->h/32+1)ac->map.defy[ttiles[x+bx][y+by][level].objects[h].first->defNumber].handler->ourImages.size(); SDL_BlitSurface(CGI->ac->map.defy[ttiles[x+bx][y+by][level].objects[h].first->defNumber].handler->ourImages[anim%imgVal].bitmap,&pp,su,&sr); } - //printing appropriate flag colour (TODO) + //printing appropriate flag colour + if(ttiles[x+bx][y+by][level].objects[h].second.second.size()) + { + std::list & curl = ttiles[x+bx][y+by][level].objects[h].second.second[anim%ttiles[x+bx][y+by][level].objects[h].second.second.size()]; + for(std::list::iterator g=curl.begin(); g!=curl.end(); ++g) + { + SDL_Color ourC; + int own = ttiles[x+bx][y+by][level].objects[h].first->owner; + if(ttiles[x+bx][y+by][level].objects[h].first->owner!=255 && ttiles[x+bx][y+by][level].objects[h].first->owner!=254) + ourC = CGI->playerColors[ttiles[x+bx][y+by][level].objects[h].first->owner]; + else if(ttiles[x+bx][y+by][level].objects[h].first->owner==255) + ourC = CGI->neutralColor; + else continue; + CSDL_Ext::SDL_PutPixelWithoutRefresh(su, bx*32 + g->x%32 , by*32 + g->y%32, ourC.r , ourC.g, ourC.b, 0); + } + } } } }