--- a/saveload.c Thu Sep 01 21:19:48 2005 +0000
+++ b/saveload.c Fri Sep 02 16:05:59 2005 +0000
@@ -1255,7 +1255,7 @@
/** Update the gui accordingly when starting saving
* and set locks on saveload. Also turn off fast-forward cause with that
* saving takes Aaaaages */
-static inline void SaveFileStart(void)
+void SaveFileStart(void)
{
_ts.ff_state = _fast_forward;
_fast_forward = false;
@@ -1267,7 +1267,7 @@
/** Update the gui accordingly when saving is done and release locks
* on saveload */
-static inline void SaveFileDone(void)
+void SaveFileDone(void)
{
_fast_forward = _ts.ff_state;
if (_cursor.sprite == SPR_CURSOR_ZZZ) SetMouseCursor(SPR_CURSOR_MOUSE);
@@ -1276,10 +1276,17 @@
_ts.saveinprogress = false;
}
+/** Show a gui message when saving has failed */
+void SaveFileError(void)
+{
+ ShowErrorMessage(STR_4007_GAME_SAVE_FAILED, STR_NULL, 0, 0);
+ SaveFileDone();
+}
+
/** We have written the whole game into memory, _save_pool, now find
* and appropiate compressor and start writing to file.
*/
-static void* SaveFileToDisk(void* arg)
+static void* SaveFileToDisk(void *arg)
{
const SaveLoadFormat *fmt = GetSavegameFormat(_savegame_format);
/* XXX - backup _sl.buf cause it is used internally by the writer
@@ -1287,6 +1294,8 @@
static byte *tmp = NULL;
uint32 hdr[2];
+ OTTD_SendThreadMessage(MSG_OTTD_SAVETHREAD_START);
+
tmp = _sl.buf;
/* XXX - Setup setjmp error handler if an error occurs anywhere deep during
@@ -1297,9 +1306,7 @@
_sl.excpt_uninit();
ShowInfoF("Save game failed: %s.", _sl.excpt_msg);
- ShowErrorMessage(STR_4007_GAME_SAVE_FAILED, STR_NULL, 0, 0);
-
- SaveFileDone();
+ OTTD_SendThreadMessage(MSG_OTTD_SAVETHREAD_ERROR);
return NULL;
}
@@ -1334,7 +1341,7 @@
GetSavegameFormat("memory")->uninit_write(); // clean the memorypool
fclose(_sl.fh);
- SaveFileDone();
+ OTTD_SendThreadMessage(MSG_OTTD_SAVETHREAD_DONE);
return NULL;
}
@@ -1405,10 +1412,10 @@
if (mode == SL_LOAD) {
ShowInfoF("Load game failed: %s.", _sl.excpt_msg);
return SL_REINIT;
- } else {
- ShowInfoF("Save game failed: %s.", _sl.excpt_msg);
- return SL_ERROR;
}
+
+ ShowInfoF("Save game failed: %s.", _sl.excpt_msg);
+ return SL_ERROR;
}
/* We first initialize here to avoid: "warning: variable `version' might
@@ -1434,7 +1441,6 @@
SlWriteFill(); // flush the save buffer
/* Write to file */
- SaveFileStart();
if (_network_server ||
(save_thread = OTTDCreateThread(&SaveFileToDisk, NULL)) == NULL) {
DEBUG(misc, 1) ("cannot create savegame thread, reverting to single-threaded mode...");