OpenTTD Source: src/town_cmd.h File Reference

OpenTTD Source 13.2.1

Functions
town_cmd.h File Reference
`#include "command_type.h"`
`#include "company_type.h"`
`#include "town_type.h"`

Go to the source code of this file.

## Functions
enum TownEffect byte std::tuple< CommandCost, Money, TownID > | CmdFoundTown (DoCommandFlag flags, TileIndex tile, TownSize size, bool city, TownLayout layout, bool random_location, uint32 townnameparts, const std::string &text)
| Create a new town. More...
CommandCost | CmdRenameTown (DoCommandFlag flags, TownID town_id, const std::string &text)
| Rename a town (server-only). More...
CommandCost | CmdDoTownAction (DoCommandFlag flags, TownID town_id, uint8 action)
| Do a town action. More...
CommandCost | CmdTownGrowthRate (DoCommandFlag flags, TownID town_id, uint16 growth_rate)
| Change the growth rate of the town. More...
CommandCost | CmdTownRating (DoCommandFlag flags, TownID town_id, CompanyID company_id, int16 rating)
| Change the rating of a company in a town. More...
CommandCost | CmdTownCargoGoal (DoCommandFlag flags, TownID town_id, TownEffect te, uint32 goal)
| Change the cargo goal of a town. More...
CommandCost | CmdTownSetText (DoCommandFlag flags, TownID town_id, const std::string &text)
| Set a custom text in the Town window. More...
CommandCost | CmdExpandTown (DoCommandFlag flags, TownID town_id, uint32 grow_amount)
| Expand a town (scenario editor only). More...
CommandCost | CmdDeleteTown (DoCommandFlag flags, TownID town_id)
| Delete a town (scenario editor or worldgen only). More...
| DEF_CMD_TRAIT (CMD_FOUND_TOWN, CmdFoundTown, CMD_DEITY|CMD_NO_TEST, CMDT_LANDSCAPE_CONSTRUCTION) CommandCallback CcFoundTown
void | CcFoundRandomTown (Commands cmd, const CommandCost &result, Money, TownID town_id)

## Detailed Description

Command definitions related to towns.

Definition in file town_cmd.h.

## Function Documentation

## ◆ CmdDeleteTown()

CommandCost CmdDeleteTown | ( | DoCommandFlag | flags,
|  | TownID | town_id
| ) |  |

Delete a town (scenario editor or worldgen only).

Parameters

  flags | Type of operation.
  town_id | Town ID to delete.

Returns
  Empty cost or an error.

Definition at line 2968 of file town_cmd.cpp.

## ◆ CmdDoTownAction()

CommandCost CmdDoTownAction | ( | DoCommandFlag | flags,
|  | TownID | town_id,
|  | uint8 | action
| ) |  |

Do a town action.

This performs an action such as advertising, building a statue, funding buildings, but also bribing the town-council

Parameters

  flags | type of operation
  town_id | town to do the action at
  action | action to perform,

See also
  _town_action_proc for the list of available actions

Returns
  the cost of this operation or an error

Definition at line 3348 of file town_cmd.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::GetIfValid(), and lengthof.

## ◆ CmdExpandTown()

CommandCost CmdExpandTown | ( | DoCommandFlag | flags,
|  | TownID | town_id,
|  | uint32 | grow_amount
| ) |  |

Expand a town (scenario editor only).

Parameters

  flags | Type of operation.
  TownID | Town ID to expand.
  grow_amount | Amount to grow, or 0 to grow a random size up to the current amount of houses.

Returns
  Empty cost or an error.

Definition at line 2931 of file town_cmd.cpp.

## ◆ CmdFoundTown()

enum TownEffect byte std::tuple<CommandCost, Money, TownID> CmdFoundTown | ( | DoCommandFlag | flags,
|  | TileIndex | tile,
|  | TownSize | size,
|  | bool | city,
|  | TownLayout | layout,
|  | bool | random_location,
|  | uint32 | townnameparts,
|  | const std::string & | text
| ) |  |

Create a new town.

Parameters

  flags | type of operation
  tile | coordinates where town is built
  size | size of the town (

See also
  TownSize)

Parameters

  city | true iff it should be a city
  layout | town road layout (

See also
  TownLayout)

Parameters

  random_location | use random location (randomize `tile` )
  townnameparts | town name parts
  text | Custom name for the town. If empty, the town name parts will be used.

Returns
  the cost of this operation or an error

Definition at line 1965 of file town_cmd.cpp.

References _settings_game, CMD_ERROR, GameSettings::game_creation, GameCreationSettings::town_name, and TSZ_END.

## ◆ CmdRenameTown()

CommandCost CmdRenameTown | ( | DoCommandFlag | flags,
|  | TownID | town_id,
|  | const std::string & | text
| ) |  |

Rename a town (server-only).

Parameters

  flags | type of operation
  town_id | town ID to rename
  text | the new name or an empty string when resetting to the default

Returns
  the cost of this operation or an error

Definition at line 2767 of file town_cmd.cpp.

References Town::cached_name, CMD_ERROR, DC_EXEC, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::GetIfValid(), InvalidateWindowData(), IsUniqueTownName(), MAX_LENGTH_TOWN_NAME_CHARS, Town::name, return_cmd_error, Town::UpdateVirtCoord(), Utf8StringLength(), and WC_TOWN_DIRECTORY.

## ◆ CmdTownCargoGoal()

CommandCost CmdTownCargoGoal | ( | DoCommandFlag | flags,
|  | TownID | town_id,
|  | TownEffect | te,
|  | uint32 | goal
| ) |  |

Change the cargo goal of a town.

Parameters

  flags | Type of operation.
  town_id | Town ID to cargo game of.
  te | TownEffect to change the game of.
  goal | The new goal value.

Returns
  Empty cost or an error.

Definition at line 2817 of file town_cmd.cpp.

References _current_company, CMD_ERROR, DC_EXEC, FindFirstCargoWithTownEffect(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::GetIfValid(), Town::goal, InvalidateWindowData(), OWNER_DEITY, TE_END, UpdateTownGrowth(), and WC_TOWN_VIEW.

## ◆ CmdTownGrowthRate()

CommandCost CmdTownGrowthRate | ( | DoCommandFlag | flags,
|  | TownID | town_id,
|  | uint16 | growth_rate
| ) |  |

Change the growth rate of the town.

Parameters

  flags | Type of operation.
  town_id | Town ID to cargo game of.
  growth_rate | Amount of days between growth, or TOWN_GROWTH_RATE_NONE, or 0 to reset custom growth rate.

Returns
  Empty cost or an error.

Definition at line 2868 of file town_cmd.cpp.

References _current_company, ClrBit(), CMD_ERROR, DC_EXEC, Town::flags, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::GetIfValid(), Town::grow_counter, Town::growth_rate, InvalidateWindowData(), OWNER_DEITY, SetBit(), TOWN_CUSTOM_GROWTH, UpdateTownGrowth(), and WC_TOWN_VIEW.

## ◆ CmdTownRating()

CommandCost CmdTownRating | ( | DoCommandFlag | flags,
|  | TownID | town_id,
|  | CompanyID | company_id,
|  | int16 | rating
| ) |  |

Change the rating of a company in a town.

Parameters

  flags | Type of operation.
  town_id | Town ID to change, bit 16..23 =
  company_id | Company ID to change.
  rating | New rating of company (signed int16).

Returns
  Empty cost or an error.

Definition at line 2906 of file town_cmd.cpp.

References _current_company, Clamp(), CMD_ERROR, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::GetIfValid(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), and OWNER_DEITY.

## ◆ CmdTownSetText()

CommandCost CmdTownSetText | ( | DoCommandFlag | flags,
|  | TownID | town_id,
|  | const std::string & | text
| ) |  |

Set a custom text in the Town window.

Parameters

  flags | Type of operation.
  town_id | Town ID to change the text of.
  text | The new text (empty to remove the text).

Returns
  Empty cost or an error.

Definition at line 2846 of file town_cmd.cpp.

References _current_company, CMD_ERROR, DC_EXEC, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::GetIfValid(), InvalidateWindowData(), OWNER_DEITY, Town::text, and WC_TOWN_VIEW.