96 } |
96 } |
97 |
97 |
98 static int TerraformProc(TerraformerState *ts, TileIndex tile, int mode) |
98 static int TerraformProc(TerraformerState *ts, TileIndex tile, int mode) |
99 { |
99 { |
100 int r; |
100 int r; |
101 int32 ret; |
101 CommandCost ret; |
102 |
102 |
103 assert(tile < MapSize()); |
103 assert(tile < MapSize()); |
104 |
104 |
105 r = TerraformAllowTileProcess(ts, tile); |
105 r = TerraformAllowTileProcess(ts, tile); |
106 if (r <= 0) return r; |
106 if (r <= 0) return r; |
231 * @param flags for this command type |
231 * @param flags for this command type |
232 * @param p1 corners to terraform. |
232 * @param p1 corners to terraform. |
233 * @param p2 direction; eg up or down |
233 * @param p2 direction; eg up or down |
234 * @return error or cost of terraforming |
234 * @return error or cost of terraforming |
235 */ |
235 */ |
236 int32 CmdTerraformLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
236 CommandCost CmdTerraformLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
237 { |
237 { |
238 TerraformerState ts; |
238 TerraformerState ts; |
239 TileIndex t; |
239 TileIndex t; |
240 int direction; |
240 int direction; |
241 |
241 |
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 unused |
359 * @return error or cost of terraforming |
359 * @return error or cost of terraforming |
360 */ |
360 */ |
361 int32 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, curh; |
368 int32 ret, cost, money; |
368 int32 money; |
|
369 CommandCost ret; |
|
370 CommandCost cost; |
369 |
371 |
370 if (p1 >= MapSize()) return CMD_ERROR; |
372 if (p1 >= MapSize()) return CMD_ERROR; |
371 |
373 |
372 SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
374 SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
373 |
375 |
417 * @param flags for this command type |
419 * @param flags for this command type |
418 * @param p1 unused |
420 * @param p1 unused |
419 * @param p2 unused |
421 * @param p2 unused |
420 * @return error of cost of operation |
422 * @return error of cost of operation |
421 */ |
423 */ |
422 int32 CmdPurchaseTile(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
424 CommandCost CmdPurchaseTile(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
423 { |
425 { |
424 int32 cost; |
426 CommandCost cost; |
425 |
427 |
426 SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
428 SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
427 |
429 |
428 if (!EnsureNoVehicle(tile)) return CMD_ERROR; |
430 if (!EnsureNoVehicle(tile)) return CMD_ERROR; |
429 |
431 |
441 |
443 |
442 return cost + Town::GetTilePrice(tile); |
444 return cost + Town::GetTilePrice(tile); |
443 } |
445 } |
444 |
446 |
445 |
447 |
446 static int32 ClearTile_Clear(TileIndex tile, byte flags) |
448 static CommandCost ClearTile_Clear(TileIndex tile, byte flags) |
447 { |
449 { |
448 static const int32 clear_price_table[] = { |
450 static const int32 clear_price_table[] = { |
449 _eco->GetPrice(CEconomy::CLEAR_1), |
451 _eco->GetPrice(CEconomy::CLEAR_1), |
450 _eco->GetPrice(CEconomy::PURCHASE_LAND), |
452 _eco->GetPrice(CEconomy::PURCHASE_LAND), |
451 _eco->GetPrice(CEconomy::CLEAR_2), |
453 _eco->GetPrice(CEconomy::CLEAR_2), |
452 _eco->GetPrice(CEconomy::CLEAR_3), |
454 _eco->GetPrice(CEconomy::CLEAR_3), |
453 _eco->GetPrice(CEconomy::PURCHASE_LAND), |
455 _eco->GetPrice(CEconomy::PURCHASE_LAND), |
454 _eco->GetPrice(CEconomy::PURCHASE_LAND), |
456 _eco->GetPrice(CEconomy::PURCHASE_LAND), |
455 _eco->GetPrice(CEconomy::CLEAR_2), // XXX unused? |
457 _eco->GetPrice(CEconomy::CLEAR_2), // XXX unused? |
456 }; |
458 }; |
457 int32 price; |
459 CommandCost price; |
458 |
460 |
459 if (IsClearGround(tile, CLEAR_GRASS) && GetClearDensity(tile) == 0) { |
461 if (IsClearGround(tile, CLEAR_GRASS) && GetClearDensity(tile) == 0) { |
460 price = 0; |
462 price = 0; |
461 } else { |
463 } else { |
462 price = clear_price_table[GetClearGround(tile)]; |
464 price = clear_price_table[GetClearGround(tile)]; |
473 * @param flags for this command type |
475 * @param flags for this command type |
474 * @param p1 unused |
476 * @param p1 unused |
475 * @param p2 unused |
477 * @param p2 unused |
476 * @return error or cost of operation |
478 * @return error or cost of operation |
477 */ |
479 */ |
478 int32 CmdSellTile(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
480 CommandCost CmdSellTile(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
479 { |
481 { |
480 SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
482 SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
481 |
483 |
482 if (!IsOwnedLandTile(tile)) return CMD_ERROR; |
484 if (!IsOwnedLandTile(tile)) return CMD_ERROR; |
483 if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER) return CMD_ERROR; |
485 if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER) return CMD_ERROR; |