diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp index 76fbf4b9c9..2247397ec9 100644 --- a/src/tree_cmd.cpp +++ b/src/tree_cmd.cpp @@ -538,7 +538,9 @@ void GenerateTrees() * Plant a tree. * @param tile end tile of area-drag * @param flags type of operation - * @param p1 tree type, TREE_INVALID means random. + * @param p1 various bitstuffed data. + * - p1 = (bit 0 - 7) - tree type, TREE_INVALID means random. + * - p1 = (bit 8) - whether to use the Orthogonal (0) or Diagonal (1) iterator. * @param p2 start tile of area-drag of tree plantation * @param text unused * @return the cost of this operation or an error @@ -556,8 +558,9 @@ CommandCost CmdPlantTree(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 Company *c = (_game_mode != GM_EDITOR) ? Company::GetIfValid(_current_company) : nullptr; int limit = (c == nullptr ? INT32_MAX : GB(c->tree_limit, 16, 16)); - TileArea ta(tile, p2); - for (TileIndex tile : ta) { + OrthogonalOrDiagonalTileIterator iter(tile, p2, HasBit(p1, 8)); + for (; *iter != INVALID_TILE; ++iter) { + TileIndex tile = *iter; switch (GetTileType(tile)) { case MP_TREES: { bool grow_existing_tree_instead = false; diff --git a/src/tree_gui.cpp b/src/tree_gui.cpp index 7505eb3db8..1616a47f34 100644 --- a/src/tree_gui.cpp +++ b/src/tree_gui.cpp @@ -90,7 +90,7 @@ class BuildTreesWindow : public Window if (this->tree_to_plant >= 0) { /* Activate placement */ if (_settings_client.sound.confirm) SndPlayFx(SND_15_BEEP); - SetObjectToPlace(SPR_CURSOR_TREE, PAL_NONE, HT_RECT, this->window_class, this->window_number); + SetObjectToPlace(SPR_CURSOR_TREE, PAL_NONE, HT_RECT | HT_DIAGONAL, this->window_class, this->window_number); this->tree_to_plant = current_tree; // SetObjectToPlace may call ResetObjectToPlace which may reset tree_to_plant to -1 } else { /* Deactivate placement */ @@ -234,7 +234,7 @@ public: void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) override { if (_game_mode != GM_EDITOR && this->mode == PM_NORMAL && pt.x != -1 && select_proc == DDSP_PLANT_TREES) { - DoCommandP(end_tile, this->tree_to_plant, start_tile, CMD_PLANT_TREE | CMD_MSG(STR_ERROR_CAN_T_PLANT_TREE_HERE)); + DoCommandP(end_tile, this->tree_to_plant | ((_ctrl_pressed ? 1 : 0) << 8), start_tile, CMD_PLANT_TREE | CMD_MSG(STR_ERROR_CAN_T_PLANT_TREE_HERE)); } }