ship_cmd.c
changeset 1330 5d76a0522a11
parent 1313 f1013ec3d318
child 1401 44a7e0f04d28
--- a/ship_cmd.c	Sun Feb 06 22:25:27 2005 +0000
+++ b/ship_cmd.c	Sun Feb 06 22:36:08 2005 +0000
@@ -69,14 +69,12 @@
 	Depot *depot;
 	Depot *best_depot = NULL;
 	uint tile, dist, best_dist = (uint)-1;
-	byte owner = v->owner;
 	uint tile2 = v->tile;
 
 	if (_patches.new_pathfinding_all) {
 		NPFFoundTargetData ftd;
 		byte trackdir = _track_direction_to_trackdir[FIND_FIRST_BIT(v->u.ship.state)][v->direction];
-		/* XXX --- SLOW!!!! */
-		ftd = NPFRouteToDepotTrialError(v->tile, trackdir, TRANSPORT_WATER);
+		ftd = NPFRouteToDepotTrialError(v->tile, trackdir, TRANSPORT_WATER, v->owner);
 		if (ftd.best_bird_dist == 0)
 			best_depot = GetDepotByTile(ftd.node.tile); /* Found target */
 		else
@@ -84,7 +82,7 @@
 	} else {
 		FOR_ALL_DEPOTS(depot) {
 			tile = depot->xy;
-			if (IsTileType(tile, MP_WATER) && _map_owner[tile] == owner) {
+			if (IsValidDepot(depot) && IsTileDepotType(tile, TRANSPORT_WATER) && IsTileOwner(tile, v->owner)) {
 				dist = DistanceManhattan(tile, tile2);
 				if (dist < best_dist) {
 					best_dist = dist;
@@ -598,7 +596,7 @@
 
 		NPFFillWithOrderData(&fstd, v);
 
-		ftd = NPFRouteToStationOrTile(src_tile, _track_direction_to_trackdir[track][v->direction], &fstd, TRANSPORT_WATER);
+		ftd = NPFRouteToStationOrTile(src_tile, _track_direction_to_trackdir[track][v->direction], &fstd, TRANSPORT_WATER, v->owner);
 
 		if (ftd.best_bird_dist == 0 && ftd.best_trackdir != 0xff)
 			/* Found the target, and it is not our current tile */
@@ -876,12 +874,12 @@
 	int32 value;
 	Vehicle *v;
 	UnitID unit_num;
-	uint tile = TILE_FROM_XY(x,y);
+	TileIndex tile = TILE_FROM_XY(x,y);
 	Engine *e;
 
 	if (!IsEngineBuildable(p1, VEH_Ship)) return CMD_ERROR;
 
-	if (!IsShipDepotTile((TileIndex)tile)) return CMD_ERROR;
+	if (!IsTileDepotType(tile, TRANSPORT_WATER)) return CMD_ERROR;
 
 	if (_map_owner[tile] != _current_player) return CMD_ERROR;
 
@@ -964,7 +962,7 @@
 
 	SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
 
-	if (!IsShipDepotTile(v->tile) || v->u.road.state != 0x80 || !(v->vehstatus&VS_STOPPED))
+	if (!IsTileDepotType(v->tile, TRANSPORT_WATER) || v->u.road.state != 0x80 || !(v->vehstatus&VS_STOPPED))
 		return_cmd_error(STR_980B_SHIP_MUST_BE_STOPPED_IN);
 
 	if (flags & DC_EXEC) {
@@ -1088,7 +1086,7 @@
 		return CMD_ERROR;
 
 	if (!( SkipStoppedInDepotCheck )) {
-		if (!IsShipDepotTile(v->tile) ||
+		if (!IsTileDepotType(v->tile, TRANSPORT_WATER) ||
 				!(v->vehstatus&VS_STOPPED) ||
 				v->u.ship.state != 0x80)
 			return_cmd_error(STR_980B_SHIP_MUST_BE_STOPPED_IN);