# goal_sl.cpp

Go to the documentation of this file.

    00001 /* $Id: goal_sl.cpp 26596 2014-05-18 11:26:09Z frosch $ */
    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_FILE_U16 | SLE_VAR_U8),
    00019       SLE_VAR(Goal, type,      SLE_FILE_U16 | SLE_VAR_U8),
    00020       SLE_VAR(Goal, dst,       SLE_UINT32),
    00021       SLE_STR(Goal, text,      SLE_STR | SLF_ALLOW_CONTROL, 0),
    00022   SLE_CONDSTR(Goal, progress,  SLE_STR | SLF_ALLOW_CONTROL, 0, 182, SL_MAX_VERSION),
    00023   SLE_CONDVAR(Goal, completed, SLE_BOOL, 182, SL_MAX_VERSION),
    00024       SLE_END()
    00025 };
    00026
    00027 static void Save_GOAL()
    00028 {
    00029   Goal *s;
    00030   FOR_ALL_GOALS(s) {
    00031     SlSetArrayIndex(s->index);
    00032     SlObject(s, _goals_desc);
    00033   }
    00034 }
    00035
    00036 static void Load_GOAL()
    00037 {
    00038   int index;
    00039   while ((index = SlIterateArray()) != -1) {
    00040     Goal *s = new (index) Goal();
    00041     SlObject(s, _goals_desc);
    00042   }
    00043 }
    00044
    00045 extern const ChunkHandler _goal_chunk_handlers[] = {
    00046   { 'GOAL', Save_GOAL, Load_GOAL, NULL, NULL, CH_ARRAY | CH_LAST},
    00047 };