diff options
author | Darkvater <darkvater@openttd.org> | 2005-07-16 09:55:31 +0000 |
---|---|---|
committer | Darkvater <darkvater@openttd.org> | 2005-07-16 09:55:31 +0000 |
commit | 19cb5e054a385c382b196df9cfcb90f59f053cbb (patch) | |
tree | 33e6cc47f0c3db8b4724dbe9c98cf34eb248ef43 | |
parent | 85ef06a0b5ce12b3ae796be1f6f490bf8b7df00f (diff) | |
download | openttd-19cb5e054a385c382b196df9cfcb90f59f053cbb.tar.xz |
(svn r2587) - Fix: Don't close the save-thread if it wasn't started because of some error or a network-server
-rw-r--r-- | saveload.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/saveload.c b/saveload.c index d2fc3748f..8739daca1 100644 --- a/saveload.c +++ b/saveload.c @@ -1280,7 +1280,7 @@ static bool SaveFileToDisk(void *ptr) fclose(_sl.fh); SaveFileDone(); - CloseOTTDThread(); + if (*(bool*)ptr) CloseOTTDThread(); return true; } @@ -1352,6 +1352,7 @@ int SaveOrLoad(const char *filename, int mode) /* General tactic is to first save the game to memory, then use an available writer * to write it to file, either in threaded mode if possible, or single-threaded */ if (mode == SL_SAVE) { /* SAVE game */ + bool threaded = true; fmt = GetSavegameFormat("memory"); // write to memory _sl.write_bytes = fmt->writer; @@ -1368,9 +1369,10 @@ int SaveOrLoad(const char *filename, int mode) SlWriteFill(); // flush the save buffer /* Write to file */ - if (_network_server || !CreateOTTDThread(&SaveFileToDisk, NULL)) { + if (_network_server || !CreateOTTDThread(&SaveFileToDisk, &threaded)) { DEBUG(misc, 1) ("cannot create savegame thread, reverting to single-threaded mode..."); - SaveFileToDisk(NULL); + threaded = false; + SaveFileToDisk(&threaded); } } else { /* LOAD game */ |