summaryrefslogtreecommitdiff
path: root/roadveh_cmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'roadveh_cmd.c')
-rw-r--r--roadveh_cmd.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/roadveh_cmd.c b/roadveh_cmd.c
index e46666066..bd99fd227 100644
--- a/roadveh_cmd.c
+++ b/roadveh_cmd.c
@@ -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 @@ static const Depot* FindClosestRoadDepot(const Vehicle* v)
{
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 @@ int32 CmdTurnRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
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 @@ static byte SetRoadVehPosition(Vehicle *v, int x, int y)
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 @@ static bool RoadVehAccelerate(Vehicle *v)
// 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 @@ static void RoadVehController(Vehicle *v)
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 @@ static void RoadVehController(Vehicle *v)
v->x_pos = gp.x;
v->y_pos = gp.y;
VehiclePositionChanged(v);
- if (!(v->vehstatus & VS_HIDDEN)) EndVehicleMove(v);
return;
}