changeset 3404:fa9eda1bda62 draft

(svn r4215) -Codechange: Renamed *RoadStation* functions to *RoadStop* and moved them to station_map.h to keep consistency
author celestar <celestar@openttd.org>
date Fri, 31 Mar 2006 19:10:54 +0000
parents 8969148e65ee
children 50a4b81137ed
files ai/trolly/trolly.c npf.c road_map.c roadveh_cmd.c station.h station_map.h vehicle.c
diffstat 7 files changed, 31 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/ai/trolly/trolly.c
+++ b/ai/trolly/trolly.c
@@ -617,7 +617,7 @@
 							if (AiNew_CheckVehicleStation(p, st)) {
 								// We did found a station that was good enough!
 								new_tile = st->xy;
-								direction = GetRoadStationDir(st->xy);
+								direction = GetRoadStopDir(st->xy);
 								break;
 							}
 						}
--- a/npf.c
+++ b/npf.c
@@ -459,7 +459,7 @@
 	if (IsTileType(tile, MP_RAILWAY) ||           /* Rail tile (also rail depot) */
 			IsTrainStationTile(tile) ||               /* Rail station tile */
 			IsTileDepotType(tile, TRANSPORT_ROAD) ||  /* Road depot tile */
-			IsRoadStationTile(tile) ||                /* Road station tile */
+			IsRoadStopTile(tile) ||                /* Road station tile */
 			IsTileDepotType(tile, TRANSPORT_WATER)) { /* Water depot tile */
 		return IsTileOwner(tile, owner); /* You need to own these tiles entirely to use them */
 	}
@@ -533,15 +533,15 @@
 		 * otherwise we wouldn't have got here. It is also facing us,
 		 * so we should skip it's body */
 		dst_tile = GetOtherTunnelEnd(src_tile);
-	} else if (type != TRANSPORT_WATER && (IsRoadStationTile(src_tile) || IsTileDepotType(src_tile, type))) {
+	} else if (type != TRANSPORT_WATER && (IsRoadStopTile(src_tile) || IsTileDepotType(src_tile, type))) {
 		/* This is a road station or a train or road depot. We can enter and exit
 		 * those from one side only. Trackdirs don't support that (yet), so we'll
 		 * do this here. */
 
 		DiagDirection exitdir;
 		/* Find out the exit direction first */
-		if (IsRoadStationTile(src_tile)) {
-			exitdir = GetRoadStationDir(src_tile);
+		if (IsRoadStopTile(src_tile)) {
+			exitdir = GetRoadStopDir(src_tile);
 		} else { /* Train or road depot */
 			exitdir = GetDepotDirection(src_tile, type);
 		}
@@ -597,11 +597,11 @@
 	}
 
 	/* Determine available tracks */
-	if (type != TRANSPORT_WATER && (IsRoadStationTile(dst_tile) || IsTileDepotType(dst_tile, type))){
+	if (type != TRANSPORT_WATER && (IsRoadStopTile(dst_tile) || IsTileDepotType(dst_tile, type))){
 		/* Road stations and road and train depots return 0 on GTTS, so we have to do this by hand... */
 		DiagDirection exitdir;
-		if (IsRoadStationTile(dst_tile)) {
-			exitdir = GetRoadStationDir(dst_tile);
+		if (IsRoadStopTile(dst_tile)) {
+			exitdir = GetRoadStopDir(dst_tile);
 		} else { /* Road or train depot */
 			exitdir = GetDepotDirection(dst_tile, type);
 		}
--- a/road_map.c
+++ b/road_map.c
@@ -7,6 +7,7 @@
 #include "road_map.h"
 #include "station.h"
 #include "tunnel_map.h"
+#include "station_map.h"
 
 
 RoadBits GetAnyRoadBits(TileIndex tile)
@@ -21,8 +22,8 @@
 			}
 
 		case MP_STATION:
-			if (!IsRoadStationTile(tile)) return 0;
-			return DiagDirToRoadBits(GetRoadStationDir(tile));
+			if (!IsRoadStopTile(tile)) return 0;
+			return DiagDirToRoadBits(GetRoadStopDir(tile));
 
 		case MP_TUNNELBRIDGE:
 			if (IsBridge(tile)) {
--- a/roadveh_cmd.c
+++ b/roadveh_cmd.c
@@ -1012,7 +1012,7 @@
 			/* Road depot */
 			bitmask |= _road_veh_fp_ax_or[GetRoadDepotDirection(tile)];
 		}
-	} else if (IsTileType(tile, MP_STATION) && IsRoadStationTile(tile)) {
+	} else if (IsTileType(tile, MP_STATION) && IsRoadStopTile(tile)) {
 		if (IsTileOwner(tile, v->owner)) {
 			/* Our station */
 			RoadStopType rstype = (v->cargo_type == CT_PASSENGERS) ? RS_BUS : RS_TRUCK;
@@ -1021,7 +1021,7 @@
 				const RoadStop *rs = GetRoadStopByTile(tile, rstype);
 
 				if (rs != NULL && (_patches.roadveh_queue || GB(rs->status, 0, 2) != 0)) {
-					bitmask |= _road_veh_fp_ax_or[GetRoadStationDir(tile)];
+					bitmask |= _road_veh_fp_ax_or[GetRoadStopDir(tile)];
 				}
 			}
 		}
@@ -1089,7 +1089,7 @@
 			}
 		} else if (IsTileType(desttile, MP_STATION)) {
 			if (IsRoadStop(desttile)) {
-				dir = GetRoadStationDir(desttile);
+				dir = GetRoadStopDir(desttile);
 do_it:;
 				/* When we are heading for a depot or station, we just
 				 * pretend we are heading for the tile in front, we'll
--- a/station.h
+++ b/station.h
@@ -213,10 +213,6 @@
 		GB(_m[tile].m5, 0, 1) == GB(_m[ref].m5, 0, 1);   // same direction?
 }
 
-static inline bool IsRoadStationTile(TileIndex tile) {
-	return IsTileType(tile, MP_STATION) && IS_BYTE_INSIDE(_m[tile].m5, 0x43, 0x4B);
-}
-
 /**
  * Check if a station really exists.
  */
@@ -235,13 +231,4 @@
 	return IsTileType(tile, MP_STATION) && _m[tile].m5 == 0x52;
 }
 
-/**
- * Get's the direction the road stop entrance points towards.
- */
-static inline DiagDirection GetRoadStationDir(TileIndex tile)
-{
-	assert(IsRoadStationTile(tile));
-	return (_m[tile].m5 - 0x43) & 3;
-}
-
 #endif /* STATION_H */
--- a/station_map.h
+++ b/station_map.h
@@ -105,6 +105,20 @@
 	return IsTruckStop(t) || IsBusStop(t);
 }
 
+static inline bool IsRoadStopTile(TileIndex t)
+{
+	return IsTileType(t, MP_STATION) && IsRoadStop(t);
+}
+
+/**
+ * Gets the direction the road stop entrance points towards.
+ */
+static inline DiagDirection GetRoadStopDir(TileIndex tile)
+{
+	assert(IsRoadStopTile(tile));
+	return (_m[tile].m5 - TRUCK_BASE) & 3;
+}
+
 static inline bool IsOilRig(TileIndex t)
 {
 	assert(IsTileType(t, MP_STATION));
--- a/vehicle.c
+++ b/vehicle.c
@@ -23,6 +23,7 @@
 #include "station.h"
 #include "rail.h"
 #include "train.h"
+#include "station_map.h"
 
 #define INVALID_COORD (-0x8000)
 #define GEN_HASH(x,y) (((x & 0x1F80)>>7) + ((y & 0xFC0)))
@@ -1988,8 +1989,8 @@
 			if (v->u.road.state == 254) /* We'll assume the road vehicle is facing outwards */
 				return DiagdirToDiagTrackdir(GetRoadDepotDirection(v->tile));
 
-			if (IsRoadStationTile(v->tile)) /* We'll assume the road vehicle is facing outwards */
-				return DiagdirToDiagTrackdir(GetRoadStationDir(v->tile)); /* Road vehicle in a station */
+			if (IsRoadStopTile(v->tile)) /* We'll assume the road vehicle is facing outwards */
+				return DiagdirToDiagTrackdir(GetRoadStopDir(v->tile)); /* Road vehicle in a station */
 
 			return DiagdirToDiagTrackdir(DirToDiagDir(v->direction));