saveload.h
author celestar
Tue, 02 Jan 2007 09:54:03 +0000
branchcustombridgeheads
changeset 5632 025c3b25f1fd
parent 5142 d423c895a5b4
permissions -rw-r--r--
(svn r7739) [cbh] - Feature: Allow the construction and removal of signals on bridge heads. Warning: the signals are only displayed, they do not work yet
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2162
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2162
diff changeset
     2
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     3
#ifndef SAVELOAD_H
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     4
#define SAVELOAD_H
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
2162
c1ded3bd3d0c (svn r2672) Move saving/loading related declarations to saveload.h
tron
parents: 1887
diff changeset
     6
typedef enum SaveOrLoadResult {
3044
631d21c289e2 (svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents: 2848
diff changeset
     7
	SL_OK     = 0, // completed successfully
631d21c289e2 (svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents: 2848
diff changeset
     8
	SL_ERROR  = 1, // error that was caught before internal structures were modified
2162
c1ded3bd3d0c (svn r2672) Move saving/loading related declarations to saveload.h
tron
parents: 1887
diff changeset
     9
	SL_REINIT = 2, // error that was caught in the middle of updating game state, need to clear it. (can only happen during load)
c1ded3bd3d0c (svn r2672) Move saving/loading related declarations to saveload.h
tron
parents: 1887
diff changeset
    10
} SaveOrLoadResult;
c1ded3bd3d0c (svn r2672) Move saving/loading related declarations to saveload.h
tron
parents: 1887
diff changeset
    11
c1ded3bd3d0c (svn r2672) Move saving/loading related declarations to saveload.h
tron
parents: 1887
diff changeset
    12
typedef enum SaveOrLoadMode {
3044
631d21c289e2 (svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents: 2848
diff changeset
    13
	SL_INVALID  = -1,
631d21c289e2 (svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents: 2848
diff changeset
    14
	SL_LOAD     =  0,
631d21c289e2 (svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents: 2848
diff changeset
    15
	SL_SAVE     =  1,
631d21c289e2 (svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents: 2848
diff changeset
    16
	SL_OLD_LOAD =  2,
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4257
diff changeset
    17
	SL_PNG      =  3,
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4257
diff changeset
    18
	SL_BMP      =  4,
2162
c1ded3bd3d0c (svn r2672) Move saving/loading related declarations to saveload.h
tron
parents: 1887
diff changeset
    19
} SaveOrLoadMode;
c1ded3bd3d0c (svn r2672) Move saving/loading related declarations to saveload.h
tron
parents: 1887
diff changeset
    20
c1ded3bd3d0c (svn r2672) Move saving/loading related declarations to saveload.h
tron
parents: 1887
diff changeset
    21
SaveOrLoadResult SaveOrLoad(const char *filename, int mode);
2285
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents: 2186
diff changeset
    22
void WaitTillSaved(void);
4548
23b56455df33 (svn r6380) -Codechange: unify all ways to quit OTTD.
rubidium
parents: 4344
diff changeset
    23
void DoExitSave(void);
2162
c1ded3bd3d0c (svn r2672) Move saving/loading related declarations to saveload.h
tron
parents: 1887
diff changeset
    24
c1ded3bd3d0c (svn r2672) Move saving/loading related declarations to saveload.h
tron
parents: 1887
diff changeset
    25
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1024
diff changeset
    26
typedef void ChunkSaveLoadProc(void);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    27
typedef void AutolengthProc(void *arg);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    28
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    29
typedef struct {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    30
	uint32 id;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    31
	ChunkSaveLoadProc *save_proc;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    32
	ChunkSaveLoadProc *load_proc;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    33
	uint32 flags;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    34
} ChunkHandler;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    35
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    36
typedef struct {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    37
	byte null;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    38
} NullStruct;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    39
1881
023a134a4b12 (svn r2387) - CodeChange: made the saveload code more readable and also removed the 'byte' saveload arrays which means you can save an array of more than 255 elements, or bigger structs than 255 bytes. This doesn't yet solve the problem that a chunk can be a maximum of 16384 big.
Darkvater
parents: 1217
diff changeset
    40
typedef enum SLRefType {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
    41
	REF_ORDER         = 0,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
    42
	REF_VEHICLE       = 1,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
    43
	REF_STATION       = 2,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
    44
	REF_TOWN          = 3,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
    45
	REF_VEHICLE_OLD   = 4,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
    46
	REF_ROADSTOPS     = 5,
2848
cb4b1cc0bf65 (svn r3396) - Autoreplace changes:
peter1138
parents: 2685
diff changeset
    47
	REF_ENGINE_RENEWS = 6,
1881
023a134a4b12 (svn r2387) - CodeChange: made the saveload code more readable and also removed the 'byte' saveload arrays which means you can save an array of more than 255 elements, or bigger structs than 255 bytes. This doesn't yet solve the problem that a chunk can be a maximum of 16384 big.
Darkvater
parents: 1217
diff changeset
    48
} SLRefType;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    49
3044
631d21c289e2 (svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents: 2848
diff changeset
    50
#define SL_MAX_VERSION 255
1881
023a134a4b12 (svn r2387) - CodeChange: made the saveload code more readable and also removed the 'byte' saveload arrays which means you can save an array of more than 255 elements, or bigger structs than 255 bytes. This doesn't yet solve the problem that a chunk can be a maximum of 16384 big.
Darkvater
parents: 1217
diff changeset
    51
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    52
enum {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    53
	INC_VEHICLE_COMMON = 0,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    54
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    55
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    56
enum {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
    57
	CH_RIFF         =  0,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
    58
	CH_ARRAY        =  1,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
    59
	CH_SPARSE_ARRAY =  2,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
    60
	CH_TYPE_MASK    =  3,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
    61
	CH_LAST         =  8,
3044
631d21c289e2 (svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents: 2848
diff changeset
    62
	CH_AUTO_LENGTH  = 16,
631d21c289e2 (svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents: 2848
diff changeset
    63
631d21c289e2 (svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents: 2848
diff changeset
    64
	CH_PRI_0          = 0 << 4,
631d21c289e2 (svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents: 2848
diff changeset
    65
	CH_PRI_1          = 1 << 4,
631d21c289e2 (svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents: 2848
diff changeset
    66
	CH_PRI_2          = 2 << 4,
631d21c289e2 (svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents: 2848
diff changeset
    67
	CH_PRI_3          = 3 << 4,
631d21c289e2 (svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents: 2848
diff changeset
    68
	CH_PRI_SHL        = 4,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    69
	CH_NUM_PRI_LEVELS = 4,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    70
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    71
3114
b5576f77693d (svn r3718) - Add proper Doxygen comments to some saveload-structs (using ///<)
Darkvater
parents: 3108
diff changeset
    72
/** VarTypes is the general bitmasked magic type that tells us
b5576f77693d (svn r3718) - Add proper Doxygen comments to some saveload-structs (using ///<)
Darkvater
parents: 3108
diff changeset
    73
 * certain characteristics about the variable it refers to. For example
b5576f77693d (svn r3718) - Add proper Doxygen comments to some saveload-structs (using ///<)
Darkvater
parents: 3108
diff changeset
    74
 * SLE_FILE_* gives the size(type) as it would be in the savegame and
b5576f77693d (svn r3718) - Add proper Doxygen comments to some saveload-structs (using ///<)
Darkvater
parents: 3108
diff changeset
    75
 * SLE_VAR_* the size(type) as it is in memory during runtime. These are
b5576f77693d (svn r3718) - Add proper Doxygen comments to some saveload-structs (using ///<)
Darkvater
parents: 3108
diff changeset
    76
 * the first 8 bytes (0-3 SLE_FILE, 4-7 SLE_VAR).
b5576f77693d (svn r3718) - Add proper Doxygen comments to some saveload-structs (using ///<)
Darkvater
parents: 3108
diff changeset
    77
 * Bytes 8-15 are reserved for various flags as explained below */
3046
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
    78
enum VarTypes {
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
    79
	/* 4 bytes allocated a maximum of 16 types for NumberType */
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
    80
	SLE_FILE_I8       = 0,
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
    81
	SLE_FILE_U8       = 1,
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
    82
	SLE_FILE_I16      = 2,
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
    83
	SLE_FILE_U16      = 3,
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
    84
	SLE_FILE_I32      = 4,
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
    85
	SLE_FILE_U32      = 5,
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
    86
	SLE_FILE_I64      = 6,
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
    87
	SLE_FILE_U64      = 7,
3114
b5576f77693d (svn r3718) - Add proper Doxygen comments to some saveload-structs (using ///<)
Darkvater
parents: 3108
diff changeset
    88
	SLE_FILE_STRINGID = 8, ///< StringID offset into strings-array
3048
9dd3128a6358 (svn r3628) - Add BOOL and STRING types to saveload capabilities. String is unused up till now and it saves the full-buffer, regardless of how many characters the string actually has. So give a warning for that and figure it out later.
Darkvater
parents: 3046
diff changeset
    89
	SLE_FILE_STRING   = 9,
3114
b5576f77693d (svn r3718) - Add proper Doxygen comments to some saveload-structs (using ///<)
Darkvater
parents: 3108
diff changeset
    90
	/* 6 more possible file-primitives */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    91
3046
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
    92
	/* 4 bytes allocated a maximum of 16 types for NumberType */
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
    93
	SLE_VAR_BL    =  0 << 4,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
    94
	SLE_VAR_I8    =  1 << 4,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
    95
	SLE_VAR_U8    =  2 << 4,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
    96
	SLE_VAR_I16   =  3 << 4,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
    97
	SLE_VAR_U16   =  4 << 4,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
    98
	SLE_VAR_I32   =  5 << 4,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
    99
	SLE_VAR_U32   =  6 << 4,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   100
	SLE_VAR_I64   =  7 << 4,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   101
	SLE_VAR_U64   =  8 << 4,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   102
	SLE_VAR_NULL  =  9 << 4, ///< useful to write zeros in savegame.
5140
3d58647a202a (svn r7228) -Codechange: [internal] Add the possibility to save/load string-pointers which do not
Darkvater
parents: 4548
diff changeset
   103
	SLE_VAR_STRB  = 10 << 4, ///< string (with pre-allocated buffer)
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   104
	SLE_VAR_STRBQ = 11 << 4, ///< string enclosed in quotes (with pre-allocated buffer)
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   105
	SLE_VAR_STR   = 12 << 4, ///< string pointer
5140
3d58647a202a (svn r7228) -Codechange: [internal] Add the possibility to save/load string-pointers which do not
Darkvater
parents: 4548
diff changeset
   106
	SLE_VAR_STRQ  = 13 << 4, ///< string pointer enclosed in quotes
4255
5cb4bcf7c83f (svn r5871) -Feature: Add a possibility to handle pointer strings without a buffer from the configuration file. Handy for variables that will never be changed during runtime
Darkvater
parents: 3625
diff changeset
   107
	/* 2 more possible memory-primitives */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   108
3046
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
   109
	/* Shortcut values */
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
   110
	SLE_VAR_CHAR = SLE_VAR_I8,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   111
3046
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
   112
	/* Default combinations of variables. As savegames change, so can variables
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
   113
	 * and thus it is possible that the saved value and internal size do not
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
   114
	 * match and you need to specify custom combo. The defaults are listed here */
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   115
	SLE_BOOL         = SLE_FILE_I8  | SLE_VAR_BL,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   116
	SLE_INT8         = SLE_FILE_I8  | SLE_VAR_I8,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   117
	SLE_UINT8        = SLE_FILE_U8  | SLE_VAR_U8,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   118
	SLE_INT16        = SLE_FILE_I16 | SLE_VAR_I16,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   119
	SLE_UINT16       = SLE_FILE_U16 | SLE_VAR_U16,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   120
	SLE_INT32        = SLE_FILE_I32 | SLE_VAR_I32,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   121
	SLE_UINT32       = SLE_FILE_U32 | SLE_VAR_U32,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   122
	SLE_INT64        = SLE_FILE_I64 | SLE_VAR_I64,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   123
	SLE_UINT64       = SLE_FILE_U64 | SLE_VAR_U64,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   124
	SLE_CHAR         = SLE_FILE_I8  | SLE_VAR_CHAR,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   125
	SLE_STRINGID     = SLE_FILE_STRINGID | SLE_VAR_U16,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   126
	SLE_STRINGBUF    = SLE_FILE_STRING   | SLE_VAR_STRB,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   127
	SLE_STRINGBQUOTE = SLE_FILE_STRING   | SLE_VAR_STRBQ,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   128
	SLE_STRING       = SLE_FILE_STRING   | SLE_VAR_STR,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   129
	SLE_STRINGQUOTE  = SLE_FILE_STRING   | SLE_VAR_STRQ,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   130
3046
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
   131
	/* Shortcut values */
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   132
	SLE_UINT  = SLE_UINT32,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   133
	SLE_INT   = SLE_INT32,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   134
	SLE_STRB  = SLE_STRINGBUF,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   135
	SLE_STRBQ = SLE_STRINGBQUOTE,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   136
	SLE_STR   = SLE_STRING,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   137
	SLE_STRQ  = SLE_STRINGQUOTE,
3115
1f4949f5dc5d (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3114
diff changeset
   138
1f4949f5dc5d (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3114
diff changeset
   139
	/* 8 bytes allocated for a maximum of 8 flags
1f4949f5dc5d (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3114
diff changeset
   140
	 * Flags directing saving/loading of a variable */
1f4949f5dc5d (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3114
diff changeset
   141
	SLF_SAVE_NO      = 1 <<  8, ///< do not save with savegame, basically player-based
1f4949f5dc5d (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3114
diff changeset
   142
	SLF_CONFIG_NO    = 1 <<  9, ///< do not save to config file
1f4949f5dc5d (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3114
diff changeset
   143
	SLF_NETWORK_NO   = 1 << 10, ///< do not synchronize over network (but it is saved if SSF_SAVE_NO is not set)
1f4949f5dc5d (svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents: 3114
diff changeset
   144
	/* 5 more possible flags */
3046
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
   145
};
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
   146
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
   147
typedef uint32 VarType;
1881
023a134a4b12 (svn r2387) - CodeChange: made the saveload code more readable and also removed the 'byte' saveload arrays which means you can save an array of more than 255 elements, or bigger structs than 255 bytes. This doesn't yet solve the problem that a chunk can be a maximum of 16384 big.
Darkvater
parents: 1217
diff changeset
   148
023a134a4b12 (svn r2387) - CodeChange: made the saveload code more readable and also removed the 'byte' saveload arrays which means you can save an array of more than 255 elements, or bigger structs than 255 bytes. This doesn't yet solve the problem that a chunk can be a maximum of 16384 big.
Darkvater
parents: 1217
diff changeset
   149
enum SaveLoadTypes {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   150
	SL_VAR       =  0,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   151
	SL_REF       =  1,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   152
	SL_ARR       =  2,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   153
	SL_STR       =  3,
1881
023a134a4b12 (svn r2387) - CodeChange: made the saveload code more readable and also removed the 'byte' saveload arrays which means you can save an array of more than 255 elements, or bigger structs than 255 bytes. This doesn't yet solve the problem that a chunk can be a maximum of 16384 big.
Darkvater
parents: 1217
diff changeset
   154
	// non-normal save-load types
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   155
	SL_WRITEBYTE =  8,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   156
	SL_INCLUDE   =  9,
1881
023a134a4b12 (svn r2387) - CodeChange: made the saveload code more readable and also removed the 'byte' saveload arrays which means you can save an array of more than 255 elements, or bigger structs than 255 bytes. This doesn't yet solve the problem that a chunk can be a maximum of 16384 big.
Darkvater
parents: 1217
diff changeset
   157
	SL_END       = 15
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   158
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   159
3046
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
   160
typedef byte SaveLoadType;
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
   161
1881
023a134a4b12 (svn r2387) - CodeChange: made the saveload code more readable and also removed the 'byte' saveload arrays which means you can save an array of more than 255 elements, or bigger structs than 255 bytes. This doesn't yet solve the problem that a chunk can be a maximum of 16384 big.
Darkvater
parents: 1217
diff changeset
   162
/** SaveLoad type struct. Do NOT use this directly but use the SLE_ macros defined just below! */
2295
af67e1ea8687 (svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents: 2285
diff changeset
   163
typedef struct SaveLoad {
3114
b5576f77693d (svn r3718) - Add proper Doxygen comments to some saveload-structs (using ///<)
Darkvater
parents: 3108
diff changeset
   164
	SaveLoadType cmd;    ///< the action to take with the saved/loaded type, All types need different action
b5576f77693d (svn r3718) - Add proper Doxygen comments to some saveload-structs (using ///<)
Darkvater
parents: 3108
diff changeset
   165
	VarType conv;        ///< type of the variable to be saved, int
b5576f77693d (svn r3718) - Add proper Doxygen comments to some saveload-structs (using ///<)
Darkvater
parents: 3108
diff changeset
   166
	uint16 length;       ///< (conditional) length of the variable (eg. arrays) (max array size is 65536 elements)
b5576f77693d (svn r3718) - Add proper Doxygen comments to some saveload-structs (using ///<)
Darkvater
parents: 3108
diff changeset
   167
	uint16 version_from; ///< save/load the variable starting from this savegame version
b5576f77693d (svn r3718) - Add proper Doxygen comments to some saveload-structs (using ///<)
Darkvater
parents: 3108
diff changeset
   168
	uint16 version_to;   ///< save/load the variable until this savegame version
3046
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
   169
	/* NOTE: This element either denotes the address of the variable for a global
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
   170
	 * variable, or the offset within a struct which is then bound to a variable
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
   171
	 * during runtime. Decision on which one to use is controlled by the function
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
   172
	 * that is called to save it. address: SlGlobList, offset: SlObject */
3114
b5576f77693d (svn r3718) - Add proper Doxygen comments to some saveload-structs (using ///<)
Darkvater
parents: 3108
diff changeset
   173
	void *address;       ///< address of variable OR offset of variable in the struct (max offset is 65536)
2295
af67e1ea8687 (svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents: 2285
diff changeset
   174
} SaveLoad;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   175
3046
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
   176
/* Same as SaveLoad but global variables are used (for better readability); */
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
   177
typedef SaveLoad SaveLoadGlobVarList;
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
   178
1881
023a134a4b12 (svn r2387) - CodeChange: made the saveload code more readable and also removed the 'byte' saveload arrays which means you can save an array of more than 255 elements, or bigger structs than 255 bytes. This doesn't yet solve the problem that a chunk can be a maximum of 16384 big.
Darkvater
parents: 1217
diff changeset
   179
/* Simple variables, references (pointers) and arrays */
3073
eb443625edae (svn r3662) Fix regression FS#58 with union, endiannes and static decleration problems. Removed the union.
Darkvater
parents: 3072
diff changeset
   180
#define SLE_GENERAL(cmd, base, variable, type, length, from, to) {cmd, type, length, from, to, (void*)offsetof(base, variable)}
3044
631d21c289e2 (svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents: 2848
diff changeset
   181
#define SLE_CONDVAR(base, variable, type, from, to) SLE_GENERAL(SL_VAR, base, variable, type, 0, from, to)
631d21c289e2 (svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents: 2848
diff changeset
   182
#define SLE_CONDREF(base, variable, type, from, to) SLE_GENERAL(SL_REF, base, variable, type, 0, from, to)
631d21c289e2 (svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents: 2848
diff changeset
   183
#define SLE_CONDARR(base, variable, type, length, from, to) SLE_GENERAL(SL_ARR, base, variable, type, length, from, to)
631d21c289e2 (svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents: 2848
diff changeset
   184
#define SLE_CONDSTR(base, variable, type, length, from, to) SLE_GENERAL(SL_STR, base, variable, type, length, from, to)
631d21c289e2 (svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents: 2848
diff changeset
   185
631d21c289e2 (svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents: 2848
diff changeset
   186
#define SLE_VAR(base, variable, type) SLE_CONDVAR(base, variable, type, 0, SL_MAX_VERSION)
631d21c289e2 (svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents: 2848
diff changeset
   187
#define SLE_REF(base, variable, type) SLE_CONDREF(base, variable, type, 0, SL_MAX_VERSION)
631d21c289e2 (svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents: 2848
diff changeset
   188
#define SLE_ARR(base, variable, type, length) SLE_CONDARR(base, variable, type, length, 0, SL_MAX_VERSION)
631d21c289e2 (svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents: 2848
diff changeset
   189
#define SLE_STR(base, variable, type, length) SLE_CONDSTR(base, variable, type, length, 0, SL_MAX_VERSION)
631d21c289e2 (svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents: 2848
diff changeset
   190
3240
ad3a18a3a319 (svn r3914) - Properly implement SDT(G)_CONDNULL macro's without special cases (add flag SLF_CONFIG_NO and empty string as name)
Darkvater
parents: 3222
diff changeset
   191
#define SLE_CONDNULL(length, from, to) SLE_CONDARR(NullStruct, null, SLE_FILE_U8 | SLE_VAR_NULL | SLF_CONFIG_NO, length, from, to)
3222
8bfed4267cba (svn r3895) - Add proper SLE(G)_CONDNULL macros for the empty space reservation in savegames and update where used
Darkvater
parents: 3117
diff changeset
   192
1881
023a134a4b12 (svn r2387) - CodeChange: made the saveload code more readable and also removed the 'byte' saveload arrays which means you can save an array of more than 255 elements, or bigger structs than 255 bytes. This doesn't yet solve the problem that a chunk can be a maximum of 16384 big.
Darkvater
parents: 1217
diff changeset
   193
/* Translate values ingame to different values in the savegame and vv */
3044
631d21c289e2 (svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents: 2848
diff changeset
   194
#define SLE_WRITEBYTE(base, variable, game_value, file_value) SLE_GENERAL(SL_WRITEBYTE, base, variable, 0, 0, game_value, file_value)
1881
023a134a4b12 (svn r2387) - CodeChange: made the saveload code more readable and also removed the 'byte' saveload arrays which means you can save an array of more than 255 elements, or bigger structs than 255 bytes. This doesn't yet solve the problem that a chunk can be a maximum of 16384 big.
Darkvater
parents: 1217
diff changeset
   195
/* Load common code and put it into each struct (currently only for vehicles */
3044
631d21c289e2 (svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents: 2848
diff changeset
   196
#define SLE_INCLUDE(base, variable, include_index) SLE_GENERAL(SL_INCLUDE, base, variable, 0, 0, include_index, 0)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   197
1881
023a134a4b12 (svn r2387) - CodeChange: made the saveload code more readable and also removed the 'byte' saveload arrays which means you can save an array of more than 255 elements, or bigger structs than 255 bytes. This doesn't yet solve the problem that a chunk can be a maximum of 16384 big.
Darkvater
parents: 1217
diff changeset
   198
/* The same as the ones at the top, only the offset is given directly; used for unions */
3073
eb443625edae (svn r3662) Fix regression FS#58 with union, endiannes and static decleration problems. Removed the union.
Darkvater
parents: 3072
diff changeset
   199
#define SLE_GENERALX(cmd, offset, type, param1, param2) {cmd, type, 0, param1, param2, (void*)(offset)}
3044
631d21c289e2 (svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents: 2848
diff changeset
   200
#define SLE_CONDVARX(offset, type, from, to) SLE_GENERALX(SL_VAR, offset, type, from, to)
631d21c289e2 (svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents: 2848
diff changeset
   201
#define SLE_CONDREFX(offset, type, from, to) SLE_GENERALX(SL_REF, offset, type, from, to)
631d21c289e2 (svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents: 2848
diff changeset
   202
631d21c289e2 (svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents: 2848
diff changeset
   203
#define SLE_VARX(offset, type) SLE_CONDVARX(offset, type, 0, SL_MAX_VERSION)
631d21c289e2 (svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents: 2848
diff changeset
   204
#define SLE_REFX(offset, type) SLE_CONDREFX(offset, type, 0, SL_MAX_VERSION)
631d21c289e2 (svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents: 2848
diff changeset
   205
631d21c289e2 (svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents: 2848
diff changeset
   206
#define SLE_WRITEBYTEX(offset, something) SLE_GENERALX(SL_WRITEBYTE, offset, 0, something, 0)
631d21c289e2 (svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents: 2848
diff changeset
   207
#define SLE_INCLUDEX(offset, type) SLE_GENERALX(SL_INCLUDE, offset, type, 0, SL_MAX_VERSION)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   208
1881
023a134a4b12 (svn r2387) - CodeChange: made the saveload code more readable and also removed the 'byte' saveload arrays which means you can save an array of more than 255 elements, or bigger structs than 255 bytes. This doesn't yet solve the problem that a chunk can be a maximum of 16384 big.
Darkvater
parents: 1217
diff changeset
   209
/* End marker */
3073
eb443625edae (svn r3662) Fix regression FS#58 with union, endiannes and static decleration problems. Removed the union.
Darkvater
parents: 3072
diff changeset
   210
#define SLE_END() {SL_END, 0, 0, 0, 0, NULL}
3046
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
   211
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
   212
/* Simple variables, references (pointers) and arrays, but for global variables */
3073
eb443625edae (svn r3662) Fix regression FS#58 with union, endiannes and static decleration problems. Removed the union.
Darkvater
parents: 3072
diff changeset
   213
#define SLEG_GENERAL(cmd, variable, type, length, from, to) {cmd, type, length, from, to, (void*)&variable}
3046
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
   214
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
   215
#define SLEG_CONDVAR(variable, type, from, to) SLEG_GENERAL(SL_VAR, variable, type, 0, from, to)
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
   216
#define SLEG_CONDREF(variable, type, from, to) SLEG_GENERAL(SL_REF, variable, type, 0, from, to)
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
   217
#define SLEG_CONDARR(variable, type, length, from, to) SLEG_GENERAL(SL_ARR, variable, type, length, from, to)
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
   218
#define SLEG_CONDSTR(variable, type, length, from, to) SLEG_GENERAL(SL_STR, variable, type, length, from, to)
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
   219
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
   220
#define SLEG_VAR(variable, type) SLEG_CONDVAR(variable, type, 0, SL_MAX_VERSION)
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
   221
#define SLEG_REF(variable, type) SLEG_CONDREF(variable, type, 0, SL_MAX_VERSION)
3222
8bfed4267cba (svn r3895) - Add proper SLE(G)_CONDNULL macros for the empty space reservation in savegames and update where used
Darkvater
parents: 3117
diff changeset
   222
#define SLEG_ARR(variable, type) SLEG_CONDARR(variable, type, lengthof(variable), 0, SL_MAX_VERSION)
8bfed4267cba (svn r3895) - Add proper SLE(G)_CONDNULL macros for the empty space reservation in savegames and update where used
Darkvater
parents: 3117
diff changeset
   223
#define SLEG_STR(variable, type) SLEG_CONDSTR(variable, type, lengthof(variable), 0, SL_MAX_VERSION)
8bfed4267cba (svn r3895) - Add proper SLE(G)_CONDNULL macros for the empty space reservation in savegames and update where used
Darkvater
parents: 3117
diff changeset
   224
3240
ad3a18a3a319 (svn r3914) - Properly implement SDT(G)_CONDNULL macro's without special cases (add flag SLF_CONFIG_NO and empty string as name)
Darkvater
parents: 3222
diff changeset
   225
#define SLEG_CONDNULL(length, from, to) {SL_ARR, SLE_FILE_U8 | SLE_VAR_NULL | SLF_CONFIG_NO, length, from, to, (void*)NULL}
3046
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
   226
3073
eb443625edae (svn r3662) Fix regression FS#58 with union, endiannes and static decleration problems. Removed the union.
Darkvater
parents: 3072
diff changeset
   227
#define SLEG_END() {SL_END, 0, 0, 0, 0, NULL}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   228
2685
00111d5ca47f (svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents: 2380
diff changeset
   229
/** Checks if the savegame is below major.minor.
00111d5ca47f (svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents: 2380
diff changeset
   230
 */
00111d5ca47f (svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents: 2380
diff changeset
   231
static inline bool CheckSavegameVersionOldStyle(uint16 major, byte minor)
00111d5ca47f (svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents: 2380
diff changeset
   232
{
3045
bed3ec96499f (svn r3625) - Move sl_version inside the functions where they are used to force usage.
Darkvater
parents: 3044
diff changeset
   233
	extern uint16 _sl_version;
bed3ec96499f (svn r3625) - Move sl_version inside the functions where they are used to force usage.
Darkvater
parents: 3044
diff changeset
   234
	extern byte   _sl_minor_version;
2685
00111d5ca47f (svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents: 2380
diff changeset
   235
	return (_sl_version < major) || (_sl_version == major && _sl_minor_version < minor);
00111d5ca47f (svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents: 2380
diff changeset
   236
}
00111d5ca47f (svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents: 2380
diff changeset
   237
00111d5ca47f (svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents: 2380
diff changeset
   238
/** Checks if the savegame is below version.
00111d5ca47f (svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents: 2380
diff changeset
   239
 */
00111d5ca47f (svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents: 2380
diff changeset
   240
static inline bool CheckSavegameVersion(uint16 version)
00111d5ca47f (svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents: 2380
diff changeset
   241
{
3045
bed3ec96499f (svn r3625) - Move sl_version inside the functions where they are used to force usage.
Darkvater
parents: 3044
diff changeset
   242
	extern uint16 _sl_version;
2685
00111d5ca47f (svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents: 2380
diff changeset
   243
	return _sl_version < version;
00111d5ca47f (svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents: 2380
diff changeset
   244
}
00111d5ca47f (svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents: 2380
diff changeset
   245
3117
8066b8d0802b (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3115
diff changeset
   246
/** Checks if some version from/to combination falls within the range of the
8066b8d0802b (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3115
diff changeset
   247
 * active savegame version */
8066b8d0802b (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3115
diff changeset
   248
static inline bool SlIsObjectCurrentlyValid(uint16 version_from, uint16 version_to)
8066b8d0802b (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3115
diff changeset
   249
{
8066b8d0802b (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3115
diff changeset
   250
	extern const uint16 SAVEGAME_VERSION;
8066b8d0802b (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3115
diff changeset
   251
	if (SAVEGAME_VERSION < version_from || SAVEGAME_VERSION > version_to) return false;
8066b8d0802b (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3115
diff changeset
   252
8066b8d0802b (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3115
diff changeset
   253
	return true;
8066b8d0802b (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3115
diff changeset
   254
}
8066b8d0802b (svn r3721) - [3/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. From part 3 on, OpenTTD is once again compilable.
Darkvater
parents: 3115
diff changeset
   255
3108
de4252bcae08 (svn r3711) - Extract the WriteValue() and ReadValue() parts of the saveload code to assign/read to/from a variable. Preparatory work to make this the general function type for such assignments
Darkvater
parents: 3073
diff changeset
   256
/* Get the NumberType of a setting. This describes the integer type
de4252bcae08 (svn r3711) - Extract the WriteValue() and ReadValue() parts of the saveload code to assign/read to/from a variable. Preparatory work to make this the general function type for such assignments
Darkvater
parents: 3073
diff changeset
   257
 * as it is represented in memory
de4252bcae08 (svn r3711) - Extract the WriteValue() and ReadValue() parts of the saveload code to assign/read to/from a variable. Preparatory work to make this the general function type for such assignments
Darkvater
parents: 3073
diff changeset
   258
 * @param type VarType holding information about the variable-type
de4252bcae08 (svn r3711) - Extract the WriteValue() and ReadValue() parts of the saveload code to assign/read to/from a variable. Preparatory work to make this the general function type for such assignments
Darkvater
parents: 3073
diff changeset
   259
 * @return return the SLE_VAR_* part of a variable-type description */
de4252bcae08 (svn r3711) - Extract the WriteValue() and ReadValue() parts of the saveload code to assign/read to/from a variable. Preparatory work to make this the general function type for such assignments
Darkvater
parents: 3073
diff changeset
   260
static inline VarType GetVarMemType(VarType type)
de4252bcae08 (svn r3711) - Extract the WriteValue() and ReadValue() parts of the saveload code to assign/read to/from a variable. Preparatory work to make this the general function type for such assignments
Darkvater
parents: 3073
diff changeset
   261
{
3625
5112d9999b6a (svn r4524) - Codechange: Use GB() macros for getting the saveload file/memory types
Darkvater
parents: 3240
diff changeset
   262
	return type & 0xF0; // GB(type, 4, 4) << 4;
3108
de4252bcae08 (svn r3711) - Extract the WriteValue() and ReadValue() parts of the saveload code to assign/read to/from a variable. Preparatory work to make this the general function type for such assignments
Darkvater
parents: 3073
diff changeset
   263
}
de4252bcae08 (svn r3711) - Extract the WriteValue() and ReadValue() parts of the saveload code to assign/read to/from a variable. Preparatory work to make this the general function type for such assignments
Darkvater
parents: 3073
diff changeset
   264
de4252bcae08 (svn r3711) - Extract the WriteValue() and ReadValue() parts of the saveload code to assign/read to/from a variable. Preparatory work to make this the general function type for such assignments
Darkvater
parents: 3073
diff changeset
   265
/* Get the FileType of a setting. This describes the integer type
de4252bcae08 (svn r3711) - Extract the WriteValue() and ReadValue() parts of the saveload code to assign/read to/from a variable. Preparatory work to make this the general function type for such assignments
Darkvater
parents: 3073
diff changeset
   266
 * as it is represented in a savegame/file
de4252bcae08 (svn r3711) - Extract the WriteValue() and ReadValue() parts of the saveload code to assign/read to/from a variable. Preparatory work to make this the general function type for such assignments
Darkvater
parents: 3073
diff changeset
   267
 * @param type VarType holding information about the variable-type
de4252bcae08 (svn r3711) - Extract the WriteValue() and ReadValue() parts of the saveload code to assign/read to/from a variable. Preparatory work to make this the general function type for such assignments
Darkvater
parents: 3073
diff changeset
   268
 * @param return the SLE_FILE_* part of a variable-type description */
de4252bcae08 (svn r3711) - Extract the WriteValue() and ReadValue() parts of the saveload code to assign/read to/from a variable. Preparatory work to make this the general function type for such assignments
Darkvater
parents: 3073
diff changeset
   269
static inline VarType GetVarFileType(VarType type)
de4252bcae08 (svn r3711) - Extract the WriteValue() and ReadValue() parts of the saveload code to assign/read to/from a variable. Preparatory work to make this the general function type for such assignments
Darkvater
parents: 3073
diff changeset
   270
{
de4252bcae08 (svn r3711) - Extract the WriteValue() and ReadValue() parts of the saveload code to assign/read to/from a variable. Preparatory work to make this the general function type for such assignments
Darkvater
parents: 3073
diff changeset
   271
	return type & 0xF; // GB(type, 0, 4);
de4252bcae08 (svn r3711) - Extract the WriteValue() and ReadValue() parts of the saveload code to assign/read to/from a variable. Preparatory work to make this the general function type for such assignments
Darkvater
parents: 3073
diff changeset
   272
}
de4252bcae08 (svn r3711) - Extract the WriteValue() and ReadValue() parts of the saveload code to assign/read to/from a variable. Preparatory work to make this the general function type for such assignments
Darkvater
parents: 3073
diff changeset
   273
5141
05a806850445 (svn r7231) -Codechange: rename ini_get_variable to GetVariableAddress for use both in settings.c
Darkvater
parents: 5140
diff changeset
   274
/** Get the address of the variable. Which one to pick depends on the object
05a806850445 (svn r7231) -Codechange: rename ini_get_variable to GetVariableAddress for use both in settings.c
Darkvater
parents: 5140
diff changeset
   275
 * pointer. If it is NULL we are dealing with global variables so the address
05a806850445 (svn r7231) -Codechange: rename ini_get_variable to GetVariableAddress for use both in settings.c
Darkvater
parents: 5140
diff changeset
   276
 * is taken. If non-null only the offset is stored in the union and we need
05a806850445 (svn r7231) -Codechange: rename ini_get_variable to GetVariableAddress for use both in settings.c
Darkvater
parents: 5140
diff changeset
   277
 * to add this to the address of the object */
05a806850445 (svn r7231) -Codechange: rename ini_get_variable to GetVariableAddress for use both in settings.c
Darkvater
parents: 5140
diff changeset
   278
static inline void *GetVariableAddress(const void *object, const SaveLoad *sld)
05a806850445 (svn r7231) -Codechange: rename ini_get_variable to GetVariableAddress for use both in settings.c
Darkvater
parents: 5140
diff changeset
   279
{
05a806850445 (svn r7231) -Codechange: rename ini_get_variable to GetVariableAddress for use both in settings.c
Darkvater
parents: 5140
diff changeset
   280
	return (byte*)object + (ptrdiff_t)sld->address;
05a806850445 (svn r7231) -Codechange: rename ini_get_variable to GetVariableAddress for use both in settings.c
Darkvater
parents: 5140
diff changeset
   281
}
05a806850445 (svn r7231) -Codechange: rename ini_get_variable to GetVariableAddress for use both in settings.c
Darkvater
parents: 5140
diff changeset
   282
3108
de4252bcae08 (svn r3711) - Extract the WriteValue() and ReadValue() parts of the saveload code to assign/read to/from a variable. Preparatory work to make this the general function type for such assignments
Darkvater
parents: 3073
diff changeset
   283
int64 ReadValue(const void *ptr, VarType conv);
de4252bcae08 (svn r3711) - Extract the WriteValue() and ReadValue() parts of the saveload code to assign/read to/from a variable. Preparatory work to make this the general function type for such assignments
Darkvater
parents: 3073
diff changeset
   284
void WriteValue(void *ptr, VarType conv, int64 val);
de4252bcae08 (svn r3711) - Extract the WriteValue() and ReadValue() parts of the saveload code to assign/read to/from a variable. Preparatory work to make this the general function type for such assignments
Darkvater
parents: 3073
diff changeset
   285
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   286
void SlSetArrayIndex(uint index);
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1024
diff changeset
   287
int SlIterateArray(void);
3046
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
   288
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   289
void SlAutolength(AutolengthProc *proc, void *arg);
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1024
diff changeset
   290
uint SlGetFieldLength(void);
1881
023a134a4b12 (svn r2387) - CodeChange: made the saveload code more readable and also removed the 'byte' saveload arrays which means you can save an array of more than 255 elements, or bigger structs than 255 bytes. This doesn't yet solve the problem that a chunk can be a maximum of 16384 big.
Darkvater
parents: 1217
diff changeset
   291
void SlSetLength(size_t length);
5142
d423c895a5b4 (svn r7232) -Codechange: Also allow for the save/load of non pre-allocated strings inside structs.
Darkvater
parents: 5141
diff changeset
   292
size_t SlCalcObjMemberLength(const void *object, const SaveLoad *sld);
3046
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
   293
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
   294
byte SlReadByte(void);
1881
023a134a4b12 (svn r2387) - CodeChange: made the saveload code more readable and also removed the 'byte' saveload arrays which means you can save an array of more than 255 elements, or bigger structs than 255 bytes. This doesn't yet solve the problem that a chunk can be a maximum of 16384 big.
Darkvater
parents: 1217
diff changeset
   295
void SlWriteByte(byte b);
3046
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
   296
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
   297
void SlGlobList(const SaveLoadGlobVarList *sldg);
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
   298
void SlArray(void *array, uint length, VarType conv);
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
   299
void SlObject(void *object, const SaveLoad *sld);
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3045
diff changeset
   300
bool SlObjectMember(void *object, const SaveLoad *sld);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   301
2380
3b26659b4a9a (svn r2906) Fix some threaded saving problems. Now the thread only interfaces with the main program through a sort of mutex. Communication uses the function OTTD_SendThreadMessage() with the approiate message which is handled in ProcessSentMessage() during the main loop.
Darkvater
parents: 2337
diff changeset
   302
void SaveFileStart(void);
3b26659b4a9a (svn r2906) Fix some threaded saving problems. Now the thread only interfaces with the main program through a sort of mutex. Communication uses the function OTTD_SendThreadMessage() with the approiate message which is handled in ProcessSentMessage() during the main loop.
Darkvater
parents: 2337
diff changeset
   303
void SaveFileDone(void);
3b26659b4a9a (svn r2906) Fix some threaded saving problems. Now the thread only interfaces with the main program through a sort of mutex. Communication uses the function OTTD_SendThreadMessage() with the approiate message which is handled in ProcessSentMessage() during the main loop.
Darkvater
parents: 2337
diff changeset
   304
void SaveFileError(void);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   305
#endif /* SAVELOAD_H */