- do not show errors on console for scenarios without a description

This commit is contained in:
Mark Vejvoda 2013-02-09 17:18:34 +00:00
parent af100408ed
commit 7dae926cf2
3 changed files with 22 additions and 3 deletions

View File

@ -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 = "";

View File

@ -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);

View File

@ -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) {