OpenTTD
group_sl.cpp
Go to the documentation of this file.
1 /* $Id: group_sl.cpp 26482 2014-04-23 20:13:33Z rubidium $ */
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 "../group.h"
14 
15 #include "saveload.h"
16 
17 #include "../safeguards.h"
18 
19 static const SaveLoad _group_desc[] = {
20  SLE_CONDVAR(Group, name, SLE_NAME, 0, 83),
22  SLE_CONDNULL(2, 0, 163), // num_vehicle
23  SLE_VAR(Group, owner, SLE_UINT8),
24  SLE_VAR(Group, vehicle_type, SLE_UINT8),
25  SLE_VAR(Group, replace_protection, SLE_BOOL),
26  SLE_CONDVAR(Group, parent, SLE_UINT16, 189, SL_MAX_VERSION),
27  SLE_END()
28 };
29 
30 static void Save_GRPS()
31 {
32  Group *g;
33 
34  FOR_ALL_GROUPS(g) {
35  SlSetArrayIndex(g->index);
36  SlObject(g, _group_desc);
37  }
38 }
39 
40 
41 static void Load_GRPS()
42 {
43  int index;
44 
45  while ((index = SlIterateArray()) != -1) {
46  Group *g = new (index) Group();
47  SlObject(g, _group_desc);
48 
50  }
51 }
52 
53 extern const ChunkHandler _group_chunk_handlers[] = {
54  { 'GRPS', Save_GRPS, Load_GRPS, NULL, NULL, CH_ARRAY | CH_LAST},
55 };