diff --git a/src/util/util.c b/src/util/util.c index 1e6c743e4e..30f874385a 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -71,9 +71,7 @@ void path_set_extension(char *path, const char *extension) void path_remove_extension(char *path) { - char *ch = path; - - while (*ch != '\0') ++ch; + char *ch = path + strlen(path); for (--ch; ch >= path; --ch) { if (*ch == '.') { *ch = '\0'; diff --git a/src/windows/loadsave.c b/src/windows/loadsave.c index b1ba7ee8ed..c19ed2bac4 100644 --- a/src/windows/loadsave.c +++ b/src/windows/loadsave.c @@ -346,8 +346,7 @@ static void window_loadsave_scrollmousedown() char *templateString; templateString = (char*)language_get_string(templateStringId); - int folderlength = strlen(RCT2_ADDRESS(RCT2_ADDRESS_SAVED_GAMES_PATH, char)); - strcpy(templateString, RCT2_ADDRESS(RCT2_ADDRESS_SAVED_GAMES_PATH_2 + folderlength, char)); + strcpy(templateString, path_get_filename(RCT2_ADDRESS(RCT2_ADDRESS_SAVED_GAMES_PATH_2, char))); path_remove_extension(templateString); window_text_input_open(w, WIDX_SCROLL, STR_NONE, 2710, templateStringId, 0, 64);