Code handling saving and loading of link graphs. More...
#include "../stdafx.h"
#include "../linkgraph/linkgraph.h"
#include "../linkgraph/linkgraphjob.h"
#include "../linkgraph/linkgraphschedule.h"
#include "../settings_internal.h"
#include "saveload.h"
Go to the source code of this file.
Typedefs | |
typedef LinkGraph::BaseNode | Node |
typedef LinkGraph::BaseEdge | Edge |
Functions | |
const SettingDesc * | GetSettingDescription (uint index) |
const SaveLoad * | GetLinkGraphDesc () |
Get a SaveLoad array for a link graph. | |
const SaveLoad * | GetLinkGraphJobDesc () |
Get a SaveLoad array for a link graph job. | |
const SaveLoad * | GetLinkGraphScheduleDesc () |
Get a SaveLoad array for the link graph schedule. | |
void | SaveLoad_LinkGraph (LinkGraph &lg) |
Save/load a link graph. | |
static void | DoSave_LGRJ (LinkGraphJob *lgj) |
Save a link graph job. | |
static void | DoSave_LGRP (LinkGraph *lg) |
Save a link graph. | |
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. | |
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 uint | _num_nodes |
static const SaveLoad | _node_desc [] |
SaveLoad desc for a link graph node. | |
static const SaveLoad | _edge_desc [] |
SaveLoad desc for a link graph edge. | |
const ChunkHandler | _linkgraph_chunk_handlers [] |
Code handling saving and loading of link graphs.
Definition in file linkgraph_sl.cpp.
void AfterLoadLinkGraphs | ( | ) |
Spawn the threads for running link graph calculations.
Has to be done after loading as the cargo classes might have changed.
Definition at line 218 of file linkgraph_sl.cpp.
References LinkGraphSchedule::Instance(), and LinkGraphSchedule::SpawnAll().
Referenced by AfterLoadGame().
static void DoSave_LGRJ | ( | LinkGraphJob * | lgj | ) | [static] |
Save a link graph job.
lgj | LinkGraphJob to be saved. |
Definition at line 149 of file linkgraph_sl.cpp.
References GetLinkGraphDesc(), GetLinkGraphJobDesc(), LinkGraphJob::Graph(), SaveLoad_LinkGraph(), LinkGraphJob::Size(), and SlObject().
Referenced by Save_LGRJ().
static void DoSave_LGRP | ( | LinkGraph * | lg | ) | [static] |
Save a link graph.
lg | LinkGraph to be saved. |
Definition at line 161 of file linkgraph_sl.cpp.
References GetLinkGraphDesc(), SaveLoad_LinkGraph(), LinkGraph::Size(), and SlObject().
Referenced by Save_LGRP().
const SaveLoad* GetLinkGraphDesc | ( | ) |
Get a SaveLoad array for a link graph.
Definition at line 30 of file linkgraph_sl.cpp.
References SL_MAX_VERSION, SLE_CONDVAR, SLE_END, and SLEG_CONDVAR.
Referenced by DoSave_LGRJ(), DoSave_LGRP(), Load_LGRJ(), and Load_LGRP().
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.
Definition at line 50 of file linkgraph_sl.cpp.
References SaveLoad::address, SmallVector< T, S >::Append(), SaveLoad::cmd, SettingDesc::desc, SmallVector< T, S >::Length(), SettingDescBase::name, SettingDesc::save, SL_MAX_VERSION, SLE_CONDVAR, and SLE_END.
Referenced by DoSave_LGRJ(), and Load_LGRJ().
const SaveLoad* GetLinkGraphScheduleDesc | ( | ) |
Get a SaveLoad array for the link graph schedule.
Definition at line 94 of file linkgraph_sl.cpp.
References REF_LINK_GRAPH, REF_LINK_GRAPH_JOB, SL_MAX_VERSION, SLE_CONDLST, and SLE_END.
Referenced by Load_LGRS(), Ptrs_LGRS(), and Save_LGRS().
void SaveLoad_LinkGraph | ( | LinkGraph & | lg | ) |
Save/load a link graph.
comp | Link graph to be saved or loaded. |
Definition at line 133 of file linkgraph_sl.cpp.
References LinkGraph::edges, LinkGraph::nodes, LinkGraph::Size(), and SlObject().
Referenced by DoSave_LGRJ(), DoSave_LGRP(), Load_LGRJ(), and Load_LGRP().
const SaveLoad _edge_desc[] [static] |
{ SLE_CONDVAR(Edge, distance, SLE_UINT32, SL_LINKGRAPH_JOB, SL_MAX_VERSION), SLE_CONDVAR(Edge, capacity, SLE_UINT32, SL_LINKGRAPH_JOB, SL_MAX_VERSION), SLE_CONDVAR(Edge, usage, SLE_UINT32, SL_LINKGRAPH_JOB, SL_MAX_VERSION), SLE_CONDVAR(Edge, last_update, SLE_UINT32, SL_LINKGRAPH_JOB, SL_MAX_VERSION), SLE_CONDVAR(Edge, next_edge, SLE_UINT16, SL_LINKGRAPH_JOB, SL_MAX_VERSION), }
SaveLoad desc for a link graph edge.
Definition at line 120 of file linkgraph_sl.cpp.
const ChunkHandler _linkgraph_chunk_handlers[] |
{ { 'LGRP', Save_LGRP, Load_LGRP, NULL, NULL, CH_ARRAY}, { 'LGRJ', Save_LGRJ, Load_LGRJ, NULL, NULL, CH_ARRAY}, { 'LGRS', Save_LGRS, Load_LGRS, Ptrs_LGRS, NULL, CH_LAST}, }
const SaveLoad _node_desc[] [static] |
{ SLE_CONDVAR(Node, supply, SLE_UINT32, SL_LINKGRAPH_JOB, SL_MAX_VERSION), SLE_CONDVAR(Node, demand, SLE_UINT32, SL_LINKGRAPH_JOB, SL_MAX_VERSION), SLE_CONDVAR(Node, station, SLE_UINT16, SL_LINKGRAPH_JOB, SL_MAX_VERSION), SLE_CONDVAR(Node, last_update, SLE_UINT32, SL_LINKGRAPH_JOB, SL_MAX_VERSION), }
SaveLoad desc for a link graph node.
Definition at line 109 of file linkgraph_sl.cpp.