Files
@ r27976:645fcc9c218c
Branch filter:
Location: cpp/openttd-patchpack/source/src/saveload/linkgraph_sl.cpp - annotation
r27976:645fcc9c218c
11.4 KiB
text/x-c
Change: Store station blocked/wires/pylons flags in map. (#11337)
This stores three flags in unused map bits, and avoids having to look up
station graphics and custom station specs to determine blocked/wires/pylons
status.
This potentially affects rail pathfinding performance.
Savegame version is not bumped, as the flags can just be updated every
time.
This stores three flags in unused map bits, and avoids having to look up
station graphics and custom station specs to determine blocked/wires/pylons
status.
This potentially affects rail pathfinding performance.
Savegame version is not bumped, as the flags can just be updated every
time.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 | r20251:8c2b509af318 r20251:8c2b509af318 r20251:8c2b509af318 r20251:8c2b509af318 r20251:8c2b509af318 r20251:8c2b509af318 r20251:8c2b509af318 r20251:8c2b509af318 r20251:8c2b509af318 r20251:8c2b509af318 r25753:722d782a707d r25753:722d782a707d r25753:722d782a707d r25753:722d782a707d r20251:8c2b509af318 r20345:3f31790c09c9 r20345:3f31790c09c9 r24483:c8962d3f47a6 r20251:8c2b509af318 r25781:2889ee13e097 r20251:8c2b509af318 r21383:942c32fb8b0e r21383:942c32fb8b0e r20251:8c2b509af318 r20251:8c2b509af318 r20251:8c2b509af318 r27737:728d55b97775 r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r25901:ecc6a1476cb8 r25681:3f3776f44d48 r25681:3f3776f44d48 r26920:e212d9198e19 r26920:e212d9198e19 r25681:3f3776f44d48 r25753:722d782a707d r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r26920:e212d9198e19 r26920:e212d9198e19 r26920:e212d9198e19 r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r26920:e212d9198e19 r27737:728d55b97775 r26920:e212d9198e19 r25681:3f3776f44d48 r26920:e212d9198e19 r26920:e212d9198e19 r26920:e212d9198e19 r27061:c5d62ad93958 r26920:e212d9198e19 r26920:e212d9198e19 r26920:e212d9198e19 r26920:e212d9198e19 r26920:e212d9198e19 r26920:e212d9198e19 r26920:e212d9198e19 r26920:e212d9198e19 r25681:3f3776f44d48 r26920:e212d9198e19 r26920:e212d9198e19 r26920:e212d9198e19 r26920:e212d9198e19 r26920:e212d9198e19 r26920:e212d9198e19 r25693:311303f64840 r26920:e212d9198e19 r26920:e212d9198e19 r26920:e212d9198e19 r26920:e212d9198e19 r26920:e212d9198e19 r26920:e212d9198e19 r26920:e212d9198e19 r26920:e212d9198e19 r26920:e212d9198e19 r26920:e212d9198e19 r26920:e212d9198e19 r26920:e212d9198e19 r26920:e212d9198e19 r26920:e212d9198e19 r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r25751:3154638283de r25681:3f3776f44d48 r25753:722d782a707d r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r25693:311303f64840 r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r27737:728d55b97775 r25693:311303f64840 r25693:311303f64840 r25681:3f3776f44d48 r25753:722d782a707d r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r20251:8c2b509af318 r20251:8c2b509af318 r20251:8c2b509af318 r20251:8c2b509af318 r20251:8c2b509af318 r25585:53810459092f r20251:8c2b509af318 r20251:8c2b509af318 r20853:63f0a4343cc3 r25751:3154638283de r20251:8c2b509af318 r25751:3154638283de r20251:8c2b509af318 r20251:8c2b509af318 r20251:8c2b509af318 r20251:8c2b509af318 r20345:3f31790c09c9 r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r25753:722d782a707d r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r25753:722d782a707d r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r25753:722d782a707d r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r25681:3f3776f44d48 r20345:3f31790c09c9 r20345:3f31790c09c9 r20345:3f31790c09c9 r20345:3f31790c09c9 r20345:3f31790c09c9 r20345:3f31790c09c9 r20345:3f31790c09c9 r20345:3f31790c09c9 r25585:53810459092f r20345:3f31790c09c9 r23538:8df50944b27a r20345:3f31790c09c9 r24755:9b2ef076754d r24755:9b2ef076754d r24755:9b2ef076754d r25751:3154638283de r24755:9b2ef076754d r24755:9b2ef076754d r24755:9b2ef076754d r24755:9b2ef076754d r24755:9b2ef076754d r24755:9b2ef076754d r24755:9b2ef076754d r24755:9b2ef076754d r24755:9b2ef076754d r24755:9b2ef076754d r24755:9b2ef076754d r20345:3f31790c09c9 r23520:20bbc807b0eb r25781:2889ee13e097 r20345:3f31790c09c9 r25579:86a9c48defe8 r25579:86a9c48defe8 r20345:3f31790c09c9 r20345:3f31790c09c9 r25585:53810459092f r25585:53810459092f r25585:53810459092f r20345:3f31790c09c9 r20345:3f31790c09c9 r25585:53810459092f r20345:3f31790c09c9 r20345:3f31790c09c9 r20345:3f31790c09c9 r20345:3f31790c09c9 r20345:3f31790c09c9 r20345:3f31790c09c9 r25585:53810459092f r20345:3f31790c09c9 r20345:3f31790c09c9 r25611:85dc1dbf8554 r25611:85dc1dbf8554 r20345:3f31790c09c9 r20345:3f31790c09c9 r20345:3f31790c09c9 r20345:3f31790c09c9 r20251:8c2b509af318 r20345:3f31790c09c9 r20345:3f31790c09c9 r20345:3f31790c09c9 r20345:3f31790c09c9 r20345:3f31790c09c9 r23264:b36243874b4a r23963:b6586baea514 r21529:6bf3ee37953c r26922:e16d3a06d864 r23726:97431e47d49a r21529:6bf3ee37953c r21529:6bf3ee37953c r21529:6bf3ee37953c r23963:b6586baea514 r23963:b6586baea514 r21529:6bf3ee37953c r26922:e16d3a06d864 r23726:97431e47d49a r21529:6bf3ee37953c r21529:6bf3ee37953c r21529:6bf3ee37953c r21529:6bf3ee37953c r22021:daba722f3935 r24483:c8962d3f47a6 r24483:c8962d3f47a6 r24483:c8962d3f47a6 r24483:c8962d3f47a6 r20345:3f31790c09c9 r20345:3f31790c09c9 r20345:3f31790c09c9 r25773:457e167f3c9e r20251:8c2b509af318 r25773:457e167f3c9e r25773:457e167f3c9e r25753:722d782a707d r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25753:722d782a707d r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25680:619a6509d944 r25680:619a6509d944 r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25753:722d782a707d r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r20345:3f31790c09c9 r25773:457e167f3c9e r20345:3f31790c09c9 r20345:3f31790c09c9 r25773:457e167f3c9e r25680:619a6509d944 r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25753:722d782a707d r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25680:619a6509d944 r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25680:619a6509d944 r25680:619a6509d944 r25773:457e167f3c9e r20345:3f31790c09c9 r25773:457e167f3c9e r25774:14ee6e7f4ecc r25753:722d782a707d r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r20345:3f31790c09c9 r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25753:722d782a707d r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25680:619a6509d944 r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r20345:3f31790c09c9 r25773:457e167f3c9e r25773:457e167f3c9e r25773:457e167f3c9e r25772:5ba83ce3a853 r25772:5ba83ce3a853 r25772:5ba83ce3a853 r25772:5ba83ce3a853 r20251:8c2b509af318 r25596:7bf7822e5659 r25596:7bf7822e5659 | /*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file linkgraph_sl.cpp Code handling saving and loading of link graphs */
#include "../stdafx.h"
#include "saveload.h"
#include "compat/linkgraph_sl_compat.h"
#include "../linkgraph/linkgraph.h"
#include "../linkgraph/linkgraphjob.h"
#include "../linkgraph/linkgraphschedule.h"
#include "../network/network.h"
#include "../settings_internal.h"
#include "../settings_table.h"
#include "../safeguards.h"
typedef LinkGraph::BaseNode Node;
typedef LinkGraph::BaseEdge Edge;
static uint16_t _num_nodes;
static LinkGraph *_linkgraph; ///< Contains the current linkgraph being saved/loaded.
static NodeID _linkgraph_from; ///< Contains the current "from" node being saved/loaded.
class SlLinkgraphEdge : public DefaultSaveLoadHandler<SlLinkgraphEdge, Node> {
public:
inline static const SaveLoad description[] = {
SLE_VAR(Edge, capacity, SLE_UINT32),
SLE_VAR(Edge, usage, SLE_UINT32),
SLE_CONDVAR(Edge, travel_time_sum, SLE_UINT64, SLV_LINKGRAPH_TRAVEL_TIME, SL_MAX_VERSION),
SLE_VAR(Edge, last_unrestricted_update, SLE_INT32),
SLE_CONDVAR(Edge, last_restricted_update, SLE_INT32, SLV_187, SL_MAX_VERSION),
SLE_VAR(Edge, dest_node, SLE_UINT16),
SLE_CONDVARNAME(Edge, dest_node, "next_edge", SLE_UINT16, SL_MIN_VERSION, SLV_LINKGRAPH_EDGES),
};
inline const static SaveLoadCompatTable compat_description = _linkgraph_edge_sl_compat;
void Save(Node *bn) const override
{
SlSetStructListLength(bn->edges.size());
for (Edge &e : bn->edges) {
SlObject(&e, this->GetDescription());
}
}
void Load(Node *bn) const override
{
if (IsSavegameVersionBefore(SLV_LINKGRAPH_EDGES)) {
uint16_t max_size = _linkgraph->Size();
std::vector<Edge> edges(max_size);
if (IsSavegameVersionBefore(SLV_191)) {
/* We used to save the full matrix ... */
for (NodeID to = 0; to < max_size; ++to) {
SlObject(&edges[to], this->GetLoadDescription());
}
} else {
size_t used_size = IsSavegameVersionBefore(SLV_SAVELOAD_LIST_LENGTH) ? max_size : SlGetStructListLength(UINT16_MAX);
/* ... but as that wasted a lot of space we save a sparse matrix now. */
for (NodeID to = _linkgraph_from; to != INVALID_NODE; to = edges[to].dest_node) {
if (used_size == 0) SlErrorCorrupt("Link graph structure overflow");
used_size--;
if (to >= max_size) SlErrorCorrupt("Link graph structure overflow");
SlObject(&edges[to], this->GetLoadDescription());
}
if (!IsSavegameVersionBefore(SLV_SAVELOAD_LIST_LENGTH) && used_size > 0) SlErrorCorrupt("Corrupted link graph");
}
/* Build edge list from edge matrix. */
for (NodeID to = edges[_linkgraph_from].dest_node; to != INVALID_NODE; to = edges[to].dest_node) {
bn->edges.push_back(edges[to]);
bn->edges.back().dest_node = to;
}
/* Sort by destination. */
std::sort(bn->edges.begin(), bn->edges.end());
} else {
/* Edge data is now a simple vector and not any kind of matrix. */
size_t size = SlGetStructListLength(UINT16_MAX);
for (size_t i = 0; i < size; i++) {
bn->edges.emplace_back();
SlObject(&bn->edges.back(), this->GetLoadDescription());
}
}
}
};
class SlLinkgraphNode : public DefaultSaveLoadHandler<SlLinkgraphNode, LinkGraph> {
public:
inline static const SaveLoad description[] = {
SLE_CONDVAR(Node, xy, SLE_UINT32, SLV_191, SL_MAX_VERSION),
SLE_VAR(Node, supply, SLE_UINT32),
SLE_VAR(Node, demand, SLE_UINT32),
SLE_VAR(Node, station, SLE_UINT16),
SLE_VAR(Node, last_update, SLE_INT32),
SLEG_STRUCTLIST("edges", SlLinkgraphEdge),
};
inline const static SaveLoadCompatTable compat_description = _linkgraph_node_sl_compat;
void Save(LinkGraph *lg) const override
{
_linkgraph = lg;
SlSetStructListLength(lg->Size());
for (NodeID from = 0; from < lg->Size(); ++from) {
_linkgraph_from = from;
SlObject(&lg->nodes[from], this->GetDescription());
}
}
void Load(LinkGraph *lg) const override
{
_linkgraph = lg;
uint16_t length = IsSavegameVersionBefore(SLV_SAVELOAD_LIST_LENGTH) ? _num_nodes : (uint16_t)SlGetStructListLength(UINT16_MAX);
lg->Init(length);
for (NodeID from = 0; from < length; ++from) {
_linkgraph_from = from;
SlObject(&lg->nodes[from], this->GetLoadDescription());
}
}
};
/**
* Get a SaveLoad array for a link graph.
* @return SaveLoad array for link graph.
*/
SaveLoadTable GetLinkGraphDesc()
{
static const SaveLoad link_graph_desc[] = {
SLE_VAR(LinkGraph, last_compression, SLE_INT32),
SLEG_CONDVAR("num_nodes", _num_nodes, SLE_UINT16, SL_MIN_VERSION, SLV_SAVELOAD_LIST_LENGTH),
SLE_VAR(LinkGraph, cargo, SLE_UINT8),
SLEG_STRUCTLIST("nodes", SlLinkgraphNode),
};
return link_graph_desc;
}
/**
* Proxy to reuse LinkGraph to save/load a LinkGraphJob.
* One of the members of a LinkGraphJob is a LinkGraph, but SLEG_STRUCT()
* doesn't allow us to select a member. So instead, we add a bit of glue to
* accept a LinkGraphJob, get the LinkGraph, and use that to call the
* save/load routines for a regular LinkGraph.
*/
class SlLinkgraphJobProxy : public DefaultSaveLoadHandler<SlLinkgraphJobProxy, LinkGraphJob> {
public:
inline static const SaveLoad description[] = {{}}; // Needed to keep DefaultSaveLoadHandler happy.
SaveLoadTable GetDescription() const override { return GetLinkGraphDesc(); }
inline const static SaveLoadCompatTable compat_description = _linkgraph_sl_compat;
void Save(LinkGraphJob *lgj) const override
{
SlObject(const_cast<LinkGraph *>(&lgj->Graph()), this->GetDescription());
}
void Load(LinkGraphJob *lgj) const override
{
SlObject(const_cast<LinkGraph *>(&lgj->Graph()), this->GetLoadDescription());
}
};
/**
* Get a SaveLoad array for a link graph job. The settings struct is derived from
* the global settings saveload array. The exact entries are calculated when the function
* is called the first time.
* It's necessary to keep a copy of the settings for each link graph job so that you can
* change the settings while in-game and still not mess with current link graph runs.
* Of course the settings have to be saved and loaded, too, to avoid desyncs.
* @return Array of SaveLoad structs.
*/
SaveLoadTable GetLinkGraphJobDesc()
{
static std::vector<SaveLoad> saveloads;
static const SaveLoad job_desc[] = {
SLE_VAR(LinkGraphJob, join_date, SLE_INT32),
SLE_VAR(LinkGraphJob, link_graph.index, SLE_UINT16),
SLEG_STRUCT("linkgraph", SlLinkgraphJobProxy),
};
/* The member offset arithmetic below is only valid if the types in question
* are standard layout types. Otherwise, it would be undefined behaviour. */
static_assert(std::is_standard_layout<LinkGraphSettings>::value, "LinkGraphSettings needs to be a standard layout type");
/* We store the offset of each member of the #LinkGraphSettings in the
* extra data of the saveload struct. Use it together with the address
* of the settings struct inside the job to find the final memory address. */
static SaveLoadAddrProc * const proc = [](void *b, size_t extra) -> void * { return const_cast<void *>(static_cast<const void *>(reinterpret_cast<const char *>(std::addressof(static_cast<LinkGraphJob *>(b)->settings)) + extra)); };
/* Build the SaveLoad array on first call and don't touch it later on */
if (saveloads.size() == 0) {
GetSaveLoadFromSettingTable(_linkgraph_settings, saveloads);
for (auto &sl : saveloads) {
sl.address_proc = proc;
}
for (auto &sld : job_desc) {
saveloads.push_back(sld);
}
}
return saveloads;
}
/**
* Get a SaveLoad array for the link graph schedule.
* @return SaveLoad array for the link graph schedule.
*/
SaveLoadTable GetLinkGraphScheduleDesc()
{
static const SaveLoad schedule_desc[] = {
SLE_REFLIST(LinkGraphSchedule, schedule, REF_LINK_GRAPH),
SLE_REFLIST(LinkGraphSchedule, running, REF_LINK_GRAPH_JOB),
};
return schedule_desc;
}
/**
* Spawn the threads for running link graph calculations.
* Has to be done after loading as the cargo classes might have changed.
*/
void AfterLoadLinkGraphs()
{
if (IsSavegameVersionBefore(SLV_191)) {
for (LinkGraph *lg : LinkGraph::Iterate()) {
for (NodeID node_id = 0; node_id < lg->Size(); ++node_id) {
const Station *st = Station::GetIfValid((*lg)[node_id].station);
if (st != nullptr) (*lg)[node_id].UpdateLocation(st->xy);
}
}
for (LinkGraphJob *lgj : LinkGraphJob::Iterate()) {
LinkGraph *lg = &(const_cast<LinkGraph &>(lgj->Graph()));
for (NodeID node_id = 0; node_id < lg->Size(); ++node_id) {
const Station *st = Station::GetIfValid((*lg)[node_id].station);
if (st != nullptr) (*lg)[node_id].UpdateLocation(st->xy);
}
}
}
LinkGraphSchedule::instance.SpawnAll();
if (!_networking || _network_server) {
AfterLoad_LinkGraphPauseControl();
}
}
/**
* All link graphs.
*/
struct LGRPChunkHandler : ChunkHandler {
LGRPChunkHandler() : ChunkHandler('LGRP', CH_TABLE) {}
void Save() const override
{
SlTableHeader(GetLinkGraphDesc());
for (LinkGraph *lg : LinkGraph::Iterate()) {
SlSetArrayIndex(lg->index);
SlObject(lg, GetLinkGraphDesc());
}
}
void Load() const override
{
const std::vector<SaveLoad> slt = SlCompatTableHeader(GetLinkGraphDesc(), _linkgraph_sl_compat);
int index;
while ((index = SlIterateArray()) != -1) {
LinkGraph *lg = new (index) LinkGraph();
SlObject(lg, slt);
}
}
};
/**
* All link graph jobs.
*/
struct LGRJChunkHandler : ChunkHandler {
LGRJChunkHandler() : ChunkHandler('LGRJ', CH_TABLE) {}
void Save() const override
{
SlTableHeader(GetLinkGraphJobDesc());
for (LinkGraphJob *lgj : LinkGraphJob::Iterate()) {
SlSetArrayIndex(lgj->index);
SlObject(lgj, GetLinkGraphJobDesc());
}
}
void Load() const override
{
const std::vector<SaveLoad> slt = SlCompatTableHeader(GetLinkGraphJobDesc(), _linkgraph_job_sl_compat);
int index;
while ((index = SlIterateArray()) != -1) {
LinkGraphJob *lgj = new (index) LinkGraphJob();
SlObject(lgj, slt);
}
}
};
/**
* Link graph schedule.
*/
struct LGRSChunkHandler : ChunkHandler {
LGRSChunkHandler() : ChunkHandler('LGRS', CH_TABLE) {}
void Save() const override
{
SlTableHeader(GetLinkGraphScheduleDesc());
SlSetArrayIndex(0);
SlObject(&LinkGraphSchedule::instance, GetLinkGraphScheduleDesc());
}
void Load() const override
{
const std::vector<SaveLoad> slt = SlCompatTableHeader(GetLinkGraphScheduleDesc(), _linkgraph_schedule_sl_compat);
if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() == -1) return;
SlObject(&LinkGraphSchedule::instance, slt);
if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() != -1) SlErrorCorrupt("Too many LGRS entries");
}
void FixPointers() const override
{
SlObject(&LinkGraphSchedule::instance, GetLinkGraphScheduleDesc());
}
};
static const LGRPChunkHandler LGRP;
static const LGRJChunkHandler LGRJ;
static const LGRSChunkHandler LGRS;
static const ChunkHandlerRef linkgraph_chunk_handlers[] = {
LGRP,
LGRJ,
LGRS,
};
extern const ChunkHandlerTable _linkgraph_chunk_handlers(linkgraph_chunk_handlers);
|