This might fix issue #26. Thinking about sorting does my head in though.

This commit is contained in:
WrinklyNinja
2013-06-20 17:27:55 +01:00
parent 6e71136964
commit 4c3080dfb5
3 changed files with 26 additions and 15 deletions
+13 -14
View File
@@ -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) {
+1
View 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
View File
@@ -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;