mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Exceptions thrown during global message condition eval are now caught.
Also fixed global message conditions in v2 masterlists not being converted.
This commit is contained in:
@@ -501,11 +501,6 @@ namespace boss {
|
||||
std::list<Message>::iterator it = messages.begin();
|
||||
while (it != messages.end()) {
|
||||
|
||||
std::string condition = it->Condition();
|
||||
ConvertCondition(condition);
|
||||
|
||||
*it = Message(it->Type(), it->Content(), condition);
|
||||
|
||||
if (it->Type() == g_message_tag) {
|
||||
std::string message = it->ChooseContent(g_lang_any).Str();
|
||||
|
||||
@@ -684,6 +679,8 @@ namespace boss {
|
||||
std::vector<MessageContent> mc_vec;
|
||||
mc_vec.push_back(MessageContent(content, langInt));
|
||||
|
||||
ConvertCondition(condition);
|
||||
|
||||
message = Message(type, mc_vec, condition);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/regex.hpp>
|
||||
#include <boost/log/trivial.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -83,6 +84,8 @@ namespace boss {
|
||||
}
|
||||
|
||||
bool ConditionStruct::EvalCondition(boss::Game& game) const {
|
||||
BOOST_LOG_TRIVIAL(trace) << "Evaluating condition: " << _condition;
|
||||
|
||||
if (_condition.empty())
|
||||
return true;
|
||||
|
||||
@@ -153,6 +156,10 @@ namespace boss {
|
||||
}
|
||||
|
||||
bool Message::EvalCondition(boss::Game& game, const unsigned int language) {
|
||||
|
||||
BOOST_LOG_TRIVIAL(trace) << "Choosing message language.";
|
||||
|
||||
|
||||
if (_content.size() > 1) {
|
||||
if (language == g_lang_any) //Can use a message of any language, so use the first string.
|
||||
_content.resize(1);
|
||||
|
||||
@@ -570,6 +570,9 @@ namespace boss {
|
||||
|
||||
//Checks that the path (not regex) doesn't go outside any game folders.
|
||||
bool IsSafePath(const std::string& path) {
|
||||
|
||||
BOOST_LOG_TRIVIAL(trace) << "Checking to see if the path \"" << path << "\" is safe.";
|
||||
|
||||
std::vector<std::string> components;
|
||||
boost::split(components, path, boost::is_any_of("/\\"));
|
||||
components.pop_back();
|
||||
|
||||
+13
-7
@@ -75,12 +75,12 @@ namespace loc = boost::locale;
|
||||
|
||||
struct plugin_loader {
|
||||
plugin_loader(boss::Plugin& plugin, boss::Game& game) : _plugin(plugin), _game(game) {
|
||||
BOOST_LOG_TRIVIAL(info) << "Creating loader for: " << plugin.Name();
|
||||
}
|
||||
|
||||
void operator () () {
|
||||
BOOST_LOG_TRIVIAL(info) << "Loading: " << _plugin.Name();
|
||||
_plugin = boss::Plugin(_game, _plugin.Name(), false);
|
||||
BOOST_LOG_TRIVIAL(info) << "Finished loading: " << _plugin.Name();
|
||||
}
|
||||
|
||||
boss::Plugin& _plugin;
|
||||
@@ -95,6 +95,7 @@ struct plugin_list_loader {
|
||||
if (skipPlugins.find(it->Name()) == skipPlugins.end()) {
|
||||
BOOST_LOG_TRIVIAL(info) << "Loading: " << it->Name();
|
||||
*it = boss::Plugin(_game, it->Name(), false);
|
||||
BOOST_LOG_TRIVIAL(info) << "Finished loading: " << it->Name();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -524,12 +525,17 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) {
|
||||
|
||||
//Evaluate any conditions in the global messages.
|
||||
BOOST_LOG_TRIVIAL(trace) << "Evaluating global message conditions...";
|
||||
list<boss::Message>::iterator it=messages.begin();
|
||||
while (it != messages.end()) {
|
||||
if (!it->EvalCondition(_game, lang))
|
||||
it = messages.erase(it);
|
||||
else
|
||||
++it;
|
||||
try {
|
||||
list<boss::Message>::iterator it=messages.begin();
|
||||
while (it != messages.end()) {
|
||||
if (!it->EvalCondition(_game, lang))
|
||||
it = messages.erase(it);
|
||||
else
|
||||
++it;
|
||||
}
|
||||
} catch (boss::error& e) {
|
||||
BOOST_LOG_TRIVIAL(error) << "A global message contains a condition that could not be evaluated. Details: " << e.what();
|
||||
messages.push_back(boss::Message(boss::g_message_error, (format(loc::translate("A global message contains a condition that could not be evaluated. Details: %1%")) % e.what()).str()));
|
||||
}
|
||||
|
||||
//Merge plugin list, masterlist and userlist plugin data.
|
||||
|
||||
Reference in New Issue
Block a user