src/clear_cmd.cpp
branchgamebalance
changeset 9899 cde52f745560
parent 9895 7bd07f43b0e3
child 9902 ed8f92929297
equal deleted inserted replaced
9898:324dad59eb35 9899:cde52f745560
    19 #include "variables.h"
    19 #include "variables.h"
    20 #include "table/sprites.h"
    20 #include "table/sprites.h"
    21 #include "unmovable_map.h"
    21 #include "unmovable_map.h"
    22 #include "genworld.h"
    22 #include "genworld.h"
    23 #include "industry.h"
    23 #include "industry.h"
       
    24 #include "town.h"
    24 
    25 
    25 struct TerraformerHeightMod {
    26 struct TerraformerHeightMod {
    26 	TileIndex tile;
    27 	TileIndex tile;
    27 	byte height;
    28 	byte height;
    28 };
    29 };
   407 	} END_TILE_LOOP(tile2, size_x, size_y, tile)
   408 	} END_TILE_LOOP(tile2, size_x, size_y, tile)
   408 
   409 
   409 	return (cost == 0) ? CMD_ERROR : cost;
   410 	return (cost == 0) ? CMD_ERROR : cost;
   410 }
   411 }
   411 
   412 
   412 /** Purchase a land area. Actually you only purchase one tile, so
   413 /**
   413  * the name is a bit confusing ;p
   414  * Purchase a single tile
   414  * @param tile the tile the player is purchasing
   415  * @param tile the tile the player is purchasing
   415  * @param flags for this command type
   416  * @param flags for this command type
   416  * @param p1 unused
   417  * @param p1 unused
   417  * @param p2 unused
   418  * @param p2 unused
   418  * @return error of cost of operation
   419  * @return error of cost of operation
   419  */
   420  */
   420 int32 CmdPurchaseLandArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
   421 int32 CmdPurchaseTile(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
   421 {
   422 {
   422 	int32 cost;
   423 	int32 cost;
   423 
   424 
   424 	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
   425 	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
   425 
   426 
   435 	if (flags & DC_EXEC) {
   436 	if (flags & DC_EXEC) {
   436 		MakeOwnedLand(tile, _current_player);
   437 		MakeOwnedLand(tile, _current_player);
   437 		MarkTileDirtyByTile(tile);
   438 		MarkTileDirtyByTile(tile);
   438 	}
   439 	}
   439 
   440 
   440 	return cost + _price.purchase_land * 10;
   441 	uint rad;
       
   442 	Town::GetRadiusGroupForTile(tile, rad);
       
   443 	return cost + (_price.purchase_land * 10) * rad * rad;
   441 }
   444 }
   442 
   445 
   443 
   446 
   444 static int32 ClearTile_Clear(TileIndex tile, byte flags)
   447 static int32 ClearTile_Clear(TileIndex tile, byte flags)
   445 {
   448 {
   463 	if (flags & DC_EXEC) DoClearSquare(tile);
   466 	if (flags & DC_EXEC) DoClearSquare(tile);
   464 
   467 
   465 	return price;
   468 	return price;
   466 }
   469 }
   467 
   470 
   468 /** Sell a land area. Actually you only sell one tile, so
   471 /**
   469  * the name is a bit confusing ;p
   472  * Sell a tile
   470  * @param tile the tile the player is selling
   473  * @param tile the tile the player is selling
   471  * @param flags for this command type
   474  * @param flags for this command type
   472  * @param p1 unused
   475  * @param p1 unused
   473  * @param p2 unused
   476  * @param p2 unused
   474  * @return error or cost of operation
   477  * @return error or cost of operation
   475  */
   478  */
   476 int32 CmdSellLandArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
   479 int32 CmdSellTile(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
   477 {
   480 {
   478 	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
   481 	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
   479 
   482 
   480 	if (!IsOwnedLandTile(tile)) return CMD_ERROR;
   483 	if (!IsOwnedLandTile(tile)) return CMD_ERROR;
   481 	if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER) return CMD_ERROR;
   484 	if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER) return CMD_ERROR;
   483 
   486 
   484 	if (!EnsureNoVehicle(tile)) return CMD_ERROR;
   487 	if (!EnsureNoVehicle(tile)) return CMD_ERROR;
   485 
   488 
   486 	if (flags & DC_EXEC) DoClearSquare(tile);
   489 	if (flags & DC_EXEC) DoClearSquare(tile);
   487 
   490 
   488 	return - _price.purchase_land * 2;
   491 	uint rad;
       
   492 	Town::GetRadiusGroupForTile(tile, rad);
       
   493 	return -(_price.purchase_land * 10) * rad * rad;
   489 }
   494 }
   490 
   495 
   491 
   496 
   492 #include "table/clear_land.h"
   497 #include "table/clear_land.h"
   493 
   498