34 RAIL_BIT_RIGHT = 32, // 5 |
34 RAIL_BIT_RIGHT = 32, // 5 |
35 RAIL_BIT_MASK = 0x3F, |
35 RAIL_BIT_MASK = 0x3F, |
36 |
36 |
37 RAIL_DEPOT_TRACK_MASK = 1, |
37 RAIL_DEPOT_TRACK_MASK = 1, |
38 RAIL_DEPOT_DIR = 3, |
38 RAIL_DEPOT_DIR = 3, |
39 RAIL_DEPOT_UNUSED_BITS = 0x3C, |
|
40 |
39 |
41 RAIL_TYPE_WAYPOINT = 0xC4, |
40 RAIL_TYPE_WAYPOINT = 0xC4, |
42 RAIL_WAYPOINT_TRACK_MASK = 1, |
41 RAIL_WAYPOINT_TRACK_MASK = 1, |
43 RAIL_WAYPOINT_UNUSED_BITS = 0x3E, |
|
44 |
42 |
45 RAIL_SUBTYPE_MASK = 0x3C, |
43 RAIL_SUBTYPE_MASK = 0x3C, |
46 RAIL_SUBTYPE_DEPOT = 0x00, |
44 RAIL_SUBTYPE_DEPOT = 0x00, |
47 RAIL_SUBTYPE_WAYPOINT = 0x04 |
45 RAIL_SUBTYPE_WAYPOINT = 0x04 |
48 }; |
46 }; |
49 |
47 |
50 #define IS_RAIL_DEPOT(x) (((x) & (RAIL_TYPE_DEPOT|RAIL_DEPOT_UNUSED_BITS)) == RAIL_TYPE_DEPOT) |
48 static inline bool IsRailDepot(byte m5) |
51 #define IS_RAIL_WAYPOINT(x) (((x) & (RAIL_TYPE_WAYPOINT|RAIL_WAYPOINT_UNUSED_BITS)) == RAIL_TYPE_WAYPOINT) |
49 { |
|
50 return |
|
51 (m5 & RAIL_TYPE_MASK) == RAIL_TYPE_DEPOT && |
|
52 (m5 & RAIL_SUBTYPE_MASK) == RAIL_SUBTYPE_DEPOT; |
|
53 } |
|
54 |
|
55 static inline bool IsRailWaypoint(byte m5) |
|
56 { |
|
57 return |
|
58 (m5 & RAIL_TYPE_MASK) == RAIL_TYPE_DEPOT && |
|
59 (m5 & RAIL_SUBTYPE_MASK) == RAIL_SUBTYPE_WAYPOINT; |
|
60 } |
52 |
61 |
53 /* Format of rail map5 byte. |
62 /* Format of rail map5 byte. |
54 * 00 abcdef => Normal rail |
63 * 00 abcdef => Normal rail |
55 * 01 abcdef => Rail with signals |
64 * 01 abcdef => Rail with signals |
56 * 10 ?????? => Unused |
65 * 10 ?????? => Unused |
798 static int32 RemoveTrainWaypoint(uint tile, uint32 flags, bool justremove) |
807 static int32 RemoveTrainWaypoint(uint tile, uint32 flags, bool justremove) |
799 { |
808 { |
800 Waypoint *cp; |
809 Waypoint *cp; |
801 |
810 |
802 // make sure it's a waypoint |
811 // make sure it's a waypoint |
803 if (!IsTileType(tile, MP_RAILWAY) || !IS_RAIL_WAYPOINT(_map5[tile])) |
812 if (!IsTileType(tile, MP_RAILWAY) || !IsRailWaypoint(_map5[tile])) |
804 return CMD_ERROR; |
813 return CMD_ERROR; |
805 |
814 |
806 if (!CheckTileOwnership(tile) && !(_current_player==17)) |
815 if (!CheckTileOwnership(tile) && !(_current_player==17)) |
807 return CMD_ERROR; |
816 return CMD_ERROR; |
808 |
817 |
1619 if (!(m5 & (RAIL_TYPE_MASK&~RAIL_TYPE_SPECIAL))) |
1628 if (!(m5 & (RAIL_TYPE_MASK&~RAIL_TYPE_SPECIAL))) |
1620 return; |
1629 return; |
1621 |
1630 |
1622 if (ti->tileh != 0) { DrawFoundation(ti, ti->tileh); } |
1631 if (ti->tileh != 0) { DrawFoundation(ti, ti->tileh); } |
1623 |
1632 |
1624 if (!IS_RAIL_DEPOT(m5) && IS_RAIL_WAYPOINT(m5) && _map3_lo[ti->tile]&16) { |
1633 if (IsRailWaypoint(m5) && _map3_lo[ti->tile] & 16) { |
1625 // look for customization |
1634 // look for customization |
1626 StationSpec *stat = GetCustomStation(STAT_CLASS_WAYP, _map3_hi[ti->tile]); |
1635 StationSpec *stat = GetCustomStation(STAT_CLASS_WAYP, _map3_hi[ti->tile]); |
1627 |
1636 |
1628 if (stat) { |
1637 if (stat) { |
1629 DrawTileSeqStruct const *seq; |
1638 DrawTileSeqStruct const *seq; |
2161 return ret; |
2170 return ret; |
2162 } |
2171 } |
2163 |
2172 |
2164 static void ClickTile_Track(uint tile) |
2173 static void ClickTile_Track(uint tile) |
2165 { |
2174 { |
2166 if (IS_RAIL_DEPOT(_map5[tile])) |
2175 if (IsRailDepot(_map5[tile])) |
2167 ShowTrainDepotWindow(tile); |
2176 ShowTrainDepotWindow(tile); |
2168 else if (IS_RAIL_WAYPOINT(_map5[tile])) |
2177 else if (IsRailWaypoint(_map5[tile])) |
2169 ShowRenameWaypointWindow(&_waypoints[GetWaypointByTile(tile)]); |
2178 ShowRenameWaypointWindow(&_waypoints[GetWaypointByTile(tile)]); |
2170 |
2179 |
2171 } |
2180 } |
2172 |
2181 |
2173 static void GetTileDesc_Track(uint tile, TileDesc *td) |
2182 static void GetTileDesc_Track(uint tile, TileDesc *td) |