Allow planting trees on diagonal areas

This commit is contained in:
Jonathan G Rennison
2022-12-30 18:24:13 +00:00
parent 160dcc345a
commit b1a1760bcc
2 changed files with 8 additions and 5 deletions

View File

@@ -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;