summaryrefslogtreecommitdiff
path: root/roadveh_cmd.c
diff options
context:
space:
mode:
authorcelestar <celestar@openttd.org>2006-12-27 12:38:02 +0000
committercelestar <celestar@openttd.org>2006-12-27 12:38:02 +0000
commitd95e2c2dd10a0dfc1704962a68a2bd32b635d158 (patch)
tree28100daed109de06e979123edd0601487ecc8261 /roadveh_cmd.c
parentd92103d6ff97ae413e2e6eae602e04b05addaf17 (diff)
downloadopenttd-d95e2c2dd10a0dfc1704962a68a2bd32b635d158.tar.xz
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
Diffstat (limited to 'roadveh_cmd.c')
-rw-r--r--roadveh_cmd.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/roadveh_cmd.c b/roadveh_cmd.c
index 57143853b..48f6ad180 100644
--- a/roadveh_cmd.c
+++ b/roadveh_cmd.c
@@ -21,7 +21,9 @@
#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_callbacks.h"
#include "newgrf_engine.h"
@@ -322,8 +324,6 @@ 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;
@@ -444,14 +444,19 @@ 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_HIDDEN | VS_STOPPED) ||
+ if (v->vehstatus & 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;
@@ -518,11 +523,9 @@ 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;
@@ -872,6 +875,7 @@ 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) {
@@ -1339,8 +1343,7 @@ static void RoadVehController(Vehicle *v)
return;
}
- if (IsTunnelTile(gp.new_tile) &&
- VehicleEnterTile(v, gp.new_tile, gp.x, gp.y) & 4) {
+ if ((IsTunnelTile(gp.new_tile) || IsBridgeTile(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);
@@ -1351,6 +1354,7 @@ 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;
}