summaryrefslogtreecommitdiff
path: root/src/saveload/tunnel_sl.cpp
blob: 7ad37b12b902ca20c797d181460c0cd34488d4d7 (plain)
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
/* $Id$ */

/*
 * 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 tunnel_sl.cpp Code handling saving and loading of tunnels */

#include "../stdafx.h"
#include "../tunnel_base.h"

#include "saveload.h"

#include "../safeguards.h"


static const SaveLoad _tunnel_desc[] = {
	 SLE_CONDVAR(Tunnel, tile_n,           SLE_UINT32,             SLV_196, SL_MAX_VERSION),
	 SLE_CONDVAR(Tunnel, tile_s,           SLE_UINT32,             SLV_196, SL_MAX_VERSION),
	 SLE_CONDVAR(Tunnel, is_chunnel,         SLE_BOOL,             SLV_196, SL_MAX_VERSION),
	 SLE_END()
};

static void Save_TUNN()
{
	for(Tunnel *tunnel : Tunnel::Iterate()) {
		SlSetArrayIndex(tunnel->index);
		SlObject(tunnel, _tunnel_desc);
	}
}

static void Load_TUNN()
{
	int index;

	while ((index = SlIterateArray()) != -1) {
		Tunnel *tunnel = new (index) Tunnel();
		SlObject(tunnel, _tunnel_desc);
	}
}


extern const ChunkHandler _tunnel_chunk_handlers[] = {
	{ 'TUNN', Save_TUNN, Load_TUNN, nullptr, nullptr, CH_ARRAY | CH_LAST},
};