mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Improved some error messages, fixed sorting bugginess.
This commit is contained in:
+23
-17
@@ -232,8 +232,9 @@ namespace boss {
|
||||
ret = lo_create_handle(&gh, LIBLO_GAME_FNV, gamePath.string().c_str());
|
||||
|
||||
if (ret != LIBLO_OK) {
|
||||
const char * err;
|
||||
lo_get_error_message(&err);
|
||||
const char * e;
|
||||
lo_get_error_message(&e);
|
||||
string err = string("libloadorder failed to create a game handle. Details: ") + err;
|
||||
lo_cleanup();
|
||||
throw error(ERROR_LIBLO_ERROR, err);
|
||||
}
|
||||
@@ -241,17 +242,19 @@ namespace boss {
|
||||
ret = lo_set_game_master(gh, _masterFile.c_str());
|
||||
|
||||
if (ret != LIBLO_OK) {
|
||||
const char * err;
|
||||
lo_get_error_message(&err);
|
||||
const char * e;
|
||||
lo_get_error_message(&e);
|
||||
lo_destroy_handle(gh);
|
||||
string err = string("libloadorder total conversion support setup failed. Details: ") + e;
|
||||
lo_cleanup();
|
||||
throw error(ERROR_LIBLO_ERROR, "libloadorder total conversion support setup failed.");
|
||||
throw error(ERROR_LIBLO_ERROR,err);
|
||||
}
|
||||
|
||||
if (lo_get_active_plugins(gh, &pluginArr, &pluginArrSize) != LIBLO_OK) {
|
||||
const char * err;
|
||||
lo_get_error_message(&err);
|
||||
const char * e;
|
||||
lo_get_error_message(&e);
|
||||
lo_destroy_handle(gh);
|
||||
string err = string("libloadorder failed to get the active plugins list. Details: ") + e;
|
||||
lo_cleanup();
|
||||
throw error(ERROR_LIBLO_ERROR, err);
|
||||
}
|
||||
@@ -283,20 +286,22 @@ namespace boss {
|
||||
ret = lo_create_handle(&gh, LIBLO_GAME_FNV, gamePath.string().c_str());
|
||||
|
||||
if (ret != LIBLO_OK) {
|
||||
const char * err;
|
||||
lo_get_error_message(&err);
|
||||
const char * e;
|
||||
lo_get_error_message(&e);
|
||||
string err = string("libloadorder game handle creation failed. Details: ") + e;
|
||||
lo_cleanup();
|
||||
throw error(ERROR_LIBLO_ERROR, "libloadorder game handle creation failed.");
|
||||
throw error(ERROR_LIBLO_ERROR, err);
|
||||
}
|
||||
|
||||
ret = lo_set_game_master(gh, _masterFile.c_str());
|
||||
|
||||
if (ret != LIBLO_OK) {
|
||||
const char * err;
|
||||
lo_get_error_message(&err);
|
||||
const char * e;
|
||||
lo_get_error_message(&e);
|
||||
lo_destroy_handle(gh);
|
||||
string err = string("libloadorder total conversion support setup failed. Details: ") + e;
|
||||
lo_cleanup();
|
||||
throw error(ERROR_LIBLO_ERROR, "libloadorder total conversion support setup failed.");
|
||||
throw error(ERROR_LIBLO_ERROR, err);
|
||||
}
|
||||
|
||||
pluginArrSize = loadOrder.size();
|
||||
@@ -312,11 +317,12 @@ namespace boss {
|
||||
for (size_t i=0; i < pluginArrSize; i++)
|
||||
delete [] pluginArr[i];
|
||||
delete [] pluginArr;
|
||||
const char * err;
|
||||
lo_get_error_message(&err);
|
||||
const char * e;
|
||||
lo_get_error_message(&e);
|
||||
lo_destroy_handle(gh);
|
||||
string err = string("libloadorder failed to set the load order. Details: ") + e;
|
||||
lo_cleanup();
|
||||
throw error(ERROR_LIBLO_ERROR, "Setting load order failed.");
|
||||
throw error(ERROR_LIBLO_ERROR, err);
|
||||
}
|
||||
|
||||
for (size_t i=0; i < pluginArrSize; i++)
|
||||
@@ -332,7 +338,7 @@ namespace boss {
|
||||
if (!fs::exists(g_path_local / bossFolderName))
|
||||
fs::create_directory(g_path_local / bossFolderName);
|
||||
} catch (fs::filesystem_error& e) {
|
||||
throw error(ERROR_PATH_WRITE_FAIL, "Could not create BOSS folder for game.");
|
||||
throw error(ERROR_PATH_WRITE_FAIL, string("Could not create BOSS folder for game. Details: ") + e.what());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -547,7 +547,8 @@ namespace boss {
|
||||
}
|
||||
|
||||
bool Plugin::MustLoadAfter(const Plugin& plugin) const {
|
||||
if (find(masters.begin(), masters.end(), plugin) != masters.end()
|
||||
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())
|
||||
return true;
|
||||
@@ -680,7 +681,8 @@ namespace boss {
|
||||
if (!lhs.OverlapFormIDs(rhs).empty() && lhs.FormIDs().size() != rhs.FormIDs().size())
|
||||
return lhs.FormIDs().size() > rhs.FormIDs().size();
|
||||
|
||||
return boost::ilexicographical_compare(lhs.Name(), rhs.Name());
|
||||
// return boost::ilexicographical_compare(lhs.Name(), rhs.Name());
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsPlugin(const std::string& file) {
|
||||
|
||||
+21
-8
@@ -489,7 +489,7 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) {
|
||||
if (!cyclicDependenciesExist) {
|
||||
out << "Sorting plugins..." << endl;
|
||||
|
||||
//std::sort doesn't compare each plugin to every other plugin, it seems to compare plugins until no movement is necessary, because it assumes that each plugin will be comparable on all tested data, which isn't the case when dealing with masters, etc. Therefore, loop through the list and move each plugin's dependencies directly before it, then apply std::sort.
|
||||
//std::sort doesn't compare each plugin to every other plugin, it seems to compare plugins until no movement is necessary, because it assumes that each plugin will be comparable on all tested data, which isn't the case when dealing with masters, etc.
|
||||
list<boss::Plugin>::iterator it=plugins.begin();
|
||||
while (it != plugins.end()) {
|
||||
list<boss::Plugin>::iterator jt=it;
|
||||
@@ -499,7 +499,11 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) {
|
||||
|
||||
list<boss::Plugin> moved;
|
||||
while (jt != plugins.end()) {
|
||||
if (it->MustLoadAfter(*jt)) {
|
||||
/* 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)) {
|
||||
moved.push_back(*jt);
|
||||
jt = plugins.erase(jt);
|
||||
} else
|
||||
@@ -515,9 +519,7 @@ 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;
|
||||
|
||||
@@ -584,14 +586,25 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) {
|
||||
uout.close();
|
||||
|
||||
//Now set load order.
|
||||
_game.SetLoadOrder(plugins);
|
||||
try {
|
||||
_game.SetLoadOrder(plugins);
|
||||
} catch (boss::error& e) {
|
||||
messages.push_back(boss::Message(boss::g_message_error, (format(loc::translate("Failed to set the load order. Details: %1%")) % e.what()).str()));
|
||||
}
|
||||
} else
|
||||
messages.push_back(boss::Message(boss::g_message_warn, loc::translate("The load order displayed in the Details tab was not applied as sorting was canceled.")));
|
||||
cyclicDependenciesExist = true;
|
||||
|
||||
out << "Set load order:" << endl;
|
||||
for (list<boss::Plugin>::iterator it=plugins.begin(), endIt = plugins.end(); it != endIt; ++it)
|
||||
for (list<boss::Plugin>::iterator it=plugins.begin(), endIt = plugins.end(); it != endIt; ++it) {
|
||||
out << '\t' << 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;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
out << "Generating report..." << endl;
|
||||
@@ -638,7 +651,7 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) {
|
||||
|
||||
progDia->Pulse();
|
||||
|
||||
out << "Tester finished. Total time taken: " << time(NULL) - t0 << endl;
|
||||
out << "Sorting finished. Total time taken: " << time(NULL) - t0 << endl;
|
||||
out.close();
|
||||
|
||||
//Now a results report definitely exists.
|
||||
|
||||
Reference in New Issue
Block a user