|
@@ -9,49 +9,49 @@
|
|
|
* <li>use their description array (SaveLoad) to know what elements to save and in what version
|
|
|
* of the game it was active (used when loading)
|
|
|
* <li>write all data byte-by-byte to the temporary buffer so it is endian-safe
|
|
|
* <li>when the buffer is full; flush it to the output (eg save to file) (_sl.buf, _sl.bufp, _sl.bufe)
|
|
|
* <li>repeat this until everything is done, and flush any remaining output to file
|
|
|
* </ol>
|
|
|
* @see ChunkHandler
|
|
|
* @see SaveLoad
|
|
|
*/
|
|
|
#include "stdafx.h"
|
|
|
#include "openttd.h"
|
|
|
#include "debug.h"
|
|
|
#include "functions.h"
|
|
|
#include "hal.h"
|
|
|
#include "vehicle.h"
|
|
|
#include "station.h"
|
|
|
#include "thread.h"
|
|
|
#include "town.h"
|
|
|
#include "player.h"
|
|
|
#include "saveload.h"
|
|
|
#include "network.h"
|
|
|
#include "variables.h"
|
|
|
#include <setjmp.h>
|
|
|
|
|
|
const uint16 SAVEGAME_VERSION = 33;
|
|
|
const uint16 SAVEGAME_VERSION = 34;
|
|
|
uint16 _sl_version; /// the major savegame version identifier
|
|
|
byte _sl_minor_version; /// the minor savegame version, DO NOT USE!
|
|
|
|
|
|
typedef void WriterProc(uint len);
|
|
|
typedef uint ReaderProc(void);
|
|
|
|
|
|
/** The saveload struct, containing reader-writer functions, bufffer, version, etc. */
|
|
|
static struct {
|
|
|
bool save; /// are we doing a save or a load atm. True when saving
|
|
|
byte need_length; /// ???
|
|
|
byte block_mode; /// ???
|
|
|
bool error; /// did an error occur or not
|
|
|
|
|
|
int 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
|
|
|
|
|
|
uint32 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
|
|
|
|
|
|
const ChunkHandler* const *chs; /// the chunk of data that is being processed atm (vehicles, signs, etc.)
|
|
|
const SaveLoad* const *includes; /// the internal layouf of the given chunk
|
|
|
|