Changeset - r25680:619a6509d944
[Not reviewed]
master
0 1 0
Patric Stout - 3 years ago 2021-06-14 12:03:03
truebrain@openttd.org
Codechange: move Save/Load functions of same chunk next to each other
1 file changed with 69 insertions and 69 deletions:
0 comments (0 inline, 0 general)
src/saveload/linkgraph_sl.cpp
Show inline comments
 
@@ -144,75 +144,6 @@ void SaveLoad_LinkGraph(LinkGraph &lg)
 
}
 

	
 
/**
 
 * Save a link graph job.
 
 * @param lgj LinkGraphJob to be saved.
 
 */
 
static void DoSave_LGRJ(LinkGraphJob *lgj)
 
{
 
	SlObject(lgj, GetLinkGraphJobDesc());
 
	_num_nodes = lgj->Size();
 
	SlObject(const_cast<LinkGraph *>(&lgj->Graph()), GetLinkGraphDesc());
 
	SaveLoad_LinkGraph(const_cast<LinkGraph &>(lgj->Graph()));
 
}
 

	
 
/**
 
 * Save a link graph.
 
 * @param lg LinkGraph to be saved.
 
 */
 
static void DoSave_LGRP(LinkGraph *lg)
 
{
 
	_num_nodes = lg->Size();
 
	SlObject(lg, GetLinkGraphDesc());
 
	SaveLoad_LinkGraph(*lg);
 
}
 

	
 
/**
 
 * Load all link graphs.
 
 */
 
static void Load_LGRP()
 
{
 
	int index;
 
	while ((index = SlIterateArray()) != -1) {
 
		if (!LinkGraph::CanAllocateItem()) {
 
			/* Impossible as they have been present in previous game. */
 
			NOT_REACHED();
 
		}
 
		LinkGraph *lg = new (index) LinkGraph();
 
		SlObject(lg, GetLinkGraphDesc());
 
		lg->Init(_num_nodes);
 
		SaveLoad_LinkGraph(*lg);
 
	}
 
}
 

	
 
/**
 
 * Load all link graph jobs.
 
 */
 
static void Load_LGRJ()
 
{
 
	int index;
 
	while ((index = SlIterateArray()) != -1) {
 
		if (!LinkGraphJob::CanAllocateItem()) {
 
			/* Impossible as they have been present in previous game. */
 
			NOT_REACHED();
 
		}
 
		LinkGraphJob *lgj = new (index) LinkGraphJob();
 
		SlObject(lgj, GetLinkGraphJobDesc());
 
		LinkGraph &lg = const_cast<LinkGraph &>(lgj->Graph());
 
		SlObject(&lg, GetLinkGraphDesc());
 
		lg.Init(_num_nodes);
 
		SaveLoad_LinkGraph(lg);
 
	}
 
}
 

	
 
/**
 
 * Load the link graph schedule.
 
 */
 
static void Load_LGRS()
 
{
 
	SlObject(&LinkGraphSchedule::instance, GetLinkGraphScheduleDesc());
 
}
 

	
 
/**
 
 * Spawn the threads for running link graph calculations.
 
 * Has to be done after loading as the cargo classes might have changed.
 
 */
 
@@ -243,6 +174,17 @@ void AfterLoadLinkGraphs()
 
}
 

	
 
/**
 
 * Save a link graph.
 
 * @param lg LinkGraph to be saved.
 
 */
 
static void DoSave_LGRP(LinkGraph *lg)
 
{
 
	_num_nodes = lg->Size();
 
	SlObject(lg, GetLinkGraphDesc());
 
	SaveLoad_LinkGraph(*lg);
 
}
 

	
 
/**
 
 * Save all link graphs.
 
 */
 
static void Save_LGRP()
 
@@ -254,6 +196,36 @@ static void Save_LGRP()
 
}
 

	
 
/**
 
 * Load all link graphs.
 
 */
 
static void Load_LGRP()
 
{
 
	int index;
 
	while ((index = SlIterateArray()) != -1) {
 
		if (!LinkGraph::CanAllocateItem()) {
 
			/* Impossible as they have been present in previous game. */
 
			NOT_REACHED();
 
		}
 
		LinkGraph *lg = new (index) LinkGraph();
 
		SlObject(lg, GetLinkGraphDesc());
 
		lg->Init(_num_nodes);
 
		SaveLoad_LinkGraph(*lg);
 
	}
 
}
 

	
 
/**
 
 * Save a link graph job.
 
 * @param lgj LinkGraphJob to be saved.
 
 */
 
static void DoSave_LGRJ(LinkGraphJob *lgj)
 
{
 
	SlObject(lgj, GetLinkGraphJobDesc());
 
	_num_nodes = lgj->Size();
 
	SlObject(const_cast<LinkGraph *>(&lgj->Graph()), GetLinkGraphDesc());
 
	SaveLoad_LinkGraph(const_cast<LinkGraph &>(lgj->Graph()));
 
}
 

	
 
/**
 
 * Save all link graph jobs.
 
 */
 
static void Save_LGRJ()
 
@@ -265,6 +237,26 @@ static void Save_LGRJ()
 
}
 

	
 
/**
 
 * Load all link graph jobs.
 
 */
 
static void Load_LGRJ()
 
{
 
	int index;
 
	while ((index = SlIterateArray()) != -1) {
 
		if (!LinkGraphJob::CanAllocateItem()) {
 
			/* Impossible as they have been present in previous game. */
 
			NOT_REACHED();
 
		}
 
		LinkGraphJob *lgj = new (index) LinkGraphJob();
 
		SlObject(lgj, GetLinkGraphJobDesc());
 
		LinkGraph &lg = const_cast<LinkGraph &>(lgj->Graph());
 
		SlObject(&lg, GetLinkGraphDesc());
 
		lg.Init(_num_nodes);
 
		SaveLoad_LinkGraph(lg);
 
	}
 
}
 

	
 
/**
 
 * Save the link graph schedule.
 
 */
 
static void Save_LGRS()
 
@@ -273,6 +265,14 @@ static void Save_LGRS()
 
}
 

	
 
/**
 
 * Load the link graph schedule.
 
 */
 
static void Load_LGRS()
 
{
 
	SlObject(&LinkGraphSchedule::instance, GetLinkGraphScheduleDesc());
 
}
 

	
 
/**
 
 * Substitute pointers in link graph schedule.
 
 */
 
static void Ptrs_LGRS()
0 comments (0 inline, 0 general)