From 75afd25e1673fe7ad55e9011f7741fedaa46c8c1 Mon Sep 17 00:00:00 2001 From: rubidium42 Date: Sat, 12 Jun 2021 21:37:19 +0200 Subject: [PATCH] Change: do not print the '-' in front of help messages and make help messages more uniform --- src/console.cpp | 2 +- src/console_cmds.cpp | 271 +++++++++++++++++++++---------------------- 2 files changed, 132 insertions(+), 141 deletions(-) diff --git a/src/console.cpp b/src/console.cpp index dcc0725dff..10e0bc279a 100644 --- a/src/console.cpp +++ b/src/console.cpp @@ -267,7 +267,7 @@ static void IConsoleAliasExec(const IConsoleAlias *alias, byte tokencount, char if (param < 0 || param >= tokencount) { IConsolePrint(CC_ERROR, "Too many or wrong amount of parameters passed to alias."); - IConsolePrint(CC_HELP, "Usage of alias '{}': {}", alias->name, alias->cmdline); + IConsolePrint(CC_HELP, "Usage of alias '{}': '{}'.", alias->name, alias->cmdline); return; } diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index e719c153d7..09b1db4af9 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -185,15 +185,6 @@ DEF_CONSOLE_HOOK(ConHookNewGRFDeveloperTool) return CHR_HIDE; } -/** - * Show help for the console. - * @param str String to print in the console. - */ -static void IConsoleHelp(const char *str) -{ - IConsolePrint(CC_HELP, "- {}", str); -} - /** * Reset status of all engines. * @return Will always succeed. @@ -201,7 +192,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; } @@ -217,7 +208,7 @@ 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; } @@ -243,8 +234,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; } @@ -273,9 +264,9 @@ DEF_CONSOLE_CMD(ConScrollToTile) { switch (argc) { case 0: - IConsoleHelp("Center the screen on a given tile."); - IConsoleHelp("Usage: 'scrollto ' or 'scrollto '"); - IConsoleHelp("Numbers can be either decimal (34161) or hexadecimal (0x4a5B)."); + IConsolePrint(CC_HELP, "Center the screen on a given tile."); + IConsolePrint(CC_HELP, "Usage: 'scrollto ' or 'scrollto '."); + IConsolePrint(CC_HELP, "Numbers can be either decimal (34161) or hexadecimal (0x4a5B)."); return true; case 2: { @@ -316,7 +307,7 @@ DEF_CONSOLE_CMD(ConScrollToTile) 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; } @@ -343,8 +334,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; } @@ -356,7 +347,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; } @@ -385,7 +376,7 @@ DEF_CONSOLE_CMD(ConLoad) 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; } @@ -411,7 +402,7 @@ 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; } @@ -427,7 +418,7 @@ DEF_CONSOLE_CMD(ConListFiles) 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; } @@ -456,7 +447,7 @@ DEF_CONSOLE_CMD(ConPrintWorkingDirectory) const char *path; 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; } @@ -472,7 +463,7 @@ DEF_CONSOLE_CMD(ConPrintWorkingDirectory) 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; } @@ -532,8 +523,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; } @@ -555,9 +546,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; } @@ -579,8 +570,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; } @@ -611,7 +602,7 @@ 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; } @@ -629,7 +620,7 @@ 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; } @@ -651,7 +642,7 @@ 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; } @@ -677,8 +668,8 @@ DEF_CONSOLE_CMD(ConUnpauseGame) 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; } @@ -695,7 +686,7 @@ DEF_CONSOLE_CMD(ConRcon) 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; } @@ -706,8 +697,8 @@ 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', 'network.max_companies' and 'network.max_spectators'"); + 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', 'network.max_companies' and 'network.max_spectators'."); return true; } @@ -721,8 +712,8 @@ 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; } @@ -755,8 +746,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; } @@ -802,8 +793,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; } @@ -845,8 +836,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; } @@ -885,7 +876,7 @@ DEF_CONSOLE_CMD(ConResetCompany) 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; } @@ -897,9 +888,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; } @@ -928,9 +919,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; } @@ -946,7 +937,7 @@ DEF_CONSOLE_CMD(ConNetworkConnect) DEF_CONSOLE_CMD(ConExec) { if (argc == 0) { - IConsoleHelp("Execute a local script file. Usage: 'exec