~ubuntu-branches/debian/squeeze/openttd/squeeze

« back to all changes in this revision

Viewing changes to src/rail_cmd.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Matthijs Kooijman, Matthijs Kooijman
  • Date: 2009-10-01 22:52:59 UTC
  • mfrom: (1.1.8 upstream) (2.1.6 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091001225259-5kpkp4sthbszpyif
[ Matthijs Kooijman ]
* New upstream release
* Use printf instead of echo -en in openttd-wrapper to make it POSIX
  compatible (Closes: #547758).
* Remove three patches that are now included in upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: rail_cmd.cpp 16531 2009-06-07 15:26:33Z rubidium $ */
 
1
/* $Id: rail_cmd.cpp 17456 2009-09-07 14:09:45Z rubidium $ */
2
2
 
3
3
/** @file rail_cmd.cpp Handling of rail tiles. */
4
4
 
118
118
        TrackBits future;  // The track layout we want to build
119
119
        _error_message = STR_1001_IMPOSSIBLE_TRACK_COMBINATION;
120
120
 
121
 
        if (!IsPlainRailTile(tile)) return false;
 
121
        if (!IsPlainRail(tile)) return false;
122
122
 
123
123
        /* So, we have a tile with tracks on it (and possibly signals). Let's see
124
124
         * what tracks first */
321
321
                case MP_RAILWAY:
322
322
                        if (!CheckTileOwnership(tile)) return CMD_ERROR;
323
323
 
324
 
                        if (!IsPlainRailTile(tile)) return CMD_ERROR;
 
324
                        if (!IsPlainRail(tile)) return CMD_ERROR;
325
325
 
326
326
                        if (!IsCompatibleRail(GetRailType(tile), railtype)) return_cmd_error(STR_1001_IMPOSSIBLE_TRACK_COMBINATION);
327
327
 
481
481
                case MP_RAILWAY: {
482
482
                        TrackBits present;
483
483
 
484
 
                        if (!IsPlainRailTile(tile) ||
 
484
                        if (!IsPlainRail(tile) ||
485
485
                                        (_current_company != OWNER_WATER && !CheckTileOwnership(tile)) ||
486
486
                                        !EnsureNoTrainOnTrack(tile, track)) {
487
487
                                return CMD_ERROR;
825
825
 
826
826
        if (sigtype > SIGTYPE_LAST) return CMD_ERROR;
827
827
 
828
 
        if (!ValParamTrackOrientation(track) || !IsTileType(tile, MP_RAILWAY) || !EnsureNoTrainOnTrack(tile, track))
 
828
        /* You can only build signals on plain rail tiles, and the selected track must exist */
 
829
        if (!ValParamTrackOrientation(track) || !IsPlainRailTile(tile) ||
 
830
                        !HasTrack(tile, track) || !EnsureNoTrainOnTrack(tile, track)) {
829
831
                return CMD_ERROR;
 
832
        }
830
833
 
831
834
        /* Protect against invalid signal copying */
832
835
        if (p2 != 0 && (p2 & SignalOnTrack(track)) == 0) return CMD_ERROR;
833
836
 
834
 
        /* You can only build signals on plain rail tiles, and the selected track must exist */
835
 
        if (!IsPlainRailTile(tile) || !HasTrack(tile, track)) return CMD_ERROR;
836
 
 
837
837
        if (!CheckTileOwnership(tile)) return CMD_ERROR;
838
838
 
839
839
        {
1047
1047
        end_tile = p1;
1048
1048
        if (signal_density == 0 || signal_density > 20) return CMD_ERROR;
1049
1049
 
1050
 
        if (!IsTileType(tile, MP_RAILWAY) || !IsPlainRailTile(tile)) return CMD_ERROR;
 
1050
        if (!IsPlainRailTile(tile)) return CMD_ERROR;
1051
1051
 
1052
1052
        /* for vertical/horizontal tracks, double the given signals density
1053
1053
         * since the original amount will be too dense (shorter tracks) */
1172
1172
        Track track = (Track)GB(p1, 0, 3);
1173
1173
 
1174
1174
        if (!ValParamTrackOrientation(track) ||
1175
 
                        !IsTileType(tile, MP_RAILWAY) ||
1176
1175
                        !IsPlainRailTile(tile) ||
1177
1176
                        !HasTrack(tile, track) ||
1178
1177
                        !EnsureNoTrainOnTrack(tile, track) ||
1440
1439
                        if (v != NULL) FreeTrainTrackReservation(v);
1441
1440
                }
1442
1441
 
 
1442
                delete GetDepotByTile(tile);
1443
1443
                DoClearSquare(tile);
1444
 
                delete GetDepotByTile(tile);
1445
1444
                AddSideToSignalBuffer(tile, dir, owner);
1446
1445
                YapfNotifyTrackLayoutChange(tile, DiagDirToDiagTrack(dir));
1447
1446
                if (v != NULL) TryPathReserve(v, true);
1456
1455
        CommandCost ret;
1457
1456
 
1458
1457
        if (flags & DC_AUTO) {
1459
 
                if (!IsTileOwner(tile, _current_company))
 
1458
                if (!IsTileOwner(tile, _current_company)) {
1460
1459
                        return_cmd_error(STR_1024_AREA_IS_OWNED_BY_ANOTHER);
 
1460
                }
1461
1461
 
1462
 
                if (IsPlainRailTile(tile)) {
 
1462
                if (IsPlainRail(tile)) {
1463
1463
                        return_cmd_error(STR_1008_MUST_REMOVE_RAILROAD_TRACK);
1464
1464
                } else {
1465
1465
                        return_cmd_error(STR_2004_BUILDING_MUST_BE_DEMOLISHED);
1890
1890
 
1891
1891
        _drawtile_track_palette = COMPANY_SPRITE_COLOUR(GetTileOwner(ti->tile));
1892
1892
 
1893
 
        if (IsPlainRailTile(ti->tile)) {
 
1893
        if (IsPlainRail(ti->tile)) {
1894
1894
                TrackBits rails = GetTrackBits(ti->tile);
1895
1895
 
1896
1896
                DrawTrackBits(ti, rails);
2060
2060
        Slope tileh = GetTileSlope(tile, &z);
2061
2061
 
2062
2062
        if (tileh == SLOPE_FLAT) return z;
2063
 
        if (IsPlainRailTile(tile)) {
 
2063
        if (IsPlainRail(tile)) {
2064
2064
                z += ApplyFoundationToSlope(GetRailFoundation(tileh, GetTrackBits(tile)), &tileh);
2065
2065
                return z + GetPartialZ(x & 0xF, y & 0xF, tileh);
2066
2066
        } else {
2070
2070
 
2071
2071
static Foundation GetFoundation_Track(TileIndex tile, Slope tileh)
2072
2072
{
2073
 
        return IsPlainRailTile(tile) ? GetRailFoundation(tileh, GetTrackBits(tile)) : FlatteningFoundation(tileh);
 
2073
        return IsPlainRail(tile) ? GetRailFoundation(tileh, GetTrackBits(tile)) : FlatteningFoundation(tileh);
2074
2074
}
2075
2075
 
2076
2076
static void GetAcceptedCargo_Track(TileIndex tile, AcceptedCargo ac)
2078
2078
        /* not used */
2079
2079
}
2080
2080
 
2081
 
static void AnimateTile_Track(TileIndex tile)
2082
 
{
2083
 
        /* not used */
2084
 
}
2085
 
 
2086
2081
static void TileLoop_Track(TileIndex tile)
2087
2082
{
2088
2083
        RailGroundType old_ground = GetRailGroundType(tile);
2101
2096
 
2102
2097
                        /* for non-flat track, use lower part of track
2103
2098
                         * in other cases, use the highest part with track */
2104
 
                        if (IsPlainRailTile(tile)) {
 
2099
                        if (IsPlainRail(tile)) {
2105
2100
                                TrackBits track = GetTrackBits(tile);
2106
2101
                                Foundation f = GetRailFoundation(slope, track);
2107
2102
 
2159
2154
                        break;
2160
2155
        }
2161
2156
 
2162
 
        if (!IsPlainRailTile(tile)) return;
 
2157
        if (!IsPlainRail(tile)) return;
2163
2158
 
2164
2159
        new_ground = RAIL_GROUND_GRASS;
2165
2160
 
2181
2176
                                                        (rail & TRACK_BIT_X)
2182
2177
                                                )) {
2183
2178
                                        TileIndex n = tile + TileDiffXY(0, -1);
2184
 
                                        TrackBits nrail = (IsTileType(n, MP_RAILWAY) && IsPlainRailTile(n) ? GetTrackBits(n) : TRACK_BIT_NONE);
 
2179
                                        TrackBits nrail = (IsPlainRailTile(n) ? GetTrackBits(n) : TRACK_BIT_NONE);
2185
2180
 
2186
2181
                                        if (!IsTileType(n, MP_RAILWAY) ||
2187
2182
                                                        !IsTileOwner(n, owner) ||
2196
2191
                                                        (rail & TRACK_BIT_X)
2197
2192
                                                )) {
2198
2193
                                        TileIndex n = tile + TileDiffXY(0, 1);
2199
 
                                        TrackBits nrail = (IsTileType(n, MP_RAILWAY) && IsPlainRailTile(n) ? GetTrackBits(n) : TRACK_BIT_NONE);
 
2194
                                        TrackBits nrail = (IsPlainRailTile(n) ? GetTrackBits(n) : TRACK_BIT_NONE);
2200
2195
 
2201
2196
                                        if (!IsTileType(n, MP_RAILWAY) ||
2202
2197
                                                        !IsTileOwner(n, owner) ||
2212
2207
                                                        (rail & TRACK_BIT_Y)
2213
2208
                                                )) {
2214
2209
                                        TileIndex n = tile + TileDiffXY(-1, 0);
2215
 
                                        TrackBits nrail = (IsTileType(n, MP_RAILWAY) && IsPlainRailTile(n) ? GetTrackBits(n) : TRACK_BIT_NONE);
 
2210
                                        TrackBits nrail = (IsPlainRailTile(n) ? GetTrackBits(n) : TRACK_BIT_NONE);
2216
2211
 
2217
2212
                                        if (!IsTileType(n, MP_RAILWAY) ||
2218
2213
                                                        !IsTileOwner(n, owner) ||
2227
2222
                                                        (rail & TRACK_BIT_Y)
2228
2223
                                                )) {
2229
2224
                                        TileIndex n = tile + TileDiffXY(1, 0);
2230
 
                                        TrackBits nrail = (IsTileType(n, MP_RAILWAY) && IsPlainRailTile(n) ? GetTrackBits(n) : TRACK_BIT_NONE);
 
2225
                                        TrackBits nrail = (IsPlainRailTile(n) ? GetTrackBits(n) : TRACK_BIT_NONE);
2231
2226
 
2232
2227
                                        if (!IsTileType(n, MP_RAILWAY) ||
2233
2228
                                                        !IsTileOwner(n, owner) ||
2253
2248
static TrackStatus GetTileTrackStatus_Track(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
2254
2249
{
2255
2250
        /* Case of half tile slope with water. */
2256
 
        if (mode == TRANSPORT_WATER && IsPlainRailTile(tile) && GetRailGroundType(tile) == RAIL_GROUND_WATER) {
 
2251
        if (mode == TRANSPORT_WATER && IsPlainRail(tile) && GetRailGroundType(tile) == RAIL_GROUND_WATER) {
2257
2252
                TrackBits tb = GetTrackBits(tile);
2258
2253
                switch (tb) {
2259
2254
                        default: NOT_REACHED();
2556
2551
{
2557
2552
        uint z_old;
2558
2553
        Slope tileh_old = GetTileSlope(tile, &z_old);
2559
 
        if (IsPlainRailTile(tile)) {
 
2554
        if (IsPlainRail(tile)) {
2560
2555
                TrackBits rail_bits = GetTrackBits(tile);
2561
2556
                /* Is there flat water on the lower halftile, that must be cleared expensively? */
2562
2557
                bool was_water = (GetRailGroundType(tile) == RAIL_GROUND_WATER && IsSlopeWithOneCornerRaised(tileh_old));
2621
2616
        GetTileDesc_Track,        // get_tile_desc_proc
2622
2617
        GetTileTrackStatus_Track, // get_tile_track_status_proc
2623
2618
        ClickTile_Track,          // click_tile_proc
2624
 
        AnimateTile_Track,        // animate_tile_proc
 
2619
        NULL,                     // animate_tile_proc
2625
2620
        TileLoop_Track,           // tile_loop_clear
2626
2621
        ChangeTileOwner_Track,    // change_tile_owner_clear
2627
2622
        NULL,                     // get_produced_cargo_proc