From 8794e411bd57d9c5017ba38137770a586c558b06 Mon Sep 17 00:00:00 2001 From: Hanicef Date: Wed, 20 Mar 2024 19:23:13 +0100 Subject: [PATCH 1/2] Don't traverse the entire HOME directory to find wads --- src/dedicated/i_system.c | 8 +++++++- src/sdl/i_system.c | 10 ++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/dedicated/i_system.c b/src/dedicated/i_system.c index 858dfaf20..b231080a8 100644 --- a/src/dedicated/i_system.c +++ b/src/dedicated/i_system.c @@ -1433,9 +1433,15 @@ static const char *locateWad(void) #ifndef NOHOME // find in $HOME - I_OutputMsg(",HOME"); + I_OutputMsg(",HOME/.srb2"); if ((envstr = I_GetEnv("HOME")) != NULL) + { + char *tmp = malloc(strlen(envstr) + sizeof("/.srb2")); + strcpy(tmp, envstr); + strcat(tmp, "/.srb2"); SEARCHWAD(envstr); + free(tmp); + } #endif // search paths diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 9f0fa0250..c6750ce74 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -3038,10 +3038,16 @@ static const char *locateWad(void) } #ifndef NOHOME - // find in $HOME - I_OutputMsg(",HOME"); + // find in $HOME/.srb2 + I_OutputMsg(",HOME/.srb2"); if ((envstr = I_GetEnv("HOME")) != NULL) + { + char *tmp = malloc(strlen(envstr) + sizeof("/.srb2")); + strcpy(tmp, envstr); + strcat(tmp, "/.srb2"); SEARCHWAD(envstr); + free(tmp); + } #endif // search paths From 10365e943aacd35d7b1052cdc4543556b94ee6f8 Mon Sep 17 00:00:00 2001 From: Hanicef Date: Wed, 20 Mar 2024 20:44:17 +0100 Subject: [PATCH 2/2] Use DEFAULTDIR instead of hardcoding .srb2 --- src/dedicated/i_system.c | 6 +++--- src/sdl/i_system.c | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/dedicated/i_system.c b/src/dedicated/i_system.c index b231080a8..61b7a239a 100644 --- a/src/dedicated/i_system.c +++ b/src/dedicated/i_system.c @@ -1433,12 +1433,12 @@ static const char *locateWad(void) #ifndef NOHOME // find in $HOME - I_OutputMsg(",HOME/.srb2"); + I_OutputMsg(",HOME/" DEFAULTDIR); if ((envstr = I_GetEnv("HOME")) != NULL) { - char *tmp = malloc(strlen(envstr) + sizeof("/.srb2")); + char *tmp = malloc(strlen(envstr) + sizeof(DEFAULTDIR)); strcpy(tmp, envstr); - strcat(tmp, "/.srb2"); + strcat(tmp, DEFAULTDIR); SEARCHWAD(envstr); free(tmp); } diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index c6750ce74..64fcb2f2b 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -3038,13 +3038,13 @@ static const char *locateWad(void) } #ifndef NOHOME - // find in $HOME/.srb2 - I_OutputMsg(",HOME/.srb2"); + // find in $HOME + I_OutputMsg(",HOME/" DEFAULTDIR); if ((envstr = I_GetEnv("HOME")) != NULL) { - char *tmp = malloc(strlen(envstr) + sizeof("/.srb2")); + char *tmp = malloc(strlen(envstr) + sizeof(DEFAULTDIR)); strcpy(tmp, envstr); - strcat(tmp, "/.srb2"); + strcat(tmp, DEFAULTDIR); SEARCHWAD(envstr); free(tmp); }