saveload.c
changeset 817 238bbdaa228b
parent 781 4c9177888196
child 929 19096353d35c
equal deleted inserted replaced
816:cee64d137cc8 817:238bbdaa228b
     3 #include "vehicle.h"
     3 #include "vehicle.h"
     4 #include "station.h"
     4 #include "station.h"
     5 #include "town.h"
     5 #include "town.h"
     6 #include "player.h"
     6 #include "player.h"
     7 #include "saveload.h"
     7 #include "saveload.h"
     8 #include <setjmp.h>
       
     9 
     8 
    10 enum {
     9 enum {
    11 	SAVEGAME_MAJOR_VERSION = 4,
    10 	SAVEGAME_MAJOR_VERSION = 4,
    12 	SAVEGAME_MINOR_VERSION = 2,
    11 	SAVEGAME_MINOR_VERSION = 2,
    13 
    12 
    15 };
    14 };
    16 
    15 
    17 /******************************************************/
    16 /******************************************************/
    18 /******************************************************/
    17 /******************************************************/
    19 /******************************************************/
    18 /******************************************************/
    20 
       
    21 typedef void WriterProc(uint len);
       
    22 typedef uint ReaderProc();
       
    23 
       
    24 typedef uint ReferenceToIntProc(void *v, uint t);
       
    25 typedef void *IntToReferenceProc(uint r, uint t);
       
    26 
       
    27 typedef struct {
       
    28 	bool save;
       
    29 	byte need_length;
       
    30 	byte block_mode;
       
    31 	bool error;
       
    32 	byte version;
       
    33 
       
    34 	int obj_len;
       
    35 	int array_index, last_array_index;
       
    36 
       
    37 	uint32 offs_base;
       
    38 
       
    39 	WriterProc *write_bytes;
       
    40 	ReaderProc *read_bytes;
       
    41 
       
    42 	ReferenceToIntProc *ref_to_int_proc;
       
    43 	IntToReferenceProc *int_to_ref_proc;
       
    44 
       
    45 	const ChunkHandler * const * chs;
       
    46 	const byte * const *includes;
       
    47 
       
    48 	byte *bufp, *bufe;
       
    49 
       
    50 	int tmp;
       
    51 
       
    52 	// these 3 may be used by compressor/decompressors.
       
    53 	byte *buf; // pointer and size to read/write, initialized by init
       
    54 	uint bufsize;
       
    55 	FILE *fh;
       
    56 
       
    57 	void (*excpt_uninit)();
       
    58 	const char *excpt_msg;
       
    59 	jmp_buf excpt; // used to jump to "exception handler"
       
    60 } SaverLoader;
       
    61 
    19 
    62 enum NeedLengthValues { NL_NONE = 0,NL_WANTLENGTH = 1,NL_CALCLENGTH = 2};
    20 enum NeedLengthValues { NL_NONE = 0,NL_WANTLENGTH = 1,NL_CALCLENGTH = 2};
    63 
    21 
    64 SaverLoader _sl;
    22 SaverLoader _sl;
    65 
    23