src/train_cmd.cpp
changeset 8283 bbe075d76da6
parent 8281 c4b8951e7aa9
child 8300 dfd530665621
equal deleted inserted replaced
8282:d9f5096a5d54 8283:bbe075d76da6
  3241 			InvalidateWindow(WC_VEHICLE_VIEW, v->index);
  3241 			InvalidateWindow(WC_VEHICLE_VIEW, v->index);
  3242 		}
  3242 		}
  3243 	}
  3243 	}
  3244 }
  3244 }
  3245 
  3245 
       
  3246 /** Maximum speeds for train that is broken down or approaching line end */
  3246 static const byte _breakdown_speeds[16] = {
  3247 static const byte _breakdown_speeds[16] = {
  3247 	225, 210, 195, 180, 165, 150, 135, 120, 105, 90, 75, 60, 45, 30, 15, 15
  3248 	225, 210, 195, 180, 165, 150, 135, 120, 105, 90, 75, 60, 45, 30, 15, 15
  3248 };
  3249 };
  3249 
  3250 
       
  3251 /**
       
  3252  * Checks for line end. Also, bars crossing at next tile if needed
       
  3253  *
       
  3254  * @param v vehicle we are checking
       
  3255  * @return true iff we do NOT have to reverse
       
  3256  */
  3250 static bool TrainCheckIfLineEnds(Vehicle *v)
  3257 static bool TrainCheckIfLineEnds(Vehicle *v)
  3251 {
  3258 {
  3252 	int t = v->breakdown_ctr;
  3259 	int t = v->breakdown_ctr;
  3253 	if (t > 1) {
  3260 	if (t > 1) {
  3254 		v->vehstatus |= VS_TRAIN_SLOWING;
  3261 		v->vehstatus |= VS_TRAIN_SLOWING;
  3267 	if (IsTileType(tile, MP_TUNNELBRIDGE)) {
  3274 	if (IsTileType(tile, MP_TUNNELBRIDGE)) {
  3268 		DiagDirection dir = GetTunnelBridgeDirection(tile);
  3275 		DiagDirection dir = GetTunnelBridgeDirection(tile);
  3269 		if (DiagDirToDir(dir) == v->direction) return true;
  3276 		if (DiagDirToDir(dir) == v->direction) return true;
  3270 	}
  3277 	}
  3271 
  3278 
  3272 	// depot?
  3279 	if (IsTileType(tile, MP_RAILWAY) && GetRailTileType(tile) == RAIL_TILE_DEPOT) {
  3273 	/* XXX -- When enabled, this makes it possible to crash trains of others
  3280 		DiagDirection dir = ReverseDiagDir(GetRailDepotDirection(tile));
  3274 	     (by building a depot right against a station) */
  3281 		if (DiagDirToDir(dir) == v->direction) return true;
  3275 /*	if (IsTileType(tile, MP_RAILWAY) && GetRailTileType(tile) == RAIL_TILE_DEPOT_WAYPOINT)
  3282 	}
  3276 		return true;*/
       
  3277 
  3283 
  3278 	/* Determine the non-diagonal direction in which we will exit this tile */
  3284 	/* Determine the non-diagonal direction in which we will exit this tile */
  3279 	DiagDirection dir = TrainExitDir(v->direction, v->u.rail.track);
  3285 	DiagDirection dir = TrainExitDir(v->direction, v->u.rail.track);
  3280 	/* Calculate next tile */
  3286 	/* Calculate next tile */
  3281 	tile += TileOffsByDiagDir(dir);
  3287 	tile += TileOffsByDiagDir(dir);