Removal of JS game caching required C++ changes.

Global messages shouldn't be cached anyway, as install changes can
affect them, so always re-derive and send them. Also always send
masterlist revision info, as there's little worth in caching it, and it
means nothing needs to be cached in JS.
This commit is contained in:
Oliver Hamlet
2014-11-11 19:17:09 +00:00
parent cfc5265d6a
commit 46a177ad7c
2 changed files with 35 additions and 39 deletions
+1 -1
View File
@@ -26,7 +26,7 @@
"paper-checkbox": "Polymer/paper-checkbox#~0.4.2",
"paper-dialog": "Polymer/paper-dialog#~0.4.2",
"paper-menu-button": "Polymer/paper-menu-button#~0.4.2",
"Jed": "SlexAxton/Jed#~1.1.0",
"Jed": "SlexAxton/Jed#a9d03e1bbca9211a8b29a93a298a7ee9ddb353f0",
"marked": "chjj/marked#~0.3.2",
"requirejs": "jrburke/requirejs-bower#~2.1.15"
}
+34 -38
View File
@@ -656,16 +656,14 @@ namespace loot {
// ID the game using its folder value.
gameNode["folder"] = g_app_state.CurrentGame().FolderName();
if (isFirstLoad) {
// Store the masterlist revision and date.
try {
gameNode["masterlist"]["revision"] = g_app_state.CurrentGame().masterlist.GetRevision(g_app_state.CurrentGame().MasterlistPath(), true);
gameNode["masterlist"]["date"] = g_app_state.CurrentGame().masterlist.GetDate(g_app_state.CurrentGame().MasterlistPath());
}
catch (error &e) {
gameNode["masterlist"]["revision"] = e.what();
gameNode["masterlist"]["date"] = e.what();
}
// Store the masterlist revision and date.
try {
gameNode["masterlist"]["revision"] = g_app_state.CurrentGame().masterlist.GetRevision(g_app_state.CurrentGame().MasterlistPath(), true);
gameNode["masterlist"]["date"] = g_app_state.CurrentGame().masterlist.GetDate(g_app_state.CurrentGame().MasterlistPath());
}
catch (error &e) {
gameNode["masterlist"]["revision"] = e.what();
gameNode["masterlist"]["date"] = e.what();
}
// Now store plugin data.
@@ -730,37 +728,35 @@ namespace loot {
gameNode["plugins"].push_back(pluginNode);
}
if (isFirstLoad) {
SendProgressUpdate(frame, "Loading general messages...");
//Set language.
unsigned int language;
if (g_app_state.GetSettings()["language"])
language = Language(g_app_state.GetSettings()["language"].as<string>()).Code();
else
language = Language::any;
BOOST_LOG_TRIVIAL(info) << "Using message language: " << Language(language).Name();
SendProgressUpdate(frame, "Loading general messages...");
//Set language.
unsigned int language;
if (g_app_state.GetSettings()["language"])
language = Language(g_app_state.GetSettings()["language"].as<string>()).Code();
else
language = Language::any;
BOOST_LOG_TRIVIAL(info) << "Using message language: " << Language(language).Name();
//Evaluate any conditions in the global messages.
BOOST_LOG_TRIVIAL(debug) << "Evaluating global message conditions.";
list<Message> messages = g_app_state.CurrentGame().masterlist.messages;
messages.insert(messages.end(), g_app_state.CurrentGame().userlist.messages.begin(), g_app_state.CurrentGame().userlist.messages.end());
try {
list<Message>::iterator it = messages.begin();
while (it != messages.end()) {
if (!it->EvalCondition(g_app_state.CurrentGame(), language))
it = messages.erase(it);
else
++it;
}
//Evaluate any conditions in the global messages.
BOOST_LOG_TRIVIAL(debug) << "Evaluating global message conditions.";
list<Message> messages = g_app_state.CurrentGame().masterlist.messages;
messages.insert(messages.end(), g_app_state.CurrentGame().userlist.messages.begin(), g_app_state.CurrentGame().userlist.messages.end());
try {
list<Message>::iterator it = messages.begin();
while (it != messages.end()) {
if (!it->EvalCondition(g_app_state.CurrentGame(), language))
it = messages.erase(it);
else
++it;
}
catch (std::exception& e) {
BOOST_LOG_TRIVIAL(error) << "A global message contains a condition that could not be evaluated. Details: " << e.what();
messages.push_back(Message(Message::error, (format(loc::translate("A global message contains a condition that could not be evaluated. Details: %1%")) % e.what()).str()));
}
// Now store global messages from masterlist.
gameNode["globalMessages"] = messages;
}
catch (std::exception& e) {
BOOST_LOG_TRIVIAL(error) << "A global message contains a condition that could not be evaluated. Details: " << e.what();
messages.push_back(Message(Message::error, (format(loc::translate("A global message contains a condition that could not be evaluated. Details: %1%")) % e.what()).str()));
}
// Now store global messages.
gameNode["globalMessages"] = messages;
callback->Success(JSON::stringify(gameNode));
}