author | rubidium |
Sun, 25 May 2008 19:17:03 +0000 | |
changeset 9354 | 845e07db4549 |
parent 9111 | 48ce04029fe4 |
child 9390 | 88d36f907e96 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
9111
48ce04029fe4
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents:
9101
diff
changeset
|
3 |
/** @file saveload.h Functions/types related to saving and loading games. */ |
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6248
diff
changeset
|
4 |
|
0 | 5 |
#ifndef SAVELOAD_H |
6 |
#define SAVELOAD_H |
|
7 |
||
6929
56470c1b8a66
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
6817
diff
changeset
|
8 |
#include "fileio.h" |
56470c1b8a66
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
6817
diff
changeset
|
9 |
|
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5475
diff
changeset
|
10 |
#ifdef SIZE_MAX |
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5475
diff
changeset
|
11 |
#undef SIZE_MAX |
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5475
diff
changeset
|
12 |
#endif |
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5475
diff
changeset
|
13 |
|
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5475
diff
changeset
|
14 |
#define SIZE_MAX ((size_t)-1) |
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5475
diff
changeset
|
15 |
|
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
16 |
enum SaveOrLoadResult { |
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6248
diff
changeset
|
17 |
SL_OK = 0, ///< completed successfully |
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6248
diff
changeset
|
18 |
SL_ERROR = 1, ///< error that was caught before internal structures were modified |
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6248
diff
changeset
|
19 |
SL_REINIT = 2, ///< error that was caught in the middle of updating game state, need to clear it. (can only happen during load) |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
20 |
}; |
2162
b98e430ffd10
(svn r2672) Move saving/loading related declarations to saveload.h
tron
parents:
1887
diff
changeset
|
21 |
|
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
22 |
enum SaveOrLoadMode { |
3044
fbaef2401476
(svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents:
2848
diff
changeset
|
23 |
SL_INVALID = -1, |
fbaef2401476
(svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents:
2848
diff
changeset
|
24 |
SL_LOAD = 0, |
fbaef2401476
(svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents:
2848
diff
changeset
|
25 |
SL_SAVE = 1, |
fbaef2401476
(svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents:
2848
diff
changeset
|
26 |
SL_OLD_LOAD = 2, |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4257
diff
changeset
|
27 |
SL_PNG = 3, |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4257
diff
changeset
|
28 |
SL_BMP = 4, |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
29 |
}; |
2162
b98e430ffd10
(svn r2672) Move saving/loading related declarations to saveload.h
tron
parents:
1887
diff
changeset
|
30 |
|
9101
40c05255536e
(svn r12961) -Codechange: store the type of savegame we are loading in a global variable
smatz
parents:
8989
diff
changeset
|
31 |
enum SavegameType { |
40c05255536e
(svn r12961) -Codechange: store the type of savegame we are loading in a global variable
smatz
parents:
8989
diff
changeset
|
32 |
SGT_TTD, ///< TTD savegame (can be detected incorrectly) |
40c05255536e
(svn r12961) -Codechange: store the type of savegame we are loading in a global variable
smatz
parents:
8989
diff
changeset
|
33 |
SGT_TTDP1, ///< TTDP savegame ( -//- ) (data at NW border) |
40c05255536e
(svn r12961) -Codechange: store the type of savegame we are loading in a global variable
smatz
parents:
8989
diff
changeset
|
34 |
SGT_TTDP2, ///< TTDP savegame in new format (data at SE border) |
40c05255536e
(svn r12961) -Codechange: store the type of savegame we are loading in a global variable
smatz
parents:
8989
diff
changeset
|
35 |
SGT_OTTD ///< OTTD savegame |
40c05255536e
(svn r12961) -Codechange: store the type of savegame we are loading in a global variable
smatz
parents:
8989
diff
changeset
|
36 |
}; |
40c05255536e
(svn r12961) -Codechange: store the type of savegame we are loading in a global variable
smatz
parents:
8989
diff
changeset
|
37 |
|
7036
f1e26f21aa08
(svn r10300) -Fix [FS#917]: give a better explanation why the loading of a savegame failed and do not crash on loading savegames that were altered by patches or branches.
rubidium
parents:
7010
diff
changeset
|
38 |
void SetSaveLoadError(uint16 str); |
f1e26f21aa08
(svn r10300) -Fix [FS#917]: give a better explanation why the loading of a savegame failed and do not crash on loading savegames that were altered by patches or branches.
rubidium
parents:
7010
diff
changeset
|
39 |
const char *GetSaveLoadErrorString(); |
6929
56470c1b8a66
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
6817
diff
changeset
|
40 |
SaveOrLoadResult SaveOrLoad(const char *filename, int mode, Subdirectory sb); |
6247 | 41 |
void WaitTillSaved(); |
42 |
void DoExitSave(); |
|
2162
b98e430ffd10
(svn r2672) Move saving/loading related declarations to saveload.h
tron
parents:
1887
diff
changeset
|
43 |
|
b98e430ffd10
(svn r2672) Move saving/loading related declarations to saveload.h
tron
parents:
1887
diff
changeset
|
44 |
|
6247 | 45 |
typedef void ChunkSaveLoadProc(); |
0 | 46 |
typedef void AutolengthProc(void *arg); |
47 |
||
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
48 |
struct ChunkHandler { |
0 | 49 |
uint32 id; |
50 |
ChunkSaveLoadProc *save_proc; |
|
51 |
ChunkSaveLoadProc *load_proc; |
|
52 |
uint32 flags; |
|
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
53 |
}; |
0 | 54 |
|
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
55 |
struct NullStruct { |
0 | 56 |
byte null; |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
57 |
}; |
0 | 58 |
|
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
59 |
enum SLRefType { |
4344
7e123fec5b0b
(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 |
REF_ORDER = 0, |
7e123fec5b0b
(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 |
REF_VEHICLE = 1, |
7e123fec5b0b
(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
|
62 |
REF_STATION = 2, |
7e123fec5b0b
(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
|
63 |
REF_TOWN = 3, |
7e123fec5b0b
(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
|
64 |
REF_VEHICLE_OLD = 4, |
7e123fec5b0b
(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
|
65 |
REF_ROADSTOPS = 5, |
2848 | 66 |
REF_ENGINE_RENEWS = 6, |
7010
6f0d9f03180d
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium
parents:
6929
diff
changeset
|
67 |
REF_CARGO_PACKET = 7, |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
68 |
}; |
0 | 69 |
|
3044
fbaef2401476
(svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents:
2848
diff
changeset
|
70 |
#define SL_MAX_VERSION 255 |
1881
435d39bd6ee0
(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
|
71 |
|
0 | 72 |
enum { |
73 |
INC_VEHICLE_COMMON = 0, |
|
74 |
}; |
|
75 |
||
76 |
enum { |
|
4344
7e123fec5b0b
(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
|
77 |
CH_RIFF = 0, |
7e123fec5b0b
(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
|
78 |
CH_ARRAY = 1, |
7e123fec5b0b
(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
|
79 |
CH_SPARSE_ARRAY = 2, |
7e123fec5b0b
(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
|
80 |
CH_TYPE_MASK = 3, |
7e123fec5b0b
(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
|
81 |
CH_LAST = 8, |
3044
fbaef2401476
(svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents:
2848
diff
changeset
|
82 |
CH_AUTO_LENGTH = 16, |
fbaef2401476
(svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents:
2848
diff
changeset
|
83 |
|
fbaef2401476
(svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents:
2848
diff
changeset
|
84 |
CH_PRI_0 = 0 << 4, |
fbaef2401476
(svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents:
2848
diff
changeset
|
85 |
CH_PRI_1 = 1 << 4, |
fbaef2401476
(svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents:
2848
diff
changeset
|
86 |
CH_PRI_2 = 2 << 4, |
fbaef2401476
(svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents:
2848
diff
changeset
|
87 |
CH_PRI_3 = 3 << 4, |
fbaef2401476
(svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents:
2848
diff
changeset
|
88 |
CH_PRI_SHL = 4, |
0 | 89 |
CH_NUM_PRI_LEVELS = 4, |
90 |
}; |
|
91 |
||
3114
a4ee405be667
(svn r3718) - Add proper Doxygen comments to some saveload-structs (using ///<)
Darkvater
parents:
3108
diff
changeset
|
92 |
/** VarTypes is the general bitmasked magic type that tells us |
a4ee405be667
(svn r3718) - Add proper Doxygen comments to some saveload-structs (using ///<)
Darkvater
parents:
3108
diff
changeset
|
93 |
* certain characteristics about the variable it refers to. For example |
a4ee405be667
(svn r3718) - Add proper Doxygen comments to some saveload-structs (using ///<)
Darkvater
parents:
3108
diff
changeset
|
94 |
* SLE_FILE_* gives the size(type) as it would be in the savegame and |
a4ee405be667
(svn r3718) - Add proper Doxygen comments to some saveload-structs (using ///<)
Darkvater
parents:
3108
diff
changeset
|
95 |
* SLE_VAR_* the size(type) as it is in memory during runtime. These are |
a4ee405be667
(svn r3718) - Add proper Doxygen comments to some saveload-structs (using ///<)
Darkvater
parents:
3108
diff
changeset
|
96 |
* the first 8 bytes (0-3 SLE_FILE, 4-7 SLE_VAR). |
a4ee405be667
(svn r3718) - Add proper Doxygen comments to some saveload-structs (using ///<)
Darkvater
parents:
3108
diff
changeset
|
97 |
* Bytes 8-15 are reserved for various flags as explained below */ |
3046
baa216f9911a
(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
|
98 |
enum VarTypes { |
baa216f9911a
(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
|
99 |
/* 4 bytes allocated a maximum of 16 types for NumberType */ |
baa216f9911a
(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
|
100 |
SLE_FILE_I8 = 0, |
baa216f9911a
(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
|
101 |
SLE_FILE_U8 = 1, |
baa216f9911a
(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
|
102 |
SLE_FILE_I16 = 2, |
baa216f9911a
(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
|
103 |
SLE_FILE_U16 = 3, |
baa216f9911a
(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
|
104 |
SLE_FILE_I32 = 4, |
baa216f9911a
(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
|
105 |
SLE_FILE_U32 = 5, |
baa216f9911a
(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
|
106 |
SLE_FILE_I64 = 6, |
baa216f9911a
(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
|
107 |
SLE_FILE_U64 = 7, |
3114
a4ee405be667
(svn r3718) - Add proper Doxygen comments to some saveload-structs (using ///<)
Darkvater
parents:
3108
diff
changeset
|
108 |
SLE_FILE_STRINGID = 8, ///< StringID offset into strings-array |
3048
adf46229d390
(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
|
109 |
SLE_FILE_STRING = 9, |
3114
a4ee405be667
(svn r3718) - Add proper Doxygen comments to some saveload-structs (using ///<)
Darkvater
parents:
3108
diff
changeset
|
110 |
/* 6 more possible file-primitives */ |
0 | 111 |
|
3046
baa216f9911a
(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 |
/* 4 bytes allocated a maximum of 16 types for NumberType */ |
4344
7e123fec5b0b
(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
|
113 |
SLE_VAR_BL = 0 << 4, |
7e123fec5b0b
(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
|
114 |
SLE_VAR_I8 = 1 << 4, |
7e123fec5b0b
(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_VAR_U8 = 2 << 4, |
7e123fec5b0b
(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_VAR_I16 = 3 << 4, |
7e123fec5b0b
(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_VAR_U16 = 4 << 4, |
7e123fec5b0b
(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_VAR_I32 = 5 << 4, |
7e123fec5b0b
(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_VAR_U32 = 6 << 4, |
7e123fec5b0b
(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_VAR_I64 = 7 << 4, |
7e123fec5b0b
(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_VAR_U64 = 8 << 4, |
7e123fec5b0b
(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_VAR_NULL = 9 << 4, ///< useful to write zeros in savegame. |
5140
b1097c36a598
(svn r7228) -Codechange: [internal] Add the possibility to save/load string-pointers which do not
Darkvater
parents:
4548
diff
changeset
|
123 |
SLE_VAR_STRB = 10 << 4, ///< string (with pre-allocated buffer) |
4344
7e123fec5b0b
(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_VAR_STRBQ = 11 << 4, ///< string enclosed in quotes (with pre-allocated buffer) |
7e123fec5b0b
(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_VAR_STR = 12 << 4, ///< string pointer |
5140
b1097c36a598
(svn r7228) -Codechange: [internal] Add the possibility to save/load string-pointers which do not
Darkvater
parents:
4548
diff
changeset
|
126 |
SLE_VAR_STRQ = 13 << 4, ///< string pointer enclosed in quotes |
8258
9fa31acb07bc
(svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents:
7610
diff
changeset
|
127 |
SLE_VAR_NAME = 14 << 4, ///< old custom name to be converted to a char pointer |
4255
e550bf3de1c8
(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
|
128 |
/* 2 more possible memory-primitives */ |
0 | 129 |
|
3046
baa216f9911a
(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
|
130 |
/* Shortcut values */ |
baa216f9911a
(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 |
SLE_VAR_CHAR = SLE_VAR_I8, |
0 | 132 |
|
3046
baa216f9911a
(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
|
133 |
/* Default combinations of variables. As savegames change, so can variables |
baa216f9911a
(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
|
134 |
* and thus it is possible that the saved value and internal size do not |
baa216f9911a
(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
|
135 |
* match and you need to specify custom combo. The defaults are listed here */ |
4344
7e123fec5b0b
(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_BOOL = SLE_FILE_I8 | SLE_VAR_BL, |
7e123fec5b0b
(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_INT8 = SLE_FILE_I8 | SLE_VAR_I8, |
7e123fec5b0b
(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
|
138 |
SLE_UINT8 = SLE_FILE_U8 | SLE_VAR_U8, |
7e123fec5b0b
(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
|
139 |
SLE_INT16 = SLE_FILE_I16 | SLE_VAR_I16, |
7e123fec5b0b
(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
|
140 |
SLE_UINT16 = SLE_FILE_U16 | SLE_VAR_U16, |
7e123fec5b0b
(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
|
141 |
SLE_INT32 = SLE_FILE_I32 | SLE_VAR_I32, |
7e123fec5b0b
(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
|
142 |
SLE_UINT32 = SLE_FILE_U32 | SLE_VAR_U32, |
7e123fec5b0b
(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
|
143 |
SLE_INT64 = SLE_FILE_I64 | SLE_VAR_I64, |
7e123fec5b0b
(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
|
144 |
SLE_UINT64 = SLE_FILE_U64 | SLE_VAR_U64, |
7e123fec5b0b
(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
|
145 |
SLE_CHAR = SLE_FILE_I8 | SLE_VAR_CHAR, |
7e123fec5b0b
(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
|
146 |
SLE_STRINGID = SLE_FILE_STRINGID | SLE_VAR_U16, |
7e123fec5b0b
(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
|
147 |
SLE_STRINGBUF = SLE_FILE_STRING | SLE_VAR_STRB, |
7e123fec5b0b
(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
|
148 |
SLE_STRINGBQUOTE = SLE_FILE_STRING | SLE_VAR_STRBQ, |
7e123fec5b0b
(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
|
149 |
SLE_STRING = SLE_FILE_STRING | SLE_VAR_STR, |
7e123fec5b0b
(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 |
SLE_STRINGQUOTE = SLE_FILE_STRING | SLE_VAR_STRQ, |
8258
9fa31acb07bc
(svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents:
7610
diff
changeset
|
151 |
SLE_NAME = SLE_FILE_STRINGID | SLE_VAR_NAME, |
0 | 152 |
|
3046
baa216f9911a
(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
|
153 |
/* Shortcut values */ |
4344
7e123fec5b0b
(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
|
154 |
SLE_UINT = SLE_UINT32, |
7e123fec5b0b
(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 |
SLE_INT = SLE_INT32, |
7e123fec5b0b
(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 |
SLE_STRB = SLE_STRINGBUF, |
7e123fec5b0b
(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
|
157 |
SLE_STRBQ = SLE_STRINGBQUOTE, |
7e123fec5b0b
(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
|
158 |
SLE_STR = SLE_STRING, |
7e123fec5b0b
(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
|
159 |
SLE_STRQ = SLE_STRINGQUOTE, |
3115
24c7e92baa31
(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
|
160 |
|
24c7e92baa31
(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
|
161 |
/* 8 bytes allocated for a maximum of 8 flags |
24c7e92baa31
(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
|
162 |
* Flags directing saving/loading of a variable */ |
24c7e92baa31
(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
|
163 |
SLF_SAVE_NO = 1 << 8, ///< do not save with savegame, basically player-based |
24c7e92baa31
(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
|
164 |
SLF_CONFIG_NO = 1 << 9, ///< do not save to config file |
24c7e92baa31
(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
|
165 |
SLF_NETWORK_NO = 1 << 10, ///< do not synchronize over network (but it is saved if SSF_SAVE_NO is not set) |
24c7e92baa31
(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
|
166 |
/* 5 more possible flags */ |
3046
baa216f9911a
(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
|
167 |
}; |
baa216f9911a
(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
|
168 |
|
baa216f9911a
(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 |
typedef uint32 VarType; |
1881
435d39bd6ee0
(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
|
170 |
|
435d39bd6ee0
(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
|
171 |
enum SaveLoadTypes { |
7493
07944c9e005f
(svn r11004) -Codechange: some reworks of the saveload mechanism to be able to save and load private and protected variables in the vehicle struct.
rubidium
parents:
7036
diff
changeset
|
172 |
SL_VAR = 0, |
07944c9e005f
(svn r11004) -Codechange: some reworks of the saveload mechanism to be able to save and load private and protected variables in the vehicle struct.
rubidium
parents:
7036
diff
changeset
|
173 |
SL_REF = 1, |
07944c9e005f
(svn r11004) -Codechange: some reworks of the saveload mechanism to be able to save and load private and protected variables in the vehicle struct.
rubidium
parents:
7036
diff
changeset
|
174 |
SL_ARR = 2, |
07944c9e005f
(svn r11004) -Codechange: some reworks of the saveload mechanism to be able to save and load private and protected variables in the vehicle struct.
rubidium
parents:
7036
diff
changeset
|
175 |
SL_STR = 3, |
07944c9e005f
(svn r11004) -Codechange: some reworks of the saveload mechanism to be able to save and load private and protected variables in the vehicle struct.
rubidium
parents:
7036
diff
changeset
|
176 |
SL_LST = 4, |
1881
435d39bd6ee0
(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
|
177 |
// non-normal save-load types |
7493
07944c9e005f
(svn r11004) -Codechange: some reworks of the saveload mechanism to be able to save and load private and protected variables in the vehicle struct.
rubidium
parents:
7036
diff
changeset
|
178 |
SL_WRITEBYTE = 8, |
07944c9e005f
(svn r11004) -Codechange: some reworks of the saveload mechanism to be able to save and load private and protected variables in the vehicle struct.
rubidium
parents:
7036
diff
changeset
|
179 |
SL_VEH_INCLUDE = 9, |
07944c9e005f
(svn r11004) -Codechange: some reworks of the saveload mechanism to be able to save and load private and protected variables in the vehicle struct.
rubidium
parents:
7036
diff
changeset
|
180 |
SL_END = 15 |
0 | 181 |
}; |
182 |
||
3046
baa216f9911a
(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
|
183 |
typedef byte SaveLoadType; |
baa216f9911a
(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
|
184 |
|
1881
435d39bd6ee0
(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
|
185 |
/** SaveLoad type struct. Do NOT use this directly but use the SLE_ macros defined just below! */ |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
186 |
struct SaveLoad { |
7010
6f0d9f03180d
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium
parents:
6929
diff
changeset
|
187 |
bool global; ///< should we load a global variable or a non-global one |
3114
a4ee405be667
(svn r3718) - Add proper Doxygen comments to some saveload-structs (using ///<)
Darkvater
parents:
3108
diff
changeset
|
188 |
SaveLoadType cmd; ///< the action to take with the saved/loaded type, All types need different action |
a4ee405be667
(svn r3718) - Add proper Doxygen comments to some saveload-structs (using ///<)
Darkvater
parents:
3108
diff
changeset
|
189 |
VarType conv; ///< type of the variable to be saved, int |
a4ee405be667
(svn r3718) - Add proper Doxygen comments to some saveload-structs (using ///<)
Darkvater
parents:
3108
diff
changeset
|
190 |
uint16 length; ///< (conditional) length of the variable (eg. arrays) (max array size is 65536 elements) |
a4ee405be667
(svn r3718) - Add proper Doxygen comments to some saveload-structs (using ///<)
Darkvater
parents:
3108
diff
changeset
|
191 |
uint16 version_from; ///< save/load the variable starting from this savegame version |
a4ee405be667
(svn r3718) - Add proper Doxygen comments to some saveload-structs (using ///<)
Darkvater
parents:
3108
diff
changeset
|
192 |
uint16 version_to; ///< save/load the variable until this savegame version |
3046
baa216f9911a
(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
|
193 |
/* NOTE: This element either denotes the address of the variable for a global |
baa216f9911a
(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
|
194 |
* variable, or the offset within a struct which is then bound to a variable |
baa216f9911a
(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
|
195 |
* during runtime. Decision on which one to use is controlled by the function |
7010
6f0d9f03180d
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium
parents:
6929
diff
changeset
|
196 |
* that is called to save it. address: global=true, offset: global=false */ |
3114
a4ee405be667
(svn r3718) - Add proper Doxygen comments to some saveload-structs (using ///<)
Darkvater
parents:
3108
diff
changeset
|
197 |
void *address; ///< address of variable OR offset of variable in the struct (max offset is 65536) |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
198 |
}; |
0 | 199 |
|
3046
baa216f9911a
(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
|
200 |
/* Same as SaveLoad but global variables are used (for better readability); */ |
baa216f9911a
(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
|
201 |
typedef SaveLoad SaveLoadGlobVarList; |
baa216f9911a
(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
|
202 |
|
1881
435d39bd6ee0
(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
|
203 |
/* Simple variables, references (pointers) and arrays */ |
7010
6f0d9f03180d
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium
parents:
6929
diff
changeset
|
204 |
#define SLE_GENERAL(cmd, base, variable, type, length, from, to) {false, cmd, type, length, from, to, (void*)cpp_offsetof(base, variable)} |
3044
fbaef2401476
(svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents:
2848
diff
changeset
|
205 |
#define SLE_CONDVAR(base, variable, type, from, to) SLE_GENERAL(SL_VAR, base, variable, type, 0, from, to) |
fbaef2401476
(svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents:
2848
diff
changeset
|
206 |
#define SLE_CONDREF(base, variable, type, from, to) SLE_GENERAL(SL_REF, base, variable, type, 0, from, to) |
fbaef2401476
(svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents:
2848
diff
changeset
|
207 |
#define SLE_CONDARR(base, variable, type, length, from, to) SLE_GENERAL(SL_ARR, base, variable, type, length, from, to) |
fbaef2401476
(svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents:
2848
diff
changeset
|
208 |
#define SLE_CONDSTR(base, variable, type, length, from, to) SLE_GENERAL(SL_STR, base, variable, type, length, from, to) |
6499
e46cf40d8743
(svn r9682) -Codechange: Add support for saving/loading std::lists containing object references (REF_*)
peter1138
parents:
6420
diff
changeset
|
209 |
#define SLE_CONDLST(base, variable, type, from, to) SLE_GENERAL(SL_LST, base, variable, type, 0, from, to) |
3044
fbaef2401476
(svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents:
2848
diff
changeset
|
210 |
|
fbaef2401476
(svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents:
2848
diff
changeset
|
211 |
#define SLE_VAR(base, variable, type) SLE_CONDVAR(base, variable, type, 0, SL_MAX_VERSION) |
fbaef2401476
(svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents:
2848
diff
changeset
|
212 |
#define SLE_REF(base, variable, type) SLE_CONDREF(base, variable, type, 0, SL_MAX_VERSION) |
fbaef2401476
(svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents:
2848
diff
changeset
|
213 |
#define SLE_ARR(base, variable, type, length) SLE_CONDARR(base, variable, type, length, 0, SL_MAX_VERSION) |
fbaef2401476
(svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents:
2848
diff
changeset
|
214 |
#define SLE_STR(base, variable, type, length) SLE_CONDSTR(base, variable, type, length, 0, SL_MAX_VERSION) |
6499
e46cf40d8743
(svn r9682) -Codechange: Add support for saving/loading std::lists containing object references (REF_*)
peter1138
parents:
6420
diff
changeset
|
215 |
#define SLE_LST(base, variable, type) SLE_CONDLST(base, variable, type, 0, SL_MAX_VERSION) |
3044
fbaef2401476
(svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents:
2848
diff
changeset
|
216 |
|
3240
204f995f25df
(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
|
217 |
#define SLE_CONDNULL(length, from, to) SLE_CONDARR(NullStruct, null, SLE_FILE_U8 | SLE_VAR_NULL | SLF_CONFIG_NO, length, from, to) |
3222
6de22e06a1e9
(svn r3895) - Add proper SLE(G)_CONDNULL macros for the empty space reservation in savegames and update where used
Darkvater
parents:
3117
diff
changeset
|
218 |
|
6817
ca1cc2fd4cfa
(svn r10056) -Revert (r10049): removing SLE_WRITEBYTE didn't work as expected :(. Somehow SlIterateArray and SlObject depend on eachother and adding a some arbitrary data before the SlObject makes it go crazy.
rubidium
parents:
6810
diff
changeset
|
219 |
/* Translate values ingame to different values in the savegame and vv */ |
ca1cc2fd4cfa
(svn r10056) -Revert (r10049): removing SLE_WRITEBYTE didn't work as expected :(. Somehow SlIterateArray and SlObject depend on eachother and adding a some arbitrary data before the SlObject makes it go crazy.
rubidium
parents:
6810
diff
changeset
|
220 |
#define SLE_WRITEBYTE(base, variable, value) SLE_GENERAL(SL_WRITEBYTE, base, variable, 0, 0, value, value) |
0 | 221 |
|
1881
435d39bd6ee0
(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
|
222 |
/* The same as the ones at the top, only the offset is given directly; used for unions */ |
7610
13b7d9e247d2
(svn r11139) -Codechange: add support for persistent storage for NewGRFs.
rubidium
parents:
7493
diff
changeset
|
223 |
#define SLE_GENERALX(cmd, offset, type, length, param1, param2) {false, cmd, type, length, param1, param2, (void*)(offset)} |
13b7d9e247d2
(svn r11139) -Codechange: add support for persistent storage for NewGRFs.
rubidium
parents:
7493
diff
changeset
|
224 |
#define SLE_CONDVARX(offset, type, from, to) SLE_GENERALX(SL_VAR, offset, type, 0, from, to) |
13b7d9e247d2
(svn r11139) -Codechange: add support for persistent storage for NewGRFs.
rubidium
parents:
7493
diff
changeset
|
225 |
#define SLE_CONDARRX(offset, type, length, from, to) SLE_GENERALX(SL_ARR, offset, type, length, from, to) |
13b7d9e247d2
(svn r11139) -Codechange: add support for persistent storage for NewGRFs.
rubidium
parents:
7493
diff
changeset
|
226 |
#define SLE_CONDREFX(offset, type, from, to) SLE_GENERALX(SL_REF, offset, type, 0, from, to) |
3044
fbaef2401476
(svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents:
2848
diff
changeset
|
227 |
|
fbaef2401476
(svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents:
2848
diff
changeset
|
228 |
#define SLE_VARX(offset, type) SLE_CONDVARX(offset, type, 0, SL_MAX_VERSION) |
fbaef2401476
(svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents:
2848
diff
changeset
|
229 |
#define SLE_REFX(offset, type) SLE_CONDREFX(offset, type, 0, SL_MAX_VERSION) |
fbaef2401476
(svn r3624) - CodeChange: Some cosmetic changes in the saveload code;
Darkvater
parents:
2848
diff
changeset
|
230 |
|
7610
13b7d9e247d2
(svn r11139) -Codechange: add support for persistent storage for NewGRFs.
rubidium
parents:
7493
diff
changeset
|
231 |
#define SLE_WRITEBYTEX(offset, something) SLE_GENERALX(SL_WRITEBYTE, offset, 0, 0, something, 0) |
13b7d9e247d2
(svn r11139) -Codechange: add support for persistent storage for NewGRFs.
rubidium
parents:
7493
diff
changeset
|
232 |
#define SLE_VEH_INCLUDEX() SLE_GENERALX(SL_VEH_INCLUDE, 0, 0, 0, 0, SL_MAX_VERSION) |
0 | 233 |
|
1881
435d39bd6ee0
(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
|
234 |
/* End marker */ |
7010
6f0d9f03180d
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium
parents:
6929
diff
changeset
|
235 |
#define SLE_END() {false, SL_END, 0, 0, 0, 0, NULL} |
3046
baa216f9911a
(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
|
236 |
|
baa216f9911a
(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
|
237 |
/* Simple variables, references (pointers) and arrays, but for global variables */ |
7010
6f0d9f03180d
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium
parents:
6929
diff
changeset
|
238 |
#define SLEG_GENERAL(cmd, variable, type, length, from, to) {true, cmd, type, length, from, to, (void*)&variable} |
3046
baa216f9911a
(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
|
239 |
|
baa216f9911a
(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
|
240 |
#define SLEG_CONDVAR(variable, type, from, to) SLEG_GENERAL(SL_VAR, variable, type, 0, from, to) |
baa216f9911a
(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
|
241 |
#define SLEG_CONDREF(variable, type, from, to) SLEG_GENERAL(SL_REF, variable, type, 0, from, to) |
baa216f9911a
(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
|
242 |
#define SLEG_CONDARR(variable, type, length, from, to) SLEG_GENERAL(SL_ARR, variable, type, length, from, to) |
baa216f9911a
(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
|
243 |
#define SLEG_CONDSTR(variable, type, length, from, to) SLEG_GENERAL(SL_STR, variable, type, length, from, to) |
6499
e46cf40d8743
(svn r9682) -Codechange: Add support for saving/loading std::lists containing object references (REF_*)
peter1138
parents:
6420
diff
changeset
|
244 |
#define SLEG_CONDLST(variable, type, from, to) SLEG_GENERAL(SL_LST, variable, type, 0, from, to) |
3046
baa216f9911a
(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
|
245 |
|
baa216f9911a
(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
|
246 |
#define SLEG_VAR(variable, type) SLEG_CONDVAR(variable, type, 0, SL_MAX_VERSION) |
baa216f9911a
(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
|
247 |
#define SLEG_REF(variable, type) SLEG_CONDREF(variable, type, 0, SL_MAX_VERSION) |
3222
6de22e06a1e9
(svn r3895) - Add proper SLE(G)_CONDNULL macros for the empty space reservation in savegames and update where used
Darkvater
parents:
3117
diff
changeset
|
248 |
#define SLEG_ARR(variable, type) SLEG_CONDARR(variable, type, lengthof(variable), 0, SL_MAX_VERSION) |
6de22e06a1e9
(svn r3895) - Add proper SLE(G)_CONDNULL macros for the empty space reservation in savegames and update where used
Darkvater
parents:
3117
diff
changeset
|
249 |
#define SLEG_STR(variable, type) SLEG_CONDSTR(variable, type, lengthof(variable), 0, SL_MAX_VERSION) |
6499
e46cf40d8743
(svn r9682) -Codechange: Add support for saving/loading std::lists containing object references (REF_*)
peter1138
parents:
6420
diff
changeset
|
250 |
#define SLEG_LST(variable, type) SLEG_CONDLST(variable, type, 0, SL_MAX_VERSION) |
3222
6de22e06a1e9
(svn r3895) - Add proper SLE(G)_CONDNULL macros for the empty space reservation in savegames and update where used
Darkvater
parents:
3117
diff
changeset
|
251 |
|
7010
6f0d9f03180d
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium
parents:
6929
diff
changeset
|
252 |
#define SLEG_CONDNULL(length, from, to) {true, SL_ARR, SLE_FILE_U8 | SLE_VAR_NULL | SLF_CONFIG_NO, length, from, to, (void*)NULL} |
3046
baa216f9911a
(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
|
253 |
|
7010
6f0d9f03180d
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium
parents:
6929
diff
changeset
|
254 |
#define SLEG_END() {true, SL_END, 0, 0, 0, 0, NULL} |
0 | 255 |
|
2685
805a28b7c3b7
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2380
diff
changeset
|
256 |
/** Checks if the savegame is below major.minor. |
805a28b7c3b7
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2380
diff
changeset
|
257 |
*/ |
805a28b7c3b7
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2380
diff
changeset
|
258 |
static inline bool CheckSavegameVersionOldStyle(uint16 major, byte minor) |
805a28b7c3b7
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2380
diff
changeset
|
259 |
{ |
3045
0364fedfd355
(svn r3625) - Move sl_version inside the functions where they are used to force usage.
Darkvater
parents:
3044
diff
changeset
|
260 |
extern uint16 _sl_version; |
0364fedfd355
(svn r3625) - Move sl_version inside the functions where they are used to force usage.
Darkvater
parents:
3044
diff
changeset
|
261 |
extern byte _sl_minor_version; |
2685
805a28b7c3b7
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2380
diff
changeset
|
262 |
return (_sl_version < major) || (_sl_version == major && _sl_minor_version < minor); |
805a28b7c3b7
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2380
diff
changeset
|
263 |
} |
805a28b7c3b7
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2380
diff
changeset
|
264 |
|
805a28b7c3b7
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2380
diff
changeset
|
265 |
/** Checks if the savegame is below version. |
805a28b7c3b7
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2380
diff
changeset
|
266 |
*/ |
805a28b7c3b7
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2380
diff
changeset
|
267 |
static inline bool CheckSavegameVersion(uint16 version) |
805a28b7c3b7
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2380
diff
changeset
|
268 |
{ |
3045
0364fedfd355
(svn r3625) - Move sl_version inside the functions where they are used to force usage.
Darkvater
parents:
3044
diff
changeset
|
269 |
extern uint16 _sl_version; |
2685
805a28b7c3b7
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2380
diff
changeset
|
270 |
return _sl_version < version; |
805a28b7c3b7
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2380
diff
changeset
|
271 |
} |
805a28b7c3b7
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2380
diff
changeset
|
272 |
|
3117
4c9e8842598e
(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
|
273 |
/** Checks if some version from/to combination falls within the range of the |
4c9e8842598e
(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
|
274 |
* active savegame version */ |
4c9e8842598e
(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
|
275 |
static inline bool SlIsObjectCurrentlyValid(uint16 version_from, uint16 version_to) |
4c9e8842598e
(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
|
276 |
{ |
4c9e8842598e
(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
|
277 |
extern const uint16 SAVEGAME_VERSION; |
4c9e8842598e
(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
|
278 |
if (SAVEGAME_VERSION < version_from || SAVEGAME_VERSION > version_to) return false; |
4c9e8842598e
(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
|
279 |
|
4c9e8842598e
(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
|
280 |
return true; |
4c9e8842598e
(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
|
281 |
} |
4c9e8842598e
(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
|
282 |
|
3108
797699723806
(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 |
/* Get the NumberType of a setting. This describes the integer type |
797699723806
(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 |
* as it is represented in memory |
797699723806
(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 |
* @param type VarType holding information about the variable-type |
797699723806
(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
|
286 |
* @return return the SLE_VAR_* part of a variable-type description */ |
797699723806
(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
|
287 |
static inline VarType GetVarMemType(VarType type) |
797699723806
(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
|
288 |
{ |
3625
929df0b3484a
(svn r4524) - Codechange: Use GB() macros for getting the saveload file/memory types
Darkvater
parents:
3240
diff
changeset
|
289 |
return type & 0xF0; // GB(type, 4, 4) << 4; |
3108
797699723806
(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
|
290 |
} |
797699723806
(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
|
291 |
|
797699723806
(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
|
292 |
/* Get the FileType of a setting. This describes the integer type |
797699723806
(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
|
293 |
* as it is represented in a savegame/file |
797699723806
(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
|
294 |
* @param type VarType holding information about the variable-type |
797699723806
(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
|
295 |
* @param return the SLE_FILE_* part of a variable-type description */ |
797699723806
(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
|
296 |
static inline VarType GetVarFileType(VarType type) |
797699723806
(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
|
297 |
{ |
797699723806
(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
|
298 |
return type & 0xF; // GB(type, 0, 4); |
797699723806
(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
|
299 |
} |
797699723806
(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
|
300 |
|
5141
63e24cb6f071
(svn r7231) -Codechange: rename ini_get_variable to GetVariableAddress for use both in settings.c
Darkvater
parents:
5140
diff
changeset
|
301 |
/** Get the address of the variable. Which one to pick depends on the object |
63e24cb6f071
(svn r7231) -Codechange: rename ini_get_variable to GetVariableAddress for use both in settings.c
Darkvater
parents:
5140
diff
changeset
|
302 |
* pointer. If it is NULL we are dealing with global variables so the address |
63e24cb6f071
(svn r7231) -Codechange: rename ini_get_variable to GetVariableAddress for use both in settings.c
Darkvater
parents:
5140
diff
changeset
|
303 |
* is taken. If non-null only the offset is stored in the union and we need |
63e24cb6f071
(svn r7231) -Codechange: rename ini_get_variable to GetVariableAddress for use both in settings.c
Darkvater
parents:
5140
diff
changeset
|
304 |
* to add this to the address of the object */ |
63e24cb6f071
(svn r7231) -Codechange: rename ini_get_variable to GetVariableAddress for use both in settings.c
Darkvater
parents:
5140
diff
changeset
|
305 |
static inline void *GetVariableAddress(const void *object, const SaveLoad *sld) |
63e24cb6f071
(svn r7231) -Codechange: rename ini_get_variable to GetVariableAddress for use both in settings.c
Darkvater
parents:
5140
diff
changeset
|
306 |
{ |
63e24cb6f071
(svn r7231) -Codechange: rename ini_get_variable to GetVariableAddress for use both in settings.c
Darkvater
parents:
5140
diff
changeset
|
307 |
return (byte*)object + (ptrdiff_t)sld->address; |
63e24cb6f071
(svn r7231) -Codechange: rename ini_get_variable to GetVariableAddress for use both in settings.c
Darkvater
parents:
5140
diff
changeset
|
308 |
} |
63e24cb6f071
(svn r7231) -Codechange: rename ini_get_variable to GetVariableAddress for use both in settings.c
Darkvater
parents:
5140
diff
changeset
|
309 |
|
3108
797699723806
(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
|
310 |
int64 ReadValue(const void *ptr, VarType conv); |
797699723806
(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
|
311 |
void WriteValue(void *ptr, VarType conv, int64 val); |
797699723806
(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
|
312 |
|
0 | 313 |
void SlSetArrayIndex(uint index); |
6247 | 314 |
int SlIterateArray(); |
3046
baa216f9911a
(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
|
315 |
|
0 | 316 |
void SlAutolength(AutolengthProc *proc, void *arg); |
6247 | 317 |
uint SlGetFieldLength(); |
1881
435d39bd6ee0
(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
|
318 |
void SlSetLength(size_t length); |
5142
ee34e9968a62
(svn r7232) -Codechange: Also allow for the save/load of non pre-allocated strings inside structs.
Darkvater
parents:
5141
diff
changeset
|
319 |
size_t SlCalcObjMemberLength(const void *object, const SaveLoad *sld); |
3046
baa216f9911a
(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
|
320 |
|
6247 | 321 |
byte SlReadByte(); |
1881
435d39bd6ee0
(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
|
322 |
void SlWriteByte(byte b); |
3046
baa216f9911a
(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
|
323 |
|
baa216f9911a
(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
|
324 |
void SlGlobList(const SaveLoadGlobVarList *sldg); |
baa216f9911a
(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
|
325 |
void SlArray(void *array, uint length, VarType conv); |
baa216f9911a
(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
|
326 |
void SlObject(void *object, const SaveLoad *sld); |
baa216f9911a
(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
|
327 |
bool SlObjectMember(void *object, const SaveLoad *sld); |
0 | 328 |
|
329 |
#endif /* SAVELOAD_H */ |