From 46a177ad7cd7934d6a21b861d1ab4a146b761442 Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Tue, 11 Nov 2014 19:17:09 +0000 Subject: [PATCH] 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. --- resources/report/bower.json | 2 +- src/gui/handler.cpp | 72 ++++++++++++++++++------------------- 2 files changed, 35 insertions(+), 39 deletions(-) diff --git a/resources/report/bower.json b/resources/report/bower.json index b8f6d2af..ebcd74df 100644 --- a/resources/report/bower.json +++ b/resources/report/bower.json @@ -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" } diff --git a/src/gui/handler.cpp b/src/gui/handler.cpp index 227c7a70..b49c22dd 100644 --- a/src/gui/handler.cpp +++ b/src/gui/handler.cpp @@ -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()).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()).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 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::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 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::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)); }