diff --git a/client/CMT.cpp b/client/CMT.cpp index a9e5d4b17..de916b0b8 100644 --- a/client/CMT.cpp +++ b/client/CMT.cpp @@ -240,6 +240,7 @@ int main(int argc, char** argv) ("autoSkip", "automatically skip turns in GUI") ("disable-video", "disable video player") ("nointro,i", "skips intro movies") + ("donotstartserver,d","do not attempt to start server and just connect to it instead server") ("loadserver","specifies we are the multiplayer server for loaded games") ("loadnumplayers",po::value(),"specifies the number of players connecting to a multiplayer game") ("loadhumanplayerindices",po::value>(),"Indexes of human players (0=Red, etc.)") @@ -277,6 +278,10 @@ int main(int argc, char** argv) gNoGUI = true; vm.insert(std::pair("onlyAI", po::variable_value())); } + if(vm.count("donotstartserver")) + { + CServerHandler::DO_NOT_START_SERVER = true; + } // Have effect on X11 system only (Linux). // For whatever reason in fullscreen mode SDL takes "raw" mouse input from DGA X11 extension diff --git a/client/CPreGame.cpp b/client/CPreGame.cpp index 1ae57cbf2..3b629652a 100644 --- a/client/CPreGame.cpp +++ b/client/CPreGame.cpp @@ -719,6 +719,10 @@ CSelectionScreen::CSelectionScreen(CMenuScreen::EState Type, CMenuScreen::EMulti else if(current) { SelectMap sm(*current); + // FIXME: Super dirty hack to avoid crash on multiplayer game start. + // There is some issues with TriggeredEvent serialization that cause it. + // We'll look into them once refactored serializer fixed and merged + sm.mapInfo->mapHeader->triggeredEvents.clear(); *serv << &sm; UpdateStartOptions uso(sInfo); diff --git a/client/Client.cpp b/client/Client.cpp index 19f803f61..6aa14d45d 100644 --- a/client/Client.cpp +++ b/client/Client.cpp @@ -928,10 +928,15 @@ std::string CClient::aiNameForPlayer(const PlayerSettings &ps, bool battleAI) return goodAI; } +bool CServerHandler::DO_NOT_START_SERVER = false; void CServerHandler::startServer() { + if(DO_NOT_START_SERVER) + return; + th.update(); + serverThread = new boost::thread(&CServerHandler::callServer, this); //runs server executable; if(verbose) logNetwork->infoStream() << "Setting up thread calling server: " << th.getDiff(); @@ -939,6 +944,9 @@ void CServerHandler::startServer() void CServerHandler::waitForServer() { + if(DO_NOT_START_SERVER) + return; + if(!serverThread) startServer(); diff --git a/client/Client.h b/client/Client.h index 920638a00..314ac5d2c 100644 --- a/client/Client.h +++ b/client/Client.h @@ -42,6 +42,8 @@ class CServerHandler private: void callServer(); //calls server via system(), should be called as thread public: + static bool DO_NOT_START_SERVER; + CStopWatch th; boost::thread *serverThread; //thread that called system to run server SharedMem *shared; //interprocess memory (for waiting for server)