changeset 16886:c123be7fd3cb draft

(svn r21621) -Codechange: Only consider tile highlighting mode bits in tile selection functions.
author alberth <alberth@openttd.org>
date Fri, 24 Dec 2010 14:55:31 +0000
parents 4937eb396d5a
children 69b56a3d9341
files src/rail_gui.cpp src/viewport.cpp
diffstat 2 files changed, 10 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -382,7 +382,7 @@
 	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;
 	}
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -898,7 +898,7 @@
 	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
@@ -970,8 +970,8 @@
 	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)) {
@@ -1903,7 +1903,8 @@
 		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;
 	}
@@ -2128,8 +2129,8 @@
 			_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;
@@ -2138,8 +2139,8 @@
 		_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();
 	}
 }