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 bridge_signal_sl.cpp Code handling saving and loading of data for signal on bridges */
12 #include "../stdafx.h"
13 #include "../bridge_signal_map.h"
17 /** stub save header struct */
18 struct LongBridgeSignalStorageStub
{
22 static const SaveLoad _long_bridge_signal_storage_stub_desc
[] = {
23 SLE_VAR(LongBridgeSignalStorageStub
, length
, SLE_UINT32
),
27 static void Load_XBSS()
30 LongBridgeSignalStorageStub stub
;
31 while ((index
= SlIterateArray()) != -1) {
32 LongBridgeSignalStorage
&lbss
= _long_bridge_signal_sim_map
[index
];
33 SlObject(&stub
, _long_bridge_signal_storage_stub_desc
);
34 lbss
.signal_red_bits
.resize(stub
.length
);
35 SlArray(&(lbss
.signal_red_bits
[0]), stub
.length
, SLE_UINT64
);
39 static void RealSave_XBSS(const LongBridgeSignalStorage
*lbss
)
41 LongBridgeSignalStorageStub stub
;
42 stub
.length
= lbss
->signal_red_bits
.size();
43 SlObject(&stub
, _long_bridge_signal_storage_stub_desc
);
44 SlArray(const_cast<uint64
*>(&(lbss
->signal_red_bits
[0])), stub
.length
, SLE_UINT64
);
47 static void Save_XBSS()
49 for (const auto &it
: _long_bridge_signal_sim_map
) {
50 const LongBridgeSignalStorage
&lbss
= it
.second
;
51 SlSetArrayIndex(it
.first
);
52 SlAutolength((AutolengthProc
*) RealSave_XBSS
, const_cast<LongBridgeSignalStorage
*>(&lbss
));
56 extern const ChunkHandler _bridge_signal_chunk_handlers
[] = {
57 { 'XBSS', Save_XBSS
, Load_XBSS
, NULL
, NULL
, CH_SPARSE_ARRAY
| CH_LAST
},