1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2025-12-14 17:02:26 +01:00

(svn r8222) [0.5] -Backport from trunk (lang, r8171, r8186, r8218):

- last missed chunk of danish language changes (lang)
 - (FS#556) return SL_ERROR when unthreaded saves failed (r8171)
 - (FS#557) apply railtype offset to station graphics if no custom station is in use (r8186)
 - Increase spritecache size to 2MB (r8218).
This commit is contained in:
Darkvater
2007-01-17 23:39:13 +00:00
parent 1a5957ef7f
commit c3fcb2ef2a
5 changed files with 25 additions and 11 deletions

View File

@@ -1429,7 +1429,7 @@ static OTTDThread* save_thread;
/** We have written the whole game into memory, _Savegame_pool, now find
* and appropiate compressor and start writing to file.
*/
static void* SaveFileToDisk(void *arg)
static SaveOrLoadResult SaveFileToDisk(bool threaded)
{
const SaveLoadFormat *fmt;
uint32 hdr[2];
@@ -1441,12 +1441,12 @@ static void* SaveFileToDisk(void *arg)
_sl.excpt_uninit();
fprintf(stderr, "Save game failed: %s.", _sl.excpt_msg);
if (arg != NULL) {
if (threaded) {
OTTD_SendThreadMessage(MSG_OTTD_SAVETHREAD_ERROR);
} else {
SaveFileError();
}
return NULL;
return SL_ERROR;
}
fmt = GetSavegameFormat(_savegame_format);
@@ -1479,7 +1479,14 @@ static void* SaveFileToDisk(void *arg)
GetSavegameFormat("memory")->uninit_write(); // clean the memorypool
fclose(_sl.fh);
if (arg != NULL) OTTD_SendThreadMessage(MSG_OTTD_SAVETHREAD_DONE);
if (threaded) OTTD_SendThreadMessage(MSG_OTTD_SAVETHREAD_DONE);
return SL_OK;
}
static void* SaveFileToDiskThread(void *arg)
{
SaveFileToDisk(true);
return NULL;
}
@@ -1567,11 +1574,14 @@ SaveOrLoadResult SaveOrLoad(const char *filename, int mode)
SlWriteFill(); // flush the save buffer
SaveFileStart();
if (_network_server ||
(save_thread = OTTDCreateThread(&SaveFileToDisk, (void*)"")) == NULL) {
DEBUG(misc, 1) ("[Sl] Cannot create savegame thread, reverting to single-threaded mode...");
SaveFileToDisk(NULL);
if (_network_server || (save_thread = OTTDCreateThread(&SaveFileToDiskThread, NULL)) == NULL) {
SaveOrLoadResult result;
if (!_network_server) DEBUG(misc, 1) ("Cannot create savegame thread, reverting to single-threaded mode...");
result = SaveFileToDisk(false);
SaveFileDone();
return result;
}
} else { /* LOAD game */