Changeset - r12944:5f0fae995b6c
[Not reviewed]
master
0 1 0
rubidium - 15 years ago 2009-09-07 09:07:56
rubidium@openttd.org
(svn r17447) -Codechange: rename a local variable so it doesn't collide with the name of a global function
1 file changed with 3 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/rail_cmd.cpp
Show inline comments
 
@@ -1030,25 +1030,25 @@ static bool CheckSignalAutoFill(TileInde
 
 * - p2 = (bit  3)    - 1 = override signal/semaphore, or pre/exit/combo signal (CTRL-toggle)
 
 * - p2 = (bit  4)    - 0 = signals, 1 = semaphores
 
 * - p2 = (bit  5)    - 0 = build, 1 = remove signals
 
 * - p2 = (bit  6)    - 0 = selected stretch, 1 = auto fill
 
 * - p2 = (bit  7- 9) - default signal type
 
 * - p2 = (bit 24-31) - user defined signals_density
 
 */
 
static CommandCost CmdSignalTrackHelper(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
{
 
	CommandCost ret, total_cost(EXPENSES_CONSTRUCTION);
 
	int signal_ctr;
 
	byte signals;
 
	bool error = true;
 
	bool err = true;
 
	TileIndex end_tile;
 
	TileIndex start_tile = tile;
 

	
 
	Track track = (Track)GB(p2, 0, 3);
 
	bool mode = HasBit(p2, 3);
 
	bool semaphores = HasBit(p2, 4);
 
	bool remove = HasBit(p2, 5);
 
	bool autofill = HasBit(p2, 6);
 
	Trackdir trackdir = TrackToTrackdir(track);
 
	byte signal_density = GB(p2, 24, 8);
 

	
 
	if (p1 >= MapSize()) return CMD_ERROR;
 
@@ -1109,50 +1109,50 @@ static CommandCost CmdSignalTrackHelper(
 
			SB(p1, 5, 3, sigtype);
 
			if (!remove && signal_ctr == 0) SetBit(p1, 17);
 

	
 
			/* Pick the correct orientation for the track direction */
 
			signals = 0;
 
			if (HasBit(signal_dir, 0)) signals |= SignalAlongTrackdir(trackdir);
 
			if (HasBit(signal_dir, 1)) signals |= SignalAgainstTrackdir(trackdir);
 

	
 
			ret = DoCommand(tile, p1, signals, flags, remove ? CMD_REMOVE_SIGNALS : CMD_BUILD_SIGNALS);
 

	
 
			/* Be user-friendly and try placing signals as much as possible */
 
			if (CmdSucceeded(ret)) {
 
				error = false;
 
				err = false;
 
				total_cost.AddCost(ret);
 
			}
 
		}
 

	
 
		if (autofill) {
 
			if (!CheckSignalAutoFill(tile, trackdir, signal_ctr, remove)) break;
 

	
 
			/* Prevent possible loops */
 
			if (tile == start_tile && trackdir == start_trackdir) break;
 
		} else {
 
			if (tile == end_tile) break;
 

	
 
			tile += ToTileIndexDiff(_trackdelta[trackdir]);
 
			signal_ctr++;
 

	
 
			/* toggle railbit for the non-diagonal tracks (|, -- tracks) */
 
			if (IsDiagonalTrackdir(trackdir)) {
 
				signal_ctr++;
 
			} else {
 
				ToggleBit(trackdir, 0);
 
			}
 
		}
 
	}
 

	
 
	return error ? CMD_ERROR : total_cost;
 
	return err ? CMD_ERROR : total_cost;
 
}
 

	
 
/** Build signals on a stretch of track.
 
 * Stub for the unified signal builder/remover
 
 * @param tile start tile of drag
 
 * @param flags operation to perform
 
 * @param p1  end tile of drag
 
 * @param p2 various bitstuffed elements
 
 * - p2 = (bit  0- 2) - track-orientation, valid values: 0-5 (Track enum)
 
 * - p2 = (bit  3)    - 1 = override signal/semaphore, or pre/exit/combo signal (CTRL-toggle)
 
 * - p2 = (bit  4)    - 0 = signals, 1 = semaphores
 
 * - p2 = (bit  5)    - 0 = build, 1 = remove signals
0 comments (0 inline, 0 general)