OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

subsidy_sl.cpp
Go to the documentation of this file.
1 /* $Id: subsidy_sl.cpp 26482 2014-04-23 20:13:33Z rubidium $ */
2
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
8 */
9
12 #include "../stdafx.h"
13 #include "../subsidy_base.h"
14
15 #include "saveload.h"
16
17 #include "../safeguards.h"
18
19 static const SaveLoad _subsidies_desc[] = {
20 SLE_VAR(Subsidy, cargo_type, SLE_UINT8),
21 SLE_VAR(Subsidy, remaining, SLE_UINT8),
22 SLE_CONDVAR(Subsidy, awarded, SLE_UINT8, 125, SL_MAX_VERSION),
23 SLE_CONDVAR(Subsidy, src_type, SLE_UINT8, 125, SL_MAX_VERSION),
24 SLE_CONDVAR(Subsidy, dst_type, SLE_UINT8, 125, SL_MAX_VERSION),
25 SLE_CONDVAR(Subsidy, src, SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
26 SLE_CONDVAR(Subsidy, src, SLE_UINT16, 5, SL_MAX_VERSION),
27 SLE_CONDVAR(Subsidy, dst, SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
28 SLE_CONDVAR(Subsidy, dst, SLE_UINT16, 5, SL_MAX_VERSION),
29 SLE_END()
30 };
31
32 static void Save_SUBS()
33 {
34 Subsidy *s;
35 FOR_ALL_SUBSIDIES(s) {
36 SlSetArrayIndex(s->index);
37 SlObject(s, _subsidies_desc);
38 }
39 }
40
41 static void Load_SUBS()
42 {
43 int index;
44 while ((index = SlIterateArray()) != -1) {
45 Subsidy *s = new (index) Subsidy();
46 SlObject(s, _subsidies_desc);
47 }
48 }
49
50 extern const ChunkHandler _subsidy_chunk_handlers[] = {
51 { 'SUBS', Save_SUBS, Load_SUBS, NULL, NULL, CH_ARRAY | CH_LAST},
52 };