src/tunnelbridge_cmd.cpp
branchNewGRF_ports
changeset 10991 d8811e327d12
parent 10731 67db0d431d5e
child 10994 cd9968b6f96b
equal deleted inserted replaced
10731:67db0d431d5e 10991:d8811e327d12
   167 
   167 
   168 	if (bridge_type >= MAX_BRIDGES) return false;
   168 	if (bridge_type >= MAX_BRIDGES) return false;
   169 	if (b->avail_year > _cur_year) return false;
   169 	if (b->avail_year > _cur_year) return false;
   170 
   170 
   171 	max = b->max_length;
   171 	max = b->max_length;
   172 	if (max >= 16 && _settings.construction.longbridges) max = 100;
   172 	if (max >= 16 && _settings_game.construction.longbridges) max = 100;
   173 
   173 
   174 	return b->min_length <= bridge_len && bridge_len <= max;
   174 	return b->min_length <= bridge_len && bridge_len <= max;
   175 }
   175 }
   176 
   176 
   177 /** Build a Bridge
   177 /** Build a Bridge
   309 		/* Do not remove road types when upgrading a bridge */
   309 		/* Do not remove road types when upgrading a bridge */
   310 		roadtypes |= GetRoadTypes(tile_start);
   310 		roadtypes |= GetRoadTypes(tile_start);
   311 	} else {
   311 	} else {
   312 		/* Build a new bridge. */
   312 		/* Build a new bridge. */
   313 
   313 
   314 		bool allow_on_slopes = (!_is_old_ai_player && _settings.construction.build_on_slopes);
   314 		bool allow_on_slopes = (!_is_old_ai_player && _settings_game.construction.build_on_slopes);
   315 
   315 
   316 		/* Try and clear the start landscape */
   316 		/* Try and clear the start landscape */
   317 		ret = DoCommand(tile_start, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
   317 		ret = DoCommand(tile_start, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
   318 		if (CmdFailed(ret)) return ret;
   318 		if (CmdFailed(ret)) return ret;
   319 		cost = ret;
   319 		cost = ret;
   574 	/* Floods can remove anything as well as the scenario editor */
   574 	/* Floods can remove anything as well as the scenario editor */
   575 	if (_current_player == OWNER_WATER || _game_mode == GM_EDITOR) return true;
   575 	if (_current_player == OWNER_WATER || _game_mode == GM_EDITOR) return true;
   576 	/* Obviously if the bridge/tunnel belongs to us, or no-one, we can remove it */
   576 	/* Obviously if the bridge/tunnel belongs to us, or no-one, we can remove it */
   577 	if (CheckTileOwnership(tile) || IsTileOwner(tile, OWNER_NONE)) return true;
   577 	if (CheckTileOwnership(tile) || IsTileOwner(tile, OWNER_NONE)) return true;
   578 	/* Otherwise we can only remove town-owned stuff with extra patch-settings, or cheat */
   578 	/* Otherwise we can only remove town-owned stuff with extra patch-settings, or cheat */
   579 	if (IsTileOwner(tile, OWNER_TOWN) && (_settings.construction.extra_dynamite || _cheats.magic_bulldozer.value)) return true;
   579 	if (IsTileOwner(tile, OWNER_TOWN) && (_settings_game.construction.extra_dynamite || _cheats.magic_bulldozer.value)) return true;
   580 	return false;
   580 	return false;
   581 }
   581 }
   582 
   582 
   583 static CommandCost DoClearTunnel(TileIndex tile, uint32 flags)
   583 static CommandCost DoClearTunnel(TileIndex tile, uint32 flags)
   584 {
   584 {
  1121 				pal = PALETTE_TO_TRANSPARENT;
  1121 				pal = PALETTE_TO_TRANSPARENT;
  1122 			}
  1122 			}
  1123 
  1123 
  1124 			DrawGroundSpriteAt(image, pal, x, y, z);
  1124 			DrawGroundSpriteAt(image, pal, x, y, z);
  1125 		}
  1125 		}
  1126 	} else if (_settings.gui.bridge_pillars) {
  1126 	} else if (_settings_client.gui.bridge_pillars) {
  1127 		/* draw pillars below for high bridges */
  1127 		/* draw pillars below for high bridges */
  1128 		DrawBridgePillars(psid, ti, axis, type, x, y, z);
  1128 		DrawBridgePillars(psid, ti, axis, type, x, y, z);
  1129 	}
  1129 	}
  1130 }
  1130 }
  1131 
  1131 
  1198 }
  1198 }
  1199 
  1199 
  1200 static void TileLoop_TunnelBridge(TileIndex tile)
  1200 static void TileLoop_TunnelBridge(TileIndex tile)
  1201 {
  1201 {
  1202 	bool snow_or_desert = HasTunnelBridgeSnowOrDesert(tile);
  1202 	bool snow_or_desert = HasTunnelBridgeSnowOrDesert(tile);
  1203 	switch (_settings.game_creation.landscape) {
  1203 	switch (_settings_game.game_creation.landscape) {
  1204 		case LT_ARCTIC:
  1204 		case LT_ARCTIC:
  1205 			if (snow_or_desert != (GetTileZ(tile) > GetSnowLine())) {
  1205 			if (snow_or_desert != (GetTileZ(tile) > GetSnowLine())) {
  1206 				SetTunnelBridgeSnowOrDesert(tile, !snow_or_desert);
  1206 				SetTunnelBridgeSnowOrDesert(tile, !snow_or_desert);
  1207 				MarkTileDirtyByTile(tile);
  1207 				MarkTileDirtyByTile(tile);
  1208 			}
  1208 			}
  1386 	return VETSB_CONTINUE;
  1386 	return VETSB_CONTINUE;
  1387 }
  1387 }
  1388 
  1388 
  1389 static CommandCost TerraformTile_TunnelBridge(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new)
  1389 static CommandCost TerraformTile_TunnelBridge(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new)
  1390 {
  1390 {
  1391 	if (_settings.construction.build_on_slopes && AutoslopeEnabled() && IsBridge(tile)) {
  1391 	if (_settings_game.construction.build_on_slopes && AutoslopeEnabled() && IsBridge(tile)) {
  1392 		DiagDirection direction = GetTunnelBridgeDirection(tile);
  1392 		DiagDirection direction = GetTunnelBridgeDirection(tile);
  1393 		Axis axis = DiagDirToAxis(direction);
  1393 		Axis axis = DiagDirToAxis(direction);
  1394 		CommandCost res;
  1394 		CommandCost res;
  1395 		uint z_old;
  1395 		uint z_old;
  1396 		Slope tileh_old = GetTileSlope(tile, &z_old);
  1396 		Slope tileh_old = GetTileSlope(tile, &z_old);