autoreplace_sl.cpp

Go to the documentation of this file.
00001 /* $Id$ */
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 "../autoreplace_base.h"
00014 
00015 #include "saveload.h"
00016 
00017 static const SaveLoad _engine_renew_desc[] = {
00018       SLE_VAR(EngineRenew, from,     SLE_UINT16),
00019       SLE_VAR(EngineRenew, to,       SLE_UINT16),
00020 
00021       SLE_REF(EngineRenew, next,     REF_ENGINE_RENEWS),
00022   SLE_CONDVAR(EngineRenew, group_id, SLE_UINT16, 60, SL_MAX_VERSION),
00023   SLE_END()
00024 };
00025 
00026 static void Save_ERNW()
00027 {
00028   EngineRenew *er;
00029 
00030   FOR_ALL_ENGINE_RENEWS(er) {
00031     SlSetArrayIndex(er->index);
00032     SlObject(er, _engine_renew_desc);
00033   }
00034 }
00035 
00036 static void Load_ERNW()
00037 {
00038   int index;
00039 
00040   while ((index = SlIterateArray()) != -1) {
00041     EngineRenew *er = new (index) EngineRenew();
00042     SlObject(er, _engine_renew_desc);
00043 
00044     /* Advanced vehicle lists, ungrouped vehicles got added */
00045     if (IsSavegameVersionBefore(60)) {
00046       er->group_id = ALL_GROUP;
00047     } else if (IsSavegameVersionBefore(71)) {
00048       if (er->group_id == DEFAULT_GROUP) er->group_id = ALL_GROUP;
00049     }
00050   }
00051 }
00052 
00053 static void Ptrs_ERNW()
00054 {
00055   EngineRenew *er;
00056 
00057   FOR_ALL_ENGINE_RENEWS(er) {
00058     SlObject(er, _engine_renew_desc);
00059   }
00060 }
00061 
00062 extern const ChunkHandler _autoreplace_chunk_handlers[] = {
00063   { 'ERNW', Save_ERNW, Load_ERNW, Ptrs_ERNW, NULL, CH_ARRAY | CH_LAST},
00064 };

Generated on Fri Jun 3 05:18:57 2011 for OpenTTD by  doxygen 1.6.1