Skip to content

Commit

Permalink
bugfix: text color in windows consoles (otland#4044)
Browse files Browse the repository at this point in the history
otland#3940 introduced a colored message
colored messages sometimes fail to process in command prompt/powershell
this code fixes that issue

(cherry picked from commit 73bdc12)
  • Loading branch information
Zbizu authored and Codinablack committed Apr 5, 2022
1 parent 646ceb1 commit 3237661
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/otserv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,13 @@ void mainLoader(int, char*[], ServiceManager* services)
srand(static_cast<unsigned int>(OTSYS_TIME()));
#ifdef _WIN32
SetConsoleTitle(STATUS_SERVER_NAME);

// fixes a problem with escape characters not being processed in Windows consoles
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
DWORD dwMode = 0;
GetConsoleMode(hOut, &dwMode);
dwMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
SetConsoleMode(hOut, dwMode);
#endif

printServerVersion();
Expand Down

0 comments on commit 3237661

Please sign in to comment.