Codechange: Use null pointer literal instead of the NULL macro
[openttd-github.git] / src / saveload / autoreplace_sl.cpp
blob6493b6f4523ee0b0b7c4f277fa547deca603c627
1 /* $Id$ */
3 /*
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/>.
8 */
10 /** @file autoreplace_sl.cpp Code handling saving and loading of autoreplace rules */
12 #include "../stdafx.h"
13 #include "../autoreplace_base.h"
15 #include "saveload.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, SLV_60, SL_MAX_VERSION),
25 SLE_CONDVAR(EngineRenew, replace_when_old, SLE_BOOL, SLV_175, SL_MAX_VERSION),
26 SLE_END()
29 static void Save_ERNW()
31 EngineRenew *er;
33 FOR_ALL_ENGINE_RENEWS(er) {
34 SlSetArrayIndex(er->index);
35 SlObject(er, _engine_renew_desc);
39 static void Load_ERNW()
41 int index;
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(SLV_60)) {
49 er->group_id = ALL_GROUP;
50 } else if (IsSavegameVersionBefore(SLV_71)) {
51 if (er->group_id == DEFAULT_GROUP) er->group_id = ALL_GROUP;
56 static void Ptrs_ERNW()
58 EngineRenew *er;
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, nullptr, CH_ARRAY | CH_LAST},