From 565e9ff8aa9cd396562afd6b087a7009ca287016 Mon Sep 17 00:00:00 2001 From: Kitzunu <24550914+Kitzunu@users.noreply.github.com> Date: Sat, 22 May 2021 15:14:04 +0200 Subject: [PATCH] refactor(Core/CliRunnable): Make AC> a static (#5621) --- .../worldserver/CommandLine/CliRunnable.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/server/worldserver/CommandLine/CliRunnable.cpp b/src/server/worldserver/CommandLine/CliRunnable.cpp index 751319a41..bda81a18f 100644 --- a/src/server/worldserver/CommandLine/CliRunnable.cpp +++ b/src/server/worldserver/CommandLine/CliRunnable.cpp @@ -22,6 +22,13 @@ #include "World.h" #include "WorldSession.h" +static constexpr char CLI_PREFIX[] = "AC> "; + +static inline void PrintCliPrefix() +{ + printf("%s", CLI_PREFIX); +} + #if AC_PLATFORM != AC_PLATFORM_WINDOWS #include #include @@ -97,7 +104,7 @@ void utf8print(void* /*arg*/, const char* str) void commandFinished(void*, bool /*success*/) { - printf("AC> "); + PrintCliPrefix(); fflush(stdout); } @@ -131,7 +138,7 @@ void CliRunnable::run() // print this here the first time // later it will be printed after command queue updates - printf("AC>"); + PrintCliPrefix(); ///- As long as the World is running (no World::m_stopEvent), get the command line and handle it while (!World::IsStopped()) @@ -144,7 +151,7 @@ void CliRunnable::run() char commandbuf[256]; command_str = fgets(commandbuf, sizeof(commandbuf), stdin); #else - command_str = readline("AC>"); + command_str = readline(CLI_PREFIX); rl_bind_key('\t', rl_complete); #endif @@ -160,7 +167,7 @@ void CliRunnable::run() if (!*command_str) { #if AC_PLATFORM == AC_PLATFORM_WINDOWS - printf("AC>"); + PrintCliPrefix(); #else free(command_str); #endif @@ -171,7 +178,7 @@ void CliRunnable::run() if (!consoleToUtf8(command_str, command)) // convert from console encoding to utf8 { #if AC_PLATFORM == AC_PLATFORM_WINDOWS - printf("AC>"); + PrintCliPrefix(); #else free(command_str); #endif