ClientCommandManager.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686
  1. /*
  2. * ClientCommandManager.cpp, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #include "StdInc.h"
  11. #include "ClientCommandManager.h"
  12. #include "Client.h"
  13. #include "adventureMap/CInGameConsole.h"
  14. #include "CPlayerInterface.h"
  15. #include "PlayerLocalState.h"
  16. #include "CServerHandler.h"
  17. #include "GameEngine.h"
  18. #include "GameInstance.h"
  19. #include "gui/WindowHandler.h"
  20. #include "render/IRenderHandler.h"
  21. #include "ClientNetPackVisitors.h"
  22. #include "../lib/callback/CCallback.h"
  23. #include "../lib/callback/CGlobalAI.h"
  24. #include "../lib/callback/CDynLibHandler.h"
  25. #include "../lib/CConfigHandler.h"
  26. #include "../lib/gameState/CGameState.h"
  27. #include "../lib/CPlayerState.h"
  28. #include "../lib/constants/StringConstants.h"
  29. #include "../lib/callback/EditorCallback.h"
  30. #include "../lib/campaign/CampaignHandler.h"
  31. #include "../lib/mapping/CMapService.h"
  32. #include "../lib/mapping/CMap.h"
  33. #include "windows/CCastleInterface.h"
  34. #include "../lib/mapObjects/CGHeroInstance.h"
  35. #include "render/CAnimation.h"
  36. #include "../lib/texts/CGeneralTextHandler.h"
  37. #include "../lib/filesystem/Filesystem.h"
  38. #include "../lib/modding/CModHandler.h"
  39. #include "../lib/modding/ContentTypeHandler.h"
  40. #include "../lib/modding/ModUtility.h"
  41. #include "../lib/serializer/GameConnection.h"
  42. #include "../lib/VCMIDirs.h"
  43. #include "../lib/logging/VisualLogger.h"
  44. #ifdef SCRIPTING_ENABLED
  45. #include "../lib/ScriptHandler.h"
  46. #endif
  47. void ClientCommandManager::handleQuitCommand()
  48. {
  49. exit(EXIT_SUCCESS);
  50. }
  51. void ClientCommandManager::handleSaveCommand(std::istringstream & singleWordBuffer)
  52. {
  53. if(!GAME->server().client)
  54. {
  55. printCommandMessage("Game is not in playing state");
  56. return;
  57. }
  58. std::string saveFilename;
  59. singleWordBuffer >> saveFilename;
  60. GAME->interface()->cb->save(saveFilename, false);
  61. printCommandMessage("Game saved as: " + saveFilename);
  62. }
  63. void ClientCommandManager::handleLoadCommand(std::istringstream& singleWordBuffer)
  64. {
  65. // TODO: this code should end the running game and manage to call startGame instead
  66. //std::string fname;
  67. //singleWordBuffer >> fname;
  68. //GAME->server().client->loadGame(fname);
  69. }
  70. void ClientCommandManager::handleGoSoloCommand()
  71. {
  72. Settings session = settings.write["session"];
  73. std::scoped_lock interfaceLock(ENGINE->interfaceMutex);
  74. if(!GAME->server().client)
  75. {
  76. printCommandMessage("Game is not in playing state");
  77. return;
  78. }
  79. if(session["aiSolo"].Bool())
  80. {
  81. // unlikely it will work but just in case to be consistent
  82. for(auto & color : GAME->server().getAllClientPlayers(GAME->server().logicConnection->connectionID))
  83. {
  84. if(color.isValidPlayer() && GAME->server().client->gameInfo().getStartInfo()->playerInfos.at(color).isControlledByHuman())
  85. {
  86. GAME->server().client->installNewPlayerInterface(std::make_shared<CPlayerInterface>(color), color);
  87. }
  88. }
  89. }
  90. else
  91. {
  92. PlayerColor currentColor = GAME->interface()->playerID;
  93. GAME->server().client->removeGUI();
  94. for(auto & color : GAME->server().getAllClientPlayers(GAME->server().logicConnection->connectionID))
  95. {
  96. if(color.isValidPlayer() && GAME->server().client->gameInfo().getStartInfo()->playerInfos.at(color).isControlledByHuman())
  97. {
  98. auto AiToGive = GAME->server().client->aiNameForPlayer(*GAME->server().client->gameInfo().getPlayerSettings(color), false, false);
  99. printCommandMessage("Player " + color.toString() + " will be lead by " + AiToGive, ELogLevel::INFO);
  100. GAME->server().client->installNewPlayerInterface(CDynLibHandler::getNewAI(AiToGive), color);
  101. }
  102. }
  103. ENGINE->windows().totalRedraw();
  104. giveTurn(currentColor);
  105. }
  106. session["aiSolo"].Bool() = !session["aiSolo"].Bool();
  107. }
  108. void ClientCommandManager::handleAutoskipCommand()
  109. {
  110. Settings session = settings.write["session"];
  111. session["autoSkip"].Bool() = !session["autoSkip"].Bool();
  112. }
  113. void ClientCommandManager::handleControlaiCommand(std::istringstream& singleWordBuffer)
  114. {
  115. std::string colorName;
  116. singleWordBuffer >> colorName;
  117. boost::to_lower(colorName);
  118. std::scoped_lock interfaceLock(ENGINE->interfaceMutex);
  119. if(!GAME->server().client)
  120. {
  121. printCommandMessage("Game is not in playing state");
  122. return;
  123. }
  124. PlayerColor color;
  125. if(GAME->interface())
  126. color = GAME->interface()->playerID;
  127. for(auto & elem : GAME->server().client->gameState().players)
  128. {
  129. if(!elem.first.isValidPlayer()
  130. || elem.second.human
  131. || (colorName.length() && elem.first.getNum() != vstd::find_pos(GameConstants::PLAYER_COLOR_NAMES, colorName)))
  132. {
  133. continue;
  134. }
  135. GAME->server().client->removeGUI();
  136. GAME->server().client->installNewPlayerInterface(std::make_shared<CPlayerInterface>(elem.first), elem.first);
  137. }
  138. ENGINE->windows().totalRedraw();
  139. if(color != PlayerColor::NEUTRAL)
  140. giveTurn(color);
  141. }
  142. void ClientCommandManager::handleSetBattleAICommand(std::istringstream& singleWordBuffer)
  143. {
  144. std::string aiName;
  145. singleWordBuffer >> aiName;
  146. printCommandMessage("Will try loading that AI to see if it is correct name...\n");
  147. try
  148. {
  149. if(auto ai = CDynLibHandler::getNewBattleAI(aiName)) //test that given AI is indeed available... heavy but it is easy to make a typo and break the game
  150. {
  151. Settings neutralAI = settings.write["ai"]["combatNeutralAI"];
  152. neutralAI->String() = aiName;
  153. printCommandMessage("Setting changed, from now the battle ai will be " + aiName + "!\n");
  154. }
  155. }
  156. catch(std::exception &e)
  157. {
  158. printCommandMessage("Failed opening " + aiName + ": " + e.what(), ELogLevel::WARN);
  159. printCommandMessage("Setting not changed, AI not found or invalid!", ELogLevel::WARN);
  160. }
  161. }
  162. void ClientCommandManager::handleRedrawCommand()
  163. {
  164. ENGINE->windows().totalRedraw();
  165. }
  166. void ClientCommandManager::handleTranslateGameCommand(bool onlyMissing)
  167. {
  168. std::map<std::string, std::map<std::string, std::string>> textsByMod;
  169. LIBRARY->generaltexth->exportAllTexts(textsByMod, onlyMissing);
  170. const boost::filesystem::path outPath = VCMIDirs::get().userExtractedPath() / ( onlyMissing ? "translationMissing" : "translation");
  171. boost::filesystem::create_directories(outPath);
  172. for(const auto & modEntry : textsByMod)
  173. {
  174. JsonNode output;
  175. for(const auto & stringEntry : modEntry.second)
  176. {
  177. if(boost::algorithm::starts_with(stringEntry.first, "map."))
  178. continue;
  179. if(boost::algorithm::starts_with(stringEntry.first, "campaign."))
  180. continue;
  181. output[stringEntry.first].String() = stringEntry.second;
  182. }
  183. if (!output.isNull())
  184. {
  185. const boost::filesystem::path filePath = outPath / (modEntry.first + ".json");
  186. std::ofstream file(filePath.c_str());
  187. file << output.toString();
  188. }
  189. }
  190. printCommandMessage("Translation export complete");
  191. printCommandMessage("Extracted files can be found in " + outPath.string() + " directory\n");
  192. }
  193. void ClientCommandManager::handleTranslateMapsCommand()
  194. {
  195. CMapService mapService;
  196. printCommandMessage("Searching for available maps");
  197. std::unordered_set<ResourcePath> mapList = CResourceHandler::get()->getFilteredFiles([&](const ResourcePath & ident)
  198. {
  199. return ident.getType() == EResType::MAP;
  200. });
  201. std::vector<std::unique_ptr<CMap>> loadedMaps;
  202. std::vector<std::shared_ptr<CampaignState>> loadedCampaigns;
  203. printCommandMessage("Loading maps for export");
  204. for (auto const & mapName : mapList)
  205. {
  206. try
  207. {
  208. EditorCallback cb(nullptr);
  209. // load and drop loaded map - we only need loader to run over all maps
  210. loadedMaps.push_back(mapService.loadMap(mapName, &cb));
  211. }
  212. catch(std::exception & e)
  213. {
  214. logGlobal->warn("Map %s is invalid. Message: %s", mapName.getName(), e.what());
  215. }
  216. }
  217. printCommandMessage("Searching for available campaigns");
  218. std::unordered_set<ResourcePath> campaignList = CResourceHandler::get()->getFilteredFiles([&](const ResourcePath & ident)
  219. {
  220. return ident.getType() == EResType::CAMPAIGN;
  221. });
  222. logGlobal->info("Loading campaigns for export");
  223. for (auto const & campaignName : campaignList)
  224. {
  225. try
  226. {
  227. loadedCampaigns.push_back(CampaignHandler::getCampaign(campaignName.getName()));
  228. for (auto const & part : loadedCampaigns.back()->allScenarios())
  229. {
  230. EditorCallback cb(nullptr);
  231. loadedCampaigns.back()->getMap(part, &cb);
  232. }
  233. }
  234. catch(std::exception & e)
  235. {
  236. logGlobal->warn("Campaign %s is invalid. Message: %s", campaignName.getName(), e.what());
  237. }
  238. }
  239. std::map<std::string, std::map<std::string, std::string>> textsByMod;
  240. LIBRARY->generaltexth->exportAllTexts(textsByMod, false);
  241. const boost::filesystem::path outPath = VCMIDirs::get().userExtractedPath() / "translation";
  242. boost::filesystem::create_directories(outPath);
  243. for(const auto & modEntry : textsByMod)
  244. {
  245. JsonNode output;
  246. for(const auto & stringEntry : modEntry.second)
  247. {
  248. if(boost::algorithm::starts_with(stringEntry.first, "map."))
  249. output[stringEntry.first].String() = stringEntry.second;
  250. if(boost::algorithm::starts_with(stringEntry.first, "campaign."))
  251. output[stringEntry.first].String() = stringEntry.second;
  252. }
  253. if (!output.isNull())
  254. {
  255. const boost::filesystem::path filePath = outPath / (modEntry.first + ".json");
  256. std::ofstream file(filePath.c_str());
  257. file << output.toString();
  258. }
  259. }
  260. printCommandMessage("Translation export complete");
  261. printCommandMessage("Extracted files can be found in " + outPath.string() + " directory\n");
  262. }
  263. void ClientCommandManager::handleGetConfigCommand()
  264. {
  265. printCommandMessage("Command accepted.\t");
  266. const boost::filesystem::path outPath = VCMIDirs::get().userExtractedPath() / "configuration";
  267. boost::filesystem::create_directories(outPath);
  268. const std::vector<std::string> contentNames = { "heroClasses", "artifacts", "creatures", "factions", "objects", "heroes", "spells", "skills" };
  269. for(auto contentName : contentNames)
  270. {
  271. auto const & handler = *LIBRARY->modh->content;
  272. auto const & content = handler[contentName];
  273. auto contentOutPath = outPath / contentName;
  274. boost::filesystem::create_directories(contentOutPath);
  275. for(auto& iter : content.modData)
  276. {
  277. const JsonNode& modData = iter.second.modData;
  278. for(auto& nameAndObject : modData.Struct())
  279. {
  280. const JsonNode& object = nameAndObject.second;
  281. std::string name = ModUtility::makeFullIdentifier(object.getModScope(), contentName, nameAndObject.first);
  282. boost::algorithm::replace_all(name, ":", "_");
  283. const boost::filesystem::path filePath = contentOutPath / (name + ".json");
  284. std::ofstream file(filePath.c_str());
  285. file << object.toString();
  286. }
  287. }
  288. }
  289. printCommandMessage("\rExtracting done :)\n");
  290. printCommandMessage("Extracted files can be found in " + outPath.string() + " directory\n");
  291. }
  292. void ClientCommandManager::handleAntilagCommand(std::istringstream& singleWordBuffer)
  293. {
  294. std::string commandName;
  295. singleWordBuffer >> commandName;
  296. if (commandName == "on")
  297. {
  298. GAME->server().enableLagCompensation(true);
  299. printCommandMessage("Network lag compensation is now enabled.\n");
  300. }
  301. else if (commandName == "off")
  302. {
  303. GAME->server().enableLagCompensation(true);
  304. printCommandMessage("Network lag compensation is now disabled.\n");
  305. }
  306. else
  307. {
  308. printCommandMessage("Unexpected syntax. Supported forms:\n");
  309. printCommandMessage("'antilag on'\n");
  310. printCommandMessage("'antilag off'\n");
  311. }
  312. }
  313. void ClientCommandManager::handleGetScriptsCommand()
  314. {
  315. #if SCRIPTING_ENABLED
  316. printCommandMessage("Command accepted.\t");
  317. const boost::filesystem::path outPath = VCMIDirs::get().userExtractedPath() / "scripts";
  318. boost::filesystem::create_directories(outPath);
  319. for(const auto & kv : LIBRARY->scriptHandler->objects)
  320. {
  321. std::string name = kv.first;
  322. boost::algorithm::replace_all(name,":","_");
  323. const scripting::ScriptImpl * script = kv.second.get();
  324. boost::filesystem::path filePath = outPath / (name + ".lua");
  325. std::ofstream file(filePath.c_str());
  326. file << script->getSource();
  327. }
  328. printCommandMessage("\rExtracting done :)\n");
  329. printCommandMessage("Extracted files can be found in " + outPath.string() + " directory\n");
  330. #endif
  331. }
  332. void ClientCommandManager::handleGetTextCommand()
  333. {
  334. printCommandMessage("Command accepted.\t");
  335. const boost::filesystem::path outPath =
  336. VCMIDirs::get().userExtractedPath();
  337. auto list =
  338. CResourceHandler::get()->getFilteredFiles([](const ResourcePath & ident)
  339. {
  340. return ident.getType() == EResType::TEXT && boost::algorithm::starts_with(ident.getName(), "DATA/");
  341. });
  342. for (auto & filename : list)
  343. {
  344. const boost::filesystem::path filePath = outPath / (filename.getName() + ".TXT");
  345. boost::filesystem::create_directories(filePath.parent_path());
  346. std::ofstream file(filePath.c_str());
  347. auto text = CResourceHandler::get()->load(filename)->readAll();
  348. file.write((char*)text.first.get(), text.second);
  349. }
  350. printCommandMessage("\rExtracting done :)\n");
  351. printCommandMessage("Extracted files can be found in " + outPath.string() + " directory\n");
  352. }
  353. void ClientCommandManager::handleDef2bmpCommand(std::istringstream& singleWordBuffer)
  354. {
  355. std::string URI;
  356. singleWordBuffer >> URI;
  357. auto anim = ENGINE->renderHandler().loadAnimation(AnimationPath::builtin(URI), EImageBlitMode::SIMPLE);
  358. anim->exportBitmaps(VCMIDirs::get().userExtractedPath());
  359. }
  360. void ClientCommandManager::handleExtractCommand(std::istringstream& singleWordBuffer)
  361. {
  362. std::string URI;
  363. singleWordBuffer >> URI;
  364. if(CResourceHandler::get()->existsResource(ResourcePath(URI)))
  365. {
  366. const boost::filesystem::path outPath = VCMIDirs::get().userExtractedPath() / URI;
  367. auto data = CResourceHandler::get()->load(ResourcePath(URI))->readAll();
  368. boost::filesystem::create_directories(outPath.parent_path());
  369. std::ofstream outFile(outPath.c_str(), std::ofstream::binary);
  370. outFile.write((char*)data.first.get(), data.second);
  371. }
  372. else
  373. printCommandMessage("File not found!", ELogLevel::ERROR);
  374. }
  375. void ClientCommandManager::handleBonusesCommand(std::istringstream & singleWordBuffer)
  376. {
  377. if(currentCallFromIngameConsole)
  378. {
  379. printCommandMessage("Output for this command is too large for ingame chat! Please run it from client console.\n");
  380. return;
  381. }
  382. std::string outputFormat;
  383. singleWordBuffer >> outputFormat;
  384. auto format = [outputFormat](const BonusList & b) -> std::string
  385. {
  386. if(outputFormat == "json")
  387. return b.toJsonNode().toCompactString();
  388. std::ostringstream ss;
  389. ss << b;
  390. return ss.str();
  391. };
  392. printCommandMessage("Bonuses of " + GAME->interface()->localState->getCurrentArmy()->getObjectName() + "\n");
  393. printCommandMessage(format(*GAME->interface()->localState->getCurrentArmy()->getAllBonuses(Selector::all)) + "\n");
  394. printCommandMessage("\nInherited bonuses:\n");
  395. TCNodes parents;
  396. GAME->interface()->localState->getCurrentArmy()->getDirectParents(parents);
  397. for(const CBonusSystemNode *parent : parents)
  398. {
  399. printCommandMessage(std::string("\nBonuses from ") + typeid(*parent).name() + "\n" + format(*parent->getAllBonuses(Selector::all)) + "\n");
  400. }
  401. }
  402. void ClientCommandManager::handleTellCommand(std::istringstream& singleWordBuffer)
  403. {
  404. std::string what;
  405. int id1;
  406. int id2;
  407. singleWordBuffer >> what >> id1 >> id2;
  408. if(what == "hs")
  409. {
  410. for(const CGHeroInstance* h : GAME->interface()->cb->getHeroesInfo())
  411. if(h->getHeroTypeID().getNum() == id1)
  412. if(const CArtifactInstance* a = h->getArt(ArtifactPosition(id2)))
  413. printCommandMessage(a->nodeName());
  414. }
  415. }
  416. void ClientCommandManager::handleMpCommand()
  417. {
  418. if(const CGHeroInstance* h = GAME->interface()->localState->getCurrentHero())
  419. printCommandMessage(std::to_string(h->movementPointsRemaining()) + "; max: " + std::to_string(h->movementPointsLimit(true)) + "/" + std::to_string(h->movementPointsLimit(false)) + "\n");
  420. }
  421. void ClientCommandManager::handleSetCommand(std::istringstream& singleWordBuffer)
  422. {
  423. std::string what;
  424. std::string value;
  425. singleWordBuffer >> what;
  426. Settings config = settings.write["session"][what];
  427. singleWordBuffer >> value;
  428. if(value == "on")
  429. {
  430. config->Bool() = true;
  431. printCommandMessage("Option " + what + " enabled!", ELogLevel::INFO);
  432. }
  433. else if(value == "off")
  434. {
  435. config->Bool() = false;
  436. printCommandMessage("Option " + what + " disabled!", ELogLevel::INFO);
  437. }
  438. }
  439. void ClientCommandManager::handleCrashCommand()
  440. {
  441. int* ptr = nullptr;
  442. *ptr = 666;
  443. //disaster!
  444. }
  445. void ClientCommandManager::handleVsLog(std::istringstream & singleWordBuffer)
  446. {
  447. std::string key;
  448. singleWordBuffer >> key;
  449. logVisual->setKey(key);
  450. }
  451. void ClientCommandManager::handleGenerateAssets()
  452. {
  453. ENGINE->renderHandler().exportGeneratedAssets();
  454. printCommandMessage("All assets generated");
  455. }
  456. void ClientCommandManager::printCommandMessage(const std::string &commandMessage, ELogLevel::ELogLevel messageType)
  457. {
  458. switch(messageType)
  459. {
  460. case ELogLevel::NOT_SET:
  461. std::cout << commandMessage;
  462. break;
  463. case ELogLevel::TRACE:
  464. logGlobal->trace(commandMessage);
  465. break;
  466. case ELogLevel::DEBUG:
  467. logGlobal->debug(commandMessage);
  468. break;
  469. case ELogLevel::INFO:
  470. logGlobal->info(commandMessage);
  471. break;
  472. case ELogLevel::WARN:
  473. logGlobal->warn(commandMessage);
  474. break;
  475. case ELogLevel::ERROR:
  476. logGlobal->error(commandMessage);
  477. break;
  478. default:
  479. std::cout << commandMessage;
  480. break;
  481. }
  482. if(currentCallFromIngameConsole)
  483. {
  484. std::scoped_lock interfaceLock(ENGINE->interfaceMutex);
  485. if(GAME->interface() && GAME->interface()->cingconsole)
  486. {
  487. GAME->interface()->cingconsole->addMessage("", "System", commandMessage);
  488. }
  489. }
  490. }
  491. void ClientCommandManager::giveTurn(const PlayerColor &colorIdentifier)
  492. {
  493. PlayerStartsTurn yt;
  494. yt.player = colorIdentifier;
  495. yt.queryID = QueryID::NONE;
  496. ApplyClientNetPackVisitor visitor(*GAME->server().client, GAME->server().client->gameState());
  497. yt.visit(visitor);
  498. }
  499. void ClientCommandManager::processCommand(const std::string & message, bool calledFromIngameConsole)
  500. {
  501. // split the message into individual words
  502. std::istringstream singleWordBuffer;
  503. singleWordBuffer.str(message);
  504. // get command name, to be used for single word commands
  505. std::string commandName;
  506. singleWordBuffer >> commandName;
  507. currentCallFromIngameConsole = calledFromIngameConsole;
  508. if(message == std::string("die, fool"))
  509. handleQuitCommand();
  510. else if(commandName == "save")
  511. handleSaveCommand(singleWordBuffer);
  512. else if(commandName=="load")
  513. handleLoadCommand(singleWordBuffer); // not implemented
  514. else if(commandName == "gosolo")
  515. handleGoSoloCommand();
  516. else if(commandName == "autoskip")
  517. handleAutoskipCommand();
  518. else if(commandName == "controlai")
  519. handleControlaiCommand(singleWordBuffer);
  520. else if(commandName == "setBattleAI")
  521. handleSetBattleAICommand(singleWordBuffer);
  522. else if(commandName == "antilag")
  523. handleAntilagCommand(singleWordBuffer);
  524. else if(commandName == "redraw")
  525. handleRedrawCommand();
  526. else if(message=="translate" || message=="translate game")
  527. handleTranslateGameCommand(false);
  528. else if(message=="translate missing")
  529. handleTranslateGameCommand(true);
  530. else if(message=="translate maps")
  531. handleTranslateMapsCommand();
  532. else if(message=="get config")
  533. handleGetConfigCommand();
  534. else if(message=="get scripts")
  535. handleGetScriptsCommand();
  536. else if(message=="get txt")
  537. handleGetTextCommand();
  538. else if(commandName == "def2bmp")
  539. handleDef2bmpCommand(singleWordBuffer);
  540. else if(commandName == "extract")
  541. handleExtractCommand(singleWordBuffer);
  542. else if(commandName == "bonuses")
  543. handleBonusesCommand(singleWordBuffer);
  544. else if(commandName == "tell")
  545. handleTellCommand(singleWordBuffer);
  546. else if(commandName == "mp" && GAME->interface())
  547. handleMpCommand();
  548. else if (commandName == "set")
  549. handleSetCommand(singleWordBuffer);
  550. else if(commandName == "crash")
  551. handleCrashCommand();
  552. else if(commandName == "vslog")
  553. handleVsLog(singleWordBuffer);
  554. else if(message=="generate assets")
  555. handleGenerateAssets();
  556. else
  557. {
  558. if (!commandName.empty() && !vstd::iswithin(commandName[0], 0, ' ')) // filter-out debugger/IDE noise
  559. printCommandMessage("Command not found :(", ELogLevel::ERROR);
  560. }
  561. }