src/roadveh_cmd.cpp
branchcpp_gui
changeset 6268 4b5241e5dd10
parent 6254 abc6ad7c035c
child 6285 187e3ef04cc9
equal deleted inserted replaced
6267:7c8ec33959b1 6268:4b5241e5dd10
   878 	uint spd = v->cur_speed + 1 + (v->u.road.overtaking != 0 ? 1 : 0);
   878 	uint spd = v->cur_speed + 1 + (v->u.road.overtaking != 0 ? 1 : 0);
   879 	byte t;
   879 	byte t;
   880 
   880 
   881 	// Clamp
   881 	// Clamp
   882 	spd = min(spd, v->max_speed);
   882 	spd = min(spd, v->max_speed);
   883 	if (v->u.road.state == RVSB_WORMHOLE) spd = min(spd, SetSpeedLimitOnBridge(v));
   883 	if (v->u.road.state == RVSB_WORMHOLE && !(v->vehstatus & VS_HIDDEN)) {
       
   884 		spd = min(spd, GetBridge(GetBridgeType(v->tile))->speed * 2);
       
   885 	}
   884 
   886 
   885 	//updates statusbar only if speed have changed to save CPU time
   887 	//updates statusbar only if speed have changed to save CPU time
   886 	if (spd != v->cur_speed) {
   888 	if (spd != v->cur_speed) {
   887 		v->cur_speed = spd;
   889 		v->cur_speed = spd;
   888 		if (_patches.vehicle_speed) {
   890 		if (_patches.vehicle_speed) {
   970 	}
   972 	}
   971 
   973 
   972 	if (v->direction != u->direction || !(v->direction & 1)) return;
   974 	if (v->direction != u->direction || !(v->direction & 1)) return;
   973 
   975 
   974 	/* Check if vehicle is in a road stop, depot, tunnel or bridge or not on a straight road */
   976 	/* Check if vehicle is in a road stop, depot, tunnel or bridge or not on a straight road */
   975 	if (v->u.road.state >= RVS_IN_ROAD_STOP || !IsStraightRoadTrackdir((Trackdir)(v->u.road.state & RVSB_TRACKDIR_MASK))) return;
   977 	if (v->u.road.state >= RVSB_IN_ROAD_STOP || !IsStraightRoadTrackdir((Trackdir)(v->u.road.state & RVSB_TRACKDIR_MASK))) return;
   976 
   978 
   977 	tt = GetTileTrackStatus(v->tile, TRANSPORT_ROAD) & 0x3F;
   979 	tt = GetTileTrackStatus(v->tile, TRANSPORT_ROAD) & 0x3F;
   978 	if ((tt & 3) == 0) return;
   980 	if ((tt & 3) == 0) return;
   979 	if ((tt & 0x3C) != 0) return;
   981 	if ((tt & 0x3C) != 0) return;
   980 
   982 
  1353 	/* Save old vehicle position to use at end of move to set viewport area dirty */
  1355 	/* Save old vehicle position to use at end of move to set viewport area dirty */
  1354 	BeginVehicleMove(v);
  1356 	BeginVehicleMove(v);
  1355 
  1357 
  1356 	if (v->u.road.state == RVSB_WORMHOLE) {
  1358 	if (v->u.road.state == RVSB_WORMHOLE) {
  1357 		/* Vehicle is entering a depot or is on a bridge or in a tunnel */
  1359 		/* Vehicle is entering a depot or is on a bridge or in a tunnel */
  1358 		GetNewVehiclePosResult gp;
  1360 		GetNewVehiclePosResult gp = GetNewVehiclePos(v);
  1359 
       
  1360 		GetNewVehiclePos(v, &gp);
       
  1361 
  1361 
  1362 		const Vehicle *u = RoadVehFindCloseTo(v, gp.x, gp.y, v->direction);
  1362 		const Vehicle *u = RoadVehFindCloseTo(v, gp.x, gp.y, v->direction);
  1363 		if (u != NULL && u->cur_speed < v->cur_speed) {
  1363 		if (u != NULL && u->cur_speed < v->cur_speed) {
  1364 			v->cur_speed = u->cur_speed;
  1364 			v->cur_speed = u->cur_speed;
  1365 			return;
  1365 			return;