1
0
Fork 0

(svn r2587) - Fix: Don't close the save-thread if it wasn't started because of some error or a network-server

release/0.4.5
Darkvater 2005-07-16 09:55:31 +00:00
parent 85ef06a0b5
commit 19cb5e054a
1 changed files with 5 additions and 3 deletions

View File

@ -1280,7 +1280,7 @@ static bool SaveFileToDisk(void *ptr)
fclose(_sl.fh); fclose(_sl.fh);
SaveFileDone(); SaveFileDone();
CloseOTTDThread(); if (*(bool*)ptr) CloseOTTDThread();
return true; 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 /* 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 */ * to write it to file, either in threaded mode if possible, or single-threaded */
if (mode == SL_SAVE) { /* SAVE game */ if (mode == SL_SAVE) { /* SAVE game */
bool threaded = true;
fmt = GetSavegameFormat("memory"); // write to memory fmt = GetSavegameFormat("memory"); // write to memory
_sl.write_bytes = fmt->writer; _sl.write_bytes = fmt->writer;
@ -1368,9 +1369,10 @@ int SaveOrLoad(const char *filename, int mode)
SlWriteFill(); // flush the save buffer SlWriteFill(); // flush the save buffer
/* Write to file */ /* 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..."); DEBUG(misc, 1) ("cannot create savegame thread, reverting to single-threaded mode...");
SaveFileToDisk(NULL); threaded = false;
SaveFileToDisk(&threaded);
} }
} else { /* LOAD game */ } else { /* LOAD game */