From 70df2b661e9c632d04825b259e63ad58c29c01ac Mon Sep 17 00:00:00 2001 From: Jaycie Ewald Date: Tue, 23 May 2023 14:36:33 -0500 Subject: [PATCH] fix QS not opening from tracker --- Quake/sys_sdl_unix.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Quake/sys_sdl_unix.c b/Quake/sys_sdl_unix.c index 8820dc58..71c8595b 100644 --- a/Quake/sys_sdl_unix.c +++ b/Quake/sys_sdl_unix.c @@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include #include -#ifdef PLATFORM_OSX +#if defined(PLATFORM_OSX) || defined(PLATFORM_HAIKU) #include /* dirname() and basename() */ #endif #include @@ -321,6 +321,21 @@ static void Sys_GetBasedir (char *argv0, char *dst, size_t dstsize) { char *tmp; + #ifdef PLATFORM_HAIKU + if (realpath(argv0, dst) == NULL) + { + perror("realpath"); + if (getcwd(dst, dstsize - 1) == NULL) + _fail: Sys_Error ("Couldn't determine current directory"); + } + else + { + /* strip off the binary name */ + if (! (tmp = strdup (dst))) goto _fail; + q_strlcpy (dst, dirname(tmp), dstsize); + free (tmp); + } + #else if (getcwd(dst, dstsize - 1) == NULL) Sys_Error ("Couldn't determine current directory"); @@ -333,6 +348,7 @@ static void Sys_GetBasedir (char *argv0, char *dst, size_t dstsize) if (tmp != dst && *tmp == '/') *tmp = 0; } + #endif } #endif