(svn r3750) Use INVALID_STATION instead of -1 in NPF
authortron
Fri, 03 Mar 2006 20:54:54 +0000
changeset 3135 3a20ced2e34b
parent 3134 067721ea923c
child 3136 e2682061ef1d
(svn r3750) Use INVALID_STATION instead of -1 in NPF
npf.c
npf.h
roadveh_cmd.c
--- a/npf.c	Fri Mar 03 20:48:03 2006 +0000
+++ b/npf.c	Fri Mar 03 20:54:54 2006 +0000
@@ -117,7 +117,7 @@
 	uint dist;
 
 	// for train-stations, we are going to aim for the closest station tile
-	if (as->user_data[NPF_TYPE] == TRANSPORT_RAIL && fstd->station_index != -1)
+	if (as->user_data[NPF_TYPE] == TRANSPORT_RAIL && fstd->station_index != INVALID_STATION)
 		to = CalcClosestStationTile(fstd->station_index, from);
 
 	if (as->user_data[NPF_TYPE] == TRANSPORT_ROAD) {
@@ -420,7 +420,7 @@
 	/* If GetNeighbours said we could get here, we assume the station type
 	 * is correct */
 	if (
-		(fstd->station_index == -1 && tile == fstd->dest_coords) || /* We've found the tile, or */
+		(fstd->station_index == INVALID_STATION && tile == fstd->dest_coords) || /* We've found the tile, or */
 		(IsTileType(tile, MP_STATION) && _m[tile].m2 == fstd->station_index) /* the station */
 	) {
 		return AYSTAR_FOUND_END_NODE;
@@ -800,7 +800,7 @@
 		assert(0);
 
 	/* Initialize target */
-	target.station_index = -1; /* We will initialize dest_coords inside the loop below */
+	target.station_index = INVALID_STATION; /* We will initialize dest_coords inside the loop below */
 	_npf_aystar.user_target = ⌖
 
 	/* Initialize user_data */
@@ -879,6 +879,6 @@
 		fstd->dest_coords = CalcClosestStationTile(v->current_order.station, v->tile);
 	} else {
 		fstd->dest_coords = v->dest_tile;
-		fstd->station_index = -1;
+		fstd->station_index = INVALID_STATION;
 	}
 }
--- a/npf.h	Fri Mar 03 20:48:03 2006 +0000
+++ b/npf.h	Fri Mar 03 20:54:54 2006 +0000
@@ -5,6 +5,7 @@
 
 #include "openttd.h"
 #include "aystar.h"
+#include "station.h"
 #include "vehicle.h"
 #include "tile.h"
 #include "variables.h"
@@ -31,7 +32,7 @@
 
 typedef struct NPFFindStationOrTileData { /* Meant to be stored in AyStar.targetdata */
 	TileIndex dest_coords; /* An indication of where the station is, for heuristic purposes, or the target tile */
-	int station_index; /* station index we're heading for, or -1 when we're heading for a tile */
+	StationID station_index; /* station index we're heading for, or INVALID_STATION when we're heading for a tile */
 } NPFFindStationOrTileData;
 
 enum { /* Indices into AyStar.userdata[] */
--- a/roadveh_cmd.c	Fri Mar 03 20:48:03 2006 +0000
+++ b/roadveh_cmd.c	Fri Mar 03 20:54:54 2006 +0000
@@ -1111,7 +1111,7 @@
 	assert(trackdir != 0xFF);
 
 	fstd.dest_coords = tile;
-	fstd.station_index = -1;	// indicates that the destination is a tile, not a station
+	fstd.station_index = INVALID_STAION; // indicates that the destination is a tile, not a station
 
 	return NPFRouteToStationOrTile(v->tile, trackdir, &fstd, TRANSPORT_ROAD, v->owner, INVALID_RAILTYPE).best_path_dist;
 }