aboutsummaryrefslogtreecommitdiff
path: root/src/text_file_functions.cpp
diff options
context:
space:
mode:
authorCrystalwarrior <Varsash@Gmail.com>2022-07-26 00:54:11 +0300
committerGitHub <noreply@github.com>2022-07-26 00:54:11 +0300
commitf8c2b1a2f06d2c2f99fa9eaa7b2334524823aac5 (patch)
tree2c1895467a4c9eb681c99ac82d187b15c67f8567 /src/text_file_functions.cpp
parent0dac3cc2c017e8c785cb00c340ea37e050eb6366 (diff)
Part 2 of #713: merge get_real_suffixed_path into get_real_path (#717)
* Fix get_real_suffixed_path existing, causing the previous PR to not function on suffixed... anything Fix suffixes ignoring a case where a suffixed path is already provided, causing that pre-suffixed filepath to fail to find anything * Fix image paths being used as sound effects and vice versa Better check for sfx and image absolute paths which double-checks the absolute path we got is *actually a valid file format* Co-authored-by: stonedDiscord <Tukz@gmx.de> Co-authored-by: Salanto <62221668+Salanto@users.noreply.github.com>
Diffstat (limited to 'src/text_file_functions.cpp')
-rw-r--r--src/text_file_functions.cpp26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/text_file_functions.cpp b/src/text_file_functions.cpp
index dc95dc34..ee6db6b9 100644
--- a/src/text_file_functions.cpp
+++ b/src/text_file_functions.cpp
@@ -544,8 +544,18 @@ QString AOApplication::get_court_sfx(QString p_identifier, QString p_misc)
QString AOApplication::get_sfx_suffix(VPath sound_to_check)
{
- return get_real_suffixed_path(sound_to_check,
- {".opus", ".ogg", ".mp3", ".wav", ".mid", ".midi", ".xm", ".it", ".s3m", ".mod", ".mtm", ".umx" });
+ QStringList suffixes = {".opus", ".ogg", ".mp3", ".wav", ".mid", ".midi", ".xm", ".it", ".s3m", ".mod", ".mtm", ".umx" };
+ // Check if we were provided a direct filepath with a suffix already
+ QString path = sound_to_check.toQString();
+ // Loop through our suffixes
+ for (const QString &suffix : suffixes) {
+ // If our VPath ends with a valid suffix
+ if (path.endsWith(suffix, Qt::CaseInsensitive))
+ // Return that as the path
+ return get_real_path(sound_to_check);
+ }
+ // Otherwise, ignore the provided suffix and check our own
+ return get_real_path(sound_to_check, suffixes);
}
QString AOApplication::get_image_suffix(VPath path_to_check, bool static_image)
@@ -556,7 +566,17 @@ QString AOApplication::get_image_suffix(VPath path_to_check, bool static_image)
}
suffixes.append(".png");
- return get_real_suffixed_path(path_to_check, suffixes);
+ // Check if we were provided a direct filepath with a suffix already
+ QString path = path_to_check.toQString();
+ // Loop through our suffixes
+ for (const QString &suffix : suffixes) {
+ // If our VPath ends with a valid suffix
+ if (path.endsWith(suffix, Qt::CaseInsensitive))
+ // Return that as the path
+ return get_real_path(path_to_check);
+ }
+ // Otherwise, ignore the provided suffix and check our own
+ return get_real_path(path_to_check, suffixes);
}
// returns whatever is to the right of "search_line =" within target_tag and