From d5b0bdcf9efb6f372781a6978916f894cda8faf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20W=2E=20Urba=C5=84czyk?= Date: Mon, 16 Jun 2008 10:51:14 +0000 Subject: [PATCH] A little threading and minor changes. --- CMT.cpp | 56 ++-- CPreGame.cpp | Bin 128732 -> 129722 bytes CPreGame.h | 1 + client/Graphics.cpp | 589 ++++++++++++++------------------------ client/Graphics.h | 3 + client/VCMI_client.vcproj | 2 +- hch/CLodHandler.cpp | 7 +- hch/CLodHandler.h | 4 +- hch/CObjectHandler.cpp | 3 +- lib/VCMI_lib.vcproj | 6 +- 10 files changed, 263 insertions(+), 408 deletions(-) diff --git a/CMT.cpp b/CMT.cpp index 944ab8d33..452590147 100644 --- a/CMT.cpp +++ b/CMT.cpp @@ -48,6 +48,7 @@ #include "CAdvmapInterface.h" #include "CCastleInterface.h" #include "client\Graphics.h" +#include #if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__) # include # include @@ -324,57 +325,43 @@ void initGameState(Mapa * map, CGameInfo * cgi) int _tmain(int argc, _TCHAR* argv[]) { - //std::ios_base::sync_with_stdio(0); + srand ( time(NULL) ); + CPG=NULL; + atexit(SDL_Quit); + CGameInfo * cgi = CGI = new CGameInfo; //contains all global informations about game (texts, lodHandlers, map handler itp.) //CLuaHandler luatest; //luatest.test(); - //CBIKHandler cb; //cb.open("CSECRET.BIK"); + std::cout << "Starting... " << std::endl; THC timeHandler tmh, total, pomtime; - int xx=0, yy=0, zz=0; - srand ( time(NULL) ); - std::vector Sprites; if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_AUDIO/*|SDL_INIT_EVENTTHREAD*/)==0) { - screen = SDL_SetVideoMode(800,600,24,SDL_SWSURFACE|SDL_DOUBLEBUF/*|SDL_FULLSCREEN*/); - - //initializing important global surface -#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 + screen = SDL_SetVideoMode(800,600,24,SDL_SWSURFACE|SDL_DOUBLEBUF/*|SDL_FULLSCREEN*/); //initializing important global surface + THC std::cout<<"\tInitializing screen: "<initMusics(); //audio initialized - - - //screen2 = SDL_SetVideoMode(800,600,24,SDL_SWSURFACE|SDL_DOUBLEBUF/*|SDL_FULLSCREEN*/); - //screen = SDL_ConvertSurface(screen2, screen2->format, SDL_SWSURFACE); - - SDL_WM_SetCaption(NAME,""); //set window title - CGameInfo * cgi = CGI = new CGameInfo; //contains all global informations about game (texts, lodHandlers, map handler itp.) cgi->consoleh = new CConsoleHandler; cgi->mush = mush; cgi->curh = new CCursorHandler; - + THC std::cout<<"\tInitializing sound and cursor: "<spriteh = new CLodHandler(); cgi->spriteh->init("Data\\H3sprite.lod","Sprites"); @@ -403,7 +390,14 @@ int _tmain(int argc, _TCHAR* argv[]) cgi->heroh = heroh; THC std::cout<<"\tHero handler: "< animacje; + for(std::vector::iterator i = cgi->heroh->heroClasses.begin();i!=cgi->heroh->heroClasses.end();i++) + animacje.push_back(&((*i)->*(&CHeroClass::moveAnim))); + graphics->loadHeroAnim(animacje); + THC std::cout<<"\tHero animations: "<1M zh-kQr=hFUwf|5l+bXVMT??yKwG?qk41^1r!CP}AOxeV{k%>6j$+n2XDJUWQi)=C7HE;ul%zR|;$DDFmCMG!1UcPiDMJsPE|pD}^=aV1WsJrsM@z_; zrWFd{zCz=&*APSAJf-ll2)l+d1)Qeb>lASj?8xrXl%tTKm4nL>Ki79IwHJUV z$5u7O9ko-P0Xl~~N{=F2wXnycQEfB4T#dU+pu9wB{&s%QlL1$&~uiUx@&B%?2@K=8A`h;<@q4!lFng;^alnj~tao0c6@TQ23w*CB-QHxZLnJY>ue?eU{~7SRbapsSfXh^wO52DN}z=zo7P zFKS=y9)-~TCgm5aS1Px+yM6smCijtEwIG3@EXmHp0J_6>VjHtVqJ9GmW7%*Zu)!WV(bCoV}$W~p=7Y;=Q9V)KJbD$LW5IWsCv zeso%F^0hO3(>KU4N=;sN)`c;1^82%z)3bgua!sGZ!zePj=$sL!HiI@pCJ0UrG*=V^ zvFsR37!1HrlR;s6;yOn0$=}XpF>5o}PWC=0J-P3Ej;ua|K2TvAg93vFLopae12x1l z*f1C|SWLcqK~}hmA%~$7D4)iV&rrmW%aF)WGWp~AnT(m6`!5(XPL?<)#j6FD&IBq< zWiXm-drq6Nc=}sqMsdd2$?^TNlN0{(Km;Tw&qxuF=L8xBRm%{~kOj2N7H&0=H(CCY zKEE@AFVLa_22X}Okj0Z1UY8V(2I`7s&_U9zIl1tXyfDHvYX)8hE(T79+UCR$+Y>)9 HMsfiF{5)%n diff --git a/CPreGame.h b/CPreGame.h index cce661198..26c865edb 100644 --- a/CPreGame.h +++ b/CPreGame.h @@ -203,6 +203,7 @@ public: void moveByOne(bool up); void printSelectedInfo(); void printFlags(); + void processMaps(std::vector &pliczkiTemp, int &index); MapSel(); ~MapSel(); }; diff --git a/client/Graphics.cpp b/client/Graphics.cpp index 41389a4d5..8389644a4 100644 --- a/client/Graphics.cpp +++ b/client/Graphics.cpp @@ -2,7 +2,13 @@ #include "Graphics.h" #include "../hch/CDefHandler.h" #include "../hch/CObjectHandler.h" +//#include "../hch/CHeroHandler.h" #include "../SDL_Extensions.h" +#include +#include +#include +#include +#include using namespace CSDL_Ext; Graphics * graphics = NULL; SDL_Surface * Graphics::drawPrimarySkill(const CGHeroInstance *curh, SDL_Surface *ret, int from, int to) @@ -157,380 +163,221 @@ Graphics::Graphics() smallIcons = CDefHandler::giveDef("ITPA.DEF"); resources32 = CDefHandler::giveDef("RESOURCE.DEF"); loadHeroFlags(); - - - - //std::stringstream nm; - //nm<<"AH"; - //nm<moveAnim = CDefHandler::giveDef(nm.str()); - - //for(int o=0; omoveAnim->ourImages.size(); ++o) - //{ - // if(hc->moveAnim->ourImages[o].groupNumber==6) - // { - // for(int e=0; e<8; ++e) - // { - // Cimage nci; - // nci.bitmap = CSDL_Ext::rotate01(hc->moveAnim->ourImages[o+e].bitmap); - // nci.groupNumber = 10; - // nci.imName = std::string(); - // hc->moveAnim->ourImages.push_back(nci); - // } - // o+=8; - // } - // if(hc->moveAnim->ourImages[o].groupNumber==7) - // { - // for(int e=0; e<8; ++e) - // { - // Cimage nci; - // nci.bitmap = CSDL_Ext::rotate01(hc->moveAnim->ourImages[o+e].bitmap); - // nci.groupNumber = 11; - // nci.imName = std::string(); - // hc->moveAnim->ourImages.push_back(nci); - // } - // o+=8; - // } - // if(hc->moveAnim->ourImages[o].groupNumber==8) - // { - // for(int e=0; e<8; ++e) - // { - // Cimage nci; - // nci.bitmap = CSDL_Ext::rotate01(hc->moveAnim->ourImages[o+e].bitmap); - // nci.groupNumber = 12; - // nci.imName = std::string(); - // hc->moveAnim->ourImages.push_back(nci); - // } - // o+=8; - // } - //} - //for(int o=0; omoveAnim->ourImages.size(); ++o) - //{ - // if(hc->moveAnim->ourImages[o].groupNumber==1) - // { - // Cimage nci; - // nci.bitmap = CSDL_Ext::rotate01(hc->moveAnim->ourImages[o].bitmap); - // nci.groupNumber = 13; - // nci.imName = std::string(); - // hc->moveAnim->ourImages.push_back(nci); - // //o+=1; - // } - // if(hc->moveAnim->ourImages[o].groupNumber==2) - // { - // Cimage nci; - // nci.bitmap = CSDL_Ext::rotate01(hc->moveAnim->ourImages[o].bitmap); - // nci.groupNumber = 14; - // nci.imName = std::string(); - // hc->moveAnim->ourImages.push_back(nci); - // //o+=1; - // } - // if(hc->moveAnim->ourImages[o].groupNumber==3) - // { - // Cimage nci; - // nci.bitmap = CSDL_Ext::rotate01(hc->moveAnim->ourImages[o].bitmap); - // nci.groupNumber = 15; - // nci.imName = std::string(); - // hc->moveAnim->ourImages.push_back(nci); - // //o+=1; - // } - //} - - //for(int ff=0; ffmoveAnim->ourImages.size(); ++ff) - //{ - // CSDL_Ext::alphaTransform(hc->moveAnim->ourImages[ff].bitmap); - //} - //hc->moveAnim->alphaTransformed = true; } +void Graphics::loadHeroAnim(std::vector & anims) +{ + for(int i=0; iourImages.size(); ++o) + { + if((*anims[i])->ourImages[o].groupNumber==6) + { + for(int e=0; e<8; ++e) + { + Cimage nci; + nci.bitmap = CSDL_Ext::rotate01((*anims[i])->ourImages[o+e].bitmap); + nci.groupNumber = 10; + nci.imName = std::string(); + (*anims[i])->ourImages.push_back(nci); + } + o+=8; + } + if((*anims[i])->ourImages[o].groupNumber==7) + { + for(int e=0; e<8; ++e) + { + Cimage nci; + nci.bitmap = CSDL_Ext::rotate01((*anims[i])->ourImages[o+e].bitmap); + nci.groupNumber = 11; + nci.imName = std::string(); + (*anims[i])->ourImages.push_back(nci); + } + o+=8; + } + if((*anims[i])->ourImages[o].groupNumber==8) + { + for(int e=0; e<8; ++e) + { + Cimage nci; + nci.bitmap = CSDL_Ext::rotate01((*anims[i])->ourImages[o+e].bitmap); + nci.groupNumber = 12; + nci.imName = std::string(); + (*anims[i])->ourImages.push_back(nci); + } + o+=8; + } + } + for(int o=0; o<(*anims[i])->ourImages.size(); ++o) + { + if((*anims[i])->ourImages[o].groupNumber==1) + { + Cimage nci; + nci.bitmap = CSDL_Ext::rotate01((*anims[i])->ourImages[o].bitmap); + nci.groupNumber = 13; + nci.imName = std::string(); + (*anims[i])->ourImages.push_back(nci); + //o+=1; + } + if((*anims[i])->ourImages[o].groupNumber==2) + { + Cimage nci; + nci.bitmap = CSDL_Ext::rotate01((*anims[i])->ourImages[o].bitmap); + nci.groupNumber = 14; + nci.imName = std::string(); + (*anims[i])->ourImages.push_back(nci); + //o+=1; + } + if((*anims[i])->ourImages[o].groupNumber==3) + { + Cimage nci; + nci.bitmap = CSDL_Ext::rotate01((*anims[i])->ourImages[o].bitmap); + nci.groupNumber = 15; + nci.imName = std::string(); + (*anims[i])->ourImages.push_back(nci); + //o+=1; + } + } + + for(int ff=0; ff<(*anims[i])->ourImages.size(); ++ff) + { + CSDL_Ext::alphaTransform((*anims[i])->ourImages[ff].bitmap); + } + (*anims[i])->alphaTransformed = true; + } +} + +void Graphics::loadHeroFlags(std::pair Graphics::*, std::vector > &pr, bool mode) +{ + for(int i=0;i<8;i++) + (this->*pr.first).push_back(CDefHandler::giveDef(pr.second[i])); + + for(int q=0; q<8; ++q) + { + for(int o=0; o<(this->*pr.first)[q]->ourImages.size(); ++o) + { + if((this->*pr.first)[q]->ourImages[o].groupNumber==6) + { + for(int e=0; e<8; ++e) + { + Cimage nci; + nci.bitmap = CSDL_Ext::rotate01((this->*pr.first)[q]->ourImages[o+e].bitmap); + nci.groupNumber = 10; + nci.imName = std::string(); + (this->*pr.first)[q]->ourImages.push_back(nci); + } + o+=8; + } + if((this->*pr.first)[q]->ourImages[o].groupNumber==7) + { + for(int e=0; e<8; ++e) + { + Cimage nci; + nci.bitmap = CSDL_Ext::rotate01((this->*pr.first)[q]->ourImages[o+e].bitmap); + nci.groupNumber = 11; + nci.imName = std::string(); + (this->*pr.first)[q]->ourImages.push_back(nci); + } + o+=8; + } + if((this->*pr.first)[q]->ourImages[o].groupNumber==8) + { + for(int e=0; e<8; ++e) + { + Cimage nci; + nci.bitmap = CSDL_Ext::rotate01((this->*pr.first)[q]->ourImages[o+e].bitmap); + nci.groupNumber = 12; + nci.imName = std::string(); + (this->*pr.first)[q]->ourImages.push_back(nci); + } + o+=8; + } + } + if (mode) + { + for(int o=0; oourImages.size(); ++o) + { + if(flags4[q]->ourImages[o].groupNumber==1) + { + for(int e=0; e<8; ++e) + { + Cimage nci; + nci.bitmap = CSDL_Ext::rotate01(flags4[q]->ourImages[o+e].bitmap); + nci.groupNumber = 13; + nci.imName = std::string(); + flags4[q]->ourImages.push_back(nci); + } + o+=8; + } + if(flags4[q]->ourImages[o].groupNumber==2) + { + for(int e=0; e<8; ++e) + { + Cimage nci; + nci.bitmap = CSDL_Ext::rotate01(flags4[q]->ourImages[o+e].bitmap); + nci.groupNumber = 14; + nci.imName = std::string(); + flags4[q]->ourImages.push_back(nci); + } + o+=8; + } + if(flags4[q]->ourImages[o].groupNumber==3) + { + for(int e=0; e<8; ++e) + { + Cimage nci; + nci.bitmap = CSDL_Ext::rotate01(flags4[q]->ourImages[o+e].bitmap); + nci.groupNumber = 15; + nci.imName = std::string(); + flags4[q]->ourImages.push_back(nci); + } + o+=8; + } + } + } + for(int ff=0; ff<(this->*pr.first)[q]->ourImages.size(); ++ff) + { + SDL_SetColorKey((this->*pr.first)[q]->ourImages[ff].bitmap, SDL_SRCCOLORKEY, + SDL_MapRGB((this->*pr.first)[q]->ourImages[ff].bitmap->format, 0, 255, 255) + ); + } + (this->*pr.first)[q]->alphaTransformed = true; + } +} + void Graphics::loadHeroFlags() { - flags1.push_back(CDefHandler::giveDef("ABF01L.DEF")); //red - flags1.push_back(CDefHandler::giveDef("ABF01G.DEF")); //blue - flags1.push_back(CDefHandler::giveDef("ABF01R.DEF")); //tan - flags1.push_back(CDefHandler::giveDef("ABF01D.DEF")); //green - flags1.push_back(CDefHandler::giveDef("ABF01B.DEF")); //orange - flags1.push_back(CDefHandler::giveDef("ABF01P.DEF")); //purple - flags1.push_back(CDefHandler::giveDef("ABF01W.DEF")); //teal - flags1.push_back(CDefHandler::giveDef("ABF01K.DEF")); //pink - - for(int q=0; q<8; ++q) - { - for(int o=0; oourImages.size(); ++o) - { - if(flags1[q]->ourImages[o].groupNumber==6) - { - for(int e=0; e<8; ++e) - { - Cimage nci; - nci.bitmap = CSDL_Ext::rotate01(flags1[q]->ourImages[o+e].bitmap); - nci.groupNumber = 10; - nci.imName = std::string(); - flags1[q]->ourImages.push_back(nci); - } - o+=8; - } - if(flags1[q]->ourImages[o].groupNumber==7) - { - for(int e=0; e<8; ++e) - { - Cimage nci; - nci.bitmap = CSDL_Ext::rotate01(flags1[q]->ourImages[o+e].bitmap); - nci.groupNumber = 11; - nci.imName = std::string(); - flags1[q]->ourImages.push_back(nci); - } - o+=8; - } - if(flags1[q]->ourImages[o].groupNumber==8) - { - for(int e=0; e<8; ++e) - { - Cimage nci; - nci.bitmap = CSDL_Ext::rotate01(flags1[q]->ourImages[o+e].bitmap); - nci.groupNumber = 12; - nci.imName = std::string(); - flags1[q]->ourImages.push_back(nci); - } - o+=8; - } - } - - for(int ff=0; ffourImages.size(); ++ff) - { - SDL_SetColorKey(flags1[q]->ourImages[ff].bitmap, SDL_SRCCOLORKEY, - SDL_MapRGB(flags1[q]->ourImages[ff].bitmap->format, 0, 255, 255) - ); - } - flags1[q]->alphaTransformed = true; - } - - flags2.push_back(CDefHandler::giveDef("ABF02L.DEF")); //red - flags2.push_back(CDefHandler::giveDef("ABF02G.DEF")); //blue - flags2.push_back(CDefHandler::giveDef("ABF02R.DEF")); //tan - flags2.push_back(CDefHandler::giveDef("ABF02D.DEF")); //green - flags2.push_back(CDefHandler::giveDef("ABF02B.DEF")); //orange - flags2.push_back(CDefHandler::giveDef("ABF02P.DEF")); //purple - flags2.push_back(CDefHandler::giveDef("ABF02W.DEF")); //teal - flags2.push_back(CDefHandler::giveDef("ABF02K.DEF")); //pink - - for(int q=0; q<8; ++q) - { - for(int o=0; oourImages.size(); ++o) - { - if(flags2[q]->ourImages[o].groupNumber==6) - { - for(int e=0; e<8; ++e) - { - Cimage nci; - nci.bitmap = CSDL_Ext::rotate01(flags2[q]->ourImages[o+e].bitmap); - nci.groupNumber = 10; - nci.imName = std::string(); - flags2[q]->ourImages.push_back(nci); - } - o+=8; - } - if(flags2[q]->ourImages[o].groupNumber==7) - { - for(int e=0; e<8; ++e) - { - Cimage nci; - nci.bitmap = CSDL_Ext::rotate01(flags2[q]->ourImages[o+e].bitmap); - nci.groupNumber = 11; - nci.imName = std::string(); - flags2[q]->ourImages.push_back(nci); - } - o+=8; - } - if(flags2[q]->ourImages[o].groupNumber==8) - { - for(int e=0; e<8; ++e) - { - Cimage nci; - nci.bitmap = CSDL_Ext::rotate01(flags2[q]->ourImages[o+e].bitmap); - nci.groupNumber = 12; - nci.imName = std::string(); - flags2[q]->ourImages.push_back(nci); - } - o+=8; - } - } - - for(int ff=0; ffourImages.size(); ++ff) - { - SDL_SetColorKey(flags2[q]->ourImages[ff].bitmap, SDL_SRCCOLORKEY, - SDL_MapRGB(flags2[q]->ourImages[ff].bitmap->format, 0, 255, 255) - ); - } - flags2[q]->alphaTransformed = true; - } - - flags3.push_back(CDefHandler::giveDef("ABF03L.DEF")); //red - flags3.push_back(CDefHandler::giveDef("ABF03G.DEF")); //blue - flags3.push_back(CDefHandler::giveDef("ABF03R.DEF")); //tan - flags3.push_back(CDefHandler::giveDef("ABF03D.DEF")); //green - flags3.push_back(CDefHandler::giveDef("ABF03B.DEF")); //orange - flags3.push_back(CDefHandler::giveDef("ABF03P.DEF")); //purple - flags3.push_back(CDefHandler::giveDef("ABF03W.DEF")); //teal - flags3.push_back(CDefHandler::giveDef("ABF03K.DEF")); //pink - - for(int q=0; q<8; ++q) - { - for(int o=0; oourImages.size(); ++o) - { - if(flags3[q]->ourImages[o].groupNumber==6) - { - for(int e=0; e<8; ++e) - { - Cimage nci; - nci.bitmap = CSDL_Ext::rotate01(flags3[q]->ourImages[o+e].bitmap); - nci.groupNumber = 10; - nci.imName = std::string(); - flags3[q]->ourImages.push_back(nci); - } - o+=8; - } - if(flags3[q]->ourImages[o].groupNumber==7) - { - for(int e=0; e<8; ++e) - { - Cimage nci; - nci.bitmap = CSDL_Ext::rotate01(flags3[q]->ourImages[o+e].bitmap); - nci.groupNumber = 11; - nci.imName = std::string(); - flags3[q]->ourImages.push_back(nci); - } - o+=8; - } - if(flags3[q]->ourImages[o].groupNumber==8) - { - for(int e=0; e<8; ++e) - { - Cimage nci; - nci.bitmap = CSDL_Ext::rotate01(flags3[q]->ourImages[o+e].bitmap); - nci.groupNumber = 12; - nci.imName = std::string(); - flags3[q]->ourImages.push_back(nci); - } - o+=8; - } - } - - for(int ff=0; ffourImages.size(); ++ff) - { - SDL_SetColorKey(flags3[q]->ourImages[ff].bitmap, SDL_SRCCOLORKEY, - SDL_MapRGB(flags3[q]->ourImages[ff].bitmap->format, 0, 255, 255) - ); - } - flags3[q]->alphaTransformed = true; - } - - flags4.push_back(CDefHandler::giveDef("AF00.DEF")); //red - flags4.push_back(CDefHandler::giveDef("AF01.DEF")); //blue - flags4.push_back(CDefHandler::giveDef("AF02.DEF")); //tan - flags4.push_back(CDefHandler::giveDef("AF03.DEF")); //green - flags4.push_back(CDefHandler::giveDef("AF04.DEF")); //orange - flags4.push_back(CDefHandler::giveDef("AF05.DEF")); //purple - flags4.push_back(CDefHandler::giveDef("AF06.DEF")); //teal - flags4.push_back(CDefHandler::giveDef("AF07.DEF")); //pink - - - for(int q=0; q<8; ++q) - { - for(int o=0; oourImages.size(); ++o) - { - if(flags4[q]->ourImages[o].groupNumber==6) - { - for(int e=0; e<8; ++e) - { - Cimage nci; - nci.bitmap = CSDL_Ext::rotate01(flags4[q]->ourImages[o+e].bitmap); - nci.groupNumber = 10; - nci.imName = std::string(); - flags4[q]->ourImages.push_back(nci); - } - o+=8; - } - if(flags4[q]->ourImages[o].groupNumber==7) - { - for(int e=0; e<8; ++e) - { - Cimage nci; - nci.bitmap = CSDL_Ext::rotate01(flags4[q]->ourImages[o+e].bitmap); - nci.groupNumber = 10; - nci.groupNumber = 11; - nci.imName = std::string(); - flags4[q]->ourImages.push_back(nci); - } - o+=8; - } - if(flags4[q]->ourImages[o].groupNumber==8) - { - for(int e=0; e<8; ++e) - { - Cimage nci; - nci.bitmap = CSDL_Ext::rotate01(flags4[q]->ourImages[o+e].bitmap); - nci.groupNumber = 10; - nci.groupNumber = 12; - nci.imName = std::string(); - flags4[q]->ourImages.push_back(nci); - } - o+=8; - } - } - - for(int o=0; oourImages.size(); ++o) - { - if(flags4[q]->ourImages[o].groupNumber==1) - { - for(int e=0; e<8; ++e) - { - Cimage nci; - nci.bitmap = CSDL_Ext::rotate01(flags4[q]->ourImages[o+e].bitmap); - nci.groupNumber = 10; - nci.groupNumber = 13; - nci.imName = std::string(); - flags4[q]->ourImages.push_back(nci); - } - o+=8; - } - if(flags4[q]->ourImages[o].groupNumber==2) - { - for(int e=0; e<8; ++e) - { - Cimage nci; - nci.bitmap = CSDL_Ext::rotate01(flags4[q]->ourImages[o+e].bitmap); - nci.groupNumber = 10; - nci.groupNumber = 14; - nci.imName = std::string(); - flags4[q]->ourImages.push_back(nci); - } - o+=8; - } - if(flags4[q]->ourImages[o].groupNumber==3) - { - for(int e=0; e<8; ++e) - { - Cimage nci; - nci.bitmap = CSDL_Ext::rotate01(flags4[q]->ourImages[o+e].bitmap); - nci.groupNumber = 10; - nci.groupNumber = 15; - nci.imName = std::string(); - flags4[q]->ourImages.push_back(nci); - } - o+=8; - } - } - - for(int ff=0; ffourImages.size(); ++ff) - { - SDL_SetColorKey(flags4[q]->ourImages[ff].bitmap, SDL_SRCCOLORKEY, - SDL_MapRGB(flags4[q]->ourImages[ff].bitmap->format, 0, 255, 255) - ); - } - flags4[q]->alphaTransformed = true; - } + using namespace boost::assign; + timeHandler th; + std::vector Graphics::*point; + std::pair Graphics::*, std::vector > pr[4]; + pr[0].first = &Graphics::flags1; + pr[0].second+=("ABF01L.DEF"),("ABF01G.DEF"),("ABF01R.DEF"),("ABF01D.DEF"),("ABF01B.DEF"), + ("ABF01P.DEF"),("ABF01W.DEF"),("ABF01K.DEF"); + pr[1].first = &Graphics::flags2; + pr[1].second+=("ABF02L.DEF"),("ABF02G.DEF"),("ABF02R.DEF"),("ABF02D.DEF"),("ABF02B.DEF"), + ("ABF02P.DEF"),("ABF02W.DEF"),("ABF02K.DEF"); + pr[2].first = &Graphics::flags3; + pr[2].second+=("ABF03L.DEF"),("ABF03G.DEF"),("ABF03R.DEF"),("ABF03D.DEF"),("ABF03B.DEF"), + ("ABF03P.DEF"),("ABF03W.DEF"),("ABF03K.DEF"); + pr[3].first = &Graphics::flags4; + pr[3].second+=("AF00.DEF"),("AF01.DEF"),("AF02.DEF"),("AF03.DEF"),("AF04.DEF"), + ("AF05.DEF"),("AF06.DEF"),("AF07.DEF"); + boost::thread_group grupa; + grupa.create_thread(boost::bind(&Graphics::loadHeroFlags,this,boost::ref(pr[3]),true)); + grupa.create_thread(boost::bind(&Graphics::loadHeroFlags,this,boost::ref(pr[2]),false)); + grupa.create_thread(boost::bind(&Graphics::loadHeroFlags,this,boost::ref(pr[1]),false)); + grupa.create_thread(boost::bind(&Graphics::loadHeroFlags,this,boost::ref(pr[0]),false)); + grupa.join_all(); + std::cout << "Flagi: "< Graphics::*, std::vector > &pr, bool mode); + void loadHeroAnim(std::vector & anims); SDL_Surface * drawHeroInfoWin(const CGHeroInstance * curh); SDL_Surface * drawPrimarySkill(const CGHeroInstance *curh, SDL_Surface *ret, int from=0, int to=PRIMARY_SKILLS); SDL_Surface * drawTownInfoWin(const CGTownInstance * curh); diff --git a/client/VCMI_client.vcproj b/client/VCMI_client.vcproj index b6dc3076f..c2250a898 100644 --- a/client/VCMI_client.vcproj +++ b/client/VCMI_client.vcproj @@ -121,7 +121,7 @@ AdditionalIncludeDirectories="G:\vcmt\repa\include" StringPooling="true" BasicRuntimeChecks="0" - RuntimeLibrary="3" + RuntimeLibrary="2" EnableFunctionLevelLinking="false" WarningLevel="3" DebugInformationFormat="3" diff --git a/hch/CLodHandler.cpp b/hch/CLodHandler.cpp index 89d105e0b..7335484b0 100644 --- a/hch/CLodHandler.cpp +++ b/hch/CLodHandler.cpp @@ -9,6 +9,7 @@ #include "boost/filesystem/operations.hpp" #include #include +#include DLL_EXPORT int readNormalNr (int pos, int bytCon, unsigned char * str) { int ret=0; @@ -34,6 +35,7 @@ unsigned char * CLodHandler::giveFile(std::string defName, int * length) return NULL; } if(length) *length = ourEntry->realSize; + mutex->lock(); fseek(FLOD, ourEntry->offset, 0); unsigned char * outp; if (ourEntry->offset<0) //file is in the sprites/ folder; no compression @@ -44,6 +46,7 @@ unsigned char * CLodHandler::giveFile(std::string defName, int * length) strcat(name,(char*)ourEntry->name); FILE * f = fopen(name,"rb"); int result = fread(outp,1,ourEntry->realSize,f); + mutex->unlock(); if(result<0) {std::cout<<"Error in file reading: "<realSize]; fread((char*)outp, 1, ourEntry->realSize, FLOD); + mutex->unlock(); return outp; } else //we will decompress file { outp = new unsigned char[ourEntry->size]; fread((char*)outp, 1, ourEntry->size, FLOD); - fseek(FLOD, 0, 0); + mutex->unlock(); unsigned char * decomp = NULL; int decRes = infs2(outp, ourEntry->size, ourEntry->realSize, decomp); delete[] outp; @@ -340,6 +344,7 @@ int CLodHandler::readNormalNr (unsigned char* bufor, int bytCon, bool cyclic) void CLodHandler::init(std::string lodFile, std::string dirName) { + mutex = new boost::mutex; std::string Ts; FLOD = fopen(lodFile.c_str(), "rb"); fseek(FLOD, 8, 0); diff --git a/hch/CLodHandler.h b/hch/CLodHandler.h index c61d334b5..e84645e4a 100644 --- a/hch/CLodHandler.h +++ b/hch/CLodHandler.h @@ -9,7 +9,8 @@ struct SDL_Surface; class CDefHandler; class CDefEssential; - +namespace boost +{class mutex;}; namespace NLoadHandlerHelp { const int dmHelp=0, dmNoExtractingMask=1; @@ -44,6 +45,7 @@ public: FILE* FLOD; nodrze entries; unsigned int totalFiles; + boost::mutex *mutex; int readNormalNr (unsigned char* bufor, int bytCon, bool cyclic=false); //lod header reading helper int infs(unsigned char * in, int size, int realSize, std::ofstream & out, int wBits=15); //zlib fast handler diff --git a/hch/CObjectHandler.cpp b/hch/CObjectHandler.cpp index b6d8b3115..18e4733dc 100644 --- a/hch/CObjectHandler.cpp +++ b/hch/CObjectHandler.cpp @@ -326,7 +326,6 @@ CGTownInstance::CGTownInstance() builded=-1; destroyed=-1; garrisonHero=NULL; - //state->owner=-1; town=NULL; visitingHero = NULL; } @@ -335,7 +334,7 @@ CGObjectInstance::CGObjectInstance(): animPhaseShift(rand()%0xff) { //std::cout << "Tworze obiekt "< + +