From 6c12f45f3b7d7eab32ed29860d2261fc8a512f0e Mon Sep 17 00:00:00 2001 From: Mikhail Redko Date: Tue, 11 May 2021 10:55:57 +0300 Subject: Core/Console: Improve ReadWinConsole logic and cosmetic changes (#26402) * Core/Console: Improve ReadWinConsole logic and cosmetic changes * Core/Console: Fixed possible appearance of weird characters in the console when printing the output of child processes * Fix codestyle * Removed auto * Core/Misc: Explicit casting Difficulty values to uint8 before outputting to console * Core/Misc: Cast Difficulty to uint32 for output to console Co-authored-by: jackpoz --- src/server/worldserver/CommandLine/CliRunnable.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'src/server/worldserver/CommandLine') diff --git a/src/server/worldserver/CommandLine/CliRunnable.cpp b/src/server/worldserver/CommandLine/CliRunnable.cpp index 2d858c415d4..ef1c12f9b67 100644 --- a/src/server/worldserver/CommandLine/CliRunnable.cpp +++ b/src/server/worldserver/CommandLine/CliRunnable.cpp @@ -136,10 +136,7 @@ void CliThread() #if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS if (!ReadWinConsole(command)) - { - PrintCliPrefix(); continue; - } #else char* command_str = readline(CLI_PREFIX); ::rl_bind_key('\t', ::rl_complete); @@ -152,18 +149,13 @@ void CliThread() if (!command.empty()) { - std::size_t nextLineIndex = command.find_first_of("\r\n"); - if (nextLineIndex != std::string::npos) + Optional nextLineIndex = RemoveCRLF(command); + if (nextLineIndex && *nextLineIndex == 0) { - if (nextLineIndex == 0) - { #if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS - PrintCliPrefix(); + PrintCliPrefix(); #endif - continue; - } - - command.erase(nextLineIndex); + continue; } fflush(stdout); -- cgit v1.2.3