bool PluginMetadata::operator == (const PluginMetadata& rhs) const { if (IsRegexPlugin() == rhs.IsRegexPlugin()) return boost::iequals(name, rhs.Name()); if (IsRegexPlugin()) return regex_match(rhs.Name(), regex(name, regex::ECMAScript | regex::icase)); else return regex_match(name, regex(rhs.Name(), regex::ECMAScript | regex::icase)); }
PluginMetadata& PluginMetadata::EvalAllConditions(Game& game, const unsigned int language) { for (auto it = loadAfter.begin(); it != loadAfter.end();) { if (!it->EvalCondition(game)) loadAfter.erase(it++); else ++it; } for (auto it = requirements.begin(); it != requirements.end();) { if (!it->EvalCondition(game)) requirements.erase(it++); else ++it; } for (auto it = incompatibilities.begin(); it != incompatibilities.end();) { if (!it->EvalCondition(game)) incompatibilities.erase(it++); else ++it; } for (auto it = messages.begin(); it != messages.end();) { if (!it->EvalCondition(game, language)) it = messages.erase(it); else ++it; } for (auto it = tags.begin(); it != tags.end();) { if (!it->EvalCondition(game)) tags.erase(it++); else ++it; } //First need to get plugin's CRC, if it is an exact plugin and it does not have its CRC set. if (!IsRegexPlugin()) { uint32_t crc = 0; unordered_map<std::string, uint32_t>::iterator it = game.crcCache.find(boost::locale::to_lower(name)); if (it != game.crcCache.end()) crc = it->second; else if (boost::filesystem::exists(game.DataPath() / name)) { crc = GetCrc32(game.DataPath() / name); } else if (boost::filesystem::exists(game.DataPath() / (name + ".ghost"))) { crc = GetCrc32(game.DataPath() / (name + ".ghost")); } else { // The plugin isn't installed, discard the dirty info. _dirtyInfo.clear(); } // Store the CRC in the cache in case it's not already in there. game.crcCache.insert(pair<string, uint32_t>(boost::locale::to_lower(name), crc)); // Now use the CRC to evaluate the dirty info. for (auto it = _dirtyInfo.begin(); it != _dirtyInfo.end();) { if (it->CRC() != crc) _dirtyInfo.erase(it++); else ++it; } } else { // Regex plugins shouldn't have dirty info, but just clear in case. _dirtyInfo.clear(); } return *this; }
bool PluginMetadata::operator == (const PluginMetadata& 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)))); }