44 #include "table/strings.h" 67 for (
TileIndex t = begin; t != end; t += delta) {
87 if (_bridge[i].sprite_table != NULL) {
88 for (
BridgePieces j = BRIDGE_PIECE_NORTH; j < BRIDGE_PIECE_INVALID; j++)
free(_bridge[i].sprite_table[j]);
89 free(_bridge[i].sprite_table);
94 memset(&_bridge, 0,
sizeof(_bridge));
96 memcpy(&_bridge, &_orig_bridge,
sizeof(_orig_bridge));
107 if (length < 2)
return length;
111 for (
int delta = 1;; delta++) {
112 for (
int count = 0; count < delta; count++) {
113 if (length == 0)
return sum;
152 assert(table < BRIDGE_PIECE_INVALID);
154 return _bridge_sprite_table[index][table];
252 TransportType transport_type = Extract<TransportType, 15, 2>(p2);
255 switch (transport_type) {
257 roadtypes = Extract<RoadTypes, 8, 2>(p2);
262 railtype = Extract<RailType, 8, 4>(p2);
288 if (tile_start == tile_end) {
295 }
else if (
TileY(tile_start) ==
TileY(tile_end)) {
301 if (tile_end < tile_start)
Swap(tile_start, tile_end);
307 if (ret.
Failed())
return ret;
316 bool pbs_reservation =
false;
323 if (z_start != z_end)
return_cmd_error(STR_ERROR_BRIDGEHEADS_NOT_SAME_HEIGHT);
341 _game_mode != GM_EDITOR) {
362 cost.
AddCost((bridge_len + 1) * _price[PR_CLEAR_BRIDGE]);
367 if (is_new_owner) owner = company;
369 switch (transport_type) {
389 if (ret.
Failed())
return ret;
392 if (terraform_cost_north.
Failed() || (terraform_cost_north.
GetCost() != 0 && !allow_on_slopes))
return_cmd_error(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
393 cost.
AddCost(terraform_cost_north);
397 if (ret.
Failed())
return ret;
401 if (terraform_cost_south.
Failed() || (terraform_cost_south.
GetCost() != 0 && !allow_on_slopes))
return_cmd_error(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
402 cost.
AddCost(terraform_cost_south);
404 const TileIndex heads[] = {tile_start, tile_end};
405 for (
int i = 0; i < 2; i++) {
418 for (
TileIndex tile = tile_start + delta; tile != tile_end; tile += delta) {
469 if (ret.
Failed())
return ret;
491 switch (transport_type) {
518 MakeRoadBridgeRamp(tile_start, owner, owner_road, owner_tram, bridge_type, dir, roadtypes);
552 switch (transport_type) {
561 cost.
AddCost((int64)bridge_len * _price[PR_BUILD_BRIDGE] *
GetBridgeSpec(bridge_type)->price >> 8);
564 cost.
AddCost((int64)bridge_len * _price[PR_BUILD_AQUEDUCT]);
587 TransportType transport_type = Extract<TransportType, 8, 2>(p1);
592 switch (transport_type) {
594 railtype = Extract<RailType, 0, 4>(p1);
599 rts = Extract<RoadTypes, 0, 2>(p1);
627 if (ret.
Failed())
return ret;
658 if (start_z == end_z)
break;
665 if (tiles == tiles_bump) {
670 cost.
AddCost(_price[PR_BUILD_TUNNEL]);
675 cost.
AddCost(_price[PR_BUILD_TUNNEL]);
696 coa = _cleared_object_areas.Append();
709 cost.
AddCost(_price[PR_BUILD_TUNNEL]);
712 switch (transport_type) {
715 default: NOT_REACHED();
786 default: NOT_REACHED();
799 if (ret.
Failed())
return ret;
804 if (ret.
Failed())
return ret;
815 if (ret.
Failed())
return ret;
845 DoClearSquare(endtile);
867 DoClearSquare(endtile);
883 if (ret.
Failed())
return ret;
888 if (ret.
Failed())
return ret;
900 if (ret.
Failed())
return ret;
943 DoClearSquare(endtile);
944 for (
TileIndex c = tile + delta; c != endtile; c += delta) {
1000 AddSortableSpriteToDraw(psid->
sprite, psid->
pal, x, y, w, h,
BB_HEIGHT_UNDER_BRIDGE - PILLAR_Z_OFFSET, z,
IsTransparencySet(
TO_BRIDGES), 0, 0, -PILLAR_Z_OFFSET, subsprite);
1017 for (cur_z = z_top; cur_z >= z_bottom; cur_z -=
TILE_HEIGHT) {
1036 static const int bounding_box_size[2] = {16, 2};
1037 static const int back_pillar_offset[2] = { 0, 9};
1039 static const int INF = 1000;
1040 static const SubSprite half_pillar_sub_sprite[2][2] = {
1041 { { -14, -INF, INF, INF }, { -INF, -INF, -15, INF } },
1042 { { -INF, -INF, 15, INF }, { 16, -INF, INF, INF } },
1045 if (psid->
sprite == 0)
return;
1049 int z_front_north = ti->
z;
1050 int z_back_north = ti->
z;
1051 int z_front_south = ti->
z;
1052 int z_back_south = ti->
z;
1057 int z_front =
max(z_front_north, z_front_south);
1058 int z_back =
max(z_back_north, z_back_south);
1061 int w = bounding_box_size[axis];
1062 int h = bounding_box_size[
OtherAxis(axis)];
1064 int x_back = x - back_pillar_offset[axis];
1065 int y_back = y - back_pillar_offset[
OtherAxis(axis)];
1069 if (z_front_north < z_front)
DrawPillar(psid, x, y, bottom_z, w, h, &half_pillar_sub_sprite[axis][0]);
1070 if (z_front_south < z_front)
DrawPillar(psid, x, y, bottom_z, w, h, &half_pillar_sub_sprite[axis][1]);
1073 int z_bridge_back = z_bridge - 2 * (int)
TILE_HEIGHT;
1074 if (drawfarpillar && (z_back_north <= z_bridge_back || z_back_south <= z_bridge_back)) {
1075 bottom_z =
DrawPillarColumn(z_back, z_bridge_back, psid, x_back, y_back, w, h);
1076 if (z_back_north < z_back)
DrawPillar(psid, x_back, y_back, bottom_z, w, h, &half_pillar_sub_sprite[axis][0]);
1077 if (z_back_south < z_back)
DrawPillar(psid, x_back, y_back, bottom_z, w, h, &half_pillar_sub_sprite[axis][1]);
1092 static const SpriteID tram_offsets[2][6] = { { 107, 108, 109, 110, 111, 112 }, { 4, 5, 15, 16, 17, 18 } };
1093 static const SpriteID back_offsets[6] = { 95, 96, 99, 102, 100, 101 };
1094 static const SpriteID front_offsets[6] = { 97, 98, 103, 106, 104, 105 };
1096 static const uint size_x[6] = { 1, 16, 16, 1, 16, 1 };
1097 static const uint size_y[6] = { 16, 1, 1, 16, 1, 16 };
1098 static const uint front_bb_offset_x[6] = { 15, 0, 0, 15, 0, 15 };
1099 static const uint front_bb_offset_y[6] = { 0, 15, 15, 0, 15, 0 };
1105 x, y, size_x[offset], size_y[offset], 0x28, z,
1112 x, y, size_x[offset], size_y[offset], 0x28, z,
1123 x, y, size_x[offset] + front_bb_offset_x[offset], size_y[offset] + front_bb_offset_y[offset], 0x28, z,
1156 static const int _tunnel_BB[4][12] = {
1159 { 1, 0, -15, -14, 0, 15, 16, 1, 0, 1, 16, 15 },
1160 { 0, 1, -14, -15, 15, 0, 1, 16, 1, 0, 15, 16 },
1161 { 1, 0, -15, -14, 0, 15, 16, 1, 0, 1, 16, 15 },
1162 { 0, 1, -14, -15, 15, 0, 1, 16, 1, 0, 15, 16 },
1164 const int *BB_data = _tunnel_BB[tunnelbridge_direction];
1166 bool catenary =
false;
1173 if (rti->UsesOverlay()) {
1179 image = SPR_TUNNEL_ENTRY_REAR_ROAD;
1184 image += tunnelbridge_direction * 2;
1191 static const SpriteID tunnel_sprites[2][4] = { { 28, 78, 79, 27 }, { 5, 76, 77, 4 } };
1199 AddSortableSpriteToDraw(SPR_TRAMWAY_TUNNEL_WIRES + tunnelbridge_direction, PAL_NONE, ti->
x, ti->
y, BB_data[10], BB_data[11],
TILE_HEIGHT, ti->
z,
IsTransparencySet(
TO_CATENARY), BB_data[8], BB_data[9],
BB_Z_SEPARATOR);
1204 if (rti->UsesOverlay()) {
1206 if (surface != 0)
DrawGroundSprite(surface + tunnelbridge_direction, PAL_NONE);
1211 if (rti->UsesOverlay()) {
1232 AddSortableSpriteToDraw(image + 1, PAL_NONE, ti->
x +
TILE_SIZE - 1, ti->
y +
TILE_SIZE - 1, BB_data[0], BB_data[1],
TILE_HEIGHT, ti->
z,
false, BB_data[2], BB_data[3],
BB_Z_SEPARATOR);
1234 if (railtype_overlay != 0)
AddSortableSpriteToDraw(railtype_overlay + tunnelbridge_direction, PAL_NONE, ti->
x +
TILE_SIZE - 1, ti->
y +
TILE_SIZE - 1, BB_data[0], BB_data[1],
TILE_HEIGHT, ti->
z,
false, BB_data[2], BB_data[3],
BB_Z_SEPARATOR);
1250 assert(base_offset != 8);
1256 assert( (base_offset & 0x07) == 0x00);
1261 base_offset += (6 - tunnelbridge_direction) % 4;
1266 psid = &GetBridgeSpriteTable(
GetBridgeType(ti->
tile), BRIDGE_PIECE_HEAD)[base_offset];
1268 psid = _aqueduct_sprites + base_offset;
1274 DrawShoreTile(ti->
tileh);
1276 DrawClearLandTile(ti, 3);
1297 uint offset = tunnelbridge_direction;
1300 offset = (offset + 1) & 1;
1311 if (rti->UsesOverlay()) {
1327 if (rti->UsesOverlay()) {
1375 return BRIDGE_PIECE_NORTH;
1376 }
else if (south == 1) {
1377 return BRIDGE_PIECE_SOUTH;
1378 }
else if (north < south) {
1379 return north & 1 ? BRIDGE_PIECE_INNER_SOUTH : BRIDGE_PIECE_INNER_NORTH;
1380 }
else if (north > south) {
1381 return south & 1 ? BRIDGE_PIECE_INNER_NORTH : BRIDGE_PIECE_INNER_SOUTH;
1383 return north & 1 ? BRIDGE_PIECE_MIDDLE_EVEN : BRIDGE_PIECE_MIDDLE_ODD;
1434 psid = base_offset + GetBridgeSpriteTable(type, piece);
1436 drawfarpillar =
true;
1437 psid = _aqueduct_sprites;
1440 if (axis !=
AXIS_X) psid += 4;
1456 AddSortableSpriteToDraw(psid->
sprite, psid->
pal, x, y, 16, 1, 0x28, z,
IsTransparencySet(
TO_BRIDGES), 0, 0, BRIDGE_Z_START);
1458 AddSortableSpriteToDraw(psid->
sprite, psid->
pal, x, y, 1, 16, 0x28, z,
IsTransparencySet(
TO_BRIDGES), 0, 0, BRIDGE_Z_START);
1484 if (rti->UsesOverlay()) {
1503 if (psid->
sprite &
SPRITE_MASK)
AddSortableSpriteToDraw(psid->
sprite, psid->
pal, x, y, 16, 4, 0x28, z,
IsTransparencySet(
TO_BRIDGES), 0, 3, BRIDGE_Z_START);
1506 if (psid->
sprite &
SPRITE_MASK)
AddSortableSpriteToDraw(psid->
sprite, psid->
pal, x, y, 4, 16, 0x28, z,
IsTransparencySet(
TO_BRIDGES), 3, 0, BRIDGE_Z_START);
1517 if (ti->
z + 5 == z) {
1536 static int GetSlopePixelZ_TunnelBridge(
TileIndex tile, uint x, uint y)
1548 if (5 <= pos && pos <= 10)
return z;
1556 if (5 <= pos && pos <= 10) {
1562 default: NOT_REACHED();
1568 return z + 1 + delta;
1585 td->
str = (tt ==
TRANSPORT_RAIL) ? STR_LAI_TUNNEL_DESCRIPTION_RAILROAD : STR_LAI_TUNNEL_DESCRIPTION_ROAD;
1602 td->
owner_type[i] = STR_LAND_AREA_INFORMATION_ROAD_OWNER;
1603 td->
owner[i] = road_owner;
1607 td->
owner_type[i] = STR_LAND_AREA_INFORMATION_TRAM_OWNER;
1608 td->
owner[i] = tram_owner;
1619 if (td->
rail_speed == 0 || spd < td->rail_speed) {
1629 static void TileLoop_TunnelBridge(
TileIndex tile)
1667 static void ChangeTileOwner_TunnelBridge(
TileIndex tile,
Owner old_owner,
Owner new_owner)
1680 Company::Get(old_owner)->infrastructure.road[rt] -= num_pieces * 2;
1736 int z = GetSlopePixelZ(x, y) - v->
z_pos;
1755 SndPlayVehicleFx(SND_05_TRAIN_THROUGH_TUNNEL, v);
1782 assert(frame == rv->frame + 1);
1836 default: NOT_REACHED();
1870 default: NOT_REACHED();
1902 extern const TileTypeProcs _tile_type_tunnelbridge_procs = {
1904 GetSlopePixelZ_TunnelBridge,
1907 GetTileDesc_TunnelBridge,
1908 GetTileTrackStatus_TunnelBridge,
1911 TileLoop_TunnelBridge,
1912 ChangeTileOwner_TunnelBridge,
1914 VehicleEnter_TunnelBridge,
1915 GetFoundation_TunnelBridge,
1916 TerraformTile_TunnelBridge,
TileIndex GetOtherBridgeEnd(TileIndex tile)
Starting at one bridge end finds the other bridge end.
static bool HasSlopeHighestCorner(Slope s)
Tests if a slope has a highest corner (i.e.
Functions related to OTTD's strings.
static TileType GetTileType(TileIndex tile)
Get the tiletype of a given tile.
don't allow building on structures
uint ApplyFoundationToSlope(Foundation f, Slope *s)
Applies a foundation to a slope.
static void Swap(T &a, T &b)
Type safe swap operation.
TileIndex first_tile
The first tile being cleared, which then causes the whole object to be cleared.
struct RailtypeInfo::@36 base_sprites
Struct containing the main sprites.
static void ClearBridgeMiddle(TileIndex t)
Removes bridges from the given, that is bridges along the X and Y axis.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition of stuff that is very close to a company, like the company struct itself.
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
static const PaletteID PALETTE_TO_TRANSPARENT
This sets the sprite to transparent.
static const int BRIDGE_Z_START
Z position of the bridge sprites relative to bridge height (downwards)
NewGRF handling of rail types.
static const RailtypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
Year avail_year
the year where it becomes available
static TropicZone GetTropicZone(TileIndex tile)
Get the tropic zone.
static TransportType GetTunnelBridgeTransportType(TileIndex t)
Tunnel: Get the transport type of the tunnel (road or rail) Bridge: Get the transport type of the bri...
ObjectFlags flags
Flags/settings related to the object.
static void SetTunnelBridgeReservation(TileIndex t, bool b)
Set the reservation state of the rail tunnel/bridge.
static void SetTileOwner(TileIndex tile, Owner owner)
Sets the owner of a tile.
Tile information, used while rendering the tile.
south and east corner are raised
SpriteID single_sloped
single piece of rail for slopes
void DrawRailCatenaryOnBridge(const TileInfo *ti)
Draws wires on a tunnel tile.
static DiagDirection DirToDiagDir(Direction dir)
Convert a Direction to a DiagDirection.
byte landscape
the landscape we're currently in
DirectionByte direction
facing
RailType
Enumeration for all possible railtypes.
The mask to for the main sprite.
bool HasBridgeFlatRamp(Slope tileh, Axis axis)
Determines if the track on a bridge ramp is flat or goes up/down.
uint32 squared_town_zone_radius[HZB_END]
UpdateTownRadius updates this given the house count.
uint GetPartialPixelZ(int x, int y, Slope corners)
Determines height at given coordinate of a slope.
Flag for an invalid DiagDirection.
int32 TileIndexDiff
An offset value between to tiles.
static bool IsWater(TileIndex t)
Is it a plain water tile?
void ResetBridges()
Reset the data been eventually changed by the grf loaded.
static Titem * Get(size_t index)
Returns Titem with given index.
static bool IsBridgeTile(TileIndex t)
checks if there is a bridge on this tile
Functions related to dates.
static WaterClass GetWaterClass(TileIndex t)
Get the water class at a tile.
penalty for removing town owned tunnel or bridge
Base for the train class.
static const byte TUNNEL_SOUND_FRAME
Frame when the 'enter tunnel' sound should be played.
PalSpriteID ** sprite_table
table of sprites for drawing the bridge
static T SetBit(T &x, const uint8 y)
Set a bit in a variable.
Track
These are used to specify a single track.
uint16 cur_speed
current speed
query cost only, don't build.
A tile with road (or tram tracks)
static const CommandCost CMD_ERROR
Define a default return value for a failed command.
Slope tileh
Slope of the tile.
static const uint BB_Z_SEPARATOR
Separates the bridge/tunnel from the things under/above it.
static void SetTunnelBridgeSnowOrDesert(TileIndex t, bool snow_or_desert)
Tunnel: Places this tunnel entrance in a snowy or desert area, or takes it out of there...
bool extra_dynamite
extra dynamite
bool ValParamRailtype(const RailType rail)
Validate functions for rail building.
static void MakeRailTunnel(TileIndex t, Owner o, DiagDirection d, RailType r)
Makes a rail tunnel entrance.
Piece of rail on slope with north-east raised.
Functions related to vehicles.
static TrackBits DiagDirToDiagTrackBits(DiagDirection diagdir)
Maps a (4-way) direction to the diagonal track bits incidating with that diagdir. ...
void AddSideToSignalBuffer(TileIndex tile, DiagDirection side, Owner owner)
Add side of tile to signal update buffer.
static bool HasTileWaterGround(TileIndex t)
Checks whether the tile has water at the ground.
static uint TileX(TileIndex tile)
Get the X component of a tile.
Combination of a palette sprite and a 'real' sprite.
static int DrawPillarColumn(int z_bottom, int z_top, const PalSpriteID *psid, int x, int y, int w, int h)
Draw two bridge pillars (north and south).
Tile description for the 'land area information' tool.
CommandCost CheckTileOwnership(TileIndex tile)
Check whether the current owner owns the stuff on the given tile.
TrackBitsByte state
The "track" the ship is following.
Tindex index
Index of this pool item.
#define FOR_EACH_SET_ROADTYPE(var, road_types)
Iterate through each set RoadType in a RoadTypes value.
static Roadside GetRoadside(TileIndex tile)
Get the decorations of a road.
Northeast, upper right on your monitor.
uint16 speed
maximum travel speed (1 unit = 1/1.6 mph = 1 km-ish/h)
Allow incrementing of ObjectClassID variables.
static CommandCost CheckAllowRemoveTunnelBridge(TileIndex tile)
Are we allowed to remove the tunnel or bridge at tile?
Helper functions to extract data from command parameters.
int GetBridgeHeight(TileIndex t)
Get the height ('z') of a bridge.
static Track DiagDirToDiagTrack(DiagDirection diagdir)
Maps a (4-way) direction to the diagonal track incidating with that diagdir.
static void MakeRoadBridgeRamp(TileIndex t, Owner o, Owner owner_road, Owner owner_tram, BridgeType bridgetype, DiagDirection d, RoadTypes r)
Make a bridge ramp for roads.
const byte _tunnel_visibility_frame[DIAGDIR_END]
Frame when a vehicle should be hidden in a tunnel with a certain direction.
static CommandCost CheckBridgeSlopeNorth(Axis axis, Slope *tileh, int *z)
Determines the foundation for the north bridge head, and tests if the resulting slope is valid...
static Track AxisToTrack(Axis a)
Convert an Axis to the corresponding Track AXIS_X -> TRACK_X AXIS_Y -> TRACK_Y Uses the fact that the...
Money GetCost() const
The costs as made up to this moment.
bool IsTunnelInWayDir(TileIndex tile, int z, DiagDirection dir)
Is there a tunnel in the way in the given direction?
Contains objects such as transmitters and owned land.
south and west corner are raised
Common return value for all commands.
static bool HasExactlyOneBit(T value)
Test whether value has exactly 1 bit set.
void StartSpriteCombine()
Starts a block of sprites, which are "combined" into a single bounding box.
RoadType
The different roadtypes we support.
static void DrawPillar(const PalSpriteID *psid, int x, int y, int z, int w, int h, const SubSprite *subsprite)
Draw a single pillar sprite.
static T max(const T a, const T b)
Returns the maximum of two values.
Year _cur_year
Current year, starting at 0.
Struct containing information about a single bridge type.
struct RailtypeInfo::@39 strings
Strings associated with the rail type.
static Train * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
Road with paved sidewalks.
uint16 rail_speed
Speed limit of rail (bridges and track)
static const uint TILE_SIZE
Tile size in world coordinates.
void DrawFoundation(TileInfo *ti, Foundation f)
Draw foundation f at tile ti.
void AddCost(const Money &cost)
Adds the given cost to the cost of the command.
Owner owner[4]
Name of the owner(s)
TileIndex GetNorthernBridgeEnd(TileIndex t)
Finds the northern end of a bridge starting at a middle tile.
void YapfNotifyTrackLayoutChange(TileIndex tile, Track track)
Use this function to notify YAPF that track layout (or signal configuration) has change.
north and east corner are raised
This struct contains all the info that is needed to draw and construct tracks.
int GetTileZ(TileIndex tile)
Get bottom height of the tile.
company bankrupts, skip money check, skip vehicle on tile check in some cases
void DrawBridgeMiddle(const TileInfo *ti)
Draw the middle bits of a bridge.
Functions related to (drawing on) viewports.
Functions related to NewGRF objects.
The object is owned by a superuser / goal script.
Slope GetTileSlope(TileIndex tile, int *h)
Return the slope of a given tile inside the map.
static bool IsValidTile(TileIndex tile)
Checks if a tile is valid.
SpriteID single_y
single piece of rail in Y direction, without ground
void EndSpriteCombine()
Terminates a block of sprites started by StartSpriteCombine.
static bool IsBridgeAbove(TileIndex t)
checks if a bridge is set above the ground of this tile
Buses, trucks and trams belong to this class.
Querying information about stuff on the bridge (via some bridgehead).
static bool IsTileOwner(TileIndex tile, Owner owner)
Checks if a tile belongs to the given owner.
Town * ClosestTownFromTile(TileIndex tile, uint threshold)
Return the town closest (in distance or ownership) to a given tile, within a given threshold...
uint8 height
The height of this structure, in heightlevels; max MAX_TILE_HEIGHT.
static Slope ComplementSlope(Slope s)
Return the complement of a slope.
SpriteID GetCustomRailSprite(const RailtypeInfo *rti, TileIndex tile, RailTypeSpriteGroup rtsg, TileContext context, uint *num_results)
Get the sprite to draw for the given tile.
uint x
X position of the tile in unit coordinates.
static TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
OrthogonalTileArea TileArea
Shorthand for the much more common orthogonal tile area.
Foundation
Enumeration for Foundations.
Types related to cheating.
TileIndex xy
town center tile
TileIndex tile
Tile index.
static uint ApplyPixelFoundationToSlope(Foundation f, Slope *s)
Applies a foundation to a slope.
CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags)
Shorthand for calling the long DoCommand with a container.
static bool IsCoast(TileIndex t)
Is it a coast tile?
Sloped rail pieces, in order NE, SE, SW, NW.
static Owner GetRoadOwner(TileIndex t, RoadType rt)
Get the owner of a specific road type.
Piece of rail in X direction.
StringID owner_type[4]
Type of each owner.
Road with trees on paved sidewalks.
Header file for things common for tunnels and bridges.
static void SetRoadOwner(TileIndex t, RoadType rt, Owner o)
Set the owner of a specific road type.
void DirtyCompanyInfrastructureWindows(CompanyID company)
Redraw all windows with company infrastructure counts.
Images for overlaying track.
bool HasRoadTypesAvail(const CompanyID company, const RoadTypes rts)
Finds out, whether given company has all given RoadTypes available.
Entry point for OpenTTD to YAPF's cache.
The vehicle is in a tunnel and/or bridge.
CommandCost TunnelBridgeIsFree(TileIndex tile, TileIndex endtile, const Vehicle *ignore)
Finds vehicle in tunnel / bridge.
static Owner GetTileOwner(TileIndex tile)
Returns the owner of a tile.
static DiagDirection ReverseDiagDir(DiagDirection d)
Returns the reverse direction of the given DiagDirection.
DoCommandFlag
List of flags for a command.
int CalcBridgeLenCostFactor(int length)
Calculate the price factor for building a long bridge.
static uint GetTunnelBridgeLength(TileIndex begin, TileIndex end)
Calculates the length of a tunnel or a bridge (without end tiles)
The vehicle either entered a bridge, tunnel or depot tile (this includes the last tile of the bridge/...
ClientSettings _settings_client
The current settings for this game.
Piece of rail in X direction.
bool Succeeded() const
Did this command succeed?
Keeps track of removed objects during execution/testruns of commands.
Definition of base types and functions in a cross-platform compatible way.
static const BridgeSpec * GetBridgeSpec(BridgeType i)
Get the specification of a bridge type.
uint32 road[ROADTYPE_END]
Count of company owned track bits for each road type.
static const uint BB_HEIGHT_UNDER_BRIDGE
Some values for constructing bounding boxes (BB).
A number of safeguards to prevent using unsafe methods.
bool value
tells if the bool cheat is active or not
BridgeSpec _bridge[MAX_BRIDGES]
The specification of all bridges.
TileArea area
The area of the object.
The vehicle cannot enter the tile.
uint y
Y position of the tile in unit coordinates.
Foundation GetBridgeFoundation(Slope tileh, Axis axis)
Get the foundation for a bridge.
void DrawRailCatenaryOnTunnel(const TileInfo *ti)
Draws wires on a tunnel tile.
static Slope GetTilePixelSlope(TileIndex tile, int *h)
Return the slope of a given tile.
static CommandCost DoClearBridge(TileIndex tile, DoCommandFlag flags)
Remove a bridge from the game, update town rating, etc.
static const uint TILE_HEIGHT
Height of a height level in world coordinate AND in pixels in #ZOOM_LVL_BASE.
Train * GetTrainForReservation(TileIndex tile, Track track)
Find the train which has reserved a specific path.
GUI Functions related to companies.
static const uint TUNNELBRIDGE_TRACKBIT_FACTOR
Multiplier for how many regular track bits a tunnel/bridge counts.
uint16 max_bridge_length
maximum length of bridges
bool IsFrontEngine() const
Check if the vehicle is a front engine.
uint16 max_speed
Maximum speed for vehicles travelling on this rail type.
byte min_length
the minimum length (not counting start and end tile)
TileIndex tile
Current tile index.
CommandCost CheckOwnership(Owner owner, TileIndex tile)
Check whether the current owner owns something.
bool is_ai
If true, the company is (also) controlled by the computer (a NoAI program).
The tile has no ownership.
static Trackdir DiagDirToDiagTrackdir(DiagDirection diagdir)
Maps a (4-way) direction to the diagonal trackdir that runs in that direction.
SpriteID single_x
single piece of rail in X direction, without ground
BridgePieces
This enum is related to the definition of bridge pieces, which is used to determine the proper sprite...
DiagDirection
Enumeration for diagonal directions.
CommandCost CmdBuildTunnel(TileIndex start_tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Build Tunnel.
static T min(const T a, const T b)
Returns the minimum of two values.
static Foundation FlatteningFoundation(Slope s)
Returns the foundation needed to flatten a slope.
StringID railtype
Type of rail on the tile.
static void MakeRailBridgeRamp(TileIndex t, Owner o, BridgeType bridgetype, DiagDirection d, RailType r)
Make a bridge ramp for rails.
TileIndex GetSouthernBridgeEnd(TileIndex t)
Finds the southern end of a bridge starting at a middle tile.
static DiagDirection GetInclinedSlopeDirection(Slope s)
Returns the direction of an inclined slope.
Functions related to autoslope.
Functions related to sound.
static void SetBridgeMiddle(TileIndex t, Axis a)
Set that there is a bridge over the given axis.
ClearedObjectArea * FindClearedObject(TileIndex tile)
Find the entry in _cleared_object_areas which occupies a certain tile.
static DiagDirection GetTunnelBridgeDirection(TileIndex t)
Get the direction pointing to the other end.
Vehicle is currently going uphill. (Cached track information for acceleration)
static bool AutoslopeEnabled()
Tests if autoslope is enabled for _current_company.
Vehicle * First() const
Get the first vehicle of this vehicle chain.
static TrackStatus CombineTrackStatus(TrackdirBits trackdirbits, TrackdirBits red_signals)
Builds a TrackStatus.
bool build_on_slopes
allow building on slopes
bool Failed() const
Did this command fail?
Piece of rail in Y direction.
All ships have this type.
RoadTypes
The different roadtypes we support, but then a bitmask of them.
static Axis GetBridgeAxis(TileIndex t)
Get the axis of the bridge that goes over the tile.
void AddSortableSpriteToDraw(SpriteID image, PaletteID pal, int x, int y, int w, int h, int dz, int z, bool transparent, int bb_offset_x, int bb_offset_y, int bb_offset_z, const SubSprite *sub)
Draw a (transparent) sprite at given coordinates with a given bounding box.
bool PlayVehicleSound(const Vehicle *v, VehicleSoundEvent event)
Checks whether a NewGRF wants to play a different vehicle sound effect.
#define return_cmd_error(errcode)
Returns from a function with a specific StringID as error.
static void SetRoadside(TileIndex tile, Roadside s)
Set the decorations of a road.
static const SpriteID SPR_RAILTYPE_TUNNEL_BASE
Tunnel sprites with grass only for custom railtype tunnel.
Removal of a tunnel or bridge owned by the towb.
'Train' is either a loco or a wagon.
Functions related to clear (MP_CLEAR) land.
static BridgeType GetBridgeType(TileIndex t)
Determines the type of bridge on a tile.
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset)
Mark a tile given by its index dirty for repaint.
CompanyInfrastructure infrastructure
NOSAVE: Counts of company owned infrastructure.
uint32 rail[RAILTYPE_END]
Count of company owned track bits for each rail type.
static Axis DiagDirToAxis(DiagDirection d)
Convert a DiagDirection to the axis.
Town * CalcClosestTownFromTile(TileIndex tile, uint threshold=UINT_MAX)
Return the town closest to the given tile within threshold.
Bitflag for a wormhole (used for tunnels)
static TileIndex GetOtherTunnelBridgeEnd(TileIndex t)
Determines type of the wormhole and returns its other end.
static bool HasTunnelBridgeSnowOrDesert(TileIndex t)
Tunnel: Is this tunnel entrance in a snowy or desert area? Bridge: Does the bridge ramp lie in a snow...
execute the given command
static CommandCost CheckBridgeSlopeSouth(Axis axis, Slope *tileh, int *z)
Determines the foundation for the south bridge head, and tests if the resulting slope is valid...
void GetSlopePixelZOnEdge(Slope tileh, DiagDirection edge, int *z1, int *z2)
Determine the Z height of the corners of a specific tile edge.
Vehicle is currently going downhill. (Cached track information for acceleration)
static bool IsNormalRoadTile(TileIndex t)
Return whether a tile is a normal road tile.
static void MakeRoadTunnel(TileIndex t, Owner o, DiagDirection d, RoadTypes r)
Makes a road tunnel entrance.
static T ClrBit(T &x, const uint8 y)
Clears a bit in a variable.
GUISettings gui
settings related to the GUI
Tunnel entry/exit and bridge heads.
static bool HasTunnelBridgeReservation(TileIndex t)
Get the reservation state of the rail tunnel/bridge.
uint16 max_length
the maximum length (not counting start and end tile)
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
int GetTileMaxZ(TileIndex t)
Get top height of the tile inside the map.
uint16 road_speed
Speed limit of road (bridges)
CompanyByte _current_company
Company currently doing an action.
Set of callback functions for performing tile operations of a given tile type.
uint32 TileIndex
The index/ID of a Tile.
static const PaletteID PALETTE_CRASH
Recolour sprite greying of crashed vehicles.
static BridgePieces CalcBridgePiece(uint north, uint south)
Compute bridge piece.
This file contains all the sprites for bridges It consists of a number of arrays. ...
A town owns the tile, or a town is expanding.
Cheat crossing_tunnels
allow tunnels that cross each other
static int GetBridgePixelHeight(TileIndex tile)
Get the height ('z') of a bridge in pixels.
north and west corner are raised
static Money RailBuildCost(RailType railtype)
Returns the cost of building the specified railtype.
static uint TileY(TileIndex tile)
Get the Y component of a tile.
Cheat magic_bulldozer
dynamite industries, objects
Bit sets of the above specified bits.
when a sprite is to be displayed transparently, this bit needs to be set.
static T abs(const T a)
Returns the absolute value of (scalar) variable.
The tile has no foundation, the slope remains unchanged.
void FreeTrainTrackReservation(const Train *v)
Free the reserved path in front of a vehicle.
TransportType
Available types of transport.
static const uint MAX_BRIDGES
Maximal number of available bridge specs.
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
Slope
Enumeration for the slope-type.
void DrawRailCatenary(const TileInfo *ti)
Draws overhead wires and pylons for electric railways.
TownCache cache
Container for all cacheable data.
bool show_track_reservation
highlight reserved tracks.
Used to only draw a part of the sprite.
Transport by road vehicle.
byte max_bridge_height
maximum height of bridges
static const uint TILE_UNIT_MASK
For masking in/out the inner-tile world coordinate units.
static uint CountBits(T value)
Counts the number of set bits in a variable.
Functions related to commands.
void DrawGroundSprite(SpriteID image, PaletteID pal, const SubSprite *sub, int extra_offs_x, int extra_offs_y)
Draws a ground sprite for the current tile.
byte GetSnowLine()
Get the current snow line, either variable or static.
uint BridgeType
Bridge spec number.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-NULL) Titem.
static bool HasRailCatenaryDrawn(RailType rt)
Test if we should draw rail catenary.
void MarkBridgeDirty(TileIndex begin, TileIndex end, DiagDirection direction, uint bridge_height)
Mark bridge tiles dirty.
static uint TileHeight(TileIndex tile)
Returns the height of a tile.
static void DrawBridgeTramBits(int x, int y, int z, int offset, bool overlay, bool head)
Draws the trambits over an already drawn (lower end) of a bridge.
header file for electrified rail specific functions
static Axis OtherAxis(Axis a)
Select the other axis as provided.
SpriteID bridge_offset
Bridge offset.
static const SpriteID SPR_TRAMWAY_BASE
Tramway sprites.
TileIndex GetOtherTunnelEnd(TileIndex tile)
Gets the other end of the tunnel.
static uint SlopeToSpriteOffset(Slope s)
Returns the Sprite offset for a given Slope.
static CommandCost DoClearTunnel(TileIndex tile, DoCommandFlag flags)
Remove a tunnel from the game, update town rating, etc.
ConstructionSettings construction
construction of things in-game
Functions that have tunnels and bridges in common.
static TileIndexDiff TileDiffXY(int x, int y)
Calculates an offset for the given coordinate(-offset).
static RoadTypes GetRoadTypes(TileIndex t)
Get the present road types of a tile.
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
static bool IsTunnelTile(TileIndex t)
Is this a tunnel (entrance)?
static void DrawTile_TunnelBridge(TileInfo *ti)
Draws a tunnel of bridge tile.
StringID name
Name of this rail type.
static CommandCost ClearTile_TunnelBridge(TileIndex tile, DoCommandFlag flags)
Remove a tunnel or a bridge from the game.
EngineID engine_type
The type of engine used for this vehicle.
static Foundation InclinedFoundation(Axis axis)
Returns the along a specific axis inclined foundation.
StringID str
Description of the tile.
SpriteID tunnel
tunnel sprites base
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
static bool HasTileWaterClass(TileIndex t)
Checks whether the tile has an waterclass associated.
Functions related to NewGRF provided sounds.
static TrackdirBits TrackBitsToTrackdirBits(TrackBits bits)
Converts TrackBits to TrackdirBits while allowing both directions.
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
Object can built under a bridge.
Main group of ground images for snow or desert.
GameCreationSettings game_creation
settings used during the creation of a game (map)
static bool IsPlainRail(TileIndex t)
Returns whether this is plain rails, with or without signals.
A tile without any structures, i.e. grass, rocks, farm fields etc.
static const ObjectSpec * GetByTile(TileIndex tile)
Get the specification associated with a tile.
static uint MapMaxX()
Gets the maximum X coordinate within the map, including MP_VOID.
Flag for invalid railtype.
void DrawGroundSpriteAt(SpriteID image, PaletteID pal, int32 x, int32 y, int z, const SubSprite *sub, int extra_offs_x, int extra_offs_y)
Draws a ground sprite at a specific world-coordinate relative to the current tile.
static bool IsInvisibilitySet(TransparencyOption to)
Check if the invisibility option bit is set and if we aren't in the game menu (there's never transpar...
uint DistanceSquare(TileIndex t0, TileIndex t1)
Gets the 'Square' distance between the two given tiles.
static void MakeAqueductBridgeRamp(TileIndex t, Owner o, DiagDirection d)
Make a bridge ramp for aqueducts.
Owner
Enum for all companies/owners.
Functions related to water (management)
static DiagDirection AxisToDiagDir(Axis a)
Converts an Axis to a DiagDirection.
VehicleEnterTileStatus
The returned bits of VehicleEnterTile.
SpriteID sprite
The 'real' sprite.
bool TryPathReserve(Train *v, bool mark_as_stuck=false, bool first_tile_okay=false)
Try to reserve a path to a safe position.
The tile/execution is done by "water".
static void DrawBridgePillars(const PalSpriteID *psid, const TileInfo *ti, Axis axis, bool drawfarpillar, int x, int y, int z_bridge)
Draws the pillars under high bridges.
static bool IsTunnel(TileIndex t)
Is this a tunnel (entrance)?
VehicleTypeByte type
Type of vehicle.
static bool IsTransparencySet(TransparencyOption to)
Check if the transparency option bit is set and if we aren't in the game menu (there's never transpar...
Axis
Allow incrementing of DiagDirDiff variables.
CommandCost CheckBridgeAvailability(BridgeType bridge_type, uint bridge_len, DoCommandFlag flags)
Is a bridge of the specified type and length available?
static bool IsRoadDepot(TileIndex t)
Return whether a tile is a road depot.
minimum rating after removing tunnel or bridge
static RailType GetRailType(TileIndex t)
Gets the rail type of the given tile.
static bool IsBridge(TileIndex t)
Checks if this is a bridge, instead of a tunnel.
CommandCost CheckforTownRating(DoCommandFlag flags, Town *t, TownRatingCheckType type)
Does the town authority allow the (destructive) action of the current company?
CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Build a Bridge.
void ChangeTownRating(Town *t, int add, int max, DoCommandFlag flags)
Changes town rating of the current company.
TileIndex _build_tunnel_endtile
The end of a tunnel; as hidden return from the tunnel build command for GUI purposes.
Cheats _cheats
All the cheats.
uint16 max_tunnel_length
maximum length of tunnels
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
PaletteID pal
The palette (use PAL_NONE) if not needed)
uint32 water
Count of company owned track bits for canals.