equal
deleted
inserted
replaced
3 /** @file rail_map.h Hides the direct accesses to the map array with map accessors */ |
3 /** @file rail_map.h Hides the direct accesses to the map array with map accessors */ |
4 |
4 |
5 #ifndef RAIL_MAP_H |
5 #ifndef RAIL_MAP_H |
6 #define RAIL_MAP_H |
6 #define RAIL_MAP_H |
7 |
7 |
8 #include "direction.h" |
8 #include "rail_type.h" |
9 #include "rail.h" |
9 #include "signal_func.h" |
10 #include "tile.h" |
10 #include "direction_func.h" |
|
11 #include "track_func.h" |
|
12 #include "tile_map.h" |
11 |
13 |
12 |
14 |
13 /** Different types of Rail-related tiles */ |
15 /** Different types of Rail-related tiles */ |
14 enum RailTileType { |
16 enum RailTileType { |
15 RAIL_TILE_NORMAL = 0, ///< Normal rail tile without signals |
17 RAIL_TILE_NORMAL = 0, ///< Normal rail tile without signals |
369 { |
371 { |
370 assert(IsValidTrackdir(trackdir)); |
372 assert(IsValidTrackdir(trackdir)); |
371 assert(HasSignalOnTrack(tile, TrackdirToTrack(trackdir))); |
373 assert(HasSignalOnTrack(tile, TrackdirToTrack(trackdir))); |
372 return GetSignalStates(tile) & SignalAlongTrackdir(trackdir) ? |
374 return GetSignalStates(tile) & SignalAlongTrackdir(trackdir) ? |
373 SIGNAL_STATE_GREEN : SIGNAL_STATE_RED; |
375 SIGNAL_STATE_GREEN : SIGNAL_STATE_RED; |
|
376 } |
|
377 |
|
378 /** |
|
379 * Sets the state of the signal along the given trackdir. |
|
380 */ |
|
381 static inline void SetSignalStateByTrackdir(TileIndex tile, Trackdir trackdir, SignalState state) |
|
382 { |
|
383 if (state == SIGNAL_STATE_GREEN) { // set 1 |
|
384 SetSignalStates(tile, GetSignalStates(tile) | SignalAlongTrackdir(trackdir)); |
|
385 } else { |
|
386 SetSignalStates(tile, GetSignalStates(tile) & ~SignalAlongTrackdir(trackdir)); |
|
387 } |
374 } |
388 } |
375 |
389 |
376 |
390 |
377 /** |
391 /** |
378 * Return the rail type of tile, or INVALID_RAILTYPE if this is no rail tile. |
392 * Return the rail type of tile, or INVALID_RAILTYPE if this is no rail tile. |