summaryrefslogtreecommitdiff
path: root/src/station_cmd.cpp
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2010-01-03 22:44:57 +0000
committerpeter1138 <peter1138@openttd.org>2010-01-03 22:44:57 +0000
commit5ab64809fe72c38d373bdbed6ffa9b6660dd69d6 (patch)
tree49b0a7ac404ffab434ecb124ee9931f0e11d8c7e /src/station_cmd.cpp
parent9e2ccca327b309da98217e92f133619a30cc4038 (diff)
downloadopenttd-5ab64809fe72c38d373bdbed6ffa9b6660dd69d6.tar.xz
(svn r18708) -Feature: [NewGRF] Add support for custom station foundation graphics.
Diffstat (limited to 'src/station_cmd.cpp')
-rw-r--r--src/station_cmd.cpp59
1 files changed, 55 insertions, 4 deletions
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index df57900f4..f51a32def 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -2316,10 +2316,6 @@ static void DrawTile_Station(TileInfo *ti)
palette = PALETTE_TO_GREY;
}
- /* don't show foundation for docks */
- if (ti->tileh != SLOPE_FLAT && !IsDock(ti->tile))
- DrawFoundation(ti, FOUNDATION_LEVELED);
-
if (IsCustomStationSpecIndex(ti->tile)) {
/* look for customization */
st = BaseStation::GetByTile(ti->tile);
@@ -2344,6 +2340,61 @@ static void DrawTile_Station(TileInfo *ti)
if (t == NULL || t->seq == NULL) t = &_station_display_datas[GetStationType(ti->tile)][GetStationGfx(ti->tile)];
+ /* don't show foundation for docks */
+ if (ti->tileh != SLOPE_FLAT && !IsDock(ti->tile)) {
+ if (statspec != NULL && HasBit(statspec->flags, SSF_CUSTOM_FOUNDATIONS)) {
+ /* Station has custom foundations. */
+ SpriteID image = GetCustomStationFoundationRelocation(statspec, st, ti->tile);
+
+ if (HasBit(statspec->flags, SSF_EXTENDED_FOUNDATIONS)) {
+ /* Station provides extended foundations. */
+
+ static const uint8 foundation_parts[] = {
+ 0, 0, 0, 0, // Invalid, Invalid, Invalid, SLOPE_SW
+ 0, 1, 2, 3, // Invalid, SLOPE_EW, SLOPE_SE, SLOPE_WSE
+ 0, 4, 5, 6, // Invalid, SLOPE_NW, SLOPE_NS, SLOPE_NWS
+ 7, 8, 9 // SLOPE_NE, SLOPE_ENW, SLOPE_SEN
+ };
+
+ AddSortableSpriteToDraw(image + foundation_parts[ti->tileh], PAL_NONE, ti->x, ti->y, 16, 16, 7, ti->z);
+ } else {
+ /* Draw simple foundations, built up from 8 possible foundation sprites. */
+
+ /* Each set bit represents one of the eight composite sprites to be drawn.
+ * 'Invalid' entries will not drawn but are included for completeness. */
+ static const uint8 composite_foundation_parts[] = {
+ /* Invalid (00000000), Invalid (11010001), Invalid (11100100), SLOPE_SW (11100000) */
+ 0x00, 0xD1, 0xE4, 0xE0,
+ /* Invalid (11001010), SLOPE_EW (11001001), SLOPE_SE (11000100), SLOPE_WSE (11000000) */
+ 0xCA, 0xC9, 0xC4, 0xC0,
+ /* Invalid (11010010), SLOPE_NW (10010001), SLOPE_NS (11100100), SLOPE_NWS (10100000) */
+ 0xD2, 0x91, 0xE4, 0xA0,
+ /* SLOPE_NE (01001010), SLOPE_ENW (00001001), SLOPE_SEN (01000100) */
+ 0x4A, 0x09, 0x44
+ };
+
+ uint8 parts = composite_foundation_parts[ti->tileh];
+
+ /* If foundations continue beyond the tile's upper sides then
+ * mask out the last two pieces. */
+ uint z;
+ Slope slope = GetFoundationSlope(ti->tile, &z);
+ if (!HasFoundationNW(ti->tile, slope, z)) ClrBit(parts, 6);
+ if (!HasFoundationNE(ti->tile, slope, z)) ClrBit(parts, 7);
+
+ for (int i = 0; i < 8; i++) {
+ if (HasBit(parts, i)) {
+ AddSortableSpriteToDraw(image + i, PAL_NONE, ti->x, ti->y, 16, 16, 7, ti->z);
+ }
+ }
+ }
+
+ OffsetGroundSprite(31, 1);
+ ti->z += ApplyFoundationToSlope(FOUNDATION_LEVELED, &ti->tileh);
+ } else {
+ DrawFoundation(ti, FOUNDATION_LEVELED);
+ }
+ }
if (IsBuoy(ti->tile) || IsDock(ti->tile) || (IsOilRig(ti->tile) && GetWaterClass(ti->tile) != WATER_CLASS_INVALID)) {
if (ti->tileh == SLOPE_FLAT) {