# subsidy_sl.cpp

Go to the documentation of this file.

    00001 /* $Id: subsidy_sl.cpp 19973 2010-06-13 14:11:59Z 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 "../subsidy_base.h"
    00014
    00015 #include "saveload.h"
    00016
    00017 static const SaveLoad _subsidies_desc[] = {
    00018       SLE_VAR(Subsidy, cargo_type, SLE_UINT8),
    00019       SLE_VAR(Subsidy, remaining,  SLE_UINT8),
    00020   SLE_CONDVAR(Subsidy, awarded,    SLE_UINT8,                 125, SL_MAX_VERSION),
    00021   SLE_CONDVAR(Subsidy, src_type,   SLE_UINT8,                 125, SL_MAX_VERSION),
    00022   SLE_CONDVAR(Subsidy, dst_type,   SLE_UINT8,                 125, SL_MAX_VERSION),
    00023   SLE_CONDVAR(Subsidy, src,        SLE_FILE_U8 | SLE_VAR_U16,   0, 4),
    00024   SLE_CONDVAR(Subsidy, src,        SLE_UINT16,                  5, SL_MAX_VERSION),
    00025   SLE_CONDVAR(Subsidy, dst,        SLE_FILE_U8 | SLE_VAR_U16,   0, 4),
    00026   SLE_CONDVAR(Subsidy, dst,        SLE_UINT16,                  5, SL_MAX_VERSION),
    00027   SLE_END()
    00028 };
    00029
    00030 static void Save_SUBS()
    00031 {
    00032   Subsidy *s;
    00033   FOR_ALL_SUBSIDIES(s) {
    00034     SlSetArrayIndex(s->index);
    00035     SlObject(s, _subsidies_desc);
    00036   }
    00037 }
    00038
    00039 static void Load_SUBS()
    00040 {
    00041   int index;
    00042   while ((index = SlIterateArray()) != -1) {
    00043     Subsidy *s = new (index) Subsidy();
    00044     SlObject(s, _subsidies_desc);
    00045   }
    00046 }
    00047
    00048 extern const ChunkHandler _subsidy_chunk_handlers[] = {
    00049   { 'SUBS', Save_SUBS, Load_SUBS, NULL, NULL, CH_ARRAY | CH_LAST},
    00050 };