OpenTTD Source 20250312-master-gcdcc6b491d
league_cmd.cpp File Reference

Handling of league tables. More...

#include "stdafx.h"
#include "league_cmd.h"
#include "league_base.h"
#include "command_type.h"
#include "command_func.h"
#include "industry.h"
#include "story_base.h"
#include "town.h"
#include "window_func.h"
#include "core/pool_func.hpp"
#include "safeguards.h"

Go to the source code of this file.

Functions

bool IsValidLink (Link link)
 Checks whether a link is valid, i.e.
 
std::tuple< CommandCost, LeagueTableIDCmdCreateLeagueTable (DoCommandFlags flags, const EncodedString &title, const EncodedString &header, const EncodedString &footer)
 Create a new league table.
 
std::tuple< CommandCost, LeagueTableElementIDCmdCreateLeagueTableElement (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.
 
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.
 

Variables

LeagueTableElementPool _league_table_element_pool ("LeagueTableElement")
 
LeagueTablePool _league_table_pool ("LeagueTable")
 

Detailed Description

Handling of league tables.

Definition in file league_cmd.cpp.

Function Documentation

◆ CmdCreateLeagueTable()

std::tuple< CommandCost, LeagueTableID > CmdCreateLeagueTable ( DoCommandFlags  flags,
const EncodedString title,
const EncodedString header,
const EncodedString footer 
)

Create a new league table.

Parameters
flagstype of operation
titleTitle of the league table
headerText to show above the table
footerText to show below the table
Returns
the cost of this operation or an error

Definition at line 56 of file league_cmd.cpp.

References _current_company, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_league_table_pool >::CanAllocateItem(), CMD_ERROR, Execute, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, OWNER_DEITY, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().

◆ CmdCreateLeagueTableElement()

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.

Parameters
flagstype of operation
tableId of the league table this element belongs to
ratingValue that elements are ordered by
companyCompany to show the color blob for or CompanyID::Invalid()
textText of the element
scoreString representation of the score associated with the element
link_typeType of the referenced object
link_targetId of the referenced object
Returns
the cost of this operation or an error

Definition at line 83 of file league_cmd.cpp.

References _current_company, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_league_table_element_pool >::CanAllocateItem(), CMD_ERROR, Execute, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, InvalidateWindowData(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::IsValidID(), IsValidLink(), OWNER_DEITY, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), and WC_COMPANY_LEAGUE.

◆ CmdRemoveLeagueTableElement()

CommandCost CmdRemoveLeagueTableElement ( DoCommandFlags  flags,
LeagueTableElementID  element 
)

Remove a league table element.

Parameters
flagstype of operation
elementId of the element to update
Returns
the cost of this operation or an error

Definition at line 155 of file league_cmd.cpp.

References _current_company, CMD_ERROR, Execute, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_league_table_element_pool >::GetIfValid(), InvalidateWindowData(), OWNER_DEITY, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), and WC_COMPANY_LEAGUE.

◆ CmdUpdateLeagueTableElementData()

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.

Parameters
flagstype of operation
elementId of the element to update
companyCompany to show the color blob for or CompanyID::Invalid()
textText of the element
link_typeType of the referenced object
link_targetId of the referenced object
Returns
the cost of this operation or an error

Definition at line 109 of file league_cmd.cpp.

References _current_company, CMD_ERROR, Execute, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_league_table_element_pool >::GetIfValid(), InvalidateWindowData(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::IsValidID(), IsValidLink(), OWNER_DEITY, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), and WC_COMPANY_LEAGUE.

◆ CmdUpdateLeagueTableElementScore()

CommandCost CmdUpdateLeagueTableElementScore ( DoCommandFlags  flags,
LeagueTableElementID  element,
int64_t  rating,
const EncodedString score 
)

Update the score of a league table element.

Parameters
flagstype of operation
elementId of the element to update
ratingValue that elements are ordered by
scoreString representation of the score associated with the element
Returns
the cost of this operation or an error

Definition at line 135 of file league_cmd.cpp.

References _current_company, CMD_ERROR, Execute, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_league_table_element_pool >::GetIfValid(), InvalidateWindowData(), OWNER_DEITY, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), and WC_COMPANY_LEAGUE.

◆ IsValidLink()