Changeset - r12542:0440fd34fe28
[Not reviewed]
master
0 6 0
rubidium - 15 years ago 2009-07-29 22:32:20
rubidium@openttd.org
(svn r16990) -Codechange: unify some (command) naming w.r.t. stations/waypoints.
6 files changed with 34 insertions and 34 deletions:
0 comments (0 inline, 0 general)
src/ai/api/ai_rail.cpp
Show inline comments
 
@@ -135,13 +135,13 @@
 
	EnforcePrecondition(false, IsRailTypeAvailable(GetCurrentRailType()));
 
	EnforcePrecondition(false, station_id == AIStation::STATION_NEW || station_id == AIStation::STATION_JOIN_ADJACENT || AIStation::IsValidStation(station_id));
 

	
 
	uint32 p1 = GetCurrentRailType() | (platform_length << 16) | (num_platforms << 8);
 
	if (direction == RAILTRACK_NW_SE) p1 |= (1 << 4);
 
	if (station_id != AIStation::STATION_JOIN_ADJACENT) p1 |= (1 << 24);
 
	return AIObject::DoCommand(tile, p1, (AIStation::IsValidStation(station_id) ? station_id : INVALID_STATION) << 16, CMD_BUILD_RAILROAD_STATION);
 
	return AIObject::DoCommand(tile, p1, (AIStation::IsValidStation(station_id) ? station_id : INVALID_STATION) << 16, CMD_BUILD_RAIL_STATION);
 
}
 

	
 
/* static */ bool AIRail::BuildNewGRFRailStation(TileIndex tile, RailTrack direction, uint num_platforms, uint platform_length, StationID station_id, CargoID cargo_id, IndustryType source_industry, IndustryType goal_industry, int distance, bool source_station)
 
{
 
	EnforcePrecondition(false, ::IsValidTile(tile));
 
	EnforcePrecondition(false, direction == RAILTRACK_NW_SE || direction == RAILTRACK_NE_SW);
 
@@ -164,39 +164,39 @@
 
			DEBUG(grf, 1, "%s returned an invalid station ID for 'AI construction/purchase selection (18)' callback", file->filename);
 
		} else {
 
			p2 |= spec->sclass | index << 8;
 
		}
 

	
 
	}
 
	return AIObject::DoCommand(tile, p1, p2, CMD_BUILD_RAILROAD_STATION);
 
	return AIObject::DoCommand(tile, p1, p2, CMD_BUILD_RAIL_STATION);
 
}
 

	
 
/* static */ bool AIRail::BuildRailWaypoint(TileIndex tile)
 
{
 
	EnforcePrecondition(false, ::IsValidTile(tile));
 
	EnforcePrecondition(false, IsRailTile(tile));
 
	EnforcePrecondition(false, GetRailTracks(tile) == RAILTRACK_NE_SW || GetRailTracks(tile) == RAILTRACK_NW_SE);
 
	EnforcePrecondition(false, IsRailTypeAvailable(GetCurrentRailType()));
 

	
 
	return AIObject::DoCommand(tile, 0, 0, CMD_BUILD_TRAIN_WAYPOINT);
 
	return AIObject::DoCommand(tile, 0, 0, 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_TRAIN_WAYPOINT);
 
	return AIObject::DoCommand(tile, 0, 0, CMD_REMOVE_FROM_RAIL_WAYPOINT);
 
}
 

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

	
 
	return AIObject::DoCommand(tile, tile2, 0, CMD_REMOVE_FROM_RAILROAD_STATION);
 
	return AIObject::DoCommand(tile, tile2, 0, CMD_REMOVE_FROM_RAIL_STATION);
 
}
 

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

	
src/command.cpp
Show inline comments
 
@@ -42,14 +42,14 @@ DEF_COMMAND(CmdBuildSingleRail);
 
DEF_COMMAND(CmdRemoveSingleRail);
 

	
 
DEF_COMMAND(CmdLandscapeClear);
 

	
 
DEF_COMMAND(CmdBuildBridge);
 

	
 
DEF_COMMAND(CmdBuildRailroadStation);
 
DEF_COMMAND(CmdRemoveFromRailroadStation);
 
DEF_COMMAND(CmdBuildRailStation);
 
DEF_COMMAND(CmdRemoveFromRailStation);
 
DEF_COMMAND(CmdConvertRail);
 

	
 
DEF_COMMAND(CmdBuildSingleSignal);
 
DEF_COMMAND(CmdRemoveSingleSignal);
 

	
 
DEF_COMMAND(CmdTerraformLand);
 
@@ -57,15 +57,15 @@ DEF_COMMAND(CmdTerraformLand);
 
DEF_COMMAND(CmdPurchaseLandArea);
 
DEF_COMMAND(CmdSellLandArea);
 

	
 
DEF_COMMAND(CmdBuildTunnel);
 

	
 
DEF_COMMAND(CmdBuildTrainDepot);
 
DEF_COMMAND(CmdBuildTrainWaypoint);
 
DEF_COMMAND(CmdBuildRailWaypoint);
 
DEF_COMMAND(CmdRenameWaypoint);
 
DEF_COMMAND(CmdRemoveTrainWaypoint);
 
DEF_COMMAND(CmdRemoveFromRailWaypoint);
 

	
 
DEF_COMMAND(CmdBuildRoadStop);
 
DEF_COMMAND(CmdRemoveRoadStop);
 

	
 
DEF_COMMAND(CmdBuildLongRoad);
 
DEF_COMMAND(CmdRemoveLongRoad);
 
@@ -205,25 +205,25 @@ static const Command _command_proc_table
 
	{CmdBuildRailroadTrack,   CMD_NO_WATER | CMD_AUTO}, // CMD_BUILD_RAILROAD_TRACK
 
	{CmdRemoveRailroadTrack,                 CMD_AUTO}, // CMD_REMOVE_RAILROAD_TRACK
 
	{CmdBuildSingleRail,      CMD_NO_WATER | CMD_AUTO}, // CMD_BUILD_SINGLE_RAIL
 
	{CmdRemoveSingleRail,                    CMD_AUTO}, // CMD_REMOVE_SINGLE_RAIL
 
	{CmdLandscapeClear,                             0}, // CMD_LANDSCAPE_CLEAR
 
	{CmdBuildBridge,                         CMD_AUTO}, // CMD_BUILD_BRIDGE
 
	{CmdBuildRailroadStation, CMD_NO_WATER | CMD_AUTO}, // CMD_BUILD_RAILROAD_STATION
 
	{CmdBuildRailStation,     CMD_NO_WATER | CMD_AUTO}, // CMD_BUILD_RAIL_STATION
 
	{CmdBuildTrainDepot,      CMD_NO_WATER | CMD_AUTO}, // CMD_BUILD_TRAIN_DEPOT
 
	{CmdBuildSingleSignal,                   CMD_AUTO}, // CMD_BUILD_SIGNALS
 
	{CmdRemoveSingleSignal,                  CMD_AUTO}, // CMD_REMOVE_SIGNALS
 
	{CmdTerraformLand,       CMD_ALL_TILES | CMD_AUTO}, // CMD_TERRAFORM_LAND
 
	{CmdPurchaseLandArea,     CMD_NO_WATER | CMD_AUTO}, // CMD_PURCHASE_LAND_AREA
 
	{CmdSellLandArea,                               0}, // CMD_SELL_LAND_AREA
 
	{CmdBuildTunnel,                         CMD_AUTO}, // CMD_BUILD_TUNNEL
 
	{CmdRemoveFromRailroadStation,                  0}, // CMD_REMOVE_FROM_RAILROAD_STATION
 
	{CmdRemoveFromRailStation,                      0}, // CMD_REMOVE_FROM_RAIL_STATION
 
	{CmdConvertRail,                                0}, // CMD_CONVERT_RAILD
 
	{CmdBuildTrainWaypoint,                         0}, // CMD_BUILD_TRAIN_WAYPOINT
 
	{CmdBuildRailWaypoint,                          0}, // CMD_BUILD_RAIL_WAYPOINT
 
	{CmdRenameWaypoint,                             0}, // CMD_RENAME_WAYPOINT
 
	{CmdRemoveTrainWaypoint,                        0}, // CMD_REMOVE_TRAIN_WAYPOINT
 
	{CmdRemoveFromRailWaypoint,                     0}, // CMD_REMOVE_FROM_RAIL_WAYPOINT
 

	
 
	{CmdBuildRoadStop,        CMD_NO_WATER | CMD_AUTO}, // CMD_BUILD_ROAD_STOP
 
	{CmdRemoveRoadStop,                             0}, // CMD_REMOVE_ROAD_STOP
 
	{CmdBuildLongRoad,        CMD_NO_WATER | CMD_AUTO}, // CMD_BUILD_LONG_ROAD
 
	{CmdRemoveLongRoad,        CMD_NO_TEST | CMD_AUTO}, // CMD_REMOVE_LONG_ROAD; towns may disallow removing road bits (as they are connected) in test, but in exec they're removed and thus removing is allowed.
 
	{CmdBuildRoad,                                  0}, // CMD_BUILD_ROAD
src/command_type.h
Show inline comments
 
@@ -146,27 +146,27 @@ enum {
 
	CMD_BUILD_RAILROAD_TRACK,         ///< build a rail track
 
	CMD_REMOVE_RAILROAD_TRACK,        ///< remove a rail track
 
	CMD_BUILD_SINGLE_RAIL,            ///< build a single rail track
 
	CMD_REMOVE_SINGLE_RAIL,           ///< remove a single rail track
 
	CMD_LANDSCAPE_CLEAR,              ///< demolish a tile
 
	CMD_BUILD_BRIDGE,                 ///< build a bridge
 
	CMD_BUILD_RAILROAD_STATION,       ///< build a railroad station
 
	CMD_BUILD_RAIL_STATION,           ///< build a rail station
 
	CMD_BUILD_TRAIN_DEPOT,            ///< build a train depot
 
	CMD_BUILD_SIGNALS,                ///< build a signal
 
	CMD_REMOVE_SIGNALS,               ///< remove a signal
 
	CMD_TERRAFORM_LAND,               ///< terraform a tile
 
	CMD_PURCHASE_LAND_AREA,           ///< purchase a tile
 
	CMD_SELL_LAND_AREA,               ///< sell a bought tile before
 
	CMD_BUILD_TUNNEL,                 ///< build a tunnel
 

	
 
	CMD_REMOVE_FROM_RAILROAD_STATION, ///< remove a tile station
 
	CMD_REMOVE_FROM_RAIL_STATION,     ///< remove a (rectangle of) tiles from a rail station
 
	CMD_CONVERT_RAIL,                 ///< convert a rail type
 

	
 
	CMD_BUILD_TRAIN_WAYPOINT,         ///< build a waypoint
 
	CMD_BUILD_RAIL_WAYPOINT,          ///< build a waypoint
 
	CMD_RENAME_WAYPOINT,              ///< rename a waypoint
 
	CMD_REMOVE_TRAIN_WAYPOINT,        ///< remove a waypoint
 
	CMD_REMOVE_FROM_RAIL_WAYPOINT,    ///< remove a (rectangle of) tiles from a rail waypoint
 

	
 
	CMD_BUILD_ROAD_STOP,              ///< build a road stop
 
	CMD_REMOVE_ROAD_STOP,             ///< remove a road stop
 
	CMD_BUILD_LONG_ROAD,              ///< build a complete road (not a "half" one)
 
	CMD_REMOVE_LONG_ROAD,             ///< remove a complete road (not a "half" one)
 
	CMD_BUILD_ROAD,                   ///< build a "half" road
src/rail_gui.cpp
Show inline comments
 
@@ -146,15 +146,15 @@ static void PlaceRail_Depot(TileIndex ti
 
		CcRailDepot);
 
}
 

	
 
static void PlaceRail_Waypoint(TileIndex tile)
 
{
 
	if (_remove_button_clicked) {
 
		DoCommandP(tile, 0, 0, CMD_REMOVE_TRAIN_WAYPOINT | CMD_MSG(STR_CANT_REMOVE_TRAIN_WAYPOINT), CcPlaySound1E);
 
		DoCommandP(tile, 0, 0, CMD_REMOVE_FROM_RAIL_WAYPOINT | CMD_MSG(STR_CANT_REMOVE_TRAIN_WAYPOINT), CcPlaySound1E);
 
	} else {
 
		DoCommandP(tile, _cur_waypoint_type, 0, CMD_BUILD_TRAIN_WAYPOINT | CMD_MSG(STR_CANT_BUILD_TRAIN_WAYPOINT), CcPlaySound1E);
 
		DoCommandP(tile, _cur_waypoint_type, 0, CMD_BUILD_RAIL_WAYPOINT | CMD_MSG(STR_CANT_BUILD_TRAIN_WAYPOINT), CcPlaySound1E);
 
	}
 
}
 

	
 
void CcStation(bool success, TileIndex tile, uint32 p1, uint32 p2)
 
{
 
	if (success) {
 
@@ -177,13 +177,13 @@ static void PlaceRail_Station(TileIndex 
 
		uint32 p2 = _railstation.station_class | _railstation.station_type << 8 | INVALID_STATION << 16;
 

	
 
		int w = _settings_client.gui.station_numtracks;
 
		int h = _settings_client.gui.station_platlength;
 
		if (!_railstation.orientation) Swap(w, h);
 

	
 
		CommandContainer cmdcont = { tile, p1, p2, CMD_BUILD_RAILROAD_STATION | CMD_MSG(STR_ERROR_CAN_T_BUILD_RAILROAD_STATION), CcStation, "" };
 
		CommandContainer cmdcont = { tile, p1, p2, CMD_BUILD_RAIL_STATION | CMD_MSG(STR_ERROR_CAN_T_BUILD_RAILROAD_STATION), CcStation, "" };
 
		ShowSelectStationIfNeeded(cmdcont, TileArea(tile, w, h));
 
	}
 
}
 

	
 
/**
 
 * Build a new signal or edit/remove a present signal, use CmdBuildSingleSignal() or CmdRemoveSingleSignal() in rail_cmd.cpp
 
@@ -748,13 +748,13 @@ struct BuildRailToolbarWindow : Window {
 
					DoCommandP(end_tile, start_tile, _cur_railtype, CMD_CONVERT_RAIL | CMD_MSG(STR_CANT_CONVERT_RAIL), CcPlaySound10);
 
					break;
 

	
 
				case DDSP_REMOVE_STATION:
 
				case DDSP_BUILD_STATION:
 
					if (_remove_button_clicked) {
 
						DoCommandP(end_tile, start_tile, 0, CMD_REMOVE_FROM_RAILROAD_STATION | CMD_MSG(STR_CANT_REMOVE_PART_OF_STATION), CcPlaySound1E);
 
						DoCommandP(end_tile, start_tile, 0, CMD_REMOVE_FROM_RAIL_STATION | CMD_MSG(STR_CANT_REMOVE_PART_OF_STATION), CcPlaySound1E);
 
						break;
 
					}
 
					HandleStationPlacement(start_tile, end_tile);
 
					break;
 
			}
 
		}
 
@@ -879,13 +879,13 @@ static void HandleStationPlacement(TileI
 

	
 
	if (_railstation.orientation == AXIS_X) Swap(numtracks, platlength);
 

	
 
	uint32 p1 = _cur_railtype | _railstation.orientation << 4 | numtracks << 8 | platlength << 16 | _ctrl_pressed << 24;
 
	uint32 p2 = _railstation.station_class | _railstation.station_type << 8 | INVALID_STATION << 16;
 

	
 
	CommandContainer cmdcont = { ta.tile, p1, p2, CMD_BUILD_RAILROAD_STATION | CMD_MSG(STR_ERROR_CAN_T_BUILD_RAILROAD_STATION), CcStation, "" };
 
	CommandContainer cmdcont = { ta.tile, p1, p2, CMD_BUILD_RAIL_STATION | CMD_MSG(STR_ERROR_CAN_T_BUILD_RAILROAD_STATION), CcStation, "" };
 
	ShowSelectStationIfNeeded(cmdcont, ta);
 
}
 

	
 
/** Enum referring to the widgets of the rail stations window */
 
enum BuildRailStationWidgets {
 
	BRSW_CLOSEBOX = 0,
src/station_cmd.cpp
Show inline comments
 
@@ -818,13 +818,13 @@ static void GetStationLayout(byte *layou
 
			layout = CreateMulti(layout, plat_len, 6);
 
		}
 
	}
 
}
 

	
 
/**
 
 * Build railroad station
 
 * Build rail station
 
 * @param tile_org northern most position of station dragging/placement
 
 * @param flags operation to perform
 
 * @param p1 various bitstuffed elements
 
 * - p1 = (bit  0- 3) - railtype
 
 * - p1 = (bit  4)    - orientation (Axis)
 
 * - p1 = (bit  8-15) - number of tracks
 
@@ -832,13 +832,13 @@ static void GetStationLayout(byte *layou
 
 * - p1 = (bit 24)    - allow stations directly adjacent to other stations.
 
 * @param p2 various bitstuffed elements
 
 * - p2 = (bit  0- 7) - custom station class
 
 * - p2 = (bit  8-15) - custom station id
 
 * - p2 = (bit 16-31) - station ID to join (NEW_STATION if build new one)
 
 */
 
CommandCost CmdBuildRailroadStation(TileIndex tile_org, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
{
 
	/* Unpack parameters */
 
	RailType rt    = (RailType)GB(p1, 0, 4);
 
	Axis axis      = Extract<Axis, 4>(p1);
 
	byte numtracks = GB(p1,  8, 8);
 
	byte plat_len  = GB(p1, 16, 8);
 
@@ -1220,22 +1220,22 @@ CommandCost RemoveFromRailBaseStation(Ti
 
		}
 
	}
 

	
 
	return CommandCost(EXPENSES_CONSTRUCTION, quantity * removal_cost);
 
}
 

	
 
/** Remove a single tile from a railroad station.
 
/** 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 text unused
 
 * @return cost of operation or error
 
 */
 
CommandCost CmdRemoveFromRailroadStation(TileIndex start, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
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;
 
@@ -1262,13 +1262,13 @@ CommandCost CmdRemoveFromRailroadStation
 
 * @param flags operation to perform
 
 * @param p1 start_tile
 
 * @param p2 unused
 
 * @param text unused
 
 * @return cost of operation or error
 
 */
 
CommandCost CmdRemoveTrainWaypoint(TileIndex start, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
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;
 
@@ -1345,17 +1345,17 @@ CommandCost RemoveRailStation(T *st, DoC
 
/**
 
 * Remove a rail road station
 
 * @param tile TileIndex been queried
 
 * @param flags operation to perform
 
 * @return cost or failure of operation
 
 */
 
static CommandCost RemoveRailroadStation(TileIndex tile, DoCommandFlag flags)
 
static CommandCost RemoveRailStation(TileIndex tile, DoCommandFlag flags)
 
{
 
	/* if there is flooding and non-uniform stations are enabled, remove platforms tile by tile */
 
	if (_current_company == OWNER_WATER && _settings_game.station.nonuniform_stations) {
 
		return DoCommand(tile, 0, 0, DC_EXEC, CMD_REMOVE_FROM_RAILROAD_STATION);
 
		return DoCommand(tile, 0, 0, DC_EXEC, CMD_REMOVE_FROM_RAIL_STATION);
 
	}
 

	
 
	Station *st = Station::GetByTile(tile);
 
	CommandCost cost = RemoveRailStation(st, flags);
 

	
 
	if (flags & DC_EXEC) st->RecomputeIndustriesNear();
 
@@ -1366,17 +1366,17 @@ static CommandCost RemoveRailroadStation
 
/**
 
 * Remove a rail waypoint
 
 * @param tile TileIndex been queried
 
 * @param flags operation to perform
 
 * @return cost or failure of operation
 
 */
 
static CommandCost RemoveTrainWaypoint(TileIndex tile, DoCommandFlag flags)
 
static CommandCost RemoveRailWaypoint(TileIndex tile, DoCommandFlag flags)
 
{
 
	/* if there is flooding and non-uniform stations are enabled, remove waypoints tile by tile */
 
	if (_current_company == OWNER_WATER && _settings_game.station.nonuniform_stations) {
 
		return DoCommand(tile, 0, 0, DC_EXEC, CMD_REMOVE_TRAIN_WAYPOINT);
 
		return DoCommand(tile, 0, 0, DC_EXEC, CMD_REMOVE_FROM_RAIL_WAYPOINT);
 
	}
 

	
 
	return RemoveRailStation(Waypoint::GetByTile(tile), flags);
 
}
 

	
 

	
 
@@ -3086,14 +3086,14 @@ static CommandCost ClearTile_Station(Til
 
				SetDParam(0, STR_INDUSTRY_NAME_OIL_RIG);
 
				return_cmd_error(STR_OBJECT_IN_THE_WAY);
 
		}
 
	}
 

	
 
	switch (GetStationType(tile)) {
 
		case STATION_RAIL:     return RemoveRailroadStation(tile, flags);
 
		case STATION_WAYPOINT: return RemoveTrainWaypoint(tile, flags);
 
		case STATION_RAIL:     return RemoveRailStation(tile, flags);
 
		case STATION_WAYPOINT: return RemoveRailWaypoint(tile, flags);
 
		case STATION_AIRPORT:  return RemoveAirport(tile, flags);
 
		case STATION_TRUCK:
 
			if (IsDriveThroughStopTile(tile) && !CanRemoveRoadWithStop(tile, flags))
 
				return_cmd_error(STR_ERROR_MUST_DEMOLISH_TRUCK_STATION_FIRST);
 
			return RemoveRoadStop(tile, flags);
 
		case STATION_BUS:
src/waypoint_cmd.cpp
Show inline comments
 
@@ -129,13 +129,13 @@ static Waypoint *FindDeletedWaypointClos
 
 * @param text unused
 
 * @return cost of operation or error
 
 *
 
 * @todo When checking for the tile slope,
 
 * distingush between "Flat land required" and "land sloped in wrong direction"
 
 */
 
CommandCost CmdBuildTrainWaypoint(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdBuildRailWaypoint(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
{
 
	Axis axis;
 

	
 
	/* if custom gfx are used, make sure it is within bounds */
 
	if (p1 >= GetNumCustomStations(STAT_CLASS_WAYP)) return CMD_ERROR;
 

	
0 comments (0 inline, 0 general)