353 |
353 |
354 /** Levels a selected (rectangle) area of land |
354 /** Levels a selected (rectangle) area of land |
355 * @param tile end tile of area-drag |
355 * @param tile end tile of area-drag |
356 * @param flags for this command type |
356 * @param flags for this command type |
357 * @param p1 start tile of area drag |
357 * @param p1 start tile of area drag |
358 * @param p2 unused |
358 * @param p2 height difference; eg raise (+1), lower (-1) or level (0) |
359 * @return error or cost of terraforming |
359 * @return error or cost of terraforming |
360 */ |
360 */ |
361 CommandCost CmdLevelLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
361 CommandCost CmdLevelLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
362 { |
362 { |
363 int size_x, size_y; |
363 int size_x, size_y; |
364 int ex; |
364 int ex; |
365 int ey; |
365 int ey; |
366 int sx, sy; |
366 int sx, sy; |
367 uint h, curh; |
367 uint h, oldh, curh; |
368 CommandCost money; |
368 CommandCost money; |
369 CommandCost ret; |
369 CommandCost ret; |
370 CommandCost cost; |
370 CommandCost cost; |
371 |
371 |
372 if (p1 >= MapSize()) return CMD_ERROR; |
372 if (p1 >= MapSize()) return CMD_ERROR; |
373 |
373 |
374 SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
374 SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
375 |
375 |
376 /* remember level height */ |
376 /* remember level height */ |
377 h = TileHeight(p1); |
377 oldh = TileHeight(p1); |
|
378 |
|
379 /* compute new height */ |
|
380 h = oldh + p2; |
|
381 |
|
382 /* Check range of destination height */ |
|
383 if (h > MAX_TILE_HEIGHT) return_cmd_error((oldh == 0) ? STR_1003_ALREADY_AT_SEA_LEVEL : STR_1004_TOO_HIGH); |
378 |
384 |
379 /* make sure sx,sy are smaller than ex,ey */ |
385 /* make sure sx,sy are smaller than ex,ey */ |
380 ex = TileX(tile); |
386 ex = TileX(tile); |
381 ey = TileY(tile); |
387 ey = TileY(tile); |
382 sx = TileX(p1); |
388 sx = TileX(p1); |