From 856698bd80dbf7af6bda0b19a2d2940e1208600e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20W=2E=20Urba=C5=84czyk?= Date: Fri, 19 Sep 2008 08:16:19 +0000 Subject: [PATCH] * 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 --- AdventureMapButton.cpp | 4 +- AdventureMapButton.h | 2 +- CCallback.cpp | 6 +-- CCallback.h | 4 +- CConsoleHandler.cpp | 4 +- CHeroWindow.cpp | 14 +++---- CMT.cpp | 78 +++++++++++++++++--------------------- CPreGame.cpp | 14 +++---- client/Client.cpp | 80 +++++++++++++++++++-------------------- client/Graphics.cpp | 2 +- client/VCMI_client.vcproj | 4 -- global.h | 24 ++++++------ hch/CLodHandler.cpp | 14 +++---- hch/CObjectHandler.cpp | 1 - hch/CObjectHandler.h | 2 +- lib/Connection.cpp | 16 ++++---- lib/VCMI_Lib.cpp | 32 ++++++++-------- map.cpp | 24 ++++++------ mapHandler.cpp | 18 ++++----- server/CGameHandler.cpp | 10 ++--- server/CVCMIServer.cpp | 8 ---- 21 files changed, 171 insertions(+), 190 deletions(-) diff --git a/AdventureMapButton.cpp b/AdventureMapButton.cpp index af0b56125..f2c712822 100644 --- a/AdventureMapButton.cpp +++ b/AdventureMapButton.cpp @@ -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 &onSelect, const CFunctionList &onDeselect, const std::map &Name, const std::string &HelpBox, bool playerColoredButton, const std::string &defName, std::vector * add, int x, int y, bool activ ) { + onlyOn = false; init(onSelect,Name,HelpBox,playerColoredButton,defName,add,x,y,activ); callback2 = onDeselect; } diff --git a/AdventureMapButton.h b/AdventureMapButton.h index d65fd14df..cc1686769 100644 --- a/AdventureMapButton.h +++ b/AdventureMapButton.h @@ -34,7 +34,7 @@ class CHighlightableButton { public: CHighlightableButton(const CFunctionList &onSelect, const CFunctionList &onDeselect, const std::map &Name, const std::string &HelpBox, bool playerColoredButton, const std::string &defName, std::vector * add, int x, int y, bool activ ); - bool selected; + bool selected, onlyOn; CFunctionList callback2; //when disselecting void select(bool on); void clickLeft (tribool down); diff --git a/CCallback.cpp b/CCallback.cpp index c315dcfc6..ff75ec386 100644 --- a/CCallback.cpp +++ b/CCallback.cpp @@ -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(hero)->army.formation = tight; + *cl->serv << ui16(512) << hero->id << ui8(tight); } \ No newline at end of file diff --git a/CCallback.h b/CCallback.h index 6880157d9..bebbd01f2 100644 --- a/CCallback.h +++ b/CCallback.h @@ -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); diff --git a/CConsoleHandler.cpp b/CConsoleHandler.cpp index e5b201dc6..23770cc54 100644 --- a/CConsoleHandler.cpp +++ b/CConsoleHandler.cpp @@ -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"; } diff --git a/CHeroWindow.cpp b/CHeroWindow.cpp index 227de508c..5d984b219 100644 --- a/CHeroWindow.cpp +++ b/CHeroWindow.cpp @@ -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(), 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(); } diff --git a/CMT.cpp b/CMT.cpp index e9167f847..2f8ea7809 100644 --- a/CMT.cpp +++ b/CMT.cpp @@ -51,14 +51,6 @@ extern SDL_Surface * CSDL_Ext::std32bppSurface; std::queue 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: "<initMusics(); //audio initialized cgi->mush = mush; - THC _log0<<"\tInitializing sound: "<spriteh = new CLodHandler(); cgi->spriteh->init("Data" PATHSEPARATOR "H3sprite.lod","Sprites"); BitmapHandler::bitmaph = cgi->bitmaph = new CLodHandler; cgi->bitmaph->init("Data" PATHSEPARATOR "H3bitmap.lod","Data"); - THC _log0<<"Loading .lod files: "<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: "<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: "<loadAbilities(); cgi->abilh = abilh; - _log0<<"\tAbility handler: "< animacje; for(std::vector::iterator i = cgi->heroh->heroClasses.begin();i!=cgi->heroh->heroClasses.end();i++) animacje.push_back(&((*i)->*(&CHeroClass::moveAnim))); graphics->loadHeroAnim(animacje); - _log0<<"\tHero animations: "<generaltexth = new CGeneralTextHandler; cgi->generaltexth->load(); - _log0<<"Preparing more handlers: "<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: "<pathf = new CPathfinder(); - _log0<<"\tPathfinder: "< 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()<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: "<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;ientries.size(); i++) @@ -302,9 +294,9 @@ void processCommand(const std::string &message) if(p2!=curp) { curp = p2; - _log0<<"\r"< &pliczkiTemp, int &index) else break; } gzclose(tempf); - if(iii<50) {_log3<<"\t\tWarning: corrupted map file: "<loadTexts(); CGI->preth=preth; - _log0<<"\tCPreGame: loading txts: "<state = new CGameState(); - _log0 <<"\tGamestate: "<> mapname >> sum >> seed; - _log0 <<"\tSending/Getting info to/from the server: "<checksum << std::endl; + tlog0 <<"Reading and detecting map file (together): "<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: "<state; gs->scenarioOps = si; gs->init(si,mapa,seed); CGI->mh = new CMapHandler(); - _log0 <<"Initializing GameState (together): "<mh->map = mapa; - _log0 <<"Creating mapHandler: "<mh->init(); - _log0 <<"Initializing mapHandler (together): "<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."<> n; - _log5 << "New day: "<<(unsigned)n.day<<". Applying changes... "; + tlog5 << "New day: "<<(unsigned)n.day<<". Applying changes... "; gs->apply(&n); - _log5 << "done!"<> sr; - _log5 << "Set amount of "<objh->restypes[sr.resid] + tlog5 << "Set amount of "<objh->restypes[sr.resid] << " of player "<<(unsigned)sr.player <<" to "<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<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"<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"<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 "<apply(&vc); break; } @@ -273,7 +273,7 @@ void CClient::process(int what) if(obj->ID == 34) { CGHeroInstance *h = static_cast(obj); - _log5 << "Removing hero with id = "<<(unsigned)rh.id<result<<"\tPosition "<end<result<<"\tPosition "<end<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::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(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 "<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) <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!" <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 " < comps; for(int i=0;i> ynd; - _log5 << "Showing yes/no dialog " < comps; for(int i=0;i> bs; //uses new to allocate memory for battleInfo - must be deleted when battle is over - _log5 << "Starting battle!" <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 <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 <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 <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 "<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 <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(*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"; } diff --git a/client/Graphics.cpp b/client/Graphics.cpp index a0f4580a8..8ecca3e21 100644 --- a/client/Graphics.cpp +++ b/client/Graphics.cpp @@ -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: "< - - diff --git a/global.h b/global.h index 7140d0f34..744d361c8 100644 --- a/global.h +++ b/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 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; \ } diff --git a/hch/CLodHandler.cpp b/hch/CLodHandler.cpp index fadf1987c..3e3c77788 100644 --- a/hch/CLodHandler.cpp +++ b/hch/CLodHandler.cpp @@ -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: "<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: "<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 < _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: "<loadArtifacts(); VLC->arth = arth; - _log0<<"\tArtifact handler: "<loadCreatures(); VLC->creh = creh; - _log0<<"\tCreature handler: "<townh = new CTownHandler; VLC->townh->loadNames(); - _log0<<"\tTown handler: "<loadObjects(); VLC->objh = objh; - _log0<<"\tObject handler: "<dobjinfo = new CDefObjInfoHandler; VLC->dobjinfo->load(); - _log0<<"\tDef information handler: "<buildh = new CBuildingHandler; VLC->buildh->loadBuildings(); - _log0<<"\tBuilding handler: "<loadSpells(); VLC->spellh = spellh; - _log0<<"\tSpell handler: "< mapstr; int pom; while((pom=gzgetc(map))>=0) @@ -547,11 +547,11 @@ Mapa::Mapa(std::string filename) { initTable[ss] = mapstr[ss]; } - _log0<<"done."<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; diff --git a/mapHandler.cpp b/mapHandler.cpp index 773a1fb95..f4fccedaf 100644 --- a/mapHandler.cpp +++ b/mapHandler.cpp @@ -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; yyhandler->ourImages.size(); ++yy) @@ -484,7 +484,7 @@ void CMapHandler::init() timeHandler th; th.getDif(); loadDefs(); //loading castles' defs - _log0<<"Reading terrain defs: "<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: "<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: "<players[i].heroesNames[j].heroID); } } - _log0<<"\tChecking used heroes: "<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: "< > > * visibilityMap, bool otherHeroAnim, unsigned char heroAnim, SDL_Surface * extSurf, SDL_Rect * extRect) diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index cce7e5c84..7f0204f38 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -341,7 +341,7 @@ void CGameHandler::handleConnection(std::set 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!"<>dump; positions>>dump; diff --git a/server/CVCMIServer.cpp b/server/CVCMIServer.cpp index 1e92901cc..c68b9a6a8 100644 --- a/server/CVCMIServer.cpp +++ b/server/CVCMIServer.cpp @@ -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;