summaryrefslogtreecommitdiff
path: root/clear_cmd.c
diff options
context:
space:
mode:
authorDarkvater <darkvater@openttd.org>2005-05-12 23:46:01 +0000
committerDarkvater <darkvater@openttd.org>2005-05-12 23:46:01 +0000
commit033995ec6ecd443404fa1a236c6763ddc9cce321 (patch)
treedde69a1afcdeffecc49a408ef9164ad83781a82f /clear_cmd.c
parent56e7e4cf25929feefc4586dc3ffe1f4471bbdef1 (diff)
downloadopenttd-033995ec6ecd443404fa1a236c6763ddc9cce321.tar.xz
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
- CodeChange: remove cmd-misuses CmdStartScenario() and CmdDestroyCompanyHQ() - Fix (invisible): when parameter checking CmdRestoreOrderIndex() the vehicle did not have its orders yet, so it would fail. So move doing this until AFTER the orders have been added back in RestoreVehicleOrders()
Diffstat (limited to 'clear_cmd.c')
-rw-r--r--clear_cmd.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/clear_cmd.c b/clear_cmd.c
index a854b3985..9dc30bd8e 100644
--- a/clear_cmd.c
+++ b/clear_cmd.c
@@ -322,18 +322,21 @@ int32 CmdTerraformLand(int x, int y, uint32 flags, uint32 p1, uint32 p2)
}
-/*
- * p1 - start
+/** Levels a selected (rectangle) area of land
+ * @param x,y end tile of area-drag
+ * @param p1 start tile of area drag
+ * @param p2 unused
*/
-
int32 CmdLevelLand(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
{
int size_x, size_y;
int sx, sy;
uint h, curh;
- uint tile;
+ TileIndex tile;
int32 ret, cost, money;
+ if (p1 > MapSize()) return CMD_ERROR;
+
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
// remember level height
@@ -354,11 +357,11 @@ int32 CmdLevelLand(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
money = GetAvailableMoneyForCommand();
cost = 0;
- BEGIN_TILE_LOOP(tile2, size_x, size_y, tile)
+ BEGIN_TILE_LOOP(tile2, size_x, size_y, tile) {
curh = TileHeight(tile2);
while (curh != h) {
- ret = DoCommandByTile(tile2, 8, (curh > h)?0:1, flags & ~DC_EXEC, CMD_TERRAFORM_LAND);
- if (ret == CMD_ERROR) break;
+ ret = DoCommandByTile(tile2, 8, (curh > h) ? 0 : 1, flags & ~DC_EXEC, CMD_TERRAFORM_LAND);
+ if (CmdFailed(ret)) break;
cost += ret;
if (flags & DC_EXEC) {
@@ -366,15 +369,14 @@ int32 CmdLevelLand(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
_additional_cash_required = ret;
return cost - ret;
}
- DoCommandByTile(tile2, 8, (curh > h)?0:1, flags, CMD_TERRAFORM_LAND);
+ DoCommandByTile(tile2, 8, (curh > h) ? 0 : 1, flags, CMD_TERRAFORM_LAND);
}
curh += (curh > h) ? -1 : 1;
}
- END_TILE_LOOP(tile2, size_x, size_y, tile)
+ } END_TILE_LOOP(tile2, size_x, size_y, tile)
- if (cost == 0) return CMD_ERROR;
- return cost;
+ return (cost == 0) ? CMD_ERROR : cost;
}
/** Purchase a land area. Actually you only purchase one tile, so