OpenTTD Source  1.11.2
linkgraph_sl.cpp File Reference

Go to the source code of this file.

Typedefs

typedef LinkGraph::BaseNode Node
 
typedef LinkGraph::BaseEdge Edge
 

Functions

const SettingDescGetSettingDescription (uint index)
 
const SaveLoadGetLinkGraphDesc ()
 Get a SaveLoad array for a link graph. More...
 
const SaveLoadGetLinkGraphJobDesc ()
 Get a SaveLoad array for a link graph job. More...
 
const SaveLoadGetLinkGraphScheduleDesc ()
 Get a SaveLoad array for the link graph schedule. More...
 
void SaveLoad_LinkGraph (LinkGraph &lg)
 Save/load a link graph. More...
 
static void DoSave_LGRJ (LinkGraphJob *lgj)
 Save a link graph job. More...
 
static void DoSave_LGRP (LinkGraph *lg)
 Save a link graph. More...
 
static void Load_LGRP ()
 Load all link graphs.
 
static void Load_LGRJ ()
 Load all link graph jobs.
 
static void Load_LGRS ()
 Load the link graph schedule.
 
void AfterLoadLinkGraphs ()
 Spawn the threads for running link graph calculations. More...
 
static void Save_LGRP ()
 Save all link graphs.
 
static void Save_LGRJ ()
 Save all link graph jobs.
 
static void Save_LGRS ()
 Save the link graph schedule.
 
static void Ptrs_LGRS ()
 Substitute pointers in link graph schedule.
 

Variables

static uint16 _num_nodes
 
static const SaveLoad _node_desc []
 SaveLoad desc for a link graph node. More...
 
static const SaveLoad _edge_desc []
 SaveLoad desc for a link graph edge. More...
 
const ChunkHandler _linkgraph_chunk_handlers []
 

Detailed Description

Code handling saving and loading of link graphs

Definition in file linkgraph_sl.cpp.

Function Documentation

◆ AfterLoadLinkGraphs()

◆ DoSave_LGRJ()

static void DoSave_LGRJ ( LinkGraphJob lgj)
static

Save a link graph job.

Parameters
lgjLinkGraphJob to be saved.

Definition at line 165 of file linkgraph_sl.cpp.

References GetLinkGraphJobDesc(), and SlObject().

◆ DoSave_LGRP()

static void DoSave_LGRP ( LinkGraph lg)
static

Save a link graph.

Parameters
lgLinkGraph to be saved.

Definition at line 177 of file linkgraph_sl.cpp.

◆ GetLinkGraphDesc()

const SaveLoad* GetLinkGraphDesc ( )

Get a SaveLoad array for a link graph.

Returns
SaveLoad array for link graph.

Definition at line 31 of file linkgraph_sl.cpp.

References SLE_VAR.

◆ GetLinkGraphJobDesc()

const SaveLoad* GetLinkGraphJobDesc ( )

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.

Returns
Array of SaveLoad structs.

Definition at line 51 of file linkgraph_sl.cpp.

References SLE_VAR.

Referenced by DoSave_LGRJ().

◆ GetLinkGraphScheduleDesc()

const SaveLoad* GetLinkGraphScheduleDesc ( )

Get a SaveLoad array for the link graph schedule.

Returns
SaveLoad array for the link graph schedule.

Definition at line 99 of file linkgraph_sl.cpp.

References REF_LINK_GRAPH, REF_LINK_GRAPH_JOB, SLE_END, and SLE_LST.

Referenced by Load_LGRS(), Ptrs_LGRS(), and Save_LGRS().

◆ SaveLoad_LinkGraph()

void SaveLoad_LinkGraph ( LinkGraph lg)

Save/load a link graph.

Parameters
lgLink graph to be saved or loaded.

Definition at line 140 of file linkgraph_sl.cpp.

References _edge_desc, _node_desc, LinkGraph::edges, IsSavegameVersionBefore(), LinkGraph::nodes, LinkGraph::Size(), SlObject(), and SLV_191.

Variable Documentation

◆ _edge_desc

const SaveLoad _edge_desc[]
static
Initial value:
= {
SLE_VAR(Edge, capacity, SLE_UINT32),
SLE_VAR(Edge, usage, SLE_UINT32),
SLE_VAR(Edge, last_unrestricted_update, SLE_INT32),
SLE_CONDVAR(Edge, last_restricted_update, SLE_INT32, SLV_187, SL_MAX_VERSION),
SLE_VAR(Edge, next_edge, SLE_UINT16),
}

SaveLoad desc for a link graph edge.

Definition at line 126 of file linkgraph_sl.cpp.

Referenced by SaveLoad_LinkGraph().

◆ _linkgraph_chunk_handlers

const ChunkHandler _linkgraph_chunk_handlers[]
Initial value:
= {
{ 'LGRP', Save_LGRP, Load_LGRP, nullptr, nullptr, CH_ARRAY },
{ 'LGRJ', Save_LGRJ, Load_LGRJ, nullptr, nullptr, CH_ARRAY },
{ 'LGRS', Save_LGRS, Load_LGRS, Ptrs_LGRS, nullptr, CH_LAST }
}

◆ _node_desc

const SaveLoad _node_desc[]
static
Initial value:
= {
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),
}

SaveLoad desc for a link graph node.

Definition at line 114 of file linkgraph_sl.cpp.

Referenced by SaveLoad_LinkGraph().

SLV_187
@ SLV_187
187 25899 Linkgraph - restricted flows
Definition: saveload.h:267
Save_LGRS
static void Save_LGRS()
Save the link graph schedule.
Definition: linkgraph_sl.cpp:285
LinkGraph::Node
Updatable node class.
Definition: linkgraph.h:373
SL_MIN_VERSION
@ SL_MIN_VERSION
First savegame version.
Definition: saveload.h:31
Load_LGRS
static void Load_LGRS()
Load the link graph schedule.
Definition: linkgraph_sl.cpp:225
SLE_CONDVAR
#define SLE_CONDVAR(base, variable, type, from, to)
Storage of a variable in some savegame versions.
Definition: saveload.h:552
CH_LAST
@ CH_LAST
Last chunk in this array.
Definition: saveload.h:411
Load_LGRJ
static void Load_LGRJ()
Load all link graph jobs.
Definition: linkgraph_sl.cpp:205
SLE_CONDNULL
#define SLE_CONDNULL(length, from, to)
Empty space in some savegame versions.
Definition: saveload.h:678
LinkGraph::Edge
An updatable edge class.
Definition: linkgraph.h:292
Save_LGRJ
static void Save_LGRJ()
Save all link graph jobs.
Definition: linkgraph_sl.cpp:274
Save_LGRP
static void Save_LGRP()
Save all link graphs.
Definition: linkgraph_sl.cpp:263
SL_MAX_VERSION
@ SL_MAX_VERSION
Highest possible saveload version.
Definition: saveload.h:329
SLE_VAR
#define SLE_VAR(base, variable, type)
Storage of a variable in every version of a savegame.
Definition: saveload.h:622
Ptrs_LGRS
static void Ptrs_LGRS()
Substitute pointers in link graph schedule.
Definition: linkgraph_sl.cpp:293
SLV_191
@ SLV_191
191 26636 FS#6026 Fix disaster vehicle storage (No bump) 191 26646 FS#6041 Linkgraph - store location...
Definition: saveload.h:272
Load_LGRP
static void Load_LGRP()
Load all link graphs.
Definition: linkgraph_sl.cpp:187