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/>.
10 /** @file goal_sl.cpp Code handling saving and loading of goals */
12 #include "../stdafx.h"
13 #include "../goal_base.h"
17 #include "../safeguards.h"
19 static const SaveLoad _goals_desc
[] = {
20 SLE_VAR(Goal
, company
, SLE_FILE_U16
| SLE_VAR_U8
),
21 SLE_VAR(Goal
, type
, SLE_FILE_U16
| SLE_VAR_U8
),
22 SLE_VAR(Goal
, dst
, SLE_UINT32
),
23 SLE_STR(Goal
, text
, SLE_STR
| SLF_ALLOW_CONTROL
, 0),
24 SLE_CONDSTR(Goal
, progress
, SLE_STR
| SLF_ALLOW_CONTROL
, 0, SLV_182
, SL_MAX_VERSION
),
25 SLE_CONDVAR(Goal
, completed
, SLE_BOOL
, SLV_182
, SL_MAX_VERSION
),
29 static void Save_GOAL()
33 SlSetArrayIndex(s
->index
);
34 SlObject(s
, _goals_desc
);
38 static void Load_GOAL()
41 while ((index
= SlIterateArray()) != -1) {
42 Goal
*s
= new (index
) Goal();
43 SlObject(s
, _goals_desc
);
47 extern const ChunkHandler _goal_chunk_handlers
[] = {
48 { 'GOAL', Save_GOAL
, Load_GOAL
, nullptr, nullptr, CH_ARRAY
| CH_LAST
},