mirror of
https://github.com/glest/glest-source.git
synced 2025-02-25 12:12:25 +01:00
- updated to not segfault when loading a saved game and tileset is not found
This commit is contained in:
parent
fff77031fc
commit
e2844938b7
@ -121,15 +121,22 @@ void AmbientSounds::load(const string &dir, const XmlNode *xmlNode,
|
||||
Checksum Tileset::loadTileset(const vector<string> pathList, const string &tilesetName,
|
||||
Checksum* checksum, std::map<string,vector<pair<string, string> > > &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());
|
||||
|
@ -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 && time>=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 && time>=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 && time>=dusk){
|
||||
soundRenderer.stopAmbient(ambientSounds->getDay());
|
||||
if(ambientSounds != NULL) {
|
||||
soundRenderer.stopAmbient(ambientSounds->getDay());
|
||||
}
|
||||
UnitParticleSystem::isNight=true;
|
||||
}
|
||||
|
||||
if(lastTime<dusk && time>=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 && time<dayEnd) {
|
||||
color= tileset->getSunLightColor();
|
||||
}
|
||||
else if(time>nightStart || time<nightEnd) {
|
||||
color= tileset->getMoonLightColor();
|
||||
}
|
||||
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 && time<dayEnd) {
|
||||
color= tileset->getSunLightColor();
|
||||
}
|
||||
else if(time>nightStart || time<nightEnd) {
|
||||
color= tileset->getMoonLightColor();
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user