From 82308c10fe861801e355c1b9059fcf682162b087 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20W=2E=20Urba=C5=84czyk?= Date: Mon, 2 Jul 2007 19:44:30 +0000 Subject: [PATCH] =?UTF-8?q?Dzisiejsze=20zmiany=20(wy=C5=9Bwietlanie=20obie?= =?UTF-8?q?kt=C3=B3w)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CGameInfo.h | 2 + CMT.cpp | 12 ++++-- map.cpp | 10 ++++- map.h | 1 + mapHandler.cpp | 99 +++++++++++++++++++++++++++++++++++++++++++++++++- mapHandler.h | 11 +++++- 6 files changed, 127 insertions(+), 8 deletions(-) diff --git a/CGameInfo.h b/CGameInfo.h index afe00ab07..dd5e5748b 100644 --- a/CGameInfo.h +++ b/CGameInfo.h @@ -11,6 +11,7 @@ #include "CObjectHandler.h" #include "CMusicHandler.h" #include "CSemiLodHandler.h" +#include "CDefObjInfoHandler.h" /* CGameInfo class @@ -30,6 +31,7 @@ public: CObjectHandler * objh; CMusicHandler * mush; CSemiLodHandler * sspriteh; + CDefObjInfoHandler * dobjinfo; }; #endif //CGAMEINFO_H \ No newline at end of file diff --git a/CMT.cpp b/CMT.cpp index d1cca0dda..56e6d6e45 100644 --- a/CMT.cpp +++ b/CMT.cpp @@ -27,6 +27,7 @@ #include "CSemiLodHandler.h" #include "CLodHandler.h" #include "CDefHandler.h" +#include "CDefObjInfoHandler.h" #if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__) # include # include @@ -280,10 +281,10 @@ int _tmain(int argc, _TCHAR* argv[]) //CLodHandler * bitmapLod = new CLodHandler; //bitmapLod->init(std::string("newH3bitmap.lod")); - CPCXConv * tconv = new CPCXConv; - tconv->fromFile(std::string("newh3bitmap\\ADOPBPNL.PCX")); - tconv->convert(); - tconv->saveBMP(std::string("tesciczekConva.bmp")); + //CPCXConv * tconv = new CPCXConv; + //tconv->fromFile(std::string("newh3bitmap\\ADOPBPNL.PCX")); + //tconv->convert(); + //tconv->saveBMP(std::string("tesciczekConva.bmp")); CSemiDefHandler * semek = new CSemiDefHandler; semek->openDef(std::string("EDG.DEF"), std::string("H3sprite.lod")); @@ -313,6 +314,9 @@ int _tmain(int argc, _TCHAR* argv[]) CObjectHandler * objh = new CObjectHandler; objh->loadObjects(); cgi->objh = objh; + cgi->dobjinfo = new CDefObjInfoHandler; + cgi->dobjinfo->load(); + std::string mapname; //if (CPG) mapname = CPG->ourScenSel->mapsel.ourMaps[CPG->ourScenSel->mapsel.selected].filename; //else mapname = "4gryf"; diff --git a/map.cpp b/map.cpp index 20a1ba85b..07adf5f3f 100644 --- a/map.cpp +++ b/map.cpp @@ -12,7 +12,15 @@ int readNormalNr (unsigned char * bufor, int pos, int bytCon = 4) } return ret; } - +bool DefInfo::isVisitable() +{ + for (int i=6; i<12; i++) + { + if (bytes[i]) + return true; + } + return false; +} CMapHeader::CMapHeader(unsigned char *map) { this->version = (Eformat)map[0]; //wersja mapy diff --git a/map.h b/map.h index d052870a7..67f39e97d 100644 --- a/map.h +++ b/map.h @@ -59,6 +59,7 @@ struct DefInfo //information from def declaration int bytes [42]; //CSemiDefHandler * handler; CDefHandler * handler; + bool isVisitable(); }; struct Location { diff --git a/mapHandler.cpp b/mapHandler.cpp index 39e2f6254..1874c320a 100644 --- a/mapHandler.cpp +++ b/mapHandler.cpp @@ -5,8 +5,40 @@ #include "SDL_Extensions.h" #include "CGameInfo.h" #include "stdlib.h" +#include extern SDL_Surface * ekran; +// +//bool ObjSorter::operator <(const ObjSorter & por) const +//{ +// if(this->xpos>=por.xpos) +// return false; +// if(this->ypos>=por.ypos) +// return false; +// return true; +//}; + +class poX +{ +public: + bool operator()(const ObjSorter & por2, const ObjSorter & por) const + { + if(por2.xpos>=por.xpos) + return false; + return true; + }; +} pox; +class poY +{ +public: + bool operator ()(const ObjSorter & por2, const ObjSorter & por) const + { + if(por2.ypos>=por.ypos) + return false; + return true; + }; +} poy; + void CMapHandler::init() { fullHide = CGameInfo::mainObj->sspriteh->giveDef("TSHRC.DEF", 2); @@ -280,7 +312,72 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level, } } ////terrain printed; printing objects + std::vector lowPrObjs; + std::vector highPrObjs; + std::vector highPrObjsVis; for(int gg=0; ggobjh->objInstances.size(); ++gg) + { + if(CGameInfo::mainObj->objh->objInstances[gg].x >= x-Woff-4 && CGameInfo::mainObj->objh->objInstances[gg].x < dx+x-Hoff+4 && CGameInfo::mainObj->objh->objInstances[gg].y >= y-Hoff-4 && CGameInfo::mainObj->objh->objInstances[gg].y < dy+y-Hoff+4 && CGameInfo::mainObj->objh->objInstances[gg].z == level) + { + std::vector::iterator pit = std::find(CGameInfo::mainObj->dobjinfo->objs.begin(), CGameInfo::mainObj->dobjinfo->objs.end(), + CGameInfo::mainObj->ac->map.defy[CGameInfo::mainObj->objh->objInstances[gg].defNumber].name); + if(pit->priority==0) + { + ObjSorter os; + os.bitmap = CGameInfo::mainObj->ac->map.defy[CGameInfo::mainObj->objh->objInstances[gg].defNumber].handler->ourImages[anim%CGameInfo::mainObj->ac->map.defy[CGameInfo::mainObj->objh->objInstances[gg].defNumber].handler->ourImages.size()].bitmap; + os.xpos = (CGameInfo::mainObj->objh->objInstances[gg].x-x+4)*32; + os.ypos = (CGameInfo::mainObj->objh->objInstances[gg].y-y+4)*32; + if (CGameInfo::mainObj->ac->map.defy[CGameInfo::mainObj->objh->objInstances[gg].defNumber].isVisitable()) + highPrObjsVis.push_back(os); + else + highPrObjs.push_back(os); + } + else + { + ObjSorter os; + os.bitmap = CGameInfo::mainObj->ac->map.defy[CGameInfo::mainObj->objh->objInstances[gg].defNumber].handler->ourImages[anim%CGameInfo::mainObj->ac->map.defy[CGameInfo::mainObj->objh->objInstances[gg].defNumber].handler->ourImages.size()].bitmap; + os.xpos = (CGameInfo::mainObj->objh->objInstances[gg].x-x+4)*32; + os.ypos = (CGameInfo::mainObj->objh->objInstances[gg].y-y+4)*32; + lowPrObjs.push_back(os); + } + } + } + //std::stable_sort(lowPrObjs.begin(), lowPrObjs.end()); + std::stable_sort(highPrObjs.begin(), highPrObjs.end(),pox); + std::stable_sort(highPrObjs.begin(), highPrObjs.end(),poy); + std::stable_sort(highPrObjsVis.begin(), highPrObjsVis.end(),pox); + std::stable_sort(highPrObjsVis.begin(), highPrObjsVis.end(),poy); + for(int yy=0; yyw = lowPrObjs[yy].bitmap->w; + sr->h = lowPrObjs[yy].bitmap->h; + sr->x = lowPrObjs[yy].xpos - lowPrObjs[yy].bitmap->w + 32; + sr->y = lowPrObjs[yy].ypos - lowPrObjs[yy].bitmap->h + 32; + SDL_BlitSurface(lowPrObjs[yy].bitmap, NULL, su, sr); + delete sr; + } + for(int yy=0; yyw = highPrObjs[yy].bitmap->w; + sr->h = highPrObjs[yy].bitmap->h; + sr->x = highPrObjs[yy].xpos - highPrObjs[yy].bitmap->w + 32; + sr->y = highPrObjs[yy].ypos - highPrObjs[yy].bitmap->h + 32; + SDL_BlitSurface(highPrObjs[yy].bitmap, NULL, su, sr); + delete sr; + } + for(int yy=0; yyw = highPrObjsVis[yy].bitmap->w; + sr->h = highPrObjsVis[yy].bitmap->h; + sr->x = highPrObjsVis[yy].xpos - highPrObjsVis[yy].bitmap->w + 32; + sr->y = highPrObjsVis[yy].ypos - highPrObjsVis[yy].bitmap->h + 32; + SDL_BlitSurface(highPrObjsVis[yy].bitmap, NULL, su, sr); + delete sr; + } + /*for(int gg=0; ggobjh->objInstances.size(); ++gg) { if(CGameInfo::mainObj->objh->objInstances[gg].x >= x-3 && CGameInfo::mainObj->objh->objInstances[gg].x < dx+x-3 && CGameInfo::mainObj->objh->objInstances[gg].y >= y-3 && CGameInfo::mainObj->objh->objInstances[gg].y < dy+y-3 && CGameInfo::mainObj->objh->objInstances[gg].z == level) { @@ -292,7 +389,7 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level, SDL_BlitSurface(CGameInfo::mainObj->ac->map.defy[CGameInfo::mainObj->objh->objInstances[gg].defNumber].handler->ourImages[anim%CGameInfo::mainObj->ac->map.defy[CGameInfo::mainObj->objh->objInstances[gg].defNumber].handler->ourImages.size()].bitmap, NULL, su, sr); delete sr; } - } + }*/ ////objects printed, printing shadow for (int bx=0; bx