(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.
authorpeter1138
Tue, 11 Apr 2006 10:45:06 +0000
changeset 3503 425903b204fa
parent 3502 d41ccd2fb5c5
child 3504 546b53897c01
(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.
rail.h
rail_cmd.c
railtypes.h
station_cmd.c
waypoint.c
--- a/rail.h	Tue Apr 11 10:19:50 2006 +0000
+++ b/rail.h	Tue Apr 11 10:45:06 2006 +0000
@@ -129,6 +129,11 @@
 	  * 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];
--- a/rail_cmd.c	Tue Apr 11 10:19:50 2006 +0000
+++ b/rail_cmd.c	Tue Apr 11 10:45:06 2006 +0000
@@ -1382,7 +1382,7 @@
 				 * 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);
 
--- a/railtypes.h	Tue Apr 11 10:19:50 2006 +0000
+++ b/railtypes.h	Tue Apr 11 10:45:06 2006 +0000
@@ -51,6 +51,9 @@
 
 		/* bridge offset */
 		0,
+
+		/* custom ground offset */
+		0,
 	},
 
 	/** Electrified railway */
@@ -100,7 +103,10 @@
 		0,
 
 		/* bridge offset */
-		0
+		0,
+
+		/* custom ground offset */
+		0,
 	},
 
 	/** Monorail */
@@ -147,6 +153,9 @@
 
 		/* bridge offset */
 		16,
+
+		/* custom ground offset */
+		1,
 	},
 
 	/** Maglev */
@@ -193,5 +202,8 @@
 
 		/* bridge offset */
 		24,
+
+		/* custom ground offset */
+		2,
 	},
 };
--- a/station_cmd.c	Tue Apr 11 10:19:50 2006 +0000
+++ b/station_cmd.c	Tue Apr 11 10:45:06 2006 +0000
@@ -1935,7 +1935,7 @@
 	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
--- a/waypoint.c	Tue Apr 11 10:19:50 2006 +0000
+++ b/waypoint.c	Tue Apr 11 10:45:06 2006 +0000
@@ -412,7 +412,7 @@
 	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);