Add: Overlay cargo icon in vehicle/depot list when holding shift+ctrl. (#12938)
[openttd-github.git] / src / saveload / league_sl.cpp
blob9945b6c298f55c77106d72ce39d18dcc6cdc6f11
1 /*
2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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/>.
6 */
8 /** @file league_sl.cpp Code handling saving and loading of league tables */
10 #include "../stdafx.h"
12 #include "saveload.h"
14 #include "../league_base.h"
16 #include "../safeguards.h"
18 static const SaveLoad _league_table_elements_desc[] = {
19 SLE_VAR(LeagueTableElement, table, SLE_UINT8),
20 SLE_CONDVAR(LeagueTableElement, rating, SLE_FILE_U64 | SLE_VAR_I64, SL_MIN_VERSION, SLV_LINKGRAPH_EDGES),
21 SLE_CONDVAR(LeagueTableElement, rating, SLE_INT64, SLV_LINKGRAPH_EDGES, SL_MAX_VERSION),
22 SLE_VAR(LeagueTableElement, company, SLE_UINT8),
23 SLE_SSTR(LeagueTableElement, text, SLE_STR | SLF_ALLOW_CONTROL),
24 SLE_SSTR(LeagueTableElement, score, SLE_STR | SLF_ALLOW_CONTROL),
25 SLE_VAR(LeagueTableElement, link.type, SLE_UINT8),
26 SLE_VAR(LeagueTableElement, link.target, SLE_UINT32),
29 struct LEAEChunkHandler : ChunkHandler {
30 LEAEChunkHandler() : ChunkHandler('LEAE', CH_TABLE) {}
32 void Save() const override
34 SlTableHeader(_league_table_elements_desc);
36 for (LeagueTableElement *lte : LeagueTableElement::Iterate()) {
37 SlSetArrayIndex(lte->index);
38 SlObject(lte, _league_table_elements_desc);
42 void Load() const override
44 const std::vector<SaveLoad> slt = SlTableHeader(_league_table_elements_desc);
46 int index;
47 while ((index = SlIterateArray()) != -1) {
48 LeagueTableElement *lte = new (index) LeagueTableElement();
49 SlObject(lte, slt);
54 static const SaveLoad _league_tables_desc[] = {
55 SLE_SSTR(LeagueTable, title, SLE_STR | SLF_ALLOW_CONTROL),
56 SLE_SSTR(LeagueTable, header, SLE_STR | SLF_ALLOW_CONTROL),
57 SLE_SSTR(LeagueTable, footer, SLE_STR | SLF_ALLOW_CONTROL),
60 struct LEATChunkHandler : ChunkHandler {
61 LEATChunkHandler() : ChunkHandler('LEAT', CH_TABLE) {}
63 void Save() const override
65 SlTableHeader(_league_tables_desc);
67 for (LeagueTable *lt : LeagueTable::Iterate()) {
68 SlSetArrayIndex(lt->index);
69 SlObject(lt, _league_tables_desc);
73 void Load() const override
75 const std::vector<SaveLoad> slt = SlTableHeader(_league_tables_desc);
77 int index;
78 while ((index = SlIterateArray()) != -1) {
79 LeagueTable *lt = new (index) LeagueTable();
80 SlObject(lt, slt);
85 static const LEAEChunkHandler LEAE;
86 static const LEATChunkHandler LEAT;
87 static const ChunkHandlerRef league_chunk_handlers[] = {
88 LEAE,
89 LEAT,
92 extern const ChunkHandlerTable _league_chunk_handlers(league_chunk_handlers);