From 7e03dd0f1247f152e10bf6e09ec7478b2972da00 Mon Sep 17 00:00:00 2001 From: tri4ng1e Date: Thu, 17 May 2018 21:07:20 +0300 Subject: [PATCH] Read data paths from `data-local` section too --- apps/mwiniimporter/importer.cpp | 27 ++++++++++++++++----------- apps/mwiniimporter/importer.hpp | 1 + 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/apps/mwiniimporter/importer.cpp b/apps/mwiniimporter/importer.cpp index 3433fe5c7..6f5c2e2cd 100644 --- a/apps/mwiniimporter/importer.cpp +++ b/apps/mwiniimporter/importer.cpp @@ -859,6 +859,17 @@ std::vector::iterator MwIniImporter::findString(std::vector& output, std::vector input) { + for (auto& path : input) { + if (path.front() == '"') + { + path.erase(path.begin()); + path.erase(path.end() - 1); + } + output.emplace_back(path); + } +} + void MwIniImporter::importGameFiles(multistrmap &cfg, const multistrmap &ini, const boost::filesystem::path& iniFilename) const { std::vector> contentFiles; @@ -869,17 +880,11 @@ void MwIniImporter::importGameFiles(multistrmap &cfg, const multistrmap &ini, co std::vector dataPaths; if (cfg.count("data")) - { - for (std::string filePathString : cfg["data"]) - { - if (filePathString.front() == '"') - { - filePathString.erase(filePathString.begin()); - filePathString.erase(filePathString.end() - 1); - } - dataPaths.emplace_back(filePathString); - } - } + addPaths(dataPaths, cfg["data"]); + + if (cfg.count("data-local")) + addPaths(dataPaths, cfg["data-local"]); + dataPaths.push_back(iniFilename.parent_path() /= "Data Files"); multistrmap::const_iterator it = ini.begin(); diff --git a/apps/mwiniimporter/importer.hpp b/apps/mwiniimporter/importer.hpp index d99866533..7b710a4a4 100644 --- a/apps/mwiniimporter/importer.hpp +++ b/apps/mwiniimporter/importer.hpp @@ -35,6 +35,7 @@ class MwIniImporter { static std::vector::iterator findString(std::vector& source, const std::string& string); static void insertMultistrmap(multistrmap &cfg, const std::string& key, const std::string& value); + static void addPaths(std::vector& output, std::vector input); /// \return file's "last modified time", used in original MW to determine plug-in load order static std::time_t lastWriteTime(const boost::filesystem::path& filename, std::time_t defaultTime);