2009-01-04 15:32:25 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* 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.
|
|
|
|
* 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.
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2009-01-04 15:32:25 +00:00
|
|
|
/** @file autoreplace_sl.cpp Code handling saving and loading of autoreplace rules */
|
|
|
|
|
|
|
|
#include "../stdafx.h"
|
|
|
|
#include "../autoreplace_base.h"
|
|
|
|
|
|
|
|
#include "saveload.h"
|
|
|
|
|
2014-04-23 20:13:33 +00:00
|
|
|
#include "../safeguards.h"
|
|
|
|
|
2009-01-04 15:32:25 +00:00
|
|
|
static const SaveLoad _engine_renew_desc[] = {
|
|
|
|
SLE_VAR(EngineRenew, from, SLE_UINT16),
|
|
|
|
SLE_VAR(EngineRenew, to, SLE_UINT16),
|
|
|
|
|
|
|
|
SLE_REF(EngineRenew, next, REF_ENGINE_RENEWS),
|
|
|
|
SLE_CONDVAR(EngineRenew, group_id, SLE_UINT16, 60, SL_MAX_VERSION),
|
2012-04-17 19:44:02 +00:00
|
|
|
SLE_CONDVAR(EngineRenew, replace_when_old, SLE_BOOL, 175, SL_MAX_VERSION),
|
2009-01-04 15:32:25 +00:00
|
|
|
SLE_END()
|
|
|
|
};
|
|
|
|
|
|
|
|
static void Save_ERNW()
|
|
|
|
{
|
|
|
|
EngineRenew *er;
|
|
|
|
|
|
|
|
FOR_ALL_ENGINE_RENEWS(er) {
|
|
|
|
SlSetArrayIndex(er->index);
|
|
|
|
SlObject(er, _engine_renew_desc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void Load_ERNW()
|
|
|
|
{
|
|
|
|
int index;
|
|
|
|
|
|
|
|
while ((index = SlIterateArray()) != -1) {
|
|
|
|
EngineRenew *er = new (index) EngineRenew();
|
|
|
|
SlObject(er, _engine_renew_desc);
|
|
|
|
|
|
|
|
/* Advanced vehicle lists, ungrouped vehicles got added */
|
2010-11-21 12:47:04 +00:00
|
|
|
if (IsSavegameVersionBefore(60)) {
|
2009-01-04 15:32:25 +00:00
|
|
|
er->group_id = ALL_GROUP;
|
2010-11-21 12:47:04 +00:00
|
|
|
} else if (IsSavegameVersionBefore(71)) {
|
2009-01-04 15:32:25 +00:00
|
|
|
if (er->group_id == DEFAULT_GROUP) er->group_id = ALL_GROUP;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-17 16:28:29 +00:00
|
|
|
static void Ptrs_ERNW()
|
|
|
|
{
|
|
|
|
EngineRenew *er;
|
|
|
|
|
|
|
|
FOR_ALL_ENGINE_RENEWS(er) {
|
|
|
|
SlObject(er, _engine_renew_desc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-04 15:32:25 +00:00
|
|
|
extern const ChunkHandler _autoreplace_chunk_handlers[] = {
|
2010-06-13 14:11:59 +00:00
|
|
|
{ 'ERNW', Save_ERNW, Load_ERNW, Ptrs_ERNW, NULL, CH_ARRAY | CH_LAST},
|
2009-01-04 15:32:25 +00:00
|
|
|
};
|