From 033995ec6ecd443404fa1a236c6763ddc9cce321 Mon Sep 17 00:00:00 2001 From: Darkvater Date: Thu, 12 May 2005 23:46:01 +0000 Subject: (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() --- clear_cmd.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'clear_cmd.c') 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 -- cgit v1.2.3-54-g00ecf