Changeset - r17654:f28c4b7b0c47
[Not reviewed]
master
0 6 0
frosch - 13 years ago 2011-05-08 15:58:59
frosch@openttd.org
(svn r22436) -Fix (r18969): Apply railtype property 12 (station graphics) also to station groundsprites from action 1.
6 files changed with 29 insertions and 39 deletions:
0 comments (0 inline, 0 general)
src/newgrf.cpp
Show inline comments
 
@@ -3279,7 +3279,7 @@ static ChangeInfoResult RailTypeChangeIn
 
				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
src/newgrf_station.cpp
Show inline comments
 
@@ -768,14 +768,14 @@ bool DrawStationTile(int x, int y, RailT
 
	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;
 
}
src/rail.h
Show inline comments
 
@@ -163,24 +163,14 @@ struct RailtypeInfo {
 
	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;
 
	}
 
};
 

	
 

	
src/rail_cmd.cpp
Show inline comments
 
@@ -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, 
 
	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;
src/station_cmd.cpp
Show inline comments
 
@@ -2507,8 +2507,8 @@ static void DrawTile_Station(TileInfo *t
 
	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 
 

	
 
	if (railtype != INVALID_RAILTYPE) {
 
		rti = GetRailTypeInfo(railtype);
 
		total_offset = rti->total_offset;
 
		total_offset = rti->GetRailtypeSpriteOffset();
 
	}
 

	
 
	SpriteID img = t->ground.sprite;
src/table/railtypes.h
Show inline comments
 
@@ -65,13 +65,10 @@ static const RailtypeInfo _original_rail
 
		/* 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_rail
 
		/* 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_rail
 
		/* 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_rail
 
		/* Compatible Railtypes */
 
		RAILTYPES_MAGLEV,
 

	
 
		/* main offset */
 
		164,
 

	
 
		/* bridge offset */
 
		24,
 

	
 
		/* custom ground offset */
 
		/* fallback_railtype */
 
		2,
 

	
 
		/* curve speed advantage (multiplier) */
0 comments (0 inline, 0 general)