Changeset - r16876:b93e61d7eb25
[Not reviewed]
master
0 2 0
alberth - 13 years ago 2010-12-24 14:55:31
alberth@openttd.org
(svn r21621) -Codechange: Only consider tile highlighting mode bits in tile selection functions.
2 files changed with 10 insertions and 9 deletions:
0 comments (0 inline, 0 general)
src/rail_gui.cpp
Show inline comments
 
@@ -379,13 +379,13 @@ static void HandleAutodirPlacement()
 
 */
 
static void HandleAutoSignalPlacement()
 
{
 
	TileHighlightData *thd = &_thd;
 
	uint32 p2 = GB(thd->drawstyle, 0, 3); // 0..5
 

	
 
	if (thd->drawstyle == HT_RECT) { // one tile case
 
	if ((thd->drawstyle & HT_DRAG_MASK) == HT_RECT) { // one tile case
 
		GenericPlaceSignals(TileVirtXY(thd->selend.x, thd->selend.y));
 
		return;
 
	}
 

	
 
	const Window *w = FindWindowById(WC_BUILD_SIGNAL, 0);
 

	
src/viewport.cpp
Show inline comments
 
@@ -895,13 +895,13 @@ static void DrawTileSelectionRect(const 
 

	
 
static bool IsPartOfAutoLine(int px, int py)
 
{
 
	px -= _thd.selstart.x;
 
	py -= _thd.selstart.y;
 

	
 
	if ((_thd.drawstyle & ~HT_DIR_MASK) != HT_LINE) return false;
 
	if ((_thd.drawstyle & HT_DRAG_MASK) != HT_LINE) return false;
 

	
 
	switch (_thd.drawstyle & HT_DIR_MASK) {
 
		case HT_DIR_X:  return py == 0; // x direction
 
		case HT_DIR_Y:  return px == 0; // y direction
 
		case HT_DIR_HU: return px == -py || px == -py - 16; // horizontal upper
 
		case HT_DIR_HL: return px == -py || px == -py + 16; // horizontal lower
 
@@ -967,14 +967,14 @@ static void DrawAutorailSelection(const 
 
static void DrawTileSelection(const TileInfo *ti)
 
{
 
	/* Draw a red error square? */
 
	bool is_redsq = _thd.redsq == ti->tile;
 
	if (is_redsq) DrawTileSelectionRect(ti, PALETTE_TILE_RED_PULSATING);
 

	
 
	/* no selection active? */
 
	if (_thd.drawstyle == 0) return;
 
	/* No tile selection active? */
 
	if ((_thd.drawstyle & HT_DRAG_MASK) == HT_NONE) return;
 

	
 
	if (_thd.diagonal) { // We're drawing a 45 degrees rotated (diagonal) rectangle
 
		if (IsInsideRotatedRectangle((int)ti->x, (int)ti->y)) {
 
			if (_thd.drawstyle & HT_RECT) { // Highlighting a square (clear land)
 
				/* Don't mark tiles outside the map. */
 
				if (!IsValidTile(ti->tile)) return;
 
@@ -1900,13 +1900,14 @@ bool HandleViewportClicked(const ViewPor
 
	const Vehicle *v = CheckClickOnVehicle(vp, x, y);
 

	
 
	if (_thd.place_mode & HT_VEHICLE) {
 
		if (v != NULL && VehicleClicked(v)) return true;
 
	}
 

	
 
	if (_thd.place_mode & HT_DRAG_MASK) {
 
	/* Vehicle placement mode already handled above. */
 
	if ((_thd.place_mode & HT_DRAG_MASK) != HT_NONE) {
 
		PlaceObject();
 
		return true;
 
	}
 

	
 
	if (CheckClickOnTown(vp, x, y)) return true;
 
	if (CheckClickOnStation(vp, x, y)) return true;
 
@@ -2125,24 +2126,24 @@ void UpdateTileSelection()
 
	if (_thd.drawstyle != new_drawstyle ||
 
			_thd.pos.x != _thd.new_pos.x || _thd.pos.y != _thd.new_pos.y ||
 
			_thd.size.x != _thd.new_size.x || _thd.size.y != _thd.new_size.y ||
 
			_thd.outersize.x != _thd.new_outersize.x ||
 
			_thd.outersize.y != _thd.new_outersize.y ||
 
			_thd.diagonal    != new_diagonal) {
 
		/* clear the old selection? */
 
		if (_thd.drawstyle) SetSelectionTilesDirty();
 
		/* Clear the old tile selection? */
 
		if ((_thd.drawstyle & HT_DRAG_MASK) != HT_NONE) SetSelectionTilesDirty();
 

	
 
		_thd.drawstyle = new_drawstyle;
 
		_thd.pos = _thd.new_pos;
 
		_thd.size = _thd.new_size;
 
		_thd.outersize = _thd.new_outersize;
 
		_thd.diagonal = new_diagonal;
 
		_thd.dirty = 0xff;
 

	
 
		/* draw the new selection? */
 
		if (new_drawstyle != HT_NONE) SetSelectionTilesDirty();
 
		/* Draw the new tile selection? */
 
		if ((new_drawstyle & HT_DRAG_MASK) != HT_NONE) SetSelectionTilesDirty();
 
	}
 
}
 

	
 
/**
 
 * Displays the measurement tooltips when selecting multiple tiles
 
 * @param str String to be displayed
0 comments (0 inline, 0 general)