1
0
Fork 0

(svn r22436) -Fix (r18969): Apply railtype property 12 (station graphics) also to station groundsprites from action 1.

release/1.2
frosch 2011-05-08 15:58:59 +00:00
parent 28067c21d5
commit 76c7cbff70
6 changed files with 29 additions and 39 deletions

View File

@ -3279,7 +3279,7 @@ static ChangeInfoResult RailTypeChangeInfo(uint id, int numinfo, int prop, ByteR
break; break;
case 0x12: // Station graphic case 0x12: // Station graphic
rti->total_offset = Clamp(buf->ReadByte(), 0, 2) * 82; rti->fallback_railtype = Clamp(buf->ReadByte(), 0, 2);
break; break;
case 0x13: // Construction cost factor case 0x13: // Construction cost factor

View File

@ -768,14 +768,14 @@ bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID
PaletteID pal = sprites->ground.pal; PaletteID pal = sprites->ground.pal;
if (HasBit(image, SPRITE_MODIFIER_CUSTOM_SPRITE)) { if (HasBit(image, SPRITE_MODIFIER_CUSTOM_SPRITE)) {
image += GetCustomStationGroundRelocation(statspec, NULL, INVALID_TILE); image += GetCustomStationGroundRelocation(statspec, NULL, INVALID_TILE);
image += rti->custom_ground_offset; image += rti->fallback_railtype;
} else { } else {
image += rti->total_offset; image += rti->GetRailtypeSpriteOffset();
} }
DrawSprite(image, GroundSpritePaletteTransform(image, pal, palette), x, y); 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; return true;
} }

View File

@ -162,25 +162,15 @@ struct RailtypeInfo {
/** bitmask to the OTHER railtypes on which an engine of THIS railtype can physically travel */ /** bitmask to the OTHER railtypes on which an engine of THIS railtype can physically travel */
RailTypes compatible_railtypes; RailTypes compatible_railtypes;
/**
* Offset between the current railtype and normal rail. This means that:<p>
* 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<p>
* 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 * Bridge offset
*/ */
SpriteID 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 * Multiplier for curve maximum speed advantage
@ -251,6 +241,18 @@ struct RailtypeInfo {
{ {
return this->group[RTSG_GROUND] != NULL; return this->group[RTSG_GROUND] != NULL;
} }
/**
* Offset between the current railtype and normal rail. This means that:<p>
* 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<p>
* 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;
}
}; };

View File

@ -2247,7 +2247,7 @@ static void DrawTile_Track(TileInfo *ti)
image = SPR_FLAT_GRASS_TILE; image = SPR_FLAT_GRASS_TILE;
} else { } else {
image = dts->ground.sprite; 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 /* adjust ground tile for desert
@ -2286,7 +2286,7 @@ static void DrawTile_Track(TileInfo *ti)
} }
int depot_sprite = GetCustomRailSprite(rti, ti->tile, RTSG_DEPOT); 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 { } else {
/* PBS debugging, draw reserved tracks darker */ /* PBS debugging, draw reserved tracks darker */
if (_game_mode != GM_MENU && _settings_client.gui.show_track_reservation && HasDepotReservation(ti->tile)) { 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); 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 DrawTileSprites *dts = &_depot_gfx_table[dir];
const RailtypeInfo *rti = GetRailTypeInfo(railtype); const RailtypeInfo *rti = GetRailTypeInfo(railtype);
SpriteID image = rti->UsesOverlay() ? SPR_FLAT_GRASS_TILE : dts->ground.sprite; SpriteID image = rti->UsesOverlay() ? SPR_FLAT_GRASS_TILE : dts->ground.sprite;
uint32 offset = rti->total_offset; uint32 offset = rti->GetRailtypeSpriteOffset();
x += 33; x += 33;
y += 17; y += 17;

View File

@ -2507,8 +2507,8 @@ static void DrawTile_Station(TileInfo *ti)
if (HasStationRail(ti->tile)) { if (HasStationRail(ti->tile)) {
rti = GetRailTypeInfo(GetRailType(ti->tile)); rti = GetRailTypeInfo(GetRailType(ti->tile));
roadtypes = ROADTYPES_NONE; roadtypes = ROADTYPES_NONE;
total_offset = rti->total_offset; total_offset = rti->GetRailtypeSpriteOffset();
custom_ground_offset = rti->custom_ground_offset; custom_ground_offset = rti->fallback_railtype;
if (IsCustomStationSpecIndex(ti->tile)) { if (IsCustomStationSpecIndex(ti->tile)) {
/* look for customization */ /* look for customization */
@ -2713,7 +2713,7 @@ void StationPickerDrawSprite(int x, int y, StationType st, RailType railtype, Ro
if (railtype != INVALID_RAILTYPE) { if (railtype != INVALID_RAILTYPE) {
rti = GetRailTypeInfo(railtype); rti = GetRailTypeInfo(railtype);
total_offset = rti->total_offset; total_offset = rti->GetRailtypeSpriteOffset();
} }
SpriteID img = t->ground.sprite; SpriteID img = t->ground.sprite;

View File

@ -65,13 +65,10 @@ static const RailtypeInfo _original_railtypes[] = {
/* Compatible railtypes */ /* Compatible railtypes */
RAILTYPES_RAIL | RAILTYPES_ELECTRIC, RAILTYPES_RAIL | RAILTYPES_ELECTRIC,
/* main offset */
0,
/* bridge offset */ /* bridge offset */
0, 0,
/* custom ground offset */ /* fallback_railtype */
0, 0,
/* curve speed advantage (multiplier) */ /* curve speed advantage (multiplier) */
@ -160,13 +157,10 @@ static const RailtypeInfo _original_railtypes[] = {
/* Compatible railtypes */ /* Compatible railtypes */
RAILTYPES_ELECTRIC | RAILTYPES_RAIL, RAILTYPES_ELECTRIC | RAILTYPES_RAIL,
/* main offset */
0,
/* bridge offset */ /* bridge offset */
0, 0,
/* custom ground offset */ /* fallback_railtype */
0, 0,
/* curve speed advantage (multiplier) */ /* curve speed advantage (multiplier) */
@ -251,13 +245,10 @@ static const RailtypeInfo _original_railtypes[] = {
/* Compatible Railtypes */ /* Compatible Railtypes */
RAILTYPES_MONO, RAILTYPES_MONO,
/* main offset */
82,
/* bridge offset */ /* bridge offset */
16, 16,
/* custom ground offset */ /* fallback_railtype */
1, 1,
/* curve speed advantage (multiplier) */ /* curve speed advantage (multiplier) */
@ -342,13 +333,10 @@ static const RailtypeInfo _original_railtypes[] = {
/* Compatible Railtypes */ /* Compatible Railtypes */
RAILTYPES_MAGLEV, RAILTYPES_MAGLEV,
/* main offset */
164,
/* bridge offset */ /* bridge offset */
24, 24,
/* custom ground offset */ /* fallback_railtype */
2, 2,
/* curve speed advantage (multiplier) */ /* curve speed advantage (multiplier) */