# subsidy_sl.cpp

Go to the documentation of this file.

    00001 /* $Id: subsidy_sl.cpp 15027 2009-01-12 17:11:45Z truebrain $ */
    00002
    00005 #include "../stdafx.h"
    00006 #include "../economy_func.h"
    00007
    00008 #include "saveload.h"
    00009
    00010 static const SaveLoad _subsidies_desc[] = {
    00011       SLE_VAR(Subsidy, cargo_type, SLE_UINT8),
    00012       SLE_VAR(Subsidy, age,        SLE_UINT8),
    00013   SLE_CONDVAR(Subsidy, from,       SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
    00014   SLE_CONDVAR(Subsidy, from,       SLE_UINT16,                5, SL_MAX_VERSION),
    00015   SLE_CONDVAR(Subsidy, to,         SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
    00016   SLE_CONDVAR(Subsidy, to,         SLE_UINT16,                5, SL_MAX_VERSION),
    00017   SLE_END()
    00018 };
    00019
    00020 void Save_SUBS()
    00021 {
    00022   int i;
    00023   Subsidy *s;
    00024
    00025   for (i = 0; i != lengthof(_subsidies); i++) {
    00026     s = &_subsidies[i];
    00027     if (s->cargo_type != CT_INVALID) {
    00028       SlSetArrayIndex(i);
    00029       SlObject(s, _subsidies_desc);
    00030     }
    00031   }
    00032 }
    00033
    00034 void Load_SUBS()
    00035 {
    00036   int index;
    00037   while ((index = SlIterateArray()) != -1)
    00038     SlObject(&_subsidies[index], _subsidies_desc);
    00039 }
    00040
    00041 extern const ChunkHandler _subsidy_chunk_handlers[] = {
    00042   { 'SUBS', Save_SUBS,     Load_SUBS,     CH_ARRAY | CH_LAST},
    00043 };