diff --git a/src/debug.h b/src/debug.h index 28a3cc88eb..6279ba8166 100644 --- a/src/debug.h +++ b/src/debug.h @@ -128,9 +128,14 @@ std::string GetDebugString(); } -void ShowInfo(const char *str); +void ShowInfoI(const char *str); void CDECL ShowInfoF(const char *str, ...) WARN_FORMAT(1, 2); +inline void ShowInfoI(const std::string &str) +{ + ShowInfoI(str.c_str()); +} + struct log_prefix { const char *GetLogPrefix(); diff --git a/src/debug_fmt.h b/src/debug_fmt.h index 5ad25d559f..d4d4851c17 100644 --- a/src/debug_fmt.h +++ b/src/debug_fmt.h @@ -13,6 +13,8 @@ #include "debug.h" #include "core/format.hpp" +#define ShowInfo(format_string, ...) ShowInfoI(fmt::format(FMT_STRING(format_string), ## __VA_ARGS__)) + /** * Ouptut a line of debugging information. * @param name The category of debug information. diff --git a/src/openttd.cpp b/src/openttd.cpp index 70b79b3522..8d46d260ff 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -259,7 +259,7 @@ void CDECL ShowInfoF(const char *str, ...) va_start(va, str); vseprintf(buf, lastof(buf), str, va); va_end(va); - ShowInfo(buf); + ShowInfoI(buf); } /** @@ -343,7 +343,7 @@ static void ShowHelp() #if !defined(_WIN32) printf("%s\n", buf); #else - ShowInfo(buf); + ShowInfoI(buf); #endif } @@ -402,7 +402,7 @@ static void WriteSavegameInfo(const char *name) #if !defined(_WIN32) printf("%s\n", buf); #else - ShowInfo(buf); + ShowInfoI(buf); #endif } @@ -445,7 +445,7 @@ static void WriteSavegameDebugData(const char *name) #if !defined(_WIN32) printf("%s\n", buf); #else - ShowInfo(buf); + ShowInfoI(buf); #endif free(buf); } @@ -805,7 +805,7 @@ int openttd_main(int argc, char *argv[]) videodriver = "dedicated"; blitter = "null"; dedicated = true; - SetDebugString("net=3", ShowInfo); + SetDebugString("net=3", ShowInfoI); if (mgo.opt != nullptr) { scanner->dedicated_host = ParseFullConnectionString(mgo.opt, scanner->dedicated_port); } @@ -829,7 +829,7 @@ int openttd_main(int argc, char *argv[]) #if defined(_WIN32) CreateConsole(); #endif - if (mgo.opt != nullptr) SetDebugString(mgo.opt, ShowInfo); + if (mgo.opt != nullptr) SetDebugString(mgo.opt, ShowInfoI); break; } case 'e': _switch_mode = (_switch_mode == SM_LOAD_GAME || _switch_mode == SM_LOAD_SCENARIO ? SM_LOAD_SCENARIO : SM_EDITOR); break; diff --git a/src/os/unix/unix.cpp b/src/os/unix/unix.cpp index 291c57507a..c27a97a082 100644 --- a/src/os/unix/unix.cpp +++ b/src/os/unix/unix.cpp @@ -202,7 +202,7 @@ std::string FS2OTTD(const std::string &name) #endif /* WITH_ICONV */ -void ShowInfo(const char *str) +void ShowInfoI(const char *str) { fprintf(stderr, "%s\n", str); } diff --git a/src/os/windows/win32.cpp b/src/os/windows/win32.cpp index d20f4c267f..fd9a12c94a 100644 --- a/src/os/windows/win32.cpp +++ b/src/os/windows/win32.cpp @@ -274,7 +274,7 @@ void CreateConsole() _close(fd); CloseHandle(hand); - ShowInfo("Unable to open an output handle to the console. Check known-bugs.txt for details."); + ShowInfoI("Unable to open an output handle to the console. Check known-bugs.txt for details."); return; } @@ -339,7 +339,7 @@ static INT_PTR CALLBACK HelpDialogFunc(HWND wnd, UINT msg, WPARAM wParam, LPARAM return FALSE; } -void ShowInfo(const char *str) +void ShowInfoI(const char *str) { if (_has_console) { fprintf(stderr, "%s\n", str); diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index afa607531a..f5551451d5 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -471,7 +471,7 @@ static void CDECL HandleSavegameLoadCrash(int signum) "Please file a bug report and attach this savegame.\n"); } - ShowInfo(buffer); + ShowInfoI(buffer); #ifdef WITH_SIGACTION struct sigaction call;