src/rail_map.h
branchNewGRF_ports
changeset 6872 1c4a4a609f85
parent 6871 5a9dc001e1ad
child 6877 889301acc299
--- a/src/rail_map.h	Mon Dec 03 23:39:38 2007 +0000
+++ b/src/rail_map.h	Tue Jan 22 21:00:30 2008 +0000
@@ -5,9 +5,11 @@
 #ifndef RAIL_MAP_H
 #define RAIL_MAP_H
 
-#include "direction.h"
-#include "rail.h"
-#include "tile.h"
+#include "rail_type.h"
+#include "signal_func.h"
+#include "direction_func.h"
+#include "track_func.h"
+#include "tile_map.h"
 
 
 /** Different types of Rail-related tiles */
@@ -373,6 +375,18 @@
 		SIGNAL_STATE_GREEN : SIGNAL_STATE_RED;
 }
 
+/**
+ * Sets the state of the signal along the given trackdir.
+ */
+static inline void SetSignalStateByTrackdir(TileIndex tile, Trackdir trackdir, SignalState state)
+{
+	if (state == SIGNAL_STATE_GREEN) { // set 1
+		SetSignalStates(tile, GetSignalStates(tile) | SignalAlongTrackdir(trackdir));
+	} else {
+		SetSignalStates(tile, GetSignalStates(tile) & ~SignalAlongTrackdir(trackdir));
+	}
+}
+
 
 /**
  * Return the rail type of tile, or INVALID_RAILTYPE if this is no rail tile.