OpenTTD
|
Handling of town tiles. More...
#include "stdafx.h"
#include "road_internal.h"
#include "road_cmd.h"
#include "landscape.h"
#include "viewport_func.h"
#include "cmd_helper.h"
#include "command_func.h"
#include "industry.h"
#include "station_base.h"
#include "company_base.h"
#include "news_func.h"
#include "error.h"
#include "object.h"
#include "genworld.h"
#include "newgrf_debug.h"
#include "newgrf_house.h"
#include "newgrf_text.h"
#include "autoslope.h"
#include "tunnelbridge_map.h"
#include "strings_func.h"
#include "window_func.h"
#include "string_func.h"
#include "newgrf_cargo.h"
#include "cheat_type.h"
#include "animated_tile_func.h"
#include "date_func.h"
#include "subsidy_func.h"
#include "core/pool_func.hpp"
#include "town.h"
#include "townname_func.h"
#include "core/random_func.hpp"
#include "core/backup_type.hpp"
#include "depot_base.h"
#include "object_map.h"
#include "object_base.h"
#include "ai/ai.hpp"
#include "game/game.hpp"
#include "table/strings.h"
#include "table/town_land.h"
#include "safeguards.h"
Go to the source code of this file.
Data Structures | |
struct | SpotData |
Used as the user_data for FindFurthestFromWater. More... | |
struct | StatueBuildSearchData |
Structure for storing data while searching the best place to build a statue. More... |
Typedefs | |
typedef void | TownDrawTileProc (const TileInfo *ti) |
typedef CommandCost | TownActionProc (Town *t, DoCommandFlag flags) |
Enumerations | |
enum | TownGrowthResult { GROWTH_SUCCEED = -1, GROWTH_SEARCH_STOPPED = 0 } |
Functions | |
static bool | BuildTownHouse (Town *t, TileIndex tile) |
Tries to build a house at this tile. | |
static Town * | CreateRandomTown (uint attempts, uint32 townnameparts, TownSize size, bool city, TownLayout layout) |
static void | TownDrawHouseLift (const TileInfo *ti) |
static DiagDirection | RandomDiagDir () |
Return a random direction. | |
static void | DrawTile_Town (TileInfo *ti) |
House Tile drawing handler. | |
static int | GetSlopePixelZ_Town (TileIndex tile, uint x, uint y) |
static Foundation | GetFoundation_Town (TileIndex tile, Slope tileh) |
Tile callback routine. | |
static void | AnimateTile_Town (TileIndex tile) |
Animate a tile for a town Only certain houses can be animated The newhouses animation supersedes regular ones. | |
static bool | IsCloseToTown (TileIndex tile, uint dist) |
Determines if a town is close to a tile. | |
void | UpdateAllTownVirtCoords () |
Update the virtual coords needed to draw the town sign for all towns. | |
static void | ChangePopulation (Town *t, int mod) |
Change the towns population. | |
uint32 | GetWorldPopulation () |
Determines the world population Basically, count population of all towns, one by one. | |
static void | MakeSingleHouseBigger (TileIndex tile) |
Helper function for house completion stages progression. | |
static void | MakeTownHouseBigger (TileIndex tile) |
Make the house advance in its construction stages until completion. | |
static void | TileLoop_Town (TileIndex tile) |
Tile callback function. | |
static CommandCost | ClearTile_Town (TileIndex tile, DoCommandFlag flags) |
static void | AddProducedCargo_Town (TileIndex tile, CargoArray &produced) |
static void | AddAcceptedCargoSetMask (CargoID cargo, uint amount, CargoArray &acceptance, uint32 *always_accepted) |
static void | AddAcceptedCargo_Town (TileIndex tile, CargoArray &acceptance, uint32 *always_accepted) |
static void | GetTileDesc_Town (TileIndex tile, TileDesc *td) |
static TrackStatus | GetTileTrackStatus_Town (TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side) |
static void | ChangeTileOwner_Town (TileIndex tile, Owner old_owner, Owner new_owner) |
void | UpdateTownCargoTotal (Town *t) |
Update the total cargo acceptance of the whole town. | |
static void | UpdateTownCargoes (Town *t, TileIndex start, bool update_total=true) |
Update accepted town cargoes around a specific tile. | |
void | UpdateTownCargoes (Town *t) |
Update cargo acceptance for the complete town. | |
void | UpdateTownCargoBitmap () |
Updates the bitmap of all cargoes accepted by houses. | |
static bool | GrowTown (Town *t) |
Grow the town. | |
static void | TownTickHandler (Town *t) |
void | OnTick_Town () |
static RoadBits | GetTownRoadBits (TileIndex tile) |
Return the RoadBits of a tile. | |
static bool | IsNeighborRoadTile (TileIndex tile, const DiagDirection dir, uint dist_multi) |
Check for parallel road inside a given distance. | |
static bool | IsRoadAllowedHere (Town *t, TileIndex tile, DiagDirection dir) |
Check if a Road is allowed on a given tile. | |
static bool | TerraformTownTile (TileIndex tile, int edges, int dir) |
static void | LevelTownLand (TileIndex tile) |
static RoadBits | GetTownRoadGridElement (Town *t, TileIndex tile, DiagDirection dir) |
Generate the RoadBits of a grid tile. | |
static bool | GrowTownWithExtraHouse (Town *t, TileIndex tile) |
Grows the town with an extra house. | |
static bool | GrowTownWithRoad (const Town *t, TileIndex tile, RoadBits rcmd) |
Grows the town with a road piece. | |
static bool | GrowTownWithBridge (const Town *t, const TileIndex tile, const DiagDirection bridge_dir) |
Grows the town with a bridge. | |
static void | GrowTownInTile (TileIndex *tile_ptr, RoadBits cur_rb, DiagDirection target_dir, Town *t1) |
Grows the given town. | |
static bool | CanFollowRoad (TileIndex tile, DiagDirection dir) |
Checks whether a road can be followed or is a dead end, that can not be extended to the next tile. | |
static bool | GrowTownAtRoad (Town *t, TileIndex tile) |
Returns "growth" if a house was built, or no if the build failed. | |
static RoadBits | GenRandomRoadBits () |
Generate a random road block. | |
void | UpdateTownRadius (Town *t) |
void | UpdateTownMaxPass (Town *t) |
static void | DoCreateTown (Town *t, TileIndex tile, uint32 townnameparts, TownSize size, bool city, TownLayout layout, bool manual) |
Does the actual town creation. | |
static CommandCost | TownCanBePlacedHere (TileIndex tile) |
Checks if it's possible to place a town at given tile. | |
static bool | IsUniqueTownName (const char *name) |
Verifies this custom name is unique. | |
CommandCost | CmdFoundTown (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Create a new town. | |
static TileIndex | AlignTileToGrid (TileIndex tile, TownLayout layout) |
Towns must all be placed on the same grid or when they eventually interpenetrate their road networks will not mesh nicely; this function adjusts a tile so that it aligns properly. | |
static bool | IsTileAlignedToGrid (TileIndex tile, TownLayout layout) |
Towns must all be placed on the same grid or when they eventually interpenetrate their road networks will not mesh nicely; this function tells you if a tile is properly aligned. | |
static bool | FindFurthestFromWater (TileIndex tile, void *user_data) |
CircularTileSearch callback; finds the tile furthest from any water. | |
static bool | FindNearestEmptyLand (TileIndex tile, void *user_data) |
CircularTileSearch callback; finds the nearest land tile. | |
static TileIndex | FindNearestGoodCoastalTownSpot (TileIndex tile, TownLayout layout) |
Given a spot on the map (presumed to be a water tile), find a good coastal spot to build a city. | |
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. | |
HouseZonesBits | GetTownRadiusGroup (const Town *t, TileIndex tile) |
Returns the bit corresponding to the town zone of the specified tile. | |
static void | ClearMakeHouseTile (TileIndex tile, Town *t, byte counter, byte stage, HouseID type, byte random_bits) |
Clears tile and builds a house or house part. | |
static void | MakeTownHouse (TileIndex t, Town *town, byte counter, byte stage, HouseID type, byte random_bits) |
Write house information into the map. | |
static bool | CanBuildHouseHere (TileIndex tile, TownID town, bool noslope) |
Checks if a house can be built here. | |
static bool | CheckBuildHouseSameZ (TileIndex tile, TownID town, int z, bool noslope) |
Checks if a house can be built at this tile, must have the same max z as parameter. | |
static bool | CheckFree2x2Area (TileIndex tile, TownID town, int z, bool noslope) |
Checks if a house of size 2x2 can be built at this tile. | |
static bool | TownLayoutAllowsHouseHere (Town *t, TileIndex tile) |
Checks if current town layout allows building here. | |
static bool | TownLayoutAllows2x2HouseHere (Town *t, TileIndex tile) |
Checks if current town layout allows 2x2 building here. | |
static bool | CheckTownBuild2House (TileIndex *tile, Town *t, int maxz, bool noslope, DiagDirection second) |
Checks if 1x2 or 2x1 building is allowed here, also takes into account current town layout Also, tests both building positions that occupy this tile. | |
static bool | CheckTownBuild2x2House (TileIndex *tile, Town *t, int maxz, bool noslope) |
Checks if 2x2 building is allowed here, also takes into account current town layout Also, tests all four building positions that occupy this tile. | |
static void | DoClearTownHouseHelper (TileIndex tile, Town *t, HouseID house) |
Update data structures when a house is removed. | |
TileIndexDiff | GetHouseNorthPart (HouseID &house) |
Determines if a given HouseID is part of a multitile house. | |
void | ClearTownHouse (Town *t, TileIndex tile) |
CommandCost | CmdRenameTown (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Rename a town (server-only). | |
const CargoSpec * | FindFirstCargoWithTownEffect (TownEffect effect) |
Determines the first cargo with a certain town effect. | |
static void | UpdateTownGrowRate (Town *t) |
CommandCost | CmdTownCargoGoal (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Change the cargo goal of a town. | |
CommandCost | CmdTownSetText (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Set a custom text in the Town window. | |
CommandCost | CmdTownGrowthRate (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Change the growth rate of the town. | |
CommandCost | CmdExpandTown (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Expand a town (scenario editor only). | |
CommandCost | CmdDeleteTown (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Delete a town (scenario editor or worldgen only). | |
static CommandCost | TownActionAdvertiseSmall (Town *t, DoCommandFlag flags) |
static CommandCost | TownActionAdvertiseMedium (Town *t, DoCommandFlag flags) |
static CommandCost | TownActionAdvertiseLarge (Town *t, DoCommandFlag flags) |
static CommandCost | TownActionRoadRebuild (Town *t, DoCommandFlag flags) |
static bool | TryClearTile (TileIndex tile) |
Check whether the land can be cleared. | |
static bool | SearchTileForStatue (TileIndex tile, void *user_data) |
Search callback function for TownActionBuildStatue. | |
static CommandCost | TownActionBuildStatue (Town *t, DoCommandFlag flags) |
Perform a 9x9 tiles circular search from the center of the town in order to find a free tile to place a statue. | |
static CommandCost | TownActionFundBuildings (Town *t, DoCommandFlag flags) |
static CommandCost | TownActionBuyRights (Town *t, DoCommandFlag flags) |
static CommandCost | TownActionBribe (Town *t, DoCommandFlag flags) |
uint | GetMaskOfTownActions (int *nump, CompanyID cid, const Town *t) |
Get a list of available actions to do at a town. | |
CommandCost | CmdDoTownAction (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Do a town action. | |
static void | UpdateTownRating (Town *t) |
static void | UpdateTownAmounts (Town *t) |
static void | UpdateTownUnwanted (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. | |
Town * | CalcClosestTownFromTile (TileIndex tile, uint threshold) |
Return the town closest to the given tile within threshold. | |
Town * | ClosestTownFromTile (TileIndex tile, uint threshold) |
Return the town closest (in distance or ownership) to a given tile, within a given threshold. | |
void | SetTownRatingTestMode (bool mode) |
Switch the town rating to test-mode, to allow commands to be tested without affecting current ratings. | |
static int | GetRating (const Town *t) |
Get the rating of a town for the _current_company. | |
void | ChangeTownRating (Town *t, int add, int max, DoCommandFlag flags) |
Changes town rating of the current company. | |
CommandCost | CheckforTownRating (DoCommandFlag flags, Town *t, TownRatingCheckType type) |
Does the town authority allow the (destructive) action of the current company? | |
void | TownsMonthlyLoop () |
void | TownsYearlyLoop () |
static CommandCost | TerraformTile_Town (TileIndex tile, DoCommandFlag flags, int z_new, Slope tileh_new) |
void | ResetHouses () |
Variables | |
TownID | _new_town_id |
uint32 | _town_cargoes_accepted |
Bitmap of all cargoes accepted by houses. | |
TownPool | _town_pool ("Town") |
static int | _grow_town_result |
static TownDrawTileProc *const | _town_draw_tile_procs [1] |
static const byte | _num_initial_towns [4] = {5, 11, 23, 46} |
const byte | _town_action_costs [TACT_COUNT] |
Factor in the cost of each town action. | |
static TownActionProc *const | _town_action_proc [] |
static bool | _town_rating_test = false |
If true , town rating is in test-mode. | |
static SmallMap< const Town *, int, 4 > | _town_test_ratings |
Map of towns to modified ratings, while in town rating test-mode. | |
const TileTypeProcs | _tile_type_town_procs |
Tile callback functions for a town. | |
HouseSpec | _house_specs [NUM_HOUSES] |
Handling of town tiles.
Definition in file town_cmd.cpp.
|
static |
Towns must all be placed on the same grid or when they eventually interpenetrate their road networks will not mesh nicely; this function adjusts a tile so that it aligns properly.
tile | the tile to start at |
layout | which town layout algo is in effect |
Definition at line 1791 of file town_cmd.cpp.
References TileX(), TileXY(), TileY(), TL_2X2_GRID, and TL_3X3_GRID.
|
static |
Animate a tile for a town Only certain houses can be animated The newhouses animation supersedes regular ones.
tile | TileIndex of the house to animate |
Definition at line 291 of file town_cmd.cpp.
References _tick_counter, DeleteAnimatedTile(), GetHouseType(), GetLiftDestination(), GetLiftPosition(), HaltLift(), LiftHasDestination(), MarkTileDirtyByTile(), NEW_HOUSE_OFFSET, RandomRange(), SetLiftDestination(), and SetLiftPosition().
Tries to build a house at this tile.
t | town the house will belong to |
tile | where the house will be built |
Definition at line 2248 of file town_cmd.cpp.
References _cur_year, _generating_world, _loaded_newgrf_features, _settings_game, HouseSpec::building_availability, TownCache::building_counts, HouseSpec::building_flags, BUILDING_IS_HISTORICAL, Town::cache, CALLBACK_FAILED, HouseSpec::callback_mask, CanBuildHouseHere(), CBID_HOUSE_ALLOW_CONSTRUCTION, CBM_HOUSE_ALLOW_CONSTRUCTION, Chance16(), ChangePopulation(), CheckTownBuild2House(), CheckTownBuild2x2House(), HouseSpec::class_id, Convert8bitBooleanCallback(), DIAGDIR_SE, DIAGDIR_SW, HouseSpec::enabled, HouseSpec::extra_flags, Town::flags, GameSettings::game_creation, GB(), GetTileMaxZ(), GetTileSlope(), GetTownRadiusGroup(), HouseSpec::grf_prop, GRFFilePropsBase< Tcnt >::grffile, GRFLoadedFeatures::has_newhouses, HasBit(), HighestSnowLine(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, GameCreationSettings::landscape, MakeTownHouse(), HouseSpec::max_year, NUM_HOUSES, TownCache::num_houses, GRFFileProps::override, HouseSpec::population, HouseSpec::probability, RandomRange(), SetBit(), SLOPE_FLAT, TOWN_HAS_CHURCH, TOWN_HAS_STADIUM, TOWN_HOUSE_COMPLETED, TownLayoutAllowsHouseHere(), and UpdateTownCargoes().
Referenced by GrowTownInTile(), GrowTownWithExtraHouse(), and TileLoop_Town().
Return the town closest to the given tile within threshold.
tile | Starting point of the search. |
threshold | Biggest allowed distance to the town. |
NULL
if there is no such town.Definition at line 3220 of file town_cmd.cpp.
References DistanceManhattan(), and Town::xy.
Referenced by AfterLoadGame(), BuildObject(), ClosestTownFromTile(), CmdBuildBridge(), CmdBuildRoad(), CmdBuildTunnel(), Town::PostDestructor(), RemoveRoad(), and UpdateNearestTownForRoadTiles().
|
inlinestatic |
Checks if a house can be built here.
Important is slope, bridge above and ability to clear the land.
tile | tile to check |
town | town that is checking |
noslope | are slopes (foundations) allowed? |
Definition at line 2065 of file town_cmd.cpp.
References CMD_LANDSCAPE_CLEAR, DC_NO_WATER, DoCommand(), GetTileSlope(), GetTownIndex(), IsBridgeAbove(), IsSteepSlope(), IsTileType(), MP_HOUSE, SLOPE_FLAT, and CommandCost::Succeeded().
Referenced by BuildTownHouse(), and CheckBuildHouseSameZ().
|
static |
Checks whether a road can be followed or is a dead end, that can not be extended to the next tile.
This only checks trivial but often cases.
tile | Start tile for road. |
dir | Direction for road to follow or build. |
Definition at line 1307 of file town_cmd.cpp.
References _generating_world, _settings_game, EconomySettings::allow_town_roads, DiagDirToRoadBits(), GameSettings::economy, GetTileType(), GetTownRoadBits(), GetTunnelBridgeTransportType(), HasTileWaterGround(), IsDriveThroughStopTile(), IsValidTile(), MP_HOUSE, MP_INDUSTRY, MP_OBJECT, MP_ROAD, MP_STATION, MP_TUNNELBRIDGE, ReverseDiagDir(), ROAD_NONE, TileOffsByDiagDir(), and TRANSPORT_ROAD.
Referenced by GrowTownAtRoad().
|
static |
Change the towns population.
t | Town which population has changed |
mod | population change (can be positive or negative) |
Definition at line 401 of file town_cmd.cpp.
References Town::cache, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, InvalidateWindowData(), TownCache::population, Town::UpdateVirtCoord(), WC_TOWN_DIRECTORY, and WC_TOWN_VIEW.
Referenced by BuildTownHouse(), and MakeSingleHouseBigger().
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 3324 of file town_cmd.cpp.
References _cheats, _current_company, 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, max(), Town::ratings, SetBit(), SetWindowDirty(), Cheat::value, and WC_TOWN_AUTHORITY.
Referenced by CheckAllowRemoveRoad(), CmdPlantTree(), DoClearBridge(), and DoClearTunnel().
|
inlinestatic |
Checks if a house can be built at this tile, must have the same max z as parameter.
tile | tile to check |
town | town that is checking |
z | max z of this tile so more parts of a house are at the same height (with foundation) |
noslope | are slopes (foundations) allowed? |
Definition at line 2091 of file town_cmd.cpp.
References CanBuildHouseHere(), and GetTileMaxZ().
Referenced by CheckFree2x2Area(), and CheckTownBuild2House().
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 3361 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.
Referenced by CheckAllowRemoveRoad(), DoClearBridge(), and DoClearTunnel().
|
static |
Checks if a house of size 2x2 can be built at this tile.
tile | tile, N corner |
town | town that is checking |
z | maximum tile z so all tile have the same max z |
noslope | are slopes (foundations) allowed? |
Definition at line 2111 of file town_cmd.cpp.
References CheckBuildHouseSameZ(), DIAGDIR_END, DIAGDIR_SE, and TileOffsByDiagDir().
Referenced by CheckTownBuild2x2House().
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 3199 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< Tpool >::index, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), Town::ratings, return_cmd_error, and SetDParam().
Referenced by CmdBuildAirport(), CmdBuildDock(), CmdBuildRailStation(), and CmdBuildRoadStop().
|
static |
Checks if 1x2 or 2x1 building is allowed here, also takes into account current town layout Also, tests both building positions that occupy this tile.
tile | tile where the building should be built |
t | town |
maxz | all tiles should have the same height |
noslope | are slopes forbidden? |
second | diagdir from first tile to second tile |
Definition at line 2200 of file town_cmd.cpp.
References CheckBuildHouseSameZ(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, ReverseDiagDir(), TileOffsByDiagDir(), and TownLayoutAllowsHouseHere().
Referenced by BuildTownHouse().
Checks if 2x2 building is allowed here, also takes into account current town layout Also, tests all four building positions that occupy this tile.
tile | tile where the building should be built |
t | town |
maxz | all tiles should have the same height |
noslope | are slopes forbidden? |
Definition at line 2225 of file town_cmd.cpp.
References CheckFree2x2Area(), DIAGDIR_END, DIAGDIR_SE, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, ReverseDiagDir(), TileOffsByDiagDir(), and TownLayoutAllows2x2HouseHere().
Referenced by BuildTownHouse().
|
inlinestatic |
Clears tile and builds a house or house part.
tile | tile index |
t | The town to clear the house for |
counter | of construction step |
stage | of construction (used for drawing) |
type | of house. Index into house specs array |
random_bits | required for newgrf houses |
Definition at line 2022 of file town_cmd.cpp.
References AddAnimatedTile(), CMD_LANDSCAPE_CLEAR, DC_EXEC, DC_NO_WATER, DoCommand(), IncreaseBuildingCount(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, MakeHouseTile(), MarkTileDirtyByTile(), and CommandCost::Succeeded().
Referenced by MakeTownHouse().
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. |
NULL
if there is no such town.Definition at line 3245 of file town_cmd.cpp.
References _generating_world, CalcClosestTownFromTile(), DistanceManhattan(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::GetNumItems(), GetTileType(), GetTownIndex(), HasTownOwnedRoad(), IsRoadDepot(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::IsValidID(), MP_HOUSE, MP_ROAD, and Town::xy.
Referenced by AfterLoadGame(), BuildStationPart(), CheckAllowRemoveRoad(), CheckIfAuthorityAllowsNewStation(), CheckIfCallBackAllowsCreation(), CmdBuildAirport(), CmdBuildBridge(), CmdDeleteTown(), CmdPlantTree(), CmdRemoveRoadStop(), DisasterTick_Big_Ufo(), DoClearBridge(), DoClearTunnel(), FindTownForIndustry(), GenerateCompanyName(), GetNameOfOwner(), IndustriesResolverObject::GetTown(), StationResolverObject::GetTown(), ObjectResolverObject::GetTown(), IndustryTileScopeResolver::GetVariable(), RailTypeScopeResolver::GetVariable(), AirportTileScopeResolver::GetVariable(), ObjectScopeResolver::GetVariable(), MakeDefaultName(), LandInfoWindow::OnInit(), and Town::~Town().
CommandCost CmdDeleteTown | ( | TileIndex | tile, |
DoCommandFlag | flags, | ||
uint32 | p1, | ||
uint32 | p2, | ||
const char * | text | ||
) |
Delete a town (scenario editor or worldgen only).
tile | Unused. |
flags | Type of operation. |
p1 | Town ID to delete. |
p2 | Unused. |
text | Unused. |
Definition at line 2675 of file town_cmd.cpp.
References _generating_world, Station::airport, AT_OILRIG, ClosestTownFromTile(), CMD_ERROR, CMD_LANDSCAPE_CLEAR, DC_EXEC, DoCommand(), FACIL_AIRPORT, BaseStation::facilities, CommandCost::Failed(), Object::GetByTile(), Industry::GetByTile(), 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<&_town_pool >::GetNumItems(), GetTileType(), GetTownIndex(), HasTownOwnedRoad(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, IsTileOwner(), MapSize(), MP_HOUSE, MP_INDUSTRY, MP_OBJECT, MP_ROAD, MP_TUNNELBRIDGE, OBJECT_STATUE, OWNER_TOWN, OrthogonalTileArea::tile, Object::town, Industry::town, BaseStation::town, Object::type, and Airport::type.
CommandCost CmdDoTownAction | ( | TileIndex | tile, |
DoCommandFlag | flags, | ||
uint32 | p1, | ||
uint32 | p2, | ||
const char * | text | ||
) |
Do a town action.
This performs an action such as advertising, building a statue, funding buildings, but also bribing the town-council
tile | unused |
flags | type of operation |
p1 | town to do the action at |
p2 | action to perform, |
text | unused |
Definition at line 3048 of file town_cmd.cpp.
References _current_company, CMD_ERROR, EXPENSES_OTHER, CommandCost::Failed(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::GetIfValid(), GetMaskOfTownActions(), HasBit(), lengthof, SetWindowDirty(), and WC_TOWN_AUTHORITY.
CommandCost CmdExpandTown | ( | TileIndex | tile, |
DoCommandFlag | flags, | ||
uint32 | p1, | ||
uint32 | p2, | ||
const char * | text | ||
) |
Expand a town (scenario editor only).
tile | Unused. |
flags | Type of operation. |
p1 | Town ID to expand. |
p2 | Amount to grow, or 0 to grow a random size up to the current amount of houses. |
text | Unused. |
Definition at line 2635 of file town_cmd.cpp.
References _current_company, Town::cache, ClampToU16(), CMD_ERROR, DC_EXEC, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::GetIfValid(), GrowTown(), TownCache::num_houses, OWNER_DEITY, and RandomRange().
CommandCost CmdFoundTown | ( | TileIndex | tile, |
DoCommandFlag | flags, | ||
uint32 | p1, | ||
uint32 | p2, | ||
const char * | text | ||
) |
Create a new town.
tile | coordinates where town is built |
flags | type of operation |
p1 | 0..1 size of the town ( |
tile
) p2 | town name parts |
text | Custom name for the town. If empty, the town name parts will be used. |
Definition at line 1683 of file town_cmd.cpp.
References _current_company, _generating_world, _settings_game, AI::BroadcastNewEvent(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::CanAllocateItem(), CMD_ERROR, DC_EXEC, DoCreateTown(), GameSettings::economy, EXPENSES_OTHER, CommandCost::Failed(), EconomySettings::found_town, GameSettings::game_creation, GetAvailableMoneyForCommand(), CommandCost::GetCost(), HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, IsUniqueTownName(), lastof, lengthof, MAX_CHAR_LENGTH, MAX_LENGTH_COMPANY_NAME_CHARS, MAX_LENGTH_TOWN_NAME_CHARS, CommandCost::MultiplyCost(), Town::name, Game::NewEvent(), NT_INDUSTRY_OPEN, NUM_TLS, OWNER_DEITY, Backup< T >::Restore(), return_cmd_error, SetDParam(), SetDParamStr(), stredup(), StrEmpty(), TF_CUSTOM_LAYOUT, TF_FORBIDDEN, EconomySettings::town_layout, GameCreationSettings::town_name, TownCanBePlacedHere(), TSZ_END, TSZ_LARGE, TSZ_RANDOM, UpdateNearestTownForRoadTiles(), Town::UpdateVirtCoord(), Utf8StringLength(), and VerifyTownName().
CommandCost CmdRenameTown | ( | TileIndex | tile, |
DoCommandFlag | flags, | ||
uint32 | p1, | ||
uint32 | p2, | ||
const char * | text | ||
) |
Rename a town (server-only).
tile | unused |
flags | type of operation |
p1 | town ID to rename |
p2 | unused |
text | the new name or an empty string when resetting to the default |
Definition at line 2488 of file town_cmd.cpp.
References CMD_ERROR, DC_EXEC, free(), 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, stredup(), StrEmpty(), UpdateAllStationVirtCoords(), Town::UpdateVirtCoord(), Utf8StringLength(), and WC_TOWN_DIRECTORY.
CommandCost CmdTownCargoGoal | ( | TileIndex | tile, |
DoCommandFlag | flags, | ||
uint32 | p1, | ||
uint32 | p2, | ||
const char * | text | ||
) |
Change the cargo goal of a town.
tile | Unused. |
flags | Type of operation. |
p1 | various bitstuffed elements
|
p2 | The new goal value. |
text | Unused. |
Definition at line 2538 of file town_cmd.cpp.
References _current_company, CMD_ERROR, DC_EXEC, FindFirstCargoWithTownEffect(), GB(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::GetIfValid(), Town::goal, InvalidateWindowData(), OWNER_DEITY, TE_END, UpdateTownGrowRate(), and WC_TOWN_VIEW.
CommandCost CmdTownGrowthRate | ( | TileIndex | tile, |
DoCommandFlag | flags, | ||
uint32 | p1, | ||
uint32 | p2, | ||
const char * | text | ||
) |
Change the growth rate of the town.
tile | Unused. |
flags | Type of operation. |
p1 | Town ID to cargo game of. |
p2 | Amount of days between growth, or TOWN_GROW_RATE_CUSTOM_NONE, or 0 to reset custom growth rate. |
text | Unused. |
Definition at line 2595 of file town_cmd.cpp.
References _current_company, CMD_ERROR, DC_EXEC, GB(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::GetIfValid(), Town::grow_counter, Town::growth_rate, InvalidateWindowData(), OWNER_DEITY, TOWN_GROW_RATE_CUSTOM, TOWN_GROW_RATE_CUSTOM_NONE, UpdateTownGrowRate(), and WC_TOWN_VIEW.
CommandCost CmdTownSetText | ( | TileIndex | tile, |
DoCommandFlag | flags, | ||
uint32 | p1, | ||
uint32 | p2, | ||
const char * | text | ||
) |
Set a custom text in the Town window.
tile | Unused. |
flags | Type of operation. |
p1 | Town ID to change the text of. |
p2 | Unused. |
text | The new text (empty to remove the text). |
Definition at line 2571 of file town_cmd.cpp.
References _current_company, CMD_ERROR, DC_EXEC, free(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::GetIfValid(), InvalidateWindowData(), OWNER_DEITY, stredup(), StrEmpty(), Town::text, and WC_TOWN_VIEW.
Update data structures when a house is removed.
Definition at line 2404 of file town_cmd.cpp.
References DecreaseBuildingCount(), DeleteAnimatedTile(), DeleteNewGRFInspectWindow(), IsTileType(), and MP_HOUSE.
|
static |
Does the actual town creation.
t | The town |
tile | Where to put it |
townnameparts | The town name |
size | Parameter for size determination |
city | whether to build a city or town |
layout | the (road) layout of the town |
manual | was the town placed manually? |
Definition at line 1560 of file town_cmd.cpp.
References _nb_orig_names, _settings_game, Town::cache, GameSettings::economy, Town::exclusive_counter, Town::exclusivity, FindFirstCargoWithTownEffect(), Town::flags, Town::fund_buildings_months, GameSettings::game_creation, Town::goal, Town::grow_counter, Town::growth_rate, GrowTown(), Town::have_ratings, EconomySettings::initial_city_size, Town::InitializeLayout(), INVALID_COMPANY, InvalidateWindowData(), GameCreationSettings::landscape, Town::larger_town, MAX_COMPANIES, TownCache::num_houses, TownCache::population, RATING_INITIAL, Town::ratings, Town::statues, TE_FOOD, TE_WATER, Town::time_until_rebuild, TOWN_GROWTH_DESERT, TOWN_GROWTH_WINTER, GameCreationSettings::town_name, TSZ_RANDOM, UpdateAirportsNoise(), Town::UpdateVirtCoord(), WC_TOWN_DIRECTORY, and Town::xy.
Referenced by CmdFoundTown().
|
static |
House Tile drawing handler.
Part of the tile loop process
ti | TileInfo of the tile to draw |
Definition at line 212 of file town_cmd.cpp.
References _town_draw_tile_data, AddSortableSpriteToDraw(), DrawFoundation(), DrawGroundSprite(), FOUNDATION_LEVELED, GetHouseBuildingStage(), GetHouseType(), HouseSpec::grf_prop, IsInvisibilitySet(), IsTransparencySet(), NEW_HOUSE_OFFSET, PalSpriteID::pal, SLOPE_FLAT, PalSpriteID::sprite, TileInfo::tile, TileInfo::tileh, TileHash2Bit(), TO_HOUSES, TileInfo::x, TileInfo::y, and TileInfo::z.
const CargoSpec* FindFirstCargoWithTownEffect | ( | TownEffect | effect | ) |
Determines the first cargo with a certain town effect.
effect | Town effect of interest |
Definition at line 2516 of file town_cmd.cpp.
References CargoSpec::town_effect.
Referenced by AfterLoadGame(), CmdTownCargoGoal(), DoCreateTown(), and TownViewWindow::DrawWidget().
|
static |
CircularTileSearch callback; finds the tile furthest from any water.
slightly bit tricky, since it has to do a search of its own in order to find the distance to the water from each square in the radius.
Also, this never returns true, because it needs to take into account all locations being searched before it knows which is the furthest.
tile | Start looking from this tile |
user_data | Storage area for data that must last across calls; must be a pointer to struct SpotData |
Definition at line 1843 of file town_cmd.cpp.
References GetClosestWaterDistance(), IsTileAlignedToGrid(), IsTileFlat(), IsTileType(), SpotData::layout, SpotData::max_dist, MP_CLEAR, and SpotData::tile.
Referenced by FindNearestGoodCoastalTownSpot().
|
static |
CircularTileSearch callback; finds the nearest land tile.
tile | Start looking from this tile |
user_data | not used |
Definition at line 1865 of file town_cmd.cpp.
References IsTileType(), and MP_CLEAR.
Referenced by FindNearestGoodCoastalTownSpot().
|
static |
Given a spot on the map (presumed to be a water tile), find a good coastal spot to build a city.
We don't want to build too close to the edge if we can help it (since that retards city growth) hence the search within a search within a search. O(n*m^2), where n is how far to search for land, and m is how far inland to look for a flat spot.
tile | Start looking from this spot. |
layout | the road layout to search for |
Definition at line 1882 of file town_cmd.cpp.
References CircularTileSearch(), FindFurthestFromWater(), FindNearestEmptyLand(), INVALID_TILE, and SpotData::tile.
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 1949 of file town_cmd.cpp.
References _settings_game, Chance16(), GameCreationSettings::custom_town_number, CUSTOM_TOWN_NUMBER_DIFFICULTY, GameSettings::difficulty, GameSettings::economy, GameSettings::game_creation, GenerateTownName(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::GetNumItems(), GWP_TOWN, IncreaseGeneratingWorldProgress(), INVALID_STRING_ID, EconomySettings::larger_towns, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::MAX_SIZE, min(), DifficultySettings::number_towns, ScaleByMapSize(), SetGeneratingWorldProgress(), ShowErrorMessage(), TSZ_RANDOM, and WL_CRITICAL.
Referenced by _GenerateWorld(), and FoundTownWindow::OnClick().
|
static |
Generate a random road block.
The probability of a straight road is somewhat higher than a curved.
Definition at line 1431 of file town_cmd.cpp.
Referenced by GrowTown().
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 2421 of file town_cmd.cpp.
References TileDiffXY().
Referenced by GetDistanceFromNearbyHouse(), RebuildTownCaches(), SearchNearbyHouseClass(), SearchNearbyHouseGRFID(), SearchNearbyHouseID(), UpdateHousesAndTowns(), and WatchedCargoCallback().
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 2995 of file town_cmd.cpp.
References _settings_game, EconomySettings::bribe, COMPANY_SPECTATOR, GameSettings::economy, EconomySettings::exclusive_rights, EconomySettings::fund_buildings, EconomySettings::fund_roads, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), HasBit(), lengthof, Town::ratings, Town::statues, TACT_BRIBE, TACT_BUILD_STATUE, TACT_BUY_RIGHTS, TACT_FUND_BUILDINGS, TACT_NONE, TACT_ROAD_REBUILD, and Town::unwanted.
Referenced by CmdDoTownAction(), TownAuthorityWindow::DrawWidget(), TownAuthorityWindow::OnClick(), and TownAuthorityWindow::OnPaint().
|
static |
Get the rating of a town for the _current_company.
t | Town to get the rating from. |
Definition at line 3306 of file town_cmd.cpp.
References _current_company, SmallVector< SmallPair< T, U >, S >::End(), SmallMap< T, U, S >::Find(), and Town::ratings.
Referenced by ChangeTownRating(), and CheckforTownRating().
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 1998 of file town_cmd.cpp.
References DistanceSquare(), Town::fund_buildings_months, and Town::xy.
Referenced by BuildTownHouse(), RailTypeScopeResolver::GetVariable(), IndustryTileScopeResolver::GetVariable(), IndustriesScopeResolver::GetVariable(), AirportTileScopeResolver::GetVariable(), HouseScopeResolver::GetVariable(), and ObjectScopeResolver::GetVariable().
Return the RoadBits of a tile.
tile | The tile we want to analyse |
Definition at line 816 of file town_cmd.cpp.
References GetAnyRoadBits(), IsRoadDepotTile(), IsStandardRoadStopTile(), ROAD_NONE, and ROADTYPE_ROAD.
Referenced by CanFollowRoad(), GrowTown(), GrowTownAtRoad(), GrowTownWithBridge(), IsNeighborRoadTile(), and IsRoadAllowedHere().
|
static |
Generate the RoadBits of a grid tile.
t | current town |
tile | tile in reference to the town |
dir | The direction to which we are growing ATM |
Definition at line 944 of file town_cmd.cpp.
References DiagDirToRoadBits(), GetTileSlope(), Town::layout, ReverseDiagDir(), ROAD_ALL, ROAD_NE, ROAD_NONE, ROAD_NW, ROAD_SE, ROAD_SW, ROAD_X, ROAD_Y, SLOPE_E, SLOPE_N, SLOPE_NE, SLOPE_NW, SLOPE_S, SLOPE_SE, SLOPE_STEEP_E, SLOPE_STEEP_N, SLOPE_STEEP_S, SLOPE_STEEP_W, SLOPE_SW, SLOPE_W, TileIndexToTileIndexDiffC(), TL_2X2_GRID, TL_3X3_GRID, TileIndexDiffC::x, Town::xy, and TileIndexDiffC::y.
Referenced by GrowTownInTile().
uint32 GetWorldPopulation | ( | ) |
Determines the world population Basically, count population of all towns, one by one.
Definition at line 415 of file town_cmd.cpp.
References Town::cache, and TownCache::population.
Referenced by TownDirectoryWindow::SetStringParameters().
|
static |
Grow the town.
t | town to grow |
Definition at line 1445 of file town_cmd.cpp.
References _current_company, _generating_world, _settings_game, EconomySettings::allow_town_roads, CMD_BUILD_ROAD, CMD_LANDSCAPE_CLEAR, DC_EXEC, DC_NO_WATER, DoCommand(), GameSettings::economy, endof, GenRandomRoadBits(), GetTownRoadBits(), GrowTownAtRoad(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, IsTileFlat(), IsTileType(), MP_HOUSE, OWNER_TOWN, Backup< T >::Restore(), ROAD_NONE, CommandCost::Succeeded(), TILE_ADD, ToTileIndexDiff(), and Town::xy.
Referenced by CmdExpandTown(), and DoCreateTown().
Returns "growth" if a house was built, or no if the build failed.
t | town to inquiry |
tile | to inquiry |
Definition at line 1349 of file town_cmd.cpp.
References Town::cache, CanFollowRoad(), DIAGDIR_END, DiagDirToRoadBits(), GetTownRoadBits(), GetTunnelBridgeDirection(), GrowTownInTile(), HasTileRoadType(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, IsRoadDepot(), IsRoadOwner(), IsTileType(), IsValidDiagDirection(), Town::layout, MapSize(), MP_ROAD, MP_TUNNELBRIDGE, TownCache::num_houses, OWNER_NONE, OWNER_TOWN, RandomDiagDir(), ReverseDiagDir(), ROAD_NONE, ROADTYPE_ROAD, SetRoadOwner(), SetTownIndex(), TileAddByDiagDir(), TL_2X2_GRID, TL_3X3_GRID, and TL_BETTER_ROADS.
Referenced by GrowTown().
|
static |
Grows the given town.
There are at the moment 3 possible way's for the town expansion:
tile_ptr | The current tile |
cur_rb | The current tiles RoadBits |
target_dir | The target road dir |
t1 | The current town |
Definition at line 1137 of file town_cmd.cpp.
References _generating_world, _settings_game, EconomySettings::allow_town_level_crossings, EconomySettings::allow_town_roads, ConstructionSettings::build_on_slopes, BuildTownHouse(), Chance16(), ChangeDiagDir(), CleanUpRoadBits(), GameSettings::construction, DIAGDIR_END, DIAGDIRDIFF_90LEFT, DIAGDIRDIFF_90RIGHT, DiagDirToRoadBits(), GameSettings::economy, GetOtherTunnelBridgeEnd(), GetTownRoadGridElement(), GetTunnelBridgeTransportType(), GrowTownWithBridge(), GrowTownWithExtraHouse(), GrowTownWithRoad(), HasTileWaterGround(), IsRoadAllowedHere(), IsTileType(), IsValidTile(), Town::layout, MapSize(), MP_HOUSE, MP_RAILWAY, MP_TUNNELBRIDGE, RandomDiagDir(), ReverseDiagDir(), ROAD_NONE, TileAddByDiagDir(), TL_2X2_GRID, TL_3X3_GRID, TL_BETTER_ROADS, TL_ORIGINAL, and TRANSPORT_ROAD.
Referenced by GrowTownAtRoad().
|
static |
Grows the town with a bridge.
At first we check if a bridge is reasonable. If so we check if we are able to build it.
t | The current town |
tile | The current tile |
bridge_dir | The valid direction in which to grow a bridge |
Definition at line 1064 of file town_cmd.cpp.
References CMD_BUILD_BRIDGE, CommandFlagsToDCFlags(), DC_EXEC, DIAGDIR_END, DiagDirToRoadBits(), DoCommand(), GetCommandFlags(), GetTileSlope(), GetTownRoadBits(), InclinedSlope(), IsSea(), IsValidTile(), IsWaterTile(), MAX_BRIDGES, RandomRange(), ReverseDiagDir(), ROADTYPES_ROAD, SLOPE_FLAT, TileAddByDiagDir(), TileOffsByDiagDir(), and TRANSPORT_ROAD.
Referenced by GrowTownInTile().
Grows the town with an extra house.
Check if there are enough neighbor house tiles next to the current tile. If there are enough add another house.
t | The current town |
tile | The target tile for the extra house |
Definition at line 1003 of file town_cmd.cpp.
References BuildTownHouse(), DIAGDIR_BEGIN, DIAGDIR_END, DistanceFromEdge(), GetTileType(), MP_HOUSE, MP_VOID, and TileAddByDiagDir().
Referenced by GrowTownInTile().
Grows the town with a road piece.
t | The current town |
tile | The current tile |
rcmd | The RoadBits we want to build on the tile |
Definition at line 1045 of file town_cmd.cpp.
References CMD_BUILD_ROAD, DC_EXEC, DC_NO_WATER, DoCommand(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, and CommandCost::Succeeded().
Referenced by GrowTownInTile().
|
static |
Determines if a town is close to a tile.
tile | TileIndex of the tile to query |
dist | maximum distance to be accepted |
Definition at line 342 of file town_cmd.cpp.
References DistanceManhattan(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::GetNumItems(), GetTileType(), MapMaxX(), MapMaxY(), max(), min(), MP_HOUSE, TILE_AREA_LOOP, TileX(), TileXY(), TileY(), and Town::xy.
Referenced by TownCanBePlacedHere().
|
static |
Check for parallel road inside a given distance.
Assuming a road from (tile - TileOffsByDiagDir(dir)) to tile, is there a parallel road left or right of it within distance dist_multi?
tile | current tile |
dir | target direction |
dist_multi | distance multiplayer |
Definition at line 833 of file town_cmd.cpp.
References ChangeDiagDir(), DIAGDIRDIFF_90LEFT, DIAGDIRDIFF_90RIGHT, DiagDirToRoadBits(), GetTownRoadBits(), IsValidTile(), ReverseDiagDir(), TILE_ADD, and TileOffsByDiagDir().
Referenced by IsRoadAllowedHere().
|
static |
Check if a Road is allowed on a given tile.
t | The current town |
tile | The target tile |
dir | The direction in which we want to extend the town |
Definition at line 867 of file town_cmd.cpp.
References _generating_world, _settings_game, ConstructionSettings::build_on_slopes, Chance16(), CMD_BUILD_ROAD, CMD_ERROR, CMD_LANDSCAPE_CLEAR, CMD_TERRAFORM_LAND, ComplementSlope(), GameSettings::construction, DC_EXEC, DC_NO_WATER, DIAGDIR_NW, DIAGDIR_SE, DiagDirToAxis(), DistanceFromEdge(), DoCommand(), CommandCost::Failed(), GetBridgeAxis(), GetFoundationSlope(), GetTileSlope(), GetTownRoadBits(), IsBridgeAbove(), IsNeighborRoadTile(), Town::layout, ROAD_NONE, ROAD_X, ROAD_Y, SLOPE_ELEVATED, SLOPE_FLAT, SLOPE_NE, SLOPE_NW, and TL_ORIGINAL.
Referenced by GrowTownInTile().
|
static |
Towns must all be placed on the same grid or when they eventually interpenetrate their road networks will not mesh nicely; this function tells you if a tile is properly aligned.
tile | the tile to start at |
layout | which town layout algo is in effect |
Definition at line 1809 of file town_cmd.cpp.
References TileX(), TileY(), TL_2X2_GRID, and TL_3X3_GRID.
Referenced by FindFurthestFromWater().
|
static |
Verifies this custom name is unique.
Only custom names are checked.
name | name to check |
Definition at line 1660 of file town_cmd.cpp.
References Town::name.
Referenced by CmdFoundTown(), and CmdRenameTown().
|
static |
Helper function for house completion stages progression.
tile | TileIndex of the house (or parts of it) to "grow" |
Definition at line 428 of file town_cmd.cpp.
References ChangePopulation(), GetHouseConstructionTick(), GetHouseType(), IncHouseConstructionTick(), IsHouseCompleted(), IsTileType(), MarkTileDirtyByTile(), MP_HOUSE, and ResetHouseAge().
Referenced by MakeTownHouseBigger().
|
static |
Write house information into the map.
For houses > 1 tile, all tiles are marked.
t | tile index |
town | The town related to this house |
counter | of construction step |
stage | of construction (used for drawing) |
type | of house. Index into house specs array |
random_bits | required for newgrf houses |
Definition at line 2046 of file town_cmd.cpp.
References HouseSpec::building_flags, ClearMakeHouseTile(), and TileDiffXY().
Referenced by BuildTownHouse().
|
static |
Make the house advance in its construction stages until completion.
tile | TileIndex of house |
Definition at line 451 of file town_cmd.cpp.
References HouseSpec::building_flags, GetHouseType(), MakeSingleHouseBigger(), and TILE_ADDXY.
Referenced by TileLoop_Town().
|
inlinestatic |
Return a random direction.
Definition at line 202 of file town_cmd.cpp.
Referenced by GrowTownAtRoad(), and GrowTownInTile().
|
static |
Search callback function for TownActionBuildStatue.
tile | Tile on which to perform the search. |
user_data | Reference to the statue search data. |
Definition at line 2834 of file town_cmd.cpp.
References StatueBuildSearchData::best_position, GetTileSlope(), INVALID_TILE, IsBridgeAbove(), IsSteepSlope(), IsTileType(), MP_CLEAR, MP_HOUSE, MP_TREES, StatueBuildSearchData::tile_count, and TryClearTile().
Referenced by TownActionBuildStatue().
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 3286 of file town_cmd.cpp.
References SmallVector< SmallPair< T, U >, S >::Clear().
Referenced by DoCommand(), and DoCommandPInternal().
|
static |
Tile callback function.
Periodic tic handler for houses and town
tile | been asked to do its stuff |
Definition at line 466 of file town_cmd.cpp.
References _current_company, AddAnimatedTile(), HouseSpec::building_flags, BuildTownHouse(), CALLBACK_FAILED, CALLBACK_HOUSEPRODCARGO_END, HouseSpec::callback_mask, CBID_HOUSE_PRODUCE_CARGO, CBM_HOUSE_PRODUCE_CARGO, Chance16(), CT_INVALID, EconomyIsInRecession(), Town::flags, GB(), CargoSpec::Get(), GetCargoTranslation(), GetHouseAge(), GetHouseType(), StationFinder::GetStations(), HouseSpec::grf_prop, GRFFilePropsBase< Tcnt >::grffile, HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, IsHouseCompleted(), LiftHasDestination(), HouseSpec::mail_generation, MakeTownHouseBigger(), HouseSpec::minimum_life, TransportedCargoStat< Tstorage >::new_act, NEW_HOUSE_OFFSET, TransportedCargoStat< Tstorage >::new_max, OWNER_TOWN, HouseSpec::population, Backup< T >::Restore(), ST_TOWN, Town::supplied, Town::time_until_rebuild, and TOWN_IS_GROWING.
|
static |
Perform a 9x9 tiles circular search from the center of the town in order to find a free tile to place a statue.
t | town to search in |
flags | Used to check if the statue must be built or not. |
Definition at line 2877 of file town_cmd.cpp.
References _current_company, StatueBuildSearchData::best_position, BuildObject(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_object_pool >::CanAllocateItem(), CircularTileSearch(), CMD_LANDSCAPE_CLEAR, DoCommand(), INVALID_TILE, MarkTileDirtyByTile(), OBJECT_STATUE, OWNER_NONE, Backup< T >::Restore(), return_cmd_error, SearchTileForStatue(), SetBit(), Town::statues, and Town::xy.
|
static |
Checks if it's possible to place a town at given tile.
tile | tile to check |
Definition at line 1635 of file town_cmd.cpp.
References DistanceFromEdge(), EXPENSES_OTHER, IsCloseToTown(), IsTileFlat(), IsTileType(), MP_CLEAR, MP_TREES, and return_cmd_error.
Referenced by CmdFoundTown().
Checks if current town layout allows 2x2 building here.
t | town |
tile | tile to check |
Definition at line 2163 of file town_cmd.cpp.
References _generating_world, _settings_game, EconomySettings::allow_town_roads, GameSettings::economy, Town::layout, TileIndexToTileIndexDiffC(), TL_2X2_GRID, TL_3X3_GRID, TileIndexDiffC::x, Town::xy, and TileIndexDiffC::y.
Referenced by CheckTownBuild2x2House().
Checks if current town layout allows building here.
t | town |
tile | tile to check |
Definition at line 2132 of file town_cmd.cpp.
References _generating_world, _settings_game, EconomySettings::allow_town_roads, GameSettings::economy, Town::layout, TileIndexToTileIndexDiffC(), TL_2X2_GRID, TL_3X3_GRID, TileIndexDiffC::x, Town::xy, and TileIndexDiffC::y.
Referenced by BuildTownHouse(), and CheckTownBuild2House().
|
static |
Check whether the land can be cleared.
tile | Tile to check. |
Definition at line 2812 of file town_cmd.cpp.
References _current_company, CMD_LANDSCAPE_CLEAR, DC_NONE, DoCommand(), OWNER_NONE, Backup< T >::Restore(), and CommandCost::Succeeded().
Referenced by SearchTileForStatue().
void UpdateAllTownVirtCoords | ( | ) |
Update the virtual coords needed to draw the town sign for all towns.
Definition at line 387 of file town_cmd.cpp.
References Town::UpdateVirtCoord().
Referenced by UpdateAllVirtCoords().
void UpdateTownCargoBitmap | ( | ) |
Updates the bitmap of all cargoes accepted by houses.
Definition at line 768 of file town_cmd.cpp.
References _town_cargoes_accepted, and Town::cargo_accepted_total.
Referenced by RebuildTownCaches().
Update accepted town cargoes around a specific tile.
t | The town to update. |
start | Update the values around this tile. |
update_total | Set to true if the total cargo acceptance should be updated. |
Definition at line 719 of file town_cmd.cpp.
References Town::cargo_accepted, Town::cargo_produced, TileMatrix< uint32, 4 >::GetAreaForTile(), GetTownIndex(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, IsTileType(), MP_HOUSE, NUM_CARGO, SetBit(), TILE_AREA_LOOP, and UpdateTownCargoTotal().
void UpdateTownCargoes | ( | Town * | t | ) |
Update cargo acceptance for the complete town.
t | The town to update. |
Definition at line 749 of file town_cmd.cpp.
References Town::cargo_accepted, Town::cargo_produced, TileMatrix< T, N >::GetArea(), INVALID_TILE, OrthogonalTileArea::tile, TILE_AREA_LOOP, TileX(), TileY(), UpdateTownCargoes(), and UpdateTownCargoTotal().
Referenced by AfterLoadGame(), BuildTownHouse(), RebuildTownCaches(), and UpdateTownCargoes().
void UpdateTownCargoTotal | ( | Town * | t | ) |
Update the total cargo acceptance of the whole town.
t | The town to update. |
Definition at line 701 of file town_cmd.cpp.
References Town::cargo_accepted, Town::cargo_accepted_total, TileMatrix< T, N >::GetArea(), TILE_AREA_LOOP, TileX(), and TileY().
Referenced by UpdateTownCargoes().
|
static |
Towns are processed every TOWN_GROWTH_TICKS ticks, and this is the number of times towns are processed before a new building is built.
Definition at line 3102 of file town_cmd.cpp.
References _settings_game, Town::cache, Chance16(), ClrBit(), DistanceSquare(), GameSettings::economy, Town::flags, Town::fund_buildings_months, GetSnowLine(), GetTropicZone(), Town::goal, Town::grow_counter, Town::growth_rate, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Town::larger_town, min(), TownCache::num_houses, TransportedCargoStat< Tstorage >::old_act, TownCache::population, Town::received, SetBit(), SetWindowDirty(), TownCache::squared_town_zone_radius, TE_END, TileHeight(), TOWN_GROW_RATE_CUSTOM, TOWN_GROW_RATE_CUSTOM_NONE, TOWN_GROWTH_DESERT, EconomySettings::town_growth_rate, TOWN_GROWTH_WINTER, TOWN_IS_GROWING, TROPICZONE_DESERT, WC_TOWN_VIEW, BaseStation::xy, and Town::xy.
Referenced by CmdTownCargoGoal(), and CmdTownGrowthRate().
const TileTypeProcs _tile_type_town_procs |
Tile callback functions for a town.
const byte _town_action_costs[TACT_COUNT] |
Factor in the cost of each town action.
Definition at line 2756 of file town_cmd.cpp.
Referenced by TownAuthorityWindow::DrawWidget(), and TownAuthorityWindow::UpdateWidgetSize().
|
static |
Definition at line 2977 of file town_cmd.cpp.
|
static |
Definition at line 193 of file town_cmd.cpp.