41 #include "table/strings.h" 50 std::vector<RoadType> _sorted_roadtypes;
72 { 0, 0, 0, 0, 0, 0, 0, 0, 0, {}, {}, 0, {}, {} },
76 for (; i <
lengthof(_roadtypes); i++) _roadtypes[i] = empty_roadtype;
85 if (cursors_base != 0) {
109 if (RoadTypeIsRoad(first) == RoadTypeIsRoad(second)) {
112 return RoadTypeIsTram(first) < RoadTypeIsTram(second);
122 ResolveRoadTypeGUISprites(rti);
126 _sorted_roadtypes.clear();
128 if (_roadtypes[rt].label != 0 && !
HasBit(_roadtypes_hidden_mask, rt)) {
129 _sorted_roadtypes.push_back(rt);
132 std::sort(_sorted_roadtypes.begin(), _sorted_roadtypes.end(),
CompareRoadTypes);
143 if (rti->
label == 0) {
166 if (rtt == RTT_TRAM) {
199 if (c ==
nullptr)
return;
294 if (ret.
Failed())
return ret;
341 if (ret.
Failed())
return ret;
349 if (ret.
Failed())
return ret;
356 if (ret.
Failed())
return ret;
365 if (ret.
Failed())
return ret;
441 if (pieces ==
ROAD_NONE)
return_cmd_error((rtt == RTT_TRAM) ? STR_ERROR_THERE_IS_NO_TRAMWAY : STR_ERROR_THERE_IS_NO_ROAD);
564 RoadBits type_bits = existing | *pieces;
577 type_bits = existing | *pieces;
626 p2 = (town !=
nullptr) ? town->
index : INVALID_TOWN;
638 RoadBits pieces = Extract<RoadBits, 0, 4>(p1);
643 RoadType rt = Extract<RoadType, 4, 6>(p1);
649 RoadTramType rtt = GetRoadTramType(rt);
651 bool need_to_clear =
false;
658 other_bits =
GetRoadBits(tile, OtherRoadTramType(rtt));
667 if ((existing & pieces) == pieces) {
669 if (toggle_drd !=
DRD_NONE && rtt == RTT_ROAD) {
675 if (ret.
Failed())
return ret;
687 if (ret.
Failed())
return ret;
705 if (ret.
Failed())
return ret;
727 default: NOT_REACHED();
754 if (pieces &
ROAD_X)
goto do_clear;
759 if (pieces &
ROAD_Y)
goto do_clear;
763 default:
goto do_clear;
767 if (ret.
Failed())
return ret;
798 if (pieces & ~curbits)
goto do_clear;
812 if (ret.
Failed())
return ret;
818 need_to_clear =
true;
825 if (ret.
Failed())
return ret;
829 if (other_bits != pieces) {
840 if (!need_to_clear) {
859 if (ret.
Failed())
return ret;
865 RoadType existing_rt = GetRoadType(tile, rtt);
871 if (ret.
Failed())
return ret;
958 RoadTramType rtt = GetRoadTramType(rt);
959 RoadType existing = GetRoadType(tile, rtt);
991 RoadType rt = Extract<RoadType, 3, 6>(p2);
994 Axis axis = Extract<Axis, 2, 1>(p2);
1002 if (start_tile > end_tile || (start_tile == end_tile &&
HasBit(p2, 0))) {
1018 bool had_bridge =
false;
1019 bool had_tunnel =
false;
1020 bool had_success =
false;
1021 bool is_ai =
HasBit(p2, 11);
1028 if (!is_ai && start_tile != end_tile) {
1045 if (is_ai)
return last_error;
1068 if (tile == end_tile)
break;
1073 return had_success ? cost : last_error;
1096 RoadType rt = Extract<RoadType, 3, 6>(p2);
1099 Axis axis = Extract<Axis, 2, 1>(p2);
1105 if (start_tile > end_tile || (start_tile == end_tile &&
HasBit(p2, 0))) {
1107 start_tile = end_tile;
1115 bool had_success =
false;
1125 RoadTramType rtt = GetRoadTramType(rt);
1134 RemoveRoad(tile, flags, bits, rtt,
true,
false);
1140 if (last_error.
GetErrorMessage() != STR_ERROR_OWNED_BY) last_error = ret;
1144 if (tile == end_tile)
break;
1149 return had_success ? cost : last_error;
1169 RoadType rt = Extract<RoadType, 2, 6>(p1);
1179 cost.
AddCost(_price[PR_BUILD_FOUNDATION]);
1183 if (cost.
Failed())
return cost;
1200 cost.
AddCost(_price[PR_BUILD_DEPOT_ROAD]);
1208 if (ret.
Failed())
return ret;
1212 if (ret.
Failed())
return ret;
1218 RoadType rt = GetRoadTypeRoad(tile);
1224 delete Depot::GetByTile(tile);
1225 DoClearSquare(tile);
1240 FOR_ALL_ROADTRAMTYPES(rtt) {
1244 if (tmp_ret.
Failed())
return tmp_ret;
1259 for (RoadTramType rtt : { RTT_TRAM, RTT_ROAD }) {
1263 if (tmp_ret.
Failed())
return tmp_ret;
1278 return RemoveRoadDepot(tile, flags);
1320 const byte _road_sloped_sprites[14] = {
1341 default: NOT_REACHED();
1344 static const uint offsets[] = {
1350 return offsets[bits];
1393 RoadType rt_road = GetRoadTypeRoad(neighbour);
1394 RoadType rt_tram = GetRoadTypeTram(neighbour);
1403 if (
CountBits(rb_new) >= 2) rb = rb_new;
1410 if (front != 0 || back != 0) {
1414 back = SPR_TRAMWAY_BACK_WIRES_SLOPED + _road_sloped_sprites[ti->
tileh - 1];
1415 front = SPR_TRAMWAY_FRONT_WIRES_SLOPED + _road_sloped_sprites[ti->
tileh - 1];
1464 rt = GetRoadTypeTram(ti->
tile);
1498 if (road_rti !=
nullptr) {
1499 if (road_rti->UsesOverlay()) {
1504 if (tram_rti->UsesOverlay()) {
1513 if (road_rti !=
nullptr) {
1514 if (road_rti->UsesOverlay()) {
1521 if (tram_rti !=
nullptr) {
1522 if (tram_rti->UsesOverlay()) {
1525 }
else if (road_rti !=
nullptr) {
1542 if (rti ==
nullptr || rti->UsesOverlay()) {
1557 SpriteID image = SPR_ROAD_Y + offset;
1565 default: image -= 19;
break;
1605 if (road_rti !=
nullptr) {
1631 if (height < minz)
return;
1638 for (
const DrawRoadTileStruct *drts = _road_display_table[roadside][road | tram]; drts->image != 0; drts++) {
1639 DrawRoadDetail(drts->image, ti, drts->subcoord_x, drts->subcoord_y, 0x10);
1666 if (rti->UsesOverlay()) {
1667 SpriteID image = SPR_ROAD_Y + axis;
1676 default: image -= 19;
break;
1692 default: image += 4;
break;
1703 if (rti->UsesOverlay()) {
1709 }
else if (draw_pbs || tram_rti !=
nullptr || road_rti->UsesOverlay()) {
1736 bool default_gfx = relocation == 0;
1741 relocation = SPR_TRAMWAY_DEPOT_WITH_TRACK - SPR_ROAD_DEPOT;
1742 default_gfx =
false;
1745 relocation = SPR_TRAMWAY_DEPOT_NO_TRACK - SPR_ROAD_DEPOT;
1749 relocation -= SPR_ROAD_DEPOT;
1758 if (rti->UsesOverlay()) {
1786 bool default_gfx = relocation == 0;
1791 relocation = SPR_TRAMWAY_DEPOT_WITH_TRACK - SPR_ROAD_DEPOT;
1792 default_gfx =
false;
1795 relocation = SPR_TRAMWAY_DEPOT_NO_TRACK - SPR_ROAD_DEPOT;
1799 relocation -= SPR_ROAD_DEPOT;
1807 if (rti->UsesOverlay()) {
1809 if (ground != 0)
DrawSprite(ground + offset, PAL_NONE, x, y);
1810 }
else if (RoadTypeIsTram(rt)) {
1811 DrawSprite(SPR_TRAMWAY_OVERLAY + offset, PAL_NONE, x, y);
1829 TownID tid = INVALID_TOWN;
1832 if (town !=
nullptr) tid = town->
index;
1839 static int GetSlopePixelZ_Road(
TileIndex tile, uint x, uint y)
1864 static const Roadside _town_road_types[][2] = {
1872 static const Roadside _town_road_types_2[][2] = {
1881 static void TileLoop_Road(
TileIndex tile)
1903 HouseZonesBits grp = HZB_TOWN_EDGE;
1933 if (cur_rs == new_rs[0])
return;
1936 if (cur_rs == new_rs[1]) {
1956 if (old_rb != new_rb) {
1964 if (rt != GetRoadTypeRoad(tile)) {
1973 static bool ClickTile_Road(
TileIndex tile)
1982 static const TrackBits _road_trackbits[16] = {
2011 RoadTramType rtt = (RoadTramType)sub_mode;
2015 const uint drd_to_multiplier[
DRD_END] = { 0x101, 0x100, 0x1, 0x0 };
2054 static const StringID _road_tile_strings[] = {
2055 STR_LAI_ROAD_DESCRIPTION_ROAD,
2056 STR_LAI_ROAD_DESCRIPTION_ROAD,
2057 STR_LAI_ROAD_DESCRIPTION_ROAD,
2058 STR_LAI_ROAD_DESCRIPTION_ROAD_WITH_STREETLIGHTS,
2059 STR_LAI_ROAD_DESCRIPTION_ROAD,
2060 STR_LAI_ROAD_DESCRIPTION_TREE_LINED_ROAD,
2061 STR_LAI_ROAD_DESCRIPTION_ROAD,
2062 STR_LAI_ROAD_DESCRIPTION_ROAD,
2071 RoadType road_rt = GetRoadTypeRoad(tile);
2072 RoadType tram_rt = GetRoadTypeTram(tile);
2088 td->
str = STR_LAI_ROAD_DESCRIPTION_ROAD_RAIL_LEVEL_CROSSING;
2099 td->
str = STR_LAI_ROAD_DESCRIPTION_ROAD_VEHICLE_DEPOT;
2115 bool mixed_owners = (tram_owner !=
INVALID_OWNER && tram_owner != first_owner) || (rail_owner !=
INVALID_OWNER && rail_owner != first_owner);
2120 td->
owner[0] = rail_owner;
2122 td->
owner[1] = road_owner;
2124 td->
owner[2] = tram_owner;
2127 td->
owner[0] = first_owner;
2146 if (rv->frame == RVC_DEPOT_STOP_FRAME &&
2174 RoadType rt = GetRoadTypeRoad(tile);
2180 FOR_ALL_ROADTRAMTYPES(rtt) {
2190 FOR_ALL_ROADTRAMTYPES(rtt) {
2193 RoadType rt = GetRoadType(tile, rtt);
2197 Company::Get(old_owner)->infrastructure.road[rt] -= num_bits;
2238 if (bits == bits_copy) {
2253 default: NOT_REACHED();
2329 RoadType to_type = Extract<RoadType, 0, 6>(p2);
2338 RoadTramType rtt = GetRoadTramType(to_type);
2342 bool found_convertible_road =
false;
2350 RoadType from_type = GetRoadType(tile, rtt);
2361 error.
MakeError(STR_ERROR_CROSSING_DISALLOWED_ROAD);
2391 if (rtt == RTT_ROAD && owner ==
OWNER_TOWN) {
2392 error.
MakeError(STR_ERROR_INCOMPATIBLE_ROAD);
2398 found_convertible_road =
true;
2425 if (endtile < tile) {
2437 if (rtt == RTT_ROAD && owner ==
OWNER_TOWN) {
2438 error.
MakeError(STR_ERROR_INCOMPATIBLE_ROAD);
2445 found_convertible_road =
true;
2481 return found_convertible_road ? cost :
error;
2488 GetSlopePixelZ_Road,
2492 GetTileTrackStatus_Road,
2496 ChangeTileOwner_Road,
Functions related to OTTD's strings.
static TileType GetTileType(TileIndex tile)
Get the tiletype of a given tile.
Owner
Enum for all companies/owners.
don't allow building on structures
uint ApplyFoundationToSlope(Foundation f, Slope *s)
Applies a foundation to a slope.
Functions/types related to NewGRF debugging.
uint32 PaletteID
The number of the palette.
SpriteID crossing
level crossing, rail in X direction
struct RailtypeInfo::@36 base_sprites
Struct containing the main sprites.
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.
void UpdateNearestTownForRoadTiles(bool invalidate)
Updates cached nearest town for all road tiles.
NewGRF handling of rail types.
static const RailtypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
static TropicZone GetTropicZone(TileIndex tile)
Get the tropic zone.
TrackdirBits
Enumeration of bitmasks for the TrackDirs.
static TransportType GetTunnelBridgeTransportType(TileIndex t)
Tunnel: Get the transport type of the tunnel (road or rail) Bridge: Get the transport type of the bri...
static void MakeRoadCrossing(TileIndex t, Owner road, Owner tram, Owner rail, Axis roaddir, RailType rat, RoadType road_rt, RoadType tram_rt, uint town)
Make a level crossing.
RoadType AllocateRoadType(RoadTypeLabel label, RoadTramType rtt)
Allocate a new road type label.
Direction direction
facing
Tile information, used while rendering the tile.
static void SetTileOwner(TileIndex tile, Owner owner)
Sets the owner of a tile.
south and east corner are raised
byte landscape
the landscape we're currently in
company buildings - depots, stations, HQ, ...
CommandCost CmdConvertRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Convert one road subtype to another.
static const RoadBits _invalid_tileh_slopes_road[2][15]
Invalid RoadBits on slopes.
#define ToggleDesert
Toggle the snow/desert state of a road tile.
static RoadBits ComplementRoadBits(RoadBits r)
Calculate the complement of a RoadBits value.
static const uint LEVELCROSSING_TRACKBIT_FACTOR
Multiplier for how many regular track bits a level crossing counts.
RoadTypes _roadtypes_type
Bitmap of road/tram types.
CursorID autoroad
Cursor for autorail tool.
void MarkBridgeDirty(TileIndex begin, TileIndex end, DiagDirection direction, uint bridge_height)
Mark bridge tiles dirty.
static void StartRoadWorks(TileIndex t)
Start road works on a tile.
Functions related to roads.
RoadBits GetAnyRoadBits(TileIndex tile, RoadTramType rtt, bool straight_tunnel_bridge_entrance)
Returns the RoadBits on an arbitrary tile Special behaviour:
byte _display_opt
What do we want to draw/do?
EconomySettings economy
settings to change the economy
uint32 squared_town_zone_radius[HZB_END]
UpdateTownRadius updates this given the house count.
static RoadBits GetAllRoadBits(TileIndex tile)
Get all set RoadBits on the given tile.
uint GetPartialPixelZ(int x, int y, Slope corners)
Determines height at given coordinate of a slope.
CommandCost EnsureNoVehicleOnGround(TileIndex tile)
Ensure there is no vehicle at the ground at the given position.
CursorID depot
Cursor for building a depot.
static Titem * Get(size_t index)
Returns Titem with given index.
Money GetAvailableMoneyForCommand()
SpriteID build_depot
button for building depots
static const SpriteID SPR_ONEWAY_BASE
One way road sprites.
Functions related to dates.
RoadTypes
The different roadtypes we support, but then a bitmask of them.
TileType
The different types of tiles.
static bool HasCrossingReservation(TileIndex t)
Get the reservation state of the rail crossing.
X-axis and direction to north-east.
remove a complete road (not a "half" one)
static bool HasTileRoadType(TileIndex t, RoadTramType rtt)
Check if a tile has a road or a tram road type.
static T SetBit(T &x, const uint8 y)
Set a bit in a variable.
void DrawRoadCatenary(const TileInfo *ti)
Draws the catenary for the given tile.
RoadTypeFlags flags
Bit mask of road type flags.
static TrackBits GetCrossingRailBits(TileIndex tile)
Get the rail track bits of a level crossing.
static bool HasRoadCatenaryDrawn(RoadType roadtype)
Test if we should draw road catenary.
CommandCost CmdBuildRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Build a piece of road.
A tile with road (or tram tracks)
static const CommandCost CMD_ERROR
Define a default return value for a failed command.
static TrackBits AxisToTrackBits(Axis a)
Maps an Axis to the corresponding TrackBits value.
Depot view; Window numbers:
Slope tileh
Slope of the tile.
Full road along the x-axis (south-west + north-east)
Functions used internally by the roads.
A town owns the tile, or a town is expanding.
bool extra_dynamite
extra dynamite
static bool IsRoadStop(TileIndex t)
Is the station at t a road station?
StringID tramtype
Type of tram on the tile.
Functions related to vehicles.
static TrackBits DiagDirToDiagTrackBits(DiagDirection diagdir)
Maps a (4-way) direction to the diagonal track bits incidating with that diagdir. ...
static void MakeRoadDepot(TileIndex t, Owner owner, DepotID did, DiagDirection dir, RoadType rt)
Make a road depot.
SpriteID build_x_road
button for building single rail in X direction
static uint TileX(TileIndex tile)
Get the X component of a tile.
void VehicleEnterDepot(Vehicle *v)
Vehicle entirely entered the depot, update its status, orders, vehicle windows, service it...
SpriteID build_tunnel
button for building a tunnel
Build vehicle; Window numbers:
static TileIndex TileAddByDiagDir(TileIndex tile, DiagDirection dir)
Adds a DiagDir to a tile.
void DrawRoadDepotSprite(int x, int y, DiagDirection dir, RoadType rt)
Draw the road depot sprite.
static int GetSlopeMaxZ(Slope s)
Returns the height of the highest corner of a slope relative to TileZ (= minimal height) ...
Base for all depots (except hangars)
Tile description for the 'land area information' tool.
CommandCost CheckTileOwnership(TileIndex tile)
Check whether the current owner owns the stuff on the given tile.
bool ambient
Play ambient, industry and town sounds.
Tindex index
Index of this pool item.
flag for invalid roadtype
static Roadside GetRoadside(TileIndex tile)
Get the decorations of a road.
Sprite constructs for road depots.
A special vehicle is one of the following:
void ResetRoadTypes()
Reset all road type information to its default values.
static bool IsSteepSlope(Slope s)
Checks if a slope is steep.
T * First() const
Get the first vehicle in the chain.
Also draw details of track and roads.
Helper functions to extract data from command parameters.
int GetBridgeHeight(TileIndex t)
Get the height ('z') of a bridge.
static bool IsRoadOwner(TileIndex t, RoadTramType rtt, Owner o)
Check if a specific road type is owned by an owner.
Bit number for hidden from construction.
static void TerminateRoadWorks(TileIndex t)
Terminate road works on a tile.
static DiagDirection GetRoadDepotDirection(TileIndex t)
Get the direction of the exit of a road depot.
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...
Functions related to world/map generation.
Money GetCost() const
The costs as made up to this moment.
#define CLRBITS(x, y)
Clears several bits in a variable.
static const byte _roadveh_enter_depot_dir[4]
Given the direction the road depot is pointing, this is the direction the vehicle should be travellin...
Flag for an invalid DiagDirection.
TramReplacement tram
In which way tram depots were replaced.
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.
static Slope SlopeWithOneCornerRaised(Corner corner)
Returns the slope with a specific corner raised.
static bool IsLevelCrossing(TileIndex t)
Return whether a tile is a level crossing.
static void SetDisallowedRoadDirections(TileIndex t, DisallowedRoadDirections drd)
Sets the disallowed directions.
RoadType
The different roadtypes we support.
static bool RailNoLevelCrossings(RailType rt)
Test if a RailType disallows build of level crossings.
static bool IsDriveThroughStopTile(TileIndex t)
Is tile t a drive through road stop station?
EffectVehicle * CreateEffectVehicleAbove(int x, int y, int z, EffectVehicleType type)
Create an effect vehicle above a particular location.
struct RailtypeInfo::@39 strings
Strings associated with the rail type.
static RoadVehicle * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
static bool CanConnectToRoad(TileIndex tile, RoadType rt, DiagDirection dir)
Checks whether a road or tram connection can be found when building a new road or tram...
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)
static Corner GetHighestSlopeCorner(Slope s)
Returns the highest corner of a slope (one corner raised or a steep slope).
Roadside
The possible road side decorations.
void MakeError(StringID message)
Makes this CommandCost behave like an error command.
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.
static bool CompareRoadTypes(const RoadType &first, const RoadType &second)
Compare roadtypes based on their sorting order.
north and east corner are raised
This struct contains all the info that is needed to draw and construct tracks.
static bool HasRoadWorks(TileIndex t)
Check if a tile has road works.
static uint GetRoadSpriteOffset(Slope slope, RoadBits bits)
Get the sprite offset within a spritegroup.
Date build_date
Date of construction.
int GetTileZ(TileIndex tile)
Get bottom height of the tile.
company bankrupts, skip money check, skip vehicle on tile check in some cases
Functions related to (drawing on) viewports.
Pseudo random number generator.
Bit number for adding catenary.
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
static bool IsInsideMM(const T x, const size_t min, const size_t max)
Checks if a value is in an interval.
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.
Y-axis and direction to north-west.
static bool IsTileOwner(TileIndex tile, Owner owner)
Checks if a tile belongs to the given owner.
static bool IsOnSnow(TileIndex t)
Check if a road tile has snow/desert.
Town * ClosestTownFromTile(TileIndex tile, uint threshold)
Return the town closest (in distance or ownership) to a given tile, within a given threshold...
static void SetCrossingReservation(TileIndex t, bool b)
Set the reservation state of the rail crossing.
static void DrawRailTileSeqInGUI(int x, int y, const DrawTileSprites *dts, int32 total_offset, uint32 newgrf_offset, PaletteID default_palette)
Draw tile sprite sequence in GUI with railroad specifics.
StringID name
Name of this rail type.
static const RoadTypeInfo * GetRoadTypeInfo(RoadType roadtype)
Returns a pointer to the Roadtype information for a given roadtype.
SpriteID GetCustomRailSprite(const RailtypeInfo *rti, TileIndex tile, RailTypeSpriteGroup rtsg, TileContext context, uint *num_results)
Get the sprite to draw for the given tile.
static RoadBits DiagDirToRoadBits(DiagDirection d)
Create the road-part which belongs to the given DiagDirection.
uint x
X position of the tile in unit coordinates.
None of the directions are disallowed.
The tile has no ownership.
static SpriteID GetRoadGroundSprite(const TileInfo *ti, Roadside roadside, const RoadTypeInfo *rti, uint offset, PaletteID *pal)
Get ground sprite to draw for a road tile.
static TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
#define IsOnDesert
Check if a road tile has snow/desert.
bool ValParamRoadType(RoadType roadtype)
Validate functions for rail building.
All northbound traffic is disallowed.
Foundation
Enumeration for Foundations.
Types related to cheating.
TileIndex xy
town center tile
static bool IsTileType(TileIndex tile, TileType type)
Checks if a tile is a given tiletype.
void MakeDefaultName(T *obj)
Set the default name for a depot/waypoint.
TileIndex tile
Tile index.
static uint ApplyPixelFoundationToSlope(Foundation f, Slope *s)
Applies a foundation to a slope.
Y-axis and direction to south-east.
RoadTypes powered_roadtypes
bitmask to the OTHER roadtypes on which a vehicle of THIS roadtype generates power ...
CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags)
Shorthand for calling the long DoCommand with a container.
static void DrawRoadDetail(SpriteID img, const TileInfo *ti, int dx, int dy, int h)
Draws details on/around the road.
std::vector< RoadVehicle * > RoadVehicleList
Helper type for lists/vectors of road vehicles.
StringID owner_type[4]
Type of each owner.
static RoadBits GetRoadBits(TileIndex t, RoadTramType rtt)
Get the present road bits for a specific road type.
Road with trees on paved sidewalks.
The tile is leveled up to a flat slope.
RoadTileType
The different types of road tiles.
Level crossing overlay images.
SoundSettings sound
sound effect settings
Header file for things common for tunnels and bridges.
Ground palette sprite of a tile, together with its sprite layout.
static Money RoadClearCost(RoadType roadtype)
Returns the cost of clearing the specified roadtype.
void DirtyCompanyInfrastructureWindows(CompanyID company)
Redraw all windows with company infrastructure counts.
minimum rating after removing town owned road
static bool HasTownOwnedRoad(TileIndex t)
Checks if given tile has town owned road.
static DiagDirection GetRoadStopDir(TileIndex t)
Gets the direction the road stop entrance points towards.
Entry point for OpenTTD to YAPF's cache.
StringID GetErrorMessage() const
Returns the error message of a command.
static void DrawRoadBits(TileInfo *ti)
Draw ground sprite and road pieces.
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.
static uint GetTunnelBridgeLength(TileIndex begin, TileIndex end)
Calculates the length of a tunnel or a bridge (without end tiles)
uint16 tram_speed
Speed limit of tram (bridges and track)
T * Next() const
Get next vehicle in the chain.
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.
static const uint32 VALID_LEVEL_CROSSING_SLOPES
Constant bitset with safe slopes for building a level crossing.
static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits pieces, RoadTramType rtt, bool crossing_check, bool town_check=true)
Delete a piece of road.
bool Succeeded() const
Did this command succeed?
const TileTypeProcs _tile_type_road_procs
Tile callback functions for road tiles.
SpriteID GetCustomRoadSprite(const RoadTypeInfo *rti, TileIndex tile, RoadTypeSpriteGroup rtsg, TileContext context, uint *num_results)
Get the sprite to draw for the given tile.
Definition of base types and functions in a cross-platform compatible way.
static const Date INVALID_DATE
Representation of an invalid date.
static TrackBits GetRailReservationTrackBits(TileIndex t)
Returns the reserved track bits of the tile.
CommandCost CmdBuildRoadDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Build a road depot.
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).
#define TILE_ADDXY(tile, x, y)
Adds a given offset to a tile.
A number of safeguards to prevent using unsafe methods.
bool value
tells if the bool cheat is active or not
Optional: Catenary front.
uint y
Y position of the tile in unit coordinates.
static bool IsRoadDepotTile(TileIndex t)
Return whether a tile is a road depot tile.
RoadBits
Enumeration for the road parts on a tile.
void ShowDepotWindow(TileIndex tile, VehicleType type)
Opens a depot window.
The tile has an along Y-axis inclined foundation.
static Axis GetCrossingRailAxis(TileIndex t)
Get the rail axis of a level crossing.
All zoomlevels below or equal to this, will result in details on the screen, like road-work...
The vehicle is in a depot.
static Slope GetTilePixelSlope(TileIndex tile, int *h)
Return the slope of a given tile.
static Axis GetCrossingRoadAxis(TileIndex t)
Get the road axis of a level crossing.
static const uint TILE_HEIGHT
Height of a height level in world coordinate AND in pixels in #ZOOM_LVL_BASE.
NewGRF handling of road types.
static bool IsSlopeWithOneCornerRaised(Slope s)
Tests if a specific slope has exactly one corner raised.
Road with street lights on paved sidewalks.
Represents the covered area of e.g.
GUI Functions related to companies.
static const uint TUNNELBRIDGE_TRACKBIT_FACTOR
Multiplier for how many regular track bits a tunnel/bridge counts.
TrackBits
Bitfield corresponding to Track.
don't allow building on water
uint16 max_speed
Maximum speed for vehicles travelling on this rail type.
void FindVehicleOnPos(TileIndex tile, void *data, VehicleFromPosProc *proc)
Find a vehicle from a specific location.
TileIndex tile
Current tile index.
uint16 max_speed
Maximum speed for vehicles travelling on this road type.
CommandCost CheckOwnership(Owner owner, TileIndex tile)
Check whether the current owner owns something.
static Money RoadBuildCost(RoadType roadtype)
Returns the cost of building the specified roadtype.
Base class for tile iterators.
void UpdateCompanyRoadInfrastructure(RoadType rt, Owner o, int count)
Update road infrastructure counts for a company.
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_height_override)
Mark a tile given by its index dirty for repaint.
Optional: Cursor and toolbar icon images.
Base class for all effect vehicles.
CommandCost CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, RoadTramType rtt, DoCommandFlag flags, bool town_check)
Is it allowed to remove the given road bits from the given tile?
SpriteID single_x
single piece of rail in X direction, without ground
struct RoadTypeInfo::@42 strings
Strings associated with the rail type.
All the roadtype-specific information is stored here.
#define lengthof(x)
Return the length of an fixed size array.
bit mask containing all 'simple' slopes
bool RoadVehiclesAreBuilt()
Verify whether a road vehicle is available.
static void ToggleSnow(TileIndex t)
Toggle the snow/desert state of a road tile.
static Foundation FlatteningFoundation(Slope s)
Returns the foundation needed to flatten a slope.
HouseZonesBits GetTownRadiusGroup(const Town *t, TileIndex tile)
Returns the bit corresponding to the town zone of the specified tile.
static void DrawRailTileSeq(const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, int32 total_offset, uint32 newgrf_offset, PaletteID default_palette)
Draw tile sprite sequence on tile with railroad specifics.
StringID railtype
Type of rail on the tile.
static bool MayHaveRoad(TileIndex t)
Test whether a tile can have road/tram types.
struct RoadTypeInfo::@40 gui_sprites
struct containing the sprites for the road GUI.
RoadBits CleanUpRoadBits(const TileIndex tile, RoadBits org_rb)
Clean up unnecessary RoadBits of a planned tile.
Functions related to autoslope.
Functions related to sound.
static DiagDirection GetTunnelBridgeDirection(TileIndex t)
Get the direction pointing to the other end.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
static bool AutoslopeEnabled()
Tests if autoslope is enabled for _current_company.
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?
All directions are disallowed.
std::vector< RoadTypeLabel > RoadTypeLabelList
List of road type labels.
void UpdateLevelCrossing(TileIndex tile, bool sound=true)
Sets correct crossing state.
byte sorting_order
The sorting order of this roadtype for the toolbar dropdown.
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.
#define return_cmd_error(errcode)
Returns from a function with a specific StringID as error.
static void SetRoadOwner(TileIndex t, RoadTramType rtt, Owner o)
Set the owner of a specific road type.
static void SetRoadside(TileIndex tile, Roadside s)
Set the decorations of a road.
static void ConvertRoadTypeOwner(TileIndex tile, uint num_pieces, Owner owner, RoadType from_type, RoadType to_type)
Convert the ownership of the RoadType of the tile if applyable.
static bool Chance16(const uint a, const uint b)
Flips a coin with given probability.
static RailTileType GetRailTileType(TileIndex t)
Returns the RailTileType (normal with or without signals, waypoint or depot).
static RoadBits GetCrossingRoadBits(TileIndex tile)
Get the road bits of a level crossing.
bool mod_road_rebuild
roadworks remove unnecessary RoadBits
static TrackBits GetTrackBits(TileIndex tile)
Gets the track bits of the given tile.
CursorID road_nwse
Cursor for building rail in Y direction.
CompanyInfrastructure infrastructure
NOSAVE: Counts of company owned infrastructure.
uint32 rail[RAILTYPE_END]
Count of company owned track bits for each rail type.
static const RoadTypeInfo _original_roadtypes[]
Global Roadtype definition.
static void SetRoadBits(TileIndex t, RoadBits r, RoadTramType rtt)
Set the present road bits for a specific road 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.
static TileIndex GetOtherTunnelBridgeEnd(TileIndex t)
Determines type of the wormhole and returns its other end.
execute the given command
Slope GetFoundationSlope(TileIndex tile, int *z)
Get slope of a tile on top of a (possible) foundation If a tile does not have a foundation, the function returns the same as GetTileSlope.
The tile/execution is done by "water".
removing a roadpiece at the edge
static bool HasPowerOnRoad(RoadType enginetype, RoadType tiletype)
Checks if an engine of the given RoadType got power on a tile with a given RoadType.
static bool CanConvertRoadType(Owner owner, RoadTramType rtt)
Checks the tile and returns whether the current player is allowed to convert the roadtype to another ...
removing a roadpiece in the middle
static TileIndex TileVirtXY(uint x, uint y)
Get a tile from the virtual XY-coordinate.
static CommandCost CheckRoadSlope(Slope tileh, RoadBits *pieces, RoadBits existing, RoadBits other)
Calculate the costs for roads on slopes Aside modify the RoadBits to fit on the slopes.
PalSpriteID ground
Palette and sprite for the ground.
static T KillFirstBit(T value)
Clear the first bit in an integer.
static uint MapSize()
Get the size of the map.
bool _generating_world
Whether we are generating the map or not.
static Owner GetRoadOwner(TileIndex t, RoadTramType rtt)
Get the owner of a specific road type.
static bool DrawRoadAsSnowDesert(TileIndex tile, Roadside roadside)
Should the road be drawn as a unpaved snow/desert road? By default, roads are always drawn as unpaved...
static bool IsNormalRoadTile(TileIndex t)
Return whether a tile is a normal road tile.
static bool CanBuildDepotByTileh(DiagDirection direction, Slope tileh)
Find out if the slope of the tile is suitable to build a depot of given direction.
static T ClrBit(T &x, const uint8 y)
Clears a bit in a variable.
static RoadTileType GetRoadTileType(TileIndex t)
Get the type of the road tile.
GUISettings gui
settings related to the GUI
Tunnel entry/exit and bridge heads.
static RoadBits MirrorRoadBits(RoadBits r)
Calculate the mirrored RoadBits.
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 and track)
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.
uint DistanceManhattan(TileIndex t0, TileIndex t1)
Gets the Manhattan distance between the two given tiles.
static const PaletteID PALETTE_TO_BARE_LAND
sets colour to bare land stuff for rail, road and crossings
bool include(std::vector< T > &vec, const T &item)
Helper function to append an item to a vector if it is not already contained Consider using std::set...
CursorID road_swne
Cursor for building rail in X direction.
static bool RoadNoLevelCrossing(RoadType roadtype)
Test if road disallows level crossings.
north and west corner are raised
static bool HasAtMostOneBit(T value)
Test whether value has at most 1 bit set.
Track
These are used to specify a single track.
static Vehicle * UpdateRoadVehPowerProc(Vehicle *v, void *data)
Update power of road vehicle under which is the roadtype being converted.
static bool IncreaseRoadWorksCounter(TileIndex t)
Increase the progress counter of road works.
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.
static bool IsStraightRoad(RoadBits r)
Check if we've got a straight road.
Date introduction_date
Introduction date.
void CDECL error(const char *s,...)
Error handling for fatal non-user errors.
Removal of a road owned by the town.
The tile has no foundation, the slope remains unchanged.
The tile has an along X-axis inclined foundation.
TransportType
Available types of transport.
CommandCost CmdBuildLongRoad(TileIndex start_tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Build a long piece of road.
static Foundation GetRoadFoundation(Slope tileh, RoadBits bits)
Get the foundationtype of a RoadBits Slope combination.
Slope
Enumeration for the slope-type.
VehicleType type
Type of vehicle.
void DrawRailCatenary(const TileInfo *ti)
Draws overhead wires and pylons for electric railways.
TownCache cache
Container for all cacheable data.
Normal rail tile without signals.
Maximum number of companies.
bool show_track_reservation
highlight reserved tracks.
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function() ...
Transport by road vehicle.
SpriteID build_y_road
button for building single rail in Y direction
static uint CountBits(T value)
Counts the number of set bits in a variable.
Functions related to commands.
Road on grass with road works.
remove a single rail track
Iterator to iterate over a tile area (rectangle) of the map.
CompanyID _current_company
Company currently doing an action.
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.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
static bool HasRailCatenaryDrawn(RailType rt)
Test if we should draw rail catenary.
Date build_date
Date of construction of tile contents.
CursorID tunnel
Cursor for building a tunnel.
static bool IsRoadStopTile(TileIndex t)
Is tile t a road stop station?
header file for electrified rail specific functions
static Axis OtherAxis(Axis a)
Select the other axis as provided.
static const SpriteID SPR_TRAMWAY_BASE
Tramway sprites.
DisallowedRoadDirections
Which directions are disallowed ?
void DrawRoadTypeCatenary(const TileInfo *ti, RoadType rt, RoadBits rb)
Draws the catenary for the RoadType of the given tile.
X-axis and direction to south-west.
static uint SlopeToSpriteOffset(Slope s)
Returns the Sprite offset for a given Slope.
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 void DrawTile_Road(TileInfo *ti)
Tile callback function for rendering a road tile to the screen.
static DisallowedRoadDirections GetDisallowedRoadDirections(TileIndex t)
Gets the disallowed directions.
static bool IsNormalRoad(TileIndex t)
Return whether a tile is a normal road.
static Pool::IterateWrapper< RoadVehicle > Iterate(size_t from=0)
Returns an iterable ensemble of all valid vehicles of type T.
static void SetRoadType(TileIndex t, RoadTramType rtt, RoadType rt)
Set the road type of a tile.
static bool AutoslopeCheckForEntranceEdge(TileIndex tile, int z_new, Slope tileh_new, DiagDirection entrance)
Autoslope check for tiles with an entrance on an edge.
StringID name
Name of this rail type.
All southbound traffic is disallowed.
StringID str
Description of the tile.
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
DiagDirection
Enumeration for diagonal directions.
static TrackdirBits TrackBitsToTrackdirBits(TrackBits bits)
Converts TrackBits to TrackdirBits while allowing both directions.
static Money RoadConvertCost(RoadType from, RoadType to)
Calculates the cost of road conversion.
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
StringID roadtype
Type of road on the tile.
static bool IsCrossingBarred(TileIndex t)
Check if the level crossing is barred.
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.
Northeast, upper right on your monitor.
Required: Main group of ground images.
GameCreationSettings game_creation
settings used during the creation of a game (map)
static void SetTunnelBridgeOwner(TileIndex begin, TileIndex end, Owner owner)
Sets the ownership of the bridge/tunnel ramps.
Full road along the y-axis (north-west + south-east)
static Track GetCrossingRailTrack(TileIndex tile)
Get the rail track of a level crossing.
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.
uint DistanceSquare(TileIndex t0, TileIndex t1)
Gets the 'Square' distance between the two given tiles.
static bool HasRoadCatenary(RoadType roadtype)
Test if a road type has catenary.
CommandCost CmdRemoveLongRoad(TileIndex start_tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Remove a long piece of road.
RoadTypes introduces_roadtypes
Bitmask of which other roadtypes are introduced when this roadtype is introduced. ...
GRFLoadedFeatures _loaded_newgrf_features
Indicates which are the newgrf features currently loaded ingame.
static DiagDirection AxisToDiagDir(Axis a)
Converts an Axis to a DiagDirection.
RoadTypeLabelList alternate_labels
Road type labels this type provides in addition to the main label.
VehicleEnterTileStatus
The returned bits of VehicleEnterTile.
static void SetTrackReservation(TileIndex t, TrackBits b)
Sets the reserved track bits of the tile.
SpriteID sprite
The 'real' sprite.
SpriteID auto_road
button for the autoroad construction
static void MakeRoadNormal(TileIndex t, RoadBits bits, RoadType road_rt, RoadType tram_rt, TownID town, Owner road, Owner tram)
Make a normal road tile.
struct RoadTypeInfo::@41 cursor
Cursors associated with the road type.
byte road_build_months
fund road reconstruction in action?
SpriteID convert_road
button for converting road types
static void SetTownIndex(TileIndex t, TownID index)
Set the town index for a road or house tile.
Date _date
Current date in days (day counter)
static bool HasGrfMiscBit(GrfMiscBit bit)
Check for grf miscellaneous bits.
static Direction ReverseDir(Direction d)
Return the reverse of a direction.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
The object is owned by a superuser / goal script.
void DrawBridgeMiddle(const TileInfo *ti)
Draw the middle bits of a bridge.
Optional: Images for overlaying track.
Functions related to effect vehicles.
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.
static bool IsRoadDepot(TileIndex t)
Return whether a tile is a road depot.
void InitRoadTypes()
Resolve sprites of custom road types.
static RoadBits AxisToRoadBits(Axis a)
Create the road-part which belongs to the given Axis.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
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?
void InvalidateWindowData(WindowClass cls, WindowNumber number, int data, bool gui_scope)
Mark window data of the window of a given class and specific window number as invalid (in need of re-...
RoadTypeLabel label
Unique 32 bit road type identifier.
void ChangeTownRating(Town *t, int add, int max, DoCommandFlag flags)
Changes town rating of the current company.
Cheats _cheats
All the cheats.
static int GetTileMaxPixelZ(TileIndex tile)
Get top height of the tile.
Electrified depot graphics with tram track were loaded.
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
Base for the NewGRF implementation.