author | matthijs |
Wed, 22 Mar 2006 22:26:16 +0000 | |
branch | 0.4.5 |
changeset 9958 | bed516c67d61 |
parent 2848 | cb4b1cc0bf65 |
child 3044 | 631d21c289e2 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#ifndef SAVELOAD_H |
4 |
#define SAVELOAD_H |
|
5 |
||
2162
c1ded3bd3d0c
(svn r2672) Move saving/loading related declarations to saveload.h
tron
parents:
1887
diff
changeset
|
6 |
typedef enum SaveOrLoadResult { |
c1ded3bd3d0c
(svn r2672) Move saving/loading related declarations to saveload.h
tron
parents:
1887
diff
changeset
|
7 |
SL_OK = 0, // completed successfully |
c1ded3bd3d0c
(svn r2672) Move saving/loading related declarations to saveload.h
tron
parents:
1887
diff
changeset
|
8 |
SL_ERROR = 1, // error that was caught before internal structures were modified |
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 { |
c1ded3bd3d0c
(svn r2672) Move saving/loading related declarations to saveload.h
tron
parents:
1887
diff
changeset
|
13 |
SL_INVALID = -1, |
c1ded3bd3d0c
(svn r2672) Move saving/loading related declarations to saveload.h
tron
parents:
1887
diff
changeset
|
14 |
SL_LOAD = 0, |
c1ded3bd3d0c
(svn r2672) Move saving/loading related declarations to saveload.h
tron
parents:
1887
diff
changeset
|
15 |
SL_SAVE = 1, |
c1ded3bd3d0c
(svn r2672) Move saving/loading related declarations to saveload.h
tron
parents:
1887
diff
changeset
|
16 |
SL_OLD_LOAD = 2, |
c1ded3bd3d0c
(svn r2672) Move saving/loading related declarations to saveload.h
tron
parents:
1887
diff
changeset
|
17 |
} SaveOrLoadMode; |
c1ded3bd3d0c
(svn r2672) Move saving/loading related declarations to saveload.h
tron
parents:
1887
diff
changeset
|
18 |
|
c1ded3bd3d0c
(svn r2672) Move saving/loading related declarations to saveload.h
tron
parents:
1887
diff
changeset
|
19 |
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
|
20 |
void WaitTillSaved(void); |
2162
c1ded3bd3d0c
(svn r2672) Move saving/loading related declarations to saveload.h
tron
parents:
1887
diff
changeset
|
21 |
|
c1ded3bd3d0c
(svn r2672) Move saving/loading related declarations to saveload.h
tron
parents:
1887
diff
changeset
|
22 |
|
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
|
23 |
typedef void ChunkSaveLoadProc(void); |
0 | 24 |
typedef void AutolengthProc(void *arg); |
25 |
||
26 |
typedef struct SaveLoadGlobVarList { |
|
27 |
void *address; |
|
28 |
byte conv; |
|
2685
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2380
diff
changeset
|
29 |
uint16 from_version; |
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2380
diff
changeset
|
30 |
uint16 to_version; |
0 | 31 |
} SaveLoadGlobVarList; |
32 |
||
33 |
typedef struct { |
|
34 |
uint32 id; |
|
35 |
ChunkSaveLoadProc *save_proc; |
|
36 |
ChunkSaveLoadProc *load_proc; |
|
37 |
uint32 flags; |
|
38 |
} ChunkHandler; |
|
39 |
||
40 |
typedef struct { |
|
41 |
byte null; |
|
42 |
} NullStruct; |
|
43 |
||
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
|
44 |
typedef enum SLRefType { |
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
956
diff
changeset
|
45 |
REF_ORDER = 0, |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
956
diff
changeset
|
46 |
REF_VEHICLE = 1, |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
956
diff
changeset
|
47 |
REF_STATION = 2, |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
956
diff
changeset
|
48 |
REF_TOWN = 3, |
1217
ab9f02a224ab
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
49 |
REF_VEHICLE_OLD = 4, |
2848 | 50 |
REF_ROADSTOPS = 5, |
51 |
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
|
52 |
} SLRefType; |
0 | 53 |
|
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
|
54 |
|
2685
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2380
diff
changeset
|
55 |
extern uint16 _sl_version; /// the major savegame version identifier |
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2380
diff
changeset
|
56 |
extern byte _sl_minor_version; /// the minor savegame version, DO NOT USE! |
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
|
57 |
|
0 | 58 |
|
59 |
enum { |
|
60 |
INC_VEHICLE_COMMON = 0, |
|
61 |
}; |
|
62 |
||
63 |
enum { |
|
64 |
CH_RIFF = 0, |
|
65 |
CH_ARRAY = 1, |
|
66 |
CH_SPARSE_ARRAY = 2, |
|
67 |
CH_TYPE_MASK = 3, |
|
68 |
CH_LAST = 8, |
|
69 |
CH_AUTO_LENGTH = 16, |
|
70 |
CH_PRI_0 = 0 << 4, |
|
71 |
CH_PRI_1 = 1 << 4, |
|
72 |
CH_PRI_2 = 2 << 4, |
|
73 |
CH_PRI_3 = 3 << 4, |
|
74 |
CH_PRI_SHL = 4, |
|
75 |
CH_NUM_PRI_LEVELS = 4, |
|
76 |
}; |
|
77 |
||
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
|
78 |
typedef enum VarTypes { |
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
|
79 |
SLE_FILE_I8 = 0, |
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
|
80 |
SLE_FILE_U8 = 1, |
0 | 81 |
SLE_FILE_I16 = 2, |
82 |
SLE_FILE_U16 = 3, |
|
83 |
SLE_FILE_I32 = 4, |
|
84 |
SLE_FILE_U32 = 5, |
|
85 |
SLE_FILE_I64 = 6, |
|
86 |
SLE_FILE_U64 = 7, |
|
87 |
||
88 |
SLE_FILE_STRINGID = 8, |
|
89 |
// SLE_FILE_IVAR = 8, |
|
90 |
// SLE_FILE_UVAR = 9, |
|
91 |
||
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
|
92 |
SLE_VAR_I8 = 0 << 4, |
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
|
93 |
SLE_VAR_U8 = 1 << 4, |
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
|
94 |
SLE_VAR_I16 = 2 << 4, |
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
|
95 |
SLE_VAR_U16 = 3 << 4, |
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
|
96 |
SLE_VAR_I32 = 4 << 4, |
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
|
97 |
SLE_VAR_U32 = 5 << 4, |
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
|
98 |
SLE_VAR_I64 = 6 << 4, |
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
|
99 |
SLE_VAR_U64 = 7 << 4, |
0 | 100 |
|
101 |
SLE_VAR_NULL = 8 << 4, // useful to write zeros in savegame. |
|
102 |
||
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
|
103 |
SLE_VAR_INT = SLE_VAR_I32, |
0 | 104 |
SLE_VAR_UINT = SLE_VAR_U32, |
105 |
||
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
|
106 |
SLE_INT8 = SLE_FILE_I8 | SLE_VAR_I8, |
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
|
107 |
SLE_UINT8 = SLE_FILE_U8 | SLE_VAR_U8, |
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
|
108 |
SLE_INT16 = SLE_FILE_I16 | SLE_VAR_I16, |
0 | 109 |
SLE_UINT16 = SLE_FILE_U16 | SLE_VAR_U16, |
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
|
110 |
SLE_INT32 = SLE_FILE_I32 | SLE_VAR_I32, |
0 | 111 |
SLE_UINT32 = SLE_FILE_U32 | SLE_VAR_U32, |
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
|
112 |
SLE_INT64 = SLE_FILE_I64 | SLE_VAR_I64, |
0 | 113 |
SLE_UINT64 = SLE_FILE_U64 | SLE_VAR_U64, |
114 |
||
115 |
SLE_STRINGID = SLE_FILE_STRINGID | SLE_VAR_U16, |
|
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
|
116 |
} VarType; |
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
|
117 |
|
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
|
118 |
enum SaveLoadTypes { |
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
|
119 |
SL_VAR = 0, |
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
|
120 |
SL_REF = 1, |
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
|
121 |
SL_ARR = 2, |
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
|
122 |
SL_CONDVAR = 0 | (1 << 2), // 4 |
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
|
123 |
SL_CONDREF = 1 | (1 << 2), // 5 |
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
|
124 |
SL_CONDARR = 2 | (1 << 2), // 6 |
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
|
125 |
// non-normal save-load types |
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
|
126 |
SL_WRITEBYTE = 8, |
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
|
127 |
SL_INCLUDE = 9, |
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
|
128 |
SL_END = 15 |
0 | 129 |
}; |
130 |
||
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
|
131 |
/** 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
|
132 |
typedef struct SaveLoad { |
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
|
133 |
byte cmd; /// the action to take with the saved/loaded type, All types need different action |
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
|
134 |
VarType type; /// type of the variable to be saved, int |
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
|
135 |
uint16 offset; /// offset of this variable in the struct (max offset is 65536) |
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
|
136 |
uint16 length; /// (conditional) length of the variable (eg. arrays) (max array size is 65536 elements) |
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
|
137 |
uint16 version_from; /// save/load the variable starting from this savegame version |
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
|
138 |
uint16 version_to; /// save/load the variable until this savegame version |
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
|
139 |
} SaveLoad; |
0 | 140 |
|
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
|
141 |
/* Simple variables, references (pointers) and arrays */ |
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
|
142 |
#define SLE_VAR(base, variable, type) {SL_VAR, type, offsetof(base, variable), 0, 0, 0} |
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
|
143 |
#define SLE_REF(base, variable, type) {SL_REF, type, offsetof(base, variable), 0, 0, 0} |
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
|
144 |
#define SLE_ARR(base, variable, type, length) {SL_ARR, type, offsetof(base, variable), length, 0, 0} |
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
|
145 |
/* Conditional variables, references (pointers) and arrays that are only valid for certain savegame versions */ |
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
|
146 |
#define SLE_CONDVAR(base, variable, type, from, to) {SL_CONDVAR, type, offsetof(base, variable), 0, from, to} |
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
|
147 |
#define SLE_CONDREF(base, variable, type, from, to) {SL_CONDREF, type, offsetof(base, variable), 0, from, to} |
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 |
#define SLE_CONDARR(base, variable, type, length, from, to) {SL_CONDARR, type, offsetof(base, variable), length, from, to} |
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 |
/* Translate values ingame to different values in the savegame and vv */ |
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
|
150 |
#define SLE_WRITEBYTE(base, variable, game_value, file_value) {SL_WRITEBYTE, 0, offsetof(base, variable), 0, game_value, file_value} |
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
|
151 |
/* Load common code and put it into each struct (currently only for vehicles */ |
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
|
152 |
#define SLE_INCLUDE(base, variable, include_index) {SL_INCLUDE, 0, offsetof(base, variable), 0, include_index, 0} |
0 | 153 |
|
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 |
/* The same as the ones at the top, only the offset is given directly; used for unions */ |
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
|
155 |
#define SLE_VARX(offset, type) {SL_VAR, type, offset, 0, 0, 0} |
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
|
156 |
#define SLE_REFX(offset, type) {SL_REF, type, offset, 0, 0, 0} |
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 |
#define SLE_CONDVARX(offset, type, from, to) {SL_CONDVAR, type, offset, 0, from, to} |
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
|
158 |
#define SLE_CONDREFX(offset, type, from, to) {SL_CONDREF, type, offset, 0, from, to} |
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
|
159 |
#define SLE_WRITEBYTEX(offset, something) {SL_WRITEBYTE, 0, offset, 0, something, 0} |
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
|
160 |
#define SLE_INCLUDEX(offset, type) {SL_INCLUDE, type, offset, 0, 0, 0} |
0 | 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 |
/* End marker */ |
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
|
163 |
#define SLE_END() {SL_END, 0, 0, 0, 0, 0} |
0 | 164 |
|
2685
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2380
diff
changeset
|
165 |
/** 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
|
166 |
*/ |
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2380
diff
changeset
|
167 |
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
|
168 |
{ |
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2380
diff
changeset
|
169 |
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
|
170 |
} |
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2380
diff
changeset
|
171 |
|
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2380
diff
changeset
|
172 |
/** 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
|
173 |
*/ |
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2380
diff
changeset
|
174 |
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
|
175 |
{ |
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2380
diff
changeset
|
176 |
return _sl_version < version; |
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2380
diff
changeset
|
177 |
} |
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2380
diff
changeset
|
178 |
|
0 | 179 |
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
|
180 |
int SlIterateArray(void); |
1887 | 181 |
void SlArray(void *array, uint length, VarType conv); |
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
|
182 |
void SlObject(void *object, const SaveLoad *desc); |
0 | 183 |
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
|
184 |
uint SlGetFieldLength(void); |
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
185 |
int 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
|
186 |
void SlSetLength(size_t length); |
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
|
187 |
void SlWriteByte(byte b); |
0 | 188 |
void SlGlobList(const SaveLoadGlobVarList *desc); |
189 |
||
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
|
190 |
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
|
191 |
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
|
192 |
void SaveFileError(void); |
0 | 193 |
#endif /* SAVELOAD_H */ |