From c703de994f0b924ed9982adedeaa59cbf2e43829 Mon Sep 17 00:00:00 2001 From: PolitikerNEU Date: Tue, 1 Jun 2010 18:40:14 +0000 Subject: [PATCH] Tried to fix the wrong error message given if the file could not be found --- mk/linux/glest.ini | 15 ++++++++------- source/shared_lib/include/graphics/FileReader.h | 16 ++++++++++++++-- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/mk/linux/glest.ini b/mk/linux/glest.ini index 4ebd94028..9fda387c1 100644 --- a/mk/linux/glest.ini +++ b/mk/linux/glest.ini @@ -15,9 +15,10 @@ ConsoleMaxLinesStored=20 ConsoleTimeout=20 DayTime=1000 DebugLogFile=debug.log -DebugMode=false -DebugPerformance=false +DebugMode=true DebugNetwork=false +DebugPerformance=false +DebugWorldSynch=false DepthBits=16 FactoryGraphics=OpenGL FactorySound=OpenAL @@ -45,8 +46,8 @@ FontMenuNormalPrefix=-*-helvetica-*-r-*-*- FontMenuVeryBigBaseSize=25 FontSizeAdjustment=0 Lang=english -MaxLights=8 Masterserver=http://soft-haus.com/glest/cgi-bin/ +MaxLights=2 NetPlayerName=unknown NetworkConsistencyChecks=true PhotoMode=false @@ -58,14 +59,14 @@ ServerPort=61357 ShadowAlpha=0.2 ShadowFrameSkip=2 ShadowTextureSize=512 -Shadows=Projected +Shadows=Disabled SoundStaticBuffers=16 SoundStreamingBuffers=4 SoundVolumeAmbient=80 SoundVolumeFx=80 SoundVolumeMusic=90 StencilBits=0 -Textures3D=true -UnitParticles=true +Textures3D=0 +UnitParticles=1 UserData_Root=mydata/ -Windowed=false +Windowed=1 diff --git a/source/shared_lib/include/graphics/FileReader.h b/source/shared_lib/include/graphics/FileReader.h index 5aca42737..e20faaefd 100644 --- a/source/shared_lib/include/graphics/FileReader.h +++ b/source/shared_lib/include/graphics/FileReader.h @@ -140,11 +140,17 @@ public: template static inline T* readFromFileReaders(vector const *>* readers, const string& filepath) { + //try to assign file + ifstream file(filepath.c_str(), ios::in | ios::binary); + if (!file.is_open()) { //An error occured; TODO: Which one - throw an exception, print error message? + throw runtime_error("Could not open file " + filepath); + } for (typename vector const *>::const_iterator i = readers->begin(); i != readers->end(); ++i) { T* ret = NULL; + file.seekg(0, ios::beg); //Set position to first try { FileReader const * reader = *i; - ret = reader->read(filepath); //It is guaranteed that at least the filepath matches ... + ret = reader->read(file, filepath); //It is guaranteed that at least the filepath matches ... } catch (...) { //TODO: Specific exceptions continue; } @@ -157,11 +163,17 @@ static inline T* readFromFileReaders(vector const *>* readers, con template static inline T* readFromFileReaders(vector const *>* readers, const string& filepath, T* object) { + //try to assign file + ifstream file(filepath.c_str(), ios::in | ios::binary); + if (!file.is_open()) { //An error occured; TODO: Which one - throw an exception, print error message? + throw runtime_error("Could not open file " + filepath); + } for (typename vector const *>::const_iterator i = readers->begin(); i != readers->end(); ++i) { T* ret = NULL; + file.seekg(0, ios::beg); //Set position to first try { FileReader const * reader = *i; - ret = reader->read(filepath, object); //It is guaranteed that at least the filepath matches ... + ret = reader->read(file, filepath, object); //It is guaranteed that at least the filepath matches ... } catch (...) { //TODO: Specific exceptions continue; }