Changeset - r19439:b5bd71112a92
[Not reviewed]
master
0 1 0
frosch - 12 years ago 2012-06-23 20:18:29
frosch@openttd.org
(svn r24356) -Change: Allow building/modifying/removing signals even if a train is on the belonging track.
1 file changed with 1 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/rail_cmd.cpp
Show inline comments
 
@@ -977,31 +977,28 @@ CommandCost CmdBuildSingleSignal(TileInd
 
	SignalType cycle_start = Extract<SignalType, 9, 3>(p1);
 
	SignalType cycle_stop = Extract<SignalType, 12, 3>(p1);
 
	uint num_dir_cycle = GB(p1, 15, 2);
 

	
 
	if (sigtype > SIGTYPE_LAST) return CMD_ERROR;
 
	if (cycle_start > cycle_stop || cycle_stop > SIGTYPE_LAST) return CMD_ERROR;
 

	
 
	/* You can only build signals on plain rail tiles, and the selected track must exist */
 
	if (!ValParamTrackOrientation(track) || !IsPlainRailTile(tile) ||
 
			!HasTrack(tile, track)) {
 
		return_cmd_error(STR_ERROR_THERE_IS_NO_RAILROAD_TRACK);
 
	}
 
	CommandCost ret = EnsureNoTrainOnTrack(tile, track);
 
	if (ret.Failed()) return ret;
 

	
 
	/* Protect against invalid signal copying */
 
	if (p2 != 0 && (p2 & SignalOnTrack(track)) == 0) return CMD_ERROR;
 

	
 
	ret = CheckTileOwnership(tile);
 
	CommandCost ret = CheckTileOwnership(tile);
 
	if (ret.Failed()) return ret;
 

	
 
	{
 
		/* See if this is a valid track combination for signals, (ie, no overlap) */
 
		TrackBits trackbits = GetTrackBits(tile);
 
		if (KillFirstBit(trackbits) != TRACK_BIT_NONE && // More than one track present
 
				trackbits != TRACK_BIT_HORZ &&
 
				trackbits != TRACK_BIT_VERT) {
 
			return_cmd_error(STR_ERROR_NO_SUITABLE_RAILROAD_TRACK);
 
		}
 
	}
 

	
 
@@ -1391,26 +1388,24 @@ CommandCost CmdBuildSignalTrack(TileInde
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdRemoveSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *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);
 
	}
 
	if (!HasSignalOnTrack(tile, track)) {
 
		return_cmd_error(STR_ERROR_THERE_ARE_NO_SIGNALS);
 
	}
 
	CommandCost ret = EnsureNoTrainOnTrack(tile, track);
 
	if (ret.Failed()) return ret;
 

	
 
	/* Only water can remove signals from anyone */
 
	if (_current_company != OWNER_WATER) {
 
		CommandCost ret = CheckTileOwnership(tile);
 
		if (ret.Failed()) return ret;
 
	}
 

	
 
	/* Do it? */
 
	if (flags & DC_EXEC) {
 
		Train *v = NULL;
 
		if (HasReservedTracks(tile, TrackToTrackBits(track))) {
 
			v = GetTrainForReservation(tile, track);
0 comments (0 inline, 0 general)