(svn r21500) -Feature [FS#730]: diagonal tile clearing and terraforming. Based on patch by fonsinchen

This commit is contained in:
rubidium
2010-12-13 15:15:02 +00:00
parent b20e77be92
commit 6892cc8a60
4 changed files with 24 additions and 12 deletions

View File

@@ -642,7 +642,8 @@ CommandCost CmdLandscapeClear(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
* @param tile end tile of area dragging
* @param flags of operation to conduct
* @param p1 start tile of area dragging
* @param p2 unused
* @param p2 various bitstuffed data.
* bit 0: Whether to use the Orthogonal (0) or Diagonal (1) iterator.
* @param text unused
* @return the cost of this operation or an error
*/
@@ -656,7 +657,9 @@ CommandCost CmdClearArea(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
bool had_success = false;
TileArea ta(tile, p1);
TILE_AREA_LOOP(t, ta) {
TileIterator *iter = HasBit(p2, 0) ? (TileIterator *)new DiagonalTileIterator(tile, p1) : new OrthogonalTileIterator(ta);
for (; *iter != INVALID_TILE; ++(*iter)) {
TileIndex t = *iter;
CommandCost ret = DoCommand(t, 0, 0, flags & ~DC_EXEC, CMD_LANDSCAPE_CLEAR);
if (ret.Failed()) {
last_error = ret;
@@ -668,6 +671,7 @@ CommandCost CmdClearArea(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
money -= ret.GetCost();
if (ret.GetCost() > 0 && money < 0) {
_additional_cash_required = ret.GetCost();
delete iter;
return cost;
}
DoCommand(t, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
@@ -684,6 +688,7 @@ CommandCost CmdClearArea(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
cost.AddCost(ret);
}
delete iter;
return had_success ? cost : last_error;
}