File diff r15761:680dbdd50e09 → r15762:7fbf9fe78040
src/saveload/saveload.cpp
Show inline comments
 
@@ -164,98 +164,99 @@
 
 *   98   13375
 
 *   99   13838
 
 *  100   13952
 
 *  101   14233
 
 *  102   14332
 
 *  103   14598
 
 *  104   14735
 
 *  105   14803
 
 *  106   14919
 
 *  107   15027
 
 *  108   15045
 
 *  109   15075
 
 *  110   15148
 
 *  111   15190
 
 *  112   15290
 
 *  113   15340
 
 *  114   15601
 
 *  115   15695
 
 *  116   15893   0.7.x
 
 *  117   16037
 
 *  118   16129
 
 *  119   16242
 
 *  120   16439
 
 *  121   16694
 
 *  122   16855
 
 *  123   16909
 
 *  124   16993
 
 *  125   17113
 
 *  126   17433
 
 *  127   17439
 
 *  128   18281
 
 *  129   18292
 
 *  130   18404
 
 *  131   18481
 
 *  132   18522
 
 *  133   18674
 
 *  134   18703
 
 *  135   18719
 
 *  136   18764
 
 *  137   18912
 
 *  138   18942   1.0.x
 
 *  139   19346
 
 *  140   19382
 
 *  141   19799
 
 *  142   20003
 
 *  143   20048
 
 *  144   20334
 
 *  145   20376
 
 *  146   20446
 
 */
 
extern const uint16 SAVEGAME_VERSION = 145; ///< current savegame version of OpenTTD
 
extern const uint16 SAVEGAME_VERSION = 146; ///< current savegame version of OpenTTD
 

	
 
SavegameType _savegame_type; ///< type of savegame we are loading
 

	
 
uint32 _ttdp_version;     ///< version of TTDP savegame (if applicable)
 
uint16 _sl_version;       ///< the major savegame version identifier
 
byte   _sl_minor_version; ///< the minor savegame version, DO NOT USE!
 
char _savegame_format[8]; ///< how to compress savegames
 
bool _do_autosave;        ///< are we doing an autosave at the moment?
 

	
 
typedef void WriterProc(size_t len);
 
typedef size_t ReaderProc();
 

	
 
/** What are we currently doing? */
 
enum SaveLoadAction {
 
	SLA_LOAD,        ///< loading
 
	SLA_SAVE,        ///< saving
 
	SLA_PTRS,        ///< fixing pointers
 
	SLA_NULL,        ///< null all pointers (on loading error)
 
	SLA_LOAD_CHECK,  ///< partial loading into #_load_check_data
 
};
 

	
 
enum NeedLength {
 
	NL_NONE = 0,       ///< not working in NeedLength mode
 
	NL_WANTLENGTH = 1, ///< writing length and data
 
	NL_CALCLENGTH = 2, ///< need to calculate the length
 
};
 

	
 
/** The saveload struct, containing reader-writer functions, bufffer, version, etc. */
 
struct SaveLoadParams {
 
	SaveLoadAction action;               ///< are we doing a save or a load atm.
 
	NeedLength need_length;              ///< working in NeedLength (Autolength) mode?
 
	byte block_mode;                     ///< ???
 
	bool error;                          ///< did an error occur or not
 

	
 
	size_t obj_len;                      ///< the length of the current object we are busy with
 
	int array_index, last_array_index;   ///< in the case of an array, the current and last positions
 

	
 
	size_t offs_base;                    ///< the offset in number of bytes since we started writing data (eg uncompressed savegame size)
 

	
 
	WriterProc *write_bytes;             ///< savegame writer function
 
	ReaderProc *read_bytes;              ///< savegame loader function
 

	
 
	/* When saving/loading savegames, they are always saved to a temporary memory-place
 
	 * to be flushed to file (save) or to final place (load) when full. */
 
	byte *bufp, *bufe;                   ///< bufp(ointer) gives the current position in the buffer bufe(nd) gives the end of the buffer
 

	
 
	/* these 3 may be used by compressor/decompressors. */
 
	byte *buf;                           ///< pointer to temporary memory to read/write, initialized by SaveLoadFormat->initread/write