diff --git a/src/api/api.cpp b/src/api/api.cpp index 53e9d96b..21f7e854 100644 --- a/src/api/api.cpp +++ b/src/api/api.cpp @@ -20,7 +20,7 @@ You should have received a copy of the GNU General Public License along with LOOT. If not, see . -*/ + */ #include "api.h" #include "../backend/game.h" @@ -88,7 +88,6 @@ const unsigned int loot_needs_cleaning_no = 0; const unsigned int loot_needs_cleaning_yes = 1; const unsigned int loot_needs_cleaning_unknown = 2; - struct _loot_db_int { _loot_db_int() : extTagMap(nullptr), @@ -96,26 +95,25 @@ struct _loot_db_int { extRemovedTagIds(nullptr), extMessageArray(nullptr), extMessageArraySize(0) { - extMessage.type = loot_message_say; extMessage.message = nullptr; } ~_loot_db_int() { - delete [] extAddedTagIds; - delete [] extRemovedTagIds; - delete [] extMessage.message; + delete[] extAddedTagIds; + delete[] extRemovedTagIds; + delete[] extMessage.message; if (extTagMap != nullptr) { for (size_t i=0; i < bashTagMap.size(); i++) - delete [] extTagMap[i]; //Gotta clear those allocated strings. - delete [] extTagMap; + delete[] extTagMap[i]; //Gotta clear those allocated strings. + delete[] extTagMap; } if (extMessageArray != nullptr) { for (size_t i=0; i < extMessageArraySize; i++) - delete [] extMessageArray[i].message; //Gotta clear those allocated strings. - delete [] extMessageArray; + delete[] extMessageArray[i].message; //Gotta clear those allocated strings. + delete[] extMessageArray; } } @@ -173,7 +171,6 @@ namespace loot { } } - ////////////////////////////// // Error Handling Functions ////////////////////////////// @@ -181,7 +178,7 @@ namespace loot { // Outputs a string giving the details of the last time an error or // warning return code was returned by a function. The string exists // until this function is called again or until CleanUpAPI is called. -LOOT_API unsigned int loot_get_error_message (const char ** const message) { +LOOT_API unsigned int loot_get_error_message(const char ** const message) { if (message == nullptr) return c_error(loot_error_invalid_args, "Null message pointer passed."); @@ -191,26 +188,25 @@ LOOT_API unsigned int loot_get_error_message (const char ** const message) { } // Frees memory allocated to error string. -LOOT_API void loot_cleanup () { - delete [] extMessageStr; +LOOT_API void loot_cleanup() { + delete[] extMessageStr; extMessageStr = nullptr; } - ////////////////////////////// // Version Functions ////////////////////////////// // Returns whether this version of LOOT supports the API from the given // LOOT version. Abstracts LOOT API stability policy away from clients. -LOOT_API bool loot_is_compatible (const unsigned int versionMajor, const unsigned int versionMinor, const unsigned int versionPatch) { +LOOT_API bool loot_is_compatible(const unsigned int versionMajor, const unsigned int versionMinor, const unsigned int versionPatch) { return versionMajor == loot::g_version_major && versionMinor == loot::g_version_minor; } // Returns the version string for this version of LOOT. // The string exists until this function is called again or until // CleanUpAPI is called. -LOOT_API unsigned int loot_get_version (unsigned int * const versionMajor, unsigned int * const versionMinor, unsigned int * const versionPatch) { +LOOT_API unsigned int loot_get_version(unsigned int * const versionMajor, unsigned int * const versionMinor, unsigned int * const versionPatch) { if (versionMajor == nullptr || versionMinor == nullptr || versionPatch == nullptr) return c_error(loot_error_invalid_args, "Null pointer passed."); @@ -221,7 +217,6 @@ LOOT_API unsigned int loot_get_version (unsigned int * const versionMajor, unsig return loot_ok; } - //////////////////////////////////// // Lifecycle Management Functions //////////////////////////////////// @@ -233,7 +228,7 @@ LOOT_API unsigned int loot_get_version (unsigned int * const versionMajor, unsig // plugins.txt and loadorder.txt (if they both exist) are in sync. If // dataPath == nullptr then the API will attempt to detect the data path of // the specified game. -LOOT_API unsigned int loot_create_db (loot_db * const db, const unsigned int clientGame, const char * const gamePath) { +LOOT_API unsigned int loot_create_db(loot_db * const db, const unsigned int clientGame, const char * const gamePath) { if (db == nullptr || (clientGame != loot_game_tes4 && clientGame != loot_game_tes5 && clientGame != loot_game_fo3 && clientGame != loot_game_fonv)) return c_error(loot_error_invalid_args, "Null pointer passed."); @@ -253,14 +248,16 @@ LOOT_API unsigned int loot_create_db (loot_db * const db, const unsigned int cli loot::Game game; try { game = loot::Game(clientGame).SetPath(game_path).Init(); //This also checks to see if the game is installed if game_path is empty and throws an exception if it is not detected. It also creates a folder in %LOCALAPPDATA% and reads the active plugins list, but that shouldn't be an issue. - } catch (loot::error& e) { + } + catch (loot::error& e) { return c_error(e); } loot_db retVal; try { retVal = new _loot_db_int; - } catch (std::bad_alloc& e) { + } + catch (std::bad_alloc& e) { return c_error(loot_error_no_mem, e.what()); } retVal->game = game; @@ -270,11 +267,10 @@ LOOT_API unsigned int loot_create_db (loot_db * const db, const unsigned int cli } // Destroys the given DB, freeing any memory allocated as part of its use. -LOOT_API void loot_destroy_db (loot_db db) { +LOOT_API void loot_destroy_db(loot_db db) { delete db; } - /////////////////////////////////// // Database Loading Functions /////////////////////////////////// @@ -283,8 +279,8 @@ LOOT_API void loot_destroy_db (loot_db db) { // Can be called multiple times. On error, the database is unchanged. // Paths are case-sensitive if the underlying filesystem is case-sensitive. // masterlistPath and userlistPath are files. -LOOT_API unsigned int loot_load_lists (loot_db db, const char * const masterlistPath, - const char * const userlistPath) { +LOOT_API unsigned int loot_load_lists(loot_db db, const char * const masterlistPath, + const char * const userlistPath) { if (db == nullptr || masterlistPath == nullptr) return c_error(loot_error_invalid_args, "Null pointer passed."); @@ -298,7 +294,8 @@ LOOT_API unsigned int loot_load_lists (loot_db db, const char * const masterlist in.close(); temp = tempNode["plugins"].as< std::list >(); } - } catch (std::exception& e) { + } + catch (std::exception& e) { return c_error(loot_error_parse_fail, e.what()); } @@ -313,25 +310,26 @@ LOOT_API unsigned int loot_load_lists (loot_db db, const char * const masterlist } } } - } catch (YAML::Exception& e) { + } + catch (YAML::Exception& e) { return c_error(loot_error_parse_fail, e.what()); } //Also free memory. db->bashTagMap.clear(); - delete [] db->extAddedTagIds; - delete [] db->extRemovedTagIds; + delete[] db->extAddedTagIds; + delete[] db->extRemovedTagIds; if (db->extTagMap != nullptr) { for (size_t i=0; i < db->bashTagMap.size(); i++) - delete [] db->extTagMap[i]; //Gotta clear those allocated strings. - delete [] db->extTagMap; + delete[] db->extTagMap[i]; //Gotta clear those allocated strings. + delete[] db->extTagMap; } if (db->extMessageArray != nullptr) { for (size_t i=0; i < db->extMessageArraySize; i++) - delete [] db->extMessageArray[i].message; //Gotta clear those allocated strings. - delete [] db->extMessageArray; + delete[] db->extMessageArray[i].message; //Gotta clear those allocated strings. + delete[] db->extMessageArray; } db->extAddedTagIds = nullptr; @@ -353,7 +351,7 @@ LOOT_API unsigned int loot_load_lists (loot_db db, const char * const masterlist // is called. Repeated calls re-evaluate the masterlist from scratch each time, // ignoring the results of any previous evaluations. Paths are case-sensitive // if the underlying filesystem is case-sensitive. -LOOT_API unsigned int loot_eval_lists (loot_db db, const unsigned int language) { +LOOT_API unsigned int loot_eval_lists(loot_db db, const unsigned int language) { if (db == nullptr) return c_error(loot_error_invalid_args, "Null pointer passed."); @@ -366,7 +364,8 @@ LOOT_API unsigned int loot_eval_lists (loot_db db, const unsigned int language) std::regex reg; try { reg = std::regex(it->Name(), std::regex::ECMAScript | std::regex::icase); - } catch (std::exception& e) { + } + catch (std::exception& e) { return c_error(loot_error_regex_eval_fail, e.what()); } @@ -379,11 +378,13 @@ LOOT_API unsigned int loot_eval_lists (loot_db db, const unsigned int language) } } it = temp.erase(it); - } else { + } + else { ++it; } } - } catch (loot::error& e) { + } + catch (loot::error& e) { return c_error(e); } db->metadata = temp; @@ -396,7 +397,8 @@ LOOT_API unsigned int loot_eval_lists (loot_db db, const unsigned int language) std::regex reg; try { reg = std::regex(it->Name(), std::regex::ECMAScript | std::regex::icase); - } catch (std::exception& e) { + } + catch (std::exception& e) { return c_error(loot_error_regex_eval_fail, e.what()); } @@ -409,11 +411,13 @@ LOOT_API unsigned int loot_eval_lists (loot_db db, const unsigned int language) } } it = temp.erase(it); - } else { + } + else { ++it; } } - } catch (loot::error& e) { + } + catch (loot::error& e) { return c_error(e); } db->userMetadata = temp; @@ -421,7 +425,6 @@ LOOT_API unsigned int loot_eval_lists (loot_db db, const unsigned int language) return loot_ok; } - ////////////////////////// // DB Access Functions ////////////////////////// @@ -429,16 +432,16 @@ LOOT_API unsigned int loot_eval_lists (loot_db db, const unsigned int language) // Returns an array of the Bash Tags encounterred when loading the masterlist // and userlist, and the number of tags in the returned array. The array and // its contents are static and should not be freed by the client. -LOOT_API unsigned int loot_get_tag_map (loot_db db, char *** const tagMap, size_t * const numTags) { +LOOT_API unsigned int loot_get_tag_map(loot_db db, char *** const tagMap, size_t * const numTags) { if (db == nullptr || tagMap == nullptr || numTags == nullptr) return c_error(loot_error_invalid_args, "Null pointer passed."); //Clear existing array allocation. if (db->extTagMap != nullptr) { for (size_t i=0, max=db->bashTagMap.size(); i < max; ++i) { - delete [] db->extTagMap[i]; + delete[] db->extTagMap[i]; } - delete [] db->extTagMap; + delete[] db->extTagMap; db->extTagMap = nullptr; } @@ -448,9 +451,9 @@ LOOT_API unsigned int loot_get_tag_map (loot_db db, char *** const tagMap, size_ std::unordered_set allTags; - for (const auto &plugin: db->metadata) { + for (const auto &plugin : db->metadata) { std::set tags(plugin.Tags()); - for (const auto &tag: tags) { + for (const auto &tag : tags) { allTags.insert(tag.Name()); } } @@ -466,19 +469,21 @@ LOOT_API unsigned int loot_get_tag_map (loot_db db, char *** const tagMap, size_ try { db->extTagMap = new char*[allTags.size()]; - } catch (std::bad_alloc& e) { + } + catch (std::bad_alloc& e) { return c_error(loot_error_no_mem, e.what()); } unsigned int UID = 0; try { - for (const auto &tag: allTags) { + for (const auto &tag : allTags) { db->bashTagMap.emplace(tag, UID); //Also allocate memory. db->extTagMap[UID] = ToNewCString(tag); UID++; } - } catch (std::bad_alloc& e) { + } + catch (std::bad_alloc& e) { return c_error(loot_error_no_mem, e.what()); } @@ -495,19 +500,18 @@ LOOT_API unsigned int loot_get_tag_map (loot_db db, char *** const tagMap, size_ // case-insensitive. If no Tags are found for an array, the array pointer (*tagIds) // will be nullptr. The userlistModified bool is true if the userlist contains Bash Tag // suggestion message additions. -LOOT_API unsigned int loot_get_plugin_tags (loot_db db, const char * const plugin, - unsigned int ** const tagIds_added, - size_t * const numTags_added, - unsigned int ** const tagIds_removed, - size_t * const numTags_removed, - bool * const userlistModified) { +LOOT_API unsigned int loot_get_plugin_tags(loot_db db, const char * const plugin, + unsigned int ** const tagIds_added, + size_t * const numTags_added, + unsigned int ** const tagIds_removed, + size_t * const numTags_removed, + bool * const userlistModified) { if (db == nullptr || plugin == nullptr || tagIds_added == nullptr || numTags_added == nullptr || tagIds_removed == nullptr || numTags_removed == nullptr || userlistModified == nullptr) return c_error(loot_error_invalid_args, "Null pointer passed."); - //Clear existing array allocations. - delete [] db->extAddedTagIds; - delete [] db->extRemovedTagIds; + delete[] db->extAddedTagIds; + delete[] db->extRemovedTagIds; db->extAddedTagIds = nullptr; db->extRemovedTagIds = nullptr; @@ -522,7 +526,7 @@ LOOT_API unsigned int loot_get_plugin_tags (loot_db db, const char * const plugi std::list::iterator pluginIt = std::find(db->metadata.begin(), db->metadata.end(), loot::Plugin(plugin)); if (pluginIt != db->metadata.end()) { std::set tags(pluginIt->Tags()); - for (const auto &tag: tags) { + for (const auto &tag : tags) { if (tag.IsAddition()) tagsAdded.insert(tag.Name()); else @@ -547,7 +551,7 @@ LOOT_API unsigned int loot_get_plugin_tags (loot_db db, const char * const plugi } std::vector tagsAddedIDs, tagsRemovedIDs; - for (const auto &tagNames: tagsAdded) { + for (const auto &tagNames : tagsAdded) { const auto mapIter(db->bashTagMap.find(tagNames)); if (mapIter != db->bashTagMap.end()) tagsAddedIDs.push_back(mapIter->second); @@ -572,7 +576,8 @@ LOOT_API unsigned int loot_get_plugin_tags (loot_db db, const char * const plugi for (size_t i=0; i < numRemoved; i++) db->extRemovedTagIds[i] = tagsRemovedIDs[i]; } - } catch (std::bad_alloc& e) { + } + catch (std::bad_alloc& e) { return c_error(loot_error_no_mem, e.what()); } @@ -588,18 +593,18 @@ LOOT_API unsigned int loot_get_plugin_tags (loot_db db, const char * const plugi // Returns the messages attached to the given plugin. Messages are valid until Load, // loot_destroy_db or loot_get_plugin_messages are next called. plugin is case-insensitive. // If no messages are attached, *messages will be nullptr and numMessages will equal 0. -LOOT_API unsigned int loot_get_plugin_messages (loot_db db, const char * const plugin, - loot_message ** const messages, - size_t * const numMessages) { +LOOT_API unsigned int loot_get_plugin_messages(loot_db db, const char * const plugin, + loot_message ** const messages, + size_t * const numMessages) { if (db == nullptr || plugin == nullptr || messages == nullptr || numMessages == nullptr) return c_error(loot_error_invalid_args, "Null pointer passed."); //Clear existing array allocation. if (db->extMessageArray != nullptr) { for (size_t i=0; i < db->extMessageArraySize; ++i) { - delete [] db->extMessageArray[i].message; + delete[] db->extMessageArray[i].message; } - delete [] db->extMessageArray; + delete[] db->extMessageArray; db->extMessageArray = nullptr; } @@ -623,11 +628,12 @@ LOOT_API unsigned int loot_get_plugin_messages (loot_db db, const char * const p try { db->extMessageArray = new loot_message[db->extMessageArraySize]; int i = 0; - for (const auto &message: pluginMessages) { + for (const auto &message : pluginMessages) { db->extMessageArray[i].type = message.Type(); db->extMessageArray[i].message = ToNewCString(message.ChooseContent(loot::Language::any).Str()); } - } catch (std::bad_alloc& e) { + } + catch (std::bad_alloc& e) { return c_error(loot_error_no_mem, e.what()); } @@ -662,12 +668,11 @@ LOOT_API unsigned int loot_get_dirty_info(loot_db db, const char * const plugin, return loot_ok; } - // Writes a minimal masterlist that only contains mods that have Bash Tag suggestions, // and/or dirty messages, plus the Tag suggestions and/or messages themselves and their // conditions, in order to create the Wrye Bash taglist. outputFile is the path to use // for output. If outputFile already exists, it will only be overwritten if overwrite is true. -LOOT_API unsigned int loot_write_minimal_list (loot_db db, const char * const outputFile, const bool overwrite) { +LOOT_API unsigned int loot_write_minimal_list(loot_db db, const char * const outputFile, const bool overwrite) { if (db == nullptr || outputFile == nullptr) return c_error(loot_error_invalid_args, "Null pointer passed."); @@ -678,7 +683,7 @@ LOOT_API unsigned int loot_write_minimal_list (loot_db db, const char * const ou return c_error(loot_error_invalid_args, "Output file exists but overwrite is not set to true."); std::list temp = db->metadata; - for (auto &plugin: temp) { + for (auto &plugin : temp) { loot::Plugin p(plugin.Name()); p.Tags(plugin.Tags()); p.DirtyInfo(plugin.DirtyInfo()); @@ -689,8 +694,8 @@ LOOT_API unsigned int loot_write_minimal_list (loot_db db, const char * const ou YAML::Emitter yout; yout.SetIndent(2); yout << YAML::BeginMap - << YAML::Key << "plugins" << YAML::Value << temp - << YAML::EndMap; + << YAML::Key << "plugins" << YAML::Value << temp + << YAML::EndMap; boost::filesystem::path p(outputFile); loot::ofstream out(p); diff --git a/src/backend/game.cpp b/src/backend/game.cpp index 097e8845..0892806f 100644 --- a/src/backend/game.cpp +++ b/src/backend/game.cpp @@ -20,7 +20,7 @@ You should have received a copy of the GNU General Public License along with LOOT. If not, see . -*/ + */ #include "game.h" #include "globals.h" @@ -43,7 +43,6 @@ namespace fs = boost::filesystem; namespace lc = boost::locale; namespace loot { - std::vector GetGames(YAML::Node& settings) { vector games; @@ -264,7 +263,8 @@ namespace loot { espm_settings = espm::Settings("tes4"); _repositoryURL = "https://github.com/loot/oblivion.git"; _repositoryBranch = "master"; - } else if (Id() == Game::tes5) { + } + else if (Id() == Game::tes5) { _name = "TES V: Skyrim"; registryKey = "Software\\Bethesda Softworks\\Skyrim\\Installed Path"; lootFolderName = "Skyrim"; @@ -272,7 +272,8 @@ namespace loot { espm_settings = espm::Settings("tes5"); _repositoryURL = "https://github.com/loot/skyrim.git"; _repositoryBranch = "master"; - } else if (Id() == Game::fo3) { + } + else if (Id() == Game::fo3) { _name = "Fallout 3"; registryKey = "Software\\Bethesda Softworks\\Fallout3\\Installed Path"; lootFolderName = "Fallout3"; @@ -280,7 +281,8 @@ namespace loot { espm_settings = espm::Settings("fo3"); _repositoryURL = "https://github.com/loot/fallout3.git"; _repositoryBranch = "master"; - } else if (Id() == Game::fonv) { + } + else if (Id() == Game::fonv) { _name = "Fallout: New Vegas"; registryKey = "Software\\Bethesda Softworks\\FalloutNV\\Installed Path"; lootFolderName = "FalloutNV"; @@ -295,8 +297,7 @@ namespace loot { } Game& Game::SetDetails(const std::string& name, const std::string& masterFile, - const std::string& repositoryURL, const std::string& repositoryBranch, const std::string& path, const std::string& registry) { - + const std::string& repositoryURL, const std::string& repositoryBranch, const std::string& path, const std::string& registry) { BOOST_LOG_TRIVIAL(info) << "Setting new details for game: " << _name; if (!name.empty()) @@ -506,7 +507,7 @@ namespace loot { } activePlugins.clear(); - for (size_t i=0; i < pluginArrSize; ++i) { + for (size_t i = 0; i < pluginArrSize; ++i) { activePlugins.insert(boost::locale::to_lower(string(pluginArr[i]))); } @@ -587,7 +588,7 @@ namespace loot { } loadOrder.clear(); - for (size_t i=0; i < pluginArrSize; ++i) { + for (size_t i = 0; i < pluginArrSize; ++i) { loadOrder.push_back(string(pluginArr[i])); } @@ -647,16 +648,16 @@ namespace loot { pluginArrSize = loadOrder.size(); pluginArr = new char*[pluginArrSize]; int i = 0; - for (const auto &plugin: loadOrder) { + for (const auto &plugin : loadOrder) { pluginArr[i] = new char[plugin.length() + 1]; strcpy(pluginArr[i], plugin.c_str()); ++i; } if (lo_set_load_order(gh, pluginArr, pluginArrSize) != LIBLO_OK) { - for (size_t i=0; i < pluginArrSize; i++) - delete [] pluginArr[i]; - delete [] pluginArr; + for (size_t i = 0; i < pluginArrSize; i++) + delete[] pluginArr[i]; + delete[] pluginArr; const char * e = nullptr; string err; lo_get_error_message(&e); @@ -673,9 +674,9 @@ namespace loot { throw error(error::liblo_error, err); } - for (size_t i=0; i < pluginArrSize; i++) - delete [] pluginArr[i]; - delete [] pluginArr; + for (size_t i = 0; i < pluginArrSize; i++) + delete[] pluginArr[i]; + delete[] pluginArr; lo_destroy_handle(gh); } @@ -688,7 +689,6 @@ namespace loot { GetLoadOrder(loadorder); if (!loadorder.empty()) { - time_t lastTime; fs::path filepath = DataPath() / *loadorder.begin(); if (!fs::exists(filepath) && fs::exists(filepath.string() + ".ghost")) @@ -696,8 +696,7 @@ namespace loot { lastTime = fs::last_write_time(filepath); - for (const auto &pluginName: loadorder) { - + for (const auto &pluginName : loadorder) { filepath = DataPath() / pluginName; if (!fs::exists(filepath) && fs::exists(filepath.string() + ".ghost")) filepath += ".ghost"; @@ -725,7 +724,6 @@ namespace loot { //First calculate the mean plugin size. Store it temporarily in a map to reduce filesystem lookups and file size recalculation. for (fs::directory_iterator it(this->DataPath()); it != fs::directory_iterator(); ++it) { if (fs::is_regular_file(it->status()) && IsPlugin(it->path().string())) { - uintmax_t fileSize = fs::file_size(it->path()); meanFileSize += fileSize; @@ -736,7 +734,6 @@ namespace loot { //Now load plugins. for (const auto &pluginPair : tempMap) { - BOOST_LOG_TRIVIAL(info) << "Found plugin: " << pluginPair.first; //Insert the lowercased name as a key for case-insensitive matching. @@ -780,7 +777,8 @@ namespace loot { try { if (fs::exists(g_path_local) && !fs::exists(g_path_local / lootFolderName)) fs::create_directory(g_path_local / lootFolderName); - } catch (fs::filesystem_error& e) { + } + catch (fs::filesystem_error& e) { BOOST_LOG_TRIVIAL(error) << "Could not create LOOT folder for game. Details: " << e.what(); throw error(error::path_write_fail, lc::translate("Could not create LOOT folder for game. Details:").str() + " " + e.what()); } diff --git a/src/backend/generators.cpp b/src/backend/generators.cpp index 2800a0f7..9e1fb83e 100644 --- a/src/backend/generators.cpp +++ b/src/backend/generators.cpp @@ -36,7 +36,6 @@ along with LOOT. If not, see using namespace std; namespace YAML { - Emitter& operator << (Emitter& out, const loot::PluginDirtyInfo& rhs) { out << BeginMap << Key << "crc" << Value << Hex << rhs.CRC() << Dec @@ -146,7 +145,6 @@ namespace YAML { Emitter& operator << (Emitter& out, const loot::Plugin& rhs) { if (!rhs.HasNameOnly()) { - out << BeginMap << Key << "name" << Value << rhs.Name(); diff --git a/src/backend/git.cpp b/src/backend/git.cpp index 85437b62..28ec18a4 100644 --- a/src/backend/git.cpp +++ b/src/backend/git.cpp @@ -20,7 +20,7 @@ You should have received a copy of the GNU General Public License along with LOOT. If not, see . -*/ + */ #include "error.h" #include "parsers.h" @@ -40,10 +40,9 @@ namespace fs = boost::filesystem; namespace lc = boost::locale; namespace loot { - struct git_handler { public: - git_handler() : repo(nullptr), remote(nullptr), cfg(nullptr), obj(nullptr), commit(nullptr), ref(nullptr), ref2(nullptr), sig(nullptr), blob(nullptr), merge_head(nullptr), tree(nullptr), diff(nullptr), buf({0}) {} + git_handler() : repo(nullptr), remote(nullptr), cfg(nullptr), obj(nullptr), commit(nullptr), ref(nullptr), ref2(nullptr), sig(nullptr), blob(nullptr), merge_head(nullptr), tree(nullptr), diff(nullptr), buf({ 0 }) {} ~git_handler() { git_commit_free(commit); @@ -184,7 +183,7 @@ namespace loot { git.call(git_signature_new(&git.sig, "LOOT", "loot@placeholder.net", 0, 0)); BOOST_LOG_TRIVIAL(debug) << "Setting up checkout options."; - char * paths[] = { "masterlist.yaml" }; + char * paths[] ={ "masterlist.yaml" }; git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT; checkout_opts.checkout_strategy = GIT_CHECKOUT_FORCE; checkout_opts.paths.strings = paths; @@ -324,7 +323,7 @@ namespace loot { Need to merge the remote branch into it. Just do a fast-forward merge because that's all that should be necessary as the local repo shouldn't get changed by the user. - */ + */ BOOST_LOG_TRIVIAL(trace) << "Checking that local and remote branches can be merged by fast-forward."; git_merge_analysis_t analysis; @@ -368,7 +367,6 @@ namespace loot { return this->Update(game, language); //throw error(error::git_error, "Local repository has been edited, an automatic fast-forward merge update is not possible."); } - } // Free branch pointer. @@ -377,7 +375,6 @@ namespace loot { BOOST_LOG_TRIVIAL(trace) << "Performing a Git checkout of HEAD."; git.call(git_checkout_head(git.repo, &checkout_opts)); - } // Now whether the repository was cloned or updated, the working directory contains @@ -417,7 +414,7 @@ namespace loot { git.ref = nullptr; git.obj = nullptr; git.commit = nullptr; - git.buf = { 0 }; + git.buf ={ 0 }; //Now try parsing the masterlist. BOOST_LOG_TRIVIAL(debug) << "Testing masterlist parsing."; @@ -430,13 +427,13 @@ namespace loot { for (auto &plugin : regexPlugins) { plugin.ParseAllConditions(game); } - for (auto &message: messages) { + for (auto &message : messages) { message.ParseCondition(game); } parsingFailed = false; - - } catch (std::exception& e) { + } + catch (std::exception& e) { parsingFailed = true; //Roll back one revision if there's an error. diff --git a/src/backend/globals.cpp b/src/backend/globals.cpp index 6c5b35f8..5f41992a 100644 --- a/src/backend/globals.cpp +++ b/src/backend/globals.cpp @@ -20,13 +20,12 @@ You should have received a copy of the GNU General Public License along with LOOT. If not, see . -*/ + */ #include "globals.h" #include "helpers.h" namespace loot { - //Version numbers. const unsigned int g_version_major = 0; const unsigned int g_version_minor = 7; diff --git a/src/backend/graph.cpp b/src/backend/graph.cpp index c9ef9492..c1617f14 100644 --- a/src/backend/graph.cpp +++ b/src/backend/graph.cpp @@ -20,7 +20,7 @@ You should have received a copy of the GNU General Public License along with LOOT. If not, see . -*/ + */ #include "error.h" #include "graph.h" @@ -38,8 +38,7 @@ using namespace std; namespace loot { - - struct cycle_detector : public boost::dfs_visitor<> { + struct cycle_detector : public boost::dfs_visitor < > { cycle_detector() {} std::list trail; @@ -98,7 +97,7 @@ namespace loot { map index_map; boost::associative_property_map< map > v_index_map(index_map); - size_t i=0; + size_t i = 0; BGL_FORALL_VERTICES(v, graph, PluginGraph) put(v_index_map, v, i++); @@ -139,7 +138,6 @@ namespace loot { loot::vertex_it vit2 = vit; ++vit2; while (vit2 != vitend) { - if (graph[*vit].IsMaster() == graph[*vit2].IsMaster()) { ++vit2; continue; @@ -149,13 +147,13 @@ namespace loot { if (graph[*vit2].IsMaster()) { parentVertex = *vit2; vertex = *vit; - } else { + } + else { parentVertex = *vit; vertex = *vit2; } if (!boost::edge(parentVertex, vertex, graph).second) { - BOOST_LOG_TRIVIAL(trace) << "Adding edge from \"" << graph[parentVertex].Name() << "\" to \"" << graph[vertex].Name() << "\"."; boost::add_edge(parentVertex, vertex, graph); @@ -165,10 +163,9 @@ namespace loot { BOOST_LOG_TRIVIAL(trace) << "Adding in-edges for masters."; vector strVec(graph[*vit].Masters()); - for (const auto &master: strVec) { + for (const auto &master : strVec) { if (loot::GetVertexByName(graph, master, parentVertex) && !boost::edge(parentVertex, *vit, graph).second) { - BOOST_LOG_TRIVIAL(trace) << "Adding edge from \"" << graph[parentVertex].Name() << "\" to \"" << graph[*vit].Name() << "\"."; boost::add_edge(parentVertex, *vit, graph); @@ -181,11 +178,10 @@ namespace loot { } BOOST_LOG_TRIVIAL(trace) << "Adding in-edges for requirements."; set fileset(graph[*vit].Reqs()); - for (const auto &file: fileset) { + for (const auto &file : fileset) { if (loot::IsPlugin(file.Name()) && loot::GetVertexByName(graph, file.Name(), parentVertex) && !boost::edge(parentVertex, *vit, graph).second) { - BOOST_LOG_TRIVIAL(trace) << "Adding edge from \"" << graph[parentVertex].Name() << "\" to \"" << graph[*vit].Name() << "\"."; boost::add_edge(parentVertex, *vit, graph); @@ -203,7 +199,6 @@ namespace loot { if (loot::IsPlugin(file.Name()) && loot::GetVertexByName(graph, file.Name(), parentVertex) && !boost::edge(parentVertex, *vit, graph).second) { - BOOST_LOG_TRIVIAL(trace) << "Adding edge from \"" << graph[parentVertex].Name() << "\" to \"" << graph[*vit].Name() << "\"."; boost::add_edge(parentVertex, *vit, graph); @@ -221,7 +216,6 @@ namespace loot { BOOST_LOG_TRIVIAL(trace) << "Overriding priority for " << graph[*vit].Name() << " from " << graph[*vit].Priority() << " to " << parentPriority; graph[*vit].Priority(parentPriority); } - } } @@ -237,12 +231,11 @@ namespace loot { loot::vertex_it vit2, vitend2; for (boost::tie(vit2, vitend2) = boost::vertices(graph); vit2 != vitend2; ++vit2) { - if (graph[*vit].Priority() == graph[*vit2].Priority() || (abs(graph[*vit].Priority()) < max_priority && abs(graph[*vit2].Priority()) < max_priority - && !graph[*vit].FormIDs().empty() && !graph[*vit2].FormIDs().empty() && !graph[*vit].DoFormIDsOverlap(graph[*vit2]) - ) - ) { + && !graph[*vit].FormIDs().empty() && !graph[*vit2].FormIDs().empty() && !graph[*vit].DoFormIDsOverlap(graph[*vit2]) + ) + ) { continue; } @@ -255,14 +248,14 @@ namespace loot { if (p1 < p2) { parentVertex = *vit; vertex = *vit2; - } else { + } + else { parentVertex = *vit2; vertex = *vit; } if (!boost::edge(parentVertex, vertex, graph).second && !EdgeCreatesCycle(graph, parentVertex, vertex)) { //No edge going the other way, OK to add this edge. - BOOST_LOG_TRIVIAL(trace) << "Adding edge from \"" << graph[parentVertex].Name() << "\" to \"" << graph[vertex].Name() << "\"."; boost::add_edge(parentVertex, vertex, graph); @@ -275,7 +268,6 @@ namespace loot { loot::vertex_it vit, vitend; for (boost::tie(vit, vitend) = boost::vertices(graph); vit != vitend; ++vit) { - BOOST_LOG_TRIVIAL(trace) << "Adding overlap edges to vertex for \"" << graph[*vit].Name() << "\"."; if (graph[*vit].NumOverrideFormIDs() == 0) { @@ -310,7 +302,6 @@ namespace loot { BOOST_LOG_TRIVIAL(trace) << "Checking edge validity between \"" << graph[*vit].Name() << "\" and \"" << graph[*vit2].Name() << "\"."; if (!EdgeCreatesCycle(graph, parentVertex, vertex)) { //No edge going the other way, OK to add this edge. - BOOST_LOG_TRIVIAL(trace) << "Adding edge from \"" << graph[parentVertex].Name() << "\" to \"" << graph[vertex].Name() << "\"."; boost::add_edge(parentVertex, vertex, graph); @@ -321,7 +312,6 @@ namespace loot { } std::list Sort(PluginGraph& graph) { - //Now add the interactions between plugins to the graph as edges. BOOST_LOG_TRIVIAL(info) << "Adding edges to plugin graph."; BOOST_LOG_TRIVIAL(debug) << "Adding non-overlap edges."; @@ -339,7 +329,7 @@ namespace loot { //Topological sort requires an index map, which std::list-based VertexList graphs don't have, so one needs to be built separately. map index_map; boost::associative_property_map< map > v_index_map(index_map); - size_t i=0; + size_t i = 0; BGL_FORALL_VERTICES(v, graph, PluginGraph) put(v_index_map, v, i++); @@ -351,7 +341,7 @@ namespace loot { // Output a plugin list using the sorted vertices. BOOST_LOG_TRIVIAL(info) << "Calculated order: "; list plugins; - for (const auto &vertex: sortedVertices) { + for (const auto &vertex : sortedVertices) { BOOST_LOG_TRIVIAL(info) << '\t' << graph[vertex].Name(); plugins.push_back(graph[vertex]); } diff --git a/src/backend/helpers.cpp b/src/backend/helpers.cpp index 10db6aa0..8de6943f 100644 --- a/src/backend/helpers.cpp +++ b/src/backend/helpers.cpp @@ -20,7 +20,7 @@ You should have received a copy of the GNU General Public License along with LOOT. If not, see . -*/ + */ #include "helpers.h" #include "error.h" @@ -63,7 +63,6 @@ namespace loot { namespace fs = boost::filesystem; namespace lc = boost::locale; - /// REGEX expression definition /// Each expression is composed of three parts: /// 1. The marker string "version", "ver", "rev", "v" or "r" @@ -107,15 +106,15 @@ namespace loot { /// Array used to try each of the expressions defined above using /// an iteration for each of them. - const regex version_checks[7] = { - regex(regex1, regex::ECMAScript | regex::icase), - regex(regex2, regex::ECMAScript | regex::icase), - regex(regex3, regex::ECMAScript | regex::icase), - regex(regex4, regex::ECMAScript | regex::icase), - regex(regex5, regex::ECMAScript | regex::icase), //This incorrectly identifies "OBSE v19" where 19 is any integer. - regex(regex6, regex::ECMAScript | regex::icase), //This is responsible for metallicow's false positive. - regex(regex7, regex::ECMAScript | regex::icase) - }; + const regex version_checks[7] ={ + regex(regex1, regex::ECMAScript | regex::icase), + regex(regex2, regex::ECMAScript | regex::icase), + regex(regex3, regex::ECMAScript | regex::icase), + regex(regex4, regex::ECMAScript | regex::icase), + regex(regex5, regex::ECMAScript | regex::icase), //This incorrectly identifies "OBSE v19" where 19 is any integer. + regex(regex6, regex::ECMAScript | regex::icase), //This is responsible for metallicow's false positive. + regex(regex7, regex::ECMAScript | regex::icase) + }; // A regular expression for finding Bash Tags in plugin descriptions. const regex bash_tag_check("\\{\\{BASH:(?:[ ]*([-A-Za-z.]+)[ ]*,)+[ ]*\\}\\}", regex::ECMAScript | regex::icase); @@ -148,7 +147,8 @@ namespace loot { result.process_bytes(buffer, ifile.gcount()); } while (ifile); chksum = result.checksum(); - } else { + } + else { BOOST_LOG_TRIVIAL(error) << "Unable to open \"" << filename.string() << "\" for CRC calculation."; throw error(error::path_read_fail, (boost::format(lc::translate("Unable to open \"%1%\" for CRC calculation.")) % filename.string()).str()); } @@ -160,7 +160,7 @@ namespace loot { std::string IntToHexString(const int n) { string out; back_insert_iterator sink(out); - karma::generate(sink,karma::upper[karma::hex],n); + karma::generate(sink, karma::upper[karma::hex], n); return out; } @@ -183,7 +183,7 @@ namespace loot { key = HKEY_USERS; BOOST_LOG_TRIVIAL(trace) << "Getting registry object for key and subkey: " << keyStr << " + " << subkey; - LONG ret = RegOpenKeyEx(key, ToWinWide(subkey).c_str(), 0, KEY_READ|KEY_WOW64_32KEY, &hKey); + LONG ret = RegOpenKeyEx(key, ToWinWide(subkey).c_str(), 0, KEY_READ | KEY_WOW64_32KEY, &hKey); if (ret == ERROR_SUCCESS) { BOOST_LOG_TRIVIAL(trace) << "Getting value for entry: " << value; @@ -194,7 +194,8 @@ namespace loot { return fs::path(val).string(); //Easiest way to convert from wide to narrow character strings. else return ""; - } else + } + else return ""; } #endif @@ -232,7 +233,6 @@ namespace loot { #ifdef _WIN32 //Helper to turn UTF8 strings into strings that can be used by WinAPI. std::wstring ToWinWide(const std::string& str) { - int len = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), str.length(), 0, 0); std::wstring wstr(len, 0); MultiByteToWideChar(CP_UTF8, 0, str.c_str(), str.length(), &(wstr[0]), len); @@ -308,7 +308,7 @@ namespace loot { _name = "Deutsch"; _locale = "de"; } - else { + else { _name = "English"; _locale = "en"; } @@ -346,23 +346,23 @@ namespace loot { VS_FIXEDFILEINFO *info; string ver; - GetFileVersionInfo(ToWinWide(file.string()).c_str(),0,size,point); + GetFileVersionInfo(ToWinWide(file.string()).c_str(), 0, size, point); - VerQueryValue(point,L"\\",(LPVOID *)&info,&uLen); + VerQueryValue(point, L"\\", (LPVOID *)&info, &uLen); DWORD dwLeftMost = HIWORD(info->dwFileVersionMS); DWORD dwSecondLeft = LOWORD(info->dwFileVersionMS); DWORD dwSecondRight = HIWORD(info->dwFileVersionLS); DWORD dwRightMost = LOWORD(info->dwFileVersionLS); - delete [] point; + delete[] point; verString = to_string(dwLeftMost) + '.' + to_string(dwSecondLeft) + '.' + to_string(dwSecondRight) + '.' + to_string(dwRightMost); } #else // ensure filename has no quote characters in it to avoid command injection attacks if (string::npos != file.string().find('"')) { - // command mostly borrowed from the gnome-exe-thumbnailer.sh script + // command mostly borrowed from the gnome-exe-thumbnailer.sh script // wrestool is part of the icoutils package string cmd = "wrestool --extract --raw --type=version \"" + file.string() + "\" | tr '\\0, ' '\\t.\\0' | sed 's/\\t\\t/_/g' | tr -c -d '[:print:]' | sed -r 's/.*Version[^0-9]*([0-9]+(\\.[0-9]+)+).*/\\1/'"; @@ -405,12 +405,14 @@ namespace loot { if (parser1.good()) { parser1 >> n1; parser1.get(); - } else + } + else n1 = 0; if (parser2.good()) { parser2 >> n2; parser2.get(); - } else + } + else n2 = 0; if (n1 < n2) return true; @@ -418,7 +420,8 @@ namespace loot { return false; } return false; - } else { + } + else { //Wacky format. Use the Alphanum Algorithm. (what a name!) return (doj::alphanum_comp(verString, ver.AsString()) < 0); } diff --git a/src/backend/metadata.cpp b/src/backend/metadata.cpp index 5867d288..747f2b34 100644 --- a/src/backend/metadata.cpp +++ b/src/backend/metadata.cpp @@ -20,7 +20,7 @@ You should have received a copy of the GNU General Public License along with LOOT. If not, see . -*/ + */ #include "helpers.h" #include "metadata.h" @@ -39,7 +39,6 @@ using namespace std; namespace loot { - namespace lc = boost::locale; FormID::FormID() : id(0) {} @@ -105,7 +104,6 @@ namespace loot { return _utility; } - ConditionStruct::ConditionStruct() {} ConditionStruct::ConditionStruct(const string& condition) : _condition(condition) {} @@ -139,7 +137,8 @@ namespace loot { bool r; try { r = boost::spirit::qi::phrase_parse(begin, end, grammar, skipper, eval); - } catch (std::exception& e) { + } + catch (std::exception& e) { BOOST_LOG_TRIVIAL(error) << "Failed to parse condition \"" << _condition << "\": " << e.what(); throw loot::error(loot::error::condition_eval_fail, (boost::format(lc::translate("Failed to parse condition \"%1%\": %2%")) % _condition % e.what()).str()); } @@ -215,7 +214,7 @@ namespace loot { } Message::Message(const unsigned int type, const std::vector& content, - const std::string& condition) : _type(type), _content(content), ConditionStruct(condition) {} + const std::string& condition) : _type(type), _content(content), ConditionStruct(condition) {} bool Message::operator < (const Message& rhs) const { if (!_content.empty() && !rhs.Content().empty()) @@ -231,7 +230,6 @@ namespace loot { } bool Message::EvalCondition(loot::Game& game, const unsigned int language) { - BOOST_LOG_TRIVIAL(trace) << "Choosing message content for language: " << Language(language).Name(); if (_content.size() > 1) { @@ -239,7 +237,7 @@ namespace loot { _content.resize(1); else { MessageContent english, match; - for (const auto &mc: _content) { + for (const auto &mc : _content) { if (mc.Language() == language) { match = mc; break; @@ -341,7 +339,6 @@ 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) { - // 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; @@ -387,7 +384,7 @@ namespace loot { vector records = file->getFormIDs(); vector plugins = masters; plugins.push_back(name); - for (const auto &record: records) { + for (const auto &record : records) { FormID fid = FormID(plugins, record); formIDs.insert(fid); if (!boost::iequals(fid.Plugin(), name)) @@ -631,10 +628,12 @@ namespace loot { else if (boost::filesystem::exists(game.DataPath() / name)) { crc = GetCrc32(game.DataPath() / name); game.crcCache.emplace(boost::locale::to_lower(name), crc); - } else if (boost::filesystem::exists(game.DataPath() / (name + ".ghost"))) { + } + else if (boost::filesystem::exists(game.DataPath() / (name + ".ghost"))) { crc = GetCrc32(game.DataPath() / (name + ".ghost")); game.crcCache.emplace(boost::locale::to_lower(name), crc); - } else + } + else _dirtyInfo.clear(); for (auto it = _dirtyInfo.begin(); it != _dirtyInfo.end();) { @@ -679,8 +678,8 @@ namespace loot { bool Plugin::operator == (const Plugin& rhs) const { return (boost::iequals(name, rhs.Name()) - || (IsRegexPlugin() && regex_match(rhs.Name(), regex(name, regex::ECMAScript | regex::icase))) - || (rhs.IsRegexPlugin() && regex_match(name, regex(rhs.Name(), regex::ECMAScript | regex::icase)))); + || (IsRegexPlugin() && regex_match(rhs.Name(), regex(name, regex::ECMAScript | regex::icase))) + || (rhs.IsRegexPlugin() && regex_match(name, regex(rhs.Name(), regex::ECMAScript | regex::icase)))); } bool Plugin::operator != (const Plugin& rhs) const { @@ -696,9 +695,9 @@ namespace loot { BOOST_LOG_TRIVIAL(trace) << "Checking for FormID overlap between \"" << name << "\" and \"" << plugin.Name() << "\"."; set::const_iterator i = formIDs.begin(), - j = plugin.FormIDs().begin(), - iend = formIDs.end(), - jend = plugin.FormIDs().end(); + j = plugin.FormIDs().begin(), + iend = formIDs.end(), + jend = plugin.FormIDs().end(); while (i != iend && j != jend) { if (*i < *j) @@ -752,9 +751,9 @@ namespace loot { bool Plugin::MustLoadAfter(const Plugin& plugin) const { if ((!isMaster && plugin.IsMaster()) - || find(masters.begin(), masters.end(), plugin) != masters.end() - || find(requirements.begin(), requirements.end(), plugin) != requirements.end() - || find(loadAfter.begin(), loadAfter.end(), plugin) != loadAfter.end()) + || find(masters.begin(), masters.end(), plugin) != masters.end() + || find(requirements.begin(), requirements.end(), plugin) != requirements.end() + || find(loadAfter.begin(), loadAfter.end(), plugin) != loadAfter.end()) return true; return false; } @@ -766,24 +765,24 @@ namespace loot { else messageType = loot::Message::warn; if (tags.find(Tag("Filter")) == tags.end()) { - for (const auto &master: masters) { + for (const auto &master : masters) { if (!boost::filesystem::exists(game.DataPath() / master) && !boost::filesystem::exists(game.DataPath() / (master + ".ghost"))) { BOOST_LOG_TRIVIAL(error) << "\"" << name << "\" requires \"" << master << "\", but it is missing."; messages.push_back(loot::Message(messageType, (boost::format(boost::locale::translate("This plugin requires \"%1%\" to be installed, but it is missing.")) % master).str())); } else if (!game.IsActive(master)) { - BOOST_LOG_TRIVIAL(error) << "\"" << name << "\" requires \"" << master << "\", but it is inactive."; + BOOST_LOG_TRIVIAL(error) << "\"" << name << "\" requires \"" << master << "\", but it is inactive."; messages.push_back(loot::Message(messageType, (boost::format(boost::locale::translate("This plugin requires \"%1%\" to be active, but it is inactive.")) % master).str())); } } } - for (const auto &req: requirements) { + for (const auto &req : requirements) { if (!boost::filesystem::exists(game.DataPath() / req.Name()) && !(IsPlugin(req.Name()) && boost::filesystem::exists(game.DataPath() / (req.Name() + ".ghost")))) { BOOST_LOG_TRIVIAL(error) << "\"" << name << "\" requires \"" << req.Name() << "\", but it is missing."; messages.push_back(loot::Message(messageType, (boost::format(boost::locale::translate("This plugin requires \"%1%\" to be installed, but it is missing.")) % req.Name()).str())); } } - for (const auto &inc: incompatibilities) { + for (const auto &inc : incompatibilities) { if (boost::filesystem::exists(game.DataPath() / inc.Name()) || (IsPlugin(inc.Name()) && boost::filesystem::exists(game.DataPath() / (inc.Name() + ".ghost")))) { if (!game.IsActive(inc.Name())) messageType = loot::Message::warn; @@ -801,7 +800,6 @@ namespace loot { else if (element.ITMs() == 0 && element.UDRs() == 0 && element.DeletedNavmeshes() == 0) f = boost::format(boost::locale::translate("Clean with %1%.")) % element.CleaningUtility(); - else if (element.ITMs() == 0 && element.UDRs() > 0 && element.DeletedNavmeshes() > 0) f = boost::format(boost::locale::translate("Contains %1% UDR records and %2% deleted navmeshes. Clean with %3%.")) % element.UDRs() % element.DeletedNavmeshes() % element.CleaningUtility(); else if (element.ITMs() == 0 && element.UDRs() == 0 && element.DeletedNavmeshes() > 0) @@ -848,7 +846,7 @@ namespace loot { bool IsPlugin(const std::string& file) { if (boost::iends_with(file, ".esp") || boost::iends_with(file, ".esm") - || boost::iends_with(file, ".esp.ghost") || boost::iends_with(file, ".esm.ghost")) + || boost::iends_with(file, ".esp.ghost") || boost::iends_with(file, ".esm.ghost")) return true; else return false; diff --git a/src/gui/app.cpp b/src/gui/app.cpp index 1091aa2d..984f89e4 100644 --- a/src/gui/app.cpp +++ b/src/gui/app.cpp @@ -20,7 +20,7 @@ You should have received a copy of the GNU General Public License along with LOOT. If not, see . -*/ + */ #include "app.h" #include "handler.h" @@ -52,7 +52,6 @@ using boost::format; namespace fs = boost::filesystem; namespace loot { - LootState g_app_state = LootState(); LootApp::LootApp() {} @@ -104,11 +103,9 @@ namespace loot { return message_router_->OnProcessMessageReceived(browser, source_process, message); } - void LootApp::OnContextCreated(CefRefPtr browser, - CefRefPtr frame, - CefRefPtr context) { - + CefRefPtr frame, + CefRefPtr context) { // Register javascript functions. message_router_->OnContextCreated(browser, frame, context); } @@ -160,12 +157,12 @@ namespace loot { boost::log::keywords::file_name = g_path_log.string().c_str(), boost::log::keywords::auto_flush = true, boost::log::keywords::format = ( - boost::log::expressions::stream - << "[" << boost::log::expressions::format_date_time< boost::posix_time::ptime >("TimeStamp", "%H:%M:%S") << "]" - << " [" << boost::log::trivial::severity << "]: " - << boost::log::expressions::smessage + boost::log::expressions::stream + << "[" << boost::log::expressions::format_date_time< boost::posix_time::ptime >("TimeStamp", "%H:%M:%S") << "]" + << " [" << boost::log::trivial::severity << "]: " + << boost::log::expressions::smessage ) - ); + ); boost::log::add_common_attributes(); bool enableDebugLogging = false; if (_settings["enableDebugLogging"]) { @@ -241,7 +238,6 @@ namespace loot { return _initErrors; } - void LootState::UpdateGames(std::vector& games) { unordered_set newGameFolders; @@ -330,7 +326,8 @@ namespace loot { // Conversion from 0.6 key. _settings["language"] = _settings["Language"]; _settings.remove("Language"); - } else + } + else return false; } if (!_settings["game"]) { diff --git a/src/gui/handler.cpp b/src/gui/handler.cpp index 4a4d80b2..432d57ac 100644 --- a/src/gui/handler.cpp +++ b/src/gui/handler.cpp @@ -20,7 +20,7 @@ You should have received a copy of the GNU General Public License along with LOOT. If not, see . -*/ + */ #include "handler.h" #include "resource.h" @@ -52,7 +52,6 @@ namespace fs = boost::filesystem; namespace loc = boost::locale; namespace loot { - namespace { LootHandler * g_instance = NULL; } @@ -64,11 +63,11 @@ namespace loot { // Called due to cefQuery execution in binding.html. bool Handler::OnQuery(CefRefPtr browser, - CefRefPtr frame, - int64 query_id, - const CefString& request, - bool persistent, - CefRefPtr callback) { + CefRefPtr frame, + int64 query_id, + const CefString& request, + bool persistent, + CefRefPtr callback) { if (request == "openReadme") { try { OpenReadme(); @@ -186,11 +185,10 @@ namespace loot { } // Handle queries with input arguments. - bool Handler::HandleComplexQuery(CefRefPtr browser, - CefRefPtr frame, + bool Handler::HandleComplexQuery(CefRefPtr browser, + CefRefPtr frame, YAML::Node& request, CefRefPtr callback) { - const string requestName = request["name"].as(); if (requestName == "find") { @@ -873,7 +871,7 @@ namespace loot { g_app_state.CurrentGame().LoadPlugins(false); //Sort plugins into their load order. - list plugins = g_app_state.CurrentGame().Sort(language, [this, frame](const string& message){ + list plugins = g_app_state.CurrentGame().Sort(language, [this, frame](const string& message) { this->SendProgressUpdate(frame, message); }); @@ -940,7 +938,6 @@ namespace loot { // Now rederive the displayed metadata from the masterlist and userlist. auto pluginIt = g_app_state.CurrentGame().plugins.find(boost::locale::to_lower(pluginName)); if (pluginIt != g_app_state.CurrentGame().plugins.end()) { - Plugin master(g_app_state.CurrentGame().masterlist.FindPlugin(pluginIt->second)); Plugin user(g_app_state.CurrentGame().userlist.FindPlugin(pluginIt->second)); @@ -1013,9 +1010,9 @@ namespace loot { return this; } - bool LootHandler::OnProcessMessageReceived( CefRefPtr browser, - CefProcessId source_process, - CefRefPtr message) { + bool LootHandler::OnProcessMessageReceived(CefRefPtr browser, + CefProcessId source_process, + CefRefPtr message) { return browser_side_router_->OnProcessMessageReceived(browser, source_process, message); } @@ -1023,12 +1020,12 @@ namespace loot { //-------------------------- void LootHandler::OnTitleChange(CefRefPtr browser, - const CefString& title) { - assert(CefCurrentlyOn(TID_UI)); + const CefString& title) { + assert(CefCurrentlyOn(TID_UI)); - CefWindowHandle hwnd = browser->GetHost()->GetWindowHandle(); + CefWindowHandle hwnd = browser->GetHost()->GetWindowHandle(); #ifdef _WIN32 - SetWindowText(hwnd, ToWinWide(title).c_str()); + SetWindowText(hwnd, ToWinWide(title).c_str()); #endif } @@ -1144,10 +1141,10 @@ namespace loot { //----------------------- void LootHandler::OnLoadError(CefRefPtr browser, - CefRefPtr frame, - ErrorCode errorCode, - const CefString& errorText, - const CefString& failedUrl) { + CefRefPtr frame, + ErrorCode errorCode, + const CefString& errorText, + const CefString& failedUrl) { assert(CefCurrentlyOn(TID_UI)); // Don't display an error for downloaded files. @@ -1157,9 +1154,9 @@ namespace loot { // Display a load error message. std::stringstream ss; ss << "" - << "

Failed to load URL " << std::string(failedUrl) - << " with error " << std::string(errorText) << " (" << errorCode - << ").

"; + << "

Failed to load URL " << std::string(failedUrl) + << " with error " << std::string(errorText) << " (" << errorCode + << ").

"; frame->LoadString(ss.str(), failedUrl); } @@ -1168,10 +1165,9 @@ namespace loot { //-------------------------- bool LootHandler::OnBeforeBrowse(CefRefPtr< CefBrowser > browser, - CefRefPtr< CefFrame > frame, - CefRefPtr< CefRequest > request, - bool is_redirect) { - + CefRefPtr< CefFrame > frame, + CefRefPtr< CefRequest > request, + bool is_redirect) { BOOST_LOG_TRIVIAL(trace) << "Attemping to open link: " << request->GetURL().ToString(); BOOST_LOG_TRIVIAL(trace) << "Comparing with URL: " << ToFileURL(g_path_report); @@ -1190,11 +1186,10 @@ namespace loot { } void LootHandler::CloseAllBrowsers(bool force_close) { - if (!CefCurrentlyOn(TID_UI)) { // Execute on the UI thread. CefPostTask(TID_UI, - NewCefRunnableMethod(this, &LootHandler::CloseAllBrowsers, force_close)); + NewCefRunnableMethod(this, &LootHandler::CloseAllBrowsers, force_close)); return; } @@ -1205,5 +1200,4 @@ namespace loot { (*it)->GetHost()->CloseBrowser(force_close); } } - } \ No newline at end of file diff --git a/src/gui/main_win.cpp b/src/gui/main_win.cpp index 75b4325f..629b3057 100644 --- a/src/gui/main_win.cpp +++ b/src/gui/main_win.cpp @@ -20,7 +20,7 @@ You should have received a copy of the GNU General Public License along with LOOT. If not, see . -*/ + */ #include "app.h" @@ -84,7 +84,6 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmd return exit_code; } - // Check if LOOT is already running //--------------------------------- diff --git a/src/resource.rc b/src/resource.rc index b32b64cc..9de7d8d8 100644 --- a/src/resource.rc +++ b/src/resource.rc @@ -1,22 +1,22 @@ #include "gui/resource.h" 1 VERSIONINFO - FILEVERSION 0,7,0,0 - PRODUCTVERSION 0,7,0,0 - FILEOS VOS__WINDOWS32 - FILETYPE VFT_APP +FILEVERSION 0, 7, 0, 0 +PRODUCTVERSION 0, 7, 0, 0 +FILEOS VOS__WINDOWS32 +FILETYPE VFT_APP BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "FileVersion", "0.7.0" - VALUE "LegalCopyright", "Copyright (C) 2013-2014 WrinklyNinja" - VALUE "ProductVersion", "0.7.0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END +BLOCK "StringFileInfo" +BEGIN +BLOCK "040904b0" +BEGIN +VALUE "FileVersion", "0.7.0" +VALUE "LegalCopyright", "Copyright (C) 2013-2014 WrinklyNinja" +VALUE "ProductVersion", "0.7.0" +END +END +BLOCK "VarFileInfo" +BEGIN +VALUE "Translation", 0x409, 1200 +END END MAINICON ICON "../resources/icon.ico"