Add: Overlay cargo icon in vehicle/depot list when holding shift+ctrl. (#12938)
[openttd-github.git] / src / saveload / goal_sl.cpp
blob003e92b20f355346ee85c196a0cf10b70da79fa6
1 /*
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/>.
6 */
8 /** @file goal_sl.cpp Code handling saving and loading of goals */
10 #include "../stdafx.h"
12 #include "saveload.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);
45 int index;
46 while ((index = SlIterateArray()) != -1) {
47 Goal *s = new (index) Goal();
48 SlObject(s, slt);
53 static const GOALChunkHandler GOAL;
54 static const ChunkHandlerRef goal_chunk_handlers[] = {
55 GOAL,
58 extern const ChunkHandlerTable _goal_chunk_handlers(goal_chunk_handlers);