goal_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 "../goal_base.h"
00014 
00015 #include "saveload.h"
00016 
00017 static const SaveLoad _goals_desc[] = {
00018       SLE_VAR(Goal, company, SLE_UINT16),
00019       SLE_VAR(Goal, type,    SLE_UINT16),
00020       SLE_VAR(Goal, dst,     SLE_UINT32),
00021       SLE_STR(Goal, text,    SLE_STR | SLF_ALLOW_CONTROL, 0),
00022       SLE_END()
00023 };
00024 
00025 static void Save_GOAL()
00026 {
00027   Goal *s;
00028   FOR_ALL_GOALS(s) {
00029     SlSetArrayIndex(s->index);
00030     SlObject(s, _goals_desc);
00031   }
00032 }
00033 
00034 static void Load_GOAL()
00035 {
00036   int index;
00037   while ((index = SlIterateArray()) != -1) {
00038     Goal *s = new (index) Goal();
00039     SlObject(s, _goals_desc);
00040   }
00041 }
00042 
00043 extern const ChunkHandler _goal_chunk_handlers[] = {
00044   { 'GOAL', Save_GOAL, Load_GOAL, NULL, NULL, CH_ARRAY | CH_LAST},
00045 };