Changeset - r12967:be92c1cb71c8
[Not reviewed]
master
0 10 0
rubidium - 15 years ago 2009-09-08 10:12:13
rubidium@openttd.org
(svn r17471) -Change: when removing a station or waypoint keep the rail unless Ctrl is pressed. This makes the behaviour consistent between the two.
10 files changed with 82 insertions and 67 deletions:
0 comments (0 inline, 0 general)
bin/ai/compat_0.7.nut
Show inline comments
 
@@ -73,6 +73,16 @@ AISubsidy.GetDestination <- function(sub
 
}
 

	
 
AITown.GetMaxProduction <- function(town_id, cargo_id)
 
{
 
	return AITown.GetLastMonthProduction(town_id, cargo_id);
 
}
 

	
 
AIRail.RemoveRailWaypoint <- function(tile)
 
{
 
	return AIRail.RemoveRailWaypointTileRect(tile, tile, true);
 
}
 

	
 
AIRail.RemoveRailStationTileRect <- function(tile, tile2)
 
{
 
	return AIRail.RemoveRailStationTileRectangle(tile, tile2, false);
 
}
bin/ai/regression/regression.nut
Show inline comments
 
@@ -961,13 +961,13 @@ function Regression::Rail()
 
	print("  Station");
 
	print("    BuildRailStation():            " + AIRail.BuildRailStation(0, AIRail.RAILTRACK_NE_SW, 1, 1, AIStation.STATION_NEW));
 
	print("    BuildRailStation():            " + AIRail.BuildRailStation(7958, AIRail.RAILTRACK_NE_SW, 4, 5, AIStation.STATION_NEW));
 
	print("    IsRailStationTile():           " + AIRail.IsRailStationTile(7957));
 
	print("    IsRailStationTile():           " + AIRail.IsRailStationTile(7958));
 
	print("    IsRailStationTile():           " + AIRail.IsRailStationTile(7959));
 
	print("    RemoveRailStationTileRect():   " + AIRail.RemoveRailStationTileRect(7959, 7959));
 
	print("    RemoveRailStationTileRectangle():" + AIRail.RemoveRailStationTileRectangle(7959, 7959, false));
 
	print("    IsRailStationTile():           " + AIRail.IsRailStationTile(7957));
 
	print("    IsRailStationTile():           " + AIRail.IsRailStationTile(7958));
 
	print("    IsRailStationTile():           " + AIRail.IsRailStationTile(7959));
 
	print("    DemolishTile():                " + AITile.DemolishTile(7960));
 
	print("    IsRailStationTile():           " + AIRail.IsRailStationTile(7957));
 
	print("    IsRailStationTile():           " + AIRail.IsRailStationTile(7958));
bin/ai/regression/regression.txt
Show inline comments
 
@@ -7134,13 +7134,13 @@
 
  Station
 
    BuildRailStation():            false
 
    BuildRailStation():            true
 
    IsRailStationTile():           false
 
    IsRailStationTile():           true
 
    IsRailStationTile():           true
 
    RemoveRailStationTileRect():   true
 
    RemoveRailStationTileRectangle():true
 
    IsRailStationTile():           false
 
    IsRailStationTile():           true
 
    IsRailStationTile():           false
 
    DemolishTile():                true
 
    IsRailStationTile():           false
 
    IsRailStationTile():           false
src/ai/api/ai_changelog.hpp
Show inline comments
 
@@ -13,45 +13,57 @@
 
 * bug fixes can be found in the normal changelog. Note that removed API
 
 * functions may still be available if you return an older API version
 
 * in GetAPIVersion() in info.nut.
 
 *
 
 * \b 0.8.0
 
 *
 
 * 0.8.0 is not yet released. The following changes are not set in stone yet.
 
 *
 
 * API additions:
 
 * \li AIBaseStation
 
 * \li AIBuoyList
 
 * \li AIEventCompanyAskMerger
 
 * \li AIRail::RemoveRailWaypointTileRect
 
 * \li AIRail::RemoveRailStationTileRectangle
 
 * \li AIRail::RemoveRailWaypointTileRectangle
 
 * \li AISubsidy::SubsidyParticipantType
 
 * \li AISubsidy::GetSourceType
 
 * \li AISubsidy::GetSourceIndex
 
 * \li AISubsidy::GetDestinationType
 
 * \li AISubsidy::GetDestinationIndex
 
 * \li AITown::GetLastMonthTransportedPercentage
 
 * \li AIIndustry::GetLastMonthTransportedPercentage
 
 *
 
 * API removals:
 
 * \li AIOrder::ChangeOrder, use AIOrder::SetOrderFlags instead
 
 * \li AIRail::RemoveRailStationTileRect, use AIRail::RemoveRailStationTileRectangle instead
 
 * \li AIRail::RemoveRailWaypoint, use AIRail::RemoveRailWaypointTileRectangle instead
 
 * \li AISign::GetMaxSignID, use AISignList instead
 
 * \li AITile::GetHeight, use AITile::GetMinHeight/GetMaxHeight/GetCornerHeight instead
 
 * \li AISubsidy::SourceIsTown, use AISubsidy::GetSourceType instead
 
 * \li AISubsidy::GetSource, use AISubsidy::GetSourceIndex instead
 
 * \li AISubsidy::DestinationIsTown, use AISubsidy::GetDestinationType instead
 
 * \li AISubsidy::GetDestination, use AISubsidy::GetDestinationIndex instead
 
 * \li AITile::GetHeight, use AITile::GetMinHeight/GetMaxHeight/GetCornerHeight instead
 
 * \li AITown::GetMaxProduction, use AITown::GetLastMonthProduction instead
 
 * \li AIWaypoint::WAYPOINT_INVALID, use AIBaseStation::STATION_INVALID instead
 
 *
 
 * Other changes:
 
 * \li The GetName / SetName / GetLocation functions were moved from AIStation
 
 *     and AIWaypoint to AIBaseStation, but you can still use AIStation.GetName
 
 *     as before
 
 * \li The GetConstructionDate function was moved from AIStation to
 
 *     AIBaseStation, but can still be used as AIStation.GetConstructionDate
 
 * \li WaypointID was replaced by StationID. All WaypointIDs from previous
 
 *     savegames are invalid. Use STATION_INVALID instead of WAYPOINT_INVALID
 
 * \li AIVehicleList_Station now also works for waypoints
 
 * \li Stations can be build over rail without signals that is in the right
 
 *     direction for the to-be built station. It will also convert the rail if
 
 *     the station's rail type supports the old type.
 
 * \li GetAPIVersion() was added as function to info.nut. If it does not exist
 
 *     API version 0.7 is assumed. This function should return the major and
 
 *     minor number of the stable version of the API the AI is written against.
 
 *     For 0.7.2 that would be 0.7, for 1.1.3 it would be 1.1, etc.
 
 *
 
 * \b 0.7.3
 
 *
 
 * API additions:
 
 * \li AIAbstractList::SORT_ASCENDING
 
 * \li AIAbstractList::SORT_DESCENDING
src/ai/api/ai_rail.cpp
Show inline comments
 
@@ -184,34 +184,26 @@
 
	EnforcePrecondition(false, GetRailTracks(tile) == RAILTRACK_NE_SW || GetRailTracks(tile) == RAILTRACK_NW_SE);
 
	EnforcePrecondition(false, IsRailTypeAvailable(GetCurrentRailType()));
 

	
 
	return AIObject::DoCommand(tile, GetCurrentRailType() | (GetRailTracks(tile) == RAILTRACK_NE_SW ? AXIS_X : AXIS_Y) << 4 | 1 << 8 | 1 << 16, STAT_CLASS_WAYP | INVALID_STATION << 16, CMD_BUILD_RAIL_WAYPOINT);
 
}
 

	
 
/* static */ bool AIRail::RemoveRailWaypoint(TileIndex tile)
 
{
 
	EnforcePrecondition(false, ::IsValidTile(tile));
 
	EnforcePrecondition(false, IsRailWaypointTile(tile));
 

	
 
	return AIObject::DoCommand(tile, 0, 0, CMD_REMOVE_FROM_RAIL_WAYPOINT);
 
}
 

	
 
/* static */ bool AIRail::RemoveRailWaypointTileRect(TileIndex tile, TileIndex tile2)
 
/* static */ bool AIRail::RemoveRailWaypointTileRectangle(TileIndex tile, TileIndex tile2, bool keep_rail)
 
{
 
	EnforcePrecondition(false, ::IsValidTile(tile));
 
	EnforcePrecondition(false, ::IsValidTile(tile2));
 

	
 
	return AIObject::DoCommand(tile, tile2, 0, CMD_REMOVE_FROM_RAIL_WAYPOINT);
 
	return AIObject::DoCommand(tile, tile2, keep_rail ? 1 : 0, CMD_REMOVE_FROM_RAIL_WAYPOINT);
 
}
 

	
 
/* static */ bool AIRail::RemoveRailStationTileRect(TileIndex tile, TileIndex tile2)
 
/* static */ bool AIRail::RemoveRailStationTileRectangle(TileIndex tile, TileIndex tile2, bool keep_rail)
 
{
 
	EnforcePrecondition(false, ::IsValidTile(tile));
 
	EnforcePrecondition(false, ::IsValidTile(tile2));
 

	
 
	return AIObject::DoCommand(tile, tile2, 0, CMD_REMOVE_FROM_RAIL_STATION);
 
	return AIObject::DoCommand(tile, tile2, keep_rail ? 1 : 0, CMD_REMOVE_FROM_RAIL_STATION);
 
}
 

	
 
/* static */ uint AIRail::GetRailTracks(TileIndex tile)
 
{
 
	if (!IsRailTile(tile)) return RAILTRACK_INVALID;
 

	
src/ai/api/ai_rail.hpp
Show inline comments
 
@@ -277,39 +277,32 @@ public:
 
	 * @exception AIError::ERR_FLAT_LAND_REQUIRED
 
	 * @return Whether the rail waypoint has been/can be build or not.
 
	 */
 
	static bool BuildRailWaypoint(TileIndex tile);
 

	
 
	/**
 
	 * Remove a rail waypoint.
 
	 * @param tile Place to remove the waypoint from.
 
	 * @pre AIMap::IsValidTile(tile).
 
	 * @pre IsRailWaypointTile(tile).
 
	 * @return Whether the rail waypoint has been/can be removed or not.
 
	 */
 
	static bool RemoveRailWaypoint(TileIndex tile);
 

	
 
	/**
 
	 * Remove all rail waypoint pieces within a rectangle on the map.
 
	 * @param tile One corner of the rectangle to clear.
 
	 * @param tile2 The oppposite corner.
 
	 * @param keep_rail Whether to keep the rail after removal.
 
	 * @pre IsValidTile(tile).
 
	 * @pre IsValidTile(tile2).
 
	 * @return Whether at least one tile has been/can be cleared or not.
 
	 */
 
	static bool RemoveRailWaypointTileRect(TileIndex tile, TileIndex tile2);
 
	static bool RemoveRailWaypointTileRectangle(TileIndex tile, TileIndex tile2, bool keep_rail);
 

	
 
	/**
 
	 * Remove all rail station platform pieces within a rectangle on the map.
 
	 * @param tile One corner of the rectangle to clear.
 
	 * @param tile2 The oppposite corner.
 
	 * @param keep_rail Whether to keep the rail after removal.
 
	 * @pre IsValidTile(tile).
 
	 * @pre IsValidTile(tile2).
 
	 * @return Whether at least one tile has been/can be cleared or not.
 
	 */
 
	static bool RemoveRailStationTileRect(TileIndex tile, TileIndex tile2);
 
	static bool RemoveRailStationTileRectangle(TileIndex tile, TileIndex tile2, bool keep_rail);
 

	
 
	/**
 
	 * Get all RailTracks on the given tile.
 
	 * @note A depot has no railtracks.
 
	 * @param tile The tile to check.
 
	 * @pre IsRailTile(tile).
src/ai/api/ai_rail.hpp.sq
Show inline comments
 
@@ -65,39 +65,38 @@ void SQAIRail_Register(Squirrel *engine)
 
	AIError::RegisterErrorMap(STR_ERROR_NONUNIFORM_STATIONS_DISALLOWED, AIRail::ERR_NONUNIFORM_STATIONS_DISABLED);
 

	
 
	AIError::RegisterErrorMapString(AIRail::ERR_CROSSING_ON_ONEWAY_ROAD,      "ERR_CROSSING_ON_ONEWAY_ROAD");
 
	AIError::RegisterErrorMapString(AIRail::ERR_UNSUITABLE_TRACK,             "ERR_UNSUITABLE_TRACK");
 
	AIError::RegisterErrorMapString(AIRail::ERR_NONUNIFORM_STATIONS_DISABLED, "ERR_NONUNIFORM_STATIONS_DISABLED");
 

	
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::IsRailTile,                 "IsRailTile",                 2, ".i");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::IsLevelCrossingTile,        "IsLevelCrossingTile",        2, ".i");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::IsRailDepotTile,            "IsRailDepotTile",            2, ".i");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::IsRailStationTile,          "IsRailStationTile",          2, ".i");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::IsRailWaypointTile,         "IsRailWaypointTile",         2, ".i");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::IsRailTypeAvailable,        "IsRailTypeAvailable",        2, ".i");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::GetCurrentRailType,         "GetCurrentRailType",         1, ".");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::SetCurrentRailType,         "SetCurrentRailType",         2, ".i");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::TrainCanRunOnRail,          "TrainCanRunOnRail",          3, ".ii");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::TrainHasPowerOnRail,        "TrainHasPowerOnRail",        3, ".ii");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::GetRailType,                "GetRailType",                2, ".i");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::ConvertRailType,            "ConvertRailType",            4, ".iii");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::GetRailDepotFrontTile,      "GetRailDepotFrontTile",      2, ".i");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::GetRailStationDirection,    "GetRailStationDirection",    2, ".i");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::BuildRailDepot,             "BuildRailDepot",             3, ".ii");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::BuildRailStation,           "BuildRailStation",           6, ".iiiii");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::BuildNewGRFRailStation,     "BuildNewGRFRailStation",     11, ".iiiiiiiiib");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::BuildRailWaypoint,          "BuildRailWaypoint",          2, ".i");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::RemoveRailWaypoint,         "RemoveRailWaypoint",         2, ".i");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::RemoveRailWaypointTileRect, "RemoveRailWaypointTileRect", 3, ".ii");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::RemoveRailStationTileRect,  "RemoveRailStationTileRect",  3, ".ii");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::GetRailTracks,              "GetRailTracks",              2, ".i");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::BuildRailTrack,             "BuildRailTrack",             3, ".ii");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::RemoveRailTrack,            "RemoveRailTrack",            3, ".ii");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::AreTilesConnected,          "AreTilesConnected",          4, ".iii");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::BuildRail,                  "BuildRail",                  4, ".iii");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::RemoveRail,                 "RemoveRail",                 4, ".iii");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::GetSignalType,              "GetSignalType",              3, ".ii");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::BuildSignal,                "BuildSignal",                4, ".iii");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::RemoveSignal,               "RemoveSignal",               3, ".ii");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::IsRailTile,                      "IsRailTile",                      2, ".i");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::IsLevelCrossingTile,             "IsLevelCrossingTile",             2, ".i");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::IsRailDepotTile,                 "IsRailDepotTile",                 2, ".i");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::IsRailStationTile,               "IsRailStationTile",               2, ".i");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::IsRailWaypointTile,              "IsRailWaypointTile",              2, ".i");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::IsRailTypeAvailable,             "IsRailTypeAvailable",             2, ".i");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::GetCurrentRailType,              "GetCurrentRailType",              1, ".");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::SetCurrentRailType,              "SetCurrentRailType",              2, ".i");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::TrainCanRunOnRail,               "TrainCanRunOnRail",               3, ".ii");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::TrainHasPowerOnRail,             "TrainHasPowerOnRail",             3, ".ii");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::GetRailType,                     "GetRailType",                     2, ".i");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::ConvertRailType,                 "ConvertRailType",                 4, ".iii");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::GetRailDepotFrontTile,           "GetRailDepotFrontTile",           2, ".i");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::GetRailStationDirection,         "GetRailStationDirection",         2, ".i");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::BuildRailDepot,                  "BuildRailDepot",                  3, ".ii");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::BuildRailStation,                "BuildRailStation",                6, ".iiiii");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::BuildNewGRFRailStation,          "BuildNewGRFRailStation",          11, ".iiiiiiiiib");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::BuildRailWaypoint,               "BuildRailWaypoint",               2, ".i");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::RemoveRailWaypointTileRectangle, "RemoveRailWaypointTileRectangle", 4, ".iib");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::RemoveRailStationTileRectangle,  "RemoveRailStationTileRectangle",  4, ".iib");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::GetRailTracks,                   "GetRailTracks",                   2, ".i");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::BuildRailTrack,                  "BuildRailTrack",                  3, ".ii");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::RemoveRailTrack,                 "RemoveRailTrack",                 3, ".ii");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::AreTilesConnected,               "AreTilesConnected",               4, ".iii");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::BuildRail,                       "BuildRail",                       4, ".iii");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::RemoveRail,                      "RemoveRail",                      4, ".iii");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::GetSignalType,                   "GetSignalType",                   3, ".ii");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::BuildSignal,                     "BuildSignal",                     4, ".iii");
 
	SQAIRail.DefSQStaticMethod(engine, &AIRail::RemoveSignal,                    "RemoveSignal",                    3, ".ii");
 

	
 
	SQAIRail.PostRegister(engine);
 
}
src/lang/english.txt
Show inline comments
 
@@ -1844,13 +1844,13 @@ STR_RAIL_TOOLBAR_TOOLTIP_BUILD_AUTORAIL 
 
STR_RAIL_TOOLBAR_TOOLTIP_BUILD_TRAIN_DEPOT_FOR_BUILDING         :{BLACK}Build train depot (for buying and servicing trains)
 
STR_RAIL_TOOLBAR_TOOLTIP_CONVERT_RAIL_TO_WAYPOINT               :{BLACK}Convert rail to waypoint. Ctrl enables joining waypoints
 
STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_STATION                 :{BLACK}Build railway station. Ctrl enables joining stations
 
STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_SIGNALS                 :{BLACK}Build railway signals. Ctrl toggles semaphore/light signals{}Dragging builds signals along a straight stretch of rail. Ctrl builds signals till the next junction{}Ctrl+Click toggles opening the signal selection window
 
STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_BRIDGE                  :{BLACK}Build railway bridge
 
STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_TUNNEL                  :{BLACK}Build railway tunnel
 
STR_RAIL_TOOLBAR_TOOLTIP_TOGGLE_BUILD_REMOVE_FOR                :{BLACK}Toggle build/remove for railway track and signals
 
STR_RAIL_TOOLBAR_TOOLTIP_TOGGLE_BUILD_REMOVE_FOR                :{BLACK}Toggle build/remove for railway track, signals, waypoints and stations. Ctrl+Click will leave track when removing waypoints and stations
 
STR_RAIL_TOOLBAR_TOOLTIP_CONVERT_RAIL                           :{BLACK}Convert/Upgrade the type of rail
 

	
 
# Rail depot construction window
 
STR_BUILD_DEPOT_TRAIN_ORIENTATION_CAPTION                       :{WHITE}Train Depot Orientation
 
STR_BUILD_DEPOT_TRAIN_ORIENTATION_TOOLTIP                       :{BLACK}Select railway depot orientation
 

	
src/rail_gui.cpp
Show inline comments
 
@@ -766,20 +766,20 @@ struct BuildRailToolbarWindow : Window {
 

	
 
				case DDSP_REMOVE_STATION:
 
				case DDSP_BUILD_STATION:
 
					if (this->IsWidgetLowered(RTW_BUILD_STATION)) {
 
						/* Station */
 
						if (_remove_button_clicked) {
 
							DoCommandP(end_tile, start_tile, 0, CMD_REMOVE_FROM_RAIL_STATION | CMD_MSG(STR_ERROR_CAN_T_REMOVE_PART_OF_STATION), CcPlaySound1E);
 
							DoCommandP(end_tile, start_tile, _ctrl_pressed ? 0 : 1, CMD_REMOVE_FROM_RAIL_STATION | CMD_MSG(STR_ERROR_CAN_T_REMOVE_PART_OF_STATION), CcPlaySound1E);
 
						} else {
 
							HandleStationPlacement(start_tile, end_tile);
 
						}
 
					} else {
 
						/* Waypoint */
 
						if (_remove_button_clicked) {
 
							DoCommandP(end_tile, start_tile, 0, CMD_REMOVE_FROM_RAIL_WAYPOINT | CMD_MSG(STR_ERROR_CAN_T_REMOVE_TRAIN_WAYPOINT), CcPlaySound1E);
 
							DoCommandP(end_tile, start_tile, _ctrl_pressed ? 0 : 1, CMD_REMOVE_FROM_RAIL_WAYPOINT | CMD_MSG(STR_ERROR_CAN_T_REMOVE_TRAIN_WAYPOINT), CcPlaySound1E);
 
						} else {
 
							TileArea ta(start_tile, end_tile);
 
							uint32 p1 = _cur_railtype | (select_method == VPM_FIX_X ? AXIS_X : AXIS_Y) << 4 | ta.w << 8 | ta.h << 16 | _ctrl_pressed << 24;
 
							uint32 p2 = STAT_CLASS_WAYP | _cur_waypoint_type << 8 | INVALID_STATION << 16;
 

	
 
							CommandContainer cmdcont = { ta.tile, p1, p2, CMD_BUILD_RAIL_WAYPOINT | CMD_MSG(STR_ERROR_CAN_T_BUILD_TRAIN_WAYPOINT), CcPlaySound1E, "" };
src/station_cmd.cpp
Show inline comments
 
@@ -1214,20 +1214,22 @@ restart:
 
/**
 
 * Remove a number of tiles from any rail station within the area.
 
 * @param ta the area to clear station tile from
 
 * @param affected_stations the stations affected
 
 * @param flags the command flags
 
 * @param removal_cost the cost for removing the tile
 
 * @param keep_rail whether to keep the rail of the station
 
 * @tparam T the type of station to remove
 
 * @return the number of cleared tiles or an error
 
 */
 
template <class T>
 
CommandCost RemoveFromRailBaseStation(TileArea ta, SmallVector<T *, 4> &affected_stations, DoCommandFlag flags, Money removal_cost)
 
CommandCost RemoveFromRailBaseStation(TileArea ta, SmallVector<T *, 4> &affected_stations, DoCommandFlag flags, Money removal_cost, bool keep_rail)
 
{
 
	/* Count of the number of tiles removed */
 
	int quantity = 0;
 
	CommandCost total_cost(EXPENSES_CONSTRUCTION);
 

	
 
	/* Do the action for every tile into the area */
 
	TILE_LOOP(tile, ta.w, ta.h, ta.tile) {
 
		/* Make sure the specified tile is a rail station */
 
		if (!HasStationTileRail(tile)) continue;
 

	
 
@@ -1264,13 +1266,13 @@ CommandCost RemoveFromRailBaseStation(Ti
 
					Vehicle *temp = v;
 
					for (; temp->Next() != NULL; temp = temp->Next()) ;
 
					if (IsRailStationTile(temp->tile)) SetRailStationPlatformReservation(temp->tile, TrackdirToExitdir(ReverseTrackdir(temp->GetVehicleTrackdir())), false);
 
				}
 
			}
 

	
 
			if (st->facilities & FACIL_WAYPOINT) {
 
			if (keep_rail) {
 
				MakeRailNormal(tile, owner, TrackToTrackBits(track), rt);
 
			} else {
 
				DoClearSquare(tile);
 
			}
 
			st->rect.AfterRemoveTile(st, tile);
 
			AddTrackToSignalBuffer(tile, track, owner);
 
@@ -1285,12 +1287,16 @@ CommandCost RemoveFromRailBaseStation(Ti
 
				if (IsRailStationTile(v->tile)) SetRailStationPlatformReservation(v->tile, TrackdirToExitdir(v->GetVehicleTrackdir()), true);
 
				TryPathReserve(v, true, true);
 
				for (; v->Next() != NULL; v = v->Next()) ;
 
				if (IsRailStationTile(v->tile)) SetRailStationPlatformReservation(v->tile, TrackdirToExitdir(ReverseTrackdir(v->GetVehicleTrackdir())), true);
 
			}
 
		}
 
		if (keep_rail) {
 
			/* Don't refund the 'steel' of the track! */
 
			total_cost.AddCost(-_price.remove_rail);
 
		}
 
	}
 

	
 
	if (quantity == 0) return CMD_ERROR;
 

	
 
	for (T **stp = affected_stations.Begin(); stp != affected_stations.End(); stp++) {
 
		T *st = *stp;
 
@@ -1307,33 +1313,35 @@ CommandCost RemoveFromRailBaseStation(Ti
 
			InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_TRAINS);
 
			st->UpdateVirtCoord();
 
			DeleteStationIfEmpty(st);
 
		}
 
	}
 

	
 
	return CommandCost(EXPENSES_CONSTRUCTION, quantity * removal_cost);
 
	total_cost.AddCost(quantity * removal_cost);
 
	return total_cost;
 
}
 

	
 
/** Remove a single tile from a rail station.
 
 * This allows for custom-built station with holes and weird layouts
 
 * @param start tile of station piece to remove
 
 * @param flags operation to perform
 
 * @param p1 start_tile
 
 * @param p2 unused
 
 * @param p2 various bitstuffed elements
 
 * - p2 = bit 0 - if set keep the rail
 
 * @param text unused
 
 * @return cost of operation or error
 
 */
 
CommandCost CmdRemoveFromRailStation(TileIndex start, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
{
 
	TileIndex end = p1 == 0 ? start : p1;
 
	if (start >= MapSize() || end >= MapSize()) return CMD_ERROR;
 

	
 
	TileArea ta(start, end);
 
	SmallVector<Station *, 4> affected_stations;
 

	
 
	CommandCost ret = RemoveFromRailBaseStation(ta, affected_stations, flags, _price.remove_rail_station);
 
	CommandCost ret = RemoveFromRailBaseStation(ta, affected_stations, flags, _price.remove_rail_station, HasBit(p2, 0));
 
	if (ret.Failed()) return ret;
 

	
 
	/* Do all station specific functions here. */
 
	for (Station **stp = affected_stations.Begin(); stp != affected_stations.End(); stp++) {
 
		Station *st = *stp;
 

	
 
@@ -1348,25 +1356,26 @@ CommandCost CmdRemoveFromRailStation(Til
 

	
 
/** Remove a single tile from a waypoint.
 
 * This allows for custom-built waypoint with holes and weird layouts
 
 * @param start tile of waypoint piece to remove
 
 * @param flags operation to perform
 
 * @param p1 start_tile
 
 * @param p2 unused
 
 * @param p2 various bitstuffed elements
 
 * - p2 = bit 0 - if set keep the rail
 
 * @param text unused
 
 * @return cost of operation or error
 
 */
 
CommandCost CmdRemoveFromRailWaypoint(TileIndex start, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
{
 
	TileIndex end = p1 == 0 ? start : p1;
 
	if (start >= MapSize() || end >= MapSize()) return CMD_ERROR;
 

	
 
	TileArea ta(start, end);
 
	SmallVector<Waypoint *, 4> affected_stations;
 

	
 
	return RemoveFromRailBaseStation(ta, affected_stations, flags, _price.remove_train_depot);
 
	return RemoveFromRailBaseStation(ta, affected_stations, flags, _price.remove_train_depot, HasBit(p2, 0));
 
}
 

	
 

	
 
/**
 
 * Remove a rail road station/waypoint
 
 * @param st The station/waypoint to remove the rail part from
0 comments (0 inline, 0 general)