diff --git a/src/console.cpp b/src/console.cpp index ef74c66dbc..834714b2f6 100644 --- a/src/console.cpp +++ b/src/console.cpp @@ -13,6 +13,7 @@ #include "network/network_func.h" #include "network/network_admin.h" #include "debug.h" +#include "debug_fmt.h" #include "console_func.h" #include "settings_type.h" @@ -49,18 +50,16 @@ void IConsoleInit() IConsoleStdLibRegister(); } -static void IConsoleWriteToLogFile(const char *string) +static void IConsoleWriteToLogFile(const std::string &string) { if (_iconsole_output_file != nullptr) { /* if there is an console output file ... also print it there */ - log_prefix prefix_writer; - const char *header = prefix_writer.GetLogPrefix(); - if ((strlen(header) != 0 && fwrite(header, strlen(header), 1, _iconsole_output_file) != 1) || - fwrite(string, strlen(string), 1, _iconsole_output_file) != 1 || - fwrite("\n", 1, 1, _iconsole_output_file) != 1) { + try { + fmt::print(_iconsole_output_file, "{}{}\n", log_prefix().GetLogPrefix(), string); + } catch (const std::system_error &) { fclose(_iconsole_output_file); _iconsole_output_file = nullptr; - IConsolePrintF(CC_DEFAULT, "cannot write to log file"); + IConsolePrint(CC_ERROR, "Cannot write to console log file; closing the log file."); } } } @@ -68,7 +67,7 @@ static void IConsoleWriteToLogFile(const char *string) bool CloseConsoleLogIfActive() { if (_iconsole_output_file != nullptr) { - IConsolePrintF(CC_DEFAULT, "file output complete"); + IConsolePrint(CC_INFO, "Console log file closed."); fclose(_iconsole_output_file); _iconsole_output_file = nullptr; return true; @@ -89,10 +88,10 @@ void IConsoleFree() * as well as to a logfile. If the network server is a dedicated server, all activities * are also logged. All lines to print are added to a temporary buffer which can be * used as a history to print them onscreen - * @param colour_code the colour of the command. Red in case of errors, etc. - * @param string the message entered or output on the console (notice, error, etc.) + * @param colour_code The colour of the command. + * @param string The message to output on the console (notice, error, etc.) */ -void IConsolePrint(TextColour colour_code, const char *string) +void IConsolePrint(TextColour colour_code, const std::string &string) { assert(IsValidConsoleColour(colour_code)); @@ -113,13 +112,13 @@ void IConsolePrint(TextColour colour_code, const char *string) if (_network_dedicated) { NetworkAdminConsole("console", str); - fprintf(stdout, "%s%s\n", log_prefix().GetLogPrefix(), str.c_str()); + fmt::print("{}{}\n", log_prefix().GetLogPrefix(), str); fflush(stdout); - IConsoleWriteToLogFile(str.c_str()); + IConsoleWriteToLogFile(str); return; } - IConsoleWriteToLogFile(str.c_str()); + IConsoleWriteToLogFile(str); IConsoleGUIPrint(colour_code, std::move(str)); } @@ -133,35 +132,14 @@ void CDECL IConsolePrintF(TextColour colour_code, const char *format, ...) assert(IsValidConsoleColour(colour_code)); va_list va; - char buf[ICON_MAX_STREAMSIZE]; va_start(va, format); - vseprintf(buf, lastof(buf), format, va); + std::string buf = stdstr_vfmt(format, va); va_end(va); IConsolePrint(colour_code, buf); } -/** - * It is possible to print warnings to the console. These are mostly - * errors or mishaps, but non-fatal. You need at least a level 1 (developer) for - * debugging messages to show up - */ -void IConsoleWarning(const char *string) -{ - if (_settings_client.gui.developer == 0) return; - IConsolePrintF(CC_WARNING, "WARNING: %s", string); -} - -/** - * It is possible to print error information to the console. This can include - * game errors, or errors in general you would want the user to notice - */ -void IConsoleError(const char *string) -{ - IConsolePrintF(CC_ERROR, "ERROR: %s", string); -} - /** * Change a string into its number representation. Supports * decimal and hexadecimal numbers as well as 'on'/'off' 'true'/'false' @@ -227,7 +205,7 @@ std::string RemoveUnderscores(std::string name) /* static */ void IConsole::AliasRegister(const std::string &name, const std::string &cmd) { auto result = IConsole::Aliases().try_emplace(RemoveUnderscores(name), name, cmd); - if (!result.second) IConsoleError("an alias with this name already exists; insertion aborted"); + if (!result.second) IConsolePrint(CC_ERROR, "An alias with the name '{}' already exists.", name); } /** @@ -253,10 +231,10 @@ static void IConsoleAliasExec(const IConsoleAlias *alias, uint8_t tokencount, ch { std::string alias_buffer; - DEBUG(console, 6, "Requested command is an alias; parsing..."); + Debug(console, 6, "Requested command is an alias; parsing..."); if (recurse_count > ICON_MAX_RECURSE) { - IConsoleError("Too many alias expansions, recursion limit reached. Aborting"); + IConsolePrint(CC_ERROR, "Too many alias expansions, recursion limit reached."); return; } @@ -301,8 +279,8 @@ static void IConsoleAliasExec(const IConsoleAlias *alias, uint8_t tokencount, ch int param = *cmdptr - 'A'; if (param < 0 || param >= tokencount) { - IConsoleError("too many or wrong amount of parameters passed to alias, aborting"); - IConsolePrintF(CC_WARNING, "Usage of alias '%s': %s", alias->name.c_str(), alias->cmdline.c_str()); + IConsolePrint(CC_ERROR, "Too many or wrong amount of parameters passed to alias."); + IConsolePrint(CC_HELP, "Usage of alias '{}': '{}'.", alias->name, alias->cmdline); return; } @@ -320,7 +298,7 @@ static void IConsoleAliasExec(const IConsoleAlias *alias, uint8_t tokencount, ch } if (alias_buffer.size() >= ICON_MAX_STREAMSIZE - 1) { - IConsoleError("Requested alias execution would overflow execution buffer"); + IConsolePrint(CC_ERROR, "Requested alias execution would overflow execution buffer."); return; } } @@ -346,12 +324,12 @@ void IConsoleCmdExec(const std::string &command_string, const uint recurse_count for (cmdptr = command_string.c_str(); *cmdptr != '\0'; cmdptr++) { if (!IsValidChar(*cmdptr, CS_ALPHANUMERAL)) { - IConsolePrintF(CC_ERROR, "Command '%s' contains malformed characters.", command_string.c_str()); + IConsolePrint(CC_ERROR, "Command '{}' contains malformed characters.", command_string); return; } } - DEBUG(console, 4, "Executing cmdline: '%s'", command_string.c_str()); + Debug(console, 4, "Executing cmdline: '{}'", command_string); memset(&tokens, 0, sizeof(tokens)); memset(&tokenstream, 0, sizeof(tokenstream)); @@ -361,7 +339,7 @@ void IConsoleCmdExec(const std::string &command_string, const uint recurse_count * of characters in our stream or the max amount of tokens we can handle */ for (cmdptr = command_string.c_str(), t_index = 0, tstream_i = 0; *cmdptr != '\0'; cmdptr++) { if (tstream_i >= lengthof(tokenstream)) { - IConsoleError("command line too long"); + IConsolePrint(CC_ERROR, "Command line too long."); return; } @@ -382,7 +360,7 @@ void IConsoleCmdExec(const std::string &command_string, const uint recurse_count longtoken = !longtoken; if (!foundtoken) { if (t_index >= lengthof(tokens)) { - IConsoleError("command line too long"); + IConsolePrint(CC_ERROR, "Command line too long."); return; } tokens[t_index++] = &tokenstream[tstream_i]; @@ -400,7 +378,7 @@ void IConsoleCmdExec(const std::string &command_string, const uint recurse_count if (!foundtoken) { if (t_index >= lengthof(tokens)) { - IConsoleError("command line too long"); + IConsolePrint(CC_ERROR, "Command line too long."); return; } tokens[t_index++] = &tokenstream[tstream_i - 1]; @@ -411,7 +389,7 @@ void IConsoleCmdExec(const std::string &command_string, const uint recurse_count } for (uint i = 0; i < lengthof(tokens) && tokens[i] != nullptr; i++) { - DEBUG(console, 8, "Token %d is: '%s'", i, tokens[i]); + Debug(console, 8, "Token {} is: '{}'", i, tokens[i]); } IConsoleCmdExecTokens(t_index, tokens, recurse_count); @@ -450,5 +428,5 @@ void IConsoleCmdExecTokens(uint token_count, char *tokens[], const uint recurse_ return; } - IConsoleError("command not found"); + IConsolePrint(CC_ERROR, "Command '{}' not found.", tokens[0]); } diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index 8dc71c1901..cb6522dcaf 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -64,6 +64,7 @@ #include "object_base.h" #include "newgrf_newsignals.h" #include "roadstop_base.h" +#include "3rdparty/fmt/chrono.h" #include #include "3rdparty/cpp-btree/btree_set.h" @@ -114,6 +115,7 @@ static ConsoleFileList _console_file_list_heightmap{FT_HEIGHTMAP, false}; ///< F #define DEF_CONSOLE_CMD(function) static bool function([[maybe_unused]] uint8_t argc, [[maybe_unused]] char *argv[]) #define DEF_CONSOLE_HOOK(function) static ConsoleHookResult function(bool echo) + /**************** * command hooks ****************/ @@ -125,7 +127,7 @@ static ConsoleFileList _console_file_list_heightmap{FT_HEIGHTMAP, false}; ///< F static inline bool NetworkAvailable(bool echo) { if (!_network_available) { - if (echo) IConsoleError("You cannot use this command because there is no network available."); + if (echo) IConsolePrint(CC_ERROR, "You cannot use this command because there is no network available."); return false; } return true; @@ -140,7 +142,7 @@ DEF_CONSOLE_HOOK(ConHookServerOnly) if (!NetworkAvailable(echo)) return CHR_DISALLOW; if (!_network_server) { - if (echo) IConsoleError("This command is only available to a network server."); + if (echo) IConsolePrint(CC_ERROR, "This command is only available to a network server."); return CHR_DISALLOW; } return CHR_ALLOW; @@ -155,7 +157,7 @@ DEF_CONSOLE_HOOK(ConHookClientOnly) if (!NetworkAvailable(echo)) return CHR_DISALLOW; if (_network_server) { - if (echo) IConsoleError("This command is not available to a network server."); + if (echo) IConsolePrint(CC_ERROR, "This command is not available to a network server."); return CHR_DISALLOW; } return CHR_ALLOW; @@ -170,7 +172,7 @@ DEF_CONSOLE_HOOK(ConHookNeedNetwork) if (!NetworkAvailable(echo)) return CHR_DISALLOW; if (!_networking || (!_network_server && !MyClient::IsConnected())) { - if (echo) IConsoleError("Not connected. This command is only available in multiplayer."); + if (echo) IConsolePrint(CC_ERROR, "Not connected. This command is only available in multiplayer."); return CHR_DISALLOW; } return CHR_ALLOW; @@ -198,7 +200,7 @@ DEF_CONSOLE_HOOK(ConHookNeedNonDedicatedNetwork) DEF_CONSOLE_HOOK(ConHookNoNetwork) { if (_networking) { - if (echo) IConsoleError("This command is forbidden in multiplayer."); + if (echo) IConsolePrint(CC_ERROR, "This command is forbidden in multiplayer."); return CHR_DISALLOW; } return CHR_ALLOW; @@ -211,7 +213,7 @@ DEF_CONSOLE_HOOK(ConHookNoNetwork) DEF_CONSOLE_HOOK(ConHookServerOrNoNetwork) { if (_networking && !_network_server) { - if (echo) IConsoleError("This command is only available to a network server, or in single-player."); + if (echo) IConsolePrint(CC_ERROR, "This command is only available to a network server, or in single-player."); return CHR_DISALLOW; } return CHR_ALLOW; @@ -221,7 +223,7 @@ DEF_CONSOLE_HOOK(ConHookNewGRFDeveloperTool) { if (_settings_client.gui.newgrf_developer_tools) { if (_game_mode == GM_MENU) { - if (echo) IConsoleError("This command is only available in-game and in the editor."); + if (echo) IConsolePrint(CC_ERROR, "This command is only available in-game and in the editor."); return CHR_DISALLOW; } return ConHookNoNetwork(echo); @@ -237,15 +239,6 @@ DEF_CONSOLE_HOOK(ConHookSpecialCmd) return CHR_HIDE; } -/** - * Show help for the console. - * @param str String to print in the console. - */ -static void IConsoleHelp(const char *str) -{ - IConsolePrintF(CC_WARNING, "- %s", str); -} - /** * Reset status of all engines. * @return Will always succeed. @@ -253,7 +246,7 @@ static void IConsoleHelp(const char *str) DEF_CONSOLE_CMD(ConResetEngines) { if (argc == 0) { - IConsoleHelp("Reset status data of all engines. This might solve some issues with 'lost' engines. Usage: 'resetengines'"); + IConsolePrint(CC_HELP, "Reset status data of all engines. This might solve some issues with 'lost' engines. Usage: 'resetengines'."); return true; } @@ -269,17 +262,17 @@ DEF_CONSOLE_CMD(ConResetEngines) DEF_CONSOLE_CMD(ConResetEnginePool) { if (argc == 0) { - IConsoleHelp("Reset NewGRF allocations of engine slots. This will remove invalid engine definitions, and might make default engines available again."); + IConsolePrint(CC_HELP, "Reset NewGRF allocations of engine slots. This will remove invalid engine definitions, and might make default engines available again."); return true; } if (_game_mode == GM_MENU) { - IConsoleError("This command is only available in-game and in the editor."); + IConsolePrint(CC_ERROR, "This command is only available in-game and in the editor."); return true; } if (!EngineOverrideManager::ResetToCurrentNewGRFConfig()) { - IConsoleError("This can only be done when there are no vehicles in the game."); + IConsolePrint(CC_ERROR, "This can only be done when there are no vehicles in the game."); return true; } @@ -295,8 +288,8 @@ DEF_CONSOLE_CMD(ConResetEnginePool) DEF_CONSOLE_CMD(ConResetTile) { if (argc == 0) { - IConsoleHelp("Reset a tile to bare land. Usage: 'resettile '"); - IConsoleHelp("Tile can be either decimal (34161) or hexadecimal (0x4a5B)"); + IConsolePrint(CC_HELP, "Reset a tile to bare land. Usage: 'resettile '."); + IConsolePrint(CC_HELP, "Tile can be either decimal (34161) or hexadecimal (0x4a5B)."); return true; } @@ -321,8 +314,8 @@ DEF_CONSOLE_CMD(ConZoomToLevel) { switch (argc) { case 0: - IConsoleHelp("Set the current zoom level of the main viewport."); - IConsoleHelp("Usage: 'zoomto '."); + IConsolePrint(CC_HELP, "Set the current zoom level of the main viewport."); + IConsolePrint(CC_HELP, "Usage: 'zoomto '."); IConsolePrintF( CC_WARNING, ZOOM_LVL_MIN < _settings_client.gui.zoom_min ? @@ -332,15 +325,15 @@ DEF_CONSOLE_CMD(ConZoomToLevel) ); if (ZOOM_LVL_MIN < _settings_client.gui.zoom_min) { - IConsolePrintF(CC_WARNING, "The lowest zoom-in level allowed by current client settings is %u.", std::max(ZOOM_LVL_MIN, _settings_client.gui.zoom_min)); + IConsolePrint(CC_HELP, "The lowest zoom-in level allowed by current client settings is {}.", std::max(ZOOM_LVL_MIN, _settings_client.gui.zoom_min)); } else { - IConsolePrintF(CC_WARNING, "The lowest supported zoom-in level is %u.", std::max(ZOOM_LVL_MIN, _settings_client.gui.zoom_min)); + IConsolePrint(CC_HELP, "The lowest supported zoom-in level is {}.", std::max(ZOOM_LVL_MIN, _settings_client.gui.zoom_min)); } if (_settings_client.gui.zoom_max < ZOOM_LVL_MAX) { - IConsolePrintF(CC_WARNING, "The highest zoom-out level allowed by current client settings is %u.", std::min(_settings_client.gui.zoom_max, ZOOM_LVL_MAX)); + IConsolePrint(CC_HELP, "The highest zoom-out level allowed by current client settings is {}.", std::min(_settings_client.gui.zoom_max, ZOOM_LVL_MAX)); } else { - IConsolePrintF(CC_WARNING, "The highest supported zoom-out level is %u.", std::min(_settings_client.gui.zoom_max, ZOOM_LVL_MAX)); + IConsolePrint(CC_HELP, "The highest supported zoom-out level is {}.", std::min(_settings_client.gui.zoom_max, ZOOM_LVL_MAX)); } return true; @@ -352,13 +345,13 @@ DEF_CONSOLE_CMD(ConZoomToLevel) * reading an unsigned integer from the console, so just check for a '-' char. */ static_assert(ZOOM_LVL_MIN == 0); if (argv[1][0] == '-') { - IConsolePrintF(CC_ERROR, "Zoom-in levels below %u are not supported.", ZOOM_LVL_MIN); + IConsolePrint(CC_ERROR, "Zoom-in levels below {} are not supported.", ZOOM_LVL_MIN); } else if (level < _settings_client.gui.zoom_min) { - IConsolePrintF(CC_ERROR, "Current client settings do not allow zooming in below level %u.", _settings_client.gui.zoom_min); + IConsolePrint(CC_ERROR, "Current client settings do not allow zooming in below level {}.", _settings_client.gui.zoom_min); } else if (level > ZOOM_LVL_MAX) { - IConsolePrintF(CC_ERROR, "Zoom-in levels above %u are not supported.", ZOOM_LVL_MAX); + IConsolePrint(CC_ERROR, "Zoom-in levels above {} are not supported.", ZOOM_LVL_MAX); } else if (level > _settings_client.gui.zoom_max) { - IConsolePrintF(CC_ERROR, "Current client settings do not allow zooming out beyond level %u.", _settings_client.gui.zoom_max); + IConsolePrint(CC_ERROR, "Current client settings do not allow zooming out beyond level {}.", _settings_client.gui.zoom_max); } else { Window *w = GetMainWindow(); Viewport *vp = w->viewport; @@ -386,10 +379,10 @@ DEF_CONSOLE_CMD(ConZoomToLevel) DEF_CONSOLE_CMD(ConScrollToTile) { if (argc == 0) { - IConsoleHelp("Center the screen on a given tile."); - IConsoleHelp("Usage: 'scrollto [instant] ' or 'scrollto [instant] '."); - IConsoleHelp("Numbers can be either decimal (34161) or hexadecimal (0x4a5B)."); - IConsoleHelp("'instant' will immediately move and redraw viewport without smooth scrolling."); + IConsolePrint(CC_HELP, "Center the screen on a given tile."); + IConsolePrint(CC_HELP, "Usage: 'scrollto [instant] ' or 'scrollto [instant] '."); + IConsolePrint(CC_HELP, "Numbers can be either decimal (34161) or hexadecimal (0x4a5B)."); + IConsolePrint(CC_HELP, "'instant' will immediately move and redraw viewport without smooth scrolling."); return true; } if (argc < 2) return false; @@ -406,7 +399,7 @@ DEF_CONSOLE_CMD(ConScrollToTile) uint32_t result; if (GetArgumentInteger(&result, argv[arg_index])) { if (result >= MapSize()) { - IConsolePrint(CC_ERROR, "Tile does not exist"); + IConsolePrint(CC_ERROR, "Tile does not exist."); return true; } ScrollMainWindowToTile((TileIndex)result, instant); @@ -419,7 +412,7 @@ DEF_CONSOLE_CMD(ConScrollToTile) uint32_t x, y; if (GetArgumentInteger(&x, argv[arg_index]) && GetArgumentInteger(&y, argv[arg_index + 1])) { if (x >= MapSizeX() || y >= MapSizeY()) { - IConsolePrint(CC_ERROR, "Tile does not exist"); + IConsolePrint(CC_ERROR, "Tile does not exist."); return true; } ScrollMainWindowToTile(TileXY(x, y), instant); @@ -445,16 +438,16 @@ DEF_CONSOLE_CMD(ConHighlightTile) { switch (argc) { case 0: - IConsoleHelp("Highlight a given tile."); - IConsoleHelp("Usage: 'highlight_tile ' or 'highlight_tile '"); - IConsoleHelp("Numbers can be either decimal (34161) or hexadecimal (0x4a5B)."); + IConsolePrint(CC_HELP, "Highlight a given tile."); + IConsolePrint(CC_HELP, "Usage: 'highlight_tile ' or 'highlight_tile '"); + IConsolePrint(CC_HELP, "Numbers can be either decimal (34161) or hexadecimal (0x4a5B)."); return true; case 2: { uint32_t result; if (GetArgumentInteger(&result, argv[1])) { if (result >= MapSize()) { - IConsolePrint(CC_ERROR, "Tile does not exist"); + IConsolePrint(CC_ERROR, "Tile does not exist."); return true; } SetRedErrorSquare((TileIndex)result); @@ -467,7 +460,7 @@ DEF_CONSOLE_CMD(ConHighlightTile) uint32_t x, y; if (GetArgumentInteger(&x, argv[1]) && GetArgumentInteger(&y, argv[2])) { if (x >= MapSizeX() || y >= MapSizeY()) { - IConsolePrint(CC_ERROR, "Tile does not exist"); + IConsolePrint(CC_ERROR, "Tile does not exist."); return true; } SetRedErrorSquare(TileXY(x, y)); @@ -488,18 +481,19 @@ DEF_CONSOLE_CMD(ConHighlightTile) DEF_CONSOLE_CMD(ConSave) { if (argc == 0) { - IConsoleHelp("Save the current game. Usage: 'save '"); + IConsolePrint(CC_HELP, "Save the current game. Usage: 'save '."); return true; } if (argc == 2) { - std::string filename = stdstr_fmt("%s.sav", argv[1]); + std::string filename = argv[1]; + filename += ".sav"; IConsolePrint(CC_DEFAULT, "Saving map..."); if (SaveOrLoad(filename, SLO_SAVE, DFT_GAME_FILE, SAVE_DIR) != SL_OK) { - IConsolePrint(CC_ERROR, "Saving map failed"); + IConsolePrint(CC_ERROR, "Saving map failed."); } else { - IConsolePrintF(CC_DEFAULT, "Map successfully saved to %s", filename.c_str()); + IConsolePrint(CC_INFO, "Map successfully saved to '{}'.", filename); } return true; } @@ -514,8 +508,8 @@ DEF_CONSOLE_CMD(ConSave) DEF_CONSOLE_CMD(ConSaveConfig) { if (argc == 0) { - IConsoleHelp("Saves the configuration for new games to the configuration file, typically 'openttd.cfg'."); - IConsoleHelp("It does not save the configuration of the current game to the configuration file."); + IConsolePrint(CC_HELP, "Saves the configuration for new games to the configuration file, typically 'openttd.cfg'."); + IConsolePrint(CC_HELP, "It does not save the configuration of the current game to the configuration file."); return true; } @@ -527,7 +521,7 @@ DEF_CONSOLE_CMD(ConSaveConfig) DEF_CONSOLE_CMD(ConLoad) { if (argc == 0) { - IConsoleHelp("Load a game by name or index. Usage: 'load '"); + IConsolePrint(CC_HELP, "Load a game by name or index. Usage: 'load '."); return true; } @@ -541,10 +535,10 @@ DEF_CONSOLE_CMD(ConLoad) _switch_mode = SM_LOAD_GAME; _file_to_saveload.Set(*item); } else { - IConsolePrintF(CC_ERROR, "%s: Not a savegame.", file); + IConsolePrint(CC_ERROR, "'{}' is not a savegame.", file); } } else { - IConsolePrintF(CC_ERROR, "%s: No such file or directory.", file); + IConsolePrint(CC_ERROR, "'{}' cannot be found.", file); } return true; @@ -553,7 +547,7 @@ DEF_CONSOLE_CMD(ConLoad) DEF_CONSOLE_CMD(ConLoadScenario) { if (argc == 0) { - IConsoleHelp("Load a scenario by name or index. Usage: 'load_scenario '."); + IConsolePrint(CC_HELP, "Load a scenario by name or index. Usage: 'load_scenario '."); return true; } @@ -567,10 +561,10 @@ DEF_CONSOLE_CMD(ConLoadScenario) _switch_mode = SM_LOAD_GAME; _file_to_saveload.Set(*item); } else { - IConsolePrintF(CC_ERROR, "'%s' is not a scenario.", file); + IConsolePrint(CC_ERROR, "'{}' is not a scenario.", file); } } else { - IConsolePrintF(CC_ERROR, "'%s' cannot be found.", file); + IConsolePrint(CC_ERROR, "'{}' cannot be found.", file); } return true; @@ -579,7 +573,7 @@ DEF_CONSOLE_CMD(ConLoadScenario) DEF_CONSOLE_CMD(ConLoadHeightmap) { if (argc == 0) { - IConsoleHelp("Load a heightmap by name or index. Usage: 'load_heightmap '."); + IConsolePrint(CC_HELP, "Load a heightmap by name or index. Usage: 'load_heightmap '."); return true; } @@ -593,10 +587,10 @@ DEF_CONSOLE_CMD(ConLoadHeightmap) _switch_mode = SM_START_HEIGHTMAP; _file_to_saveload.Set(*item); } else { - IConsolePrintF(CC_ERROR, "'%s' is not a heightmap.", file); + IConsolePrint(CC_ERROR, "'{}' is not a heightmap.", file); } } else { - IConsolePrintF(CC_ERROR, "'%s' cannot be found.", file); + IConsolePrint(CC_ERROR, "'{}' cannot be found.", file); } return true; @@ -605,7 +599,7 @@ DEF_CONSOLE_CMD(ConLoadHeightmap) DEF_CONSOLE_CMD(ConRemove) { if (argc == 0) { - IConsoleHelp("Remove a savegame by name or index. Usage: 'rm '"); + IConsolePrint(CC_HELP, "Remove a savegame by name or index. Usage: 'rm '."); return true; } @@ -616,10 +610,10 @@ DEF_CONSOLE_CMD(ConRemove) const FiosItem *item = _console_file_list_savegame.FindItem(file); if (item != nullptr) { if (unlink(item->name.c_str()) != 0) { - IConsolePrintF(CC_ERROR, "%s: Failed to delete file", file); + IConsolePrint(CC_ERROR, "Failed to delete '{}'.", item->name); } } else { - IConsolePrintF(CC_ERROR, "%s: No such file or directory.", file); + IConsolePrint(CC_ERROR, "'{}' could not be found.", file); } _console_file_list_savegame.InvalidateFileList(); @@ -631,13 +625,13 @@ DEF_CONSOLE_CMD(ConRemove) DEF_CONSOLE_CMD(ConListFiles) { if (argc == 0) { - IConsoleHelp("List all loadable savegames and directories in the current dir via console. Usage: 'ls | dir'"); + IConsolePrint(CC_HELP, "List all loadable savegames and directories in the current dir via console. Usage: 'ls | dir'."); return true; } _console_file_list_savegame.ValidateFileList(true); for (uint i = 0; i < _console_file_list_savegame.size(); i++) { - IConsolePrintF(CC_DEFAULT, "%d) %s", i, _console_file_list_savegame[i].title.c_str()); + IConsolePrint(CC_DEFAULT, "{}) {}", i, _console_file_list_savegame[i].title); } return true; @@ -647,13 +641,13 @@ DEF_CONSOLE_CMD(ConListFiles) DEF_CONSOLE_CMD(ConListScenarios) { if (argc == 0) { - IConsoleHelp("List all loadable scenarios. Usage: 'list_scenarios'."); + IConsolePrint(CC_HELP, "List all loadable scenarios. Usage: 'list_scenarios'."); return true; } _console_file_list_scenario.ValidateFileList(true); for (uint i = 0; i < _console_file_list_scenario.size(); i++) { - IConsolePrintF(CC_DEFAULT, "%d) %s", i, _console_file_list_scenario[i].title.c_str()); + IConsolePrint(CC_DEFAULT, "{}) {}", i, _console_file_list_scenario[i].title); } return true; @@ -663,13 +657,13 @@ DEF_CONSOLE_CMD(ConListScenarios) DEF_CONSOLE_CMD(ConListHeightmaps) { if (argc == 0) { - IConsoleHelp("List all loadable heightmaps. Usage: 'list_heightmaps'."); + IConsolePrint(CC_HELP, "List all loadable heightmaps. Usage: 'list_heightmaps'."); return true; } _console_file_list_heightmap.ValidateFileList(true); for (uint i = 0; i < _console_file_list_heightmap.size(); i++) { - IConsolePrintF(CC_DEFAULT, "%d) %s", i, _console_file_list_heightmap[i].title.c_str()); + IConsolePrint(CC_DEFAULT, "{}) {}", i, _console_file_list_heightmap[i].title); } return true; @@ -679,7 +673,7 @@ DEF_CONSOLE_CMD(ConListHeightmaps) DEF_CONSOLE_CMD(ConChangeDirectory) { if (argc == 0) { - IConsoleHelp("Change the dir via console. Usage: 'cd '"); + IConsolePrint(CC_HELP, "Change the dir via console. Usage: 'cd '."); return true; } @@ -693,10 +687,10 @@ DEF_CONSOLE_CMD(ConChangeDirectory) case FIOS_TYPE_DIR: case FIOS_TYPE_DRIVE: case FIOS_TYPE_PARENT: FiosBrowseTo(item); break; - default: IConsolePrintF(CC_ERROR, "%s: Not a directory.", file); + default: IConsolePrint(CC_ERROR, "{}: Not a directory.", file); } } else { - IConsolePrintF(CC_ERROR, "%s: No such file or directory.", file); + IConsolePrint(CC_ERROR, "{}: No such file or directory.", file); } _console_file_list_savegame.InvalidateFileList(); @@ -706,7 +700,7 @@ DEF_CONSOLE_CMD(ConChangeDirectory) DEF_CONSOLE_CMD(ConPrintWorkingDirectory) { if (argc == 0) { - IConsoleHelp("Print out the current working directory. Usage: 'pwd'"); + IConsolePrint(CC_HELP, "Print out the current working directory. Usage: 'pwd'."); return true; } @@ -714,14 +708,14 @@ DEF_CONSOLE_CMD(ConPrintWorkingDirectory) _console_file_list_savegame.ValidateFileList(true); _console_file_list_savegame.InvalidateFileList(); - IConsolePrint(CC_DEFAULT, FiosGetCurrentPath().c_str()); + IConsolePrint(CC_DEFAULT, FiosGetCurrentPath()); return true; } DEF_CONSOLE_CMD(ConClearBuffer) { if (argc == 0) { - IConsoleHelp("Clear the console buffer. Usage: 'clear'"); + IConsolePrint(CC_HELP, "Clear the console buffer. Usage: 'clear'."); return true; } @@ -747,13 +741,13 @@ static bool ConKickOrBan(const char *argv, bool ban, const std::string &reason) * would be reading from and writing to after returning. So we would read or write data * from freed memory up till the segfault triggers. */ if (client_id == CLIENT_ID_SERVER || client_id == _redirect_console_to_client) { - IConsolePrintF(CC_ERROR, "ERROR: You can not %s yourself!", ban ? "ban" : "kick"); + IConsolePrint(CC_ERROR, "You can not {} yourself!", ban ? "ban" : "kick"); return true; } NetworkClientInfo *ci = NetworkClientInfo::GetByClientID(client_id); if (ci == nullptr) { - IConsoleError("Invalid client"); + IConsolePrint(CC_ERROR, "Invalid client ID."); return true; } @@ -770,9 +764,9 @@ static bool ConKickOrBan(const char *argv, bool ban, const std::string &reason) } if (n == 0) { - IConsolePrint(CC_DEFAULT, ban ? "Client not online, address added to banlist" : "Client not found"); + IConsolePrint(CC_DEFAULT, ban ? "Client not online, address added to banlist." : "Client not found."); } else { - IConsolePrintF(CC_DEFAULT, "%sed %u client(s)", ban ? "Bann" : "Kick", n); + IConsolePrint(CC_DEFAULT, "{}ed {} client(s).", ban ? "Bann" : "Kick", n); } return true; @@ -781,8 +775,8 @@ static bool ConKickOrBan(const char *argv, bool ban, const std::string &reason) DEF_CONSOLE_CMD(ConKick) { if (argc == 0) { - IConsoleHelp("Kick a client from a network game. Usage: 'kick []'"); - IConsoleHelp("For client-id's, see the command 'clients'"); + IConsolePrint(CC_HELP, "Kick a client from a network game. Usage: 'kick []'."); + IConsolePrint(CC_HELP, "For client-id's, see the command 'clients'."); return true; } @@ -794,7 +788,7 @@ DEF_CONSOLE_CMD(ConKick) /* Reason for kicking supplied */ size_t kick_message_length = strlen(argv[2]); if (kick_message_length >= 255) { - IConsolePrintF(CC_ERROR, "ERROR: Maximum kick message length is 254 characters. You entered " PRINTF_SIZE " characters.", kick_message_length); + IConsolePrint(CC_ERROR, "Maximum kick message length is 254 characters. You entered {} characters.", kick_message_length); return false; } else { return ConKickOrBan(argv[1], false, argv[2]); @@ -804,9 +798,9 @@ DEF_CONSOLE_CMD(ConKick) DEF_CONSOLE_CMD(ConBan) { if (argc == 0) { - IConsoleHelp("Ban a client from a network game. Usage: 'ban []'"); - IConsoleHelp("For client-id's, see the command 'clients'"); - IConsoleHelp("If the client is no longer online, you can still ban their IP"); + IConsolePrint(CC_HELP, "Ban a client from a network game. Usage: 'ban []'."); + IConsolePrint(CC_HELP, "For client-id's, see the command 'clients'."); + IConsolePrint(CC_HELP, "If the client is no longer online, you can still ban their IP."); return true; } @@ -818,7 +812,7 @@ DEF_CONSOLE_CMD(ConBan) /* Reason for kicking supplied */ size_t kick_message_length = strlen(argv[2]); if (kick_message_length >= 255) { - IConsolePrintF(CC_ERROR, "ERROR: Maximum kick message length is 254 characters. You entered " PRINTF_SIZE " characters.", kick_message_length); + IConsolePrint(CC_ERROR, "Maximum kick message length is 254 characters. You entered {} characters.", kick_message_length); return false; } else { return ConKickOrBan(argv[1], true, argv[2]); @@ -828,8 +822,8 @@ DEF_CONSOLE_CMD(ConBan) DEF_CONSOLE_CMD(ConUnBan) { if (argc == 0) { - IConsoleHelp("Unban a client from a network game. Usage: 'unban '"); - IConsoleHelp("For a list of banned IP's, see the command 'banlist'"); + IConsolePrint(CC_HELP, "Unban a client from a network game. Usage: 'unban '."); + IConsolePrint(CC_HELP, "For a list of banned IP's, see the command 'banlist'."); return true; } @@ -847,13 +841,11 @@ DEF_CONSOLE_CMD(ConUnBan) } if (index < _network_ban_list.size()) { - char msg[64]; - seprintf(msg, lastof(msg), "Unbanned %s", _network_ban_list[index].c_str()); - IConsolePrint(CC_DEFAULT, msg); + IConsolePrint(CC_DEFAULT, "Unbanned {}.", _network_ban_list[index]); _network_ban_list.erase(_network_ban_list.begin() + index); } else { IConsolePrint(CC_DEFAULT, "Invalid list index or IP not in ban-list."); - IConsolePrint(CC_DEFAULT, "For a list of banned IP's, see the command 'banlist'"); + IConsolePrint(CC_DEFAULT, "For a list of banned IP's, see the command 'banlist'."); } return true; @@ -862,15 +854,15 @@ DEF_CONSOLE_CMD(ConUnBan) DEF_CONSOLE_CMD(ConBanList) { if (argc == 0) { - IConsoleHelp("List the IP's of banned clients: Usage 'banlist'"); + IConsolePrint(CC_HELP, "List the IP's of banned clients: Usage 'banlist'."); return true; } - IConsolePrint(CC_DEFAULT, "Banlist: "); + IConsolePrint(CC_DEFAULT, "Banlist:"); uint i = 1; for (const auto &entry : _network_ban_list) { - IConsolePrintF(CC_DEFAULT, " %d) %s", i, entry.c_str()); + IConsolePrint(CC_DEFAULT, " {}) {}", i, entry); i++; } @@ -880,12 +872,12 @@ DEF_CONSOLE_CMD(ConBanList) DEF_CONSOLE_CMD(ConPauseGame) { if (argc == 0) { - IConsoleHelp("Pause a network game. Usage: 'pause'"); + IConsolePrint(CC_HELP, "Pause a network game. Usage: 'pause'."); return true; } if (_game_mode == GM_MENU) { - IConsoleError("This command is only available in-game and in the editor."); + IConsolePrint(CC_ERROR, "This command is only available in-game and in the editor."); return true; } @@ -902,12 +894,12 @@ DEF_CONSOLE_CMD(ConPauseGame) DEF_CONSOLE_CMD(ConUnpauseGame) { if (argc == 0) { - IConsoleHelp("Unpause a network game. Usage: 'unpause'"); + IConsolePrint(CC_HELP, "Unpause a network game. Usage: 'unpause'."); return true; } if (_game_mode == GM_MENU) { - IConsoleError("This command is only available in-game and in the editor."); + IConsolePrint(CC_ERROR, "This command is only available in-game and in the editor."); return true; } @@ -928,7 +920,7 @@ DEF_CONSOLE_CMD(ConUnpauseGame) DEF_CONSOLE_CMD(ConStepGame) { if (argc == 0 || argc > 2) { - IConsoleHelp("Advances the game for a certain amount of ticks (default 1). Usage: 'step [n]'"); + IConsolePrint(CC_HELP, "Advances the game for a certain amount of ticks (default 1). Usage: 'step [n]'"); return true; } auto n = (argc > 1 ? atoi(argv[1]) : 1); @@ -941,8 +933,8 @@ DEF_CONSOLE_CMD(ConStepGame) DEF_CONSOLE_CMD(ConRcon) { if (argc == 0) { - IConsoleHelp("Remote control the server from another client. Usage: 'rcon '"); - IConsoleHelp("Remember to enclose the command in quotes, otherwise only the first parameter is sent"); + IConsolePrint(CC_HELP, "Remote control the server from another client. Usage: 'rcon '."); + IConsolePrint(CC_HELP, "Remember to enclose the command in quotes, otherwise only the first parameter is sent."); return true; } @@ -959,8 +951,8 @@ DEF_CONSOLE_CMD(ConRcon) DEF_CONSOLE_CMD(ConSettingsAccess) { if (argc == 0) { - IConsoleHelp("Enable changing game settings from this client. Usage: 'settings_access '"); - IConsoleHelp("Send an empty password \"\" to drop access"); + IConsolePrint(CC_HELP, "Enable changing game settings from this client. Usage: 'settings_access '"); + IConsolePrint(CC_HELP, "Send an empty password \"\" to drop access"); return true; } @@ -975,7 +967,7 @@ DEF_CONSOLE_CMD(ConSettingsAccess) DEF_CONSOLE_CMD(ConStatus) { if (argc == 0) { - IConsoleHelp("List the status of all clients connected to the server. Usage 'status'"); + IConsolePrint(CC_HELP, "List the status of all clients connected to the server. Usage 'status'."); return true; } @@ -986,15 +978,15 @@ DEF_CONSOLE_CMD(ConStatus) DEF_CONSOLE_CMD(ConServerInfo) { if (argc == 0) { - IConsoleHelp("List current and maximum client/company limits. Usage 'server_info'"); - IConsoleHelp("You can change these values by modifying settings 'network.max_clients' and 'network.max_companies'"); + IConsolePrint(CC_HELP, "List current and maximum client/company limits. Usage 'server_info'."); + IConsolePrint(CC_HELP, "You can change these values by modifying settings 'network.max_clients' and 'network.max_companies'."); return true; } - IConsolePrintF(CC_DEFAULT, "Invite code: %s", _network_server_invite_code.c_str()); - IConsolePrintF(CC_DEFAULT, "Current/maximum clients: %3d/%3d", _network_game_info.clients_on, _settings_client.network.max_clients); - IConsolePrintF(CC_DEFAULT, "Current/maximum companies: %3d/%3d", (int)Company::GetNumItems(), _settings_client.network.max_companies); - IConsolePrintF(CC_DEFAULT, "Current spectators: %3d", NetworkSpectatorCount()); + IConsolePrint(CC_DEFAULT, "Invite code: {}", _network_server_invite_code); + IConsolePrint(CC_DEFAULT, "Current/maximum clients: {:3d}/{:3d}", _network_game_info.clients_on, _settings_client.network.max_clients); + IConsolePrint(CC_DEFAULT, "Current/maximum companies: {:3d}/{:3d}", Company::GetNumItems(), _settings_client.network.max_companies); + IConsolePrint(CC_DEFAULT, "Current spectators: {:3d}", NetworkSpectatorCount()); return true; } @@ -1002,32 +994,32 @@ DEF_CONSOLE_CMD(ConServerInfo) DEF_CONSOLE_CMD(ConClientNickChange) { if (argc != 3) { - IConsoleHelp("Change the nickname of a connected client. Usage: 'client_name '"); - IConsoleHelp("For client-id's, see the command 'clients'"); + IConsolePrint(CC_HELP, "Change the nickname of a connected client. Usage: 'client_name '."); + IConsolePrint(CC_HELP, "For client-id's, see the command 'clients'."); return true; } ClientID client_id = (ClientID)atoi(argv[1]); if (client_id == CLIENT_ID_SERVER) { - IConsoleError("Please use the command 'name' to change your own name!"); + IConsolePrint(CC_ERROR, "Please use the command 'name' to change your own name!"); return true; } if (NetworkClientInfo::GetByClientID(client_id) == nullptr) { - IConsoleError("Invalid client"); + IConsolePrint(CC_ERROR, "Invalid client ID."); return true; } std::string client_name(argv[2]); StrTrimInPlace(client_name); if (!NetworkIsValidClientName(client_name)) { - IConsoleError("Cannot give a client an empty name"); + IConsolePrint(CC_ERROR, "Cannot give a client an empty name."); return true; } if (!NetworkServerChangeClientName(client_id, client_name)) { - IConsoleError("Cannot give a client a duplicate name"); + IConsolePrint(CC_ERROR, "Cannot give a client a duplicate name."); } return true; @@ -1036,8 +1028,8 @@ DEF_CONSOLE_CMD(ConClientNickChange) DEF_CONSOLE_CMD(ConJoinCompany) { if (argc < 2) { - IConsoleHelp("Request joining another company. Usage: join []"); - IConsoleHelp("For valid company-id see company list, use 255 for spectator"); + IConsolePrint(CC_HELP, "Request joining another company. Usage: 'join []'."); + IConsolePrint(CC_HELP, "For valid company-id see company list, use 255 for spectator."); return true; } @@ -1045,29 +1037,29 @@ DEF_CONSOLE_CMD(ConJoinCompany) const NetworkClientInfo *info = NetworkClientInfo::GetByClientID(_network_own_client_id); if (info == nullptr) { - IConsoleError("You have not joined the game yet!"); + IConsolePrint(CC_ERROR, "You have not joined the game yet!"); return true; } /* Check we have a valid company id! */ if (!Company::IsValidID(company_id) && company_id != COMPANY_SPECTATOR) { - IConsolePrintF(CC_ERROR, "Company does not exist. Company-id must be between 1 and %d.", MAX_COMPANIES); + IConsolePrint(CC_ERROR, "Company does not exist. Company-id must be between 1 and {}.", MAX_COMPANIES); return true; } if (info->client_playas == company_id) { - IConsoleError("You are already there!"); + IConsolePrint(CC_ERROR, "You are already there!"); return true; } if (company_id != COMPANY_SPECTATOR && !Company::IsHumanID(company_id)) { - IConsoleError("Cannot join AI company."); + IConsolePrint(CC_ERROR, "Cannot join AI company."); return true; } /* Check if the company requires a password */ if (NetworkCompanyIsPassworded(company_id) && argc < 3) { - IConsolePrintF(CC_ERROR, "Company %d requires a password to join.", company_id + 1); + IConsolePrint(CC_ERROR, "Company {} requires a password to join.", company_id + 1); return true; } @@ -1084,8 +1076,8 @@ DEF_CONSOLE_CMD(ConJoinCompany) DEF_CONSOLE_CMD(ConMoveClient) { if (argc < 3) { - IConsoleHelp("Move a client to another company. Usage: move "); - IConsoleHelp("For valid client-id see 'clients', for valid company-id see 'companies', use 255 for moving to spectators"); + IConsolePrint(CC_HELP, "Move a client to another company. Usage: 'move '."); + IConsolePrint(CC_HELP, "For valid client-id see 'clients', for valid company-id see 'companies', use 255 for moving to spectators."); return true; } @@ -1094,27 +1086,27 @@ DEF_CONSOLE_CMD(ConMoveClient) /* check the client exists */ if (ci == nullptr) { - IConsoleError("Invalid client-id, check the command 'clients' for valid client-id's."); + IConsolePrint(CC_ERROR, "Invalid client-id, check the command 'clients' for valid client-id's."); return true; } if (!Company::IsValidID(company_id) && company_id != COMPANY_SPECTATOR) { - IConsolePrintF(CC_ERROR, "Company does not exist. Company-id must be between 1 and %d.", MAX_COMPANIES); + IConsolePrint(CC_ERROR, "Company does not exist. Company-id must be between 1 and {}.", MAX_COMPANIES); return true; } if (company_id != COMPANY_SPECTATOR && !Company::IsHumanID(company_id)) { - IConsoleError("You cannot move clients to AI companies."); + IConsolePrint(CC_ERROR, "You cannot move clients to AI companies."); return true; } if (ci->client_id == CLIENT_ID_SERVER && _network_dedicated) { - IConsoleError("You cannot move the server!"); + IConsolePrint(CC_ERROR, "You cannot move the server!"); return true; } if (ci->client_playas == company_id) { - IConsoleError("You cannot move someone to where they already are!"); + IConsolePrint(CC_ERROR, "You cannot move someone to where they already are!"); return true; } @@ -1127,8 +1119,8 @@ DEF_CONSOLE_CMD(ConMoveClient) DEF_CONSOLE_CMD(ConResetCompany) { if (argc == 0) { - IConsoleHelp("Remove an idle company from the game. Usage: 'reset_company '"); - IConsoleHelp("For company-id's, see the list of companies from the dropdown menu. Company 1 is 1, etc."); + IConsolePrint(CC_HELP, "Remove an idle company from the game. Usage: 'reset_company '."); + IConsolePrint(CC_HELP, "For company-id's, see the list of companies from the dropdown menu. Company 1 is 1, etc."); return true; } @@ -1138,23 +1130,23 @@ DEF_CONSOLE_CMD(ConResetCompany) /* Check valid range */ if (!Company::IsValidID(index)) { - IConsolePrintF(CC_ERROR, "Company does not exist. Company-id must be between 1 and %d.", MAX_COMPANIES); + IConsolePrint(CC_ERROR, "Company does not exist. Company-id must be between 1 and {}.", MAX_COMPANIES); return true; } if (!Company::IsHumanID(index)) { - IConsoleError("Company is owned by an AI."); + IConsolePrint(CC_ERROR, "Company is owned by an AI."); return true; } if (NetworkCompanyHasClients(index)) { - IConsoleError("Cannot remove company: a client is connected to that company."); + IConsolePrint(CC_ERROR, "Cannot remove company: a client is connected to that company."); return false; } const NetworkClientInfo *ci = NetworkClientInfo::GetByClientID(CLIENT_ID_SERVER); assert(ci != nullptr); if (ci->client_playas == index) { - IConsoleError("Cannot remove company: the server is connected to that company."); + IConsolePrint(CC_ERROR, "Cannot remove company: the server is connected to that company."); return true; } @@ -1168,8 +1160,8 @@ DEF_CONSOLE_CMD(ConResetCompany) DEF_CONSOLE_CMD(ConOfferCompanySale) { if (argc == 0) { - IConsoleHelp("Offer a company for sale. Usage: 'offer_company_sale '"); - IConsoleHelp("For company-id's, see the list of companies from the dropdown menu. Company 1 is 1, etc."); + IConsolePrint(CC_HELP, "Offer a company for sale. Usage: 'offer_company_sale '"); + IConsolePrint(CC_HELP, "For company-id's, see the list of companies from the dropdown menu. Company 1 is 1, etc."); return true; } @@ -1192,7 +1184,7 @@ DEF_CONSOLE_CMD(ConOfferCompanySale) DEF_CONSOLE_CMD(ConNetworkClients) { if (argc == 0) { - IConsoleHelp("Get a list of connected clients including their ID, name, company-id, and IP. Usage: 'clients'"); + IConsolePrint(CC_HELP, "Get a list of connected clients including their ID, name, company-id, and IP. Usage: 'clients'."); return true; } @@ -1204,9 +1196,9 @@ DEF_CONSOLE_CMD(ConNetworkClients) DEF_CONSOLE_CMD(ConNetworkReconnect) { if (argc == 0) { - IConsoleHelp("Reconnect to server to which you were connected last time. Usage: 'reconnect []'"); - IConsoleHelp("Company 255 is spectator (default, if not specified), 0 means creating new company."); - IConsoleHelp("All others are a certain company with Company 1 being #1"); + IConsolePrint(CC_HELP, "Reconnect to server to which you were connected last time. Usage: 'reconnect []'."); + IConsolePrint(CC_HELP, "Company 255 is spectator (default, if not specified), 0 means creating new company."); + IConsolePrint(CC_HELP, "All others are a certain company with Company 1 being #1."); return true; } @@ -1227,7 +1219,7 @@ DEF_CONSOLE_CMD(ConNetworkReconnect) } /* Don't resolve the address first, just print it directly as it comes from the config file. */ - IConsolePrintF(CC_DEFAULT, "Reconnecting to %s ...", _settings_client.network.last_joined.c_str()); + IConsolePrint(CC_DEFAULT, "Reconnecting to {} ...", _settings_client.network.last_joined); return NetworkClientConnectGame(_settings_client.network.last_joined, playas); } @@ -1235,9 +1227,9 @@ DEF_CONSOLE_CMD(ConNetworkReconnect) DEF_CONSOLE_CMD(ConNetworkConnect) { if (argc == 0) { - IConsoleHelp("Connect to a remote OTTD server and join the game. Usage: 'connect '"); - IConsoleHelp("IP can contain port and company: 'IP[:Port][#Company]', eg: 'server.ottd.org:443#2'"); - IConsoleHelp("Company #255 is spectator all others are a certain company with Company 1 being #1"); + IConsolePrint(CC_HELP, "Connect to a remote OTTD server and join the game. Usage: 'connect '."); + IConsolePrint(CC_HELP, "IP can contain port and company: 'IP[:Port][#Company]', eg: 'server.ottd.org:443#2'."); + IConsolePrint(CC_HELP, "Company #255 is spectator all others are a certain company with Company 1 being #1."); return true; } @@ -1253,7 +1245,7 @@ DEF_CONSOLE_CMD(ConNetworkConnect) DEF_CONSOLE_CMD(ConExec) { if (argc == 0) { - IConsoleHelp("Execute a local script file. Usage: 'exec