summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/clear_cmd.cpp2
-rw-r--r--src/dummy_land.cpp2
-rw-r--r--src/industry_cmd.cpp2
-rw-r--r--src/landscape.cpp13
-rw-r--r--src/rail_cmd.cpp21
-rw-r--r--src/road_cmd.cpp25
-rw-r--r--src/station_cmd.cpp13
-rw-r--r--src/tile_cmd.h5
-rw-r--r--src/town_cmd.cpp2
-rw-r--r--src/tree_cmd.cpp2
-rw-r--r--src/tunnelbridge_cmd.cpp7
-rw-r--r--src/unmovable_cmd.cpp2
-rw-r--r--src/water_cmd.cpp2
13 files changed, 68 insertions, 30 deletions
diff --git a/src/clear_cmd.cpp b/src/clear_cmd.cpp
index 320d29999..522a0e57a 100644
--- a/src/clear_cmd.cpp
+++ b/src/clear_cmd.cpp
@@ -315,7 +315,7 @@ static void ClickTile_Clear(TileIndex tile)
/* not used */
}
-static uint32 GetTileTrackStatus_Clear(TileIndex tile, TransportType mode, uint sub_mode)
+static uint32 GetTileTrackStatus_Clear(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
{
return 0;
}
diff --git a/src/dummy_land.cpp b/src/dummy_land.cpp
index f2d7527f8..8ba8d2903 100644
--- a/src/dummy_land.cpp
+++ b/src/dummy_land.cpp
@@ -64,7 +64,7 @@ static void ChangeTileOwner_Dummy(TileIndex tile, PlayerID old_player, PlayerID
/* not used */
}
-static uint32 GetTileTrackStatus_Dummy(TileIndex tile, TransportType mode, uint sub_mode)
+static uint32 GetTileTrackStatus_Dummy(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
{
return 0;
}
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index bf8dea242..07e996ab9 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -815,7 +815,7 @@ static void ClickTile_Industry(TileIndex tile)
ShowIndustryViewWindow(GetIndustryIndex(tile));
}
-static uint32 GetTileTrackStatus_Industry(TileIndex tile, TransportType mode, uint sub_mode)
+static uint32 GetTileTrackStatus_Industry(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
{
return 0;
}
diff --git a/src/landscape.cpp b/src/landscape.cpp
index 8745fa19f..5641c8924 100644
--- a/src/landscape.cpp
+++ b/src/landscape.cpp
@@ -437,9 +437,18 @@ void DoClearSquare(TileIndex tile)
MarkTileDirtyByTile(tile);
}
-uint32 GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode)
+/** Returns trackdirbits in lower two bytes and additional info about track status in upper two bytes
+ * If there is any trackbit at 'side', return all trackdirbits.
+ * For TRANSPORT_ROAD, return 0 if there is no roadbit (of given subtype) at given side.
+ * @param tile tile to get info about
+ * @param mode transport type
+ * @param sub_mode for TRANSPORT_ROAD, roadtypes to check
+ * @param side side we are entering from, INVALID_DIAGDIR to return all trackbits
+ * @return trackdirbits and other info depending on 'mode'
+ */
+uint32 GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
{
- return _tile_type_procs[GetTileType(tile)]->get_tile_track_status_proc(tile, mode, sub_mode);
+ return _tile_type_procs[GetTileType(tile)]->get_tile_track_status_proc(tile, mode, sub_mode, side);
}
void ChangeTileOwner(TileIndex tile, PlayerID old_player, PlayerID new_player)
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index 2f6c003f1..f2ffaff89 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -2083,17 +2083,14 @@ set_ground:
}
-static uint32 GetTileTrackStatus_Track(TileIndex tile, TransportType mode, uint sub_mode)
+static uint32 GetTileTrackStatus_Track(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
{
if (mode != TRANSPORT_RAIL) return 0;
switch (GetRailTileType(tile)) {
default: NOT_REACHED();
- case RAIL_TILE_NORMAL: {
- TrackBits rails = GetTrackBits(tile);
- uint32 ret = rails * 0x101;
- return (rails == TRACK_BIT_CROSS) ? ret | 0x40 : ret;
- }
+ case RAIL_TILE_NORMAL:
+ return GetTrackBits(tile) * 0x101;
case RAIL_TILE_SIGNALS: {
uint32 ret = GetTrackBits(tile) * 0x101;
@@ -2117,8 +2114,16 @@ static uint32 GetTileTrackStatus_Track(TileIndex tile, TransportType mode, uint
return ret;
}
- case RAIL_TILE_DEPOT: return AxisToTrackBits(DiagDirToAxis(GetRailDepotDirection(tile))) * 0x101;
- case RAIL_TILE_WAYPOINT: return GetRailWaypointBits(tile) * 0x101;
+ case RAIL_TILE_DEPOT: {
+ DiagDirection dir = GetRailDepotDirection(tile);
+
+ if (side != INVALID_DIAGDIR && side != dir) return 0;
+
+ return AxisToTrackBits(DiagDirToAxis(dir)) * 0x101;
+ }
+
+ case RAIL_TILE_WAYPOINT:
+ return GetRailWaypointBits(tile) * 0x101;
}
}
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
index b6df0d704..97bb769d8 100644
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -1314,7 +1314,7 @@ static const byte _road_trackbits[16] = {
0x0, 0x0, 0x0, 0x10, 0x0, 0x2, 0x8, 0x1A, 0x0, 0x4, 0x1, 0x15, 0x20, 0x26, 0x29, 0x3F,
};
-static uint32 GetTileTrackStatus_Road(TileIndex tile, TransportType mode, uint sub_mode)
+static uint32 GetTileTrackStatus_Road(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
{
switch (mode) {
@@ -1326,22 +1326,35 @@ static uint32 GetTileTrackStatus_Road(TileIndex tile, TransportType mode, uint s
if ((GetRoadTypes(tile) & sub_mode) == 0) return 0;
switch (GetRoadTileType(tile)) {
case ROAD_TILE_NORMAL: {
- RoadType rt = (RoadType)FindFirstBit(sub_mode);
const uint drd_to_multiplier[DRD_END] = { 0x101, 0x100, 0x1, 0x0 };
+ RoadType rt = (RoadType)FindFirstBit(sub_mode);
+ RoadBits bits = GetRoadBits(tile, rt);
+
+ /* no roadbit at this side of tile, return 0 */
+ if (side != INVALID_DIAGDIR && DiagDirToRoadBits(side) & bits == 0) return 0;
+
uint multiplier = drd_to_multiplier[rt == ROADTYPE_TRAM ? DRD_NONE : GetDisallowedRoadDirections(tile)];
- return HasRoadWorks(tile) ? 0 : _road_trackbits[GetRoadBits(tile, rt)] * multiplier;
+ return HasRoadWorks(tile) ? 0 : _road_trackbits[bits] * multiplier;
}
case ROAD_TILE_CROSSING: {
- uint32 r = AxisToTrackBits(GetCrossingRoadAxis(tile)) * 0x101;
+ Axis axis = GetCrossingRoadAxis(tile);
+
+ if (side != INVALID_DIAGDIR && axis != DiagDirToAxis(side)) return 0;
+ uint32 r = AxisToTrackBits(axis) * 0x101;
if (IsCrossingBarred(tile)) r *= 0x10001;
return r;
}
default:
- case ROAD_TILE_DEPOT:
- return AxisToTrackBits(DiagDirToAxis(GetRoadDepotDirection(tile))) * 0x101;
+ case ROAD_TILE_DEPOT: {
+ DiagDirection dir = GetRoadDepotDirection(tile);
+
+ if (side != INVALID_DIAGDIR && side != dir) return 0;
+
+ return AxisToTrackBits(DiagDirToAxis(dir)) * 0x101;
+ }
}
break;
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 8178b9e7f..e5f2e4826 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -2280,7 +2280,7 @@ static void GetTileDesc_Station(TileIndex tile, TileDesc *td)
}
-static uint32 GetTileTrackStatus_Station(TileIndex tile, TransportType mode, uint sub_mode)
+static uint32 GetTileTrackStatus_Station(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
{
switch (mode) {
case TRANSPORT_RAIL:
@@ -2302,8 +2302,15 @@ static uint32 GetTileTrackStatus_Station(TileIndex tile, TransportType mode, uin
break;
case TRANSPORT_ROAD:
- if ((GetRoadTypes(tile) & sub_mode) != 0 && IsRoadStopTile(tile)) {
- return AxisToTrackBits(DiagDirToAxis(GetRoadStopDir(tile))) * 0x101;
+ if ((GetRoadTypes(tile) & sub_mode) != 0 && IsRoadStop(tile)) {
+ DiagDirection dir = GetRoadStopDir(tile);
+ Axis axis = DiagDirToAxis(dir);
+
+ if (side != INVALID_DIAGDIR) {
+ if (axis != DiagDirToAxis(side) || (IsStandardRoadStopTile(tile) && dir != side)) return 0;
+ }
+
+ return AxisToTrackBits(axis) * 0x101;
}
break;
diff --git a/src/tile_cmd.h b/src/tile_cmd.h
index 50b5dad7a..92c9fe06c 100644
--- a/src/tile_cmd.h
+++ b/src/tile_cmd.h
@@ -13,6 +13,7 @@
#include "strings_type.h"
#include "date_type.h"
#include "player_type.h"
+#include "direction_type.h"
/** The returned bits of VehicleEnterTile. */
enum VehicleEnterTileStatus {
@@ -81,7 +82,7 @@ typedef void GetTileDescProc(TileIndex tile, TileDesc *td);
* @param sub_mode used to differentiate between different kinds within the mode
* @return the above mentions track status information
*/
-typedef uint32 GetTileTrackStatusProc(TileIndex tile, TransportType mode, uint sub_mode);
+typedef uint32 GetTileTrackStatusProc(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side);
typedef void GetProducedCargoProc(TileIndex tile, CargoID *b);
typedef void ClickTileProc(TileIndex tile);
typedef void AnimateTileProc(TileIndex tile);
@@ -126,7 +127,7 @@ struct TileTypeProcs {
extern const TileTypeProcs * const _tile_type_procs[16];
-uint32 GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode);
+uint32 GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side = INVALID_DIAGDIR);
void GetAcceptedCargo(TileIndex tile, AcceptedCargo ac);
void ChangeTileOwner(TileIndex tile, PlayerID old_player, PlayerID new_player);
void AnimateTile(TileIndex tile);
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index 6ef67f03e..2e8d8119f 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -592,7 +592,7 @@ static void GetTileDesc_Town(TileIndex tile, TileDesc *td)
td->owner = OWNER_TOWN;
}
-static uint32 GetTileTrackStatus_Town(TileIndex tile, TransportType mode, uint sub_mode)
+static uint32 GetTileTrackStatus_Town(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
{
/* not used */
return 0;
diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp
index 1184bfd52..3818a398a 100644
--- a/src/tree_cmd.cpp
+++ b/src/tree_cmd.cpp
@@ -747,7 +747,7 @@ static void ClickTile_Trees(TileIndex tile)
/* not used */
}
-static uint32 GetTileTrackStatus_Trees(TileIndex tile, TransportType mode, uint sub_mode)
+static uint32 GetTileTrackStatus_Trees(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
{
return 0;
}
diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp
index 92ec6b851..4025a7869 100644
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -1193,11 +1193,14 @@ static void ClickTile_TunnelBridge(TileIndex tile)
}
-static uint32 GetTileTrackStatus_TunnelBridge(TileIndex tile, TransportType mode, uint sub_mode)
+static uint32 GetTileTrackStatus_TunnelBridge(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
{
TransportType transport_type = GetTunnelBridgeTransportType(tile);
if (transport_type != mode || (transport_type == TRANSPORT_ROAD && (GetRoadTypes(tile) & sub_mode) == 0)) return 0;
- return AxisToTrackBits(DiagDirToAxis(GetTunnelBridgeDirection(tile))) * 0x101;
+
+ DiagDirection dir = GetTunnelBridgeDirection(tile);
+ if (side != INVALID_DIAGDIR && side != ReverseDiagDir(dir)) return 0;
+ return AxisToTrackBits(DiagDirToAxis(dir)) * 0x101;
}
static void ChangeTileOwner_TunnelBridge(TileIndex tile, PlayerID old_player, PlayerID new_player)
diff --git a/src/unmovable_cmd.cpp b/src/unmovable_cmd.cpp
index 345e9f0c3..64201cb6f 100644
--- a/src/unmovable_cmd.cpp
+++ b/src/unmovable_cmd.cpp
@@ -348,7 +348,7 @@ static void TileLoop_Unmovable(TileIndex tile)
}
-static uint32 GetTileTrackStatus_Unmovable(TileIndex tile, TransportType mode, uint sub_mode)
+static uint32 GetTileTrackStatus_Unmovable(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
{
return 0;
}
diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp
index 56da843b3..61f826549 100644
--- a/src/water_cmd.cpp
+++ b/src/water_cmd.cpp
@@ -1104,7 +1104,7 @@ void ConvertGroundTilesIntoWaterTiles()
}
}
-static uint32 GetTileTrackStatus_Water(TileIndex tile, TransportType mode, uint sub_mode)
+static uint32 GetTileTrackStatus_Water(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
{
static const byte coast_tracks[] = {0, 32, 4, 0, 16, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0};