23LeagueTableElementPool _league_table_element_pool(
"LeagueTableElement");
26LeagueTablePool _league_table_pool(
"LeagueTable");
37 case LT_NONE: return (link.target == 0);
38 case LT_TILE: return IsValidTile(link.target);
39 case LT_INDUSTRY: return Industry::IsValidID(link.target);
40 case LT_TOWN: return Town::IsValidID(link.target);
41 case LT_COMPANY: return Company::IsValidID(link.target);
42 case LT_STORY_PAGE: return StoryPage::IsValidID(link.target);
43 default: return false;
60 if (title.empty())
return {
CMD_ERROR, LeagueTableID::Invalid() };
87 Link link{link_type, link_target};
96 return {
CommandCost(), LeagueTableElementID::Invalid() };
115 Link link{link_type, link_target};
119 lte->company = company;
142 lte->rating = rating;
162 auto table = lte->table;
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
Common return value for all commands.
Container for an encoded string, created by GetEncodedString.
Functions related to commands.
static const CommandCost CMD_ERROR
Define a default return value for a failed command.
Types related to commands.
@ Execute
execute the given command
CompanyID _current_company
Company currently doing an action.
static constexpr Owner OWNER_DEITY
The object is owned by a superuser / goal script.
bool IsValidLink(Link link)
Checks whether a link is valid, i.e.
std::tuple< CommandCost, LeagueTableElementID > CmdCreateLeagueTableElement(DoCommandFlags flags, LeagueTableID table, int64_t rating, CompanyID company, const EncodedString &text, const EncodedString &score, LinkType link_type, LinkTargetID link_target)
Create a new element in a league table.
CommandCost CmdUpdateLeagueTableElementData(DoCommandFlags flags, LeagueTableElementID element, CompanyID company, const EncodedString &text, LinkType link_type, LinkTargetID link_target)
Update the attributes of a league table element.
bool IsValidLink(Link link)
Checks whether a link is valid, i.e.
CommandCost CmdUpdateLeagueTableElementScore(DoCommandFlags flags, LeagueTableElementID element, int64_t rating, const EncodedString &score)
Update the score of a league table element.
CommandCost CmdRemoveLeagueTableElement(DoCommandFlags flags, LeagueTableElementID element)
Remove a league table element.
std::tuple< CommandCost, LeagueTableID > CmdCreateLeagueTable(DoCommandFlags flags, const EncodedString &title, const EncodedString &header, const EncodedString &footer)
Create a new league table.
Command definitions related to league tables.
LinkType
Types of the possible link targets.
uint32_t LinkTargetID
Contains either tile, industry ID, town ID, story page ID or company ID.
PoolID< uint16_t, struct LeagueTableElementIDTag, 64000, 0xFFFF > LeagueTableElementID
ID of a league table.
PoolID< uint8_t, struct LeagueTableIDTag, 255, 0xFF > LeagueTableID
ID of a league table.
Some methods of Pool are placed here in order to reduce compilation time and binary size.
#define INSTANTIATE_POOL_METHODS(name)
Force instantiation of pool methods so we don't get linker errors.
A number of safeguards to prevent using unsafe methods.
Definition of base types and functions in a cross-platform compatible way.
Struct about league table elements.
Struct about custom league tables.
static bool CanAllocateItem(size_t n=1)
static bool IsValidID(auto index)
static T * Create(Targs &&... args)
static LeagueTableElement * GetIfValid(auto index)
void InvalidateWindowData(WindowClass cls, WindowNumber number, int data, bool gui_scope)
Mark window data of the window of a given class and specific window number as invalid (in need of re-...
Window functions not directly related to making/drawing windows.
@ WC_COMPANY_LEAGUE
Company league window; Window numbers: