2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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 /** @file goal_sl.cpp Code handling saving and loading of goals */
10 #include "../stdafx.h"
13 #include "compat/goal_sl_compat.h"
15 #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_SSTR(Goal
, text
, SLE_STR
| SLF_ALLOW_CONTROL
),
24 SLE_CONDSSTR(Goal
, progress
, SLE_STR
| SLF_ALLOW_CONTROL
, SLV_182
, SL_MAX_VERSION
),
25 SLE_CONDVAR(Goal
, completed
, SLE_BOOL
, SLV_182
, SL_MAX_VERSION
),
28 struct GOALChunkHandler
: ChunkHandler
{
29 GOALChunkHandler() : ChunkHandler('GOAL', CH_TABLE
) {}
31 void Save() const override
33 SlTableHeader(_goals_desc
);
35 for (Goal
*s
: Goal::Iterate()) {
36 SlSetArrayIndex(s
->index
);
37 SlObject(s
, _goals_desc
);
41 void Load() const override
43 const std::vector
<SaveLoad
> slt
= SlCompatTableHeader(_goals_desc
, _goals_sl_compat
);
46 while ((index
= SlIterateArray()) != -1) {
47 Goal
*s
= new (index
) Goal();
53 static const GOALChunkHandler GOAL
;
54 static const ChunkHandlerRef goal_chunk_handlers
[] = {
58 extern const ChunkHandlerTable
_goal_chunk_handlers(goal_chunk_handlers
);