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