mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
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>
(cherry picked from commit 1e9c84a3ea)
This commit is contained in:
@@ -37,7 +37,16 @@
|
||||
#if TRINITY_PLATFORM != TRINITY_PLATFORM_WINDOWS
|
||||
#include <readline/readline.h>
|
||||
#include <readline/history.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;
|
||||
@@ -107,7 +116,7 @@ void utf8print(void* /*arg*/, char const* str)
|
||||
|
||||
void commandFinished(void*, bool /*success*/)
|
||||
{
|
||||
printf("TC> ");
|
||||
PrintCliPrefix();
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
@@ -129,9 +138,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
|
||||
@@ -139,10 +150,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())
|
||||
{
|
||||
@@ -156,12 +163,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)
|
||||
{
|
||||
@@ -178,7 +185,7 @@ void CliThread()
|
||||
if (nextLineIndex == 0)
|
||||
{
|
||||
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
|
||||
printf("TC>");
|
||||
PrintCliPrefix();
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user