diff --git a/source/glest_game/world/tileset.cpp b/source/glest_game/world/tileset.cpp index 52b646736..8b84ce3ec 100644 --- a/source/glest_game/world/tileset.cpp +++ b/source/glest_game/world/tileset.cpp @@ -121,15 +121,22 @@ void AmbientSounds::load(const string &dir, const XmlNode *xmlNode, Checksum Tileset::loadTileset(const vector pathList, const string &tilesetName, Checksum* checksum, std::map > > &loadedFileList) { Checksum tilesetChecksum; + + bool found = false; for(int idx = 0; idx < pathList.size(); idx++) { string currentPath = pathList[idx]; endPathWithSlash(currentPath); string path = currentPath + tilesetName; if(isdir(path.c_str()) == true) { load(path, checksum, &tilesetChecksum, loadedFileList); + found = true; break; } } + if(found == false) { + throw megaglest_runtime_error("Error could not find tileset [" + tilesetName + "]\n"); + + } return tilesetChecksum; } @@ -162,6 +169,7 @@ void Tileset::load(const string &dir, Checksum *checksum, Checksum *tilesetCheck if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + //printf("About to load tileset [%s]\n",path.c_str()); //parse xml XmlTree xmlTree; xmlTree.load(path,Properties::getTagReplacementValues()); diff --git a/source/glest_game/world/time_flow.cpp b/source/glest_game/world/time_flow.cpp index 410bbb3e8..c45597b02 100644 --- a/source/glest_game/world/time_flow.cpp +++ b/source/glest_game/world/time_flow.cpp @@ -49,11 +49,16 @@ void TimeFlow::update() { //sounds SoundRenderer &soundRenderer= SoundRenderer::getInstance(); - AmbientSounds *ambientSounds= tileset->getAmbientSounds(); + AmbientSounds *ambientSounds= NULL; + if(tileset != NULL) { + ambientSounds = tileset->getAmbientSounds(); + } //day if(lastTime=dawn){ - soundRenderer.stopAmbient(ambientSounds->getNight()); + if(ambientSounds != NULL) { + soundRenderer.stopAmbient(ambientSounds->getNight()); + } UnitParticleSystem::isNight=false; } UnitParticleSystem::lightColor=computeLightColor(); @@ -61,12 +66,14 @@ void TimeFlow::update() { if((lastTime=dawn) || firstTime){ //day sound - if(ambientSounds->isEnabledDayStart() && !firstTime){ - soundRenderer.playFx(ambientSounds->getDayStart()); - } - if(ambientSounds->isEnabledDay()){ - if(ambientSounds->getAlwaysPlayDay() || tileset->getWeather()==wSunny){ - soundRenderer.playAmbient(ambientSounds->getDay()); + if(ambientSounds != NULL) { + if(ambientSounds->isEnabledDayStart() && !firstTime){ + soundRenderer.playFx(ambientSounds->getDayStart()); + } + if(ambientSounds->isEnabledDay()){ + if(ambientSounds->getAlwaysPlayDay() || tileset->getWeather()==wSunny){ + soundRenderer.playAmbient(ambientSounds->getDay()); + } } } firstTime= false; @@ -74,18 +81,22 @@ void TimeFlow::update() { //night if(lastTime=dusk){ - soundRenderer.stopAmbient(ambientSounds->getDay()); + if(ambientSounds != NULL) { + soundRenderer.stopAmbient(ambientSounds->getDay()); + } UnitParticleSystem::isNight=true; } if(lastTime=dusk){ //night - if(ambientSounds->isEnabledNightStart()){ - soundRenderer.playFx(ambientSounds->getNightStart()); - } - if(ambientSounds->isEnabledNight()){ - if(ambientSounds->getAlwaysPlayNight() || tileset->getWeather()==wSunny){ - soundRenderer.playAmbient(ambientSounds->getNight()); + if(ambientSounds != NULL) { + if(ambientSounds->isEnabledNightStart()){ + soundRenderer.playFx(ambientSounds->getNightStart()); + } + if(ambientSounds->isEnabledNight()){ + if(ambientSounds->getAlwaysPlayNight() || tileset->getWeather()==wSunny){ + soundRenderer.playAmbient(ambientSounds->getNight()); + } } } } @@ -99,29 +110,31 @@ void TimeFlow::update() { Vec3f TimeFlow::computeLightColor() const { Vec3f color; - float time=getTime(); + if(tileset != NULL) { + float time=getTime(); - const float transition= 2; - const float dayStart= TimeFlow::dawn; - const float dayEnd= TimeFlow::dusk-transition; - const float nightStart= TimeFlow::dusk; - const float nightEnd= TimeFlow::dawn-transition; + const float transition= 2; + const float dayStart= TimeFlow::dawn; + const float dayEnd= TimeFlow::dusk-transition; + const float nightStart= TimeFlow::dusk; + const float nightEnd= TimeFlow::dawn-transition; - if(time>dayStart && timegetSunLightColor(); - } - else if(time>nightStart || timegetMoonLightColor(); - } - else if(time>=dayEnd && time<=nightStart) { - color= tileset->getSunLightColor().lerp((time-dayEnd)/transition, tileset->getMoonLightColor()); - } - else if(time>=nightEnd && time<=dayStart) { - color= tileset->getMoonLightColor().lerp((time-nightEnd)/transition, tileset->getSunLightColor()); - } - else { - assert(false); - color= tileset->getSunLightColor(); + if(time>dayStart && timegetSunLightColor(); + } + else if(time>nightStart || timegetMoonLightColor(); + } + else if(time>=dayEnd && time<=nightStart) { + color= tileset->getSunLightColor().lerp((time-dayEnd)/transition, tileset->getMoonLightColor()); + } + else if(time>=nightEnd && time<=dayStart) { + color= tileset->getMoonLightColor().lerp((time-nightEnd)/transition, tileset->getSunLightColor()); + } + else { + assert(false); + color= tileset->getSunLightColor(); + } } return color; }