#include "oldpool.h"
#include "core/bitmath_func.hpp"
#include "core/random_func.hpp"
#include "cargo_type.h"
#include "tile_type.h"
#include "date_type.h"
#include "town_type.h"
#include "company_type.h"
#include "settings_type.h"
#include "strings_type.h"
#include "viewport_type.h"
#include "economy_type.h"
#include "map_type.h"
#include "command_type.h"
Go to the source code of this file.
Data Structures | |
| struct | BuildingCounts< T > |
| struct | Town |
| struct | HouseSpec |
Defines | |
| #define | FOR_ALL_TOWNS_FROM(t, start) for (t = GetTown(start); t != NULL; t = (t->index + 1U < GetTownPoolSize()) ? GetTown(t->index + 1U) : NULL) if (t->IsValid()) |
| #define | FOR_ALL_TOWNS(t) FOR_ALL_TOWNS_FROM(t, 0) |
Enumerations | |
| enum | { HOUSE_NO_CLASS = 0, NEW_HOUSE_OFFSET = 110, HOUSE_MAX = 512, INVALID_TOWN = 0xFFFF, INVALID_HOUSE_ID = 0xFFFF, HOUSE_CLASS_MAX = HOUSE_MAX - NEW_HOUSE_OFFSET + 1 } |
| enum | BuildingFlags { TILE_NO_FLAG = 0, TILE_SIZE_1x1 = 1U << 0, TILE_NOT_SLOPED = 1U << 1, TILE_SIZE_2x1 = 1U << 2, TILE_SIZE_1x2 = 1U << 3, TILE_SIZE_2x2 = 1U << 4, BUILDING_IS_ANIMATED = 1U << 5, BUILDING_IS_CHURCH = 1U << 6, BUILDING_IS_STADIUM = 1U << 7, BUILDING_HAS_1_TILE = TILE_SIZE_1x1 | TILE_SIZE_2x1 | TILE_SIZE_1x2 | TILE_SIZE_2x2, BUILDING_2_TILES_X = TILE_SIZE_2x1 | TILE_SIZE_2x2, BUILDING_2_TILES_Y = TILE_SIZE_1x2 | TILE_SIZE_2x2, BUILDING_HAS_4_TILES = TILE_SIZE_2x2 } |
| enum | HouseZonesBits { HZB_BEGIN = 0, HZB_TOWN_EDGE = 0, HZB_TOWN_OUTSKIRT, HZB_TOWN_OUTER_SUBURB, HZB_TOWN_INNER_SUBURB, HZB_TOWN_CENTRE, HZB_END } |
| enum | HouseZones { HZ_NOZNS = 0x0000, HZ_ZON1 = 1U << HZB_TOWN_EDGE, HZ_ZON2 = 1U << HZB_TOWN_OUTSKIRT, HZ_ZON3 = 1U << HZB_TOWN_OUTER_SUBURB, HZ_ZON4 = 1U << HZB_TOWN_INNER_SUBURB, HZ_ZON5 = 1U << HZB_TOWN_CENTRE, HZ_ZONALL = 0x001F, HZ_SUBARTC_ABOVE = 0x0800, HZ_TEMP = 0x1000, HZ_SUBARTC_BELOW = 0x2000, HZ_SUBTROPIC = 0x4000, HZ_TOYLND = 0x8000 } |
| enum | HouseExtraFlags { NO_EXTRA_FLAG = 0, BUILDING_IS_HISTORICAL = 1U << 0, BUILDING_IS_PROTECTED = 1U << 1, SYNCHRONISED_CALLBACK_1B = 1U << 2, CALLBACK_1A_RANDOM_BITS = 1U << 3 } |
| enum | { ROAD_REMOVE = 0, UNMOVEABLE_REMOVE = 1, TUNNELBRIDGE_REMOVE = 1, INDUSTRY_REMOVE = 2 } |
| enum | { TOWN_IS_FUNDED = 0, TOWN_HAS_CHURCH = 1, TOWN_HAS_STADIUM = 2 } |
| This enum is used in conjonction with town->flags12. More... | |
Functions | |
| assert_compile (HZB_END==5) | |
| uint32 | GetWorldPopulation () |
| Determines the world population Basically, count population of all towns, one by one. | |
| void | UpdateTownVirtCoord (Town *t) |
| Resize the sign(label) of the town after changes in population (creation or growth or else). | |
| void | UpdateAllTownVirtCoords () |
| Update the virtual coords needed to draw the town sign for all towns. | |
| void | InitializeTown () |
| void | ShowTownViewWindow (TownID town) |
| void | ExpandTown (Town *t) |
| Called from GUI. | |
| Town * | CreateRandomTown (uint attempts, TownSize size, bool city, TownLayout layout) |
| bool | CheckforTownRating (DoCommandFlag flags, Town *t, byte type) |
| static HouseSpec * | GetHouseSpecs (HouseID house_id) |
| TileIndexDiff | GetHouseNorthPart (HouseID &house) |
| Determines if a given HouseID is part of a multitile house. | |
| static bool | IsValidTownID (TownID index) |
| Check if a TownID is valid. | |
| static TownID | GetMaxTownIndex () |
| static uint | GetNumTowns () |
| static Town * | GetRandomTown () |
| Return a random valid town. | |
| Town * | CalcClosestTownFromTile (TileIndex tile, uint threshold=UINT_MAX) |
| void | ResetHouses () |
| void | ClearTownHouse (Town *t, TileIndex tile) |
| void | UpdateTownMaxPass (Town *t) |
| void | UpdateTownRadius (Town *t) |
| bool | CheckIfAuthorityAllowsNewStation (TileIndex tile, DoCommandFlag flags) |
| Checks whether the local authority allows construction of a new station (rail, road, airport, dock) on the given tile. | |
| Town * | ClosestTownFromTile (TileIndex tile, uint threshold) |
| void | ChangeTownRating (Town *t, int add, int max, DoCommandFlag flags) |
| Changes town rating of the current company. | |
| HouseZonesBits | GetTownRadiusGroup (const Town *t, TileIndex tile) |
| Returns the bit corresponding to the town zone of the specified tile. | |
| void | SetTownRatingTestMode (bool mode) |
| uint | GetMaskOfTownActions (int *nump, CompanyID cid, const Town *t) |
| Get a list of available actions to do at a town. | |
| bool | GenerateTowns (TownLayout layout) |
| bool | GenerateTownName (uint32 *townnameparts) |
| Generates valid town name. | |
| static uint | TileHash (uint x, uint y) |
| Calculate a hash value from a tile position. | |
| static uint | TileHash2Bit (uint x, uint y) |
| Get the last two bits of the TileHash from a tile position. | |
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 | |
| HouseSpec | _house_specs [HOUSE_MAX] |
| static const byte | TOWN_GROWTH_FREQUENCY = 70 |
| This is the number of ticks between towns being processed for building new houses or roads. | |
| static const byte | TOWN_HOUSE_COMPLETED = 3 |
| Simple value that indicates the house has reached the final stage of construction. | |
| Town * | _cleared_town |
| int | _cleared_town_rating |
| uint32 | _cur_town_ctr |
| iterator through all towns in OnTick_Town | |
| uint32 | _cur_town_iter |
| frequency iterator at the same place | |
Definition in file town.h.
| anonymous enum |
This enum is used in conjonction with town->flags12.
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 flags12...
| enum HouseExtraFlags |
| enum HouseZones |
| 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 archievable with this change | |
| flags | Command flags, especially DC_NO_MODIFY_TOWN_RATING is tested |
Definition at line 2659 of file town_cmd.cpp.
References DC_NO_MODIFY_TOWN_RATING, InvalidateWindow(), Cheats::magic_bulldozer, SetBit(), and Cheat::value.
Referenced by CheckAllowRemoveRoad(), and CmdPlantTree().
| bool 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 2559 of file town_cmd.cpp.
References _settings_game, DC_NO_TEST_TOWN_RATING, EconomySettings::dist_local_authority, and GameSettings::economy.
Referenced by CmdBuildAirport(), CmdBuildDock(), CmdBuildRailroadStation(), and CmdBuildRoadStop().
| bool GenerateTownName | ( | uint32 * | townnameparts | ) |
Generates valid town name.
| townnameparts | if a name is generated, it's stored there |
Definition at line 1430 of file town_cmd.cpp.
References _settings_game, GameSettings::game_creation, GameCreationSettings::town_name, and VerifyTownName().
| 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 2085 of file town_cmd.cpp.
References TileDiffXY().
Referenced by GetDistanceFromNearbyHouse(), SearchNearbyHouseClass(), SearchNearbyHouseGRFID(), SearchNearbyHouseID(), and UpdateHousesAndTowns().
| uint GetMaskOfTownActions | ( | int * | nump, | |
| CompanyID | cid, | |||
| const Town * | t | |||
| ) |
Get a list of available actions to do at a town.
| nump | if not NULL 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 2382 of file town_cmd.cpp.
References _settings_game, EconomySettings::bribe, COMPANY_SPECTATOR, GameSettings::economy, EconomySettings::exclusive_rights, HasBit(), and lengthof.
Referenced by CmdDoTownAction(), and AITown::IsActionAvailable().
| HouseZonesBits GetTownRadiusGroup | ( | const Town * | t, | |
| TileIndex | tile | |||
| ) |
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 1672 of file town_cmd.cpp.
References DistanceSquare().
Referenced by BuildTownHouse(), HouseGetVariable(), and IndustryGetVariable().
| uint32 GetWorldPopulation | ( | ) |
Determines the world population Basically, count population of all towns, one by one.
Definition at line 362 of file town_cmd.cpp.
| static bool IsValidTownID | ( | TownID | index | ) | [inline, static] |
Check if a TownID is valid.
| index | to inquiry in the pool of town |
Definition at line 303 of file town.h.
Referenced by CmdBuildRoad(), CmdDoTownAction(), CmdRenameTown(), GetRandomTown(), and AITown::IsValidTown().
| static uint TileHash | ( | uint | x, | |
| uint | y | |||
| ) | [inline, static] |
Calculate a hash value from a tile position.
| x | The X coordinate | |
| y | The Y coordinate |
Definition at line 378 of file town.h.
Referenced by TileHash2Bit().
| static uint TileHash2Bit | ( | uint | x, | |
| uint | y | |||
| ) | [inline, static] |
Get the last two bits of the TileHash from a tile position.
| x | The X coordinate | |
| y | The Y coordinate |
Definition at line 396 of file town.h.
References GB(), and TileHash().
Referenced by DrawTile_Town(), and HouseGetVariable().
| void UpdateAllTownVirtCoords | ( | ) |
Update the virtual coords needed to draw the town sign for all towns.
Definition at line 335 of file town_cmd.cpp.
References UpdateTownVirtCoord().
Referenced by InitializeWindowsAndCaches().
| void UpdateTownVirtCoord | ( | Town * | t | ) |
Resize the sign(label) of the town after changes in population (creation or growth or else).
| t | Town to update |
Definition at line 323 of file town_cmd.cpp.
References _settings_client, ClientSettings::gui, MarkTownSignDirty(), GUISettings::population_in_label, TILE_SIZE, TileX(), TileY(), Point::x, and Point::y.
Referenced by ChangePopulation(), CmdRenameTown(), DoCreateTown(), and UpdateAllTownVirtCoords().
const byte TOWN_GROWTH_FREQUENCY = 70 [static] |
const byte TOWN_HOUSE_COMPLETED = 3 [static] |
Simple value that indicates the house has reached the final stage of construction.
Definition at line 274 of file town.h.
Referenced by BuildTownHouse(), GetHouseBuildingStage(), IncHouseConstructionTick(), and MakeHouseTile().
1.5.6