Changeset - r16750:d175f523b128
[Not reviewed]
master
0 4 0
rubidium - 14 years ago 2010-12-13 11:21:53
rubidium@openttd.org
(svn r21493) -Codechange: don't use the full 32 bits of the level land command to tell whether to raise, lower or keep the level of the first selected tile
4 files changed with 22 insertions and 7 deletions:
0 comments (0 inline, 0 general)
src/ai/api/ai_tile.cpp
Show inline comments
 
@@ -231,13 +231,13 @@
 

	
 
/* static */ bool AITile::LevelTiles(TileIndex start_tile, TileIndex end_tile)
 
{
 
	EnforcePrecondition(false, start_tile < ::MapSize());
 
	EnforcePrecondition(false, end_tile < ::MapSize());
 

	
 
	return AIObject::DoCommand(end_tile, start_tile, 0, CMD_LEVEL_LAND);
 
	return AIObject::DoCommand(end_tile, start_tile, LM_LEVEL << 1, CMD_LEVEL_LAND);
 
}
 

	
 
/* static */ bool AITile::DemolishTile(TileIndex tile)
 
{
 
	EnforcePrecondition(false, ::IsValidTile(tile));
 

	
src/map_type.h
Show inline comments
 
@@ -72,7 +72,14 @@ static const uint MAX_MAP_SIZE      = 1 
 
 * Watch out! There are _no_ brackets around here, to prevent intermediate
 
 * rounding! Be careful when using this!
 
 * This value should be sqrt(2)/2 ~ 0.7071
 
 */
 
#define STRAIGHT_TRACK_LENGTH 7071/10000
 

	
 
/** Argument for CmdLevelLand describing what to do. */
 
enum LevelMode {
 
	LM_LEVEL, ///< Level the land.
 
	LM_LOWER, ///< Lower the land.
 
	LM_RAISE, ///< Raise the land.
 
};
 

	
 
#endif /* MAP_TYPE_H */
src/terraform_cmd.cpp
Show inline comments
 
@@ -375,13 +375,14 @@ CommandCost CmdTerraformLand(TileIndex t
 

	
 
/**
 
 * Levels a selected (rectangle) area of land
 
 * @param tile end tile of area-drag
 
 * @param flags for this command type
 
 * @param p1 start tile of area drag
 
 * @param p2 height difference; eg raise (+1), lower (-1) or level (0)
 
 * @param p2 various bitstuffed data.
 
 *  bits 1 - 2: Mode of leveling \c LevelMode.
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdLevelLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
{
 
	if (p1 >= MapSize()) return CMD_ERROR;
 
@@ -389,20 +390,27 @@ CommandCost CmdLevelLand(TileIndex tile,
 
	_terraform_err_tile = INVALID_TILE;
 

	
 
	/* remember level height */
 
	uint oldh = TileHeight(p1);
 

	
 
	/* compute new height */
 
	uint h = oldh + (int8)p2;
 
	uint h = oldh;
 
	LevelMode lm = (LevelMode)GB(p2, 1, 2);
 
	switch (lm) {
 
		case LM_LEVEL: break;
 
		case LM_RAISE: h++; break;
 
		case LM_LOWER: h--; break;
 
		default: return CMD_ERROR;
 
	}
 

	
 
	/* Check range of destination height */
 
	if (h > MAX_TILE_HEIGHT) return_cmd_error((oldh == 0) ? STR_ERROR_ALREADY_AT_SEA_LEVEL : STR_ERROR_TOO_HIGH);
 

	
 
	Money money = GetAvailableMoneyForCommand();
 
	CommandCost cost(EXPENSES_CONSTRUCTION);
 
	CommandCost last_error((p2 == 0) ? STR_ERROR_ALREADY_LEVELLED : INVALID_STRING_ID);
 
	CommandCost last_error(lm == LM_LEVEL ? STR_ERROR_ALREADY_LEVELLED : INVALID_STRING_ID);
 
	bool had_success = false;
 

	
 
	TileArea ta(tile, p1);
 
	TILE_AREA_LOOP(tile, ta) {
 
		uint curh = TileHeight(tile);
 
		while (curh != h) {
src/terraform_gui.cpp
Show inline comments
 
@@ -107,19 +107,19 @@ bool GUIPlaceProcDragXY(ViewportDragDrop
 

	
 
	switch (proc) {
 
		case DDSP_DEMOLISH_AREA:
 
			DoCommandP(end_tile, start_tile, 0, CMD_CLEAR_AREA | CMD_MSG(STR_ERROR_CAN_T_CLEAR_THIS_AREA), CcPlaySound10);
 
			break;
 
		case DDSP_RAISE_AND_LEVEL_AREA:
 
			DoCommandP(end_tile, start_tile, 1, CMD_LEVEL_LAND | CMD_MSG(STR_ERROR_CAN_T_RAISE_LAND_HERE), CcTerraform);
 
			DoCommandP(end_tile, start_tile, LM_RAISE << 1, CMD_LEVEL_LAND | CMD_MSG(STR_ERROR_CAN_T_RAISE_LAND_HERE), CcTerraform);
 
			break;
 
		case DDSP_LOWER_AND_LEVEL_AREA:
 
			DoCommandP(end_tile, start_tile, (uint32)-1, CMD_LEVEL_LAND | CMD_MSG(STR_ERROR_CAN_T_LOWER_LAND_HERE), CcTerraform);
 
			DoCommandP(end_tile, start_tile, LM_LOWER << 1, CMD_LEVEL_LAND | CMD_MSG(STR_ERROR_CAN_T_LOWER_LAND_HERE), CcTerraform);
 
			break;
 
		case DDSP_LEVEL_AREA:
 
			DoCommandP(end_tile, start_tile, 0, CMD_LEVEL_LAND | CMD_MSG(STR_ERROR_CAN_T_LEVEL_LAND_HERE), CcTerraform);
 
			DoCommandP(end_tile, start_tile, LM_LEVEL << 1, CMD_LEVEL_LAND | CMD_MSG(STR_ERROR_CAN_T_LEVEL_LAND_HERE), CcTerraform);
 
			break;
 
		case DDSP_CREATE_ROCKS:
 
			GenerateRockyArea(end_tile, start_tile);
 
			break;
 
		case DDSP_CREATE_DESERT:
 
			GenerateDesertArea(end_tile, start_tile);
0 comments (0 inline, 0 general)