From 2b0e9e40d328d67e3332c88d5767ecea3b030d15 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Wed, 18 Jul 2012 00:35:39 +0000 Subject: [PATCH] - added more error checking in scenarios --- source/glest_game/menu/menu_state_scenario.cpp | 10 +++++++--- source/glest_game/world/scenario.cpp | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/source/glest_game/menu/menu_state_scenario.cpp b/source/glest_game/menu/menu_state_scenario.cpp index d89f407a..a71d138c 100644 --- a/source/glest_game/menu/menu_state_scenario.cpp +++ b/source/glest_game/menu/menu_state_scenario.cpp @@ -287,9 +287,13 @@ void MenuStateScenario::update() { } void MenuStateScenario::launchGame() { - GameSettings gameSettings; - loadGameSettings(&scenarioInfo, &gameSettings); - program->setState(new Game(program, &gameSettings, false)); + printf("In [%s::%s Line: %d] scenarioInfo.file [%s] [%s][%s][%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,scenarioInfo.file.c_str(),scenarioInfo.tilesetName.c_str(),scenarioInfo.mapName.c_str(),scenarioInfo.techTreeName.c_str()); + + if(scenarioInfo.file != "" && scenarioInfo.tilesetName != "" && scenarioInfo.mapName != "" && scenarioInfo.techTreeName != "") { + GameSettings gameSettings; + loadGameSettings(&scenarioInfo, &gameSettings); + program->setState(new Game(program, &gameSettings, false)); + } } void MenuStateScenario::setScenario(int i) { diff --git a/source/glest_game/world/scenario.cpp b/source/glest_game/world/scenario.cpp index f9a0efc5..3fefd714 100644 --- a/source/glest_game/world/scenario.cpp +++ b/source/glest_game/world/scenario.cpp @@ -155,8 +155,8 @@ string Scenario::getFunctionName(const XmlNode *scriptNode){ void Scenario::loadScenarioInfo(string file, ScenarioInfo *scenarioInfo) { //printf("[%s:%s] Line: %d file [%s]\n",__FILE__,__FUNCTION__,__LINE__,file.c_str()); - //if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] file [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,file.c_str()); - printf("In [%s::%s Line: %d] file [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,file.c_str()); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] file [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,file.c_str()); + //printf("In [%s::%s Line: %d] file [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,file.c_str()); Lang &lang= Lang::getInstance();