# HG changeset patch # User celestar # Date 1167498570 0 # Node ID a8e391b7b10ab7692e21aa3e4d6dc590adef61f5 # Parent 3864438e7cb2cdd8f20a65df0019982a136c5962 (svn r7651) [cbh] - Fix: Allow trains to enter bridge head tiles from "the side" diff -r 3864438e7cb2 -r a8e391b7b10a bridge_cmd.c --- a/bridge_cmd.c Sat Dec 30 17:08:50 2006 +0000 +++ b/bridge_cmd.c Sat Dec 30 17:09:30 2006 +0000 @@ -766,6 +766,17 @@ return bridge_speed; } +static bool IsCustomBridgeHead(TileIndex tile) +{ + assert(IsBridgeTile(tile)); + + if (IsTileType(tile, MP_RAILWAY_BRIDGE)) { + return !(GetTrackBits(tile) == TRACK_BIT_X || GetTrackBits(tile) == TRACK_BIT_Y); + } + + return false; /* TODO - street bridges */ +} + /** Gets the absolute z coordinate of a point inside a bridge tile * When we're on the track (that means between position 5 and 10) @@ -773,6 +784,8 @@ * height of the ramp * Outside this range (from 0 to 4 and from 11 to 15) it returns the * "true" Z coordinate of the tile by taking the slope into account + * For custom bridge heads the entire bridge head is flat and has the + * same z coordinate * @param tile The index of the tile we are talking about * @param x Absolute or relative x coordinate * @param y Absolute or relative y coordinate @@ -789,8 +802,8 @@ pos = (DiagDirToAxis(dir) == AXIS_X ? y : x); - // On the bridge ramp? - if (5 <= pos && pos <= 10) { + // On the bridge ramp or flat bridge head? + if ( (5 <= pos && pos <= 10) || IsCustomBridgeHead(tile)) { uint delta; if (IsSteepSlope(tileh)) return z + TILE_HEIGHT * 2; @@ -937,6 +950,13 @@ DiagDirection dir; + if (IsCustomBridgeHead(tile)) { + uint h; + GetTileSlope(tile, &h); + + z = h + TILE_HEIGHT - v->z_pos; + } + if (myabs(z) > 2) return 8; if (v->type == VEH_Road || (v->type == VEH_Train && IsFrontEngine(v))) { @@ -948,7 +968,7 @@ } dir = GetBridgeRampDirection(tile); - if (DirToDiagDir(v->direction) == dir) { + if (DirToDiagDir(v->direction) == dir || IsTileType(tile, MP_RAILWAY_BRIDGE)) { switch (dir) { default: NOT_REACHED(); case DIAGDIR_NE: if ((x & 0xF) != 0) return 0; break;