From 950c88c5ece1213a6030d76b720e51f1f3f5d2ea Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Wed, 24 Sep 2014 10:56:58 +0100 Subject: [PATCH] Fix for ghosted plugin CRCs. Also fixed lowercasing. Both fixes just mean one less CRC calculation per affected plugin though. --- src/backend/metadata.cpp | 16 ++++++++-------- src/backend/parsers.h | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/backend/metadata.cpp b/src/backend/metadata.cpp index b41d2c4a..f4cb5fd4 100644 --- a/src/backend/metadata.cpp +++ b/src/backend/metadata.cpp @@ -339,11 +339,17 @@ namespace loot { Plugin::Plugin(loot::Game& game, const std::string& n, const bool headerOnly) : name(n), enabled(true), priority(0), isMaster(false), crc(0), numOverrideRecords(0), _isPriorityExplicit(false) { + //If the name passed ends in '.ghost', that should be trimmed. + if (boost::iends_with(name, ".ghost")) { + BOOST_LOG_TRIVIAL(trace) << name << ": " << "Trimming '.ghost' extension."; + name = name.substr(0, name.length() - 6); + } + // Get data from file contents using libespm. Assumes libespm has already been initialised. BOOST_LOG_TRIVIAL(trace) << name << ": " << "Opening with libespm..."; boost::filesystem::path filepath = game.DataPath() / name; - //In case the plugin is ghosted, but the extension already got trimmed. + //In case the plugin is ghosted. if (!boost::filesystem::exists(filepath) && boost::filesystem::exists(filepath.string() + ".ghost")) filepath += ".ghost"; @@ -368,7 +374,7 @@ namespace loot { BOOST_LOG_TRIVIAL(trace) << name << ": " << "Getting CRC."; crc = file->crc; - game.crcCache.insert(pair(n, crc)); + game.crcCache.insert(pair(boost::locale::to_lower(name), crc)); BOOST_LOG_TRIVIAL(trace) << name << ": " << "Getting the FormIDs."; vector records = file->getFormIDs(); @@ -421,12 +427,6 @@ namespace loot { messages.push_back(loot::Message(loot::Message::error, (boost::format(boost::locale::translate("Cannot read \"%1%\". Details: %2%")) % name % e.what()).str())); } - //If the name passed ends in '.ghost', that should be trimmed. - if (boost::iends_with(name, ".ghost")) { - BOOST_LOG_TRIVIAL(trace) << name << ": " << "Trimming '.ghost' extension."; - name = name.substr(0, name.length() - 6); - } - BOOST_LOG_TRIVIAL(trace) << name << ": " << "Plugin loading complete."; } diff --git a/src/backend/parsers.h b/src/backend/parsers.h index c826c7a7..77520308 100644 --- a/src/backend/parsers.h +++ b/src/backend/parsers.h @@ -583,7 +583,7 @@ namespace loot { } uint32_t crc; - unordered_map::iterator it = _game.crcCache.find(boost::to_lower_copy(file)); + unordered_map::iterator it = _game.crcCache.find(boost::locale::to_lower(file)); if (it != _game.crcCache.end()) crc = it->second; @@ -599,7 +599,7 @@ namespace loot { return; } - _game.crcCache.emplace(boost::to_lower_copy(file), crc); + _game.crcCache.emplace(boost::locale::to_lower(file), crc); } result = checksum == crc;