(svn r4280) -Codechange: Add and make use of map accessors concerning railway waypoints
authorcelestar
Wed, 05 Apr 2006 05:22:42 +0000
changeset 3448 0bee5179ae86
parent 3447 d136931464f7
child 3449 677afbebac23
(svn r4280) -Codechange: Add and make use of map accessors concerning railway waypoints
rail_map.h
waypoint.c
--- a/rail_map.h	Tue Apr 04 21:35:13 2006 +0000
+++ b/rail_map.h	Wed Apr 05 05:22:42 2006 +0000
@@ -124,12 +124,26 @@
 	return (DiagDirection)GB(_m[t].m5, 0, 2);
 }
 
+static inline TrackBits GetRailWaypointTrack(TileIndex t)
+{
+	return HASBIT(_m[t].m5, 0) ? TRACK_Y : TRACK_X;
+}
 
 static inline TrackBits GetRailWaypointBits(TileIndex t)
 {
 	return _m[t].m5 & 1 ? TRACK_BIT_Y : TRACK_BIT_X;
 }
 
+static inline void SetCustomWaypointSprite(TileIndex t)
+{
+	SETBIT(_m[t].m3, 4);
+}
+
+static inline void ClearCustomWaypointSprite(TileIndex t)
+{
+	CLRBIT(_m[t].m3, 4);
+}
+
 
 typedef enum SignalType {
 	SIGTYPE_NORMAL  = 0, // normal signal
--- a/waypoint.c	Tue Apr 04 21:35:13 2006 +0000
+++ b/waypoint.c	Wed Apr 05 05:22:42 2006 +0000
@@ -221,13 +221,13 @@
 			spec = GetCustomStation(STAT_CLASS_WAYP, GB(p1, 0, 8));
 
 		if (spec != NULL) {
-			SETBIT(_m[tile].m3, 4);
+			SetCustomWaypointSprite(tile);
 			wp->stat_id = GB(p1, 0, 8);
 			wp->grfid = spec->grfid;
 			wp->localidx = spec->localidx;
 		} else {
 			// Specified custom graphics do not exist, so use default.
-			CLRBIT(_m[tile].m3, 4);
+			ClearCustomWaypointSprite(tile);
 			wp->stat_id = 0;
 			wp->grfid = 0;
 			wp->localidx = 0;
@@ -293,8 +293,6 @@
 		return CMD_ERROR;
 
 	if (flags & DC_EXEC) {
-		Axis direction = _m[tile].m5 & RAIL_WAYPOINT_TRACK_MASK;
-
 		wp = GetWaypointByTile(tile);
 
 		wp->deleted = 30; // let it live for this many days before we do the actual deletion.
@@ -305,7 +303,7 @@
 			MarkTileDirtyByTile(tile);
 		} else {
 			DoClearSquare(tile);
-			SetSignalsOnBothDir(tile, direction == AXIS_X ? TRACK_X : TRACK_Y);
+			SetSignalsOnBothDir(tile, GetRailWaypointTrack(tile));
 		}
 	}