OpenTTD Source: src/league_base.h Source File

OpenTTD Source 15.3

league_base.h
Go to the documentation of this file.
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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#ifndef LEAGUE_BASE_H
11#define LEAGUE_BASE_H
12
13#include "company_type.h"
14#include "goal_type.h"
15#include "league_type.h"
16#include "core/pool_type.hpp"
17#include "strings_type.h"
18
19bool IsValidLink(Link link);
20
21using LeagueTableElementPool = Pool<LeagueTableElement, LeagueTableElementID, 64>;
22extern LeagueTableElementPool _league_table_element_pool;
23
24using LeagueTablePool = Pool<LeagueTable, LeagueTableID, 4>;
25extern LeagueTablePool _league_table_pool;
26
27
32 struct LeagueTableElement : LeagueTableElementPool::PoolItem<&_league_table_element_pool> {
33 LeagueTableID table = LeagueTableID::Invalid();
34 int64_t rating = 0;
35 CompanyID company = CompanyID::Invalid();
36 EncodedString text{};
37 EncodedString score{};
38 Link link{};
39
43 LeagueTableElement() { }
44 LeagueTableElement(LeagueTableID table, int64_t rating, CompanyID company, const EncodedString &text, const EncodedString &score, const Link &link) :
45 table(table), rating(rating), company(company), text(text), score(score), link(link) {}
46
50 ~LeagueTableElement() { }
51};
52
53
55 struct LeagueTable : LeagueTablePool::PoolItem<&_league_table_pool> {
56 EncodedString title{};
57 EncodedString header{};
58 EncodedString footer{};
59
63 LeagueTable() { }
64 LeagueTable(const EncodedString &title, const EncodedString &header, const EncodedString &footer) : title(title), header(header), footer(footer) { }
65
69 ~LeagueTable() { }
70};
71
72#endif /* LEAGUE_BASE_H */
EncodedString
Container for an encoded string, created by GetEncodedString.
Definition strings_type.h:98
company_type.h
Types related to companies.
goal_type.h
basic types related to goals
IsValidLink
bool IsValidLink(Link link)
Checks whether a link is valid, i.e.
Definition league_cmd.cpp:34
league_type.h
basic types related to league tables
pool_type.hpp
Definition of Pool, structure used to access PoolItems, and PoolItem, base structure for Vehicle,...
strings_type.h
Types related to strings.
LeagueTableElement
Struct about league table elements.
Definition league_base.h:32
LeagueTableElement::rating
int64_t rating
Value that determines ordering of elements in the table (higher=better)
Definition league_base.h:34
LeagueTableElement::~LeagueTableElement
~LeagueTableElement()
(Empty) destructor has to be defined else operator delete might be called with nullptr parameter
Definition league_base.h:50
LeagueTableElement::score
EncodedString score
String representation of the score associated with the element.
Definition league_base.h:37
LeagueTableElement::LeagueTableElement
LeagueTableElement()
We need an (empty) constructor so struct isn't zeroed (as C++ standard states)
Definition league_base.h:43
LeagueTableElement::link
Link link
What opens when element is clicked.
Definition league_base.h:38
LeagueTableElement::text
EncodedString text
Text of the element.
Definition league_base.h:36
LeagueTableElement::table
LeagueTableID table
Id of the table which this element belongs to.
Definition league_base.h:33
LeagueTableElement::company
CompanyID company
Company Id to show the colour blob for or CompanyID::Invalid()
Definition league_base.h:35
LeagueTable
Struct about custom league tables.
Definition league_base.h:55
LeagueTable::LeagueTable
LeagueTable()
We need an (empty) constructor so struct isn't zeroed (as C++ standard states)
Definition league_base.h:63
LeagueTable::header
EncodedString header
Text to show above the table.
Definition league_base.h:57
LeagueTable::~LeagueTable
~LeagueTable()
(Empty) destructor has to be defined else operator delete might be called with nullptr parameter
Definition league_base.h:69
LeagueTable::title
EncodedString title
Title of the table.
Definition league_base.h:56
LeagueTable::footer
EncodedString footer
Text to show below the table.
Definition league_base.h:58
Link
Definition league_type.h:27
PoolID< uint8_t, struct LeagueTableIDTag, 255, 0xFF >
Pool::PoolItem
Base class for all PoolItems.
Definition pool_type.hpp:285
Pool
Base class for all pools.
Definition pool_type.hpp:133