1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

A little threading and minor changes.

This commit is contained in:
Michał W. Urbańczyk 2008-06-16 10:51:14 +00:00
parent 300d540663
commit d5b0bdcf9e
10 changed files with 263 additions and 408 deletions

50
CMT.cpp
View File

@ -48,6 +48,7 @@
#include "CAdvmapInterface.h"
#include "CCastleInterface.h"
#include "client\Graphics.h"
#include <boost/lambda/lambda.hpp>
#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__)
# include <fcntl.h>
# include <io.h>
@ -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<SDL_Surface*> 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
screen = SDL_SetVideoMode(800,600,24,SDL_SWSURFACE|SDL_DOUBLEBUF/*|SDL_FULLSCREEN*/); //initializing important global surface
THC std::cout<<"\tInitializing screen: "<<pomtime.getDif()<<std::endl;
SDL_WM_SetCaption(NAME,""); //set window title
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
int rmask = 0xff000000;
int gmask = 0x00ff0000;
int bmask = 0x0000ff00;
int amask = 0x000000ff;
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;
int rmask = 0x000000ff; int gmask = 0x0000ff00; int bmask = 0x00ff0000; int amask = 0xff000000;
#endif
CSDL_Ext::std32bppSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, 1, 1, 32, rmask, gmask, bmask, amask);
CPG=NULL;
THC std::cout<<"\tInitializing minors: "<<pomtime.getDif()<<std::endl;
TTF_Init();
atexit(TTF_Quit);
atexit(SDL_Quit);
TNRB16 = TTF_OpenFont("Fonts\\tnrb.ttf",16);
GEOR13 = TTF_OpenFont("Fonts\\georgia.ttf",13);
GEOR16 = TTF_OpenFont("Fonts\\georgia.ttf",16);
GEORXX = TTF_OpenFont("Fonts\\tnrb.ttf",22);
GEORM = TTF_OpenFont("Fonts\\georgia.ttf",10);
atexit(TTF_Quit);
THC std::cout<<"\tInitializing fonts: "<<pomtime.getDif()<<std::endl;
CMusicHandler * mush = new CMusicHandler; //initializing audio
mush->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: "<<pomtime.getDif()<<std::endl;
THC std::cout<<"Initializing screen, fonts and sound handling: "<<tmh.getDif()<<std::endl;
CDefHandler::Spriteh = cgi->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: "<<pomtime.getDif()<<std::endl;
THC std::cout<<"Preparing first handlers: "<<tmh.getDif()<<std::endl;
pomtime.getDif();
graphics = new Graphics();
THC std::cout<<"\tMain graphics: "<<tmh.getDif()<<std::endl;
std::vector<CDefHandler **> animacje;
for(std::vector<CHeroClass *>::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: "<<tmh.getDif()<<std::endl;
THC std::cout<<"Initializing game graphics: "<<tmh.getDif()<<std::endl;
//colors initialization

Binary file not shown.

View File

@ -203,6 +203,7 @@ public:
void moveByOne(bool up);
void printSelectedInfo();
void printFlags();
void processMaps(std::vector<std::string> &pliczkiTemp, int &index);
MapSel();
~MapSel();
};

View File

@ -2,7 +2,13 @@
#include "Graphics.h"
#include "../hch/CDefHandler.h"
#include "../hch/CObjectHandler.h"
//#include "../hch/CHeroHandler.h"
#include "../SDL_Extensions.h"
#include <boost/assign/std/vector.hpp>
#include <sstream>
#include <iomanip>
#include <boost/thread.hpp>
#include <boost/bind.hpp>
using namespace CSDL_Ext;
Graphics * graphics = NULL;
SDL_Surface * Graphics::drawPrimarySkill(const CGHeroInstance *curh, SDL_Surface *ret, int from, int to)
@ -157,329 +163,146 @@ Graphics::Graphics()
smallIcons = CDefHandler::giveDef("ITPA.DEF");
resources32 = CDefHandler::giveDef("RESOURCE.DEF");
loadHeroFlags();
//std::stringstream nm;
//nm<<"AH";
//nm<<std::setw(2);
//nm<<std::setfill('0');
//nm<<heroClasses.size();
//nm<<"_.DEF";
//hc->moveAnim = CDefHandler::giveDef(nm.str());
//for(int o=0; o<hc->moveAnim->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; o<hc->moveAnim->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; ff<hc->moveAnim->ourImages.size(); ++ff)
//{
// CSDL_Ext::alphaTransform(hc->moveAnim->ourImages[ff].bitmap);
//}
//hc->moveAnim->alphaTransformed = true;
}
void Graphics::loadHeroFlags()
void Graphics::loadHeroAnim(std::vector<CDefHandler **> & anims)
{
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 i=0; i<anims.size();i++)
{
std::stringstream nm;
nm<<"AH";
nm<<std::setw(2);
nm<<std::setfill('0');
nm<<i;
nm<<"_.DEF";
std::string name = nm.str();
(*anims[i]) = CDefHandler::giveDef(name);
//(CDefHandler*)(((void*)hc)+((void*)moveAnim)) = CDefHandler::giveDef(name);
for(int o=0; o<(*anims[i])->ourImages.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<std::vector<CDefHandler *> Graphics::*, std::vector<const char *> > &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<flags1[q]->ourImages.size(); ++o)
for(int o=0; o<(this->*pr.first)[q]->ourImages.size(); ++o)
{
if(flags1[q]->ourImages[o].groupNumber==6)
if((this->*pr.first)[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.bitmap = CSDL_Ext::rotate01((this->*pr.first)[q]->ourImages[o+e].bitmap);
nci.groupNumber = 10;
nci.imName = std::string();
flags1[q]->ourImages.push_back(nci);
(this->*pr.first)[q]->ourImages.push_back(nci);
}
o+=8;
}
if(flags1[q]->ourImages[o].groupNumber==7)
if((this->*pr.first)[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.bitmap = CSDL_Ext::rotate01((this->*pr.first)[q]->ourImages[o+e].bitmap);
nci.groupNumber = 11;
nci.imName = std::string();
flags1[q]->ourImages.push_back(nci);
(this->*pr.first)[q]->ourImages.push_back(nci);
}
o+=8;
}
if(flags1[q]->ourImages[o].groupNumber==8)
if((this->*pr.first)[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.bitmap = CSDL_Ext::rotate01((this->*pr.first)[q]->ourImages[o+e].bitmap);
nci.groupNumber = 12;
nci.imName = std::string();
flags1[q]->ourImages.push_back(nci);
(this->*pr.first)[q]->ourImages.push_back(nci);
}
o+=8;
}
}
for(int ff=0; ff<flags1[q]->ourImages.size(); ++ff)
if (mode)
{
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; o<flags2[q]->ourImages.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; ff<flags2[q]->ourImages.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; o<flags3[q]->ourImages.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; ff<flags3[q]->ourImages.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; o<flags4[q]->ourImages.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; o<flags4[q]->ourImages.size(); ++o)
{
if(flags4[q]->ourImages[o].groupNumber==1)
@ -488,7 +311,6 @@ void Graphics::loadHeroFlags()
{
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);
@ -501,7 +323,6 @@ void Graphics::loadHeroFlags()
{
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);
@ -514,7 +335,6 @@ void Graphics::loadHeroFlags()
{
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);
@ -522,16 +342,43 @@ void Graphics::loadHeroFlags()
o+=8;
}
}
for(int ff=0; ff<flags4[q]->ourImages.size(); ++ff)
}
for(int ff=0; ff<(this->*pr.first)[q]->ourImages.size(); ++ff)
{
SDL_SetColorKey(flags4[q]->ourImages[ff].bitmap, SDL_SRCCOLORKEY,
SDL_MapRGB(flags4[q]->ourImages[ff].bitmap->format, 0, 255, 255)
SDL_SetColorKey((this->*pr.first)[q]->ourImages[ff].bitmap, SDL_SRCCOLORKEY,
SDL_MapRGB((this->*pr.first)[q]->ourImages[ff].bitmap->format, 0, 255, 255)
);
}
flags4[q]->alphaTransformed = true;
(this->*pr.first)[q]->alphaTransformed = true;
}
}
void Graphics::loadHeroFlags()
{
using namespace boost::assign;
timeHandler th;
std::vector<CDefHandler *> Graphics::*point;
std::pair<std::vector<CDefHandler *> Graphics::*, std::vector<const char *> > 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: "<<th.getDif()<<std::endl;
}
SDL_Surface * Graphics::getPic(int ID, bool fort, bool builded)
{
if (ID==-1)

View File

@ -5,6 +5,7 @@ struct SDL_Surface;
class CGHeroInstance;
class CGTownInstance;
class CDefHandler;
class CHeroClass;
class Graphics
{
public:
@ -31,6 +32,8 @@ public:
//functions
Graphics();
void loadHeroFlags();
void loadHeroFlags(std::pair<std::vector<CDefHandler *> Graphics::*, std::vector<const char *> > &pr, bool mode);
void loadHeroAnim(std::vector<CDefHandler **> & 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);

View File

@ -121,7 +121,7 @@
AdditionalIncludeDirectories="G:\vcmt\repa\include"
StringPooling="true"
BasicRuntimeChecks="0"
RuntimeLibrary="3"
RuntimeLibrary="2"
EnableFunctionLevelLinking="false"
WarningLevel="3"
DebugInformationFormat="3"

View File

@ -9,6 +9,7 @@
#include "boost/filesystem/operations.hpp"
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/thread.hpp>
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: "<<name<<std::endl;delete[] outp; return NULL;}
else
return outp;
@ -52,13 +55,14 @@ unsigned char * CLodHandler::giveFile(std::string defName, int * length)
{
outp = new unsigned char[ourEntry->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);

View File

@ -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<Entry> 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

View File

@ -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 "<<this<<std::endl;
//state = new CLuaObjectScript();
//state = NULL;
state = NULL;
tempOwner = 254;
blockVisit = false;
}

View File

@ -121,7 +121,7 @@
StringPooling="true"
MinimalRebuild="false"
BasicRuntimeChecks="0"
RuntimeLibrary="3"
RuntimeLibrary="2"
EnableFunctionLevelLinking="false"
WarningLevel="3"
DebugInformationFormat="3"
@ -367,6 +367,10 @@
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath="..\hch\CArtHandler.h"
>
</File>
<File
RelativePath="..\hch\CCreatureHandler.h"
>