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

pull/155/head
frosch 13 years ago
parent 29357ef65c
commit fb72295945

@ -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

@ -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;
}

@ -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:<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
*/
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:<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;
}
};

@ -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;

@ -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;

@ -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) */

Loading…
Cancel
Save