comparison src/rail_cmd.cpp @ 9413:512ea64da840 draft

(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
author rubidium <rubidium@openttd.org>
date Thu, 29 May 2008 15:13:28 +0000
parents 12f4585b2124
children b45f1056d60b
comparison
equal deleted inserted replaced
9412:a9c6a921f0aa 9413:512ea64da840
290 290
291 Foundation f_new = GetRailFoundation(tileh, rail_bits | existing); 291 Foundation f_new = GetRailFoundation(tileh, rail_bits | existing);
292 292
293 /* check track/slope combination */ 293 /* check track/slope combination */
294 if ((f_new == FOUNDATION_INVALID) || 294 if ((f_new == FOUNDATION_INVALID) ||
295 ((f_new != FOUNDATION_NONE) && (!_settings.construction.build_on_slopes || _is_old_ai_player)) 295 ((f_new != FOUNDATION_NONE) && (!_settings_game.construction.build_on_slopes || _is_old_ai_player))
296 ) return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); 296 ) return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION);
297 297
298 Foundation f_old = GetRailFoundation(tileh, existing); 298 Foundation f_old = GetRailFoundation(tileh, existing);
299 return CommandCost(EXPENSES_CONSTRUCTION, f_new != f_old ? _price.terraform : (Money)0); 299 return CommandCost(EXPENSES_CONSTRUCTION, f_new != f_old ? _price.terraform : (Money)0);
300 } 300 }
754 * 4) the exit points in the wrong direction 754 * 4) the exit points in the wrong direction
755 */ 755 */
756 756
757 if (tileh != SLOPE_FLAT && ( 757 if (tileh != SLOPE_FLAT && (
758 _is_old_ai_player || 758 _is_old_ai_player ||
759 !_settings.construction.build_on_slopes || 759 !_settings_game.construction.build_on_slopes ||
760 IsSteepSlope(tileh) || 760 IsSteepSlope(tileh) ||
761 !CanBuildDepotByTileh(dir, tileh) 761 !CanBuildDepotByTileh(dir, tileh)
762 )) { 762 )) {
763 return_cmd_error(STR_0007_FLAT_LAND_REQUIRED); 763 return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
764 } 764 }
1222 1222
1223 /* Original railtype we are converting from */ 1223 /* Original railtype we are converting from */
1224 RailType type = GetRailType(tile); 1224 RailType type = GetRailType(tile);
1225 1225
1226 /* Converting to the same type or converting 'hidden' elrail -> rail */ 1226 /* Converting to the same type or converting 'hidden' elrail -> rail */
1227 if (type == totype || (_settings.vehicle.disable_elrails && totype == RAILTYPE_RAIL && type == RAILTYPE_ELECTRIC)) continue; 1227 if (type == totype || (_settings_game.vehicle.disable_elrails && totype == RAILTYPE_RAIL && type == RAILTYPE_ELECTRIC)) continue;
1228 1228
1229 /* Trying to convert other's rail */ 1229 /* Trying to convert other's rail */
1230 if (!CheckTileOwnership(tile)) continue; 1230 if (!CheckTileOwnership(tile)) continue;
1231 1231
1232 /* Vehicle on the tile when not converting Rail <-> ElRail 1232 /* Vehicle on the tile when not converting Rail <-> ElRail
1418 return GetSlopeZ(x, y); 1418 return GetSlopeZ(x, y);
1419 } 1419 }
1420 1420
1421 static void DrawSingleSignal(TileIndex tile, Track track, byte condition, uint image, uint pos) 1421 static void DrawSingleSignal(TileIndex tile, Track track, byte condition, uint image, uint pos)
1422 { 1422 {
1423 bool side = (_settings.vehicle.road_side != 0) && _settings.construction.signal_side; 1423 bool side = (_settings_game.vehicle.road_side != 0) && _settings_game.construction.signal_side;
1424 static const Point SignalPositions[2][12] = { 1424 static const Point SignalPositions[2][12] = {
1425 { /* Signals on the left side */ 1425 { /* Signals on the left side */
1426 /* LEFT LEFT RIGHT RIGHT UPPER UPPER */ 1426 /* LEFT LEFT RIGHT RIGHT UPPER UPPER */
1427 { 8, 5}, {14, 1}, { 1, 14}, { 9, 11}, { 1, 0}, { 3, 10}, 1427 { 8, 5}, {14, 1}, { 1, 14}, { 9, 11}, { 1, 0}, { 3, 10},
1428 /* LOWER LOWER X X Y Y */ 1428 /* LOWER LOWER X X Y Y */
1787 image = dts->ground.sprite; 1787 image = dts->ground.sprite;
1788 if (image != SPR_FLAT_GRASS_TILE) image += rti->total_offset; 1788 if (image != SPR_FLAT_GRASS_TILE) image += rti->total_offset;
1789 1789
1790 /* adjust ground tile for desert 1790 /* adjust ground tile for desert
1791 * don't adjust for snow, because snow in depots looks weird */ 1791 * don't adjust for snow, because snow in depots looks weird */
1792 if (IsSnowRailGround(ti->tile) && _settings.game_creation.landscape == LT_TROPIC) { 1792 if (IsSnowRailGround(ti->tile) && _settings_game.game_creation.landscape == LT_TROPIC) {
1793 if (image != SPR_FLAT_GRASS_TILE) { 1793 if (image != SPR_FLAT_GRASS_TILE) {
1794 image += rti->snow_offset; // tile with tracks 1794 image += rti->snow_offset; // tile with tracks
1795 } else { 1795 } else {
1796 image = SPR_FLAT_SNOWY_TILE; // flat ground 1796 image = SPR_FLAT_SNOWY_TILE; // flat ground
1797 } 1797 }
1951 if (old_ground == RAIL_GROUND_WATER) { 1951 if (old_ground == RAIL_GROUND_WATER) {
1952 TileLoop_Water(tile); 1952 TileLoop_Water(tile);
1953 return; 1953 return;
1954 } 1954 }
1955 1955
1956 switch (_settings.game_creation.landscape) { 1956 switch (_settings_game.game_creation.landscape) {
1957 case LT_ARCTIC: { 1957 case LT_ARCTIC: {
1958 uint z; 1958 uint z;
1959 Slope slope = GetTileSlope(tile, &z); 1959 Slope slope = GetTileSlope(tile, &z);
1960 bool half = false; 1960 bool half = false;
1961 1961
2327 * @param tileh_new New TileSlope. 2327 * @param tileh_new New TileSlope.
2328 * @param rail_bits Trackbits. 2328 * @param rail_bits Trackbits.
2329 */ 2329 */
2330 static CommandCost TestAutoslopeOnRailTile(TileIndex tile, uint flags, uint z_old, Slope tileh_old, uint z_new, Slope tileh_new, TrackBits rail_bits) 2330 static CommandCost TestAutoslopeOnRailTile(TileIndex tile, uint flags, uint z_old, Slope tileh_old, uint z_new, Slope tileh_new, TrackBits rail_bits)
2331 { 2331 {
2332 if (!_settings.construction.build_on_slopes || !AutoslopeEnabled()) return CMD_ERROR; 2332 if (!_settings_game.construction.build_on_slopes || !AutoslopeEnabled()) return CMD_ERROR;
2333 2333
2334 /* Is the slope-rail_bits combination valid in general? I.e. is it save to call GetRailFoundation() ? */ 2334 /* Is the slope-rail_bits combination valid in general? I.e. is it save to call GetRailFoundation() ? */
2335 if (CmdFailed(CheckRailSlope(tileh_new, rail_bits, TRACK_BIT_NONE, tile))) return CMD_ERROR; 2335 if (CmdFailed(CheckRailSlope(tileh_new, rail_bits, TRACK_BIT_NONE, tile))) return CMD_ERROR;
2336 2336
2337 /* Get the slopes on top of the foundations */ 2337 /* Get the slopes on top of the foundations */
2403 if ((flags & DC_EXEC) != 0) SetRailGroundType(tile, RAIL_GROUND_BARREN); 2403 if ((flags & DC_EXEC) != 0) SetRailGroundType(tile, RAIL_GROUND_BARREN);
2404 2404
2405 /* allow terraforming */ 2405 /* allow terraforming */
2406 return CommandCost(EXPENSES_CONSTRUCTION, was_water ? _price.clear_water : (Money)0); 2406 return CommandCost(EXPENSES_CONSTRUCTION, was_water ? _price.clear_water : (Money)0);
2407 } else { 2407 } else {
2408 if (_settings.construction.build_on_slopes && AutoslopeEnabled()) { 2408 if (_settings_game.construction.build_on_slopes && AutoslopeEnabled()) {
2409 switch (GetRailTileType(tile)) { 2409 switch (GetRailTileType(tile)) {
2410 case RAIL_TILE_WAYPOINT: { 2410 case RAIL_TILE_WAYPOINT: {
2411 CommandCost cost = TestAutoslopeOnRailTile(tile, flags, z_old, tileh_old, z_new, tileh_new, GetRailWaypointBits(tile)); 2411 CommandCost cost = TestAutoslopeOnRailTile(tile, flags, z_old, tileh_old, z_new, tileh_new, GetRailWaypointBits(tile));
2412 if (!CmdFailed(cost)) return cost; // allow autoslope 2412 if (!CmdFailed(cost)) return cost; // allow autoslope
2413 break; 2413 break;