# cargopacket_sl.cpp

Go to the documentation of this file.

    00001 /* $Id: cargopacket_sl.cpp 16742 2009-07-04 17:39:00Z rubidium $ */
    00002
    00005 #include "../stdafx.h"
    00006 #include "../cargopacket.h"
    00007
    00008 #include "saveload.h"
    00009
    00010 static const SaveLoad _cargopacket_desc[] = {
    00011        SLE_VAR(CargoPacket, source,          SLE_UINT16),
    00012        SLE_VAR(CargoPacket, source_xy,       SLE_UINT32),
    00013        SLE_VAR(CargoPacket, loaded_at_xy,    SLE_UINT32),
    00014        SLE_VAR(CargoPacket, count,           SLE_UINT16),
    00015        SLE_VAR(CargoPacket, days_in_transit, SLE_UINT8),
    00016        SLE_VAR(CargoPacket, feeder_share,    SLE_INT64),
    00017
    00018   /* Used to be paid_for, but that got changed. */
    00019   SLE_CONDNULL(1, 0, 120),
    00020
    00021   SLE_END()
    00022 };
    00023
    00024 static void Save_CAPA()
    00025 {
    00026   CargoPacket *cp;
    00027
    00028   FOR_ALL_CARGOPACKETS(cp) {
    00029     SlSetArrayIndex(cp->index);
    00030     SlObject(cp, _cargopacket_desc);
    00031   }
    00032 }
    00033
    00034 static void Load_CAPA()
    00035 {
    00036   int index;
    00037
    00038   while ((index = SlIterateArray()) != -1) {
    00039     CargoPacket *cp = new (index) CargoPacket();
    00040     SlObject(cp, _cargopacket_desc);
    00041   }
    00042 }
    00043
    00044 extern const ChunkHandler _cargopacket_chunk_handlers[] = {
    00045   { 'CAPA', Save_CAPA, Load_CAPA, CH_ARRAY | CH_LAST},
    00046 };