summaryrefslogtreecommitdiff
path: root/saveload.c
diff options
context:
space:
mode:
authorDarkvater <darkvater@openttd.org>2005-09-02 22:22:02 +0000
committerDarkvater <darkvater@openttd.org>2005-09-02 22:22:02 +0000
commit92270500e990b2039049ad0dec842a7f5a27d32a (patch)
tree5c3546aea89dcb6f9b797737806d900b7230a97e /saveload.c
parentd05f504c01fb88eb8b88d28b5fd5da664e31cd95 (diff)
downloadopenttd-92270500e990b2039049ad0dec842a7f5a27d32a.tar.xz
(svn r2908) If threaded saving fails or does not happen, sending subsequent messages might hang ottd. So don't send them :)
Diffstat (limited to 'saveload.c')
-rw-r--r--saveload.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/saveload.c b/saveload.c
index 88c8a69c4..bbf39aa45 100644
--- a/saveload.c
+++ b/saveload.c
@@ -1283,6 +1283,8 @@ void SaveFileError(void)
SaveFileDone();
}
+static Thread* save_thread;
+
/** We have written the whole game into memory, _save_pool, now find
* and appropiate compressor and start writing to file.
*/
@@ -1294,7 +1296,7 @@ static void* SaveFileToDisk(void *arg)
static byte *tmp = NULL;
uint32 hdr[2];
- OTTD_SendThreadMessage(MSG_OTTD_SAVETHREAD_START);
+ if (save_thread != NULL) OTTD_SendThreadMessage(MSG_OTTD_SAVETHREAD_START);
tmp = _sl.buf;
@@ -1341,13 +1343,10 @@ static void* SaveFileToDisk(void *arg)
GetSavegameFormat("memory")->uninit_write(); // clean the memorypool
fclose(_sl.fh);
- OTTD_SendThreadMessage(MSG_OTTD_SAVETHREAD_DONE);
+ if (save_thread != NULL) OTTD_SendThreadMessage(MSG_OTTD_SAVETHREAD_DONE);
return NULL;
}
-
-static Thread* save_thread;
-
void WaitTillSaved(void)
{
OTTDJoinThread(save_thread);
@@ -1413,7 +1412,7 @@ SaveOrLoadResult SaveOrLoad(const char *filename, int mode)
ShowInfoF("Load game failed: %s.", _sl.excpt_msg);
return SL_REINIT;
}
-
+
ShowInfoF("Save game failed: %s.", _sl.excpt_msg);
return SL_ERROR;
}