OpenTTD Source
12.0-beta2
|
#include "viewport_type.h"
#include "town_map.h"
#include "subsidy_type.h"
#include "newgrf_storage.h"
#include "cargotype.h"
#include <list>
Go to the source code of this file.
Data Structures | |
struct | BuildingCounts< T > |
struct | TownCache |
Data structure with cached data of towns. More... | |
struct | Town |
Town data structure. More... | |
Typedefs | |
typedef Pool< Town, TownID, 64, 64000 > | TownPool |
Enumerations | |
enum | TownRatingCheckType { ROAD_REMOVE = 0, TUNNELBRIDGE_REMOVE = 1, TOWN_RATING_CHECK_TYPE_COUNT } |
Action types that a company must ask permission for to a town authority. More... | |
enum | TownDirectoryInvalidateWindowData { TDIWD_FORCE_REBUILD, TDIWD_POPULATION_CHANGE, TDIWD_FORCE_RESORT } |
Special values for town list window for the data parameter of InvalidateWindowData. | |
enum | TownFlags { TOWN_IS_GROWING = 0, TOWN_HAS_CHURCH = 1, TOWN_HAS_STADIUM = 2, TOWN_CUSTOM_GROWTH = 3 } |
This enum is used in conjunction with town->flags. More... | |
enum | TownActions { TACT_NONE = 0x00, TACT_ADVERTISE_SMALL = 0x01, TACT_ADVERTISE_MEDIUM = 0x02, TACT_ADVERTISE_LARGE = 0x04, TACT_ROAD_REBUILD = 0x08, TACT_BUILD_STATUE = 0x10, TACT_FUND_BUILDINGS = 0x20, TACT_BUY_RIGHTS = 0x40, TACT_BRIBE = 0x80, TACT_COUNT = 8, TACT_ADVERTISE = TACT_ADVERTISE_SMALL | TACT_ADVERTISE_MEDIUM | TACT_ADVERTISE_LARGE, TACT_CONSTRUCTION = TACT_ROAD_REBUILD | TACT_BUILD_STATUE | TACT_FUND_BUILDINGS, TACT_FUNDS = TACT_BUY_RIGHTS | TACT_BRIBE, TACT_ALL = TACT_ADVERTISE | TACT_CONSTRUCTION | TACT_FUNDS } |
Town actions of a company. More... | |
Functions | |
uint32 | GetWorldPopulation () |
Determines the world population Basically, count population of all towns, one by one. More... | |
void | UpdateAllTownVirtCoords () |
Update the virtual coords needed to draw the town sign for all towns. | |
void | ClearAllTownCachedNames () |
void | ShowTownViewWindow (TownID town) |
void | ExpandTown (Town *t) |
void | RebuildTownKdtree () |
CommandCost | CheckforTownRating (DoCommandFlag flags, Town *t, TownRatingCheckType type) |
Does the town authority allow the (destructive) action of the current company? More... | |
TileIndexDiff | GetHouseNorthPart (HouseID &house) |
Determines if a given HouseID is part of a multitile house. More... | |
Town * | CalcClosestTownFromTile (TileIndex tile, uint threshold=UINT_MAX) |
Return the town closest to the given tile within threshold. More... | |
void | ResetHouses () |
void | ClearTownHouse (Town *t, TileIndex tile) |
void | UpdateTownMaxPass (Town *t) |
void | UpdateTownRadius (Town *t) |
CommandCost | CheckIfAuthorityAllowsNewStation (TileIndex tile, DoCommandFlag flags) |
Checks whether the local authority allows construction of a new station (rail, road, airport, dock) on the given tile. More... | |
Town * | ClosestTownFromTile (TileIndex tile, uint threshold) |
Return the town closest (in distance or ownership) to a given tile, within a given threshold. More... | |
void | ChangeTownRating (Town *t, int add, int max, DoCommandFlag flags) |
Changes town rating of the current company. More... | |
HouseZonesBits | GetTownRadiusGroup (const Town *t, TileIndex tile) |
Returns the bit corresponding to the town zone of the specified tile. More... | |
void | SetTownRatingTestMode (bool mode) |
Switch the town rating to test-mode, to allow commands to be tested without affecting current ratings. More... | |
uint | GetMaskOfTownActions (int *nump, CompanyID cid, const Town *t) |
Get a list of available actions to do at a town. More... | |
bool | GenerateTowns (TownLayout layout) |
This function will generate a certain amount of towns, with a certain layout It can be called from the scenario editor (i.e. More... | |
const CargoSpec * | FindFirstCargoWithTownEffect (TownEffect effect) |
Determines the first cargo with a certain town effect. More... | |
template<class T > | |
void | MakeDefaultName (T *obj) |
Set the default name for a depot/waypoint. More... | |
static uint16 | TownTicksToGameTicks (uint16 ticks) |
RoadType | GetTownRoadType (const Town *t) |
Variables | |
static const uint | CUSTOM_TOWN_NUMBER_DIFFICULTY = 4 |
value for custom town number in difficulty settings | |
static const uint | CUSTOM_TOWN_MAX_NUMBER = 5000 |
this is the maximum number of towns a user can specify in customisation | |
static const TownID | INVALID_TOWN = 0xFFFF |
static const uint | TOWN_GROWTH_WINTER = 0xFFFFFFFE |
The town only needs this cargo in the winter (any amount) | |
static const uint | TOWN_GROWTH_DESERT = 0xFFFFFFFF |
The town needs the cargo for growth when on desert (any amount) | |
static const uint16 | TOWN_GROWTH_RATE_NONE = 0xFFFF |
Special value for Town::growth_rate to disable town growth. | |
static const uint16 | MAX_TOWN_GROWTH_TICKS = 930 |
Max amount of original town ticks that still fit into uint16, about equal to UINT16_MAX / TOWN_GROWTH_TICKS but slightly less to simplify calculations. | |
TownPool | _town_pool |
const byte | _town_action_costs [TACT_COUNT] |
Factor in the cost of each town action. More... | |
TownID | _new_town_id |
Base of the town class.
Definition in file town.h.
enum TownActions |
Town actions of a company.
enum TownFlags |
This enum is used in conjunction with town->flags.
IT simply states what bit is used for. It is pretty unrealistic (IMHO) to only have one church/stadium per town, NO MATTER the population of it. And there are 5 more bits available on flags...
Enumerator | |
---|---|
TOWN_IS_GROWING | Conditions for town growth are met. Grow according to Town::growth_rate. |
TOWN_HAS_CHURCH | There can be only one church by town. |
TOWN_HAS_STADIUM | There can be only one stadium by town. |
TOWN_CUSTOM_GROWTH | Growth rate is controlled by GS. |
enum TownRatingCheckType |
Action types that a company must ask permission for to a town authority.
Enumerator | |
---|---|
ROAD_REMOVE | Removal of a road owned by the town. |
TUNNELBRIDGE_REMOVE | Removal of a tunnel or bridge owned by the towb. |
TOWN_RATING_CHECK_TYPE_COUNT | Number of town checking action types. |
Return the town closest to the given tile within threshold.
tile | Starting point of the search. |
threshold | Biggest allowed distance to the town. |
nullptr
if there is no such town.Definition at line 3576 of file town_cmd.cpp.
Referenced by AirportGetNearestTown(), BuildObject(), ClosestTownFromTile(), CmdBuildBridge(), CmdBuildRoad(), and CmdBuildTunnel().
void ChangeTownRating | ( | Town * | t, |
int | add, | ||
int | max, | ||
DoCommandFlag | flags | ||
) |
Changes town rating of the current company.
t | Town to affect |
add | Value to add |
max | Minimum (add < 0) resp. maximum (add > 0) rating that should be achievable with this change. |
flags | Command flags, especially DC_NO_MODIFY_TOWN_RATING is tested |
Definition at line 3673 of file town_cmd.cpp.
References _cheats, _current_company, _town_rating_test, _town_test_ratings, DC_NO_MODIFY_TOWN_RATING, GetRating(), Town::have_ratings, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), Cheats::magic_bulldozer, Town::ratings, SetBit(), SetWindowDirty(), Cheat::value, and WC_TOWN_AUTHORITY.
CommandCost CheckforTownRating | ( | DoCommandFlag | flags, |
Town * | t, | ||
TownRatingCheckType | type | ||
) |
Does the town authority allow the (destructive) action of the current company?
flags | Checking flags of the command. |
t | Town that must allow the company action. |
type | Type of action that is wanted. |
Definition at line 3710 of file town_cmd.cpp.
References _cheats, _current_company, _settings_game, DC_NO_TEST_TOWN_RATING, GameSettings::difficulty, GetRating(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), Cheats::magic_bulldozer, RATING_ROAD_NEEDED_HOSTILE, RATING_ROAD_NEEDED_NEUTRAL, RATING_ROAD_NEEDED_PERMISSIVE, RATING_TUNNEL_BRIDGE_NEEDED_HOSTILE, RATING_TUNNEL_BRIDGE_NEEDED_NEUTRAL, RATING_TUNNEL_BRIDGE_NEEDED_PERMISSIVE, return_cmd_error, SetDParam(), DifficultySettings::town_council_tolerance, TOWN_RATING_CHECK_TYPE_COUNT, and Cheat::value.
CommandCost CheckIfAuthorityAllowsNewStation | ( | TileIndex | tile, |
DoCommandFlag | flags | ||
) |
Checks whether the local authority allows construction of a new station (rail, road, airport, dock) on the given tile.
tile | The tile where the station shall be constructed. |
flags | Command flags. DC_NO_TEST_TOWN_RATING is tested. |
Definition at line 3555 of file town_cmd.cpp.
References _current_company, _settings_game, ClosestTownFromTile(), DC_NO_TEST_TOWN_RATING, EconomySettings::dist_local_authority, GameSettings::economy, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), and Town::ratings.
Referenced by CmdBuildRailStation().
Return the town closest (in distance or ownership) to a given tile, within a given threshold.
tile | Starting point of the search. |
threshold | Biggest allowed distance to the town. |
nullptr
if there is no such town.Definition at line 3594 of file town_cmd.cpp.
References CalcClosestTownFromTile(), GetTileType(), GetTownIndex(), HasTownOwnedRoad(), IsRoadDepot(), and MP_ROAD.
Referenced by CheckIfAuthorityAllowsNewStation(), FindTownForIndustry(), GenerateCompanyName(), GetNameOfOwner(), StationResolverObject::GetTown(), ObjectResolverObject::GetTown(), IndustryTileScopeResolver::GetVariable(), AirportTileScopeResolver::GetVariable(), ObjectScopeResolver::GetVariable(), and LandInfoWindow::OnInit().
const CargoSpec* FindFirstCargoWithTownEffect | ( | TownEffect | effect | ) |
Determines the first cargo with a certain town effect.
effect | Town effect of interest |
Definition at line 2780 of file town_cmd.cpp.
References CargoSpec::Iterate().
Referenced by CmdTownCargoGoal().
bool GenerateTowns | ( | TownLayout | layout | ) |
This function will generate a certain amount of towns, with a certain layout It can be called from the scenario editor (i.e.
: generate Random Towns) as well as from world creation.
layout | which towns will be set to, when created |
Definition at line 2205 of file town_cmd.cpp.
TileIndexDiff GetHouseNorthPart | ( | HouseID & | house | ) |
Determines if a given HouseID is part of a multitile house.
The given ID is set to the ID of the north tile and the TileDiff to the north tile is returned.
house | Is changed to the HouseID of the north tile of the same house |
Definition at line 2681 of file town_cmd.cpp.
Referenced by GetDistanceFromNearbyHouse(), SearchNearbyHouseClass(), SearchNearbyHouseGRFID(), and SearchNearbyHouseID().
Get a list of available actions to do at a town.
nump | if not nullptr add put the number of available actions in it |
cid | the company that is querying the town |
t | the town that is queried |
Definition at line 3298 of file town_cmd.cpp.
References _settings_game, EconomySettings::bribe, COMPANY_SPECTATOR, GameSettings::economy, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), TACT_NONE, and Town::unwanted.
Referenced by TownAuthorityWindow::OnPaint().
Returns the bit corresponding to the town zone of the specified tile.
t | Town on which town zone is to be found |
tile | TileIndex where town zone needs to be found |
Definition at line 2257 of file town_cmd.cpp.
References DistanceSquare(), Town::fund_buildings_months, and Town::xy.
Referenced by BuildTownHouse(), IndustryTileScopeResolver::GetVariable(), IndustriesScopeResolver::GetVariable(), AirportTileScopeResolver::GetVariable(), HouseScopeResolver::GetVariable(), and ObjectScopeResolver::GetVariable().
uint32 GetWorldPopulation | ( | ) |
Determines the world population Basically, count population of all towns, one by one.
Definition at line 450 of file town_cmd.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::Iterate().
Referenced by TownDirectoryWindow::SetStringParameters().
void MakeDefaultName | ( | T * | obj | ) |
Set the default name for a depot/waypoint.
T | The type/class to make a default name for |
obj | The object/instance we want to find the name for |
Definition at line 239 of file town.h.
Referenced by CmdRenameDepot().
void SetTownRatingTestMode | ( | bool | mode | ) |
Switch the town rating to test-mode, to allow commands to be tested without affecting current ratings.
The function is safe to use in nested calls.
mode | Test mode switch (true means go to test-mode, false means leave test-mode). |
Definition at line 3635 of file town_cmd.cpp.
References _town_rating_test, and _town_test_ratings.
const byte _town_action_costs[TACT_COUNT] |
Factor in the cost of each town action.
Definition at line 3055 of file town_cmd.cpp.