Changeset - r9463:b30d4730d75b
[Not reviewed]
master
0 2 0
belugas - 16 years ago 2008-06-05 01:43:03
belugas@openttd.org
(svn r13383) -Codechange: Put the cost of house removal in a class member
2 files changed with 14 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/town.h
Show inline comments
 
@@ -13,12 +13,13 @@
 
#include "date_type.h"
 
#include "town_type.h"
 
#include "player_type.h"
 
#include "settings_type.h"
 
#include "strings_type.h"
 
#include "viewport_type.h"
 
#include "economy_type.h"
 

	
 
enum {
 
	HOUSE_NO_CLASS   = 0,
 
	NEW_HOUSE_OFFSET = 110,
 
	HOUSE_MAX        = 512,
 
	INVALID_TOWN     = 0xFFFF,
 
@@ -239,12 +240,19 @@ struct HouseSpec {
 
	byte processing_time;              ///< Periodic refresh multiplier
 
	byte minimum_life;                 ///< The minimum number of years this house will survive before the town rebuilds it
 

	
 
	/* grf file related properties*/
 
	uint8 local_id;                    ///< id defined by the grf file for this house
 
	const struct GRFFile *grffile;     ///< grf file that introduced this house
 

	
 
	/**
 
	 * Get the cost for removing this house
 
	 * @return the cost (inflation corrected etc)
 
	 */
 
	Money GetRemovalCost() const;
 

	
 
};
 

	
 
extern HouseSpec _house_specs[HOUSE_MAX];
 

	
 
uint32 GetWorldPopulation();
 

	
src/town_cmd.cpp
Show inline comments
 
@@ -124,12 +124,17 @@ void Town::InitializeLayout()
 
		default: break;
 
		case TL_RANDOM: this->layout = TL_ORIGINAL; break;
 
		case TL_NO_ROADS: this->layout = TL_BETTER_ROADS; break;
 
	}
 
}
 

	
 
Money HouseSpec::GetRemovalCost() const
 
{
 
	return (_price.remove_house * this->removal_cost) >> 8;
 
}
 

	
 
// Local
 
static int _grow_town_result;
 

	
 
/* Describe the possible states */
 
enum TownGrowthResult {
 
	GROWTH_SUCCEED         = -1,
 
@@ -514,13 +519,13 @@ static CommandCost ClearTile_Town(TileIn
 
	if ((flags & DC_AUTO) && !(flags & DC_AI_BUILDING)) return_cmd_error(STR_2004_BUILDING_MUST_BE_DEMOLISHED);
 
	if (!CanDeleteHouse(tile)) return CMD_ERROR;
 

	
 
	const HouseSpec *hs = GetHouseSpecs(GetHouseType(tile));
 

	
 
	CommandCost cost(EXPENSES_CONSTRUCTION);
 
	cost.AddCost(_price.remove_house * hs->removal_cost >> 8);
 
	cost.AddCost(hs->GetRemovalCost());
 

	
 
	int rating = hs->remove_rating_decrease;
 
	_cleared_town_rating += rating;
 
	Town *t = _cleared_town = GetTownByTile(tile);
 

	
 
	if (IsValidPlayer(_current_player)) {
0 comments (0 inline, 0 general)