diff --git a/CAmbarCendamo.cpp b/CAmbarCendamo.cpp index 27e2d1ead..822a1099e 100644 --- a/CAmbarCendamo.cpp +++ b/CAmbarCendamo.cpp @@ -7,6 +7,7 @@ #include "SDL_Extensions.h" #include "boost\filesystem.hpp" #include +#define CGI (CGameInfo::mainObj) unsigned int intPow(unsigned int a, unsigned int b) { @@ -1756,15 +1757,13 @@ void CAmbarCendamo::loadDefs() { if (loadedTypes.find(map.terrain[i][j].tertype)==loadedTypes.end()) { - CSemiDefHandler *sdh = new CSemiDefHandler(); - sdh->openDef((sdh->nameFromType(map.terrain[i][j].tertype)).c_str(),"H3sprite.lod"); + CDefHandler *sdh = CGI->spriteh->giveDef(CSemiDefHandler::nameFromType(map.terrain[i][j].tertype).c_str()); loadedTypes.insert(map.terrain[i][j].tertype); defs.push_back(sdh); } if (map.twoLevel && loadedTypes.find(map.undergroungTerrain[i][j].tertype)==loadedTypes.end()) { - CSemiDefHandler *sdh = new CSemiDefHandler(); - sdh->openDef((sdh->nameFromType(map.undergroungTerrain[i][j].tertype)).c_str(),"H3sprite.lod"); + CDefHandler *sdh = CGI->spriteh->giveDef(CSemiDefHandler::nameFromType(map.undergroungTerrain[i][j].tertype).c_str()); loadedTypes.insert(map.undergroungTerrain[i][j].tertype); defs.push_back(sdh); } diff --git a/CAmbarCendamo.h b/CAmbarCendamo.h index 91f3106dd..45ae81e64 100644 --- a/CAmbarCendamo.h +++ b/CAmbarCendamo.h @@ -21,7 +21,7 @@ public: std::ifstream * is; // stream used to read map file int andame; // length of map file unsigned char * bufor; // here we store map bytecode - std::vector defs; + std::vector defs; /////////////////funkcje skladowe CAmbarCendamo (const char * tie); // c-tor; tie is the path of the map file CAmbarCendamo (unsigned char * map); // c-tor; map is pointer to array containing map; it is not copied, so don't delete diff --git a/CDefHandler.h b/CDefHandler.h index b61ce1f15..bd3b2abbd 100644 Binary files a/CDefHandler.h and b/CDefHandler.h differ diff --git a/CHeroHandler.cpp b/CHeroHandler.cpp index f9aafc836..9061c0f00 100644 --- a/CHeroHandler.cpp +++ b/CHeroHandler.cpp @@ -1,6 +1,8 @@ #include "stdafx.h" #include "CHeroHandler.h" #include "CGameInfo.h" +#include +#define CGI (CGameInfo::mainObj) void CHeroHandler::loadHeroes() { diff --git a/CLodHandler.cpp b/CLodHandler.cpp index 8477f62b1..aae50fa9c 100644 --- a/CLodHandler.cpp +++ b/CLodHandler.cpp @@ -430,7 +430,7 @@ std::vector CLodHandler::extractManyFiles(std::vectoropenDef("DIALGBOX.DEF","H3sprite.lod"); - background = SDL_LoadBMP("H3bitmap.lod\\DIBOXBCK.BMP"); + piecesOfBox = CGI->spriteh->giveDef("DIALGBOX.DEF"); + background = CGI->bitmaph->loadBitmap("DIBOXBCK.BMP"); SDL_SetColorKey(background,SDL_SRCCOLORKEY,SDL_MapRGB(background->format,0,255,255)); } SDL_Surface * CMessage::drawBox1(int w, int h) @@ -90,7 +92,7 @@ std::vector * CMessage::breakText(std::string text, int line) return ret; } SDL_Surface * CMessage::genMessage -(std::string title, std::string text, EWindowType type, std::vector *addPics, void * cb) +(std::string title, std::string text, EWindowType type, std::vector *addPics, void * cb) { //max x 320 okolo 30 znakow std::vector * tekst; diff --git a/CMessage.h b/CMessage.h index 934029e7c..6666c3a59 100644 --- a/CMessage.h +++ b/CMessage.h @@ -3,6 +3,7 @@ #include "SDL_TTF.h" #include "CSemiDefHandler.h" +#include "CDefHandler.h" enum EWindowType {infoOnly, infoOK, yesOrNO}; class CPreGame; class MapSel; @@ -14,7 +15,7 @@ struct OverButton int ID; int type; SDL_Rect pos; - CSemiDefHandler* imgs; + CDefHandler* imgs; int state; virtual void show() ; virtual void press(bool down=true); @@ -23,7 +24,7 @@ template struct Button: public OverButton { T fun; CGroup * ourGroup; - Button( SDL_Rect Pos, T Fun,CSemiDefHandler* Imgs, bool Sel=false, CGroup* gr=NULL, int id=-1) + Button( SDL_Rect Pos, T Fun,CDefHandler* Imgs, bool Sel=false, CGroup* gr=NULL, int id=-1) :fun(Fun),ourGroup(gr){type=0;imgs=Imgs;selectable=Sel;selected=false;state=0;pos=Pos;ID=id;}; Button(){}; bool selectable, selected; @@ -58,7 +59,7 @@ public: int key; int * what; IntBut(){type=2;fun=NULL;}; - IntBut( SDL_Rect Pos, T Fun,CSemiDefHandler* Imgs, bool Sel, int Key, int * What) + IntBut( SDL_Rect Pos, T Fun,CDefHandler* Imgs, bool Sel, int Key, int * What) : Button(Pos,Fun,Imgs,Sel,gr),key(My),key(Key),what(What){ourGroup=gr;type=2;fun=NULL;}; void set(){*what=key;}; }; @@ -68,7 +69,7 @@ public: CPoinGroup * ourGroup; int key; IntSelBut(){}; - IntSelBut( SDL_Rect Pos, T Fun,CSemiDefHandler* Imgs, bool Sel=false, CPoinGroup* gr=NULL, int My=-1) + IntSelBut( SDL_Rect Pos, T Fun,CDefHandler* Imgs, bool Sel=false, CPoinGroup* gr=NULL, int My=-1) : Button(Pos,Fun,Imgs,Sel,gr),key(My){ourGroup=gr;type=1;}; void select(bool on=true) {(*this).Button::select(on);ourGroup->setYour(this);} }; @@ -89,10 +90,10 @@ class CMessage { public: static std::vector * breakText(std::string text, int line=30); - CSemiDefHandler * piecesOfBox; + CDefHandler * piecesOfBox; SDL_Surface * background; SDL_Surface * genMessage(std::string title, std::string text, EWindowType type=infoOnly, - std::vector *addPics=NULL, void * cb=NULL); + std::vector *addPics=NULL, void * cb=NULL); SDL_Surface * drawBox1(int w, int h); CMessage(); }; diff --git a/CPreGame.cpp b/CPreGame.cpp index 37626d5cf..f4d4886b7 100644 Binary files a/CPreGame.cpp and b/CPreGame.cpp differ diff --git a/CPreGame.h b/CPreGame.h index 9ad8d1be1..02a495ef7 100644 --- a/CPreGame.h +++ b/CPreGame.h @@ -74,7 +74,7 @@ public: CPreGameTextHandler * preth ; SDL_Rect * currentMessage; SDL_Surface * behindCurMes; - CSemiDefHandler *ok, *cancel; + CDefHandler *ok, *cancel; enum EState { //where are we? mainMenu, newGame, loadGame, ScenarioList } state; diff --git a/SDL_Extensions.cpp b/SDL_Extensions.cpp index 51789b708..d6f0e8cfd 100644 --- a/SDL_Extensions.cpp +++ b/SDL_Extensions.cpp @@ -20,8 +20,6 @@ SDL_Rect genRect(int hh, int ww, int xx, int yy) } void blitAt(SDL_Surface * src, int x, int y, SDL_Surface * dst=ekran) { - SDL_SaveBMP(src, "bufimg.bmp"); - SDL_SaveBMP(dst, "bufimg2.bmp"); SDL_Rect pom = genRect(src->h,src->w,x,y); SDL_BlitSurface(src,NULL,dst,&pom); } diff --git a/mapHandler.cpp b/mapHandler.cpp index 391d622aa..43c8e38f9 100644 --- a/mapHandler.cpp +++ b/mapHandler.cpp @@ -41,8 +41,8 @@ public: void CMapHandler::init() { - fullHide = CGameInfo::mainObj->sspriteh->giveDef("TSHRC.DEF", 2); - partialHide = CGameInfo::mainObj->sspriteh->giveDef("TSHRE.DEF", 2); + fullHide = CGameInfo::mainObj->spriteh->giveDef("TSHRC.DEF"); + partialHide = CGameInfo::mainObj->spriteh->giveDef("TSHRE.DEF"); for(int i=0; iourImages.size(); ++i) { @@ -78,7 +78,7 @@ void CMapHandler::init() terrainBitmap = new SDL_Surface **[reader->map.width+8]; for (int ii=0;iimap.width+2*Woff;ii++) terrainBitmap[ii] = new SDL_Surface*[reader->map.height+2*Hoff]; // allocate memory - CSemiDefHandler * bord = CGameInfo::mainObj->sspriteh->giveDef("EDG.DEF"); + CDefHandler * bord = CGameInfo::mainObj->spriteh->giveDef("EDG.DEF"); for (int i=0; imap.width+2*Woff; i++) //jest po szerokości { for (int j=0; jmap.height+2*Hoff;j++) //po wysokości diff --git a/mapHandler.h b/mapHandler.h index 412afc24a..639be955c 100644 --- a/mapHandler.h +++ b/mapHandler.h @@ -24,8 +24,8 @@ public: SDL_Surface * terrainRect(int x, int y, int dx, int dy, int level=0, unsigned char anim=0); SDL_Surface * terrBitmap(int x, int y); SDL_Surface * undTerrBitmap(int x, int y); - CSemiDefHandler * fullHide; - CSemiDefHandler * partialHide; + CDefHandler * fullHide; + CDefHandler * partialHide; std::vector< std::vector > visibility; //true means that pointed place is visible std::vector< std::vector > undVisibility; //true means that pointed place is visible