summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-08-02 22:47:34 +0000
committerrubidium <rubidium@openttd.org>2008-08-02 22:47:34 +0000
commitdf99103a3167874a34b1f1f65fe60aae8ff3116a (patch)
tree05501a08aa467d6f132ef0f7fd2cd1b5fee8c4c7 /src
parentec7cc498254cccf3e1d150e6d978b7cf2b89eb89 (diff)
downloadopenttd-df99103a3167874a34b1f1f65fe60aae8ff3116a.tar.xz
(svn r13927) -Add [YAPP]: Draw reserved tracks darker, toggeld by a patch setting. (michi_cc)
Diffstat (limited to 'src')
-rw-r--r--src/lang/english.txt1
-rw-r--r--src/rail_cmd.cpp33
-rw-r--r--src/road_cmd.cpp6
-rw-r--r--src/settings.cpp1
-rw-r--r--src/settings_gui.cpp1
-rw-r--r--src/settings_type.h1
-rw-r--r--src/station_cmd.cpp6
-rw-r--r--src/tunnelbridge_cmd.cpp16
8 files changed, 65 insertions, 0 deletions
diff --git a/src/lang/english.txt b/src/lang/english.txt
index cbfc79e37..498635377 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -1136,6 +1136,7 @@ STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE_MAGLEV :Maglev
STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE_FIRST :First available
STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE_LAST :Last available
STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE_MOST_USED :Most used
+STR_CONFIG_PATCHES_SHOW_TRACK_RESERVATION :{LTBLUE}Show reserved tracks: {ORANGE}{STRING1}
STR_CONFIG_PATCHES_ALWAYS_BUILD_INFRASTRUCTURE :{LTBLUE}Show building tools when no suitable vehicles are available: {ORANGE}{STRING1}
STR_CONFIG_PATCHES_MAX_TRAINS :{LTBLUE}Max trains per player: {ORANGE}{STRING1}
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index 8fa027a6d..7e231ff80 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -1688,6 +1688,29 @@ static void DrawTrackBits(TileInfo* ti, TrackBits track)
if (track & TRACK_BIT_RIGHT) DrawGroundSprite(rti->base_sprites.single_e, PAL_NONE);
}
+ /* PBS debugging, draw reserved tracks darker */
+ if (_settings_client.gui.show_track_reservation) {
+ TrackBits pbs = GetTrackReservation(ti->tile);
+ if (pbs & TRACK_BIT_X) {
+ if (ti->tileh == SLOPE_FLAT || ti->tileh == SLOPE_ELEVATED) {
+ DrawGroundSprite(rti->base_sprites.single_y, PALETTE_CRASH);
+ } else {
+ DrawGroundSprite(_track_sloped_sprites[ti->tileh - 1] + rti->base_sprites.single_sloped - 20, PALETTE_CRASH);
+ }
+ }
+ if (pbs & TRACK_BIT_Y) {
+ if (ti->tileh == SLOPE_FLAT || ti->tileh == SLOPE_ELEVATED) {
+ DrawGroundSprite(rti->base_sprites.single_x, PALETTE_CRASH);
+ } else {
+ DrawGroundSprite(_track_sloped_sprites[ti->tileh - 1] + rti->base_sprites.single_sloped - 20, PALETTE_CRASH);
+ }
+ }
+ if (pbs & TRACK_BIT_UPPER) AddSortableSpriteToDraw(rti->base_sprites.single_n, PALETTE_CRASH, ti->x, ti->y, 16, 16, 0, ti->z + (ti->tileh & SLOPE_N ? 8 : 0));
+ if (pbs & TRACK_BIT_LOWER) AddSortableSpriteToDraw(rti->base_sprites.single_s, PALETTE_CRASH, ti->x, ti->y, 16, 16, 0, ti->z + (ti->tileh & SLOPE_S ? 8 : 0));
+ if (pbs & TRACK_BIT_LEFT) AddSortableSpriteToDraw(rti->base_sprites.single_w, PALETTE_CRASH, ti->x, ti->y, 16, 16, 0, ti->z + (ti->tileh & SLOPE_W ? 8 : 0));
+ if (pbs & TRACK_BIT_RIGHT) AddSortableSpriteToDraw(rti->base_sprites.single_e, PALETTE_CRASH, ti->x, ti->y, 16, 16, 0, ti->z + (ti->tileh & SLOPE_E ? 8 : 0));
+ }
+
if (IsValidCorner(halftile_corner)) {
DrawFoundation(ti, HalftileFoundation(halftile_corner));
@@ -1702,6 +1725,11 @@ static void DrawTrackBits(TileInfo* ti, TrackBits track)
default: break;
}
DrawGroundSprite(image, pal, &(_halftile_sub_sprite[halftile_corner]));
+
+ if (_settings_client.gui.show_track_reservation && IsSteepSlope(ti->tileh) && HasReservedTracks(ti->tile, CornerToTrackBits(halftile_corner))) {
+ static const byte _corner_to_track_sprite[] = {3, 1, 2, 0};
+ AddSortableSpriteToDraw(_corner_to_track_sprite[halftile_corner] + rti->base_sprites.single_n, PALETTE_CRASH, ti->x, ti->y, 16, 16, 0, ti->z + 16);
+ }
}
}
@@ -1846,6 +1874,11 @@ default_waypoint:
DrawGroundSprite(image, PAL_NONE);
+ /* PBS debugging, draw reserved tracks darker */
+ if (_settings_client.gui.show_track_reservation && GetDepotWaypointReservation(ti->tile)) {
+ DrawGroundSprite(GetWaypointAxis(ti->tile) == AXIS_X ? rti->base_sprites.single_y : rti->base_sprites.single_x, PALETTE_CRASH);
+ }
+
if (HasCatenaryDrawn(GetRailType(ti->tile))) DrawCatenary(ti);
foreach_draw_tile_seq(dtss, dts->seq) {
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
index 8af34a470..07c327494 100644
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -1176,6 +1176,12 @@ static void DrawTile_Road(TileInfo *ti)
}
DrawGroundSprite(image, pal);
+
+ /* PBS debugging, draw reserved tracks darker */
+ if (_settings_client.gui.show_track_reservation && GetCrossingReservation(ti->tile)) {
+ DrawGroundSprite(GetCrossingRoadAxis(ti->tile) == AXIS_Y ? GetRailTypeInfo(GetRailType(ti->tile))->base_sprites.single_y : GetRailTypeInfo(GetRailType(ti->tile))->base_sprites.single_x, PALETTE_CRASH);
+ }
+
if (HasTileRoadType(ti->tile, ROADTYPE_TRAM)) {
DrawGroundSprite(SPR_TRAMWAY_OVERLAY + (GetCrossingRoadAxis(ti->tile) ^ 1), pal);
DrawTramCatenary(ti, GetCrossingRoadBits(ti->tile));
diff --git a/src/settings.cpp b/src/settings.cpp
index 213c1e716..681c33b4c 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -1789,6 +1789,7 @@ const SettingDesc _patch_settings[] = {
SDTC_BOOL(gui.bridge_pillars, S, 0, true, STR_NULL, NULL),
SDTC_BOOL(gui.auto_euro, S, 0, true, STR_NULL, NULL),
SDTC_VAR(gui.news_message_timeout, SLE_UINT8, S, 0, 2, 1, 255, 0, STR_NULL, NULL),
+ SDTC_BOOL(gui.show_track_reservation, S, 0, false, STR_CONFIG_PATCHES_SHOW_TRACK_RESERVATION, RedrawScreen),
#ifdef ENABLE_NETWORK
SDTC_VAR(network.sync_freq, SLE_UINT16,C|S,NO, 100, 0, 100, 0, STR_NULL, NULL),
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index 6ebc6e8a6..395463b46 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -613,6 +613,7 @@ static const char *_patches_ui[] = {
"gui.timetable_in_ticks",
"gui.default_rail_type",
"gui.always_build_infrastructure",
+ "gui.show_track_reservation",
};
static const char *_patches_construction[] = {
diff --git a/src/settings_type.h b/src/settings_type.h
index 0926db66c..97eb0a903 100644
--- a/src/settings_type.h
+++ b/src/settings_type.h
@@ -79,6 +79,7 @@ struct GUISettings {
int16 autorenew_months; ///< how many months from EOL of vehicles should autorenew trigger for new companies?
int32 autorenew_money; ///< how much money before autorenewing for new companies?
byte news_message_timeout; ///< how much longer than the news message "age" should we keep the message in the history
+ bool show_track_reservation; ///< highlight reserved tracks.
};
/** Settings related to currency/unit systems. */
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 53ad81fc7..4b62d7289 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -2215,6 +2215,12 @@ static void DrawTile_Station(TileInfo *ti)
image += total_offset;
}
DrawGroundSprite(image, HasBit(image, PALETTE_MODIFIER_COLOR) ? palette : PAL_NONE);
+
+ /* PBS debugging, draw reserved tracks darker */
+ if (_settings_client.gui.show_track_reservation && IsRailwayStation(ti->tile) && GetRailwayStationReservation(ti->tile)) {
+ const RailtypeInfo *rti = GetRailTypeInfo(GetRailType(ti->tile));
+ DrawGroundSprite(GetRailStationAxis(ti->tile) == AXIS_X ? rti->base_sprites.single_y : rti->base_sprites.single_x, PALETTE_CRASH);
+ }
}
if (IsRailwayStation(ti->tile) && HasCatenaryDrawn(GetRailType(ti->tile)) && IsStationTileElectrifiable(ti->tile)) DrawCatenary(ti);
diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp
index 84c732920..41af685ac 100644
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -887,6 +887,13 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
image += tunnelbridge_direction * 2;
DrawGroundSprite(image, PAL_NONE);
+
+ /* PBS debugging, draw reserved tracks darker */
+ if (_settings_client.gui.show_track_reservation && (transport_type == TRANSPORT_RAIL && GetTunnelBridgeReservation(ti->tile))) {
+ const RailtypeInfo *rti = GetRailTypeInfo(GetRailType(ti->tile));
+ DrawGroundSprite(DiagDirToAxis(tunnelbridge_direction) == AXIS_X ? rti->base_sprites.single_y : rti->base_sprites.single_x, PALETTE_CRASH);
+ }
+
if (transport_type == TRANSPORT_ROAD) {
RoadTypes rts = GetRoadTypes(ti->tile);
@@ -963,6 +970,15 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
/* Bridge heads are drawn solid no matter how invisibility/transparency is set */
AddSortableSpriteToDraw(psid->sprite, psid->pal, ti->x, ti->y, 16, 16, ti->tileh == SLOPE_FLAT ? 0 : 8, ti->z);
+ if (_settings_client.gui.show_track_reservation && transport_type == TRANSPORT_RAIL && GetTunnelBridgeReservation(ti->tile)) {
+ const RailtypeInfo *rti = GetRailTypeInfo(GetRailType(ti->tile));
+ if (HasBridgeFlatRamp(ti->tileh, DiagDirToAxis(tunnelbridge_direction))) {
+ AddSortableSpriteToDraw(DiagDirToAxis(tunnelbridge_direction) == AXIS_X ? rti->base_sprites.single_y : rti->base_sprites.single_x, PALETTE_CRASH, ti->x, ti->y, 16, 16, 0, ti->z + 8);
+ } else {
+ AddSortableSpriteToDraw(rti->base_sprites.single_sloped + tunnelbridge_direction, PALETTE_CRASH, ti->x, ti->y, 16, 16, 8, ti->z);
+ }
+ }
+
if (transport_type == TRANSPORT_ROAD) {
RoadTypes rts = GetRoadTypes(ti->tile);