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

gcc fixes(bad idea to call global vars such as log2, this name used by math function). Colored log support on some non-win32 platforms. Small Automake project update

This commit is contained in:
Vadim Glazunov 2008-09-18 20:24:53 +00:00
parent 5ee37eeb3d
commit a1dd7f22f9
16 changed files with 227 additions and 179 deletions

View File

@ -17,16 +17,16 @@
#include <boost/algorithm/string.hpp>
#include "boost/function.hpp"
#include <boost/thread.hpp>
#ifdef _MSC_VER
#ifdef _WIN32
#include <windows.h>
HANDLE handleIn;
HANDLE handleOut;
WORD defColor;
#endif
WORD defColor;
void CConsoleHandler::setColor(int level)
{
#ifdef _MSC_VER
WORD color;
switch(level)
{
@ -34,28 +34,55 @@ void CConsoleHandler::setColor(int level)
color = defColor;
break;
case 0:
#ifdef _WIN32
color = FOREGROUND_GREEN | FOREGROUND_INTENSITY;
#else
color = "\x1b[1;40;32m";
#endif
break;
case 1:
#ifdef _WIN32
color = FOREGROUND_RED | FOREGROUND_INTENSITY;
#else
color = "\x1b[1;40;31m";
#endif
break;
case 2:
#ifdef _WIN32
color = FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY;
#else
color = "\x1b[1;40;35m";
#endif
break;
case 3:
#ifdef _WIN32
color = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY;
#else
color = "\x1b[1;40;32m";
#endif
break;
case 4:
#ifdef _WIN32
color = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY;
#else
color = "\x1b[1;40;39m";
#endif
break;
case 5:
#ifdef _WIN32
color = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
#else
color = "\x1b[0;40;39m";
#endif
break;
default:
color = defColor;
break;
}
#ifdef _WIN32
SetConsoleTextAttribute(handleOut,color);
#else
std::cout << color;
#endif
}
@ -73,12 +100,14 @@ int CConsoleHandler::run()
}
CConsoleHandler::CConsoleHandler()
{
#ifdef _MSC_VER
#ifdef _WIN32
handleIn = GetStdHandle(STD_INPUT_HANDLE);
handleOut = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(handleOut,&csbi);
defColor = csbi.wAttributes;
#else
defColor = "\x1b[0m";
#endif
cb = new boost::function<void(const std::string &)>;
}
@ -86,11 +115,13 @@ CConsoleHandler::~CConsoleHandler()
{
delete cb;
}
#ifndef _WIN32
void CConsoleHandler::killConsole(pthread_t hThread)
#else
void CConsoleHandler::killConsole(void *hThread)
{
#ifdef _MSC_VER
log3 << "Killing console... ";
TerminateThread(hThread,0);
log3 << "done!\n";
#endif
}
{
_log3 << "Killing console... ";
_kill_thread(hThread,0);
_log3 << "done!\n";
}

View File

@ -1,5 +1,16 @@
#ifndef CCONSOLEHANDLER_H
#define CCONSOLEHANDLER_H
#ifndef _WIN32
#define WORD std::string
#endif
#ifndef _WIN32
#define _kill_thread(a,b) pthread_cancel(a);
#else
#define _kill_thread(a,b) TerminateThread(a,b);
#endif
namespace boost
{
template<typename signature>
@ -14,7 +25,11 @@ public:
void setColor(int level);
CConsoleHandler();
~CConsoleHandler();
#ifndef _WIN32
static void killConsole(pthread_t hThread); //for windows only, use native handle to the thread
#else
static void killConsole(void *hThread); //for windows only, use native handle to the thread
#endif
template<typename T> void print(const T &data, int level)
{
setColor(level);

90
CMT.cpp
View File

@ -51,14 +51,14 @@ extern SDL_Surface * CSDL_Ext::std32bppSurface;
std::queue<SDL_Event> events;
boost::mutex eventsM;
TTF_Font * TNRB16, *TNR, *GEOR13, *GEORXX, *GEORM, *GEOR16;
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;
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 +79,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;
_log0 << "\tConsole and logifle ready!" << std::endl;
int port;
if(argc > 1)
{
@ -92,10 +92,10 @@ int main(int argc, char** argv)
else
{
port = 3030;
log0 << "Port " << port << " will be used." << std::endl;
_log0 << "Port " << port << " will be used." << std::endl;
}
std::cout.flags(ios::unitbuf);
log0 << NAME << std::endl;
_log0 << NAME << std::endl;
srand ( time(NULL) );
CPG=NULL;
atexit(SDL_Quit);
@ -104,13 +104,13 @@ int main(int argc, char** argv)
//luatest.test();
//CBIKHandler cb;
//cb.open("CSECRET.BIK");
log0 << "Starting... " << std::endl;
_log0 << "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;
_log0 <<"\tInitializing screen: "<<pomtime.getDif();
_log0 << 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 +118,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;
_log0 << "\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 +126,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 _log0<<"\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 _log0<<"\tInitializing sound: "<<pomtime.getDif()<<std::endl;
THC _log0<<"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 _log0<<"Loading .lod files: "<<tmh.getDif()<<std::endl;
initDLL(cgi->bitmaph,::console,logfile);
CGI->arth = VLC->arth;
CGI->creh = VLC->creh;
@ -147,7 +147,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;
_log0<<"Initializing VCMI_Lib: "<<tmh.getDif()<<std::endl;
//cgi->curh->initCursor();
//cgi->curh->showGraphicCursor();
pomtime.getDif();
@ -155,28 +155,28 @@ int main(int argc, char** argv)
cgi->curh->initCursor();
//cgi->screenh = new CScreenHandler;
//cgi->screenh->initScreen();
log0<<"\tScreen handler: "<<pomtime.getDif()<<std::endl;
_log0<<"\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;
_log0<<"\tAbility handler: "<<pomtime.getDif()<<std::endl;
_log0<<"Preparing first handlers: "<<tmh.getDif()<<std::endl;
pomtime.getDif();
graphics = new Graphics();
log0<<"\tMain graphics: "<<tmh.getDif()<<std::endl;
_log0<<"\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;
_log0<<"\tHero animations: "<<tmh.getDif()<<std::endl;
_log0<<"Initializing game graphics: "<<tmh.getDif()<<std::endl;
CMessage::init();
cgi->generaltexth = new CGeneralTextHandler;
cgi->generaltexth->load();
log0<<"Preparing more handlers: "<<tmh.getDif()<<std::endl;
_log0<<"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;
_log0<<"Initialization CPreGame (together): "<<tmh.getDif()<<std::endl;
_log0<<"Initialization of VCMI (togeter): "<<total.getDif()<<std::endl;
cpg->mush = mush;
StartInfo *options = new StartInfo(cpg->runLoop());
@ -189,17 +189,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;
_log0<<"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;
_log0<<"\tPathfinder: "<<pomtime.getDif()<<std::endl;
_log0<<"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... ";
_log0<<"Waiting for server... ";
{
intpr::scoped_lock<intpr::interprocess_mutex> slock(sr->mutex);
while(!sr->ready)
@ -208,21 +208,21 @@ int main(int argc, char** argv)
}
}
intpr::shared_memory_object::remove("vcmi_memory");
log0 << tmh.getDif()<<std::endl;
_log0 << tmh.getDif()<<std::endl;
while(!c)
{
try
{
log0 << "Establishing connection...\n";
_log0 << "Establishing connection...\n";
c = new CConnection("127.0.0.1",portc,NAME,lll);
}
catch(...)
{
log1 << "\nCannot establish connection! Retrying within 2 seconds" <<std::endl;
_log1 << "\nCannot establish connection! Retrying within 2 seconds" <<std::endl;
SDL_Delay(2000);
}
}
THC log0<<"\tConnecting to the server: "<<tmh.getDif()<<std::endl;
THC _log0<<"\tConnecting to the server: "<<tmh.getDif()<<std::endl;
CClient cl(c,options);
boost::thread t(boost::bind(&CClient::run,&cl));
SDL_Event ev;
@ -232,9 +232,11 @@ int main(int argc, char** argv)
if(ev.type==SDL_QUIT)
{
cl.close();
#ifndef __unix__
::console->killConsole(console->native_handle());
#endif
SDL_Delay(750);
log0 << "Ending...\n";
_log0 << "Ending...\n";
exit(0);
}
eventsM.lock();
@ -244,7 +246,7 @@ int main(int argc, char** argv)
}
else
{
log1<<"Something was wrong: "<<SDL_GetError()<<std::endl;
_log1<<"Something was wrong: "<<SDL_GetError()<<std::endl;
return -1;
}
}
@ -282,10 +284,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";
_log0<<"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";
_log0<<"done.\nScanning .lod file\n";
int curp=0;
std::string pattern = ".TXT";
for(int i=0;i<txth->entries.size(); i++)
@ -300,9 +302,9 @@ void processCommand(const std::string &message)
if(p2!=curp)
{
curp = p2;
log0<<"\r"<<curp<<"%";
_log0<<"\r"<<curp<<"%";
}
}
log0<<"\rExtracting done :)\n";
_log0<<"\rExtracting done :)\n";
}
}
}

View File

@ -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) {_log3<<"\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;
_log0<<"\tCPreGame: loading txts: "<<tmh.getDif()<<std::endl;
currentMessage=NULL;
behindCurMes=NULL;
initMainMenu();
log0<<"\tCPreGame: main menu initialization: "<<tmh.getDif()<<std::endl;
_log0<<"\tCPreGame: main menu initialization: "<<tmh.getDif()<<std::endl;
initNewMenu();
log0<<"\tCPreGame: newgame menu initialization: "<<tmh.getDif()<<std::endl;
_log0<<"\tCPreGame: newgame menu initialization: "<<tmh.getDif()<<std::endl;
initScenSel();
log0<<"\tCPreGame: scenario choice initialization: "<<tmh.getDif()<<std::endl;
_log0<<"\tCPreGame: scenario choice initialization: "<<tmh.getDif()<<std::endl;
initOptions();
log0<<"\tCPreGame: scenario options initialization: "<<tmh.getDif()<<std::endl;
_log0<<"\tCPreGame: scenario options initialization: "<<tmh.getDif()<<std::endl;
showMainMenu();
log0<<"\tCPreGame: displaying main menu: "<<tmh.getDif()<<std::endl;
_log0<<"\tCPreGame: displaying main menu: "<<tmh.getDif()<<std::endl;
CPG=this;
playerName="Player";
}

View File

@ -101,7 +101,7 @@ CClient::CClient(CConnection *con, StartInfo *si)
{
timeHandler tmh;
CGI->state = new CGameState();
log0 <<"\tGamestate: "<<tmh.getDif()<<std::endl;
_log0 <<"\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;
_log0 <<"\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;
_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;
if(mapa->checksum != sum)
{
log1 << "Wrong map checksum!!!" << std::endl;
_log1 << "Wrong map checksum!!!" << std::endl;
#ifndef __GNUC__
throw std::exception("Wrong checksum");
#else
throw std::exception();
#endif
}
log0 << "\tUsing random seed: "<<seed << std::endl;
_log0 << "\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;
_log0 <<"Initializing GameState (together): "<<tmh.getDif()<<std::endl;
CGI->mh->map = mapa;
log0 <<"Creating mapHandler: "<<tmh.getDif()<<std::endl;
_log0 <<"Creating mapHandler: "<<tmh.getDif()<<std::endl;
CGI->mh->init();
log0 <<"Initializing mapHandler (together): "<<tmh.getDif()<<std::endl;
_log0 <<"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;
_log5 << "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... ";
_log5 << "New day: "<<(unsigned)n.day<<". Applying changes... ";
gs->apply(&n);
log5 << "done!"<<std::endl;
_log5 << "done!"<<std::endl;
break;
}
case 102: //set resource amount
{
SetResource sr;
*serv >> sr;
log5 << "Set amount of "<<CGI->objh->restypes[sr.resid]
_log5 << "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;
_log5 << "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;
_log5 << "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;
_log5 << "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;
_log5 << "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;
_log5 << "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;
_log5 << "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;
_log5 << "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;
_log5 << "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;
_log5 << "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;
_log5 << "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;
_log5 << "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;
_log5 << "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;
_log5 << "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;
_log5 << "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;
_log5 << "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;
_log5 << "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;
_log5 << "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;
_log5 << "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;
_log5 << "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;
_log5 << "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;
_log5 << "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;
_log5 << "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;
_log1 << "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";
_log3 << "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";
_log3 << "Sended closing signal to the server\n";
serv->close();
log3 << "Our socket has been closed.\n";
_log3 << "Our socket has been closed.\n";
}

View File

@ -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;
_log0 << "Loading and transforming heroes' flags: "<<th.getDif()<<std::endl;
}
SDL_Surface * Graphics::getPic(int ID, bool fort, bool builded)
{

View File

@ -14,7 +14,6 @@ vcmiclient_SOURCES = \
./CBitmapHandler.cpp \
../CCallback.cpp \
../CCastleInterface.cpp \
../CConsoleHandler.cpp \
./CCreatureAnimation.cpp \
../CCursorHandler.cpp \
../hch/CDefHandler.cpp \
@ -49,7 +48,6 @@ vcmiclient_SOURCES = \
../hch/CBuildingHandler.h \
../CCallback.h \
../CCastleInterface.h \
../CConsoleHandler.h \
./CCreatureAnimation.h \
../hch/CCreatureHandler.h \
../CCursorHandler.h \

View File

@ -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 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
#define HANDLE_EXCEPTION \
catch (const std::exception& e) { \
log1 << e.what() << std::endl; \
_log1 << e.what() << std::endl; \
} \
catch (const std::exception * e) \
{ \
log1 << e->what()<< std::endl; \
_log1 << e->what()<< std::endl; \
delete e; \
}
#define HANDLE_EXCEPTIONC(COMMAND) \
catch (const std::exception& e) { \
COMMAND; \
log1 << e.what() << std::endl; \
_log1 << e.what() << std::endl; \
} \
catch (const std::exception * e) \
{ \
COMMAND; \
log1 << e->what()<< std::endl; \
_log1 << e->what()<< std::endl; \
delete e; \
}

View File

@ -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;
_log1<<"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) {_log1<<"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;
_log1<<"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;
_log1<<"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;
_log1<<"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;
_log1<<"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;
_log1<<"Warning: No "+dirName+"/ folder!"<<std::endl;
}
std::string CLodHandler::getTextFile(std::string name)
{

View File

@ -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;
_log1 << "Problem with resolving: " << std::endl << error <<std::endl;
goto connerror1;
}
pom = endpoint_iterator;
if(pom != end)
log0<<"Found endpoints:" << std::endl;
_log0<<"Found endpoints:" << std::endl;
else
{
log1 << "Critical problem: No endpoints found!" << std::endl;
_log1 << "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;
_log0 << "\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;
_log0 << "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;
_log1 << "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;
_log1 << "Something went wrong... checking for error info" << std::endl;
if(error)
std::cout << error <<std::endl;
else
log1 << "No error info. " << std::endl;
_log1 << "No error info. " << std::endl;
delete io_service;
//delete socket;
throw std::string("Can't establish connection :(");

View File

@ -16,6 +16,8 @@ libvcmi_a_SOURCES = \
../map.cpp \
../stdafx.cpp \
./VCMI_Lib.cpp \
../hch/CSpellHandler.cpp \
../CConsoleHandler.cpp \
../hch/CAmbarCendamo.h \
../hch/CArtHandler.h \
../hch/CBuildingHandler.h \
@ -30,4 +32,4 @@ libvcmi_a_SOURCES = \
../map.h \
./NetPacks.h \
./VCMI_Lib.h \
../hch/CSpellHandler.cpp
../CConsoleHandler.h

View File

@ -12,12 +12,12 @@
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;
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 void initDLL(CLodHandler *b, CConsoleHandler *Console, std::ostream *Logfile)
@ -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;
_log0 <<"\tHero handler: "<<pomtime.getDif()<<std::endl;
CArtHandler * arth = new CArtHandler;
arth->loadArtifacts();
VLC->arth = arth;
log0<<"\tArtifact handler: "<<pomtime.getDif()<<std::endl;
_log0<<"\tArtifact handler: "<<pomtime.getDif()<<std::endl;
CCreatureHandler * creh = new CCreatureHandler();
creh->loadCreatures();
VLC->creh = creh;
log0<<"\tCreature handler: "<<pomtime.getDif()<<std::endl;
_log0<<"\tCreature handler: "<<pomtime.getDif()<<std::endl;
VLC->townh = new CTownHandler;
VLC->townh->loadNames();
log0<<"\tTown handler: "<<pomtime.getDif()<<std::endl;
_log0<<"\tTown handler: "<<pomtime.getDif()<<std::endl;
CObjectHandler * objh = new CObjectHandler;
objh->loadObjects();
VLC->objh = objh;
log0<<"\tObject handler: "<<pomtime.getDif()<<std::endl;
_log0<<"\tObject handler: "<<pomtime.getDif()<<std::endl;
VLC->dobjinfo = new CDefObjInfoHandler;
VLC->dobjinfo->load();
log0<<"\tDef information handler: "<<pomtime.getDif()<<std::endl;
_log0<<"\tDef information handler: "<<pomtime.getDif()<<std::endl;
VLC->buildh = new CBuildingHandler;
VLC->buildh->loadBuildings();
log0<<"\tBuilding handler: "<<pomtime.getDif()<<std::endl;
_log0<<"\tBuilding handler: "<<pomtime.getDif()<<std::endl;
CSpellHandler * spellh = new CSpellHandler;
spellh->loadSpells();
VLC->spellh = spellh;
log0<<"\tSpell handler: "<<pomtime.getDif()<<std::endl;
_log0<<"\tSpell handler: "<<pomtime.getDif()<<std::endl;
}
DLL_EXPORT void loadToIt(std::string &dest, std::string &src, int &iter, int mode)
@ -180,4 +180,4 @@ DLL_EXPORT void loadToIt(si32 &dest, std::string &src, int &iter, int mode)
std::string pom;
loadToIt(pom,src,iter,mode);
dest = atol(pom.c_str());
}
}

24
map.cpp
View File

@ -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;
_log0<<"\tReading header: "<<th.getDif()<<std::endl;
readRumors(bufor, i);
log0<<"\tReading rumors: "<<th.getDif()<<std::endl;
_log0<<"\tReading rumors: "<<th.getDif()<<std::endl;
readPredefinedHeroes(bufor, i);
log0<<"\tReading predefined heroes: "<<th.getDif()<<std::endl;
_log0<<"\tReading predefined heroes: "<<th.getDif()<<std::endl;
readTerrain(bufor, i);
log0<<"\tReading terrain: "<<th.getDif()<<std::endl;
_log0<<"\tReading terrain: "<<th.getDif()<<std::endl;
readDefInfo(bufor, i);
log0<<"\tReading defs info: "<<th.getDif()<<std::endl;
_log0<<"\tReading defs info: "<<th.getDif()<<std::endl;
readObjects(bufor, i);
log0<<"\tReading objects: "<<th.getDif()<<std::endl;
_log0<<"\tReading objects: "<<th.getDif()<<std::endl;
readEvents(bufor, i);
log0<<"\tReading events: "<<th.getDif()<<std::endl;
_log0<<"\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;
_log0<<"\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;
_log0<<"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;
_log0<<"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;
_log0 << "\tOur map checksum: "<<result.checksum() << std::endl;
initFromBytes(initTable);
}
@ -2465,4 +2465,4 @@ bool Mapa::isInTheMap( int3 pos )
if(pos.x<0 || pos.y<0 || pos.z<0 || pos.x >= width || pos.y >= height || pos.z > twoLevel)
return false;
else return true;
}
}

View File

@ -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;
_log3 << "\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;
_log0<<"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;
_log1 << "*HUGE* Warning - missing town def for " << i << std::endl;
map->defs.insert(n);
}
log0<<"\tLoading town def info: "<<th.getDif()<<std::endl;
_log0<<"\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;
_log0<<"\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;
_log0<<"\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;
_log0<<"\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;
_log0<<"\tPreparing FoW, roads, rivers,borders: "<<th.getDif()<<std::endl;
initObjectRects();
log0<<"\tMaking object rects: "<<th.getDif()<<std::endl;
_log0<<"\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)

View File

@ -341,7 +341,7 @@ void CGameHandler::handleConnection(std::set<int> players, CConnection &c)
{
case 99: //end!
{
log0 << "We have been requested to close.\n";
_log0 << "We have been requested to close.\n";
exit(0);
}
case 100: //my interface ended its turn
@ -967,12 +967,12 @@ upgend:
}
catch (const std::exception& e)
{
log1 << e.what() << std::endl;
_log1 << e.what() << std::endl;
end2 = true;
}
catch (const std::exception * e)
{
log1 << e->what()<< std::endl;
_log1 << 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;
_log0<<"Unable to open battleStartpos.txt!"<<std::endl;
}
std::string dump;
positions>>dump; positions>>dump;
@ -1376,4 +1376,4 @@ void CGameHandler::giveSpells( const CGTownInstance *t, const CGHeroInstance *h
}
if(cs.spells.size())
sendAndApply(&cs);
}
}

View File

@ -22,14 +22,14 @@ using namespace boost;
using namespace boost::asio;
using namespace boost::asio::ip;
namespace intpr = boost::interprocess;
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;
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;