File diff r25561:3defb050f30b → r25562:30716ba6a396
src/rail_cmd.cpp
Show inline comments
 
@@ -431,13 +431,13 @@ static inline bool ValParamTrackOrientat
 
 * @param p2 various bitstuffed elements
 
 *           - (bit  0- 2) - track-orientation, valid values: 0-5 (@see Track)
 
 *           - (bit  3)    - 0 = error on signal in the way, 1 = auto remove signals when in the way
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdBuildSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdBuildSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	RailType railtype = Extract<RailType, 0, 6>(p1);
 
	Track track = Extract<Track, 0, 3>(p2);
 
	bool auto_remove_signals = HasBit(p2, 3);
 
	CommandCost cost(EXPENSES_CONSTRUCTION);
 

	
 
@@ -619,13 +619,13 @@ CommandCost CmdBuildSingleRail(TileIndex
 
 * @param flags operation to perform
 
 * @param p1 unused
 
 * @param p2 rail orientation
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdRemoveSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdRemoveSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	Track track = Extract<Track, 0, 3>(p2);
 
	CommandCost cost(EXPENSES_CONSTRUCTION);
 
	bool crossing = false;
 

	
 
	if (!ValParamTrackOrientation(track)) return CMD_ERROR;
 
@@ -881,13 +881,13 @@ static CommandCost ValidateAutoDrag(Trac
 
 * - p2 = (bit 9)   - 0 = build, 1 = remove tracks
 
 * - p2 = (bit 10)  - 0 = build up to an obstacle, 1 = fail if an obstacle is found (used for AIs).
 
 * - p2 = (bit 11)  - 0 = error on signal in the way, 1 = auto remove signals when in the way
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
static CommandCost CmdRailTrackHelper(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
static CommandCost CmdRailTrackHelper(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	CommandCost total_cost(EXPENSES_CONSTRUCTION);
 
	Track track = Extract<Track, 6, 3>(p2);
 
	bool remove = HasBit(p2, 9);
 
	bool auto_remove_signals = HasBit(p2, 11);
 
	RailType railtype = Extract<RailType, 0, 6>(p2);
 
@@ -942,13 +942,13 @@ static CommandCost CmdRailTrackHelper(Ti
 
 * - p2 = (bit 6-8) - track-orientation, valid values: 0-5 (Track enum)
 
 * - p2 = (bit 9)   - 0 = build, 1 = remove tracks
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 * @see CmdRailTrackHelper
 
 */
 
CommandCost CmdBuildRailroadTrack(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdBuildRailroadTrack(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	return CmdRailTrackHelper(tile, flags, p1, ClrBit(p2, 9), text);
 
}
 

	
 
/**
 
 * Build rail on a stretch of track.
 
@@ -961,13 +961,13 @@ CommandCost CmdBuildRailroadTrack(TileIn
 
 * - p2 = (bit 6-8) - track-orientation, valid values: 0-5 (Track enum)
 
 * - p2 = (bit 9)   - 0 = build, 1 = remove tracks
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 * @see CmdRailTrackHelper
 
 */
 
CommandCost CmdRemoveRailroadTrack(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdRemoveRailroadTrack(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	return CmdRailTrackHelper(tile, flags, p1, SetBit(p2, 9), text);
 
}
 

	
 
/**
 
 * Build a train depot
 
@@ -978,13 +978,13 @@ CommandCost CmdRemoveRailroadTrack(TileI
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 *
 
 * @todo When checking for the tile slope,
 
 * distinguish between "Flat land required" and "land sloped in wrong direction"
 
 */
 
CommandCost CmdBuildTrainDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdBuildTrainDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	/* check railtype and valid direction for depot (0 through 3), 4 in total */
 
	RailType railtype = Extract<RailType, 0, 6>(p1);
 
	if (!ValParamRailtype(railtype)) return CMD_ERROR;
 

	
 
	Slope tileh = GetTileSlope(tile);
 
@@ -1052,13 +1052,13 @@ CommandCost CmdBuildTrainDepot(TileIndex
 
 * - p1 = (bit 17)  - 1 = don't modify an existing signal but don't fail either, 0 = always set new signal type
 
 * @param p2 used for CmdBuildManySignals() to copy direction of first signal
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 * @todo p2 should be replaced by two bits for "along" and "against" the track.
 
 */
 
CommandCost CmdBuildSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdBuildSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	Track track = Extract<Track, 0, 3>(p1);
 
	bool ctrl_pressed = HasBit(p1, 3); // was the CTRL button pressed
 
	SignalVariant sigvar = (ctrl_pressed ^ HasBit(p1, 4)) ? SIG_SEMAPHORE : SIG_ELECTRIC; // the signal variant of the new signal
 
	SignalType sigtype = Extract<SignalType, 5, 3>(p1); // the signal type of the new signal
 
	bool convert_signal = HasBit(p1, 8); // convert button pressed
 
@@ -1278,13 +1278,13 @@ static bool CheckSignalAutoFill(TileInde
 
 * - p2 = (bit  7- 9) - default signal type
 
 * - p2 = (bit 10)    - 0 = keep fixed distance, 1 = minimise gaps between signals
 
 * - p2 = (bit 24-31) - user defined signals_density
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
static CommandCost CmdSignalTrackHelper(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
static CommandCost CmdSignalTrackHelper(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	CommandCost total_cost(EXPENSES_CONSTRUCTION);
 
	TileIndex start_tile = tile;
 

	
 
	Track track = Extract<Track, 0, 3>(p2);
 
	bool mode = HasBit(p2, 3);
 
@@ -1448,13 +1448,13 @@ static CommandCost CmdSignalTrackHelper(
 
 * - p2 = (bit  7- 9) - default signal type
 
 * - p2 = (bit 24-31) - user defined signals_density
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 * @see CmdSignalTrackHelper
 
 */
 
CommandCost CmdBuildSignalTrack(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdBuildSignalTrack(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	return CmdSignalTrackHelper(tile, flags, p1, p2, text);
 
}
 

	
 
/**
 
 * Remove signals
 
@@ -1465,13 +1465,13 @@ CommandCost CmdBuildSignalTrack(TileInde
 
 *           - (bit  3)    - override signal/semaphore, or pre/exit/combo signal (CTRL-toggle)
 
 *           - (bit  4)    - 0 = signals, 1 = semaphores
 
 * @param p2 unused
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdRemoveSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdRemoveSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	Track track = Extract<Track, 0, 3>(p1);
 

	
 
	if (!ValParamTrackOrientation(track) || !IsPlainRailTile(tile) || !HasTrack(tile, track)) {
 
		return_cmd_error(STR_ERROR_THERE_IS_NO_RAILROAD_TRACK);
 
	}
 
@@ -1540,13 +1540,13 @@ CommandCost CmdRemoveSingleSignal(TileIn
 
 * - p2 = (bit  7- 9) - default signal type
 
 * - p2 = (bit 24-31) - user defined signals_density
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 * @see CmdSignalTrackHelper
 
 */
 
CommandCost CmdRemoveSignalTrack(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdRemoveSignalTrack(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	return CmdSignalTrackHelper(tile, flags, p1, SetBit(p2, 5), text); // bit 5 is remove bit
 
}
 

	
 
/** Update power of train under which is the railtype being converted */
 
static Vehicle *UpdateTrainPowerProc(Vehicle *v, void *data)
 
@@ -1568,13 +1568,13 @@ static Vehicle *UpdateTrainPowerProc(Veh
 
 * @param p2 various bitstuffed elements:
 
 * - p2 = (bit  0- 5) new railtype to convert to.
 
 * - p2 = (bit  6)    build diagonally or not.
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdConvertRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdConvertRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	RailType totype = Extract<RailType, 0, 6>(p2);
 
	TileIndex area_start = p1;
 
	TileIndex area_end = tile;
 
	bool diagonal = HasBit(p2, 6);