Index: src/saveload/saveload.cpp =================================================================== --- src/saveload/saveload.cpp (revision 27539) +++ src/saveload/saveload.cpp (working copy) @@ -409,6 +409,7 @@ byte ff_state; ///< The state of fast-forward when saving started. bool saveinprogress; ///< Whether there is currently a save in progress. + bool autosaveinprogress; ///< Whether there is currently an autosave in progress. }; static SaveLoadParams _sl; ///< Parameters used for/at saveload. @@ -2357,7 +2358,7 @@ /* After level 6 the speed reduction is significant (1.5x to 2.5x slower per level), but the reduction in filesize is * fairly insignificant (~1% for each step). Lower levels become ~5-10% bigger by each level than level 6 while level * 1 is "only" 3 times as fast. Level 0 results in uncompressed savegames at about 8 times the cost of "none". */ - {"zlib", TO_BE32X('OTTZ'), CreateLoadFilter, CreateSaveFilter, 0, 6, 9}, + {"zlib", TO_BE32X('OTTZ'), CreateLoadFilter, CreateSaveFilter, 2, 6, 9}, #else {"zlib", TO_BE32X('OTTZ'), NULL, NULL, 0, 0, 0}, #endif @@ -2382,7 +2383,9 @@ */ static const SaveLoadFormat *GetSavegameFormat(char *s, byte *compression_level) { - const SaveLoadFormat *def = lastof(_saveload_formats); + int sgf_id = 3; + if (_network_server && _sl.autosaveinprogress) sgf_id = 2; + const SaveLoadFormat *def = &_saveload_formats[sgf_id]; /* find default savegame format, the highest one with which files can be written */ while (!def->init_write) def--; @@ -2424,6 +2427,7 @@ if (complevel != NULL) *complevel = ':'; } *compression_level = def->default_compression; + if (_network_server && sgf_id == 2) *compression_level = def->min_compression; return def; } @@ -2463,6 +2467,7 @@ InvalidateWindowData(WC_STATUS_BAR, 0, SBI_SAVELOAD_START); _sl.saveinprogress = true; + if (_do_autosave) _sl.autosaveinprogress = true; } /** Update the gui accordingly when saving is done and release locks on saveload. */ @@ -2473,6 +2478,7 @@ InvalidateWindowData(WC_STATUS_BAR, 0, SBI_SAVELOAD_FINISH); _sl.saveinprogress = false; + _sl.autosaveinprogress = false; } /** Set the error message from outside of the actual loading/saving of the game (AfterLoadGame and friends) */ @@ -2603,6 +2609,8 @@ */ SaveOrLoadResult SaveWithFilter(SaveFilter *writer, bool threaded) { + if (_network_server && _sl.saveinprogress && threaded) WaitTillSaved(); + try { _sl.action = SLA_SAVE; return DoSave(writer, threaded); @@ -2829,7 +2837,7 @@ if (mode == SL_SAVE) { // SAVE game DEBUG(desync, 1, "save: %08x; %02x; %s", _date, _date_fract, filename); - if (_network_server || !_settings_client.gui.threaded_saves) threaded = false; + if (!_settings_client.gui.threaded_saves) threaded = false; return DoSave(new FileWriter(fh), threaded); }