1 /* $Id: autoreplace_sl.cpp 24136 2012-04-17 19:44:02Z michi_cc $ */
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
10 /** @file autoreplace_sl.cpp Code handling saving and loading of autoreplace rules */
12 #include "../stdafx.h"
13 #include "../autoreplace_base.h"
17 #include "../safeguards.h"
19 static const SaveLoad _engine_renew_desc
[] = {
20 SLE_VAR(EngineRenew
, from
, SLE_UINT16
),
21 SLE_VAR(EngineRenew
, to
, SLE_UINT16
),
23 SLE_REF(EngineRenew
, next
, REF_ENGINE_RENEWS
),
24 SLE_CONDVAR(EngineRenew
, group_id
, SLE_UINT16
, 60, SL_MAX_VERSION
),
25 SLE_CONDVAR(EngineRenew
, replace_when_old
, SLE_BOOL
, 175, SL_MAX_VERSION
),
29 static void Save_ERNW()
33 FOR_ALL_ENGINE_RENEWS(er
) {
34 SlSetArrayIndex(er
->index
);
35 SlObject(er
, _engine_renew_desc
);
39 static void Load_ERNW()
43 while ((index
= SlIterateArray()) != -1) {
44 EngineRenew
*er
= new (index
) EngineRenew();
45 SlObject(er
, _engine_renew_desc
);
47 /* Advanced vehicle lists, ungrouped vehicles got added */
48 if (IsSavegameVersionBefore(60)) {
49 er
->group_id
= ALL_GROUP
;
50 } else if (IsSavegameVersionBefore(71)) {
51 if (er
->group_id
== DEFAULT_GROUP
) er
->group_id
= ALL_GROUP
;
56 static void Ptrs_ERNW()
60 FOR_ALL_ENGINE_RENEWS(er
) {
61 SlObject(er
, _engine_renew_desc
);
65 extern const ChunkHandler _autoreplace_chunk_handlers
[] = {
66 { 'ERNW', Save_ERNW
, Load_ERNW
, Ptrs_ERNW
, NULL
, CH_ARRAY
| CH_LAST
},