mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	Change ClientCommandManager to become non-static
This commit is contained in:
		| @@ -239,7 +239,14 @@ int main(int argc, char * argv[]) | |||||||
| 	std::cout.flags(std::ios::unitbuf); | 	std::cout.flags(std::ios::unitbuf); | ||||||
| #ifndef VCMI_IOS | #ifndef VCMI_IOS | ||||||
| 	console = new CConsoleHandler(); | 	console = new CConsoleHandler(); | ||||||
| 	*console->cb = ClientCommandManager::processCommand; |  | ||||||
|  | 	auto callbackFunction = [](std::string buffer, bool calledFromIngameConsole) | ||||||
|  | 	{ | ||||||
|  | 		ClientCommandManager commandController; | ||||||
|  | 		commandController.processCommand(buffer, calledFromIngameConsole); | ||||||
|  | 	}; | ||||||
|  |  | ||||||
|  | 	*console->cb = callbackFunction; | ||||||
| 	console->start(); | 	console->start(); | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|   | |||||||
| @@ -33,8 +33,6 @@ | |||||||
| #include "../lib/ScriptHandler.h" | #include "../lib/ScriptHandler.h" | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| bool ClientCommandManager::currentCallFromIngameConsole; |  | ||||||
|  |  | ||||||
| void ClientCommandManager::handleGoSolo() | void ClientCommandManager::handleGoSolo() | ||||||
| { | { | ||||||
| 	Settings session = settings.write["session"]; | 	Settings session = settings.write["session"]; | ||||||
|   | |||||||
| @@ -17,15 +17,15 @@ class CIntObject; | |||||||
|  |  | ||||||
| class ClientCommandManager //take mantis #2292 issue about account if thinking about handling cheats from command-line | class ClientCommandManager //take mantis #2292 issue about account if thinking about handling cheats from command-line | ||||||
| { | { | ||||||
| 	static bool currentCallFromIngameConsole; | 	bool currentCallFromIngameConsole; | ||||||
|  |  | ||||||
| 	static void giveTurn(const PlayerColor &color); | 	void giveTurn(const PlayerColor &color); | ||||||
| 	static void printInfoAboutInterfaceObject(const CIntObject *obj, int level); | 	void printInfoAboutInterfaceObject(const CIntObject *obj, int level); | ||||||
| 	static void printCommandMessage(const std::string &commandMessage, ELogLevel::ELogLevel messageType = ELogLevel::NOT_SET); | 	void printCommandMessage(const std::string &commandMessage, ELogLevel::ELogLevel messageType = ELogLevel::NOT_SET); | ||||||
| 	static void handleGoSolo(); | 	void handleGoSolo(); | ||||||
| 	static void handleControlAi(const std::string &colorName); | 	void handleControlAi(const std::string &colorName); | ||||||
|  |  | ||||||
| public: | public: | ||||||
| 	ClientCommandManager() = delete; | 	ClientCommandManager() = default; | ||||||
| 	static void processCommand(const std::string &message, bool calledFromIngameConsole); | 	void processCommand(const std::string &message, bool calledFromIngameConsole); | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -1154,7 +1154,13 @@ void CInGameConsole::endEnteringText(bool processEnteredText) | |||||||
| 		if(txt.at(0) == '/') | 		if(txt.at(0) == '/') | ||||||
| 		{ | 		{ | ||||||
| 			//some commands like gosolo don't work when executed from GUI thread | 			//some commands like gosolo don't work when executed from GUI thread | ||||||
| 			boost::thread clientCommandThread(ClientCommandManager::processCommand, txt.substr(1), true); | 			auto threadFunction = [=]() | ||||||
|  | 			{ | ||||||
|  | 				ClientCommandManager commandController; | ||||||
|  | 				commandController.processCommand(txt.substr(1), true); | ||||||
|  | 			}; | ||||||
|  |  | ||||||
|  | 			boost::thread clientCommandThread(threadFunction); | ||||||
| 			clientCommandThread.detach(); | 			clientCommandThread.detach(); | ||||||
| 		} | 		} | ||||||
| 		else | 		else | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user