diff options
author | peter1138 <peter1138@openttd.org> | 2007-12-31 11:13:51 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2007-12-31 11:13:51 +0000 |
commit | b48e2e178fb31e779abe00ed918060081974bb30 (patch) | |
tree | fe4608c31aaf99f17d1c896e720969ce32e9d0ae /src/station_cmd.cpp | |
parent | fa0d8d352d6ab14e5a54e7be66cf41c4fa3c2581 (diff) | |
download | openttd-b48e2e178fb31e779abe00ed918060081974bb30.tar.xz |
(svn r11729) -Codechange: Don't rely on the first railtype's sprite offset being zero when drawing road stations.
Diffstat (limited to 'src/station_cmd.cpp')
-rw-r--r-- | src/station_cmd.cpp | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index fa55814ce..8ca9b74c1 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -2075,16 +2075,20 @@ const DrawTileSprites *GetStationTileLayout(StationType st, byte gfx) static void DrawTile_Station(TileInfo *ti) { const DrawTileSprites *t = NULL; - RailType railtype; RoadTypes roadtypes; + int32 total_offset; + int32 custom_ground_offset; + if (IsRailwayStation(ti->tile)) { - railtype = GetRailType(ti->tile); + const RailtypeInfo *rti = GetRailTypeInfo(GetRailType(ti->tile)); roadtypes = ROADTYPES_NONE; + total_offset = rti->total_offset; + custom_ground_offset = rti->custom_ground_offset; } else { roadtypes = GetRoadTypes(ti->tile); - railtype = RAILTYPE_BEGIN; + total_offset = 0; + custom_ground_offset = 0; } - const RailtypeInfo *rti = GetRailTypeInfo(railtype); uint32 relocation = 0; const Station *st = NULL; const StationSpec *statspec = NULL; @@ -2131,9 +2135,9 @@ static void DrawTile_Station(TileInfo *ti) SpriteID image = t->ground_sprite; if (HasBit(image, SPRITE_MODIFIER_USE_OFFSET)) { image += GetCustomStationGroundRelocation(statspec, st, ti->tile); - image += rti->custom_ground_offset; + image += custom_ground_offset; } else { - image += rti->total_offset; + image += total_offset; } /* station_land array has been increased from 82 elements to 114 @@ -2154,7 +2158,7 @@ static void DrawTile_Station(TileInfo *ti) foreach_draw_tile_seq(dtss, t->seq) { image = dtss->image; if (relocation == 0 || HasBit(image, SPRITE_MODIFIER_USE_OFFSET)) { - image += rti->total_offset; + image += total_offset; } else { image += relocation; } @@ -2182,12 +2186,17 @@ static void DrawTile_Station(TileInfo *ti) void StationPickerDrawSprite(int x, int y, StationType st, RailType railtype, RoadType roadtype, int image) { - const RailtypeInfo *rti = GetRailTypeInfo(railtype); + int32 total_offset = 0; SpriteID pal = PLAYER_SPRITE_COLOR(_local_player); const DrawTileSprites *t = &_station_display_datas[st][image]; + if (railtype != INVALID_RAILTYPE) { + const RailtypeInfo *rti = GetRailTypeInfo(railtype); + total_offset = rti->total_offset; + } + SpriteID img = t->ground_sprite; - DrawSprite(img + rti->total_offset, HasBit(img, PALETTE_MODIFIER_COLOR) ? pal : PAL_NONE, x, y); + DrawSprite(img + total_offset, HasBit(img, PALETTE_MODIFIER_COLOR) ? pal : PAL_NONE, x, y); if (roadtype == ROADTYPE_TRAM) { DrawSprite(SPR_TRAMWAY_TRAM + (t->ground_sprite == SPR_ROAD_PAVED_STRAIGHT_X ? 1 : 0), PAL_NONE, x, y); @@ -2196,7 +2205,7 @@ void StationPickerDrawSprite(int x, int y, StationType st, RailType railtype, Ro const DrawTileSeqStruct *dtss; foreach_draw_tile_seq(dtss, t->seq) { Point pt = RemapCoords(dtss->delta_x, dtss->delta_y, dtss->delta_z); - DrawSprite(dtss->image + rti->total_offset, pal, x + pt.x, y + pt.y); + DrawSprite(dtss->image + total_offset, pal, x + pt.x, y + pt.y); } } |