group_sl.cpp

Go to the documentation of this file.
00001 /* $Id: group_sl.cpp 15903 2009-03-30 23:15:05Z rubidium $ */
00002 
00005 #include "../stdafx.h"
00006 #include "../group.h"
00007 
00008 #include "saveload.h"
00009 
00010 static const SaveLoad _group_desc[] = {
00011   SLE_CONDVAR(Group, name,           SLE_NAME,    0, 83),
00012   SLE_CONDSTR(Group, name,           SLE_STR, 0, 84, SL_MAX_VERSION),
00013   SLE_VAR(Group, num_vehicle,        SLE_UINT16),
00014   SLE_VAR(Group, owner,              SLE_UINT8),
00015   SLE_VAR(Group, vehicle_type,       SLE_UINT8),
00016   SLE_VAR(Group, replace_protection, SLE_BOOL),
00017   SLE_END()
00018 };
00019 
00020 static void Save_GRPS(void)
00021 {
00022   Group *g;
00023 
00024   FOR_ALL_GROUPS(g) {
00025     SlSetArrayIndex(g->index);
00026     SlObject(g, _group_desc);
00027   }
00028 }
00029 
00030 
00031 static void Load_GRPS(void)
00032 {
00033   int index;
00034 
00035   while ((index = SlIterateArray()) != -1) {
00036     Group *g = new (index) Group();
00037     SlObject(g, _group_desc);
00038   }
00039 }
00040 
00041 extern const ChunkHandler _group_chunk_handlers[] = {
00042   { 'GRPS', Save_GRPS, Load_GRPS, CH_ARRAY | CH_LAST},
00043 };

Generated on Mon Dec 14 21:00:02 2009 for OpenTTD by  doxygen 1.5.6