Invalidate the right goal list when changing goals
[openttd/fttd.git] / src / saveload / depot_sl.cpp
blobb107e09a0d153947558ccfced42ce267b34fb938
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 depot_sl.cpp Code handling saving and loading of depots */
12 #include "../stdafx.h"
13 #include "../depot_base.h"
14 #include "../town.h"
16 #include "saveload_buffer.h"
18 static TownID _town_index;
20 static const SaveLoad _depot_desc[] = {
21 SLE_VAR(Depot, xy, SLE_FILE_U16 | SLE_VAR_U32, , , 0, 5),
22 SLE_VAR(Depot, xy, SLE_UINT32, 0, , 6, ),
23 SLEG_VAR(_town_index, SLE_UINT16, , , 0, 140),
24 SLE_REF(Depot, town, REF_TOWN, 0, , 141, ),
25 SLE_VAR(Depot, town_cn, SLE_UINT16, 0, , 141, ),
26 SLE_STR(Depot, name, SLS_STR, 0, 0, , 141, ),
27 SLE_VAR(Depot, build_date, SLE_INT32, 0, , 142, ),
28 SLE_END()
31 static void Save_DEPT(SaveDumper *dumper)
33 Depot *depot;
35 FOR_ALL_DEPOTS(depot) {
36 dumper->WriteElement(depot->index, depot, _depot_desc);
40 static void Load_DEPT(LoadBuffer *reader)
42 int index;
44 while ((index = reader->IterateChunk()) != -1) {
45 Depot *depot = new (index) Depot();
46 reader->ReadObject(depot, _depot_desc);
48 /* Set the town 'pointer' so we can restore it later. */
49 if (reader->IsOTTDVersionBefore(141)) depot->town = (Town *)(size_t)_town_index;
53 static void Ptrs_DEPT(const SavegameTypeVersion *stv)
55 Depot *depot;
57 FOR_ALL_DEPOTS(depot) {
58 SlObjectPtrs(depot, _depot_desc, stv);
59 if ((stv != NULL) && IsOTTDSavegameVersionBefore(stv, 141)) depot->town = Town::Get((size_t)depot->town);
63 extern const ChunkHandler _depot_chunk_handlers[] = {
64 { 'DEPT', Save_DEPT, Load_DEPT, Ptrs_DEPT, NULL, CH_ARRAY | CH_LAST},