39 #include "table/strings.h" 50 FOR_ALL_ROADVEHICLES(rv)
return true;
144 if (ret.
Failed())
return ret;
189 if (ret.
Failed())
return ret;
197 if (ret.
Failed())
return ret;
204 if (ret.
Failed())
return ret;
213 if (ret.
Failed())
return ret;
227 cost.
AddCost(len * 2 * _price[PR_CLEAR_ROAD]);
258 cost.
AddCost(_price[PR_CLEAR_ROAD] * 2);
435 RoadBits type_bits = existing | *pieces;
448 type_bits = existing | *pieces;
497 p2 = (town != NULL) ? town->
index : (TownID)INVALID_TOWN;
509 RoadBits pieces = Extract<RoadBits, 0, 4>(p1);
514 RoadType rt = Extract<RoadType, 4, 2>(p1);
521 bool need_to_clear =
false;
537 if ((existing & pieces) == pieces) {
545 if (ret.
Failed())
return ret;
557 if (ret.
Failed())
return ret;
575 if (ret.
Failed())
return ret;
593 default: NOT_REACHED();
616 if (pieces &
ROAD_X)
goto do_clear;
621 if (pieces &
ROAD_Y)
goto do_clear;
625 default:
goto do_clear;
629 if (ret.
Failed())
return ret;
664 if (pieces & ~curbits)
goto do_clear;
678 if (ret.
Failed())
return ret;
684 need_to_clear =
true;
691 if (ret.
Failed())
return ret;
695 if (other_bits != pieces) {
706 if (!need_to_clear) {
730 if (ret.
Failed())
return ret;
740 cost.
AddCost(num_pieces * _price[PR_BUILD_ROAD]);
840 RoadType rt = Extract<RoadType, 3, 2>(p2);
843 Axis axis = Extract<Axis, 2, 1>(p2);
851 if (start_tile > end_tile || (start_tile == end_tile &&
HasBit(p2, 0))) {
867 bool had_bridge =
false;
868 bool had_tunnel =
false;
869 bool had_success =
false;
870 bool is_ai =
HasBit(p2, 6);
877 if (!is_ai && start_tile != end_tile) {
894 if (is_ai)
return last_error;
917 if (tile == end_tile)
break;
922 return had_success ? cost : last_error;
945 RoadType rt = Extract<RoadType, 3, 2>(p2);
948 Axis axis = Extract<Axis, 2, 1>(p2);
954 if (start_tile > end_tile || (start_tile == end_tile &&
HasBit(p2, 0))) {
956 start_tile = end_tile;
964 bool had_success =
false;
982 RemoveRoad(tile, flags, bits, rt,
true,
false);
988 if (last_error.
GetErrorMessage() != STR_ERROR_OWNED_BY) last_error = ret;
992 if (tile == end_tile)
break;
997 return had_success ? cost : last_error;
1016 RoadType rt = Extract<RoadType, 2, 2>(p1);
1029 if (cost.
Failed())
return cost;
1047 cost.
AddCost(_price[PR_BUILD_DEPOT_ROAD]);
1055 if (ret.
Failed())
return ret;
1059 if (ret.
Failed())
return ret;
1069 delete Depot::GetByTile(tile);
1070 DoClearSquare(tile);
1088 if (tmp_ret.
Failed())
return tmp_ret;
1108 if (tmp_ret.
Failed())
return tmp_ret;
1124 return RemoveRoadDepot(tile, flags);
1166 const byte _road_sloped_sprites[14] = {
1210 back = SPR_TRAMWAY_BACK_WIRES_SLOPED + _road_sloped_sprites[ti->
tileh - 1];
1211 front = SPR_TRAMWAY_FRONT_WIRES_SLOPED + _road_sloped_sprites[ti->
tileh - 1];
1255 if (ti->
tileh !=
SLOPE_FLAT) image = _road_sloped_sprites[ti->
tileh - 1] + SPR_ROAD_SLOPE_START;
1258 if (image == 0) image = _road_tile_sprites_1[road !=
ROAD_NONE ? road : tram];
1269 default: image -= 19;
break;
1280 image = _road_sloped_sprites[ti->
tileh - 1] + SPR_TRAMWAY_SLOPED_OFFSET;
1282 image = _road_tile_sprites_1[tram] - SPR_ROAD_Y;
1284 image += (road ==
ROAD_NONE) ? SPR_TRAMWAY_TRAM : SPR_TRAMWAY_OVERLAY;
1313 if (height < minz)
return;
1320 for (
const DrawRoadTileStruct *drts = _road_display_table[roadside][road | tram]; drts->image != 0; drts++) {
1321 DrawRoadDetail(drts->image, ti, drts->subcoord_x, drts->subcoord_y, 0x10);
1339 if (rti->UsesOverlay()) {
1351 default: road -= 19;
break;
1377 default: image += 4;
break;
1445 TownID tid = (TownID)INVALID_TOWN;
1448 if (town != NULL) tid = town->
index;
1455 static int GetSlopePixelZ_Road(
TileIndex tile, uint x, uint y)
1480 static const Roadside _town_road_types[][2] = {
1488 static const Roadside _town_road_types_2[][2] = {
1497 static void TileLoop_Road(
TileIndex tile)
1519 HouseZonesBits grp = HZB_TOWN_EDGE;
1549 if (cur_rs == new_rs[0])
return;
1552 if (cur_rs == new_rs[1]) {
1572 if (old_rb != new_rb) {
1581 static bool ClickTile_Road(
TileIndex tile)
1590 static const TrackBits _road_trackbits[16] = {
1622 const uint drd_to_multiplier[
DRD_END] = { 0x101, 0x100, 0x1, 0x0 };
1661 static const StringID _road_tile_strings[] = {
1662 STR_LAI_ROAD_DESCRIPTION_ROAD,
1663 STR_LAI_ROAD_DESCRIPTION_ROAD,
1664 STR_LAI_ROAD_DESCRIPTION_ROAD,
1665 STR_LAI_ROAD_DESCRIPTION_ROAD_WITH_STREETLIGHTS,
1666 STR_LAI_ROAD_DESCRIPTION_ROAD,
1667 STR_LAI_ROAD_DESCRIPTION_TREE_LINED_ROAD,
1668 STR_LAI_ROAD_DESCRIPTION_ROAD,
1669 STR_LAI_ROAD_DESCRIPTION_ROAD,
1680 td->
str = STR_LAI_ROAD_DESCRIPTION_ROAD_RAIL_LEVEL_CROSSING;
1694 td->
str = STR_LAI_ROAD_DESCRIPTION_ROAD_VEHICLE_DEPOT;
1714 bool mixed_owners = (tram_owner !=
INVALID_OWNER && tram_owner != first_owner) || (rail_owner !=
INVALID_OWNER && rail_owner != first_owner);
1719 td->
owner[0] = rail_owner;
1721 td->
owner[1] = road_owner;
1723 td->
owner[2] = tram_owner;
1726 td->
owner[0] = first_owner;
1745 if (rv->frame == RVC_DEPOT_STOP_FRAME &&
1794 Company::Get(old_owner)->infrastructure.road[rt] -= num_bits;
1835 if (bits == bits_copy) {
1850 default: NOT_REACHED();
1860 GetSlopePixelZ_Road,
1864 GetTileTrackStatus_Road,
1868 ChangeTileOwner_Road,
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.
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.
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 DrawOrigTileSeqInGUI(int x, int y, const DrawTileSprites *dts, PaletteID default_palette)
Draw TTD sprite sequence in GUI.
Tile information, used while rendering the tile.
static void SetTileOwner(TileIndex tile, Owner owner)
Sets the owner of a tile.
CommandCost CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, RoadType rt, DoCommandFlag flags, bool town_check)
Is it allowed to remove the given road bits from the given tile?
All zoomlevels below or equal to this, will result in details on the screen, like road-work...
byte landscape
the landscape we're currently in
DirectionByte direction
facing
company buildings - depots, stations, HQ, ...
static const RoadBits _invalid_tileh_slopes_road[2][15]
Invalid RoadBits on slopes.
#define ToggleDesert
Toggle the snow/desert state of a road tile.
Y-axis and direction to north-west.
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.
#define FOR_ALL_EFFECTVEHICLES(var)
Iterate over disaster vehicles.
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.
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.
WindowFlags flags
Window flags.
CommandCost EnsureNoVehicleOnGround(TileIndex tile)
Ensure there is no vehicle at the ground at the given position.
Flag for an invalid DiagDirection.
bool ValParamRoadType(const RoadType rt)
Validate functions for rail building.
static bool IsRoadOwner(TileIndex t, RoadType rt, Owner o)
Check if a specific road type is owned by an owner.
static Titem * Get(size_t index)
Returns Titem with given index.
Money GetAvailableMoneyForCommand()
static const SpriteID SPR_ONEWAY_BASE
One way road sprites.
Functions related to dates.
static bool IsInsideMM(const T x, const uint min, const uint max)
Checks if a value is in an interval.
static bool HasCrossingReservation(TileIndex t)
Get the reservation state of the rail crossing.
remove a complete road (not a "half" one)
Track
These are used to specify a single track.
static TrackBits GetCrossingRailBits(TileIndex tile)
Get the rail track bits of a level crossing.
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.
bool extra_dynamite
extra dynamite
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.
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...
X-axis and direction to south-west.
void DrawRoadDepotSprite(int x, int y, DiagDirection dir, RoadType rt)
Draw the road depot sprite.
static RoadTypes RoadTypeToRoadTypes(RoadType rt)
Maps a RoadType to the corresponding RoadTypes value.
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)
static bool HasTileRoadType(TileIndex t, RoadType rt)
Check if a tile has a specific road type.
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.
static RoadBits GetRoadBits(TileIndex t, RoadType rt)
Get the present road bits for a specific road type.
#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.
Sprite constructs for road depots.
A special vehicle is one of the following:
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 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...
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.
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 IsValidRoadType(RoadType rt)
Whether the given roadtype is valid.
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.
Date build_date
Date of construction.
int GetTileZ(TileIndex tile)
Get bottom height of the tile.
CompanyByte _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
company bankrupts, skip money check, skip vehicle on tile check in some cases
Functions related to (drawing on) viewports.
Pseudo random number generator.
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.
SpriteID single_y
single piece of rail in Y direction, without ground
static bool IsBridgeAbove(TileIndex t)
checks if a bridge is set above the ground of this tile
TrackBits
Bitfield corresponding to Track.
Buses, trucks and trams belong to this class.
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.
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.
static TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
#define IsOnDesert
Check if a road tile has snow/desert.
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 give 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.
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.
static Owner GetRoadOwner(TileIndex t, RoadType rt)
Get the owner of a specific road type.
StringID owner_type[4]
Type of each owner.
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.
#define FIND_FIRST_BIT(x)
Returns the first non-zero bit in a 6-bit value (from right).
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.
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)
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.
bool Succeeded() const
Did this command succeed?
const TileTypeProcs _tile_type_road_procs
Tile callback functions for road tiles.
Definition of base types and functions in a cross-platform compatible way.
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
uint y
Y position of the tile in unit coordinates.
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.
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.
static bool IsSlopeWithOneCornerRaised(Slope s)
Tests if a specific slope has exactly one corner raised.
Road with street lights on paved sidewalks.
GUI Functions related to companies.
static const uint TUNNELBRIDGE_TRACKBIT_FACTOR
Multiplier for how many regular track bits a tunnel/bridge counts.
static void SetRoadBits(TileIndex t, RoadBits r, RoadType rt)
Set the present road bits for a specific road type.
don't allow building on water
uint16 max_speed
Maximum speed for vehicles travelling on this rail type.
TileIndex tile
Current tile index.
CommandCost CheckOwnership(Owner owner, TileIndex tile)
Check whether the current owner owns something.
The tile has no ownership.
Base class for all effect vehicles.
SpriteID single_x
single piece of rail in X direction, without ground
DiagDirection
Enumeration for diagonal directions.
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.
RoadBits GetAnyRoadBits(TileIndex tile, RoadType rt, bool straight_tunnel_bridge_entrance)
Returns the RoadBits on an arbitrary tile Special behaviour:
RoadBits CleanUpRoadBits(const TileIndex tile, RoadBits org_rb)
Clean up unnecessary RoadBits of a planed 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.
void UpdateLevelCrossing(TileIndex tile, bool sound=true)
Sets correct crossing state.
static void DrawOrigTileSeq(const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, PaletteID default_palette)
Draw TTD sprite sequence on tile.
RoadTypes
The different roadtypes we support, but then a bitmask of them.
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.
void DrawRoadCatenary(const TileInfo *ti, RoadBits tram)
Draws the catenary for the given tile.
static void SetRoadside(TileIndex tile, Roadside s)
Set the decorations of a road.
uint8 FindFirstBit(uint32 x)
Search the first set bit in a 32 bit variable.
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.
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset)
Mark a tile given by its index dirty for repaint.
bool mod_road_rebuild
roadworks remove unnecessary RoadBits
static TrackBits GetTrackBits(TileIndex tile)
Gets the track bits of the given tile.
CompanyInfrastructure infrastructure
NOSAVE: Counts of company owned infrastructure.
uint32 rail[RAILTYPE_END]
Count of company owned track bits for each rail type.
Y-axis and direction to south-east.
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.
removing a roadpiece at the edge
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 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 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.
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.
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
A town owns the tile, or a town is expanding.
static void MakeRoadCrossing(TileIndex t, Owner road, Owner tram, Owner rail, Axis roaddir, RailType rat, RoadTypes rot, uint town)
Make a level crossing.
static bool HasAtMostOneBit(T value)
Test whether value has at most 1 bit set.
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.
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.
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.
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.
static uint CountBits(T value)
Counts the number of set bits in a variable.
TrackdirBits
Enumeration of bitmasks for the TrackDirs.
Functions related to commands.
Road on grass with road works.
remove a single rail track
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-NULL) Titem.
static bool HasRailCatenaryDrawn(RailType rt)
Test if we should draw rail catenary.
static RoadBits GetOtherRoadBits(TileIndex t, RoadType rt)
Get all RoadBits set on a tile except from the given RoadType.
Date build_date
Date of construction of tile contents.
header file for electrified rail specific functions
static Axis OtherAxis(Axis a)
Select the other axis as provided.
static RoadTypes ComplementRoadTypes(RoadTypes r)
Returns the RoadTypes which are not present in the given RoadTypes.
static const SpriteID SPR_TRAMWAY_BASE
Tramway sprites.
DisallowedRoadDirections
Which directions are disallowed ?
static void MakeRoadNormal(TileIndex t, RoadBits bits, RoadTypes rot, TownID town, Owner road, Owner tram)
Make a normal road tile.
ConstructionSettings construction
construction of things in-game
Owner owner
The owner of the content shown in this window. Company colour is acquired from this variable...
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 RoadTypes GetRoadTypes(TileIndex t)
Get the present road types 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.
static TrackdirBits TrackBitsToTrackdirBits(TrackBits bits)
Converts TrackBits to TrackdirBits while allowing both directions.
static bool IsCrossingBarred(TileIndex t)
Check if the level crossing is barred.
GameCreationSettings game_creation
settings used during the creation of a game (map)
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.
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.
Owner
Enum for all companies/owners.
CommandCost CmdRemoveLongRoad(TileIndex start_tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Remove a long piece of road.
static DiagDirection AxisToDiagDir(Axis a)
Converts an Axis to a DiagDirection.
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.
static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits pieces, RoadType rt, bool crossing_check, bool town_check=true)
Delete a piece of road.
static void SetRoadTypes(TileIndex t, RoadTypes rt)
Set the present road types of a tile.
byte road_build_months
fund road reconstruction in action?
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)
X-axis and direction to north-east.
static bool HasGrfMiscBit(GrfMiscBit bit)
Check for grf miscellaneous bits.
static Direction ReverseDir(Direction d)
Return the reverse of a direction.
The tile/execution is done by "water".
VehicleTypeByte type
Type of vehicle.
void DrawBridgeMiddle(const TileInfo *ti)
Draw the middle bits of a bridge.
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.
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-...
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.
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.