From 6b0a39774af94ead1fbd778d954b9b45b656580e Mon Sep 17 00:00:00 2001 From: Sude Date: Sat, 11 Oct 2014 02:40:29 +0300 Subject: [PATCH] Better handling of empty %platform% in Util::filepathReplaceReservedStrings --- src/util.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/util.cpp b/src/util.cpp index 8bbd6a0..8d4ba1a 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -293,8 +293,6 @@ int Util::replaceString(std::string& str, const std::string& to_replace, const s void Util::filepathReplaceReservedStrings(std::string& str, const std::string& gamename, const unsigned int& platformId, const std::string& dlcname) { std::string platform; - while (Util::replaceString(str, "%gamename%", gamename)); - while (Util::replaceString(str, "%dlcname%", dlcname)); for (unsigned int i = 0; i < GlobalConstants::PLATFORMS.size(); ++i) { if ((platformId & GlobalConstants::PLATFORMS[i].platformId) == GlobalConstants::PLATFORMS[i].platformId) @@ -303,7 +301,16 @@ void Util::filepathReplaceReservedStrings(std::string& str, const std::string& g break; } } + if (platform.empty()) + { + if (str.find("%gamename%/%platform%") != std::string::npos) + platform = ""; + else + platform = "no_platform"; + } + while (Util::replaceString(str, "%gamename%", gamename)); + while (Util::replaceString(str, "%dlcname%", dlcname)); while (Util::replaceString(str, "%platform%", platform)); while (Util::replaceString(str, "//", "/")); // Replace any double slashes with single slash }