Feature: framework to make savegames self-descriptive
We won't be able to make it fully self-descriptive (looking at you MAP-chunks), but anything else can. With this framework, we can add headers for each chunk explaining how each chunk looks like in detail. They also will all be tables, making it a lot easier to read in external tooling, and opening the way to consider a database (like SQLite) to use as savegame format. Lastly, with the headers in the savegame, you can freely add fields without needing a savegame version bump; older versions of OpenTTD will simply ignore the new field. This also means we can remove all the SLE_CONDNULL, as they are irrelevant. The next few commits will start using this framework.
This commit is contained in:

committed by
Patric Stout

parent
513641f9ba
commit
7dd5fd6ed4
@@ -83,7 +83,7 @@ public:
|
||||
SLE_VAR(Node, demand, SLE_UINT32),
|
||||
SLE_VAR(Node, station, SLE_UINT16),
|
||||
SLE_VAR(Node, last_update, SLE_INT32),
|
||||
SLEG_STRUCTLIST(SlLinkgraphEdge),
|
||||
SLEG_STRUCTLIST("edges", SlLinkgraphEdge),
|
||||
};
|
||||
|
||||
void Save(LinkGraph *lg) const override
|
||||
@@ -118,9 +118,9 @@ SaveLoadTable GetLinkGraphDesc()
|
||||
{
|
||||
static const SaveLoad link_graph_desc[] = {
|
||||
SLE_VAR(LinkGraph, last_compression, SLE_INT32),
|
||||
SLEG_CONDVAR(_num_nodes, SLE_UINT16, SL_MIN_VERSION, SLV_SAVELOAD_LIST_LENGTH),
|
||||
SLEG_CONDVAR("num_nodes", _num_nodes, SLE_UINT16, SL_MIN_VERSION, SLV_SAVELOAD_LIST_LENGTH),
|
||||
SLE_VAR(LinkGraph, cargo, SLE_UINT8),
|
||||
SLEG_STRUCTLIST(SlLinkgraphNode),
|
||||
SLEG_STRUCTLIST("nodes", SlLinkgraphNode),
|
||||
};
|
||||
return link_graph_desc;
|
||||
}
|
||||
@@ -165,7 +165,7 @@ SaveLoadTable GetLinkGraphJobDesc()
|
||||
static const SaveLoad job_desc[] = {
|
||||
SLE_VAR(LinkGraphJob, join_date, SLE_INT32),
|
||||
SLE_VAR(LinkGraphJob, link_graph.index, SLE_UINT16),
|
||||
SLEG_STRUCT(SlLinkgraphJobProxy),
|
||||
SLEG_STRUCT("linkgraph", SlLinkgraphJobProxy),
|
||||
};
|
||||
|
||||
/* The member offset arithmetic below is only valid if the types in question
|
||||
|
Reference in New Issue
Block a user