From 76c7cbff70e2cd4ea86a58f3efe2eed1839e5986 Mon Sep 17 00:00:00 2001 From: frosch Date: Sun, 8 May 2011 15:58:59 +0000 Subject: (svn r22436) -Fix (r18969): Apply railtype property 12 (station graphics) also to station groundsprites from action 1. --- src/newgrf.cpp | 2 +- src/newgrf_station.cpp | 6 +++--- src/rail.h | 26 ++++++++++++++------------ src/rail_cmd.cpp | 8 ++++---- src/station_cmd.cpp | 6 +++--- src/table/railtypes.h | 20 ++++---------------- 6 files changed, 29 insertions(+), 39 deletions(-) (limited to 'src') diff --git a/src/newgrf.cpp b/src/newgrf.cpp index f5e67aa1e..dcd34de0a 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -3279,7 +3279,7 @@ static ChangeInfoResult RailTypeChangeInfo(uint id, int numinfo, int prop, ByteR break; case 0x12: // Station graphic - rti->total_offset = Clamp(buf->ReadByte(), 0, 2) * 82; + rti->fallback_railtype = Clamp(buf->ReadByte(), 0, 2); break; case 0x13: // Construction cost factor diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp index 06216df69..fd7a730dd 100644 --- a/src/newgrf_station.cpp +++ b/src/newgrf_station.cpp @@ -768,14 +768,14 @@ bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID PaletteID pal = sprites->ground.pal; if (HasBit(image, SPRITE_MODIFIER_CUSTOM_SPRITE)) { image += GetCustomStationGroundRelocation(statspec, NULL, INVALID_TILE); - image += rti->custom_ground_offset; + image += rti->fallback_railtype; } else { - image += rti->total_offset; + image += rti->GetRailtypeSpriteOffset(); } DrawSprite(image, GroundSpritePaletteTransform(image, pal, palette), x, y); - DrawRailTileSeqInGUI(x, y, sprites, rti->total_offset, relocation, palette); + DrawRailTileSeqInGUI(x, y, sprites, rti->GetRailtypeSpriteOffset(), relocation, palette); return true; } diff --git a/src/rail.h b/src/rail.h index 586b85324..067db7957 100644 --- a/src/rail.h +++ b/src/rail.h @@ -162,25 +162,15 @@ struct RailtypeInfo { /** bitmask to the OTHER railtypes on which an engine of THIS railtype can physically travel */ RailTypes compatible_railtypes; - /** - * Offset between the current railtype and normal rail. This means that:

- * 1) All the sprites in a railset MUST be in the same order. This order - * is determined by normal rail. Check sprites 1005 and following for this order

- * 2) The position where the railtype is loaded must always be the same, otherwise - * the offset will fail. - * @note: Something more flexible might be desirable in the future. - */ - SpriteID total_offset; - /** * Bridge offset */ SpriteID bridge_offset; /** - * Offset to add to ground sprite when drawing custom waypoints / stations + * Original railtype number to use when drawing non-newgrf railtypes, or when drawing stations. */ - byte custom_ground_offset; + byte fallback_railtype; /** * Multiplier for curve maximum speed advantage @@ -251,6 +241,18 @@ struct RailtypeInfo { { return this->group[RTSG_GROUND] != NULL; } + + /** + * Offset between the current railtype and normal rail. This means that:

+ * 1) All the sprites in a railset MUST be in the same order. This order + * is determined by normal rail. Check sprites 1005 and following for this order

+ * 2) The position where the railtype is loaded must always be the same, otherwise + * the offset will fail. + */ + inline uint GetRailtypeSpriteOffset() const + { + return 82 * this->fallback_railtype; + } }; diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index 990831690..cc5162d57 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -2247,7 +2247,7 @@ static void DrawTile_Track(TileInfo *ti) image = SPR_FLAT_GRASS_TILE; } else { image = dts->ground.sprite; - if (image != SPR_FLAT_GRASS_TILE) image += rti->total_offset; + if (image != SPR_FLAT_GRASS_TILE) image += rti->GetRailtypeSpriteOffset(); } /* adjust ground tile for desert @@ -2286,7 +2286,7 @@ static void DrawTile_Track(TileInfo *ti) } int depot_sprite = GetCustomRailSprite(rti, ti->tile, RTSG_DEPOT); - relocation = depot_sprite != 0 ? depot_sprite - SPR_RAIL_DEPOT_SE_1 : rti->total_offset; + relocation = depot_sprite != 0 ? depot_sprite - SPR_RAIL_DEPOT_SE_1 : rti->GetRailtypeSpriteOffset(); } else { /* PBS debugging, draw reserved tracks darker */ if (_game_mode != GM_MENU && _settings_client.gui.show_track_reservation && HasDepotReservation(ti->tile)) { @@ -2299,7 +2299,7 @@ static void DrawTile_Track(TileInfo *ti) } } - relocation = rti->total_offset; + relocation = rti->GetRailtypeSpriteOffset(); } if (HasCatenaryDrawn(GetRailType(ti->tile))) DrawCatenary(ti); @@ -2314,7 +2314,7 @@ void DrawTrainDepotSprite(int x, int y, int dir, RailType railtype) const DrawTileSprites *dts = &_depot_gfx_table[dir]; const RailtypeInfo *rti = GetRailTypeInfo(railtype); SpriteID image = rti->UsesOverlay() ? SPR_FLAT_GRASS_TILE : dts->ground.sprite; - uint32 offset = rti->total_offset; + uint32 offset = rti->GetRailtypeSpriteOffset(); x += 33; y += 17; diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 7edaf7928..d8a4a553a 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -2507,8 +2507,8 @@ static void DrawTile_Station(TileInfo *ti) if (HasStationRail(ti->tile)) { rti = GetRailTypeInfo(GetRailType(ti->tile)); roadtypes = ROADTYPES_NONE; - total_offset = rti->total_offset; - custom_ground_offset = rti->custom_ground_offset; + total_offset = rti->GetRailtypeSpriteOffset(); + custom_ground_offset = rti->fallback_railtype; if (IsCustomStationSpecIndex(ti->tile)) { /* look for customization */ @@ -2713,7 +2713,7 @@ void StationPickerDrawSprite(int x, int y, StationType st, RailType railtype, Ro if (railtype != INVALID_RAILTYPE) { rti = GetRailTypeInfo(railtype); - total_offset = rti->total_offset; + total_offset = rti->GetRailtypeSpriteOffset(); } SpriteID img = t->ground.sprite; diff --git a/src/table/railtypes.h b/src/table/railtypes.h index e8a1d51e5..191714028 100644 --- a/src/table/railtypes.h +++ b/src/table/railtypes.h @@ -65,13 +65,10 @@ static const RailtypeInfo _original_railtypes[] = { /* Compatible railtypes */ RAILTYPES_RAIL | RAILTYPES_ELECTRIC, - /* main offset */ - 0, - /* bridge offset */ 0, - /* custom ground offset */ + /* fallback_railtype */ 0, /* curve speed advantage (multiplier) */ @@ -160,13 +157,10 @@ static const RailtypeInfo _original_railtypes[] = { /* Compatible railtypes */ RAILTYPES_ELECTRIC | RAILTYPES_RAIL, - /* main offset */ - 0, - /* bridge offset */ 0, - /* custom ground offset */ + /* fallback_railtype */ 0, /* curve speed advantage (multiplier) */ @@ -251,13 +245,10 @@ static const RailtypeInfo _original_railtypes[] = { /* Compatible Railtypes */ RAILTYPES_MONO, - /* main offset */ - 82, - /* bridge offset */ 16, - /* custom ground offset */ + /* fallback_railtype */ 1, /* curve speed advantage (multiplier) */ @@ -342,13 +333,10 @@ static const RailtypeInfo _original_railtypes[] = { /* Compatible Railtypes */ RAILTYPES_MAGLEV, - /* main offset */ - 164, - /* bridge offset */ 24, - /* custom ground offset */ + /* fallback_railtype */ 2, /* curve speed advantage (multiplier) */ -- cgit v1.2.3-54-g00ecf