changeset 7307:cf51670909bb draft

(svn r10659) -Codechange: updated documentation around RAIL_GROUND_FENCE_VERT[12] (frosch) -Codechange: added documentation and SPR_ enums for track fences (frosch)
author truelight <truelight@openttd.org>
date Mon, 23 Jul 2007 16:08:58 +0000
parents c6e2fc0bbd37
children 45a7fdc97647
files src/rail_cmd.cpp src/rail_map.h src/table/sprites.h
diffstat 3 files changed, 36 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -1225,16 +1225,16 @@
 
 static void DrawTrackFence_NW(const TileInfo *ti)
 {
-	SpriteID image = 0x515;
-	if (ti->tileh != SLOPE_FLAT) image = (ti->tileh & SLOPE_S) ? 0x519 : 0x51B;
+	SpriteID image = SPR_TRACK_FENCE_FLAT_X;
+	if (ti->tileh != SLOPE_FLAT) image = (ti->tileh & SLOPE_S) ? SPR_TRACK_FENCE_SLOPE_SW : SPR_TRACK_FENCE_SLOPE_NE;
 	AddSortableSpriteToDraw(image, _drawtile_track_palette,
 		ti->x, ti->y + 1, 16, 1, 4, ti->z);
 }
 
 static void DrawTrackFence_SE(const TileInfo *ti)
 {
-	SpriteID image = 0x515;
-	if (ti->tileh != SLOPE_FLAT) image = (ti->tileh & SLOPE_S) ? 0x519 : 0x51B;
+	SpriteID image = SPR_TRACK_FENCE_FLAT_X;
+	if (ti->tileh != SLOPE_FLAT) image = (ti->tileh & SLOPE_S) ? SPR_TRACK_FENCE_SLOPE_SW : SPR_TRACK_FENCE_SLOPE_NE;
 	AddSortableSpriteToDraw(image, _drawtile_track_palette,
 		ti->x, ti->y + TILE_SIZE - 1, 16, 1, 4, ti->z);
 }
@@ -1247,16 +1247,16 @@
 
 static void DrawTrackFence_NE(const TileInfo *ti)
 {
-	SpriteID image = 0x516;
-	if (ti->tileh != SLOPE_FLAT) image = (ti->tileh & SLOPE_S) ? 0x51A : 0x51C;
+	SpriteID image = SPR_TRACK_FENCE_FLAT_Y;
+	if (ti->tileh != SLOPE_FLAT) image = (ti->tileh & SLOPE_S) ? SPR_TRACK_FENCE_SLOPE_SE : SPR_TRACK_FENCE_SLOPE_NW;
 	AddSortableSpriteToDraw(image, _drawtile_track_palette,
 		ti->x + 1, ti->y, 1, 16, 4, ti->z);
 }
 
 static void DrawTrackFence_SW(const TileInfo *ti)
 {
-	SpriteID image = 0x516;
-	if (ti->tileh != SLOPE_FLAT) image = (ti->tileh & SLOPE_S) ? 0x51A : 0x51C;
+	SpriteID image = SPR_TRACK_FENCE_FLAT_Y;
+	if (ti->tileh != SLOPE_FLAT) image = (ti->tileh & SLOPE_S) ? SPR_TRACK_FENCE_SLOPE_SE : SPR_TRACK_FENCE_SLOPE_NW;
 	AddSortableSpriteToDraw(image, _drawtile_track_palette,
 		ti->x + TILE_SIZE - 1, ti->y, 1, 16, 4, ti->z);
 }
@@ -1267,35 +1267,47 @@
 	DrawTrackFence_SW(ti);
 }
 
+/**
+ * Draw fence at eastern side of track.
+ */
 static void DrawTrackFence_NS_1(const TileInfo *ti)
 {
 	int z = ti->z;
 	if (ti->tileh & SLOPE_W) z += TILE_HEIGHT;
-	AddSortableSpriteToDraw(0x517, _drawtile_track_palette,
+	AddSortableSpriteToDraw(SPR_TRACK_FENCE_FLAT_VERT, _drawtile_track_palette,
 		ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, 4, z);
 }
 
+/**
+ * Draw fence at western side of track.
+ */
 static void DrawTrackFence_NS_2(const TileInfo *ti)
 {
 	int z = ti->z;
 	if (ti->tileh & SLOPE_E) z += TILE_HEIGHT;
-	AddSortableSpriteToDraw(0x517, _drawtile_track_palette,
+	AddSortableSpriteToDraw(SPR_TRACK_FENCE_FLAT_VERT, _drawtile_track_palette,
 		ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, 4, z);
 }
 
+/**
+ * Draw fence at southern side of track.
+ */
 static void DrawTrackFence_WE_1(const TileInfo *ti)
 {
 	int z = ti->z;
 	if (ti->tileh & SLOPE_N) z += TILE_HEIGHT;
-	AddSortableSpriteToDraw(0x518, _drawtile_track_palette,
+	AddSortableSpriteToDraw(SPR_TRACK_FENCE_FLAT_HORZ, _drawtile_track_palette,
 		ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, 4, z);
 }
 
+/**
+ * Draw fence at northern side of track.
+ */
 static void DrawTrackFence_WE_2(const TileInfo *ti)
 {
 	int z = ti->z;
 	if (ti->tileh & SLOPE_S) z += TILE_HEIGHT;
-	AddSortableSpriteToDraw(0x518, _drawtile_track_palette,
+	AddSortableSpriteToDraw(SPR_TRACK_FENCE_FLAT_HORZ, _drawtile_track_palette,
 		ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, 4, z);
 }
 
--- a/src/rail_map.h
+++ b/src/rail_map.h
@@ -389,8 +389,8 @@
 	RAIL_GROUND_FENCE_NE     =  5, ///< Grass with a fence at the NE edge
 	RAIL_GROUND_FENCE_SW     =  6, ///< Grass with a fence at the SW edge
 	RAIL_GROUND_FENCE_NESW   =  7, ///< Grass with a fence at the NE and SW edges
-	RAIL_GROUND_FENCE_VERT1  =  8, ///< Grass with a fence at the western side
-	RAIL_GROUND_FENCE_VERT2  =  9, ///< Grass with a fence at the eastern side
+	RAIL_GROUND_FENCE_VERT1  =  8, ///< Grass with a fence at the eastern side
+	RAIL_GROUND_FENCE_VERT2  =  9, ///< Grass with a fence at the western side
 	RAIL_GROUND_FENCE_HORIZ1 = 10, ///< Grass with a fence at the southern side
 	RAIL_GROUND_FENCE_HORIZ2 = 11, ///< Grass with a fence at the northern side
 	RAIL_GROUND_ICE_DESERT   = 12, ///< Icy or sandy
--- a/src/table/sprites.h
+++ b/src/table/sprites.h
@@ -303,6 +303,16 @@
 	OFFSET_TILEH_13             = 19,
 	OFFSET_TILEH_14             = 16,
 
+	/* Track fences */
+	SPR_TRACK_FENCE_FLAT_X    = 1301,
+	SPR_TRACK_FENCE_FLAT_Y    = 1302,
+	SPR_TRACK_FENCE_FLAT_VERT = 1303,
+	SPR_TRACK_FENCE_FLAT_HORZ = 1304,
+	SPR_TRACK_FENCE_SLOPE_SW  = 1305,
+	SPR_TRACK_FENCE_SLOPE_SE  = 1306,
+	SPR_TRACK_FENCE_SLOPE_NE  = 1307,
+	SPR_TRACK_FENCE_SLOPE_NW  = 1308,
+
 	/* Elrail stuff */
 	/* Wires. First identifier is the direction of the track, second is the required placement of the pylon.
 	 * "short" denotes a wire that requires a pylon on each end. Third identifier is the direction of the slope