# depot_sl.cpp

Go to the documentation of this file.

    00001 /* $Id: depot_sl.cpp 17248 2009-08-21 20:21:05Z rubidium $ */
    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 "../depot_base.h"
    00014
    00015 #include "saveload.h"
    00016
    00017 static const SaveLoad _depot_desc[] = {
    00018   SLE_CONDVAR(Depot, xy,         SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
    00019   SLE_CONDVAR(Depot, xy,         SLE_UINT32,                 6, SL_MAX_VERSION),
    00020       SLE_VAR(Depot, town_index, SLE_UINT16),
    00021   SLE_END()
    00022 };
    00023
    00024 static void Save_DEPT()
    00025 {
    00026   Depot *depot;
    00027
    00028   FOR_ALL_DEPOTS(depot) {
    00029     SlSetArrayIndex(depot->index);
    00030     SlObject(depot, _depot_desc);
    00031   }
    00032 }
    00033
    00034 static void Load_DEPT()
    00035 {
    00036   int index;
    00037
    00038   while ((index = SlIterateArray()) != -1) {
    00039     Depot *depot = new (index) Depot();
    00040     SlObject(depot, _depot_desc);
    00041   }
    00042 }
    00043
    00044 extern const ChunkHandler _depot_chunk_handlers[] = {
    00045   { 'DEPT', Save_DEPT, Load_DEPT, NULL, CH_ARRAY | CH_LAST},
    00046 };