OpenTTD Source
1.11.0-beta2
|
Go to the documentation of this file.
44 #include "table/strings.h"
67 for (
TileIndex t = begin; t != end; t += delta) {
87 if (
_bridge[i].sprite_table !=
nullptr) {
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];
172 assert(bridge_piece == BRIDGE_PIECE_NORTH || bridge_piece == BRIDGE_PIECE_SOUTH);
177 Slope valid_inclined;
178 if (bridge_piece == BRIDGE_PIECE_NORTH) {
223 Money base_cost = _price[base_price];
228 RoadType road_rt = GetRoadTypeRoad(tile);
229 RoadType tram_rt = GetRoadTypeTram(tile);
272 TransportType transport_type = Extract<TransportType, 15, 2>(p2);
275 switch (transport_type) {
277 roadtype = Extract<RoadType, 8, 6>(p2);
282 railtype = Extract<RailType, 8, 6>(p2);
308 if (tile_start == tile_end) {
315 }
else if (
TileY(tile_start) ==
TileY(tile_end)) {
321 if (tile_end < tile_start)
Swap(tile_start, tile_end);
327 if (ret.
Failed())
return ret;
337 bool pbs_reservation =
false;
344 if (z_start != z_end)
return_cmd_error(STR_ERROR_BRIDGEHEADS_NOT_SAME_HEIGHT);
356 switch (transport_type) {
364 road_rt = GetRoadTypeRoad(tile_start);
365 tram_rt = GetRoadTypeTram(tile_start);
378 RoadType existing_rt = RoadTypeIsRoad(roadtype) ? road_rt : tram_rt;
387 _game_mode != GM_EDITOR) {
414 if (is_new_owner) owner = company;
422 if (ret.
Failed())
return ret;
425 if (terraform_cost_north.
Failed() || (terraform_cost_north.
GetCost() != 0 && !allow_on_slopes))
return_cmd_error(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
426 cost.
AddCost(terraform_cost_north);
430 if (ret.
Failed())
return ret;
434 if (terraform_cost_south.
Failed() || (terraform_cost_south.
GetCost() != 0 && !allow_on_slopes))
return_cmd_error(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
435 cost.
AddCost(terraform_cost_south);
437 const TileIndex heads[] = {tile_start, tile_end};
438 for (
int i = 0; i < 2; i++) {
451 for (
TileIndex tile = tile_start + delta; tile != tile_end; tile += delta) {
502 if (ret.
Failed())
return ret;
522 if (RoadTypeIsRoad(roadtype)) road_rt = roadtype;
523 if (RoadTypeIsTram(roadtype)) tram_rt = roadtype;
531 switch (transport_type) {
560 MakeRoadBridgeRamp(tile_start, owner, owner_road, owner_tram, bridge_type, dir, road_rt, tram_rt);
594 switch (transport_type) {
611 cost.
AddCost((int64)bridge_len * _price[PR_BUILD_BRIDGE] *
GetBridgeSpec(bridge_type)->price >> 8);
614 cost.
AddCost((int64)bridge_len * _price[PR_BUILD_AQUEDUCT]);
637 TransportType transport_type = Extract<TransportType, 8, 2>(p1);
641 switch (transport_type) {
643 railtype = Extract<RailType, 0, 6>(p1);
648 roadtype = Extract<RoadType, 0, 6>(p1);
676 if (ret.
Failed())
return ret;
707 if (start_z == end_z)
break;
714 if (tiles == tiles_bump) {
719 cost.
AddCost(_price[PR_BUILD_TUNNEL]);
724 cost.
AddCost(_price[PR_BUILD_TUNNEL]);
744 if (coa ==
nullptr) {
762 assert(coa >= begin && coa < begin + _cleared_object_areas.size());
763 size_t coa_index = coa - begin;
764 assert(coa_index < UINT_MAX);
768 _cleared_object_areas[(uint)coa_index].first_tile = old_first_tile;
772 cost.
AddCost(_price[PR_BUILD_TUNNEL]);
775 switch (transport_type) {
778 default: NOT_REACHED();
816 RoadType road_rt = GetRoadTypeRoad(tile);
817 RoadType tram_rt = GetRoadTypeTram(tile);
847 default: NOT_REACHED();
860 if (ret.
Failed())
return ret;
865 if (ret.
Failed())
return ret;
876 if (ret.
Failed())
return ret;
907 DoClearSquare(endtile);
923 DoClearSquare(endtile);
940 if (ret.
Failed())
return ret;
945 if (ret.
Failed())
return ret;
957 if (ret.
Failed())
return ret;
981 bool removetile =
false;
982 bool removeendtile =
false;
999 DoClearSquare(endtile);
1001 if (removetile) RemoveDockingTile(tile);
1002 if (removeendtile) RemoveDockingTile(endtile);
1003 for (
TileIndex c = tile + delta; c != endtile; c += delta) {
1059 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);
1076 for (cur_z = z_top; cur_z >= z_bottom; cur_z -=
TILE_HEIGHT) {
1077 DrawPillar(psid, x, y, cur_z, w, h,
nullptr);
1095 static const int bounding_box_size[2] = {16, 2};
1096 static const int back_pillar_offset[2] = { 0, 9};
1098 static const int INF = 1000;
1099 static const SubSprite half_pillar_sub_sprite[2][2] = {
1100 { { -14, -INF, INF, INF }, { -INF, -INF, -15, INF } },
1101 { { -INF, -INF, 15, INF }, { 16, -INF, INF, INF } },
1104 if (psid->
sprite == 0)
return;
1108 int z_front_north = ti->
z;
1109 int z_back_north = ti->
z;
1110 int z_front_south = ti->
z;
1111 int z_back_south = ti->
z;
1116 int z_front = std::max(z_front_north, z_front_south);
1117 int z_back = std::max(z_back_north, z_back_south);
1120 int w = bounding_box_size[axis];
1121 int h = bounding_box_size[
OtherAxis(axis)];
1123 int x_back = x - back_pillar_offset[axis];
1124 int y_back = y - back_pillar_offset[
OtherAxis(axis)];
1128 if (z_front_north < z_front)
DrawPillar(psid, x, y, bottom_z, w, h, &half_pillar_sub_sprite[axis][0]);
1129 if (z_front_south < z_front)
DrawPillar(psid, x, y, bottom_z, w, h, &half_pillar_sub_sprite[axis][1]);
1132 int z_bridge_back = z_bridge - 2 * (int)
TILE_HEIGHT;
1133 if (drawfarpillar && (z_back_north <= z_bridge_back || z_back_south <= z_bridge_back)) {
1134 bottom_z =
DrawPillarColumn(z_back, z_bridge_back, psid, x_back, y_back, w, h);
1135 if (z_back_north < z_back)
DrawPillar(psid, x_back, y_back, bottom_z, w, h, &half_pillar_sub_sprite[axis][0]);
1136 if (z_back_south < z_back)
DrawPillar(psid, x_back, y_back, bottom_z, w, h, &half_pillar_sub_sprite[axis][1]);
1151 static const SpriteID back_offsets[6] = { 95, 96, 99, 102, 100, 101 };
1152 static const SpriteID front_offsets[6] = { 97, 98, 103, 106, 104, 105 };
1157 if (spr_back == 0 && spr_front == 0) {
1161 if (spr_back != 0) spr_back += 23 + offset;
1162 if (spr_front != 0) spr_front += 23 + offset;
1177 RoadType road_rt = GetRoadTypeRoad(head_tile);
1178 RoadType tram_rt = GetRoadTypeTram(head_tile);
1183 bool trans_back[4] = {
false };
1185 bool trans_front[4] = {
false };
1187 static const SpriteID overlay_offsets[6] = { 0, 1, 11, 12, 13, 14 };
1191 if (road_rti !=
nullptr) {
1192 if (road_rti->UsesOverlay()) {
1195 }
else if (tram_rti !=
nullptr) {
1196 if (tram_rti->UsesOverlay()) {
1199 seq_back[0] = SPR_TRAMWAY_BRIDGE + offset;
1205 if (road_rti !=
nullptr) {
1206 if (road_rti->UsesOverlay()) {
1208 if (seq_back[1] != 0) seq_back[1] += overlay_offsets[offset];
1214 if (tram_rti !=
nullptr) {
1215 if (tram_rti->UsesOverlay()) {
1217 if (seq_back[2] != 0) seq_back[2] += overlay_offsets[offset];
1218 }
else if (road_rti !=
nullptr) {
1219 seq_back[2] = SPR_TRAMWAY_OVERLAY + overlay_offsets[offset];
1233 static const uint size_x[6] = { 1, 16, 16, 1, 16, 1 };
1234 static const uint size_y[6] = { 16, 1, 1, 16, 1, 16 };
1235 static const uint front_bb_offset_x[6] = { 15, 0, 0, 15, 0, 15 };
1236 static const uint front_bb_offset_y[6] = { 0, 15, 15, 0, 15, 0 };
1240 for (uint i = 0; i <
lengthof(seq_back); ++i) {
1241 if (seq_back[i] != 0) {
1243 x, y, size_x[offset], size_y[offset], 0x28, z,
1252 for (uint i = 0; i <
lengthof(seq_front); ++i) {
1253 if (seq_front[i] != 0) {
1255 x, y, size_x[offset] + front_bb_offset_x[offset], size_y[offset] + front_bb_offset_y[offset], 0x28, z,
1257 front_bb_offset_x[offset], front_bb_offset_y[offset]);
1290 static const int _tunnel_BB[4][12] = {
1293 { 1, 0, -15, -14, 0, 15, 16, 1, 0, 1, 16, 15 },
1294 { 0, 1, -14, -15, 15, 0, 1, 16, 1, 0, 15, 16 },
1295 { 1, 0, -15, -14, 0, 15, 16, 1, 0, 1, 16, 15 },
1296 { 0, 1, -14, -15, 15, 0, 1, 16, 1, 0, 15, 16 },
1298 const int *BB_data = _tunnel_BB[tunnelbridge_direction];
1300 bool catenary =
false;
1307 if (rti->UsesOverlay()) {
1313 image = SPR_TUNNEL_ENTRY_REAR_ROAD;
1318 image += tunnelbridge_direction * 2;
1328 DrawRoadOverlays(ti, PAL_NONE, road_rti, tram_rti, sprite_offset, sprite_offset);
1334 if (catenary_sprite_base == 0) {
1335 catenary_sprite_base = SPR_TRAMWAY_TUNNEL_WIRES;
1337 catenary_sprite_base += 19;
1341 if (catenary_sprite_base == 0) {
1342 catenary_sprite_base = SPR_TRAMWAY_TUNNEL_WIRES;
1344 catenary_sprite_base += 19;
1348 if (catenary_sprite_base != 0) {
1351 AddSortableSpriteToDraw(catenary_sprite_base + 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);
1355 if (rti->UsesOverlay()) {
1357 if (surface != 0)
DrawGroundSprite(surface + tunnelbridge_direction, PAL_NONE);
1362 if (rti->UsesOverlay()) {
1383 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);
1385 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);
1401 assert(base_offset != 8);
1407 assert( (base_offset & 0x07) == 0x00);
1412 base_offset += (6 - tunnelbridge_direction) % 4;
1417 psid = &GetBridgeSpriteTable(
GetBridgeType(ti->
tile), BRIDGE_PIECE_HEAD)[base_offset];
1419 psid = _aqueduct_sprites + base_offset;
1425 DrawShoreTile(ti->
tileh);
1427 DrawClearLandTile(ti, 3);
1445 uint offset = tunnelbridge_direction;
1448 offset = (offset + 1) & 1;
1460 if (rti->UsesOverlay()) {
1476 if (rti->UsesOverlay()) {
1524 return BRIDGE_PIECE_NORTH;
1525 }
else if (south == 1) {
1526 return BRIDGE_PIECE_SOUTH;
1527 }
else if (north < south) {
1528 return north & 1 ? BRIDGE_PIECE_INNER_SOUTH : BRIDGE_PIECE_INNER_NORTH;
1529 }
else if (north > south) {
1530 return south & 1 ? BRIDGE_PIECE_INNER_NORTH : BRIDGE_PIECE_INNER_SOUTH;
1532 return north & 1 ? BRIDGE_PIECE_MIDDLE_EVEN : BRIDGE_PIECE_MIDDLE_ODD;
1583 psid = base_offset + GetBridgeSpriteTable(type, piece);
1585 drawfarpillar =
true;
1586 psid = _aqueduct_sprites;
1589 if (axis !=
AXIS_X) psid += 4;
1605 AddSortableSpriteToDraw(psid->
sprite, psid->
pal, x, y, 16, 1, 0x28, z,
IsTransparencySet(
TO_BRIDGES), 0, 0,
BRIDGE_Z_START);
1607 AddSortableSpriteToDraw(psid->
sprite, psid->
pal, x, y, 1, 16, 0x28, z,
IsTransparencySet(
TO_BRIDGES), 0, 0,
BRIDGE_Z_START);
1626 if (rti->UsesOverlay()) {
1645 if (psid->
sprite &
SPRITE_MASK)
AddSortableSpriteToDraw(psid->
sprite, psid->
pal, x, y, 16, 4, 0x28, z,
IsTransparencySet(
TO_BRIDGES), 0, 3,
BRIDGE_Z_START);
1648 if (psid->
sprite &
SPRITE_MASK)
AddSortableSpriteToDraw(psid->
sprite, psid->
pal, x, y, 4, 16, 0x28, z,
IsTransparencySet(
TO_BRIDGES), 3, 0,
BRIDGE_Z_START);
1663 static int GetSlopePixelZ_TunnelBridge(
TileIndex tile, uint x, uint y)
1675 if (5 <= pos && pos <= 10)
return z;
1683 if (5 <= pos && pos <= 10) {
1689 default: NOT_REACHED();
1695 return z + 1 + delta;
1712 td->
str = (tt ==
TRANSPORT_RAIL) ? STR_LAI_TUNNEL_DESCRIPTION_RAILROAD : STR_LAI_TUNNEL_DESCRIPTION_ROAD;
1720 RoadType road_rt = GetRoadTypeRoad(tile);
1721 RoadType tram_rt = GetRoadTypeTram(tile);
1740 td->
owner_type[i] = STR_LAND_AREA_INFORMATION_ROAD_OWNER;
1741 td->
owner[i] = road_owner;
1745 td->
owner_type[i] = STR_LAND_AREA_INFORMATION_TRAM_OWNER;
1746 td->
owner[i] = tram_owner;
1757 if (td->
rail_speed == 0 || spd < td->rail_speed) {
1769 static void TileLoop_TunnelBridge(
TileIndex tile)
1807 static void ChangeTileOwner_TunnelBridge(
TileIndex tile,
Owner old_owner,
Owner new_owner)
1814 FOR_ALL_ROADTRAMTYPES(rtt) {
1817 RoadType rt = GetRoadType(tile, rtt);
1821 Company::Get(old_owner)->infrastructure.road[rt] -= num_pieces * 2;
1877 int z = GetSlopePixelZ(x, y) - v->
z_pos;
1923 assert(frame == rv->frame + 1);
1977 default: NOT_REACHED();
2011 default: NOT_REACHED();
2043 extern const TileTypeProcs _tile_type_tunnelbridge_procs = {
2045 GetSlopePixelZ_TunnelBridge,
2048 GetTileDesc_TunnelBridge,
2049 GetTileTrackStatus_TunnelBridge,
2052 TileLoop_TunnelBridge,
2053 ChangeTileOwner_TunnelBridge,
2055 VehicleEnter_TunnelBridge,
2056 GetFoundation_TunnelBridge,
2057 TerraformTile_TunnelBridge,
static const int BRIDGE_Z_START
Z position of the bridge sprites relative to bridge height (downwards)
Buses, trucks and trams belong to this class.
static CommandCost DoClearTunnel(TileIndex tile, DoCommandFlag flags)
Remove a tunnel from the game, update town rating, etc.
@ MP_CLEAR
A tile without any structures, i.e. grass, rocks, farm fields etc.
@ SPRITE_MASK
The mask to for the main sprite.
@ TRACK_BIT_WORMHOLE
Bitflag for a wormhole (used for tunnels)
bool PlayVehicleSound(const Vehicle *v, VehicleSoundEvent event)
Checks whether a NewGRF wants to play a different vehicle sound effect.
bool is_ai
If true, the company is (also) controlled by the computer (a NoAI program).
@ VETSB_CANNOT_ENTER
The vehicle cannot enter the tile.
uint32 TileIndex
The index/ID of a Tile.
@ TROPICZONE_DESERT
Tile is desert.
SpriteID single_x
single piece of rail in X direction, without ground
Cheat crossing_tunnels
allow tunnels that cross each other
Cheat magic_bulldozer
dynamite industries, objects
uint16 max_speed
Maximum speed for vehicles travelling on this rail type.
CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags)
Shorthand for calling the long DoCommand with a container.
static Titem * Get(size_t index)
Returns Titem with given index.
TileIndex GetOtherBridgeEnd(TileIndex tile)
Starting at one bridge end finds the other bridge end.
static TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
int GetTileMaxZ(TileIndex t)
Get top height of the tile inside the map.
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
void ResetBridges()
Reset the data been eventually changed by the grf loaded.
void DrawRoadOverlays(const TileInfo *ti, PaletteID pal, const RoadTypeInfo *road_rti, const RoadTypeInfo *tram_rti, uint road_offset, uint tram_offset)
Draw road underlay and overlay sprites.
static BridgeType GetBridgeType(TileIndex t)
Determines the type of bridge on a tile.
static const uint BB_Z_SEPARATOR
Separates the bridge/tunnel from the things under/above it.
static bool HasTileWaterClass(TileIndex t)
Checks whether the tile has an waterclass associated.
static CommandCost CheckBridgeSlope(BridgePieces bridge_piece, Axis axis, Slope *tileh, int *z)
Determines the foundation for the bridge head, and tests if the resulting slope is valid.
@ VSE_TUNNEL
Train entering a tunnel.
Allow incrementing of ObjectClassID variables.
void YapfNotifyTrackLayoutChange(TileIndex tile, Track track)
Use this function to notify YAPF that track layout (or signal configuration) has change.
uint x
X position of the tile in unit coordinates.
struct RoadTypeInfo::@44 strings
Strings associated with the rail type.
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
static const CommandCost CMD_ERROR
Define a default return value for a failed command.
Year avail_year
the year where it becomes available
Town * ClosestTownFromTile(TileIndex tile, uint threshold)
Return the town closest (in distance or ownership) to a given tile, within a given threshold.
Tile information, used while rendering the tile.
@ RATING_TUNNEL_BRIDGE_MINIMUM
minimum rating after removing tunnel or bridge
byte landscape
the landscape we're currently in
StringID railtype
Type of rail on the tile.
bool HasBridgeFlatRamp(Slope tileh, Axis axis)
Determines if the track on a bridge ramp is flat or goes up/down.
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...
Year _cur_year
Current year, starting at 0.
@ TRANSPORT_RAIL
Transport by train.
Owner owner[4]
Name of the owner(s)
static Axis OtherAxis(Axis a)
Select the other axis as provided.
@ SND_05_TRAIN_THROUGH_TUNNEL
3 == 0x03 Train enters tunnel
Price
Enumeration of all base prices for use with Prices.
@ INVALID_ROADTYPE
flag for invalid roadtype
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 Axis DiagDirToAxis(DiagDirection d)
Convert a DiagDirection to the axis.
static void MakeRailTunnel(TileIndex t, Owner o, DiagDirection d, RailType r)
Makes a rail tunnel entrance.
@ DIAGDIR_END
Used for iterations.
uint32 squared_town_zone_radius[HZB_END]
UpdateTownRadius updates this given the house count.
CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Build a Bridge.
uint32 water
Count of company owned track bits for canals.
Tindex index
Index of this pool item.
PalSpriteID ** sprite_table
table of sprites for drawing the bridge
SpriteID sprite
The 'real' sprite.
int GetBridgeHeight(TileIndex t)
Get the height ('z') of a bridge.
static void MakeAqueductBridgeRamp(TileIndex t, Owner o, DiagDirection d)
Make a bridge ramp for aqueducts.
SpriteID single_y
single piece of rail in Y direction, without ground
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
uint16 tram_speed
Speed limit of tram (bridges and track)
int GetTileZ(TileIndex tile)
Get bottom height of the tile.
This struct contains all the info that is needed to draw and construct tracks.
static Trackdir DiagDirToDiagTrackdir(DiagDirection diagdir)
Maps a (4-way) direction to the diagonal trackdir that runs in that direction.
static T ClrBit(T &x, const uint8 y)
Clears a bit in a variable.
@ VETSB_CONTINUE
Bit sets of the above specified bits.
bool IsTunnelInWayDir(TileIndex tile, int z, DiagDirection dir)
Is there a tunnel in the way in the given direction?
static const uint BB_HEIGHT_UNDER_BRIDGE
Some values for constructing bounding boxes (BB).
static void SetRoadOwner(TileIndex t, RoadTramType rtt, Owner o)
Set the owner of a specific road type.
uint GetPartialPixelZ(int x, int y, Slope corners)
Determines height at given coordinate of a slope.
static const uint TILE_SIZE
Tile size in world coordinates.
SpriteID single_sloped
single piece of rail for slopes
static void MakeRoadTunnel(TileIndex t, Owner o, DiagDirection d, RoadType road_rt, RoadType tram_rt)
Makes a road tunnel entrance.
uint y
Y position of the tile in unit coordinates.
ClientSettings _settings_client
The current settings for this game.
TileIndex xy
town center tile
static bool IsCoast(TileIndex t)
Is it a coast tile?
void DrawRailCatenaryOnBridge(const TileInfo *ti)
Draws wires on a tunnel tile.
static uint TileY(TileIndex tile)
Get the Y component of a tile.
CompanyInfrastructure infrastructure
NOSAVE: Counts of company owned infrastructure.
void DrawBridgeMiddle(const TileInfo *ti)
Draw the middle bits of a bridge.
static CommandCost CheckAllowRemoveTunnelBridge(TileIndex tile)
Are we allowed to remove the tunnel or bridge at tile?
TransportType
Available types of transport.
@ VEH_ROAD
Road vehicle type.
uint16 cur_speed
current speed
Owner
Enum for all companies/owners.
uint16 speed
maximum travel speed (1 unit = 1/1.6 mph = 1 km-ish/h)
@ DC_EXEC
execute the given command
static Money RailClearCost(RailType railtype)
Returns the 'cost' of clearing the specified railtype.
Used to only draw a part of the sprite.
CommandCost CheckforTownRating(DoCommandFlag flags, Town *t, TownRatingCheckType type)
Does the town authority allow the (destructive) action of the current company?
@ MP_ROAD
A tile with road (or tram tracks)
Tile description for the 'land area information' tool.
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
DoCommandFlag
List of flags for a command.
Foundation
Enumeration for Foundations.
static Foundation FlatteningFoundation(Slope s)
Returns the foundation needed to flatten a slope.
bool Succeeded() const
Did this command succeed?
static uint SlopeToSpriteOffset(Slope s)
Returns the Sprite offset for a given Slope.
static const byte TUNNEL_SOUND_FRAME
Frame when the 'enter tunnel' sound should be played.
static uint TileX(TileIndex tile)
Get the X component of a tile.
GameCreationSettings game_creation
settings used during the creation of a game (map)
@ SLOPE_NW
north and west corner are raised
Slope tileh
Slope of the tile.
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
@ GVF_GOINGDOWN_BIT
Vehicle is currently going downhill. (Cached track information for acceleration)
@ RTO_SLOPE_NE
Piece of rail on slope with north-east raised.
Struct containing information about a single bridge type.
StringID name
Name of this rail type.
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).
@ TRANSPORT_ROAD
Transport by road vehicle.
static const RailtypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
bool ValParamRailtype(const RailType rail)
Validate functions for rail building.
SpriteID GetCustomRoadSprite(const RoadTypeInfo *rti, TileIndex tile, RoadTypeSpriteGroup rtsg, TileContext context, uint *num_results)
Get the sprite to draw for the given tile.
static const BridgeSpec * GetBridgeSpec(BridgeType i)
Get the specification of a bridge type.
@ RTBO_Y
Piece of rail in Y direction.
void CheckForDockingTile(TileIndex t)
Mark the supplied tile as a docking tile if it is suitable for docking.
@ VS_HIDDEN
Vehicle is not visible.
static const uint TILE_UNIT_MASK
For masking in/out the inner-tile world coordinate units.
CommandCost CheckOwnership(Owner owner, TileIndex tile)
Check whether the current owner owns something.
static DiagDirection DirToDiagDir(Direction dir)
Convert a Direction to a DiagDirection.
#define return_cmd_error(errcode)
Returns from a function with a specific StringID as error.
const byte _tunnel_visibility_frame[DIAGDIR_END]
Frame when a vehicle should be hidden in a tunnel with a certain direction.
@ EXPENSES_CONSTRUCTION
Construction costs.
RailType
Enumeration for all possible railtypes.
static bool IsBridgeTile(TileIndex t)
checks if there is a bridge on this tile
SpriteID tunnel
tunnel sprites base
Common return value for all commands.
byte GetSnowLine()
Get the current snow line, either variable or static.
static bool HasTileWaterGround(TileIndex t)
Checks whether the tile has water at the ground.
static uint TileHeight(TileIndex tile)
Returns the height of a tile.
@ CMD_TERRAFORM_LAND
terraform a tile
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...
static const uint MAX_BRIDGES
Maximal number of available bridge specs.
@ RTSG_BRIDGE
Bridge surface images.
void DirtyCompanyInfrastructureWindows(CompanyID company)
Redraw all windows with company infrastructure counts.
BridgeSpec _bridge[MAX_BRIDGES]
The specification of all bridges.
Town * CalcClosestTownFromTile(TileIndex tile, uint threshold=UINT_MAX)
Return the town closest to the given tile within threshold.
static TrackdirBits TrackBitsToTrackdirBits(TrackBits bits)
Converts TrackBits to TrackdirBits while allowing both directions.
@ GVF_GOINGUP_BIT
Vehicle is currently going uphill. (Cached track information for acceleration)
int32 TileIndexDiff
An offset value between to tiles.
TileIndex tile
Current tile index.
static void SetBridgeMiddle(TileIndex t, Axis a)
Set that there is a bridge over the given axis.
EngineID engine_type
The type of engine used for this vehicle.
StringID roadtype
Type of road on the tile.
@ MP_OBJECT
Contains objects such as transmitters and owned land.
static bool HasSlopeHighestCorner(Slope s)
Tests if a slope has a highest corner (i.e.
Cheats _cheats
All the cheats.
TileIndex first_tile
The first tile being cleared, which then causes the whole object to be cleared.
@ INVALID_OWNER
An invalid owner.
bool Failed() const
Did this command fail?
static Roadside GetRoadside(TileIndex tile)
Get the decorations of a road.
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...
@ ROADSIDE_PAVED
Road with paved sidewalks.
byte max_bridge_height
maximum height of bridges
static bool HasRoadCatenaryDrawn(RoadType roadtype)
Test if we should draw road catenary.
TileIndex GetNorthernBridgeEnd(TileIndex t)
Finds the northern end of a bridge starting at a middle tile.
void EndSpriteCombine()
Terminates a block of sprites started by StartSpriteCombine.
static const uint TUNNELBRIDGE_TRACKBIT_FACTOR
Multiplier for how many regular track bits a tunnel/bridge counts.
bool IsFrontEngine() const
Check if the vehicle is a front engine.
static bool HasTileRoadType(TileIndex t, RoadTramType rtt)
Check if a tile has a road or a tram road type.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
static Track DiagDirToDiagTrack(DiagDirection diagdir)
Maps a (4-way) direction to the diagonal track incidating with that diagdir.
static TropicZone GetTropicZone(TileIndex tile)
Get the tropic zone.
static Money RailBuildCost(RailType railtype)
Returns the cost of building the specified railtype.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
static TrackStatus CombineTrackStatus(TrackdirBits trackdirbits, TrackdirBits red_signals)
Builds a TrackStatus.
'Train' is either a loco or a wagon.
static bool IsValidTile(TileIndex tile)
Checks if a tile is valid.
void FreeTrainTrackReservation(const Train *v)
Free the reserved path in front of a vehicle.
Money GetCost() const
The costs as made up to this moment.
static DiagDirection ReverseDiagDir(DiagDirection d)
Returns the reverse direction of the given DiagDirection.
Slope GetTileSlope(TileIndex tile, int *h)
Return the slope of a given tile inside the map.
static bool IsBridge(TileIndex t)
Checks if this is a bridge, instead of a tunnel.
static bool IsTileOwner(TileIndex tile, Owner owner)
Checks if a tile belongs to the given owner.
uint8 height
The height of this structure, in heightlevels; max MAX_TILE_HEIGHT.
@ TCX_NORMAL
Nothing special.
@ ROTSG_BRIDGE
Required: Bridge surface images.
void StartSpriteCombine()
Starts a block of sprites, which are "combined" into a single bounding box.
@ INVALID_DIAGDIR
Flag for an invalid DiagDirection.
@ MP_TUNNELBRIDGE
Tunnel entry/exit and bridge heads.
static bool AutoslopeEnabled()
Tests if autoslope is enabled for _current_company.
uint32 road[ROADTYPE_END]
Count of company owned track bits for each road type.
@ FOUNDATION_NONE
The tile has no foundation, the slope remains unchanged.
static bool IsRoadDepot(TileIndex t)
Return whether a tile is a road depot.
StringID name
Name of this rail type.
@ SLOPE_SW
south and west corner are raised
bool ValParamRoadType(RoadType roadtype)
Validate functions for rail building.
TileIndex GetSouthernBridgeEnd(TileIndex t)
Finds the southern end of a bridge starting at a middle tile.
Slope
Enumeration for the slope-type.
DiagDirection
Enumeration for diagonal directions.
@ RTBO_SLOPE
Sloped rail pieces, in order NE, SE, SW, NW.
struct RailtypeInfo::@38 base_sprites
Struct containing the main sprites.
void GetSlopePixelZOnEdge(Slope tileh, DiagDirection edge, int *z1, int *z2)
Determine the Z height of the corners of a specific tile edge.
@ ROADSIDE_TREES
Road with trees on paved sidewalks.
void AddCost(const Money &cost)
Adds the given cost to the cost of the command.
bool show_track_reservation
highlight reserved tracks.
uint BridgeType
Bridge spec number.
RoadType
The different roadtypes we support.
Set of callback functions for performing tile operations of a given tile type.
bool extra_dynamite
extra dynamite
Foundation GetBridgeFoundation(Slope tileh, Axis axis)
Get the foundation for a bridge.
int CalcBridgeLenCostFactor(int length)
Calculate the price factor for building a long bridge.
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...
static void GetBridgeRoadCatenary(const RoadTypeInfo *rti, TileIndex head_tile, int offset, bool head, SpriteID &spr_back, SpriteID &spr_front)
Retrieve the sprites required for catenary on a road/tram bridge.
static const SpriteID SPR_RAILTYPE_TUNNEL_BASE
Tunnel sprites with grass only for custom railtype tunnel.
bool value
tells if the bool cheat is active or not
@ DC_BANKRUPT
company bankrupts, skip money check, skip vehicle on tile check in some cases
@ RTSG_OVERLAY
Images for overlaying track.
static CommandCost DoClearBridge(TileIndex tile, DoCommandFlag flags)
Remove a bridge from the game, update town rating, etc.
static DiagDirection AxisToDiagDir(Axis a)
Converts an Axis to a DiagDirection.
static DiagDirection GetTunnelBridgeDirection(TileIndex t)
Get the direction pointing to the other end.
void ChangeTownRating(Town *t, int add, int max, DoCommandFlag flags)
Changes town rating of the current company.
static Owner GetTileOwner(TileIndex tile)
Returns the owner of a 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.
static Axis GetBridgeAxis(TileIndex t)
Get the axis of the bridge that goes over the tile.
Direction direction
facing
byte min_length
the minimum length (not counting start and end tile)
static uint ApplyPixelFoundationToSlope(Foundation f, Slope *s)
Applies a foundation to a slope.
void DrawFoundation(TileInfo *ti, Foundation f)
Draw foundation f at tile ti.
uint16 max_bridge_length
maximum length of bridges
uint DistanceSquare(TileIndex t0, TileIndex t1)
Gets the 'Square' distance between the two given tiles.
@ RTSG_TUNNEL
Main group of ground images for snow or desert.
@ TRACKDIR_BIT_NONE
No track build.
All ships have this type.
SpriteID GetCustomRailSprite(const RailtypeInfo *rti, TileIndex tile, RailTypeSpriteGroup rtsg, TileContext context, uint *num_results)
Get the sprite to draw for the given tile.
CommandCost CmdBuildTunnel(TileIndex start_tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Build Tunnel.
CompanyID _current_company
Company currently doing an action.
static const PaletteID PALETTE_CRASH
Recolour sprite greying of crashed vehicles.
@ RTBO_X
Piece of rail in X direction.
Vehicle * First() const
Get the first vehicle of this vehicle chain.
static WaterClass GetWaterClass(TileIndex t)
Get the water class at a tile.
ClearedObjectArea * FindClearedObject(TileIndex tile)
Find the entry in _cleared_object_areas which occupies a certain tile.
uint16 max_length
the maximum length (not counting start and end tile)
static CommandCost ClearTile_TunnelBridge(TileIndex tile, DoCommandFlag flags)
Remove a tunnel or a bridge from the game.
static bool IsPlainRail(TileIndex t)
Returns whether this is plain rails, with or without signals.
static void ClearBridgeMiddle(TileIndex t)
Removes bridges from the given, that is bridges along the X and Y axis.
bool TryPathReserve(Train *v, bool mark_as_stuck=false, bool first_tile_okay=false)
Try to reserve a path to a safe position.
static Train * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
static bool IsTunnel(TileIndex t)
Is this a tunnel (entrance)?
static bool HasTunnelBridgeReservation(TileIndex t)
Get the reservation state of the rail tunnel/bridge.
@ TCX_ON_BRIDGE
Querying information about stuff on the bridge (via some bridgehead).
static bool HasRailCatenaryDrawn(RailType rt)
Test if we should draw rail catenary.
bool build_on_slopes
allow building on slopes
@ ROTSG_OVERLAY
Optional: Images for overlaying track.
@ RTO_X
Piece of rail in X direction.
static Money RoadClearCost(RoadType roadtype)
Returns the cost of clearing the specified roadtype.
static void SetTunnelBridgeReservation(TileIndex t, bool b)
Set the reservation state of the rail tunnel/bridge.
@ OBJECT_FLAG_ALLOW_UNDER_BRIDGE
Object can built under a bridge.
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_height_override)
Mark a tile given by its index dirty for repaint.
@ TRANSPORT_WATER
Transport over water.
static const ObjectSpec * GetByTile(TileIndex tile)
Get the specification associated with a tile.
void AddSideToSignalBuffer(TileIndex tile, DiagDirection side, Owner owner)
Add side of tile to signal update buffer.
@ OWNER_NONE
The tile has no ownership.
uint32 rail[RAILTYPE_END]
Count of company owned track bits for each rail type.
static TileIndexDiff TileDiffXY(int x, int y)
Calculates an offset for the given coordinate(-offset).
TrackBits state
The "track" the ship is following.
static RailType GetRailType(TileIndex t)
Gets the rail type of the given tile.
@ ROTSG_CATENARY_FRONT
Optional: Catenary front.
TownCache cache
Container for all cacheable data.
void UpdateCompanyRoadInfrastructure(RoadType rt, Owner o, int count)
Update road infrastructure counts for a company.
static const RoadTypeInfo * GetRoadTypeInfo(RoadType roadtype)
Returns a pointer to the Roadtype information for a given roadtype.
@ OWNER_DEITY
The object is owned by a superuser / goal script.
StringID str
Description of the tile.
@ DC_AUTO
don't allow building on structures
Combination of a palette sprite and a 'real' sprite.
struct RailtypeInfo::@41 strings
Strings associated with the rail type.
static uint MapMaxX()
Gets the maximum X coordinate within the map, including MP_VOID.
TileIndex GetOtherTunnelEnd(TileIndex tile)
Gets the other end of the tunnel.
static T abs(const T a)
Returns the absolute value of (scalar) variable.
OrthogonalTileArea TileArea
Shorthand for the much more common orthogonal tile area.
void DrawRailCatenaryOnTunnel(const TileInfo *ti)
Draws wires on a tunnel tile.
void MarkBridgeDirty(TileIndex begin, TileIndex end, DiagDirection direction, uint bridge_height)
Mark bridge tiles dirty.
static bool IsDockingTile(TileIndex t)
Checks whether the tile is marked as a dockling tile.
static BridgePieces CalcBridgePiece(uint north, uint south)
Compute bridge piece.
CommandCost CheckTileOwnership(TileIndex tile)
Check whether the current owner owns the stuff on the given tile.
static uint GetTunnelBridgeLength(TileIndex begin, TileIndex end)
Calculates the length of a tunnel or a bridge (without end tiles)
#define lengthof(x)
Return the length of an fixed size array.
@ RVSB_WORMHOLE
The vehicle is in a tunnel and/or bridge.
uint16 rail_speed
Speed limit of rail (bridges and track)
static TrackBits DiagDirToDiagTrackBits(DiagDirection diagdir)
Maps a (4-way) direction to the diagonal track bits incidating with that diagdir.
uint16 max_speed
Maximum speed for vehicles travelling on this road type.
static int GetBridgePixelHeight(TileIndex tile)
Get the height ('z') of a bridge in pixels.
static const uint TILE_HEIGHT
Height of a height level in world coordinate AND in pixels in #ZOOM_LVL_BASE.
static void DrawTile_TunnelBridge(TileInfo *ti)
Draws a tunnel of bridge tile.
void DrawRailCatenary(const TileInfo *ti)
Draws overhead wires and pylons for electric railways.
static Money RoadBuildCost(RoadType roadtype)
Returns the cost of building the specified roadtype.
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
static bool IsNormalRoadTile(TileIndex t)
Return whether a tile is a normal road tile.
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 void SetRoadside(TileIndex tile, Roadside s)
Set the decorations of a road.
static Owner GetRoadOwner(TileIndex t, RoadTramType rtt)
Get the owner of a specific road type.
StringID owner_type[4]
Type of each owner.
static TileIndex GetOtherTunnelBridgeEnd(TileIndex t)
Determines type of the wormhole and returns its other end.
static void SetTileOwner(TileIndex tile, Owner owner)
Sets the owner of a tile.
PaletteID pal
The palette (use PAL_NONE) if not needed)
TileIndex tile
Tile index.
ConstructionSettings construction
construction of things in-game
static TileType GetTileType(TileIndex tile)
Get the tiletype of a given tile.
@ VEH_TRAIN
Train vehicle type.
static void MakeRoadBridgeRamp(TileIndex t, Owner o, Owner owner_road, Owner owner_tram, BridgeType bridgetype, DiagDirection d, RoadType road_rt, RoadType tram_rt)
Make a bridge ramp for roads.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
VehicleType type
Type of vehicle.
StringID tramtype
Type of tram on the tile.
static bool IsWater(TileIndex t)
Is it a plain water tile?
@ DC_QUERY_COST
query cost only, don't build.
static void Swap(T &a, T &b)
Type safe swap operation.
@ TUNNELBRIDGE_REMOVE
Removal of a tunnel or bridge owned by the towb.
static Slope GetTilePixelSlope(TileIndex tile, int *h)
Return the slope of a given tile.
static Foundation InclinedFoundation(Axis axis)
Returns the along a specific axis inclined foundation.
Track
These are used to specify a single track.
uint ApplyFoundationToSlope(Foundation f, Slope *s)
Applies a foundation to a slope.
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
static TransportType GetTunnelBridgeTransportType(TileIndex t)
Tunnel: Get the transport type of the tunnel (road or rail) Bridge: Get the transport type of the bri...
@ DIAGDIR_NE
Northeast, upper right on your monitor.
Keeps track of removed objects during execution/testruns of commands.
@ VEH_SHIP
Ship vehicle type.
static Money TunnelBridgeClearCost(TileIndex tile, Price base_price)
Calculate the base cost of clearing a tunnel/bridge per tile.
uint16 max_tunnel_length
maximum length of tunnels
BridgePieces
This enum is related to the definition of bridge pieces, which is used to determine the proper sprite...
@ SLOPE_SE
south and east corner are raised
static void MakeRailBridgeRamp(TileIndex t, Owner o, BridgeType bridgetype, DiagDirection d, RailType rt)
Make a bridge ramp for rails.
@ OWNER_WATER
The tile/execution is done by "water".
@ ROTSG_CATENARY_BACK
Optional: Catenary back.
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.
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.
@ SLOPE_NE
north and east corner are raised
static Slope ComplementSlope(Slope s)
Return the complement of a slope.
@ RATING_TUNNEL_BRIDGE_DOWN_STEP
penalty for removing town owned tunnel or bridge
VehicleEnterTileStatus
The returned bits of VehicleEnterTile.
@ CMD_LANDSCAPE_CLEAR
demolish a tile
@ OWNER_TOWN
A town owns the tile, or a town is expanding.
CommandCost TunnelBridgeIsFree(TileIndex tile, TileIndex endtile, const Vehicle *ignore)
Finds vehicle in tunnel / bridge.
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.
TileIndex _build_tunnel_endtile
The end of a tunnel; as hidden return from the tunnel build command for GUI purposes.
GUISettings gui
settings related to the GUI
Train * GetTrainForReservation(TileIndex tile, Track track)
Find the train which has reserved a specific path.
static DiagDirection GetInclinedSlopeDirection(Slope s)
Returns the direction of an inclined slope.
SpriteID bridge_offset
Bridge offset.
static const SpriteID SPR_TRAMWAY_BASE
Tramway sprites.
static void DrawBridgeRoadBits(TileIndex head_tile, int x, int y, int z, int offset, bool head)
Draws the road and trambits over an already drawn (lower end) of a bridge.
@ VETSB_ENTERED_WORMHOLE
The vehicle either entered a bridge, tunnel or depot tile (this includes the last tile of the bridge/...
static bool IsBridgeAbove(TileIndex t)
checks if a bridge is set above the ground of this tile
@ INVALID_RAILTYPE
Flag for invalid railtype.
ObjectFlags flags
Flags/settings related to the object.
uint16 road_speed
Speed limit of road (bridges and track)
@ RTSG_TUNNEL_PORTAL
Tunnel portal overlay.