mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	Apply command review suggestions + minor cleanup
This commit is contained in:
		| @@ -102,17 +102,12 @@ void ClientCommandManager::handleControlAi(const std::string &colorName) | ||||
|  | ||||
| void ClientCommandManager::processCommand(const std::string &message, bool calledFromIngameConsole) | ||||
| { | ||||
| 	std::istringstream readed; | ||||
| 	readed.str(message); | ||||
| 	std::istringstream singleWordBuffer; | ||||
| 	singleWordBuffer.str(message); | ||||
| 	std::string commandName; | ||||
| 	readed >> commandName; | ||||
| 	singleWordBuffer >> commandName; | ||||
| 	currentCallFromIngameConsole = calledFromIngameConsole; | ||||
|  | ||||
| // Check mantis issue 2292 for details | ||||
| //	if(LOCPLINT && LOCPLINT->cingconsole) | ||||
| //		LOCPLINT->cingconsole->print(message); | ||||
|  | ||||
|  | ||||
| 	if(message==std::string("die, fool")) | ||||
| 	{ | ||||
| 		exit(EXIT_SUCCESS); | ||||
| @@ -120,7 +115,7 @@ void ClientCommandManager::processCommand(const std::string &message, bool calle | ||||
| 	else if(commandName == std::string("activate")) | ||||
| 	{ | ||||
| 		int what; | ||||
| 		readed >> what; | ||||
| 		singleWordBuffer >> what; | ||||
| 		switch (what) | ||||
| 		{ | ||||
| 			case 0: | ||||
| @@ -162,14 +157,14 @@ void ClientCommandManager::processCommand(const std::string &message, bool calle | ||||
| 			return; | ||||
| 		} | ||||
| 		std::string fname; | ||||
| 		readed >> fname; | ||||
| 		singleWordBuffer >> fname; | ||||
| 		CSH->client->save(fname); | ||||
| 	} | ||||
| //	else if(commandName=="load") | ||||
| //	{ | ||||
| //		// TODO: this code should end the running game and manage to call startGame instead | ||||
| //		std::string fname; | ||||
| //		readed >> fname; | ||||
| //		singleWordBuffer >> fname; | ||||
| //		CSH->client->loadGame(fname); | ||||
| //	} | ||||
| 	else if(message=="convert txt") | ||||
| @@ -351,7 +346,7 @@ void ClientCommandManager::processCommand(const std::string &message, bool calle | ||||
| 	{ | ||||
| 		std::string what; | ||||
| 		int id1, id2; | ||||
| 		readed >> what >> id1 >> id2; | ||||
| 		singleWordBuffer >> what >> id1 >> id2; | ||||
| 		if(what == "hs") | ||||
| 		{ | ||||
| 			for(const CGHeroInstance *h : LOCPLINT->cb->getHeroesInfo()) | ||||
| @@ -363,11 +358,11 @@ void ClientCommandManager::processCommand(const std::string &message, bool calle | ||||
| 	else if (commandName == "set") | ||||
| 	{ | ||||
| 		std::string what, value; | ||||
| 		readed >> what; | ||||
| 		singleWordBuffer >> what; | ||||
|  | ||||
| 		Settings config = settings.write["session"][what]; | ||||
|  | ||||
| 		readed >> value; | ||||
| 		singleWordBuffer >> value; | ||||
|  | ||||
| 		if (value == "on") | ||||
| 		{ | ||||
| @@ -383,14 +378,14 @@ void ClientCommandManager::processCommand(const std::string &message, bool calle | ||||
| 	else if(commandName == "unlock") | ||||
| 	{ | ||||
| 		std::string mxname; | ||||
| 		readed >> mxname; | ||||
| 		singleWordBuffer >> mxname; | ||||
| 		if(mxname == "pim" && LOCPLINT) | ||||
| 			LOCPLINT->pim->unlock(); | ||||
| 	} | ||||
| 	else if(commandName == "def2bmp") | ||||
| 	{ | ||||
| 		std::string URI; | ||||
| 		readed >> URI; | ||||
| 		singleWordBuffer >> URI; | ||||
| 		std::unique_ptr<CAnimation> anim = std::make_unique<CAnimation>(URI); | ||||
| 		anim->preload(); | ||||
| 		anim->exportBitmaps(VCMIDirs::get().userExtractedPath()); | ||||
| @@ -398,7 +393,7 @@ void ClientCommandManager::processCommand(const std::string &message, bool calle | ||||
| 	else if(commandName == "extract") | ||||
| 	{ | ||||
| 		std::string URI; | ||||
| 		readed >> URI; | ||||
| 		singleWordBuffer >> URI; | ||||
|  | ||||
| 		if (CResourceHandler::get()->existsResource(ResourceID(URI))) | ||||
| 		{ | ||||
| @@ -416,7 +411,7 @@ void ClientCommandManager::processCommand(const std::string &message, bool calle | ||||
| 	else if(commandName == "setBattleAI") | ||||
| 	{ | ||||
| 		std::string fname; | ||||
| 		readed >> fname; | ||||
| 		singleWordBuffer >> fname; | ||||
| 		printCommandMessage("Will try loading that AI to see if it is correct name...\n"); | ||||
| 		try | ||||
| 		{ | ||||
| @@ -433,10 +428,9 @@ void ClientCommandManager::processCommand(const std::string &message, bool calle | ||||
| 			printCommandMessage("Setting not changed, AI not found or invalid!", ELogLevel::WARN); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	Settings session = settings.write["session"]; | ||||
| 	if(commandName == "autoskip") | ||||
| 	else if(commandName == "autoskip") | ||||
| 	{ | ||||
| 		Settings session = settings.write["session"]; | ||||
| 		session["autoSkip"].Bool() = !session["autoSkip"].Bool(); | ||||
| 	} | ||||
| 	else if(commandName == "gosolo") | ||||
| @@ -446,17 +440,15 @@ void ClientCommandManager::processCommand(const std::string &message, bool calle | ||||
| 	else if(commandName == "controlai") | ||||
| 	{ | ||||
| 		std::string colorName; | ||||
| 		readed >> colorName; | ||||
| 		singleWordBuffer >> colorName; | ||||
| 		boost::to_lower(colorName); | ||||
|  | ||||
| 		ClientCommandManager::handleControlAi(colorName); | ||||
| 	} | ||||
| 	// Check mantis issue 2292 for details | ||||
| /* 	else if(client && client->serv && client->serv->connected && LOCPLINT) //send to server | ||||
| 	else | ||||
| 	{ | ||||
| 		boost::unique_lock<boost::recursive_mutex> un(*CPlayerInterface::pim); | ||||
| 		LOCPLINT->cb->sendMessage(message); | ||||
| 	}*/ | ||||
| 		printCommandMessage("Command not found :(", ELogLevel::ERROR); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| void ClientCommandManager::giveTurn(const PlayerColor &colorIdentifier) | ||||
|   | ||||
| @@ -15,7 +15,7 @@ class PlayerColor; | ||||
| VCMI_LIB_NAMESPACE_END | ||||
| class CIntObject; | ||||
|  | ||||
| class ClientCommandManager | ||||
| class ClientCommandManager //take mantis #2292 issue about account if thinking about handling cheats from command-line | ||||
| { | ||||
| 	static bool currentCallFromIngameConsole; | ||||
|  | ||||
|   | ||||
| @@ -1152,7 +1152,6 @@ void CInGameConsole::endEnteringText(bool processEnteredText) | ||||
| 	if(processEnteredText) | ||||
| 	{ | ||||
| 		std::string txt = enteredText.substr(0, enteredText.size()-1); | ||||
| 		LOCPLINT->cb->sendMessage(txt, LOCPLINT->getSelection()); | ||||
| 		previouslyEntered.push_back(txt); | ||||
|  | ||||
| 		if(txt.at(0) == '/') | ||||
| @@ -1161,6 +1160,8 @@ void CInGameConsole::endEnteringText(bool processEnteredText) | ||||
| 			boost::thread clientCommandThread(ClientCommandManager::processCommand, txt.substr(1), true); | ||||
| 			clientCommandThread.detach(); | ||||
| 		} | ||||
| 		else | ||||
| 			LOCPLINT->cb->sendMessage(txt, LOCPLINT->getSelection()); | ||||
| 	} | ||||
| 	enteredText.clear(); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user