File diff r11089:babc36cbd948 → r11090:9276cea703d4
src/unmovable_cmd.cpp
Show inline comments
 
@@ -40,25 +40,25 @@ static inline const UnmovableSpec *GetUn
 
{
 
	assert(type < UNMOVABLE_MAX);
 
	return &_original_unmovable[type];
 
}
 

	
 
/** Destroy a HQ.
 
 * During normal gameplay you can only implicitely destroy a HQ when you are
 
 * rebuilding it. Otherwise, only water can destroy it.
 
 * @param cid Company requesting the destruction of his HQ
 
 * @param flags docommand flags of calling function
 
 * @return cost of the operation
 
 */
 
static CommandCost DestroyCompanyHQ(CompanyID cid, uint32 flags)
 
static CommandCost DestroyCompanyHQ(CompanyID cid, DoCommandFlag flags)
 
{
 
	Company *c = GetCompany(cid);
 

	
 
	if (flags & DC_EXEC) {
 
		TileIndex t = c->location_of_HQ;
 

	
 
		DoClearSquare(t);
 
		DoClearSquare(t + TileDiffXY(0, 1));
 
		DoClearSquare(t + TileDiffXY(1, 0));
 
		DoClearSquare(t + TileDiffXY(1, 1));
 
		c->location_of_HQ = INVALID_TILE; // reset HQ position
 
		InvalidateWindow(WC_COMPANY, cid);
 
@@ -80,33 +80,33 @@ void UpdateCompanyHQ(Company *c, uint sc
 
	(val++, score < 520) ||
 
	(val++, score < 720) ||
 
	(val++, true);
 

	
 
	EnlargeCompanyHQ(tile, val);
 

	
 
	MarkTileDirtyByTile(tile);
 
	MarkTileDirtyByTile(tile + TileDiffXY(0, 1));
 
	MarkTileDirtyByTile(tile + TileDiffXY(1, 0));
 
	MarkTileDirtyByTile(tile + TileDiffXY(1, 1));
 
}
 

	
 
extern CommandCost CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invalid_dirs, StationID *station, bool check_clear = true);
 
extern CommandCost CheckFlatLandBelow(TileIndex tile, uint w, uint h, DoCommandFlag flags, uint invalid_dirs, StationID *station, bool check_clear = true);
 

	
 
/** Build or relocate the HQ. This depends if the HQ is already built or not
 
 * @param tile tile where the HQ will be built or relocated to
 
 * @param flags type of operation
 
 * @param p1 unused
 
 * @param p2 unused
 
 */
 
CommandCost CmdBuildCompanyHQ(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdBuildCompanyHQ(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
{
 
	Company *c = GetCompany(_current_company);
 
	CommandCost cost(EXPENSES_PROPERTY);
 

	
 
	cost = CheckFlatLandBelow(tile, 2, 2, flags, 0, NULL);
 
	if (CmdFailed(cost)) return cost;
 

	
 
	if (c->location_of_HQ != INVALID_TILE) { // Moving HQ
 
		cost.AddCost(DestroyCompanyHQ(_current_company, flags));
 
	}
 

	
 
	if (flags & DC_EXEC) {
 
@@ -122,25 +122,25 @@ CommandCost CmdBuildCompanyHQ(TileIndex 
 

	
 
	return cost;
 
}
 

	
 
/** Purchase a land area. Actually you only purchase one tile, so
 
 * the name is a bit confusing ;p
 
 * @param tile the tile the company is purchasing
 
 * @param flags for this command type
 
 * @param p1 unused
 
 * @param p2 unused
 
 * @return error of cost of operation
 
 */
 
CommandCost CmdPurchaseLandArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdPurchaseLandArea(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
{
 
	CommandCost cost(EXPENSES_CONSTRUCTION);
 

	
 
	if (IsOwnedLandTile(tile) && IsTileOwner(tile, _current_company)) {
 
		return_cmd_error(STR_5807_YOU_ALREADY_OWN_IT);
 
	}
 

	
 
	cost = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
 
	if (CmdFailed(cost)) return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
 
		MakeOwnedLand(tile, _current_company);
 
@@ -149,25 +149,25 @@ CommandCost CmdPurchaseLandArea(TileInde
 

	
 
	return cost.AddCost(GetUnmovableSpec(UNMOVABLE_OWNED_LAND)->GetBuildingCost());
 
}
 

	
 
/** Sell a land area. Actually you only sell one tile, so
 
 * the name is a bit confusing ;p
 
 * @param tile the tile the company is selling
 
 * @param flags for this command type
 
 * @param p1 unused
 
 * @param p2 unused
 
 * @return error or cost of operation
 
 */
 
CommandCost CmdSellLandArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdSellLandArea(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
{
 
	if (!IsOwnedLandTile(tile)) return CMD_ERROR;
 
	if (!CheckTileOwnership(tile) && _current_company != OWNER_WATER) return CMD_ERROR;
 

	
 
	if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) DoClearSquare(tile);
 

	
 
	return CommandCost(EXPENSES_CONSTRUCTION, - GetUnmovableSpec(UNMOVABLE_OWNED_LAND)->GetRemovalCost());
 
}
 

	
 
static Foundation GetFoundation_Unmovable(TileIndex tile, Slope tileh);
 
@@ -249,25 +249,25 @@ static uint GetSlopeZ_Unmovable(TileInde
 

	
 
		return z + GetPartialZ(x & 0xF, y & 0xF, tileh);
 
	} else {
 
		return GetTileMaxZ(tile);
 
	}
 
}
 

	
 
static Foundation GetFoundation_Unmovable(TileIndex tile, Slope tileh)
 
{
 
	return IsOwnedLand(tile) ? FOUNDATION_NONE : FlatteningFoundation(tileh);
 
}
 

	
 
static CommandCost ClearTile_Unmovable(TileIndex tile, byte flags)
 
static CommandCost ClearTile_Unmovable(TileIndex tile, DoCommandFlag flags)
 
{
 
	if (IsCompanyHQ(tile)) {
 
		if (_current_company == OWNER_WATER) {
 
			return DestroyCompanyHQ(GetTileOwner(tile), DC_EXEC);
 
		} else {
 
			return_cmd_error(STR_5804_COMPANY_HEADQUARTERS_IN);
 
		}
 
	}
 

	
 
	if (IsOwnedLand(tile)) {
 
		return DoCommand(tile, 0, 0, flags, CMD_SELL_LAND_AREA);
 
	}
 
@@ -477,25 +477,25 @@ static void ChangeTileOwner_Unmovable(Ti
 
			SetBit(t->statues, new_owner);
 
			SetTileOwner(tile, new_owner);
 
		} else {
 
			DoClearSquare(tile);
 
		}
 

	
 
		InvalidateWindow(WC_TOWN_AUTHORITY, town);
 
	} else {
 
		DoClearSquare(tile);
 
	}
 
}
 

	
 
static CommandCost TerraformTile_Unmovable(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new)
 
static CommandCost TerraformTile_Unmovable(TileIndex tile, DoCommandFlag flags, uint z_new, Slope tileh_new)
 
{
 
	/* Owned land remains unsold */
 
	if (IsOwnedLand(tile) && CheckTileOwnership(tile)) return CommandCost();
 

	
 
	if (AutoslopeEnabled() && (IsStatue(tile) || IsCompanyHQ(tile))) {
 
		if (!IsSteepSlope(tileh_new) && (z_new + GetSlopeMaxZ(tileh_new) == GetTileMaxZ(tile))) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
 
	}
 

	
 
	return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
 
}
 

	
 
extern const TileTypeProcs _tile_type_unmovable_procs = {