(svn r27985) -Codechange: Convert VA2 switches into ones with non-overlapping ranges...
[openttd.git] / src / saveload / group_sl.cpp
blob93734f80f65d5ce971f04bf456d84e97a9348093
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 group_sl.cpp Code handling saving and loading of economy data */
12 #include "../stdafx.h"
13 #include "../group.h"
15 #include "saveload.h"
17 #include "../safeguards.h"
19 static const SaveLoad _group_desc[] = {
20 SLE_CONDVAR(Group, name, SLE_NAME, 0, 83),
21 SLE_CONDSTR(Group, name, SLE_STR | SLF_ALLOW_CONTROL, 0, 84, SL_MAX_VERSION),
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()
30 static void Save_GRPS()
32 Group *g;
34 FOR_ALL_GROUPS(g) {
35 SlSetArrayIndex(g->index);
36 SlObject(g, _group_desc);
41 static void Load_GRPS()
43 int index;
45 while ((index = SlIterateArray()) != -1) {
46 Group *g = new (index) Group();
47 SlObject(g, _group_desc);
49 if (IsSavegameVersionBefore(189)) g->parent = INVALID_GROUP;
53 extern const ChunkHandler _group_chunk_handlers[] = {
54 { 'GRPS', Save_GRPS, Load_GRPS, NULL, NULL, CH_ARRAY | CH_LAST},