roadveh_cmd.c
changeset 3977 edb5b94e2094
parent 3959 e2bbaa8d4978
child 3990 d3d23f3bcd34
--- a/roadveh_cmd.c	Wed Jun 07 18:41:58 2006 +0000
+++ b/roadveh_cmd.c	Wed Jun 07 19:35:21 2006 +0000
@@ -21,9 +21,7 @@
 #include "player.h"
 #include "sound.h"
 #include "depot.h"
-#include "bridge.h"
 #include "tunnel_map.h"
-#include "bridge_map.h"
 #include "vehicle_gui.h"
 #include "newgrf_engine.h"
 #include "yapf/yapf.h"
@@ -309,6 +307,8 @@
 {
 	TileIndex tile = v->tile;
 
+	if (v->u.road.state == 255) tile = GetVehicleOutOfTunnelTile(v);
+
 	if (_patches.yapf.road_use_yapf) {
 		Depot* ret = YapfFindNearestRoadDepot(v);
 		return ret;
@@ -405,19 +405,14 @@
 
 	if (v->type != VEH_Road || !CheckOwnership(v->owner)) return CMD_ERROR;
 
-	if (v->vehstatus & VS_STOPPED ||
+	if (v->vehstatus & (VS_HIDDEN | VS_STOPPED) ||
 			v->u.road.crashed_ctr != 0 ||
 			v->breakdown_ctr != 0 ||
 			v->u.road.overtaking != 0 ||
-			v->u.road.state == 255 ||
-			IsRoadVehInDepot(v) ||
 			v->cur_speed < 5) {
 		return CMD_ERROR;
 	}
 
-	if (IsTunnelTile(v->tile) && DirToDiagDir(v->direction) == GetTunnelDirection(v->tile)) return CMD_ERROR;
-	if (IsBridgeTile(v->tile) && DirToDiagDir(v->direction) == GetBridgeRampDirection(v->tile)) return CMD_ERROR;
-
 	if (flags & DC_EXEC) v->u.road.reverse_ctr = 180;
 
 	return 0;
@@ -484,9 +479,11 @@
 	byte new_z, old_z;
 
 	// need this hint so it returns the right z coordinate on bridges.
+	_get_z_hint = v->z_pos;
 	v->x_pos = x;
 	v->y_pos = y;
 	new_z = GetSlopeZ(x, y);
+	_get_z_hint = 0;
 
 	old_z = v->z_pos;
 	v->z_pos = new_z;
@@ -821,7 +818,6 @@
 
 	// Clamp
 	spd = min(spd, v->max_speed);
-	if (v->u.road.state == 255) spd = min(spd, SetSpeedLimitOnBridge(v));
 
 	//updates statusbar only if speed have changed to save CPU time
 	if (spd != v->cur_speed) {
@@ -1290,7 +1286,8 @@
 			return;
 		}
 
-		if ((IsTunnelTile(gp.new_tile) || IsBridgeTile(gp.new_tile)) && VehicleEnterTile(v, gp.new_tile, gp.x, gp.y) & 4) {
+		if (IsTunnelTile(gp.new_tile) &&
+				VehicleEnterTile(v, gp.new_tile, gp.x, gp.y) & 4) {
 			//new_dir = RoadGetNewDirection(v, gp.x, gp.y)
 			v->cur_image = GetRoadVehImage(v, v->direction);
 			UpdateRoadVehDeltaXY(v);
@@ -1301,7 +1298,6 @@
 		v->x_pos = gp.x;
 		v->y_pos = gp.y;
 		VehiclePositionChanged(v);
-		if (!(v->vehstatus & VS_HIDDEN)) EndVehicleMove(v);
 		return;
 	}