From 8faead7e7a1f407c34b5ee3e83ba7ffd1209755b Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Wed, 19 Aug 2015 21:56:22 +0100 Subject: [PATCH] Graphically indicate restricted signals by recolouring the signal post. Recolour signal posts from grey to blue for restricted signals which are not semaphores and are not custom sprites. --- bin/data/tracerestrict.grf | Bin 0 -> 526 bytes src/gfxinit.cpp | 3 +++ src/rail_cmd.cpp | 15 ++++++++++++++- src/table/sprites.h | 6 +++++- 4 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 bin/data/tracerestrict.grf diff --git a/bin/data/tracerestrict.grf b/bin/data/tracerestrict.grf new file mode 100644 index 0000000000000000000000000000000000000000..b71ee80c1713778d8886e3aeca4568644b075d93 GIT binary patch literal 526 zcmZQ%{LjF^$i&RT%Er#Y$;HjX%f~MuC?qT*Dkd%=DJ3l ztEX>ZXk=_+YG!U>X=QC=YiIA^=;Z9;>gMj@>E-R?>*pU37!({58WtWA85JE98yBCD zn3SB7nwFlCnU$TBo0nfuSX5k6T2@|BSyf$ATUXyOY4Vh*)26p~bar+3^!D{nm}`JIdkXDU$Ah|;w4L$Enl&6)#^2C*R9{Mant54TeofBv2)k%J$v`DsiM$a%fg9rl# GFaQ8SISHfy literal 0 HcmV?d00001 diff --git a/src/gfxinit.cpp b/src/gfxinit.cpp index 10bc0afa17..440cf5bb1a 100644 --- a/src/gfxinit.cpp +++ b/src/gfxinit.cpp @@ -170,6 +170,9 @@ static void LoadSpriteTables() _palette_remap_grf[i] = (PAL_DOS != used_set->palette); LoadGrfFile(used_set->files[GFT_BASE].filename, 0, i++); + /* Tracerestrict sprites. */ + LoadGrfFile("tracerestrict.grf", SPR_TRACERESTRICT_BASE, i++); + /* * The second basic file always starts at the given location and does * contain a different amount of sprites depending on the "type"; DOS diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index e1b956bad9..3b706c69ea 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -1862,6 +1862,7 @@ static void DrawSingleSignal(TileIndex tile, const RailtypeInfo *rti, Track trac SignalVariant variant = GetSignalVariant(tile, track); SpriteID sprite = GetCustomSignalSprite(rti, tile, type, variant, condition); + bool is_custom_sprite = (sprite != 0); if (sprite != 0) { sprite += image; } else { @@ -1870,7 +1871,19 @@ static void DrawSingleSignal(TileIndex tile, const RailtypeInfo *rti, Track trac sprite += type * 16 + variant * 64 + image * 2 + condition + (type > SIGTYPE_LAST_NOPBS ? 64 : 0); } - AddSortableSpriteToDraw(sprite, PAL_NONE, x, y, 1, 1, BB_HEIGHT_UNDER_BRIDGE, GetSaveSlopeZ(x, y, track)); + if (!is_custom_sprite && variant == SIG_ELECTRIC && IsRestrictedSignal(tile) && GetExistingTraceRestrictProgram(tile, track) != NULL) { + if (type == SIGTYPE_PBS || type == SIGTYPE_PBS_ONEWAY) { + static const SubSprite lower_part { -50, -10, 50, 50 }; + static const SubSprite upper_part { -50, -50, 50, -11 }; + + AddSortableSpriteToDraw(sprite, SPR_TRACERESTRICT_BASE, x, y, 1, 1, BB_HEIGHT_UNDER_BRIDGE, GetSaveSlopeZ(x, y, track), false, 0, 0, 0, &lower_part); + AddSortableSpriteToDraw(sprite, PAL_NONE, x, y, 1, 1, BB_HEIGHT_UNDER_BRIDGE, GetSaveSlopeZ(x, y, track), false, 0, 0, 0, &upper_part); + } else { + AddSortableSpriteToDraw(sprite, SPR_TRACERESTRICT_BASE + 1, x, y, 1, 1, BB_HEIGHT_UNDER_BRIDGE, GetSaveSlopeZ(x, y, track)); + } + } else { + AddSortableSpriteToDraw(sprite, PAL_NONE, x, y, 1, 1, BB_HEIGHT_UNDER_BRIDGE, GetSaveSlopeZ(x, y, track)); + } } static uint32 _drawtile_track_palette; diff --git a/src/table/sprites.h b/src/table/sprites.h index 81d5388f99..3bd7fdffeb 100644 --- a/src/table/sprites.h +++ b/src/table/sprites.h @@ -296,8 +296,12 @@ static const uint16 EMPTY_BOUNDING_BOX_SPRITE_COUNT = 1; static const SpriteID SPR_PALETTE_BASE = SPR_EMPTY_BOUNDING_BOX + EMPTY_BOUNDING_BOX_SPRITE_COUNT; static const uint16 PALETTE_SPRITE_COUNT = 1; +/* Tracerestrict sprites */ +static const SpriteID SPR_TRACERESTRICT_BASE = SPR_PALETTE_BASE + PALETTE_SPRITE_COUNT; +static const uint16 TRACERESTRICT_SPRITE_COUNT = 2; + /* From where can we start putting NewGRFs? */ -static const SpriteID SPR_NEWGRFS_BASE = SPR_PALETTE_BASE + PALETTE_SPRITE_COUNT; +static const SpriteID SPR_NEWGRFS_BASE = SPR_TRACERESTRICT_BASE + TRACERESTRICT_SPRITE_COUNT; /* Manager face sprites */ static const SpriteID SPR_GRADIENT = 874; // background gradient behind manager face