- added a new function to correct some file paths when loading a saved game from another persons computer (may need more tweaking)

- added support for saving and loading tables from Lua
This commit is contained in:
Mark Vejvoda
2012-03-29 18:14:25 +00:00
parent c13e0ef788
commit f3df72bb14
8 changed files with 323 additions and 151 deletions

View File

@@ -150,7 +150,7 @@ static inline T* readFromFileReaders(vector<FileReader<T> const *>* readers, con
ifstream file(filepath.c_str(), ios::in | ios::binary);
#endif
if (!file.is_open()) { //An error occured; TODO: Which one - throw an exception, print error message?
throw runtime_error("Could not open file " + filepath);
throw runtime_error("[#1] Could not open file " + filepath);
}
for (typename vector<FileReader<T> const *>::const_iterator i = readers->begin(); i != readers->end(); ++i) {
T* ret = NULL;
@@ -192,9 +192,9 @@ static inline T* readFromFileReaders(vector<FileReader<T> const *>* readers, con
if (!file.is_open()) { //An error occured; TODO: Which one - throw an exception, print error message?
#if defined(WIN32) && !defined(__MINGW32__)
DWORD error = GetLastError();
throw runtime_error("Could not open file, result: " + intToStr(error) + " - " + intToStr(fileErrno) + " [" + filepath + "]");
throw runtime_error("[#2] Could not open file, result: " + intToStr(error) + " - " + intToStr(fileErrno) + " [" + filepath + "]");
#else
throw runtime_error("Could not open file [" + filepath + "]");
throw runtime_error("[#2] Could not open file [" + filepath + "]");
#endif
}
for (typename vector<FileReader<T> const *>::const_iterator i = readers->begin(); i != readers->end(); ++i) {
@@ -329,7 +329,7 @@ T* FileReader<T>::read(const string& filepath) const {
ifstream file(filepath.c_str(), ios::in | ios::binary);
#endif
if (!file.is_open()) { //An error occured; TODO: Which one - throw an exception, print error message?
throw runtime_error("Could not open file " + filepath);
throw runtime_error("[#3] Could not open file " + filepath);
}
T* ret = read(file,filepath);
file.close();
@@ -354,7 +354,7 @@ T* FileReader<T>::read(const string& filepath, T* object) const {
ifstream file(filepath.c_str(), ios::in | ios::binary);
#endif
if (!file.is_open()) { //An error occured; TODO: Which one - throw an exception, print error message?
throw runtime_error("Could not open file " + filepath);
throw runtime_error("[#4] Could not open file " + filepath);
}
T* ret = read(file,filepath,object);
file.close();