aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Drosdo.www <g1ran1q@gmail.com>2020-06-17 23:14:27 +0300
committerGitHub <noreply@github.com>2020-06-17 22:14:27 +0200
commit1e9c84a3ea0c3f255779eada0d804fab15e2e434 (patch)
treee5d16b36ea77869d88fb714892aab6f2b6505452
parent8fef9aaf75c05190a59e8b3c8d7799f883970e2e (diff)
Worldserver/CLI: console printf fix (#24802)
* Remove extra cli printf call for non-Windows systems * Codestyle changes Co-authored-by: Giacomo Pozzoni <giacomopoz@gmail.com>
-rw-r--r--src/server/worldserver/CommandLine/CliRunnable.cpp29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/server/worldserver/CommandLine/CliRunnable.cpp b/src/server/worldserver/CommandLine/CliRunnable.cpp
index dcfbd12cc48..c71213761f2 100644
--- a/src/server/worldserver/CommandLine/CliRunnable.cpp
+++ b/src/server/worldserver/CommandLine/CliRunnable.cpp
@@ -32,7 +32,16 @@
#include <readline/readline.h>
#include <readline/history.h>
#include "Chat.h"
+#endif
+
+static constexpr char CLI_PREFIX[] = "TC> ";
+static inline void PrintCliPrefix()
+{
+ printf("%s", CLI_PREFIX);
+}
+
+#if TRINITY_PLATFORM != TRINITY_PLATFORM_WINDOWS
char* command_finder(char const* text, int state)
{
static size_t idx, len;
@@ -102,7 +111,7 @@ void utf8print(void* /*arg*/, char const* str)
void commandFinished(void*, bool /*success*/)
{
- printf("TC> ");
+ PrintCliPrefix();
fflush(stdout);
}
@@ -124,9 +133,11 @@ int kb_hit_return()
/// %Thread start
void CliThread()
{
- ///- Display the list of available CLI functions then beep
- //TC_LOG_INFO("server.worldserver", "");
-#if TRINITY_PLATFORM != TRINITY_PLATFORM_WINDOWS
+#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
+ // print this here the first time
+ // later it will be printed after command queue updates
+ PrintCliPrefix();
+#else
rl_attempted_completion_function = cli_completion;
rl_event_hook = cli_hook_func;
#endif
@@ -134,10 +145,6 @@ void CliThread()
if (sConfigMgr->GetBoolDefault("BeepAtStart", true))
printf("\a"); // \a = Alert
- // print this here the first time
- // later it will be printed after command queue updates
- printf("TC>");
-
///- As long as the World is running (no World::m_stopEvent), get the command line and handle it
while (!World::IsStopped())
{
@@ -151,12 +158,12 @@ void CliThread()
{
if (!WStrToUtf8(commandbuf, wcslen(commandbuf), command))
{
- printf("TC>");
+ PrintCliPrefix();
continue;
}
}
#else
- char* command_str = readline("TC>");
+ char* command_str = readline(CLI_PREFIX);
rl_bind_key('\t', rl_complete);
if (command_str != nullptr)
{
@@ -173,7 +180,7 @@ void CliThread()
if (nextLineIndex == 0)
{
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
- printf("TC>");
+ PrintCliPrefix();
#endif
continue;
}