소스 검색

Client: add donotstartserver option. Alternative way to start a game

Option is useful for server profiling also let me test MP over network and much more.
Also there is issues with boost::interprocess on some systems under Windows and this is the way to bypass them.
Arseniy Shestakov 9 년 전
부모
커밋
1cbe9e1b8b
4개의 변경된 파일19개의 추가작업 그리고 0개의 파일을 삭제
  1. 5 0
      client/CMT.cpp
  2. 4 0
      client/CPreGame.cpp
  3. 8 0
      client/Client.cpp
  4. 2 0
      client/Client.h

+ 5 - 0
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<int>(),"specifies the number of players connecting to a multiplayer game")
         ("loadhumanplayerindices",po::value<std::vector<int>>(),"Indexes of human players (0=Red, etc.)")
@@ -277,6 +278,10 @@ int main(int argc, char** argv)
 		gNoGUI = true;
 		vm.insert(std::pair<std::string, po::variable_value>("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

+ 4 - 0
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);

+ 8 - 0
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();
 

+ 2 - 0
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)