# group_sl.cpp

Go to the documentation of this file.

    00001 /* $Id$ */
    00002
    00003 /*
    00004  * This file is part of OpenTTD.
    00005  * 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.
    00006  * 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.
    00007  * 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/>.
    00008  */
    00009
    00012 #include "../stdafx.h"
    00013 #include "../group.h"
    00014
    00015 #include "saveload.h"
    00016
    00017 static const SaveLoad _group_desc[] = {
    00018   SLE_CONDVAR(Group, name,           SLE_NAME,    0, 83),
    00019   SLE_CONDSTR(Group, name,           SLE_STR, 0, 84, SL_MAX_VERSION),
    00020   SLE_VAR(Group, num_vehicle,        SLE_UINT16),
    00021   SLE_VAR(Group, owner,              SLE_UINT8),
    00022   SLE_VAR(Group, vehicle_type,       SLE_UINT8),
    00023   SLE_VAR(Group, replace_protection, SLE_BOOL),
    00024   SLE_END()
    00025 };
    00026
    00027 static void Save_GRPS()
    00028 {
    00029   Group *g;
    00030
    00031   FOR_ALL_GROUPS(g) {
    00032     SlSetArrayIndex(g->index);
    00033     SlObject(g, _group_desc);
    00034   }
    00035 }
    00036
    00037
    00038 static void Load_GRPS()
    00039 {
    00040   int index;
    00041
    00042   while ((index = SlIterateArray()) != -1) {
    00043     Group *g = new (index) Group();
    00044     SlObject(g, _group_desc);
    00045   }
    00046 }
    00047
    00048 extern const ChunkHandler _group_chunk_handlers[] = {
    00049   { 'GRPS', Save_GRPS, Load_GRPS, NULL, NULL, CH_ARRAY | CH_LAST},
    00050 };