From c0daa89ad59c05b30f9d23dce7bfc5d3e0eecfda Mon Sep 17 00:00:00 2001 From: Kp Date: Sun, 5 Jul 2020 23:34:33 +0000 Subject: [PATCH] Avoid reopening descent.sng If !canUseExtensions, then fp is already open to descent.sng. There is no need to reopen it just to get its length. --- similar/main/songs.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/similar/main/songs.cpp b/similar/main/songs.cpp index 2041aa981..7c50ed69c 100644 --- a/similar/main/songs.cpp +++ b/similar/main/songs.cpp @@ -242,7 +242,9 @@ static void songs_init() #if defined(DXX_BUILD_DESCENT_I) // HACK: If Descent.hog is patched from 1.0 to 1.5, descent.sng is turncated. So let's patch it up here constexpr std::size_t truncated_song_count = 12; - if (!canUseExtensions && main_songs.size() == truncated_song_count && PHYSFSX_fsize("descent.sng") == 422) + if (!canUseExtensions && + main_songs.size() == truncated_song_count && + PHYSFS_fileLength(fp) == 422) { main_songs.resize(truncated_song_count + 15); for (i = 12; i <= 26; i++)