author | truelight |
Thu, 24 Mar 2005 14:43:40 +0000 | |
changeset 1540 | 6eef12dab5bf |
parent 1217 | 59c024cfaf54 |
child 1881 | 435d39bd6ee0 |
permissions | -rw-r--r-- |
0 | 1 |
#ifndef SAVELOAD_H |
2 |
#define SAVELOAD_H |
|
3 |
||
817
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
4 |
#include <setjmp.h> |
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
5 |
|
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
6 |
typedef void ChunkSaveLoadProc(void); |
0 | 7 |
typedef void AutolengthProc(void *arg); |
8 |
||
9 |
typedef struct SaveLoadGlobVarList { |
|
10 |
void *address; |
|
11 |
byte conv; |
|
12 |
byte from_version; |
|
13 |
byte to_version; |
|
14 |
} SaveLoadGlobVarList; |
|
15 |
||
16 |
||
17 |
typedef struct { |
|
18 |
uint32 id; |
|
19 |
ChunkSaveLoadProc *save_proc; |
|
20 |
ChunkSaveLoadProc *load_proc; |
|
21 |
uint32 flags; |
|
22 |
} ChunkHandler; |
|
23 |
||
24 |
typedef struct { |
|
25 |
byte null; |
|
26 |
} NullStruct; |
|
27 |
||
817
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
28 |
typedef void WriterProc(uint len); |
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
29 |
typedef uint ReaderProc(void); |
817
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
30 |
|
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
31 |
typedef uint ReferenceToIntProc(void *v, uint t); |
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
32 |
typedef void *IntToReferenceProc(uint r, uint t); |
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
33 |
|
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
34 |
typedef struct { |
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
35 |
bool save; |
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
36 |
byte need_length; |
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
37 |
byte block_mode; |
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
38 |
bool error; |
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
39 |
byte version; |
938
23cc832ac8a2
(svn r1426) -Codechange: cleaned up the reference code in the saveload routines
truelight
parents:
817
diff
changeset
|
40 |
uint16 full_version; |
817
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
41 |
|
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
42 |
int obj_len; |
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
43 |
int array_index, last_array_index; |
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
44 |
|
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
45 |
uint32 offs_base; |
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
46 |
|
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
47 |
WriterProc *write_bytes; |
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
48 |
ReaderProc *read_bytes; |
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
49 |
|
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
50 |
ReferenceToIntProc *ref_to_int_proc; |
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
51 |
IntToReferenceProc *int_to_ref_proc; |
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
52 |
|
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
53 |
const ChunkHandler * const * chs; |
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
54 |
const byte * const *includes; |
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
55 |
|
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
56 |
byte *bufp, *bufe; |
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
57 |
|
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
58 |
int tmp; |
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
59 |
|
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
60 |
// these 3 may be used by compressor/decompressors. |
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
61 |
byte *buf; // pointer and size to read/write, initialized by init |
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
62 |
uint bufsize; |
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
63 |
FILE *fh; |
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
64 |
|
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
65 |
void (*excpt_uninit)(void); |
817
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
66 |
const char *excpt_msg; |
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
67 |
jmp_buf excpt; // used to jump to "exception handler" |
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
68 |
} SaverLoader; |
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
69 |
|
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
70 |
extern SaverLoader _sl; |
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
557
diff
changeset
|
71 |
|
0 | 72 |
enum { |
1024
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
956
diff
changeset
|
73 |
REF_ORDER = 0, |
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
956
diff
changeset
|
74 |
REF_VEHICLE = 1, |
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
956
diff
changeset
|
75 |
REF_STATION = 2, |
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
956
diff
changeset
|
76 |
REF_TOWN = 3, |
1217
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
77 |
REF_VEHICLE_OLD = 4, |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
78 |
REF_ROADSTOPS = 5 |
0 | 79 |
}; |
80 |
||
81 |
||
82 |
enum { |
|
83 |
INC_VEHICLE_COMMON = 0, |
|
84 |
}; |
|
85 |
||
86 |
||
87 |
enum { |
|
88 |
CH_RIFF = 0, |
|
89 |
CH_ARRAY = 1, |
|
90 |
CH_SPARSE_ARRAY = 2, |
|
91 |
CH_TYPE_MASK = 3, |
|
92 |
CH_LAST = 8, |
|
93 |
CH_AUTO_LENGTH = 16, |
|
94 |
CH_PRI_0 = 0 << 4, |
|
95 |
CH_PRI_1 = 1 << 4, |
|
96 |
CH_PRI_2 = 2 << 4, |
|
97 |
CH_PRI_3 = 3 << 4, |
|
98 |
CH_PRI_SHL = 4, |
|
99 |
CH_NUM_PRI_LEVELS = 4, |
|
100 |
}; |
|
101 |
||
102 |
enum { |
|
103 |
SLE_FILE_I8 = 0, |
|
104 |
SLE_FILE_U8 = 1, |
|
105 |
SLE_FILE_I16 = 2, |
|
106 |
SLE_FILE_U16 = 3, |
|
107 |
SLE_FILE_I32 = 4, |
|
108 |
SLE_FILE_U32 = 5, |
|
109 |
SLE_FILE_I64 = 6, |
|
110 |
SLE_FILE_U64 = 7, |
|
111 |
||
112 |
SLE_FILE_STRINGID = 8, |
|
113 |
// SLE_FILE_IVAR = 8, |
|
114 |
// SLE_FILE_UVAR = 9, |
|
115 |
||
116 |
SLE_VAR_I8 = 0 << 4, |
|
117 |
SLE_VAR_U8 = 1 << 4, |
|
118 |
SLE_VAR_I16 = 2 << 4, |
|
119 |
SLE_VAR_U16 = 3 << 4, |
|
120 |
SLE_VAR_I32 = 4 << 4, |
|
121 |
SLE_VAR_U32 = 5 << 4, |
|
122 |
SLE_VAR_I64 = 6 << 4, |
|
123 |
SLE_VAR_U64 = 7 << 4, |
|
124 |
||
125 |
SLE_VAR_NULL = 8 << 4, // useful to write zeros in savegame. |
|
126 |
||
127 |
SLE_VAR_INT = SLE_VAR_I32, |
|
128 |
SLE_VAR_UINT = SLE_VAR_U32, |
|
129 |
||
130 |
SLE_INT8 = SLE_FILE_I8 | SLE_VAR_I8, |
|
131 |
SLE_UINT8 = SLE_FILE_U8 | SLE_VAR_U8, |
|
132 |
SLE_INT16 = SLE_FILE_I16 | SLE_VAR_I16, |
|
133 |
SLE_UINT16 = SLE_FILE_U16 | SLE_VAR_U16, |
|
134 |
SLE_INT32 = SLE_FILE_I32 | SLE_VAR_I32, |
|
135 |
SLE_UINT32 = SLE_FILE_U32 | SLE_VAR_U32, |
|
136 |
SLE_INT64 = SLE_FILE_I64 | SLE_VAR_I64, |
|
137 |
SLE_UINT64 = SLE_FILE_U64 | SLE_VAR_U64, |
|
138 |
||
139 |
SLE_STRINGID = SLE_FILE_STRINGID | SLE_VAR_U16, |
|
140 |
}; |
|
141 |
||
142 |
#define SLE_VAR(t,i,c) 0 | (offsetof(t,i) & 0xF), offsetof(t,i) >> 4, c |
|
143 |
#define SLE_REF(t,i,c) 0x10 | (offsetof(t,i) & 0xF), offsetof(t,i) >> 4, c |
|
144 |
#define SLE_ARR(t,i,c,l) 0x20 | (offsetof(t,i) & 0xF), offsetof(t,i) >> 4, c, l |
|
145 |
#define SLE_CONDVAR(t,i,c,from,to) 0x40 | (offsetof(t,i) & 0xF), offsetof(t,i) >> 4, c, from, to |
|
146 |
#define SLE_CONDREF(t,i,c,from,to) 0x50 | (offsetof(t,i) & 0xF), offsetof(t,i) >> 4, c, from, to |
|
147 |
#define SLE_CONDARR(t,i,c,l,from,to) 0x60 | (offsetof(t,i) & 0xF), offsetof(t,i) >> 4, c, from,to, l |
|
148 |
#define SLE_WRITEBYTE(t,i,b,c) 0x80 | (offsetof(t,i) & 0xF), offsetof(t,i) >> 4, b, c |
|
149 |
#define SLE_INCLUDE(t,i,c) 0x90 | (offsetof(t,i) & 0xF), offsetof(t,i) >> 4, c |
|
150 |
||
151 |
||
152 |
#define SLE_VARX(t,c) 0x00 | ((t) & 0xF), (t) >> 4, c |
|
153 |
#define SLE_REFX(t,c) 0x10 | ((t) & 0xF), (t) >> 4, c |
|
154 |
#define SLE_CONDVARX(t,c,from,to) 0x40 | ((t) & 0xF), (t) >> 4, c, from, to |
|
1217
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
155 |
#define SLE_CONDREFX(t,c,from,to) 0x50 | ((t) & 0xF), (t) >> 4, c, from, to |
0 | 156 |
#define SLE_WRITEBYTEX(t,b) 0x80 | ((t) & 0xF), (t) >> 4, b |
157 |
#define SLE_INCLUDEX(t,c) 0x90 | ((t) & 0xF), (t) >> 4, c |
|
158 |
||
159 |
#define SLE_END() 0xF0 |
|
160 |
||
161 |
||
162 |
void SlSetArrayIndex(uint index); |
|
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
163 |
int SlIterateArray(void); |
0 | 164 |
void SlArray(void *array, uint length, uint conv); |
165 |
void SlObject(void *object, const void *desc); |
|
166 |
void SlAutolength(AutolengthProc *proc, void *arg); |
|
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
167 |
uint SlGetFieldLength(void); |
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
168 |
int SlReadByte(void); |
0 | 169 |
void SlSetLength(uint length); |
170 |
void SlWriteByte(byte v); |
|
171 |
void SlGlobList(const SaveLoadGlobVarList *desc); |
|
172 |
||
173 |
//int GetSavegameType(char *file); |
|
174 |
||
175 |
#endif /* SAVELOAD_H */ |