From ddfb59d185b760841e1b7731f8891784df538ec1 Mon Sep 17 00:00:00 2001 From: SteelT Date: Sun, 11 Feb 2024 23:31:34 -0500 Subject: [PATCH] Add common I_GetSysName function Replaces the OS defines in Command_Version_f() with a common function to fetch the system name the game is currently running on. --- src/dummy/i_system.c | 5 +++++ src/i_system.h | 4 ++++ src/netcode/d_netcmd.c | 13 +------------ src/sdl/i_system.c | 6 ++++++ 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/dummy/i_system.c b/src/dummy/i_system.c index fe33cfe3e..ecabe3576 100644 --- a/src/dummy/i_system.c +++ b/src/dummy/i_system.c @@ -206,5 +206,10 @@ void I_GetCursorPosition(INT32 *x, INT32 *y) (void)y; } +const char *I_GetSysName(void) +{ + return NULL; +} + #include "../sdl/dosstr.c" diff --git a/src/i_system.h b/src/i_system.h index 834dd4091..3f0e05d12 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -335,4 +335,8 @@ void I_GetCursorPosition(INT32 *x, INT32 *y); */ void I_SetMouseGrab(boolean grab); +/** \brief Returns the system name. +*/ +const char *I_GetSysName(void); + #endif diff --git a/src/netcode/d_netcmd.c b/src/netcode/d_netcmd.c index 87f0110a9..085aa2552 100644 --- a/src/netcode/d_netcmd.c +++ b/src/netcode/d_netcmd.c @@ -3812,18 +3812,7 @@ static void Command_Version_f(void) #endif // OS - // Would be nice to use SDL_GetPlatform for this -#if defined (_WIN32) || defined (_WIN64) - CONS_Printf("Windows "); -#elif defined(__linux__) - CONS_Printf("Linux "); -#elif defined(MACOSX) - CONS_Printf("macOS "); -#elif defined(UNIXCOMMON) - CONS_Printf("Unix (Common) "); -#else - CONS_Printf("Other OS "); -#endif + CONS_Printf("%s ", I_GetSysName()); // Bitness if (sizeof(void*) == 4) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 847806270..8faf56d3b 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -3256,4 +3256,10 @@ const CPUInfoFlags *I_CPUInfo(void) // note CPUAFFINITY code used to reside here void I_RegisterSysCommands(void) {} + +const char *I_GetSysName(void) +{ + return SDL_GetPlatform(); +} + #endif