OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

goal_sl.cpp
Go to the documentation of this file.
1 /* $Id: goal_sl.cpp 26593 2014-05-17 17:18:07Z frosch $ */
2
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 */
9
12 #include "../stdafx.h"
13 #include "../goal_base.h"
14
15 #include "saveload.h"
16
17 #include "../safeguards.h"
18
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, 182, SL_MAX_VERSION),
25 SLE_CONDVAR(Goal, completed, SLE_BOOL, 182, SL_MAX_VERSION),
26 SLE_END()
27 };
28
29 static void Save_GOAL()
30 {
31 Goal *s;
32 FOR_ALL_GOALS(s) {
33 SlSetArrayIndex(s->index);
34 SlObject(s, _goals_desc);
35 }
36 }
37
38 static void Load_GOAL()
39 {
40 int index;
41 while ((index = SlIterateArray()) != -1) {
42 Goal *s = new (index) Goal();
43 SlObject(s, _goals_desc);
44 }
45 }
46
47 extern const ChunkHandler _goal_chunk_handlers[] = {
48 { 'GOAL', Save_GOAL, Load_GOAL, NULL, NULL, CH_ARRAY | CH_LAST},
49 };