From 51b5d7a41d8d70ae07e86aa20c6220bcef23eae8 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Wed, 4 Jan 2023 19:39:52 +0300 Subject: [PATCH] engine: host: ensure we always have right slashes under Windows --- engine/common/host.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/engine/common/host.c b/engine/common/host.c index 3de404a3..c0515eae 100644 --- a/engine/common/host.c +++ b/engine/common/host.c @@ -1006,7 +1006,7 @@ void Host_InitCommon( int argc, char **argv, const char *progname, qboolean bCha if( COM_CheckString( baseDir ) ) { - Q_strncpy( host.rootdir, baseDir, sizeof(host.rootdir) ); + Q_strncpy( host.rootdir, baseDir, sizeof( host.rootdir )); } else { @@ -1018,10 +1018,10 @@ void Host_InitCommon( int argc, char **argv, const char *progname, qboolean bCha if( !( szBasePath = SDL_GetBasePath() ) ) Sys_Error( "couldn't determine current directory: %s", SDL_GetError() ); - Q_strncpy( host.rootdir, szBasePath, sizeof( host.rootdir ) ); + Q_strncpy( host.rootdir, szBasePath, sizeof( host.rootdir )); SDL_free( szBasePath ); #else - if( !getcwd( host.rootdir, sizeof(host.rootdir) ) ) + if( !getcwd( host.rootdir, sizeof( host.rootdir ))) { Sys_Error( "couldn't determine current directory: %s", strerror( errno ) ); host.rootdir[0] = 0; @@ -1029,6 +1029,10 @@ void Host_InitCommon( int argc, char **argv, const char *progname, qboolean bCha #endif } +#if XASH_WIN32 + COM_FixSlashes( host.rootdir ); +#endif + len = Q_strlen( host.rootdir ); if( len && host.rootdir[len - 1] == '/' ) @@ -1045,6 +1049,10 @@ void Host_InitCommon( int argc, char **argv, const char *progname, qboolean bCha Q_strncpy( host.rodir, roDir, sizeof( host.rodir )); } +#if XASH_WIN32 + COM_FixSlashes( host.rootdir ); +#endif + len = Q_strlen( host.rodir ); if( len && host.rodir[len - 1] == '/' )