equal
deleted
inserted
replaced
36 } else { |
36 } else { |
37 type |= (TRANSPORT_RAIL << 15); |
37 type |= (TRANSPORT_RAIL << 15); |
38 type |= (RAILTYPES_RAIL << 8); |
38 type |= (RAILTYPES_RAIL << 8); |
39 } |
39 } |
40 |
40 |
41 return AIObject::DoCommand(end, start, type | bridge_id, CMD_BUILD_BRIDGE); |
41 if (!AIObject::DoCommand(end, start, type | bridge_id, CMD_BUILD_BRIDGE)) return false; |
|
42 if (vehicle_type == AIVehicle::VEHICLE_RAIL) return true; |
|
43 |
|
44 /* Build 2 road-pieces at both ends of the bridge */ |
|
45 DiagDirection dir_1 = (DiagDirection)((::TileX(start) == ::TileX(end)) ? (::TileY(start) < ::TileY(end) ? DIAGDIR_NW : DIAGDIR_SE) : (::TileX(start) < ::TileX(end) ? DIAGDIR_NE : DIAGDIR_SW)); |
|
46 DiagDirection dir_2 = ::ReverseDiagDir(dir_1); |
|
47 |
|
48 AIObject::DoCommand(start + ::TileOffsByDiagDir(dir_1), ::DiagDirToRoadBits(dir_2) | (AIObject::GetRoadType() << 4), 0, CMD_BUILD_ROAD); |
|
49 AIObject::DoCommand(end + ::TileOffsByDiagDir(dir_2), ::DiagDirToRoadBits(dir_1) | (AIObject::GetRoadType() << 4), 0, CMD_BUILD_ROAD); |
|
50 |
|
51 return true; |
42 } |
52 } |
43 |
53 |
44 /* static */ bool AIBridge::RemoveBridge(TileIndex tile) |
54 /* static */ bool AIBridge::RemoveBridge(TileIndex tile) |
45 { |
55 { |
46 EnforcePrecondition(false, IsBridgeTile(tile)); |
56 EnforcePrecondition(false, IsBridgeTile(tile)); |