# autoreplace_sl.cpp

Go to the documentation of this file.

    00001 /* $Id: autoreplace_sl.cpp 15903 2009-03-30 23:15:05Z rubidium $ */
    00002
    00005 #include "../stdafx.h"
    00006 #include "../engine_type.h"
    00007 #include "../group_type.h"
    00008 #include "../autoreplace_base.h"
    00009
    00010 #include "saveload.h"
    00011
    00012 static const SaveLoad _engine_renew_desc[] = {
    00013       SLE_VAR(EngineRenew, from,     SLE_UINT16),
    00014       SLE_VAR(EngineRenew, to,       SLE_UINT16),
    00015
    00016       SLE_REF(EngineRenew, next,     REF_ENGINE_RENEWS),
    00017   SLE_CONDVAR(EngineRenew, group_id, SLE_UINT16, 60, SL_MAX_VERSION),
    00018   SLE_END()
    00019 };
    00020
    00021 static void Save_ERNW()
    00022 {
    00023   EngineRenew *er;
    00024
    00025   FOR_ALL_ENGINE_RENEWS(er) {
    00026     SlSetArrayIndex(er->index);
    00027     SlObject(er, _engine_renew_desc);
    00028   }
    00029 }
    00030
    00031 static void Load_ERNW()
    00032 {
    00033   int index;
    00034
    00035   while ((index = SlIterateArray()) != -1) {
    00036     EngineRenew *er = new (index) EngineRenew();
    00037     SlObject(er, _engine_renew_desc);
    00038
    00039     /* Advanced vehicle lists, ungrouped vehicles got added */
    00040     if (CheckSavegameVersion(60)) {
    00041       er->group_id = ALL_GROUP;
    00042     } else if (CheckSavegameVersion(71)) {
    00043       if (er->group_id == DEFAULT_GROUP) er->group_id = ALL_GROUP;
    00044     }
    00045   }
    00046 }
    00047
    00048 extern const ChunkHandler _autoreplace_chunk_handlers[] = {
    00049   { 'ERNW', Save_ERNW,     Load_ERNW,     CH_ARRAY | CH_LAST},
    00050 };