mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	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.
This commit is contained in:
		| @@ -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 | ||||
|   | ||||
| @@ -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); | ||||
|   | ||||
| @@ -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(); | ||||
|  | ||||
|   | ||||
| @@ -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) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user