Mercurial > hg > openttd
changeset 13037:308cd9bfb7a1 draft
(svn r17535) -Fix: compiling without networking failed; also unhackify the crash logger a bit.
author | rubidium <rubidium@openttd.org> |
---|---|
date | Mon, 14 Sep 2009 15:53:19 +0000 |
parents | 8e2a0e8fa275 |
children | 7b40620b49a4 |
files | src/crashlog.cpp src/saveload/saveload.cpp src/saveload/saveload.h |
diffstat | 3 files changed, 8 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/crashlog.cpp +++ b/src/crashlog.cpp @@ -16,7 +16,6 @@ #include "rev.h" #include "string_func.h" #include "strings_func.h" -#include "network/network.h" #include "blitter/factory.hpp" #include "base_media_base.h" #include "music/music_driver.hpp" @@ -218,9 +217,8 @@ seprintf(filename, filename_last, "%scrash.sav", _personal_dir); - /* Fake ourselves to be a network server so we don't get threaded saving */ - _network_server = true; - return SaveOrLoad(filename, SL_SAVE, NO_DIRECTORY) == SL_OK; + /* Don't do a threaded saveload. */ + return SaveOrLoad(filename, SL_SAVE, NO_DIRECTORY, false) == SL_OK; } catch (...) { return false; }
--- a/src/saveload/saveload.cpp +++ b/src/saveload/saveload.cpp @@ -1780,9 +1780,10 @@ * handled. It opens the savegame, selects format and checks versions * @param filename The name of the savegame being created/loaded * @param mode Save or load. Load can also be a TTD(Patch) game. Use SL_LOAD, SL_OLD_LOAD or SL_SAVE + * @param threaded True when threaded saving is allowed * @return Return the results of the action. SL_OK, SL_ERROR or SL_REINIT ("unload" the game) */ -SaveOrLoadResult SaveOrLoad(const char *filename, int mode, Subdirectory sb) +SaveOrLoadResult SaveOrLoad(const char *filename, int mode, Subdirectory sb, bool threaded) { uint32 hdr[2]; const SaveLoadFormat *fmt; @@ -1851,9 +1852,9 @@ SlWriteFill(); // flush the save buffer SaveFileStart(); - if (_network_server || - !ThreadObject::New(&SaveFileToDiskThread, NULL, &_save_thread)) { - if (!_network_server) DEBUG(sl, 1, "Cannot create savegame thread, reverting to single-threaded mode..."); + if (_network_server) threaded = false; + if (!threaded || !ThreadObject::New(&SaveFileToDiskThread, NULL, &_save_thread)) { + if (threaded) DEBUG(sl, 1, "Cannot create savegame thread, reverting to single-threaded mode..."); SaveOrLoadResult result = SaveFileToDisk(false); SaveFileDone();
--- a/src/saveload/saveload.h +++ b/src/saveload/saveload.h @@ -47,7 +47,7 @@ void GenerateDefaultSaveName(char *buf, const char *last); void SetSaveLoadError(uint16 str); const char *GetSaveLoadErrorString(); -SaveOrLoadResult SaveOrLoad(const char *filename, int mode, Subdirectory sb); +SaveOrLoadResult SaveOrLoad(const char *filename, int mode, Subdirectory sb, bool threaded = true); void WaitTillSaved(); void DoExitSave();