Loading

Paste #p65qyonpa

  1. Index: src/saveload/saveload.cpp
  2. ===================================================================
  3. --- src/saveload/saveload.cpp   (revision 27539)
  4. +++ src/saveload/saveload.cpp   (working copy)
  5. @@ -409,6 +409,7 @@
  6.  
  7.     byte ff_state;                       ///< The state of fast-forward when saving started.
  8.     bool saveinprogress;                 ///< Whether there is currently a save in progress.
  9. +   bool autosaveinprogress;             ///< Whether there is currently an autosave in progress.
  10.  };
  11.  
  12.  static SaveLoadParams _sl; ///< Parameters used for/at saveload.
  13. @@ -2357,7 +2358,7 @@
  14.     /* After level 6 the speed reduction is significant (1.5x to 2.5x slower per level), but the reduction in filesize is
  15.      * fairly insignificant (~1% for each step). Lower levels become ~5-10% bigger by each level than level 6 while level
  16.      * 1 is "only" 3 times as fast. Level 0 results in uncompressed savegames at about 8 times the cost of "none". */
  17. -   {"zlib",   TO_BE32X('OTTZ'), CreateLoadFilter<ZlibLoadFilter>,   CreateSaveFilter<ZlibSaveFilter>,   0, 6, 9},
  18. +   {"zlib",   TO_BE32X('OTTZ'), CreateLoadFilter<ZlibLoadFilter>,   CreateSaveFilter<ZlibSaveFilter>,   2, 6, 9},
  19.  #else
  20.     {"zlib",   TO_BE32X('OTTZ'), NULL,                               NULL,                               0, 0, 0},
  21.  #endif
  22. @@ -2382,7 +2383,9 @@
  23.   */
  24.  static const SaveLoadFormat *GetSavegameFormat(char *s, byte *compression_level)
  25.  {
  26. -   const SaveLoadFormat *def = lastof(_saveload_formats);
  27. +   int sgf_id = 3;
  28. +   if (_network_server && _sl.autosaveinprogress) sgf_id = 2;
  29. +   const SaveLoadFormat *def = &_saveload_formats[sgf_id];
  30.  
  31.     /* find default savegame format, the highest one with which files can be written */
  32.     while (!def->init_write) def--;
  33. @@ -2424,6 +2427,7 @@
  34.         if (complevel != NULL) *complevel = ':';
  35.     }
  36.     *compression_level = def->default_compression;
  37. +   if (_network_server && sgf_id == 2) *compression_level = def->min_compression;
  38.     return def;
  39.  }
  40.  
  41. @@ -2463,6 +2467,7 @@
  42.  
  43.     InvalidateWindowData(WC_STATUS_BAR, 0, SBI_SAVELOAD_START);
  44.     _sl.saveinprogress = true;
  45. +   if (_do_autosave) _sl.autosaveinprogress = true;
  46.  }
  47.  
  48.  /** Update the gui accordingly when saving is done and release locks on saveload. */
  49. @@ -2473,6 +2478,7 @@
  50.  
  51.     InvalidateWindowData(WC_STATUS_BAR, 0, SBI_SAVELOAD_FINISH);
  52.     _sl.saveinprogress = false;
  53. +   _sl.autosaveinprogress = false;
  54.  }
  55.  
  56.  /** Set the error message from outside of the actual loading/saving of the game (AfterLoadGame and friends) */
  57. @@ -2603,6 +2609,8 @@
  58.   */
  59.  SaveOrLoadResult SaveWithFilter(SaveFilter *writer, bool threaded)
  60.  {
  61. +   if (_network_server && _sl.saveinprogress && threaded) WaitTillSaved();
  62. +
  63.     try {
  64.         _sl.action = SLA_SAVE;
  65.         return DoSave(writer, threaded);
  66. @@ -2829,7 +2837,7 @@
  67.  
  68.         if (mode == SL_SAVE) { // SAVE game
  69.             DEBUG(desync, 1, "save: %08x; %02x; %s", _date, _date_fract, filename);
  70. -           if (_network_server || !_settings_client.gui.threaded_saves) threaded = false;
  71. +           if (!_settings_client.gui.threaded_saves) threaded = false;
  72.  
  73.             return DoSave(new FileWriter(fh), threaded);
  74.         }

Comments