Changeset - r3503:f2c857b0cccc
[Not reviewed]
master
0 5 0
peter1138 - 19 years ago 2006-04-11 10:45:06
peter1138@openttd.org
(svn r4354) [Elrail][NewGRF] Codechange: Drawing of custom waypoints with custom ground sprites used the index of the rail type as an offset. With the introduction of elrails this offset is incorrect, so instead there is now a lookup table within the RailTypeInfo struct to explicitly list the offset.
5 files changed with 21 insertions and 4 deletions:
0 comments (0 inline, 0 general)
rail.h
Show inline comments
 
@@ -126,12 +126,17 @@ typedef struct RailtypeInfo {
 
	SpriteID total_offset;
 

	
 
	/**
 
	  * Bridge offset
 
	  */
 
	SpriteID bridge_offset;
 

	
 
	/**
 
	 * Offset to add to ground sprite when drawing custom waypoints / stations
 
	 */
 
	byte custom_ground_offset;
 
} RailtypeInfo;
 

	
 
extern const RailtypeInfo _railtypes[RAILTYPE_END];
 

	
 
// these are the maximums used for updating signal blocks, and checking if a depot is in a pbs block
 
enum {
rail_cmd.c
Show inline comments
 
@@ -1379,13 +1379,13 @@ static void DrawTile_Track(TileInfo *ti)
 
				 * for station sprites. And in the drawing
 
				 * code, it is used to indicate that the sprite
 
				 * should be drawn in company colors, and it's
 
				 * up to the GRF file to decide that. */
 

	
 
				image = cust->ground_sprite;
 
				image += (image < _custom_sprites_base) ? rti->total_offset : GetRailType(ti->tile);
 
				image += (image < _custom_sprites_base) ? rti->total_offset : GetRailTypeInfo(GetRailType(ti->tile))->custom_ground_offset;
 

	
 
				DrawGroundSprite(image);
 

	
 
				if (GetRailType(ti->tile) == RAILTYPE_ELECTRIC) DrawCatenary(ti);
 

	
 
				foreach_draw_tile_seq(seq, cust->seq) {
railtypes.h
Show inline comments
 
@@ -48,12 +48,15 @@ const RailtypeInfo _railtypes[] = {
 

	
 
		/* main offset */
 
		0,
 

	
 
		/* bridge offset */
 
		0,
 

	
 
		/* custom ground offset */
 
		0,
 
	},
 

	
 
	/** Electrified railway */
 
	{ /* Main Sprites */
 
		{ SPR_RAIL_TRACK_Y, SPR_RAIL_TRACK_N_S, SPR_RAIL_TRACK_BASE, SPR_RAIL_SINGLE_Y, SPR_RAIL_SINGLE_X,
 
			SPR_RAIL_SINGLE_NORTH, SPR_RAIL_SINGLE_SOUTH, SPR_RAIL_SINGLE_EAST, SPR_RAIL_SINGLE_WEST,
 
@@ -97,13 +100,16 @@ const RailtypeInfo _railtypes[] = {
 
		1 << RAILTYPE_ELECTRIC | 1 << RAILTYPE_RAIL,
 

	
 
		/* main offset */
 
		0,
 

	
 
		/* bridge offset */
 
		0
 
		0,
 

	
 
		/* custom ground offset */
 
		0,
 
	},
 

	
 
	/** Monorail */
 
	{ /* Main Sprites */
 
		{ SPR_MONO_TRACK_Y, SPR_MONO_TRACK_N_S, SPR_MONO_TRACK_BASE, SPR_MONO_SINGLE_Y, SPR_MONO_SINGLE_X,
 
			SPR_MONO_SINGLE_NORTH, SPR_MONO_SINGLE_SOUTH, SPR_MONO_SINGLE_EAST, SPR_MONO_SINGLE_WEST,
 
@@ -144,12 +150,15 @@ const RailtypeInfo _railtypes[] = {
 

	
 
		/* main offset */
 
		82,
 

	
 
		/* bridge offset */
 
		16,
 

	
 
		/* custom ground offset */
 
		1,
 
	},
 

	
 
	/** Maglev */
 
	{ /* Main sprites */
 
		{ SPR_MGLV_TRACK_Y, SPR_MGLV_TRACK_N_S, SPR_MGLV_TRACK_BASE, SPR_MGLV_SINGLE_Y, SPR_MGLV_SINGLE_X,
 
			SPR_MGLV_SINGLE_NORTH, SPR_MGLV_SINGLE_SOUTH, SPR_MGLV_SINGLE_EAST, SPR_MGLV_SINGLE_WEST,
 
@@ -190,8 +199,11 @@ const RailtypeInfo _railtypes[] = {
 

	
 
		/* main offset */
 
		164,
 

	
 
		/* bridge offset */
 
		24,
 

	
 
		/* custom ground offset */
 
		2,
 
	},
 
};
station_cmd.c
Show inline comments
 
@@ -1932,13 +1932,13 @@ static void DrawTile_Station(TileInfo *t
 
	if (t == NULL) t = &_station_display_datas[GetStationGfx(ti->tile)];
 

	
 
	image = t->ground_sprite;
 
	if (image & PALETTE_MODIFIER_COLOR) image |= image_or_modificator;
 

	
 
	// For custom sprites, there's no railtype-based pitching.
 
	offset = (image & SPRITE_MASK) < _custom_sprites_base ? rti->total_offset : railtype;
 
	offset = (image & SPRITE_MASK) < _custom_sprites_base ? rti->total_offset : GetRailTypeInfo(railtype)->custom_ground_offset;
 
	image += offset;
 

	
 
	// station_land array has been increased from 82 elements to 114
 
	// but this is something else. If AI builds station with 114 it looks all weird
 
	DrawGroundSprite(image);
 

	
waypoint.c
Show inline comments
 
@@ -409,13 +409,13 @@ void DrawWaypointSprite(int x, int y, in
 
	relocation = GetCustomStationRelocation(stat, NULL, 1);
 
	// emulate station tile - open with building
 
	// add 1 to get the other direction
 
	cust = &stat->renderdata[2];
 

	
 
	img = cust->ground_sprite;
 
	img += (img < _custom_sprites_base) ? rti->total_offset : railtype;
 
	img += (img < _custom_sprites_base) ? rti->total_offset : GetRailTypeInfo(railtype)->custom_ground_offset;
 

	
 
	if (img & PALETTE_MODIFIER_COLOR) img = (img & SPRITE_MASK);
 
	DrawSprite(img, x, y);
 

	
 
	foreach_draw_tile_seq(seq, cust->seq) {
 
		Point pt = RemapCoords(seq->delta_x, seq->delta_y, seq->delta_z);
0 comments (0 inline, 0 general)