1 /* $Id: group_sl.cpp 24878 2013-01-01 11:08:22Z rubidium $ */
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/>.
10 /** @file group_sl.cpp Code handling saving and loading of economy data */
12 #include "../stdafx.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_PATCH_PACK
-1),
27 SLE_CONDVAR(Group
, parent
, SLE_UINT16
, SL_PATCH_PACK_1_3
, SL_MAX_VERSION
),
31 static void Save_GRPS()
36 SlSetArrayIndex(g
->index
);
37 SlObject(g
, _group_desc
);
42 static void Load_GRPS()
46 while ((index
= SlIterateArray()) != -1) {
47 Group
*g
= new (index
) Group();
48 SlObject(g
, _group_desc
);
50 if (IsSavegameVersionBefore(189) || IsPatchPackSavegameVersionBefore(SL_PATCH_PACK_1_3
)) {
51 g
->parent
= INVALID_GROUP
;
56 extern const ChunkHandler _group_chunk_handlers
[] = {
57 { 'GRPS', Save_GRPS
, Load_GRPS
, NULL
, NULL
, CH_ARRAY
| CH_LAST
},