Codechange: Use null pointer literal instead of the NULL macro
[openttd-github.git] / src / saveload / goal_sl.cpp
blobb636dcf6a288748bc59b20e4e04fa113313ecf1c
1 /* $Id$ */
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 goal_sl.cpp Code handling saving and loading of goals */
12 #include "../stdafx.h"
13 #include "../goal_base.h"
15 #include "saveload.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),
26 SLE_END()
29 static void Save_GOAL()
31 Goal *s;
32 FOR_ALL_GOALS(s) {
33 SlSetArrayIndex(s->index);
34 SlObject(s, _goals_desc);
38 static void Load_GOAL()
40 int index;
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},