2009-01-04 15:32:25 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* 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.
|
|
|
|
* 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.
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2009-01-04 15:32:25 +00:00
|
|
|
/** @file group_sl.cpp Code handling saving and loading of economy data */
|
|
|
|
|
|
|
|
#include "../stdafx.h"
|
|
|
|
#include "../group.h"
|
|
|
|
|
|
|
|
#include "saveload.h"
|
|
|
|
|
|
|
|
static const SaveLoad _group_desc[] = {
|
|
|
|
SLE_CONDVAR(Group, name, SLE_NAME, 0, 83),
|
|
|
|
SLE_CONDSTR(Group, name, SLE_STR, 0, 84, SL_MAX_VERSION),
|
|
|
|
SLE_VAR(Group, num_vehicle, SLE_UINT16),
|
|
|
|
SLE_VAR(Group, owner, SLE_UINT8),
|
|
|
|
SLE_VAR(Group, vehicle_type, SLE_UINT8),
|
|
|
|
SLE_VAR(Group, replace_protection, SLE_BOOL),
|
|
|
|
SLE_END()
|
|
|
|
};
|
|
|
|
|
2009-05-21 22:43:25 +00:00
|
|
|
static void Save_GRPS()
|
2009-01-04 15:32:25 +00:00
|
|
|
{
|
|
|
|
Group *g;
|
|
|
|
|
|
|
|
FOR_ALL_GROUPS(g) {
|
|
|
|
SlSetArrayIndex(g->index);
|
|
|
|
SlObject(g, _group_desc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-05-21 22:43:25 +00:00
|
|
|
static void Load_GRPS()
|
2009-01-04 15:32:25 +00:00
|
|
|
{
|
|
|
|
int index;
|
|
|
|
|
|
|
|
while ((index = SlIterateArray()) != -1) {
|
|
|
|
Group *g = new (index) Group();
|
|
|
|
SlObject(g, _group_desc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extern const ChunkHandler _group_chunk_handlers[] = {
|
2009-05-17 16:28:29 +00:00
|
|
|
{ 'GRPS', Save_GRPS, Load_GRPS, NULL, CH_ARRAY | CH_LAST},
|
2009-01-04 15:32:25 +00:00
|
|
|
};
|