#include "stdafx.h"
#include "openttd.h"
#include "bridge_map.h"
#include "bridge.h"
#include "cmd_helper.h"
#include "rail_map.h"
#include "road_map.h"
#include "road_internal.h"
#include "sprite.h"
#include "tile_cmd.h"
#include "landscape.h"
#include "town_map.h"
#include "viewport_func.h"
#include "command_func.h"
#include "town.h"
#include "yapf/yapf.h"
#include "depot.h"
#include "newgrf.h"
#include "station_map.h"
#include "tunnel_map.h"
#include "variables.h"
#include "autoslope.h"
#include "transparency.h"
#include "tunnelbridge_map.h"
#include "window_func.h"
#include "strings_func.h"
#include "vehicle_func.h"
#include "vehicle_base.h"
#include "sound_func.h"
#include "road_func.h"
#include "tunnelbridge.h"
#include "table/sprites.h"
#include "table/strings.h"
#include "table/road_land.h"
Go to the source code of this file.
Data Structures | |
struct | DrawRoadTileStruct |
Defines | |
#define | M(x) (1 << (x)) |
Functions | |
Foundation | GetRoadFoundation (Slope tileh, RoadBits bits) |
bool | CheckAllowRemoveRoad (TileIndex tile, RoadBits remove, Owner owner, bool *edge_road, RoadType rt) |
Is it allowed to remove the given road bits from the given tile? | |
static bool | CheckAllowRemoveRoad (TileIndex tile, RoadBits remove, bool *edge_road, RoadType rt) |
static CommandCost | RemoveRoad (TileIndex tile, uint32 flags, RoadBits pieces, RoadType rt, bool crossing_check, bool town_check=true) |
Delete a piece of road. | |
CommandCost | CmdRemoveRoad (TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
Delete a piece of road. | |
static CommandCost | CheckRoadSlope (Slope tileh, RoadBits *pieces, RoadBits existing) |
Calculate the costs for roads on slopes Aside modify the RoadBits to fit on the slopes. | |
CommandCost | CmdBuildRoad (TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
Build a piece of road. | |
CommandCost | CmdBuildLongRoad (TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2) |
Build a long piece of road. | |
CommandCost | CmdRemoveLongRoad (TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2) |
Remove a long piece of road. | |
CommandCost | CmdBuildRoadDepot (TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
Build a road depot. | |
static CommandCost | RemoveRoadDepot (TileIndex tile, uint32 flags) |
static CommandCost | ClearTile_Road (TileIndex tile, byte flags) |
static bool | AlwaysDrawUnpavedRoads (TileIndex tile, Roadside roadside) |
Whether to draw unpaved roads regardless of the town zone. | |
void | DrawTramCatenary (TileInfo *ti, RoadBits tram) |
Draws the catenary for the given tile. | |
static void | DrawRoadDetail (SpriteID img, TileInfo *ti, int dx, int dy, int h) |
Draws details on/around the road. | |
static void | DrawRoadBits (TileInfo *ti) |
Draw ground sprite and road pieces. | |
static void | DrawTile_Road (TileInfo *ti) |
void | DrawRoadDepotSprite (int x, int y, DiagDirection dir, RoadType rt) |
static uint | GetSlopeZ_Road (TileIndex tile, uint x, uint y) |
static Foundation | GetFoundation_Road (TileIndex tile, Slope tileh) |
static void | GetAcceptedCargo_Road (TileIndex tile, AcceptedCargo ac) |
static void | AnimateTile_Road (TileIndex tile) |
static void | TileLoop_Road (TileIndex tile) |
static void | ClickTile_Road (TileIndex tile) |
static TrackStatus | GetTileTrackStatus_Road (TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side) |
static void | GetTileDesc_Road (TileIndex tile, TileDesc *td) |
static VehicleEnterTileStatus | VehicleEnter_Road (Vehicle *v, TileIndex tile, int x, int y) |
static void | ChangeTileOwner_Road (TileIndex tile, PlayerID old_player, PlayerID new_player) |
static CommandCost | TerraformTile_Road (TileIndex tile, uint32 flags, uint z_new, Slope tileh_new) |
Variables | |
static const uint32 | VALID_LEVEL_CROSSING_SLOPES = (M(SLOPE_SEN) | M(SLOPE_ENW) | M(SLOPE_NWS) | M(SLOPE_NS) | M(SLOPE_WSE) | M(SLOPE_EW) | M(SLOPE_FLAT)) |
static const RoadBits | _valid_tileh_slopes_road [][15] |
const byte | _road_sloped_sprites [14] |
static const Roadside | _town_road_types [][2] |
static const Roadside | _town_road_types_2 [][2] |
static const byte | _road_trackbits [16] |
static const StringID | _road_tile_strings [] |
static const byte | _roadveh_enter_depot_dir [4] |
Given the direction the road depot is pointing, this is the direction the vehicle should be travelling in in order to enter the depot. | |
const TileTypeProcs | _tile_type_road_procs |
Definition in file road_cmd.cpp.
static bool AlwaysDrawUnpavedRoads | ( | TileIndex | tile, | |
Roadside | roadside | |||
) | [static] |
Whether to draw unpaved roads regardless of the town zone.
By default, OpenTTD always draws roads as unpaved if they are on a desert tile or above the snowline. Newgrf files, however, can set a bit that allows paved roads to be built on desert tiles as they would be on grassy tiles.
tile | The tile the road is on | |
roadside | What sort of road this is |
Definition at line 955 of file road_cmd.cpp.
Referenced by DrawRoadBits().
bool CheckAllowRemoveRoad | ( | TileIndex | tile, | |
RoadBits | remove, | |||
Owner | owner, | |||
bool * | edge_road, | |||
RoadType | rt | |||
) |
Is it allowed to remove the given road bits from the given tile?
tile | the tile to remove the road from | |
remove | the roadbits that are going to be removed | |
owner | the actual owner of the roadbits of the tile | |
edge_road | are the removed bits from a town? | |
rt | the road type to remove the bits from |
Definition at line 47 of file road_cmd.cpp.
References GetAnyRoadBits(), OWNER_NONE, OWNER_TOWN, OWNER_WATER, ROAD_NE, ROAD_NONE, ROAD_NW, ROAD_SE, ROAD_SW, ROADTYPE_ROAD, and TILE_ADDXY.
Referenced by CanRemoveRoadWithStop(), and RemoveRoad().
static CommandCost CheckRoadSlope | ( | Slope | tileh, | |
RoadBits * | pieces, | |||
RoadBits | existing | |||
) | [static] |
Calculate the costs for roads on slopes Aside modify the RoadBits to fit on the slopes.
tileh | The current slope | |
pieces | The RoadBits we want to add | |
existing | The existent RoadBits |
Definition at line 361 of file road_cmd.cpp.
References CMD_ERROR, CountBits(), IsSlopeWithOneCornerRaised(), IsSteepSlope(), MirrorRoadBits(), ROAD_NONE, ROAD_X, ROAD_Y, and SLOPE_FLAT.
Referenced by CmdBuildRoad().
CommandCost CmdBuildLongRoad | ( | TileIndex | end_tile, | |
uint32 | flags, | |||
uint32 | p1, | |||
uint32 | p2 | |||
) |
Build a long piece of road.
end_tile | end tile of drag | |
flags | operation to perform | |
p1 | start tile of drag | |
p2 | various bitstuffed elements
|
Definition at line 649 of file road_cmd.cpp.
References CommandCost::AddCost(), CMD_BUILD_ROAD, CMD_ERROR, CmdFailed(), DIAGDIR_SE, DIAGDIR_SW, DoCommand(), DRD_BOTH, DRD_NONE, DRD_NORTHBOUND, DRD_SOUTHBOUND, GB(), GetTunnelBridgeDirection(), HasBit(), IsBridge(), IsInsideMM(), IsTileType(), IsValidRoadType(), MapSize(), MP_TUNNELBRIDGE, ROAD_NE, ROAD_NW, ROAD_SE, ROAD_SW, ROAD_X, ROAD_Y, TileDiffXY(), TileX(), and TileY().
CommandCost CmdBuildRoad | ( | TileIndex | tile, | |
uint32 | flags, | |||
uint32 | p1, | |||
uint32 | p2 | |||
) |
Build a piece of road.
tile | tile where to build road | |
flags | operation to perform | |
p1 | bit 0..3 road pieces to build (RoadBits) bit 4..5 road type bit 6..7 disallowed directions to toggle | |
p2 | the town that is building the road (0 if not applicable) |
Definition at line 413 of file road_cmd.cpp.
References CommandCost::AddCost(), AXIS_X, AXIS_Y, AxisToRoadBits(), CheckRoadSlope(), CMD_ERROR, CMD_LANDSCAPE_CLEAR, CmdFailed(), ComplementRoadBits(), CountBits(), DC_EXEC, DiagDirToAxis(), DoCommand(), DRD_NONE, FindFirstTrack(), GB(), CommandCost::GetCost(), GetDisallowedRoadDirections(), GetOtherTunnelBridgeEnd(), GetRailTileType(), GetRailType(), GetRoadStopDir(), GetTileOwner(), GetTileType(), GetTrackBits(), GetTunnelBridgeDirection(), GetTunnelBridgeLength(), GetTunnelBridgeTransportType(), HasBit(), HasVehicleOnTunnelBridge(), IsBridge(), IsSteepSlope(), IsTileType(), IsValidRoadType(), IsValidTownID(), MarkTileDirtyByTile(), MP_RAILWAY, MP_ROAD, MP_STATION, MP_TUNNELBRIDGE, CommandCost::MultiplyCost(), OWNER_TOWN, RAIL_TILE_NORMAL, return_cmd_error, ROAD_NONE, ROAD_X, ROAD_Y, ROADTYPE_END, ROADTYPE_ROAD, ROADTYPE_TRAM, ROADTYPES_ROAD, RoadTypeToRoadTypes(), SetDisallowedRoadDirections(), SetTownIndex(), TileOffsByDiagDir(), TRACK_BIT_X, TRACK_BIT_Y, UpdateLevelCrossing(), and YapfNotifyTrackLayoutChange().
CommandCost CmdBuildRoadDepot | ( | TileIndex | tile, | |
uint32 | flags, | |||
uint32 | p1, | |||
uint32 | p2 | |||
) |
Build a road depot.
tile | tile where to build the depot | |
flags | operation to perform | |
p1 | bit 0..1 entrance direction (DiagDirection) bit 2..3 road type | |
p2 | unused |
Definition at line 802 of file road_cmd.cpp.
References CommandCost::AddCost(), CanBuildDepotByTileh(), CMD_ERROR, CMD_LANDSCAPE_CLEAR, CmdFailed(), DC_EXEC, DoCommand(), GB(), IsBridgeAbove(), IsSteepSlope(), IsValidRoadType(), MarkTileDirtyByTile(), MayHaveBridgeAbove(), return_cmd_error, and SLOPE_FLAT.
CommandCost CmdRemoveLongRoad | ( | TileIndex | end_tile, | |
uint32 | flags, | |||
uint32 | p1, | |||
uint32 | p2 | |||
) |
Remove a long piece of road.
end_tile | end tile of drag | |
flags | operation to perform | |
p1 | start tile of drag | |
p2 | various bitstuffed elements
|
Definition at line 735 of file road_cmd.cpp.
References CommandCost::AddCost(), CMD_ERROR, CMD_REMOVE_LONG_ROAD, CmdSucceeded(), DC_EXEC, DoCommand(), GB(), GetAvailableMoneyForCommand(), CommandCost::GetCost(), HasBit(), IsInsideMM(), IsValidRoadType(), MapSize(), RemoveRoad(), ROAD_NE, ROAD_NW, ROAD_SE, ROAD_SW, ROAD_X, ROAD_Y, TileDiffXY(), TileX(), and TileY().
CommandCost CmdRemoveRoad | ( | TileIndex | tile, | |
uint32 | flags, | |||
uint32 | p1, | |||
uint32 | p2 | |||
) |
Delete a piece of road.
tile | tile where to remove road from | |
flags | operation to perform | |
p1 | bit 0..3 road pieces to remove (RoadBits) bit 4..5 road type | |
p2 | unused |
Definition at line 271 of file road_cmd.cpp.
References CMD_ERROR, GB(), IsValidRoadType(), and RemoveRoad().
static void DrawRoadBits | ( | TileInfo * | ti | ) | [static] |
Draw ground sprite and road pieces.
ti | TileInfo |
Definition at line 1012 of file road_cmd.cpp.
References AlwaysDrawUnpavedRoads(), CountBits(), DrawGroundSprite(), DrawRoadDetail(), DrawTramCatenary(), DRD_NONE, GetBridgeHeight(), GetDisallowedRoadDirections(), GetNorthernBridgeEnd(), HasBit(), IsBridgeAbove(), MayHaveBridgeAbove(), ROAD_NONE, ROAD_X, ROADTYPE_ROAD, ROADTYPE_TRAM, SLOPE_FLAT, TILE_HEIGHT, and ZOOM_LVL_DETAIL.
static void DrawRoadDetail | ( | SpriteID | img, | |
TileInfo * | ti, | |||
int | dx, | |||
int | dy, | |||
int | h | |||
) | [static] |
Draws details on/around the road.
img | the sprite to draw | |
ti | the tile to draw on | |
dx | the offset from the top of the BB of the tile | |
dy | the offset from the top of the BB of the tile | |
h | the height of the sprite to draw |
Definition at line 999 of file road_cmd.cpp.
References AddSortableSpriteToDraw(), and SLOPE_FLAT.
Referenced by DrawRoadBits().
void DrawTramCatenary | ( | TileInfo * | ti, | |
RoadBits | tram | |||
) |
Draws the catenary for the given tile.
Draw the catenary for tram road bits.
ti | information about the tile (slopes, height etc) | |
tram | the roadbits for the tram |
Definition at line 967 of file road_cmd.cpp.
References AddSortableSpriteToDraw(), BB_HEIGHT_UNDER_BRIDGE, GetBridgeHeight(), GetNorthernBridgeEnd(), IsBridgeAbove(), IsTransparencySet(), MayHaveBridgeAbove(), SLOPE_FLAT, TILE_HEIGHT, and TO_CATENARY.
Referenced by DrawRoadBits().
static CommandCost RemoveRoad | ( | TileIndex | tile, | |
uint32 | flags, | |||
RoadBits | pieces, | |||
RoadType | rt, | |||
bool | crossing_check, | |||
bool | town_check = true | |||
) | [static] |
Delete a piece of road.
tile | tile where to remove road from | |
flags | operation to perform | |
pieces | roadbits to remove | |
rt | roadtype to remove | |
crossing_check | should we check if there is a tram track when we are removing road from crossing? |
Definition at line 106 of file road_cmd.cpp.
References CommandCost::AddCost(), CheckAllowRemoveRoad(), CMD_ERROR, CMD_LANDSCAPE_CLEAR, ComplementRoadBits(), ComplementRoadTypes(), CountBits(), DC_EXEC, DoCommand(), DRD_NONE, FindFirstTrack(), GetOtherTunnelBridgeEnd(), GetRailType(), GetTileOwner(), GetTileType(), GetTownByTile(), GetTrackBits(), GetTunnelBridgeDirection(), GetTunnelBridgeLength(), GetTunnelBridgeTransportType(), HasBit(), HasVehicleOnTunnelBridge(), IsBridge(), IsTileType(), MarkTileDirtyByTile(), MP_ROAD, MP_STATION, MP_TUNNELBRIDGE, OWNER_TOWN, OWNER_WATER, return_cmd_error, ROAD_NONE, ROAD_X, ROAD_Y, ROADTYPE_ROAD, ROADTYPE_TRAM, ROADTYPES_NONE, RoadTypeToRoadTypes(), SetDisallowedRoadDirections(), SLOPE_FLAT, TileOffsByDiagDir(), and YapfNotifyTrackLayoutChange().
Referenced by CmdRemoveLongRoad(), and CmdRemoveRoad().
const byte _road_sloped_sprites[14] |
Initial value:
{ 0, 0, 2, 0, 0, 1, 0, 0, 3, 0, 0, 0, 0, 0 }
Definition at line 938 of file road_cmd.cpp.
const StringID _road_tile_strings[] [static] |
Initial value:
{ STR_1814_ROAD, STR_1814_ROAD, STR_1814_ROAD, STR_1815_ROAD_WITH_STREETLIGHTS, STR_1814_ROAD, STR_1816_TREE_LINED_ROAD, STR_1814_ROAD, STR_1814_ROAD, }
Definition at line 1394 of file road_cmd.cpp.
const byte _road_trackbits[16] [static] |
Initial value:
{ 0x0, 0x0, 0x0, 0x10, 0x0, 0x2, 0x8, 0x1A, 0x0, 0x4, 0x1, 0x15, 0x20, 0x26, 0x29, 0x3F, }
Definition at line 1338 of file road_cmd.cpp.
const byte _roadveh_enter_depot_dir[4] [static] |
Initial value:
Given the direction the road depot is pointing, this is the direction the vehicle should be travelling in in order to enter the depot.
Definition at line 1419 of file road_cmd.cpp.
const TileTypeProcs _tile_type_road_procs |
Initial value:
{ DrawTile_Road, GetSlopeZ_Road, ClearTile_Road, GetAcceptedCargo_Road, GetTileDesc_Road, GetTileTrackStatus_Road, ClickTile_Road, AnimateTile_Road, TileLoop_Road, ChangeTileOwner_Road, NULL, VehicleEnter_Road, GetFoundation_Road, TerraformTile_Road, }
const Roadside _town_road_types[][2] [static] |
Initial value:
{ { ROADSIDE_GRASS, ROADSIDE_GRASS }, { ROADSIDE_PAVED, ROADSIDE_PAVED }, { ROADSIDE_PAVED, ROADSIDE_PAVED }, { ROADSIDE_TREES, ROADSIDE_TREES }, { ROADSIDE_STREET_LIGHTS, ROADSIDE_PAVED } }
Definition at line 1231 of file road_cmd.cpp.
const Roadside _town_road_types_2[][2] [static] |
Initial value:
{ { ROADSIDE_GRASS, ROADSIDE_GRASS }, { ROADSIDE_PAVED, ROADSIDE_PAVED }, { ROADSIDE_STREET_LIGHTS, ROADSIDE_PAVED }, { ROADSIDE_STREET_LIGHTS, ROADSIDE_PAVED }, { ROADSIDE_STREET_LIGHTS, ROADSIDE_PAVED } }
Definition at line 1239 of file road_cmd.cpp.