Update readme.md
[openttd-joker.git] / src / saveload / subsidy_sl.cpp
blob4e70c49318a74408eb02e643e1b0b912e34ef4da
1 /* $Id: subsidy_sl.cpp 19973 2010-06-13 14:11:59Z frosch $ */
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 */
10 /** @file subsidy_sl.cpp Code handling saving and loading of subsidies */
12 #include "../stdafx.h"
13 #include "../subsidy_base.h"
15 #include "saveload.h"
17 #include "../safeguards.h"
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()
32 static void Save_SUBS()
34 Subsidy *s;
35 FOR_ALL_SUBSIDIES(s) {
36 SlSetArrayIndex(s->index);
37 SlObject(s, _subsidies_desc);
41 static void Load_SUBS()
43 int index;
44 while ((index = SlIterateArray()) != -1) {
45 Subsidy *s = new (index) Subsidy();
46 SlObject(s, _subsidies_desc);
50 extern const ChunkHandler _subsidy_chunk_handlers[] = {
51 { 'SUBS', Save_SUBS, Load_SUBS, nullptr, nullptr, CH_ARRAY | CH_LAST},