From 7dae926cf2c14ba80e4024882496e3320264b1b7 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Sat, 9 Feb 2013 17:18:34 +0000 Subject: [PATCH] - do not show errors on console for scenarios without a description --- source/glest_game/global/lang.cpp | 14 ++++++++++++++ source/glest_game/global/lang.h | 1 + source/glest_game/world/scenario.cpp | 10 +++++++--- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/source/glest_game/global/lang.cpp b/source/glest_game/global/lang.cpp index 850ae56a..a88f6873 100644 --- a/source/glest_game/global/lang.cpp +++ b/source/glest_game/global/lang.cpp @@ -453,6 +453,20 @@ string Lang::getScenarioString(const string &s) { } } +bool Lang::hasScenarioString(const string &s) { + bool result = false; + try { + scenarioStrings.getString(s); + result = true; + } + catch(exception &ex) { + if(scenarioStrings.getpath() != "") { + if(SystemFlags::VERBOSE_MODE_ENABLED) SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); + } + } + return result; +} + string Lang::getTechTreeString(const string &s,const char *defaultValue) { try{ string result = ""; diff --git a/source/glest_game/global/lang.h b/source/glest_game/global/lang.h index c0482db6..02d8520f 100644 --- a/source/glest_game/global/lang.h +++ b/source/glest_game/global/lang.h @@ -63,6 +63,7 @@ public: string get(const string &s,string uselanguage="", bool fallbackToDefault=false); bool hasString(const string &s, string uselanguage="", bool fallbackToDefault=false); string getScenarioString(const string &s); + bool hasScenarioString(const string &s); string getTechTreeString(const string &s, const char *defaultValue=NULL); string getTilesetString(const string &s, const char *defaultValue=NULL); diff --git a/source/glest_game/world/scenario.cpp b/source/glest_game/world/scenario.cpp index 0471c73c..699de14c 100644 --- a/source/glest_game/world/scenario.cpp +++ b/source/glest_game/world/scenario.cpp @@ -310,9 +310,13 @@ void Scenario::loadScenarioInfo(string file, ScenarioInfo *scenarioInfo) { //look for description and append it lang.loadScenarioStrings(scenarioDir,scenarioName.c_str()); - string tmp_description = lang.getScenarioString("DESCRIPTION"); - if( tmp_description != "???DESCRIPTION???"){ - scenarioInfo->desc+= lang.get("Description") + ": \n" + tmp_description + "\n"; + //string tmp_description = lang.getScenarioString("DESCRIPTION"); + string tmp_description = ""; + if(lang.hasScenarioString("DESCRIPTION") == true) { + tmp_description = lang.getScenarioString("DESCRIPTION"); + } + if( tmp_description != "") { + scenarioInfo->desc += lang.get("Description") + ": \n" + tmp_description + "\n"; } if(scenarioNode->hasChild("fog-of-war") == true) {