File diff r15522:07fd9844efd2 → r15523:81620324a110
src/road_cmd.cpp
Show inline comments
 
/* $Id$ */
 

	
 
/*
 
 * This file is part of OpenTTD.
 
 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
 
 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
/** @file road_cmd.cpp Commands related to road tiles. */
 

	
 
#include "stdafx.h"
 
#include "cmd_helper.h"
 
#include "road_internal.h"
 
#include "landscape.h"
 
#include "viewport_func.h"
 
#include "command_func.h"
 
#include "pathfinder/yapf/yapf_cache.h"
 
#include "depot_base.h"
 
#include "newgrf.h"
 
#include "variables.h"
 
#include "autoslope.h"
 
#include "tunnelbridge_map.h"
 
#include "window_func.h"
 
#include "strings_func.h"
 
#include "vehicle_func.h"
 
#include "sound_func.h"
 
#include "tunnelbridge.h"
 
#include "cheat_type.h"
 
#include "functions.h"
 
#include "effectvehicle_func.h"
 
#include "effectvehicle_base.h"
 
#include "elrail_func.h"
 
#include "roadveh.h"
 
#include "town.h"
 
#include "company_base.h"
 
#include "core/random_func.hpp"
 
#include "newgrf_railtype.h"
 
#include "date_func.h"
 
#include "genworld.h"
 

	
 
#include "table/strings.h"
 

	
 
/**
 
 * Verify whether a road vehicle is available.
 
 * @return \c true if at least one road vehicle is available, \c false if not
 
 */
 
bool RoadVehiclesAreBuilt()
 
{
 
	const RoadVehicle *rv;
 
	FOR_ALL_ROADVEHICLES(rv) return true;
 

	
 
	return false;
 
}
 

	
 
/* Invalid RoadBits on slopes  */
 
static const RoadBits _invalid_tileh_slopes_road[2][15] = {
 
	/* The inverse of the mixable RoadBits on a leveled slope */
 
	{
 
		ROAD_NONE,         // SLOPE_FLAT
 
		ROAD_NE | ROAD_SE, // SLOPE_W
 
		ROAD_NE | ROAD_NW, // SLOPE_S
 

	
 
		ROAD_NE,           // SLOPE_SW
 
		ROAD_NW | ROAD_SW, // SLOPE_E
 
		ROAD_NONE,         // SLOPE_EW
 

	
 
		ROAD_NW,           // SLOPE_SE
 
		ROAD_NONE,         // SLOPE_WSE
 
		ROAD_SE | ROAD_SW, // SLOPE_N
 

	
 
		ROAD_SE,           // SLOPE_NW
 
		ROAD_NONE,         // SLOPE_NS
 
		ROAD_NONE,         // SLOPE_ENW
 

	
 
		ROAD_SW,           // SLOPE_NE
 
		ROAD_NONE,         // SLOPE_SEN
 
		ROAD_NONE          // SLOPE_NWS
 
	},
 
	/* The inverse of the allowed straight roads on a slope
 
	 * (with and without a foundation). */
 
	{
 
		ROAD_NONE, // SLOPE_FLAT
 
		ROAD_NONE, // SLOPE_W    Foundation
 
		ROAD_NONE, // SLOPE_S    Foundation
 

	
 
		ROAD_Y,    // SLOPE_SW
 
		ROAD_NONE, // SLOPE_E    Foundation
 
		ROAD_ALL,  // SLOPE_EW
 

	
 
		ROAD_X,    // SLOPE_SE
 
		ROAD_ALL,  // SLOPE_WSE
 
		ROAD_NONE, // SLOPE_N    Foundation
 

	
 
		ROAD_X,    // SLOPE_NW
 
		ROAD_ALL,  // SLOPE_NS
 
		ROAD_ALL,  // SLOPE_ENW
 

	
 
		ROAD_Y,    // SLOPE_NE
 
		ROAD_ALL,  // SLOPE_SEN
 
		ROAD_ALL   // SLOPE_NW
 
	}
 
};
 

	
 
static Foundation GetRoadFoundation(Slope tileh, RoadBits bits);
 

	
 
/**
 
 * Is it allowed to remove the given road bits from the given tile?
 
 * @param tile      the tile to remove the road from
 
 * @param remove    the roadbits that are going to be removed
 
 * @param owner     the actual owner of the roadbits of the tile
 
 * @param rt        the road type to remove the bits from
 
 * @param flags     command flags
 
 * @param town_check Shall the town rating checked/affected
 
 * @return A succeeded command when it is allowed to remove the road bits, a failed command otherwise.
 
 */
 
CommandCost CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, RoadType rt, DoCommandFlag flags, bool town_check)