mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
* fixes for MSVC (it needs to have global variables from library explicitly exported)
* renamed logging variables to tlogX ('_' in var names looks ugly) * cleaned it improved setting formations * fixed crashbug on maps with random hero
This commit is contained in:
parent
a1dd7f22f9
commit
856698bd80
@ -186,7 +186,8 @@ void CHighlightableButton::clickLeft( tribool down )
|
||||
if (pressedL && (down==false))
|
||||
{
|
||||
pressedL=state;
|
||||
select(!selected);
|
||||
if(!onlyOn || !selected)
|
||||
select(!selected);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -196,6 +197,7 @@ void CHighlightableButton::clickLeft( tribool down )
|
||||
|
||||
CHighlightableButton::CHighlightableButton( const CFunctionList<void()> &onSelect, const CFunctionList<void()> &onDeselect, const std::map<int,std::string> &Name, const std::string &HelpBox, bool playerColoredButton, const std::string &defName, std::vector<std::string> * add, int x, int y, bool activ )
|
||||
{
|
||||
onlyOn = false;
|
||||
init(onSelect,Name,HelpBox,playerColoredButton,defName,add,x,y,activ);
|
||||
callback2 = onDeselect;
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ class CHighlightableButton
|
||||
{
|
||||
public:
|
||||
CHighlightableButton(const CFunctionList<void()> &onSelect, const CFunctionList<void()> &onDeselect, const std::map<int,std::string> &Name, const std::string &HelpBox, bool playerColoredButton, const std::string &defName, std::vector<std::string> * add, int x, int y, bool activ );
|
||||
bool selected;
|
||||
bool selected, onlyOn;
|
||||
CFunctionList<void()> callback2; //when disselecting
|
||||
void select(bool on);
|
||||
void clickLeft (tribool down);
|
||||
|
@ -588,8 +588,8 @@ void CCallback::trade( int mode, int id1, int id2, int val1 )
|
||||
*cl->serv << ui16(511) << ui8(player) << ui32(mode) << ui32(id1) << ui32(id2) << ui32(val1);
|
||||
}
|
||||
|
||||
void CCallback::setFormation(const CGHeroInstance * hero, bool loose)
|
||||
void CCallback::setFormation(const CGHeroInstance * hero, bool tight)
|
||||
{
|
||||
hero->looseFormation = loose;
|
||||
*cl->serv << ui16(512) << hero->id << ui8(loose);
|
||||
const_cast<CGHeroInstance*>(hero)->army.formation = tight;
|
||||
*cl->serv << ui16(512) << hero->id << ui8(tight);
|
||||
}
|
@ -42,7 +42,7 @@ public:
|
||||
virtual void swapGarrisonHero(const CGTownInstance *town)=0;
|
||||
virtual void buyArtifact(const CGHeroInstance *hero, int aid)=0; //used to buy artifacts in towns (including spell book in the guild and war machines in blacksmith)
|
||||
virtual void trade(int mode, int id1, int id2, int val1)=0; //mode==0: sell val1 units of id1 resource for id2 resiurce
|
||||
virtual void setFormation(const CGHeroInstance * hero, bool loose)=0;
|
||||
virtual void setFormation(const CGHeroInstance * hero, bool tight)=0;
|
||||
|
||||
//get info
|
||||
virtual bool verifyPath(CPath * path, bool blockSea)=0;
|
||||
@ -122,7 +122,7 @@ public:
|
||||
void swapGarrisonHero(const CGTownInstance *town);
|
||||
void buyArtifact(const CGHeroInstance *hero, int aid);
|
||||
void trade(int mode, int id1, int id2, int val1);
|
||||
void setFormation(const CGHeroInstance * hero, bool loose);
|
||||
void setFormation(const CGHeroInstance * hero, bool tight);
|
||||
|
||||
//get info
|
||||
bool verifyPath(CPath * path, bool blockSea);
|
||||
|
@ -121,7 +121,7 @@ void CConsoleHandler::killConsole(pthread_t hThread)
|
||||
void CConsoleHandler::killConsole(void *hThread)
|
||||
#endif
|
||||
{
|
||||
_log3 << "Killing console... ";
|
||||
tlog3 << "Killing console... ";
|
||||
_kill_thread(hThread,0);
|
||||
_log3 << "done!\n";
|
||||
tlog3 << "done!\n";
|
||||
}
|
||||
|
@ -50,6 +50,8 @@ CHeroWindow::CHeroWindow(int playerColor):
|
||||
|
||||
gar1button = new CHighlightableButton(0,0,map_list_of(0,CGI->generaltexth->heroscrn[23]), CGI->generaltexth->heroscrn[29], false, "hsbtns6.def" , NULL,546, 491, false);
|
||||
gar3button = new CHighlightableButton(0,0,map_list_of(0,CGI->generaltexth->heroscrn[24]), CGI->generaltexth->heroscrn[30], false, "hsbtns7.def", NULL, 546, 527, false);
|
||||
gar1button->onlyOn = gar3button->onlyOn = true;
|
||||
|
||||
gar2button = new CHighlightableButton(0, 0, map_list_of(0,CGI->generaltexth->heroscrn[26])(3,CGI->generaltexth->heroscrn[25]), CGI->generaltexth->heroscrn[31], false, "hsbtns8.def", NULL, 604, 491, false);
|
||||
gar4button = new AdventureMapButton(CGI->generaltexth->allTexts[256], CGI->generaltexth->heroscrn[32], boost::function<void()>(), 604, 527, "hsbtns9.def", false, NULL, false);
|
||||
boost::algorithm::replace_first(gar4button->hoverTexts[0],"%s",CGI->generaltexth->allTexts[43]);
|
||||
@ -311,17 +313,15 @@ void CHeroWindow::setHero(const CGHeroInstance *Hero)
|
||||
gar2button->callback2 = vstd::assigno(hero->tacticFormationEnabled,false);
|
||||
}
|
||||
gar1button->callback.clear();
|
||||
gar1button->callback = vstd::assigno(hero->looseFormation,true);
|
||||
gar1button->callback += boost::bind(&CHighlightableButton::select, gar3button, false);
|
||||
gar1button->callback += boost::bind(&CCallback::setFormation, LOCPLINT->cb, Hero, true);
|
||||
gar1button->callback += boost::bind(&CCallback::setFormation, LOCPLINT->cb, Hero, false);
|
||||
gar3button->callback.clear();
|
||||
gar3button->callback = vstd::assigno(hero->looseFormation,false);
|
||||
gar3button->callback += boost::bind(&CHighlightableButton::select, gar1button, false);
|
||||
gar3button->callback += boost::bind(&CCallback::setFormation, LOCPLINT->cb, Hero, false);
|
||||
if(hero->looseFormation)
|
||||
gar1button->select(true);
|
||||
else
|
||||
gar3button->callback += boost::bind(&CCallback::setFormation, LOCPLINT->cb, Hero, true);
|
||||
if(hero->army.formation)
|
||||
gar3button->select(true);
|
||||
else
|
||||
gar1button->select(true);
|
||||
redrawCurBack();
|
||||
}
|
||||
|
||||
|
78
CMT.cpp
78
CMT.cpp
@ -51,14 +51,6 @@ extern SDL_Surface * CSDL_Ext::std32bppSurface;
|
||||
std::queue<SDL_Event> events;
|
||||
boost::mutex eventsM;
|
||||
TTF_Font * TNRB16, *TNR, *GEOR13, *GEORXX, *GEORM, *GEOR16;
|
||||
extern CLogger<0> _log0;
|
||||
extern CLogger<1> _log1;
|
||||
extern CLogger<2> _log2;
|
||||
extern CLogger<3> _log3;
|
||||
extern CLogger<4> _log4;
|
||||
extern CLogger<5> _log5;
|
||||
extern CConsoleHandler *console;// = NULL;
|
||||
extern std::ostream *logfile;// = NULL;
|
||||
namespace intpr = boost::interprocess;
|
||||
void processCommand(const std::string &message);
|
||||
#ifndef __GNUC__
|
||||
@ -79,7 +71,7 @@ int main(int argc, char** argv)
|
||||
*::console->cb = &processCommand;
|
||||
console = new boost::thread(boost::bind(&CConsoleHandler::run,::console));
|
||||
}
|
||||
_log0 << "\tConsole and logifle ready!" << std::endl;
|
||||
tlog0 << "\tConsole and logifle ready!" << std::endl;
|
||||
int port;
|
||||
if(argc > 1)
|
||||
{
|
||||
@ -92,10 +84,10 @@ int main(int argc, char** argv)
|
||||
else
|
||||
{
|
||||
port = 3030;
|
||||
_log0 << "Port " << port << " will be used." << std::endl;
|
||||
tlog0 << "Port " << port << " will be used." << std::endl;
|
||||
}
|
||||
std::cout.flags(ios::unitbuf);
|
||||
_log0 << NAME << std::endl;
|
||||
tlog0 << NAME << std::endl;
|
||||
srand ( time(NULL) );
|
||||
CPG=NULL;
|
||||
atexit(SDL_Quit);
|
||||
@ -104,13 +96,13 @@ int main(int argc, char** argv)
|
||||
//luatest.test();
|
||||
//CBIKHandler cb;
|
||||
//cb.open("CSECRET.BIK");
|
||||
_log0 << "Starting... " << std::endl;
|
||||
tlog0 << "Starting... " << std::endl;
|
||||
THC timeHandler tmh, total, pomtime;
|
||||
if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_AUDIO)==0)
|
||||
{
|
||||
screen = SDL_SetVideoMode(800,600,24,SDL_SWSURFACE|SDL_DOUBLEBUF/*|SDL_FULLSCREEN*/); //initializing important global surface
|
||||
_log0 <<"\tInitializing screen: "<<pomtime.getDif();
|
||||
_log0 << std::endl;
|
||||
tlog0 <<"\tInitializing screen: "<<pomtime.getDif();
|
||||
tlog0 << std::endl;
|
||||
SDL_WM_SetCaption(NAME.c_str(),""); //set window title
|
||||
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
||||
int rmask = 0xff000000;int gmask = 0x00ff0000;int bmask = 0x0000ff00;int amask = 0x000000ff;
|
||||
@ -118,7 +110,7 @@ int main(int argc, char** argv)
|
||||
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);
|
||||
_log0 << "\tInitializing minors: " << pomtime.getDif() << std::endl;
|
||||
tlog0 << "\tInitializing minors: " << pomtime.getDif() << std::endl;
|
||||
TTF_Init();
|
||||
TNRB16 = TTF_OpenFont("Fonts" PATHSEPARATOR "tnrb.ttf",16);
|
||||
GEOR13 = TTF_OpenFont("Fonts" PATHSEPARATOR "georgia.ttf",13);
|
||||
@ -126,18 +118,18 @@ int main(int argc, char** argv)
|
||||
GEORXX = TTF_OpenFont("Fonts" PATHSEPARATOR "tnrb.ttf",22);
|
||||
GEORM = TTF_OpenFont("Fonts" PATHSEPARATOR "georgia.ttf",10);
|
||||
atexit(TTF_Quit);
|
||||
THC _log0<<"\tInitializing fonts: "<<pomtime.getDif()<<std::endl;
|
||||
THC tlog0<<"\tInitializing fonts: "<<pomtime.getDif()<<std::endl;
|
||||
CMusicHandler * mush = new CMusicHandler; //initializing audio
|
||||
mush->initMusics();
|
||||
//audio initialized
|
||||
cgi->mush = mush;
|
||||
THC _log0<<"\tInitializing sound: "<<pomtime.getDif()<<std::endl;
|
||||
THC _log0<<"Initializing screen, fonts and sound handling: "<<tmh.getDif()<<std::endl;
|
||||
THC tlog0<<"\tInitializing sound: "<<pomtime.getDif()<<std::endl;
|
||||
THC tlog0<<"Initializing screen, fonts and sound handling: "<<tmh.getDif()<<std::endl;
|
||||
CDefHandler::Spriteh = cgi->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");
|
||||
THC _log0<<"Loading .lod files: "<<tmh.getDif()<<std::endl;
|
||||
THC tlog0<<"Loading .lod files: "<<tmh.getDif()<<std::endl;
|
||||
initDLL(cgi->bitmaph,::console,logfile);
|
||||
CGI->arth = VLC->arth;
|
||||
CGI->creh = VLC->creh;
|
||||
@ -147,7 +139,7 @@ int main(int argc, char** argv)
|
||||
CGI->spellh = VLC->spellh;
|
||||
CGI->dobjinfo = VLC->dobjinfo;
|
||||
CGI->buildh = VLC->buildh;
|
||||
_log0<<"Initializing VCMI_Lib: "<<tmh.getDif()<<std::endl;
|
||||
tlog0<<"Initializing VCMI_Lib: "<<tmh.getDif()<<std::endl;
|
||||
//cgi->curh->initCursor();
|
||||
//cgi->curh->showGraphicCursor();
|
||||
pomtime.getDif();
|
||||
@ -155,28 +147,28 @@ int main(int argc, char** argv)
|
||||
cgi->curh->initCursor();
|
||||
//cgi->screenh = new CScreenHandler;
|
||||
//cgi->screenh->initScreen();
|
||||
_log0<<"\tScreen handler: "<<pomtime.getDif()<<std::endl;
|
||||
tlog0<<"\tScreen handler: "<<pomtime.getDif()<<std::endl;
|
||||
CAbilityHandler * abilh = new CAbilityHandler;
|
||||
abilh->loadAbilities();
|
||||
cgi->abilh = abilh;
|
||||
_log0<<"\tAbility handler: "<<pomtime.getDif()<<std::endl;
|
||||
_log0<<"Preparing first handlers: "<<tmh.getDif()<<std::endl;
|
||||
tlog0<<"\tAbility handler: "<<pomtime.getDif()<<std::endl;
|
||||
tlog0<<"Preparing first handlers: "<<tmh.getDif()<<std::endl;
|
||||
pomtime.getDif();
|
||||
graphics = new Graphics();
|
||||
_log0<<"\tMain graphics: "<<tmh.getDif()<<std::endl;
|
||||
tlog0<<"\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);
|
||||
_log0<<"\tHero animations: "<<tmh.getDif()<<std::endl;
|
||||
_log0<<"Initializing game graphics: "<<tmh.getDif()<<std::endl;
|
||||
tlog0<<"\tHero animations: "<<tmh.getDif()<<std::endl;
|
||||
tlog0<<"Initializing game graphics: "<<tmh.getDif()<<std::endl;
|
||||
CMessage::init();
|
||||
cgi->generaltexth = new CGeneralTextHandler;
|
||||
cgi->generaltexth->load();
|
||||
_log0<<"Preparing more handlers: "<<tmh.getDif()<<std::endl;
|
||||
tlog0<<"Preparing more handlers: "<<tmh.getDif()<<std::endl;
|
||||
CPreGame * cpg = new CPreGame(); //main menu and submenus
|
||||
_log0<<"Initialization CPreGame (together): "<<tmh.getDif()<<std::endl;
|
||||
_log0<<"Initialization of VCMI (togeter): "<<total.getDif()<<std::endl;
|
||||
tlog0<<"Initialization CPreGame (together): "<<tmh.getDif()<<std::endl;
|
||||
tlog0<<"Initialization of VCMI (togeter): "<<total.getDif()<<std::endl;
|
||||
cpg->mush = mush;
|
||||
|
||||
StartInfo *options = new StartInfo(cpg->runLoop());
|
||||
@ -189,17 +181,17 @@ int main(int argc, char** argv)
|
||||
ServerReady *sr = new(mr.get_address())ServerReady();
|
||||
std::string comm = std::string(SERVER_NAME) + " " + portc + " > server_log.txt";
|
||||
boost::thread servthr(boost::bind(system,comm.c_str())); //runs server executable; //TODO: will it work on non-windows platforms?
|
||||
_log0<<"Preparing shared memory and starting server: "<<tmh.getDif()<<std::endl;
|
||||
tlog0<<"Preparing shared memory and starting server: "<<tmh.getDif()<<std::endl;
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
tmh.getDif();pomtime.getDif();//reset timers
|
||||
cgi->pathf = new CPathfinder();
|
||||
_log0<<"\tPathfinder: "<<pomtime.getDif()<<std::endl;
|
||||
_log0<<"Handlers initialization (together): "<<tmh.getDif()<<std::endl;
|
||||
tlog0<<"\tPathfinder: "<<pomtime.getDif()<<std::endl;
|
||||
tlog0<<"Handlers initialization (together): "<<tmh.getDif()<<std::endl;
|
||||
std::ofstream lll("client_log.txt");
|
||||
|
||||
CConnection *c=NULL;
|
||||
//wait until server is ready
|
||||
_log0<<"Waiting for server... ";
|
||||
tlog0<<"Waiting for server... ";
|
||||
{
|
||||
intpr::scoped_lock<intpr::interprocess_mutex> slock(sr->mutex);
|
||||
while(!sr->ready)
|
||||
@ -208,21 +200,21 @@ int main(int argc, char** argv)
|
||||
}
|
||||
}
|
||||
intpr::shared_memory_object::remove("vcmi_memory");
|
||||
_log0 << tmh.getDif()<<std::endl;
|
||||
tlog0 << tmh.getDif()<<std::endl;
|
||||
while(!c)
|
||||
{
|
||||
try
|
||||
{
|
||||
_log0 << "Establishing connection...\n";
|
||||
tlog0 << "Establishing connection...\n";
|
||||
c = new CConnection("127.0.0.1",portc,NAME,lll);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
_log1 << "\nCannot establish connection! Retrying within 2 seconds" <<std::endl;
|
||||
tlog1 << "\nCannot establish connection! Retrying within 2 seconds" <<std::endl;
|
||||
SDL_Delay(2000);
|
||||
}
|
||||
}
|
||||
THC _log0<<"\tConnecting to the server: "<<tmh.getDif()<<std::endl;
|
||||
THC tlog0<<"\tConnecting to the server: "<<tmh.getDif()<<std::endl;
|
||||
CClient cl(c,options);
|
||||
boost::thread t(boost::bind(&CClient::run,&cl));
|
||||
SDL_Event ev;
|
||||
@ -236,7 +228,7 @@ int main(int argc, char** argv)
|
||||
::console->killConsole(console->native_handle());
|
||||
#endif
|
||||
SDL_Delay(750);
|
||||
_log0 << "Ending...\n";
|
||||
tlog0 << "Ending...\n";
|
||||
exit(0);
|
||||
}
|
||||
eventsM.lock();
|
||||
@ -246,7 +238,7 @@ int main(int argc, char** argv)
|
||||
}
|
||||
else
|
||||
{
|
||||
_log1<<"Something was wrong: "<<SDL_GetError()<<std::endl;
|
||||
tlog1<<"Something was wrong: "<<SDL_GetError()<<std::endl;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -284,10 +276,10 @@ void processCommand(const std::string &message)
|
||||
else if(message=="get txt")
|
||||
{
|
||||
boost::filesystem::create_directory("Extracted_txts");
|
||||
_log0<<"Command accepted. Opening .lod file...\t";
|
||||
tlog0<<"Command accepted. Opening .lod file...\t";
|
||||
CLodHandler * txth = new CLodHandler;
|
||||
txth->init(std::string(DATA_DIR "Data" PATHSEPARATOR "H3bitmap.lod"),"data");
|
||||
_log0<<"done.\nScanning .lod file\n";
|
||||
tlog0<<"done.\nScanning .lod file\n";
|
||||
int curp=0;
|
||||
std::string pattern = ".TXT";
|
||||
for(int i=0;i<txth->entries.size(); i++)
|
||||
@ -302,9 +294,9 @@ void processCommand(const std::string &message)
|
||||
if(p2!=curp)
|
||||
{
|
||||
curp = p2;
|
||||
_log0<<"\r"<<curp<<"%";
|
||||
tlog0<<"\r"<<curp<<"%";
|
||||
}
|
||||
}
|
||||
_log0<<"\rExtracting done :)\n";
|
||||
tlog0<<"\rExtracting done :)\n";
|
||||
}
|
||||
}
|
||||
|
14
CPreGame.cpp
14
CPreGame.cpp
@ -1009,7 +1009,7 @@ void MapSel::processMaps(std::vector<std::string> &pliczkiTemp, int &index)
|
||||
else break;
|
||||
}
|
||||
gzclose(tempf);
|
||||
if(iii<50) {_log3<<"\t\tWarning: corrupted map file: "<<pliczkiTemp[pom]<<std::endl; continue;}
|
||||
if(iii<50) {tlog3<<"\t\tWarning: corrupted map file: "<<pliczkiTemp[pom]<<std::endl; continue;}
|
||||
if (!sss[4]) continue; //nie ma graczy? mapa niegrywalna //ju¿ to kiedyœ komentowa³em- - to bzdura //tu calkiem pasuje...
|
||||
CMapInfo mi(pliczkiTemp[pom],sss);
|
||||
mx.lock();
|
||||
@ -1393,19 +1393,19 @@ CPreGame::CPreGame()
|
||||
preth = new CPreGameTextHandler;
|
||||
preth->loadTexts();
|
||||
CGI->preth=preth;
|
||||
_log0<<"\tCPreGame: loading txts: "<<tmh.getDif()<<std::endl;
|
||||
tlog0<<"\tCPreGame: loading txts: "<<tmh.getDif()<<std::endl;
|
||||
currentMessage=NULL;
|
||||
behindCurMes=NULL;
|
||||
initMainMenu();
|
||||
_log0<<"\tCPreGame: main menu initialization: "<<tmh.getDif()<<std::endl;
|
||||
tlog0<<"\tCPreGame: main menu initialization: "<<tmh.getDif()<<std::endl;
|
||||
initNewMenu();
|
||||
_log0<<"\tCPreGame: newgame menu initialization: "<<tmh.getDif()<<std::endl;
|
||||
tlog0<<"\tCPreGame: newgame menu initialization: "<<tmh.getDif()<<std::endl;
|
||||
initScenSel();
|
||||
_log0<<"\tCPreGame: scenario choice initialization: "<<tmh.getDif()<<std::endl;
|
||||
tlog0<<"\tCPreGame: scenario choice initialization: "<<tmh.getDif()<<std::endl;
|
||||
initOptions();
|
||||
_log0<<"\tCPreGame: scenario options initialization: "<<tmh.getDif()<<std::endl;
|
||||
tlog0<<"\tCPreGame: scenario options initialization: "<<tmh.getDif()<<std::endl;
|
||||
showMainMenu();
|
||||
_log0<<"\tCPreGame: displaying main menu: "<<tmh.getDif()<<std::endl;
|
||||
tlog0<<"\tCPreGame: displaying main menu: "<<tmh.getDif()<<std::endl;
|
||||
CPG=this;
|
||||
playerName="Player";
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ CClient::CClient(CConnection *con, StartInfo *si)
|
||||
{
|
||||
timeHandler tmh;
|
||||
CGI->state = new CGameState();
|
||||
_log0 <<"\tGamestate: "<<tmh.getDif()<<std::endl;
|
||||
tlog0 <<"\tGamestate: "<<tmh.getDif()<<std::endl;
|
||||
CConnection &c(*con);
|
||||
////////////////////////////////////////////////////
|
||||
ui8 pom8;
|
||||
@ -116,34 +116,34 @@ CClient::CClient(CConnection *con, StartInfo *si)
|
||||
ui32 seed, sum;
|
||||
std::string mapname;
|
||||
c >> mapname >> sum >> seed;
|
||||
_log0 <<"\tSending/Getting info to/from the server: "<<tmh.getDif()<<std::endl;
|
||||
tlog0 <<"\tSending/Getting info to/from the server: "<<tmh.getDif()<<std::endl;
|
||||
|
||||
Mapa * mapa = new Mapa(mapname);
|
||||
_log0 <<"Reading and detecting map file (together): "<<tmh.getDif()<<std::endl;
|
||||
_log0 << "\tServer checksum for "<<mapname <<": "<<sum << std::endl;
|
||||
_log0 << "\tOur checksum for the map: "<< mapa->checksum << std::endl;
|
||||
tlog0 <<"Reading and detecting map file (together): "<<tmh.getDif()<<std::endl;
|
||||
tlog0 << "\tServer checksum for "<<mapname <<": "<<sum << std::endl;
|
||||
tlog0 << "\tOur checksum for the map: "<< mapa->checksum << std::endl;
|
||||
|
||||
if(mapa->checksum != sum)
|
||||
{
|
||||
_log1 << "Wrong map checksum!!!" << std::endl;
|
||||
tlog1 << "Wrong map checksum!!!" << std::endl;
|
||||
#ifndef __GNUC__
|
||||
throw std::exception("Wrong checksum");
|
||||
#else
|
||||
throw std::exception();
|
||||
#endif
|
||||
}
|
||||
_log0 << "\tUsing random seed: "<<seed << std::endl;
|
||||
tlog0 << "\tUsing random seed: "<<seed << std::endl;
|
||||
|
||||
gs = CGI->state;
|
||||
gs->scenarioOps = si;
|
||||
gs->init(si,mapa,seed);
|
||||
|
||||
CGI->mh = new CMapHandler();
|
||||
_log0 <<"Initializing GameState (together): "<<tmh.getDif()<<std::endl;
|
||||
tlog0 <<"Initializing GameState (together): "<<tmh.getDif()<<std::endl;
|
||||
CGI->mh->map = mapa;
|
||||
_log0 <<"Creating mapHandler: "<<tmh.getDif()<<std::endl;
|
||||
tlog0 <<"Creating mapHandler: "<<tmh.getDif()<<std::endl;
|
||||
CGI->mh->init();
|
||||
_log0 <<"Initializing mapHandler (together): "<<tmh.getDif()<<std::endl;
|
||||
tlog0 <<"Initializing mapHandler (together): "<<tmh.getDif()<<std::endl;
|
||||
|
||||
for (int i=0; i<CGI->state->scenarioOps->playerInfos.size();i++) //initializing interfaces
|
||||
{
|
||||
@ -173,7 +173,7 @@ void CClient::process(int what)
|
||||
{
|
||||
ui8 player;
|
||||
*serv >> player;//who?
|
||||
_log5 << "It's turn of "<<(unsigned)player<<" player."<<std::endl;
|
||||
tlog5 << "It's turn of "<<(unsigned)player<<" player."<<std::endl;
|
||||
boost::thread(boost::bind(&CGameInterface::yourTurn,playerint[player]));
|
||||
break;
|
||||
}
|
||||
@ -181,16 +181,16 @@ void CClient::process(int what)
|
||||
{
|
||||
NewTurn n;
|
||||
*serv >> n;
|
||||
_log5 << "New day: "<<(unsigned)n.day<<". Applying changes... ";
|
||||
tlog5 << "New day: "<<(unsigned)n.day<<". Applying changes... ";
|
||||
gs->apply(&n);
|
||||
_log5 << "done!"<<std::endl;
|
||||
tlog5 << "done!"<<std::endl;
|
||||
break;
|
||||
}
|
||||
case 102: //set resource amount
|
||||
{
|
||||
SetResource sr;
|
||||
*serv >> sr;
|
||||
_log5 << "Set amount of "<<CGI->objh->restypes[sr.resid]
|
||||
tlog5 << "Set amount of "<<CGI->objh->restypes[sr.resid]
|
||||
<< " of player "<<(unsigned)sr.player <<" to "<<sr.val<<std::endl;
|
||||
gs->apply(&sr);
|
||||
playerint[sr.player]->receivedResource(sr.resid,sr.val);
|
||||
@ -211,7 +211,7 @@ void CClient::process(int what)
|
||||
{
|
||||
SetResources sr;
|
||||
*serv >> sr;
|
||||
_log5 << "Set amount of resources of player "<<(unsigned)sr.player<<std::endl;
|
||||
tlog5 << "Set amount of resources of player "<<(unsigned)sr.player<<std::endl;
|
||||
gs->apply(&sr);
|
||||
playerint[sr.player]->receivedResource(-1,-1);
|
||||
break;
|
||||
@ -220,7 +220,7 @@ void CClient::process(int what)
|
||||
{
|
||||
SetPrimSkill sps;
|
||||
*serv >> sps;
|
||||
_log5 << "Changing hero primary skill"<<std::endl;
|
||||
tlog5 << "Changing hero primary skill"<<std::endl;
|
||||
gs->apply(&sps);
|
||||
playerint[gs->getHero(sps.id)->tempOwner]->heroPrimarySkillChanged(gs->getHero(sps.id),sps.which,sps.val);
|
||||
break;
|
||||
@ -229,7 +229,7 @@ void CClient::process(int what)
|
||||
{
|
||||
SetSecSkill sr;
|
||||
*serv >> sr;
|
||||
_log5 << "Changing hero secondary skill"<<std::endl;
|
||||
tlog5 << "Changing hero secondary skill"<<std::endl;
|
||||
gs->apply(&sr);
|
||||
//TODO? - maybe inform interfaces
|
||||
break;
|
||||
@ -259,7 +259,7 @@ void CClient::process(int what)
|
||||
{
|
||||
ChangeSpells vc;
|
||||
*serv >> vc;
|
||||
_log5 << "Changing spells of hero "<<vc.hid<<std::endl;
|
||||
tlog5 << "Changing spells of hero "<<vc.hid<<std::endl;
|
||||
gs->apply(&vc);
|
||||
break;
|
||||
}
|
||||
@ -273,7 +273,7 @@ void CClient::process(int what)
|
||||
if(obj->ID == 34)
|
||||
{
|
||||
CGHeroInstance *h = static_cast<CGHeroInstance*>(obj);
|
||||
_log5 << "Removing hero with id = "<<(unsigned)rh.id<<std::endl;
|
||||
tlog5 << "Removing hero with id = "<<(unsigned)rh.id<<std::endl;
|
||||
playerint[h->tempOwner]->heroKilled(h);
|
||||
}
|
||||
break;
|
||||
@ -282,7 +282,7 @@ void CClient::process(int what)
|
||||
{
|
||||
TryMoveHero *th = new TryMoveHero; //will be deleted by callback after processing
|
||||
*serv >> *th;
|
||||
_log5 << "HeroMove: id="<<th->id<<"\tResult: "<<(unsigned)th->result<<"\tPosition "<<th->end<<std::endl;
|
||||
tlog5 << "HeroMove: id="<<th->id<<"\tResult: "<<(unsigned)th->result<<"\tPosition "<<th->end<<std::endl;
|
||||
|
||||
gs->apply(th);
|
||||
int player = gs->map->objects[th->id]->getOwner();
|
||||
@ -317,7 +317,7 @@ void CClient::process(int what)
|
||||
{
|
||||
SetGarrisons sg;
|
||||
*serv >> sg;
|
||||
_log5 << "Setting garrisons." << std::endl;
|
||||
tlog5 << "Setting garrisons." << std::endl;
|
||||
gs->apply(&sg);
|
||||
for(std::map<ui32,CCreatureSet>::iterator i = sg.garrs.begin(); i!=sg.garrs.end(); i++)
|
||||
playerint[gs->map->objects[i->first]->tempOwner]->garrisonChanged(gs->map->objects[i->first]);
|
||||
@ -336,7 +336,7 @@ void CClient::process(int what)
|
||||
NewStructures ns;
|
||||
*serv >> ns;
|
||||
CGTownInstance *town = static_cast<CGTownInstance*>(gs->map->objects[ns.tid]);
|
||||
_log5 << "New structure(s) in " << ns.tid <<" " << town->name << " - " << *ns.bid.begin() << std::endl;
|
||||
tlog5 << "New structure(s) in " << ns.tid <<" " << town->name << " - " << *ns.bid.begin() << std::endl;
|
||||
gs->apply(&ns);
|
||||
BOOST_FOREACH(si32 bid, ns.bid)
|
||||
{
|
||||
@ -356,7 +356,7 @@ void CClient::process(int what)
|
||||
{
|
||||
SetAvailableCreatures ns;
|
||||
*serv >> ns;
|
||||
_log5 << "Setting available creatures in " << ns.tid << std::endl;
|
||||
tlog5 << "Setting available creatures in " << ns.tid << std::endl;
|
||||
gs->apply(&ns);
|
||||
CGTownInstance *t = gs->getTown(ns.tid);
|
||||
if(vstd::contains(playerint,t->tempOwner))
|
||||
@ -367,7 +367,7 @@ void CClient::process(int what)
|
||||
{
|
||||
SetHeroesInTown inTown;
|
||||
*serv >> inTown;
|
||||
_log5 << "Setting heroes in town " << inTown.tid << std::endl;
|
||||
tlog5 << "Setting heroes in town " << inTown.tid << std::endl;
|
||||
gs->apply(&inTown);
|
||||
CGTownInstance *t = gs->getTown(inTown.tid);
|
||||
if(vstd::contains(playerint,t->tempOwner))
|
||||
@ -378,7 +378,7 @@ void CClient::process(int what)
|
||||
{
|
||||
SetHeroArtifacts sha;
|
||||
*serv >> sha;
|
||||
_log5 << "Setting artifacts of hero " << sha.hid << std::endl;
|
||||
tlog5 << "Setting artifacts of hero " << sha.hid << std::endl;
|
||||
gs->apply(&sha);
|
||||
CGHeroInstance *t = gs->getHero(sha.hid);
|
||||
if(vstd::contains(playerint,t->tempOwner))
|
||||
@ -389,7 +389,7 @@ void CClient::process(int what)
|
||||
{
|
||||
SetObjectProperty sop;
|
||||
*serv >> sop;
|
||||
_log5 << "Setting " << (unsigned)sop.what << " property of " << sop.id <<" object to "<<sop.val<<std::endl;
|
||||
tlog5 << "Setting " << (unsigned)sop.what << " property of " << sop.id <<" object to "<<sop.val<<std::endl;
|
||||
gs->apply(&sop);
|
||||
break;
|
||||
}
|
||||
@ -397,7 +397,7 @@ void CClient::process(int what)
|
||||
{
|
||||
SetHoverName shn;
|
||||
*serv >> shn;
|
||||
_log5 << "Setting a name of " << shn.id <<" object to "<< toString(shn.name) <<std::endl;
|
||||
tlog5 << "Setting a name of " << shn.id <<" object to "<< toString(shn.name) <<std::endl;
|
||||
gs->mx->lock();
|
||||
gs->map->objects[shn.id]->hoverName = toString(shn.name);
|
||||
gs->mx->unlock();
|
||||
@ -407,7 +407,7 @@ void CClient::process(int what)
|
||||
{
|
||||
HeroLevelUp bs;
|
||||
*serv >> bs;
|
||||
_log5 << "Hero levels up!" <<std::endl;
|
||||
tlog5 << "Hero levels up!" <<std::endl;
|
||||
gs->apply(&bs);
|
||||
CGHeroInstance *h = gs->getHero(bs.heroid);
|
||||
if(vstd::contains(playerint,h->tempOwner))
|
||||
@ -421,7 +421,7 @@ void CClient::process(int what)
|
||||
{
|
||||
SelectionDialog sd;
|
||||
*serv >> sd;
|
||||
_log5 << "Showing selection dialog " <<std::endl;
|
||||
tlog5 << "Showing selection dialog " <<std::endl;
|
||||
std::vector<Component*> comps;
|
||||
for(int i=0;i<sd.components.size();i++)
|
||||
comps.push_back(&sd.components[i]);
|
||||
@ -433,7 +433,7 @@ void CClient::process(int what)
|
||||
{
|
||||
YesNoDialog ynd;
|
||||
*serv >> ynd;
|
||||
_log5 << "Showing yes/no dialog " <<std::endl;
|
||||
tlog5 << "Showing yes/no dialog " <<std::endl;
|
||||
std::vector<Component*> comps;
|
||||
for(int i=0;i<ynd.components.size();i++)
|
||||
comps.push_back(&ynd.components[i]);
|
||||
@ -445,7 +445,7 @@ void CClient::process(int what)
|
||||
{
|
||||
BattleStart bs;
|
||||
*serv >> bs; //uses new to allocate memory for battleInfo - must be deleted when battle is over
|
||||
_log5 << "Starting battle!" <<std::endl;
|
||||
tlog5 << "Starting battle!" <<std::endl;
|
||||
gs->apply(&bs);
|
||||
|
||||
if(playerint.find(gs->curB->side1) != playerint.end())
|
||||
@ -459,7 +459,7 @@ void CClient::process(int what)
|
||||
{
|
||||
BattleNextRound bnr;
|
||||
*serv >> bnr;
|
||||
_log5 << "Round nr " << bnr.round <<std::endl;
|
||||
tlog5 << "Round nr " << bnr.round <<std::endl;
|
||||
gs->apply(&bnr);
|
||||
|
||||
//tell players about next round
|
||||
@ -473,7 +473,7 @@ void CClient::process(int what)
|
||||
{
|
||||
BattleSetActiveStack sas;
|
||||
*serv >> sas;
|
||||
_log5 << "Active stack: " << sas.stack <<std::endl;
|
||||
tlog5 << "Active stack: " << sas.stack <<std::endl;
|
||||
gs->apply(&sas);
|
||||
int owner = gs->curB->getStack(sas.stack)->owner;
|
||||
if(owner >= PLAYER_LIMIT) //ugly workaround to skip neutral creatures - should be replaced with AI
|
||||
@ -493,7 +493,7 @@ void CClient::process(int what)
|
||||
{
|
||||
BattleResult br;
|
||||
*serv >> br;
|
||||
_log5 << "Battle ends. Winner: " << (unsigned)br.winner<< ". Type of end: "<< (unsigned)br.result <<std::endl;
|
||||
tlog5 << "Battle ends. Winner: " << (unsigned)br.winner<< ". Type of end: "<< (unsigned)br.result <<std::endl;
|
||||
|
||||
if(playerint.find(gs->curB->side1) != playerint.end())
|
||||
playerint[gs->curB->side1]->battleEnd(&br);
|
||||
@ -507,7 +507,7 @@ void CClient::process(int what)
|
||||
{
|
||||
BattleStackMoved br;
|
||||
*serv >> br;
|
||||
_log5 << "Stack "<<br.stack <<" moves to the tile "<<br.tile<<std::endl;
|
||||
tlog5 << "Stack "<<br.stack <<" moves to the tile "<<br.tile<<std::endl;
|
||||
if(playerint.find(gs->curB->side1) != playerint.end())
|
||||
playerint[gs->curB->side1]->battleStackMoved(br.stack,br.tile,br.flags&1,br.flags&2);
|
||||
if(playerint.find(gs->curB->side2) != playerint.end())
|
||||
@ -519,7 +519,7 @@ void CClient::process(int what)
|
||||
{
|
||||
BattleAttack ba;
|
||||
*serv >> ba;
|
||||
_log5 << "Stack: " << ba.stackAttacking << " is attacking stack "<< ba.bsa.stackAttacked <<std::endl;
|
||||
tlog5 << "Stack: " << ba.stackAttacking << " is attacking stack "<< ba.bsa.stackAttacked <<std::endl;
|
||||
gs->apply(&ba);
|
||||
LOCPLINT->battleAttack(&ba);
|
||||
break;
|
||||
@ -543,7 +543,7 @@ void CClient::waitForMoveAndSend(int color)
|
||||
*serv << ui16(3002) << ba;
|
||||
return;
|
||||
}HANDLE_EXCEPTION
|
||||
_log1 << "We should not be here!" << std::endl;
|
||||
tlog1 << "We should not be here!" << std::endl;
|
||||
}
|
||||
void CClient::run()
|
||||
{
|
||||
@ -560,10 +560,10 @@ void CClient::run()
|
||||
|
||||
void CClient::close()
|
||||
{
|
||||
_log3 << "Connection has been requested to be closed.\n";
|
||||
tlog3 << "Connection has been requested to be closed.\n";
|
||||
boost::unique_lock<boost::mutex>(*serv->wmx);
|
||||
*serv << ui16(99);
|
||||
_log3 << "Sended closing signal to the server\n";
|
||||
tlog3 << "Sended closing signal to the server\n";
|
||||
serv->close();
|
||||
_log3 << "Our socket has been closed.\n";
|
||||
tlog3 << "Our socket has been closed.\n";
|
||||
}
|
||||
|
@ -396,7 +396,7 @@ void Graphics::loadHeroFlags()
|
||||
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();
|
||||
_log0 << "Loading and transforming heroes' flags: "<<th.getDif()<<std::endl;
|
||||
tlog0 << "Loading and transforming heroes' flags: "<<th.getDif()<<std::endl;
|
||||
}
|
||||
SDL_Surface * Graphics::getPic(int ID, bool fort, bool builded)
|
||||
{
|
||||
|
@ -564,10 +564,6 @@
|
||||
RelativePath="..\ChangeLog"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ttt.txt"
|
||||
>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
|
24
global.h
24
global.h
@ -190,8 +190,8 @@ namespace vstd
|
||||
using vstd::operator-=;
|
||||
|
||||
#include "CConsoleHandler.h"
|
||||
extern std::ostream *logfile;
|
||||
extern CConsoleHandler *console;
|
||||
extern DLL_EXPORT std::ostream *logfile;
|
||||
extern DLL_EXPORT CConsoleHandler *console;
|
||||
template <int lvl> class CLogger
|
||||
{
|
||||
public:
|
||||
@ -218,32 +218,32 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
extern CLogger<0> _log0; //green - standard progress info
|
||||
extern CLogger<1> _log1; //red - big errors
|
||||
extern CLogger<2> _log2; //magenta - major warnings
|
||||
extern CLogger<3> _log3; //yellow - minor warnings
|
||||
extern CLogger<4> _log4; //white - detailed log info
|
||||
extern CLogger<5> _log5; //gray - minor log info
|
||||
extern DLL_EXPORT CLogger<0> tlog0; //green - standard progress info
|
||||
extern DLL_EXPORT CLogger<1> tlog1; //red - big errors
|
||||
extern DLL_EXPORT CLogger<2> tlog2; //magenta - major warnings
|
||||
extern DLL_EXPORT CLogger<3> tlog3; //yellow - minor warnings
|
||||
extern DLL_EXPORT CLogger<4> tlog4; //white - detailed log info
|
||||
extern DLL_EXPORT CLogger<5> tlog5; //gray - minor log info
|
||||
|
||||
#define HANDLE_EXCEPTION \
|
||||
catch (const std::exception& e) { \
|
||||
_log1 << e.what() << std::endl; \
|
||||
tlog1 << e.what() << std::endl; \
|
||||
} \
|
||||
catch (const std::exception * e) \
|
||||
{ \
|
||||
_log1 << e->what()<< std::endl; \
|
||||
tlog1 << e->what()<< std::endl; \
|
||||
delete e; \
|
||||
}
|
||||
|
||||
#define HANDLE_EXCEPTIONC(COMMAND) \
|
||||
catch (const std::exception& e) { \
|
||||
COMMAND; \
|
||||
_log1 << e.what() << std::endl; \
|
||||
tlog1 << e.what() << std::endl; \
|
||||
} \
|
||||
catch (const std::exception * e) \
|
||||
{ \
|
||||
COMMAND; \
|
||||
_log1 << e->what()<< std::endl; \
|
||||
tlog1 << e->what()<< std::endl; \
|
||||
delete e; \
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ unsigned char * CLodHandler::giveFile(std::string defName, int * length)
|
||||
Entry * ourEntry = entries.znajdz(Entry(defName));
|
||||
if(!ourEntry) //nothing's been found
|
||||
{
|
||||
_log1<<"Cannot find file: "<<defName;
|
||||
tlog1<<"Cannot find file: "<<defName;
|
||||
return NULL;
|
||||
}
|
||||
if(length) *length = ourEntry->realSize;
|
||||
@ -47,7 +47,7 @@ unsigned char * CLodHandler::giveFile(std::string defName, int * length)
|
||||
FILE * f = fopen(name,"rb");
|
||||
int result = fread(outp,1,ourEntry->realSize,f);
|
||||
mutex->unlock();
|
||||
if(result<0) {_log1<<"Error in file reading: "<<name<<std::endl;delete[] outp; return NULL;}
|
||||
if(result<0) {tlog1<<"Error in file reading: "<<name<<std::endl;delete[] outp; return NULL;}
|
||||
else
|
||||
return outp;
|
||||
}
|
||||
@ -228,7 +228,7 @@ void CLodHandler::extract(std::string FName)
|
||||
out.open(bufff.c_str(), std::ios::binary);
|
||||
if(!out.is_open())
|
||||
{
|
||||
_log1<<"Unable to create "<<bufff;
|
||||
tlog1<<"Unable to create "<<bufff;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -251,7 +251,7 @@ void CLodHandler::extract(std::string FName)
|
||||
destin.close();
|
||||
if(decRes!=0)
|
||||
{
|
||||
_log1<<"LOD Extraction error"<<" "<<decRes<<" while extracting to "<<bufff<<std::endl;
|
||||
tlog1<<"LOD Extraction error"<<" "<<decRes<<" while extracting to "<<bufff<<std::endl;
|
||||
}
|
||||
}
|
||||
delete[] outp;
|
||||
@ -279,7 +279,7 @@ void CLodHandler::extractFile(std::string FName, std::string name)
|
||||
out.open(bufff.c_str(), std::ios::binary);
|
||||
if(!out.is_open())
|
||||
{
|
||||
_log1<<"Unable to create "<<bufff;
|
||||
tlog1<<"Unable to create "<<bufff;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -302,7 +302,7 @@ void CLodHandler::extractFile(std::string FName, std::string name)
|
||||
destin.close();
|
||||
if(decRes!=0)
|
||||
{
|
||||
_log1<<"LOD Extraction error"<<" "<<decRes<<" while extracting to "<<bufff<<std::endl;
|
||||
tlog1<<"LOD Extraction error"<<" "<<decRes<<" while extracting to "<<bufff<<std::endl;
|
||||
}
|
||||
}
|
||||
delete[] outp;
|
||||
@ -391,7 +391,7 @@ void CLodHandler::init(std::string lodFile, std::string dirName)
|
||||
}
|
||||
}
|
||||
else
|
||||
_log1<<"Warning: No "+dirName+"/ folder!"<<std::endl;
|
||||
tlog1<<"Warning: No "+dirName+"/ folder!"<<std::endl;
|
||||
}
|
||||
std::string CLodHandler::getTextFile(std::string name)
|
||||
{
|
||||
|
@ -397,7 +397,6 @@ CGObjectInstance::~CGObjectInstance()
|
||||
}
|
||||
CGHeroInstance::CGHeroInstance()
|
||||
{
|
||||
looseFormation = true;
|
||||
tacticFormationEnabled = inTownGarrison = false;
|
||||
portrait = level = exp = -1;
|
||||
isStanding = true;
|
||||
|
@ -82,7 +82,7 @@ public:
|
||||
mutable int moveDir; //format: 123
|
||||
// 8 4
|
||||
// 765
|
||||
mutable ui8 isStanding, tacticFormationEnabled, looseFormation;
|
||||
mutable ui8 isStanding, tacticFormationEnabled;
|
||||
CHero * type;
|
||||
ui32 exp; //experience point
|
||||
int level; //current level of hero
|
||||
|
@ -46,27 +46,27 @@ CConnection::CConnection(std::string host, std::string port, std::string Name, s
|
||||
tcp::resolver::iterator end, pom, endpoint_iterator = resolver.resolve(tcp::resolver::query(host,port),error);
|
||||
if(error)
|
||||
{
|
||||
_log1 << "Problem with resolving: " << std::endl << error <<std::endl;
|
||||
tlog1 << "Problem with resolving: " << std::endl << error <<std::endl;
|
||||
goto connerror1;
|
||||
}
|
||||
pom = endpoint_iterator;
|
||||
if(pom != end)
|
||||
_log0<<"Found endpoints:" << std::endl;
|
||||
tlog0<<"Found endpoints:" << std::endl;
|
||||
else
|
||||
{
|
||||
_log1 << "Critical problem: No endpoints found!" << std::endl;
|
||||
tlog1 << "Critical problem: No endpoints found!" << std::endl;
|
||||
goto connerror1;
|
||||
}
|
||||
i=0;
|
||||
while(pom != end)
|
||||
{
|
||||
_log0 << "\t" << i << ": " << (boost::asio::ip::tcp::endpoint&)*pom << std::endl;
|
||||
tlog0 << "\t" << i << ": " << (boost::asio::ip::tcp::endpoint&)*pom << std::endl;
|
||||
pom++;
|
||||
}
|
||||
i=0;
|
||||
while(endpoint_iterator != end)
|
||||
{
|
||||
_log0 << "Trying connection to " << (boost::asio::ip::tcp::endpoint&)*endpoint_iterator << " (" << i++ << ")" << std::endl;
|
||||
tlog0 << "Trying connection to " << (boost::asio::ip::tcp::endpoint&)*endpoint_iterator << " (" << i++ << ")" << std::endl;
|
||||
socket->connect(*endpoint_iterator, error);
|
||||
if(!error)
|
||||
{
|
||||
@ -75,18 +75,18 @@ CConnection::CConnection(std::string host, std::string port, std::string Name, s
|
||||
}
|
||||
else
|
||||
{
|
||||
_log1 << "Problem with connecting: " << std::endl << error << std::endl;
|
||||
tlog1 << "Problem with connecting: " << std::endl << error << std::endl;
|
||||
}
|
||||
endpoint_iterator++;
|
||||
}
|
||||
|
||||
//we shouldn't be here - error handling
|
||||
connerror1:
|
||||
_log1 << "Something went wrong... checking for error info" << std::endl;
|
||||
tlog1 << "Something went wrong... checking for error info" << std::endl;
|
||||
if(error)
|
||||
std::cout << error <<std::endl;
|
||||
else
|
||||
_log1 << "No error info. " << std::endl;
|
||||
tlog1 << "No error info. " << std::endl;
|
||||
delete io_service;
|
||||
//delete socket;
|
||||
throw std::string("Can't establish connection :(");
|
||||
|
@ -12,14 +12,14 @@
|
||||
class CLodHandler;
|
||||
LibClasses * VLC = NULL;
|
||||
CLodHandler * bitmaph=NULL;
|
||||
CLogger<0> _log0;
|
||||
CLogger<1> _log1;
|
||||
CLogger<2> _log2;
|
||||
CLogger<3> _log3;
|
||||
CLogger<4> _log4;
|
||||
CLogger<5> _log5;
|
||||
CConsoleHandler *console = NULL;
|
||||
std::ostream *logfile = 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)
|
||||
{
|
||||
console = Console;
|
||||
@ -32,39 +32,39 @@ DLL_EXPORT void initDLL(CLodHandler *b, CConsoleHandler *Console, std::ostream *
|
||||
heroh->loadHeroes();
|
||||
heroh->loadPortraits();
|
||||
VLC->heroh = heroh;
|
||||
_log0 <<"\tHero handler: "<<pomtime.getDif()<<std::endl;
|
||||
tlog0 <<"\tHero handler: "<<pomtime.getDif()<<std::endl;
|
||||
|
||||
CArtHandler * arth = new CArtHandler;
|
||||
arth->loadArtifacts();
|
||||
VLC->arth = arth;
|
||||
_log0<<"\tArtifact handler: "<<pomtime.getDif()<<std::endl;
|
||||
tlog0<<"\tArtifact handler: "<<pomtime.getDif()<<std::endl;
|
||||
|
||||
CCreatureHandler * creh = new CCreatureHandler();
|
||||
creh->loadCreatures();
|
||||
VLC->creh = creh;
|
||||
_log0<<"\tCreature handler: "<<pomtime.getDif()<<std::endl;
|
||||
tlog0<<"\tCreature handler: "<<pomtime.getDif()<<std::endl;
|
||||
|
||||
VLC->townh = new CTownHandler;
|
||||
VLC->townh->loadNames();
|
||||
_log0<<"\tTown handler: "<<pomtime.getDif()<<std::endl;
|
||||
tlog0<<"\tTown handler: "<<pomtime.getDif()<<std::endl;
|
||||
|
||||
CObjectHandler * objh = new CObjectHandler;
|
||||
objh->loadObjects();
|
||||
VLC->objh = objh;
|
||||
_log0<<"\tObject handler: "<<pomtime.getDif()<<std::endl;
|
||||
tlog0<<"\tObject handler: "<<pomtime.getDif()<<std::endl;
|
||||
|
||||
VLC->dobjinfo = new CDefObjInfoHandler;
|
||||
VLC->dobjinfo->load();
|
||||
_log0<<"\tDef information handler: "<<pomtime.getDif()<<std::endl;
|
||||
tlog0<<"\tDef information handler: "<<pomtime.getDif()<<std::endl;
|
||||
|
||||
VLC->buildh = new CBuildingHandler;
|
||||
VLC->buildh->loadBuildings();
|
||||
_log0<<"\tBuilding handler: "<<pomtime.getDif()<<std::endl;
|
||||
tlog0<<"\tBuilding handler: "<<pomtime.getDif()<<std::endl;
|
||||
|
||||
CSpellHandler * spellh = new CSpellHandler;
|
||||
spellh->loadSpells();
|
||||
VLC->spellh = spellh;
|
||||
_log0<<"\tSpell handler: "<<pomtime.getDif()<<std::endl;
|
||||
tlog0<<"\tSpell handler: "<<pomtime.getDif()<<std::endl;
|
||||
}
|
||||
|
||||
DLL_EXPORT void loadToIt(std::string &dest, std::string &src, int &iter, int mode)
|
||||
|
24
map.cpp
24
map.cpp
@ -448,25 +448,25 @@ void Mapa::initFromBytes(unsigned char * bufor)
|
||||
th.getDif();
|
||||
int i=0;
|
||||
readHeader(bufor, i);
|
||||
_log0<<"\tReading header: "<<th.getDif()<<std::endl;
|
||||
tlog0<<"\tReading header: "<<th.getDif()<<std::endl;
|
||||
|
||||
readRumors(bufor, i);
|
||||
_log0<<"\tReading rumors: "<<th.getDif()<<std::endl;
|
||||
tlog0<<"\tReading rumors: "<<th.getDif()<<std::endl;
|
||||
|
||||
readPredefinedHeroes(bufor, i);
|
||||
_log0<<"\tReading predefined heroes: "<<th.getDif()<<std::endl;
|
||||
tlog0<<"\tReading predefined heroes: "<<th.getDif()<<std::endl;
|
||||
|
||||
readTerrain(bufor, i);
|
||||
_log0<<"\tReading terrain: "<<th.getDif()<<std::endl;
|
||||
tlog0<<"\tReading terrain: "<<th.getDif()<<std::endl;
|
||||
|
||||
readDefInfo(bufor, i);
|
||||
_log0<<"\tReading defs info: "<<th.getDif()<<std::endl;
|
||||
tlog0<<"\tReading defs info: "<<th.getDif()<<std::endl;
|
||||
|
||||
readObjects(bufor, i);
|
||||
_log0<<"\tReading objects: "<<th.getDif()<<std::endl;
|
||||
tlog0<<"\tReading objects: "<<th.getDif()<<std::endl;
|
||||
|
||||
readEvents(bufor, i);
|
||||
_log0<<"\tReading events: "<<th.getDif()<<std::endl;
|
||||
tlog0<<"\tReading events: "<<th.getDif()<<std::endl;
|
||||
|
||||
//map readed, bufor no longer needed
|
||||
delete[] bufor; bufor=NULL;
|
||||
@ -478,7 +478,7 @@ void Mapa::initFromBytes(unsigned char * bufor)
|
||||
continue;
|
||||
addBlockVisTiles(objects[f]);
|
||||
}
|
||||
_log0<<"\tCalculating blocked/visitable tiles: "<<th.getDif()<<std::endl;
|
||||
tlog0<<"\tCalculating blocked/visitable tiles: "<<th.getDif()<<std::endl;
|
||||
}
|
||||
void Mapa::removeBlockVisTiles(CGObjectInstance * obj)
|
||||
{
|
||||
@ -534,7 +534,7 @@ void Mapa::addBlockVisTiles(CGObjectInstance * obj)
|
||||
}
|
||||
Mapa::Mapa(std::string filename)
|
||||
{
|
||||
_log0<<"Opening map file: "<<filename<<"\t "<<std::flush;
|
||||
tlog0<<"Opening map file: "<<filename<<"\t "<<std::flush;
|
||||
gzFile map = gzopen(filename.c_str(),"rb");
|
||||
std::vector<unsigned char> mapstr; int pom;
|
||||
while((pom=gzgetc(map))>=0)
|
||||
@ -547,11 +547,11 @@ Mapa::Mapa(std::string filename)
|
||||
{
|
||||
initTable[ss] = mapstr[ss];
|
||||
}
|
||||
_log0<<"done."<<std::endl;
|
||||
tlog0<<"done."<<std::endl;
|
||||
boost::crc_32_type result;
|
||||
result.process_bytes(initTable,mapstr.size());
|
||||
checksum = result.checksum();
|
||||
_log0 << "\tOur map checksum: "<<result.checksum() << std::endl;
|
||||
tlog0 << "\tOur map checksum: "<<result.checksum() << std::endl;
|
||||
initFromBytes(initTable);
|
||||
}
|
||||
|
||||
@ -1725,7 +1725,7 @@ void Mapa::readDefInfo( unsigned char * bufor, int &i)
|
||||
vinya->visitMap[zi] = reverse(bytes[6+zi]);
|
||||
}
|
||||
i+=16;
|
||||
if(vinya->id!=34)
|
||||
if(vinya->id!=34 && vinya->id!=70)
|
||||
vinya->visitDir = VLC->dobjinfo->gobjs[vinya->id][vinya->subid]->visitDir;
|
||||
else
|
||||
vinya->visitDir = 0xff;
|
||||
|
@ -469,7 +469,7 @@ void processDef (CGDefInfo* def)
|
||||
pom->height = pom->handler->ourImages[0].bitmap->h/32;
|
||||
}
|
||||
else if(def->id != 34 && def->id != 98)
|
||||
_log3 << "\t\tMinor warning: lacking def info for " << def->id << " " << def->subid <<" " << def->name << std::endl;
|
||||
tlog3 << "\t\tMinor warning: lacking def info for " << def->id << " " << def->subid <<" " << def->name << std::endl;
|
||||
if(!def->handler->alphaTransformed)
|
||||
{
|
||||
for(int yy=0; yy<def->handler->ourImages.size(); ++yy)
|
||||
@ -484,7 +484,7 @@ void CMapHandler::init()
|
||||
timeHandler th;
|
||||
th.getDif();
|
||||
loadDefs(); //loading castles' defs
|
||||
_log0<<"Reading terrain defs: "<<th.getDif()<<std::endl;
|
||||
tlog0<<"Reading terrain defs: "<<th.getDif()<<std::endl;
|
||||
|
||||
std::ifstream ifs("config/townsDefs.txt");
|
||||
int ccc;
|
||||
@ -501,10 +501,10 @@ void CMapHandler::init()
|
||||
n = CGI->state->capitols[i%ccc];
|
||||
ifs >> n->name;
|
||||
if(!n)
|
||||
_log1 << "*HUGE* Warning - missing town def for " << i << std::endl;
|
||||
tlog1 << "*HUGE* Warning - missing town def for " << i << std::endl;
|
||||
map->defs.insert(n);
|
||||
}
|
||||
_log0<<"\tLoading town def info: "<<th.getDif()<<std::endl;
|
||||
tlog0<<"\tLoading town def info: "<<th.getDif()<<std::endl;
|
||||
|
||||
for(int i=0;i<map->heroes.size();i++)
|
||||
{
|
||||
@ -518,7 +518,7 @@ void CMapHandler::init()
|
||||
|
||||
std::for_each(map->defy.begin(),map->defy.end(),processDef); //load h3m defs
|
||||
std::for_each(map->defs.begin(),map->defs.end(),processDef); //and non-h3m defs
|
||||
_log0<<"\tUnpacking and handling defs: "<<th.getDif()<<std::endl;
|
||||
tlog0<<"\tUnpacking and handling defs: "<<th.getDif()<<std::endl;
|
||||
|
||||
for(int i=0;i<PLAYER_LIMIT;i++)
|
||||
{
|
||||
@ -527,20 +527,20 @@ void CMapHandler::init()
|
||||
usedHeroes.insert(map->players[i].heroesNames[j].heroID);
|
||||
}
|
||||
}
|
||||
_log0<<"\tChecking used heroes: "<<th.getDif()<<std::endl;
|
||||
tlog0<<"\tChecking used heroes: "<<th.getDif()<<std::endl;
|
||||
|
||||
|
||||
|
||||
for(int h=0; h<map->defy.size(); ++h) //initializing loaded def handler's info {
|
||||
CGI->mh->loadedDefs.insert(std::make_pair(map->defy[h]->name, map->defy[h]->handler));
|
||||
_log0<<"\tCollecting loaded def's handlers: "<<th.getDif()<<std::endl;
|
||||
tlog0<<"\tCollecting loaded def's handlers: "<<th.getDif()<<std::endl;
|
||||
|
||||
prepareFOWDefs();
|
||||
roadsRiverTerrainInit(); //road's and river's DefHandlers; and simple values initialization
|
||||
borderAndTerrainBitmapInit();
|
||||
_log0<<"\tPreparing FoW, roads, rivers,borders: "<<th.getDif()<<std::endl;
|
||||
tlog0<<"\tPreparing FoW, roads, rivers,borders: "<<th.getDif()<<std::endl;
|
||||
initObjectRects();
|
||||
_log0<<"\tMaking object rects: "<<th.getDif()<<std::endl;
|
||||
tlog0<<"\tMaking object rects: "<<th.getDif()<<std::endl;
|
||||
}
|
||||
|
||||
SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level, unsigned char anim, std::vector< std::vector< std::vector<unsigned char> > > * visibilityMap, bool otherHeroAnim, unsigned char heroAnim, SDL_Surface * extSurf, SDL_Rect * extRect)
|
||||
|
@ -341,7 +341,7 @@ void CGameHandler::handleConnection(std::set<int> players, CConnection &c)
|
||||
{
|
||||
case 99: //end!
|
||||
{
|
||||
_log0 << "We have been requested to close.\n";
|
||||
tlog0 << "We have been requested to close.\n";
|
||||
exit(0);
|
||||
}
|
||||
case 100: //my interface ended its turn
|
||||
@ -856,7 +856,7 @@ upgend:
|
||||
si32 hid;
|
||||
ui8 formation;
|
||||
c >> hid >> formation;
|
||||
gs->getHero(hid)->army.formation = !formation;
|
||||
gs->getHero(hid)->army.formation = formation;
|
||||
break;
|
||||
}
|
||||
case 2001:
|
||||
@ -967,12 +967,12 @@ upgend:
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
_log1 << e.what() << std::endl;
|
||||
tlog1 << e.what() << std::endl;
|
||||
end2 = true;
|
||||
}
|
||||
catch (const std::exception * e)
|
||||
{
|
||||
_log1 << e->what()<< std::endl;
|
||||
tlog1 << e->what()<< std::endl;
|
||||
end2 = true;
|
||||
delete e;
|
||||
}
|
||||
@ -1273,7 +1273,7 @@ void CGameHandler::setupBattle( BattleInfo * curB, int3 tile, CCreatureSet &army
|
||||
positions.open("config" PATHSEPARATOR "battleStartpos.txt", std::ios_base::in|std::ios_base::binary);
|
||||
if(!positions.is_open())
|
||||
{
|
||||
_log0<<"Unable to open battleStartpos.txt!"<<std::endl;
|
||||
tlog0<<"Unable to open battleStartpos.txt!"<<std::endl;
|
||||
}
|
||||
std::string dump;
|
||||
positions>>dump; positions>>dump;
|
||||
|
@ -22,14 +22,6 @@ using namespace boost;
|
||||
using namespace boost::asio;
|
||||
using namespace boost::asio::ip;
|
||||
namespace intpr = boost::interprocess;
|
||||
extern CLogger<0> _log0;
|
||||
extern CLogger<1> _log1;
|
||||
extern CLogger<2> _log2;
|
||||
extern CLogger<3> _log3;
|
||||
extern CLogger<4> _log4;
|
||||
extern CLogger<5> _log5;
|
||||
extern CConsoleHandler *console;// = NULL;
|
||||
extern std::ostream *logfile;// = NULL;
|
||||
bool end2 = false;
|
||||
int port = 3030;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user