summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2011-11-26 18:11:22 +0000
committerrubidium <rubidium@openttd.org>2011-11-26 18:11:22 +0000
commit95f88ea537aec0ff4d22e5d09a07bbe41a0d6510 (patch)
tree93bcbf3c12a6abe96745e272883c5bbb707d07d8
parent104adbdb3ab9f6a8da64ff46e9706247a6161141 (diff)
downloadopenttd-95f88ea537aec0ff4d22e5d09a07bbe41a0d6510.tar.xz
(svn r23338) -Feature [FS#4841]: diagonal dragging the rail conversion tool when pressing CTRL
-rw-r--r--src/rail_cmd.cpp7
-rw-r--r--src/rail_gui.cpp4
2 files changed, 7 insertions, 4 deletions
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index ed0362935..9cd40c83e 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -1402,7 +1402,9 @@ static Vehicle *UpdateTrainPowerProc(Vehicle *v, void *data)
* @param tile end tile of rail conversion drag
* @param flags operation to perform
* @param p1 start tile of drag
- * @param p2 new railtype to convert to
+ * @param p2 various bitstuffed elements:
+ * - p2 = (bit 0- 3) new railtype to convert to.
+ * - p2 = (bit 4) build diagonally or not.
* @param text unused
* @return the cost of this operation or an error
*/
@@ -1418,7 +1420,8 @@ CommandCost CmdConvertRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
CommandCost cost(EXPENSES_CONSTRUCTION);
CommandCost error = CommandCost(STR_ERROR_NO_SUITABLE_RAILROAD_TRACK); // by default, there is no track to convert.
TileArea ta(tile, p1);
- TILE_AREA_LOOP(tile, ta) {
+ TileIterator *iter = HasBit(p2, 4) ? (TileIterator *)new DiagonalTileIterator(tile, p1) : new OrthogonalTileIterator(ta);
+ for (; (tile = *iter) != INVALID_TILE; ++(*iter)) {
TileType tt = GetTileType(tile);
/* Check if there is any track on tile */
diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp
index cffbeceff..80c2d143b 100644
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -604,7 +604,7 @@ struct BuildRailToolbarWindow : Window {
break;
case RTW_CONVERT_RAIL:
- HandlePlacePushButton(this, RTW_CONVERT_RAIL, GetRailTypeInfo(_cur_railtype)->cursor.convert, HT_RECT);
+ HandlePlacePushButton(this, RTW_CONVERT_RAIL, GetRailTypeInfo(_cur_railtype)->cursor.convert, HT_RECT | HT_DIAGONAL);
this->last_user_action = widget;
break;
@@ -715,7 +715,7 @@ struct BuildRailToolbarWindow : Window {
break;
case DDSP_CONVERT_RAIL:
- DoCommandP(end_tile, start_tile, _cur_railtype, CMD_CONVERT_RAIL | CMD_MSG(STR_ERROR_CAN_T_CONVERT_RAIL), CcPlaySound10);
+ DoCommandP(end_tile, start_tile, _cur_railtype | (_ctrl_pressed ? 0x10 : 0), CMD_CONVERT_RAIL | CMD_MSG(STR_ERROR_CAN_T_CONVERT_RAIL), CcPlaySound10);
break;
case DDSP_REMOVE_STATION: