mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
This might fix issue #26. Thinking about sorting does my head in though.
This commit is contained in:
+13
-14
@@ -533,6 +533,15 @@ namespace boss {
|
||||
|
||||
return overlap;
|
||||
}
|
||||
|
||||
std::set<FormID> Plugin::OverrideFormIDs() const {
|
||||
set<FormID> fidSubset;
|
||||
for (set<FormID>::const_iterator it = formIDs.begin(), endIt=formIDs.end(); it != endIt; ++it) {
|
||||
if (!boost::iequals(it->Plugin(), name))
|
||||
fidSubset.insert(*it);
|
||||
}
|
||||
return fidSubset;
|
||||
}
|
||||
|
||||
std::vector<std::string> Plugin::Masters() const {
|
||||
return masters;
|
||||
@@ -660,17 +669,8 @@ namespace boss {
|
||||
}
|
||||
|
||||
bool load_order_sort(const Plugin& lhs, const Plugin& rhs) {
|
||||
if (lhs.IsMaster() && !rhs.IsMaster())
|
||||
return true;
|
||||
|
||||
if (!lhs.IsMaster() && rhs.IsMaster())
|
||||
return false;
|
||||
|
||||
if (rhs.MustLoadAfter(lhs))
|
||||
return true;
|
||||
|
||||
if (lhs.MustLoadAfter(rhs))
|
||||
return false;
|
||||
return false;
|
||||
|
||||
if (lhs.Priority() < rhs.Priority())
|
||||
return true;
|
||||
@@ -678,11 +678,10 @@ namespace boss {
|
||||
if (lhs.Priority() > rhs.Priority())
|
||||
return false;
|
||||
|
||||
if (!lhs.OverlapFormIDs(rhs).empty() && lhs.FormIDs().size() != rhs.FormIDs().size())
|
||||
return lhs.FormIDs().size() > rhs.FormIDs().size();
|
||||
if (!lhs.OverlapFormIDs(rhs).empty() && lhs.OverrideFormIDs().size() != rhs.OverrideFormIDs().size())
|
||||
return lhs.OverrideFormIDs().size() > rhs.OverrideFormIDs().size();
|
||||
|
||||
// return boost::ilexicographical_compare(lhs.Name(), rhs.Name());
|
||||
return false;
|
||||
return boost::ilexicographical_compare(lhs.Name(), rhs.Name());
|
||||
}
|
||||
|
||||
bool IsPlugin(const std::string& file) {
|
||||
|
||||
@@ -174,6 +174,7 @@ namespace boss {
|
||||
|
||||
//Load ordering functions.
|
||||
std::set<FormID> OverlapFormIDs(const Plugin& plugin) const;
|
||||
std::set<FormID> OverrideFormIDs() const;
|
||||
bool MustLoadAfter(const Plugin& plugin) const; //Checks masters, reqs and loadAfter.
|
||||
|
||||
//Validity checks.
|
||||
|
||||
+12
-1
@@ -497,13 +497,22 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) {
|
||||
|
||||
out << "Sorting for: " << it->Name() << endl;
|
||||
|
||||
/* vector<string> masters = it->Masters();
|
||||
if (!masters.empty()) {
|
||||
out << "\t" << "Masters:" << endl;
|
||||
for (size_t i=0, max=masters.size(); i < max; ++i)
|
||||
out << "\t\t" << masters[i] << endl;
|
||||
}*/
|
||||
|
||||
list<boss::Plugin> moved;
|
||||
while (jt != plugins.end()) {
|
||||
/* if (it->MustLoadAfter(*jt)
|
||||
|| jt->Priority() < it->Priority()) {
|
||||
|| (!jt->OverlapFormIDs(*it).empty() && jt->FormIDs().size() != it->FormIDs().size() && jt->FormIDs().size() > it->FormIDs().size())) {
|
||||
*/
|
||||
if (load_order_sort(*jt, *it)) {
|
||||
// if (load_order_sort(*jt, *it)) {
|
||||
if (it->MustLoadAfter(*jt)) {
|
||||
out << jt->Name() << " should load before " << it->Name() << endl;
|
||||
moved.push_back(*jt);
|
||||
jt = plugins.erase(jt);
|
||||
} else
|
||||
@@ -519,6 +528,8 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) {
|
||||
|
||||
progDia->Pulse();
|
||||
}
|
||||
|
||||
plugins.sort(boss::load_order_sort);
|
||||
|
||||
end = time(NULL);
|
||||
out << "Time taken to sort plugins: " << (end - start) << " seconds." << endl;
|
||||
|
||||
Reference in New Issue
Block a user