summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-12-04 09:43:13 +0000
committerrubidium <rubidium@openttd.org>2010-12-04 09:43:13 +0000
commitd1db18757d4933bf83401f201e7056c0dff0592d (patch)
treed54a3ff03dc7ec9cc529fb48bc000ca0b17c034b /src
parent8d81e17accca4fd568765607df654484ff60a3f7 (diff)
downloadopenttd-d1db18757d4933bf83401f201e7056c0dff0592d.tar.xz
(svn r21376) -Codechange: generalise ClearMemoryDumper
Diffstat (limited to 'src')
-rw-r--r--src/saveload/saveload.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp
index 686cb5e1e..13e12a18f 100644
--- a/src/saveload/saveload.cpp
+++ b/src/saveload/saveload.cpp
@@ -2285,9 +2285,9 @@ extern bool AfterLoadGame();
extern bool LoadOldSaveGame(const char *file);
/**
- * Clear/free the memory dumper.
+ * Clear/free saveload state.
*/
-static inline void ClearMemoryDumper()
+static inline void ClearSaveLoadState()
{
delete _sl.dumper;
_sl.dumper = NULL;
@@ -2373,7 +2373,7 @@ static SaveOrLoadResult SaveFileToDisk(bool threaded)
_sl.sf = fmt->init_write(_sl.sf, compression);
_sl.dumper->Flush(_sl.sf);
- ClearMemoryDumper();
+ ClearSaveLoadState();
if (threaded) SetAsyncSaveFinish(SaveFileDone);
@@ -2381,6 +2381,7 @@ static SaveOrLoadResult SaveFileToDisk(bool threaded)
} catch (...) {
AbortSaveLoad();
if (_sl.excpt_uninit != NULL) _sl.excpt_uninit();
+ ClearSaveLoadState();
/* Skip the "colour" character */
DEBUG(sl, 0, "%s", GetSaveLoadErrorString() + 3);
@@ -2489,7 +2490,6 @@ SaveOrLoadResult SaveOrLoad(const char *filename, int mode, Subdirectory sb, boo
_sl.dumper = new MemoryDumper();
_sl.sf = new FileWriter(_sl.fh);
_sl.fh = NULL; // This shouldn't be closed; goes via _sl.sf now.
- _sl.excpt_uninit = ClearMemoryDumper;
_sl_version = SAVEGAME_VERSION;
@@ -2621,6 +2621,8 @@ SaveOrLoadResult SaveOrLoad(const char *filename, int mode, Subdirectory sb, boo
fmt->uninit_read();
fclose(_sl.fh);
+ ClearSaveLoadState();
+
_savegame_type = SGT_OTTD;
if (mode == SL_LOAD_CHECK) {
@@ -2646,6 +2648,7 @@ SaveOrLoadResult SaveOrLoad(const char *filename, int mode, Subdirectory sb, boo
/* deinitialize compressor. */
if (_sl.excpt_uninit != NULL) _sl.excpt_uninit();
+ ClearSaveLoadState();
/* Skip the "colour" character */
if (mode != SL_LOAD_CHECK) DEBUG(sl, 0, "%s", GetSaveLoadErrorString() + 3);