diff --git a/CGameInfo.h b/CGameInfo.h index de258e791..1bca61c76 100644 --- a/CGameInfo.h +++ b/CGameInfo.h @@ -59,8 +59,8 @@ public: CSemiLodHandler * sspriteh; CDefObjInfoHandler * dobjinfo; CTownHandler * townh; - CLodHandler * spriteh; - CLodHandler * bitmaph; + //CLodHandler * spriteh; + //CLodHandler * bitmaph; CGeneralTextHandler * generaltexth; CConsoleHandler * consoleh; CCursorHandler * curh; diff --git a/CMT.cpp b/CMT.cpp index fbf8834f7..40dfba389 100644 --- a/CMT.cpp +++ b/CMT.cpp @@ -127,12 +127,7 @@ int main(int argc, char** argv) tlog0<<"\tInitializing sound: "<spriteh = new CLodHandler(); - cgi->spriteh->init("Data" PATHSEPARATOR "H3sprite.lod","Sprites"); - BitmapHandler::bitmaph = cgi->bitmaph = new CLodHandler; - cgi->bitmaph->init("Data" PATHSEPARATOR "H3bitmap.lod","Data"); - tlog0<<"Loading .lod files: "<bitmaph,::console,logfile); + initDLL(::console,logfile); CGI->setFromLib(); cgi->audioh->initCreaturesSounds(CGI->creh->creatures); tlog0<<"Initializing VCMI_Lib: "<addButton(boost::assign::map_list_of(0,CGI->generaltexth->zelp[326+i].first),CGI->generaltexth->zelp[326+i].second, "syslb.def", 188 + 19*i, 415, i*11); + musicVolume->addButton(boost::assign::map_list_of(0,CGI->generaltexth->zelp[326+i].first),CGI->generaltexth->zelp[326+i].second, "syslb.def", 188 + 19*i, 416, i*11); } musicVolume->select(CGI->audioh->getMusicVolume(), 1); musicVolume->onChange = boost::bind(&CAudioHandler::setMusicVolume, CGI->audioh, _1); @@ -4462,7 +4462,7 @@ CSystemOptionsWindow::CSystemOptionsWindow(const SDL_Rect &pos, CPlayerInterface effectsVolume = new CHighlightableButtonsGroup(0, true); for(int i=0; i<10; ++i) { - effectsVolume->addButton(boost::assign::map_list_of(0,CGI->generaltexth->zelp[336+i].first),CGI->generaltexth->zelp[336+i].second, "syslb.def", 188 + 19*i, 481, i*11); + effectsVolume->addButton(boost::assign::map_list_of(0,CGI->generaltexth->zelp[336+i].first),CGI->generaltexth->zelp[336+i].second, "syslb.def", 188 + 19*i, 482, i*11); } effectsVolume->select(CGI->audioh->getSoundVolume(), 1); effectsVolume->onChange = boost::bind(&CAudioHandler::setSoundVolume, CGI->audioh, _1); diff --git a/CThreadHelper.h b/CThreadHelper.h index 2b2b6c944..38474a59f 100644 --- a/CThreadHelper.h +++ b/CThreadHelper.h @@ -46,10 +46,10 @@ template inline void setData(T * data, boost::function func) #define GET_DEF(DESTINATION, DEF_NAME) \ (GET_DATA \ (CDefHandler*,DESTINATION,\ - boost::function(boost::bind(CDefHandler::giveDef,DEF_NAME,(CLodHandler*)NULL)))) + boost::function(boost::bind(CDefHandler::giveDef,DEF_NAME)))) #define GET_DEF_ESS(DESTINATION, DEF_NAME) \ (GET_DATA \ (CDefEssential*,DESTINATION,\ - boost::function(boost::bind(CDefHandler::giveDefEss,DEF_NAME,(CLodHandler*)NULL)))) + boost::function(boost::bind(CDefHandler::giveDefEss,DEF_NAME)))) #endif // __CTHREADHELPER_H__ diff --git a/client/CBitmapHandler.cpp b/client/CBitmapHandler.cpp index 0450cdea4..e1ab573dd 100644 --- a/client/CBitmapHandler.cpp +++ b/client/CBitmapHandler.cpp @@ -19,7 +19,9 @@ boost::mutex bitmap_handler_mx; int readNormalNr (int pos, int bytCon, unsigned char * str); -CLodHandler * BitmapHandler::bitmaph = NULL; + +extern DLL_EXPORT CLodHandler *bitmaph; + void BMPHeader::print(std::ostream & out) { CDefHandler::print(out,fullSize,4); diff --git a/client/CBitmapHandler.h b/client/CBitmapHandler.h index e7536cbbc..934f5e896 100644 --- a/client/CBitmapHandler.h +++ b/client/CBitmapHandler.h @@ -47,7 +47,6 @@ public: }; namespace BitmapHandler { - extern CLodHandler *bitmaph; SDL_Surface * loadBitmap(std::string fname, bool setKey=false); }; diff --git a/client/CCreatureAnimation.cpp b/client/CCreatureAnimation.cpp index 0c29d1d5b..bddab1c8a 100644 --- a/client/CCreatureAnimation.cpp +++ b/client/CCreatureAnimation.cpp @@ -1,5 +1,6 @@ #include "CCreatureAnimation.h" #include "../hch/CLodHandler.h" +#include "../lib/VCMI_Lib.h" /* * CCreatureAnimation.cpp, part of VCMI engine @@ -35,7 +36,7 @@ void CCreatureAnimation::setType(int type) CCreatureAnimation::CCreatureAnimation(std::string name) : RLEntries(NULL), internalFrame(0), once(false) { - FDef = CDefHandler::Spriteh->giveFile(name); //load main file + FDef = spriteh->giveFile(name); //load main file //init anim data int i,j, totalInBlock; diff --git a/client/Graphics.cpp b/client/Graphics.cpp index aca3238da..7b0c85953 100644 --- a/client/Graphics.cpp +++ b/client/Graphics.cpp @@ -13,6 +13,7 @@ #include "../CThreadHelper.h" #include "../CGameInfo.h" #include "../hch/CLodHandler.h" +#include "../lib/VCMI_Lib.h" using namespace boost::assign; using namespace CSDL_Ext; #ifdef min @@ -102,7 +103,7 @@ SDL_Surface * Graphics::drawTownInfoWin(const CGTownInstance * curh) void Graphics::loadPaletteAndColors() { - std::string pals = CGI->bitmaph->getTextFile("PLAYERS.PAL"); + std::string pals = bitmaph->getTextFile("PLAYERS.PAL"); playerColorPalette = new SDL_Color[256]; neutralColor = new SDL_Color; playerColors = new SDL_Color[PLAYER_LIMIT]; diff --git a/config/settings.txt b/config/settings.txt index c8350a59e..6ffc917cb 100644 --- a/config/settings.txt +++ b/config/settings.txt @@ -97,4 +97,4 @@ GUISettings ButtonEndTurn: x=903 y=524 graphic=IAM001.DEF playerColoured=1; }; } -} +} \ No newline at end of file diff --git a/hch/CDefHandler.cpp b/hch/CDefHandler.cpp index f8807f938..d7455b92e 100644 --- a/hch/CDefHandler.cpp +++ b/hch/CDefHandler.cpp @@ -3,6 +3,7 @@ #include "CDefHandler.h" #include #include "CLodHandler.h" +#include "../lib/VCMI_Lib.h" /* * CDefHandler.cpp, part of VCMI engine @@ -14,8 +15,6 @@ * */ -CLodHandler* CDefHandler::Spriteh = NULL; - long long pow(long long a, int b) { if (!b) return 1; @@ -564,9 +563,8 @@ CDefEssential * CDefHandler::essentialize() return ret; } -CDefHandler * CDefHandler::giveDef(std::string defName, CLodHandler * spriteh) +CDefHandler * CDefHandler::giveDef(std::string defName) { - if(!spriteh) spriteh=Spriteh; unsigned char * data = spriteh->giveFile(defName); if(!data) throw "bad def name!"; @@ -576,10 +574,10 @@ CDefHandler * CDefHandler::giveDef(std::string defName, CLodHandler * spriteh) delete [] data; return nh; } -CDefEssential * CDefHandler::giveDefEss(std::string defName, CLodHandler * spriteh) +CDefEssential * CDefHandler::giveDefEss(std::string defName) { CDefEssential * ret; - CDefHandler * temp = giveDef(defName,spriteh); + CDefHandler * temp = giveDef(defName); ret = temp->essentialize(); delete temp; return ret; diff --git a/hch/CDefHandler.h b/hch/CDefHandler.h index b7d473ca5..a892325d0 100644 --- a/hch/CDefHandler.h +++ b/hch/CDefHandler.h @@ -39,7 +39,6 @@ private: public: int width, height; //width and height - static CLodHandler * Spriteh; std::string defName, curDir; std::vector ourImages; bool alphaTransformed; @@ -56,8 +55,8 @@ public: void openFromMemory(unsigned char * table, std::string name); CDefEssential * essentialize(); - static CDefHandler * giveDef(std::string defName, CLodHandler * spriteh=NULL); - static CDefEssential * giveDefEss(std::string defName, CLodHandler * spriteh=NULL); + static CDefHandler * giveDef(std::string defName); + static CDefEssential * giveDefEss(std::string defName); }; class CDefEssential //DefHandler with images only diff --git a/lib/VCMI_Lib.cpp b/lib/VCMI_Lib.cpp index 01f81f3d3..610c1deba 100644 --- a/lib/VCMI_Lib.cpp +++ b/lib/VCMI_Lib.cpp @@ -5,6 +5,7 @@ #include "../hch/CCreatureHandler.h" #include "../hch/CDefObjInfoHandler.h" #include "../hch/CHeroHandler.h" +#include "../hch/CLodHandler.h" #include "../hch/CObjectHandler.h" #include "../hch/CTownHandler.h" #include "../hch/CBuildingHandler.h" @@ -23,21 +24,23 @@ class CLodHandler; LibClasses * VLC = NULL; -CLodHandler * bitmaph=NULL; +DLL_EXPORT CLodHandler *bitmaph = NULL, + *spriteh = NULL; + DLL_EXPORT CLogger<0> tlog0; DLL_EXPORT CLogger<1> tlog1; DLL_EXPORT CLogger<2> tlog2; DLL_EXPORT CLogger<3> tlog3; DLL_EXPORT CLogger<4> tlog4; DLL_EXPORT CLogger<5> tlog5; + DLL_EXPORT CConsoleHandler *console = NULL; DLL_EXPORT std::ostream *logfile = NULL ; -DLL_EXPORT void initDLL(CLodHandler *b, CConsoleHandler *Console, std::ostream *Logfile) +DLL_EXPORT void initDLL(CConsoleHandler *Console, std::ostream *Logfile) { console = Console; logfile = Logfile; - bitmaph=b; VLC = new LibClasses; VLC->init(); } @@ -160,6 +163,12 @@ DLL_EXPORT void loadToIt(si32 &dest, std::string &src, int &iter, int mode) void LibClasses::init() { timeHandler pomtime; + spriteh = new CLodHandler(); + spriteh->init("Data" PATHSEPARATOR "H3sprite.lod","Sprites"); + bitmaph = new CLodHandler; + bitmaph->init("Data" PATHSEPARATOR "H3bitmap.lod","Data"); + tlog0<<"Loading .lod files: "<load(); tlog0<<"\tGeneral text handler: "<