210 return true; |
210 return true; |
211 } |
211 } |
212 |
212 |
213 /** Terraform land |
213 /** Terraform land |
214 * @param x,y coordinates to terraform |
214 * @param x,y coordinates to terraform |
215 * @param p1 corners to terraform. Human user only north, towns more |
215 * @param p1 corners to terraform. |
216 * @param p2 direction; eg up or down |
216 * @param p2 direction; eg up or down |
217 */ |
217 */ |
218 int32 CmdTerraformLand(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
218 int32 CmdTerraformLand(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
219 { |
219 { |
220 TerraformerState ts; |
220 TerraformerState ts; |
221 TileIndex tile; |
221 TileIndex tile; |
222 int direction; |
222 int direction; |
223 |
223 |
224 TerraformerHeightMod modheight_data[576]; |
224 TerraformerHeightMod modheight_data[576]; |
225 TileIndex tile_table_data[625]; |
225 TileIndex tile_table_data[625]; |
226 |
|
227 /* A normal user can only terraform one corner, the northern one; p1 & 8 */ |
|
228 if (_current_player < MAX_PLAYERS && p1 != 8) return CMD_ERROR; |
|
229 |
226 |
230 SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
227 SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
231 |
228 |
232 _error_message = INVALID_STRING_ID; |
229 _error_message = INVALID_STRING_ID; |
233 _terraform_err_tile = 0; |
230 _terraform_err_tile = 0; |
378 |
375 |
379 if (cost == 0) return CMD_ERROR; |
376 if (cost == 0) return CMD_ERROR; |
380 return cost; |
377 return cost; |
381 } |
378 } |
382 |
379 |
383 /* Purchase a land area |
380 /** Purchase a land area. Actually you only purchase one tile, so |
384 * p1 = unused |
381 * the name is a bit confusing ;p |
385 * p2 = unused |
382 * @param x,y the tile the player is purchasing |
|
383 * @param p1 unused |
|
384 * @param p2 unused |
386 */ |
385 */ |
387 |
|
388 int32 CmdPurchaseLandArea(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
386 int32 CmdPurchaseLandArea(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
389 { |
387 { |
390 uint tile; |
388 TileIndex tile; |
391 int32 cost; |
389 int32 cost; |
392 |
390 |
393 SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
391 SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
394 |
392 |
395 tile = TILE_FROM_XY(x,y); |
393 tile = TILE_FROM_XY(x,y); |
396 |
394 |
397 if (!EnsureNoVehicle(tile)) |
395 if (!EnsureNoVehicle(tile)) return CMD_ERROR; |
398 return CMD_ERROR; |
396 |
399 |
397 if (IsTileType(tile, MP_UNMOVABLE) && _map5[tile] == 3 && _map_owner[tile] == _current_player) |
400 if (IsTileType(tile, MP_UNMOVABLE) && |
|
401 _map5[tile] == 3 && |
|
402 _map_owner[tile] == _current_player) |
|
403 return_cmd_error(STR_5807_YOU_ALREADY_OWN_IT); |
398 return_cmd_error(STR_5807_YOU_ALREADY_OWN_IT); |
404 |
399 |
405 cost = DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
400 cost = DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
406 if (cost == CMD_ERROR) |
401 if (CmdFailed(cost)) return CMD_ERROR; |
407 return CMD_ERROR; |
|
408 |
402 |
409 if (flags & DC_EXEC) { |
403 if (flags & DC_EXEC) { |
410 ModifyTile(tile, |
404 ModifyTile(tile, |
411 MP_SETTYPE(MP_UNMOVABLE) | MP_MAPOWNER_CURRENT | MP_MAP5, |
405 MP_SETTYPE(MP_UNMOVABLE) | MP_MAPOWNER_CURRENT | MP_MAP5, |
412 3 /* map5 */ |
406 3 /* map5 */ |
437 if (price == NULL) |
431 if (price == NULL) |
438 return 0; |
432 return 0; |
439 return *price; |
433 return *price; |
440 } |
434 } |
441 |
435 |
|
436 /** Sell a land area. Actually you only sell one tile, so |
|
437 * the name is a bit confusing ;p |
|
438 * @param x,y the tile the player is selling |
|
439 * @param p1 unused |
|
440 * @param p2 unused |
|
441 */ |
442 int32 CmdSellLandArea(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
442 int32 CmdSellLandArea(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
443 { |
443 { |
444 uint tile; |
444 TileIndex tile; |
445 |
445 |
446 SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
446 SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
447 |
447 |
448 tile = TILE_FROM_XY(x,y); |
448 tile = TILE_FROM_XY(x,y); |
449 |
449 |
450 if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER) |
450 if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER) |
451 return CMD_ERROR; |
451 return CMD_ERROR; |
452 |
452 |
453 if (!EnsureNoVehicle(tile)) |
453 if (!EnsureNoVehicle(tile)) return CMD_ERROR; |
454 return CMD_ERROR; |
|
455 |
454 |
456 if (flags & DC_EXEC) |
455 if (flags & DC_EXEC) |
457 DoClearSquare(tile); |
456 DoClearSquare(tile); |
458 |
457 |
459 return - _price.purchase_land*2; |
458 return - _price.purchase_land * 2; |
460 } |
459 } |
461 |
460 |
462 |
461 |
463 #include "table/clear_land.h" |
462 #include "table/clear_land.h" |
464 |
463 |