Changeset - r18446:7b57061bbb9d
[Not reviewed]
master
0 6 0
truebrain - 13 years ago 2011-11-23 16:07:14
truebrain@openttd.org
(svn r23300) -Add: show on the GUI when a town grows and make a general framework to store goals of a town
6 files changed with 123 insertions and 80 deletions:
0 comments (0 inline, 0 general)
src/lang/english.txt
Show inline comments
 
@@ -2570,15 +2570,20 @@ STR_TOWN_POPULATION                     
 
STR_TOWN_VIEW_TOWN_CAPTION                                      :{WHITE}{TOWN}
 
STR_TOWN_VIEW_CITY_CAPTION                                      :{WHITE}{TOWN} (City)
 
STR_TOWN_VIEW_POPULATION_HOUSES                                 :{BLACK}Population: {ORANGE}{COMMA}{BLACK}  Houses: {ORANGE}{COMMA}
 
STR_TOWN_VIEW_PASSENGERS_LAST_MONTH_MAX                         :{BLACK}Passengers last month: {ORANGE}{COMMA}{BLACK}  max: {ORANGE}{COMMA}
 
STR_TOWN_VIEW_MAIL_LAST_MONTH_MAX                               :{BLACK}Mail last month: {ORANGE}{COMMA}{BLACK}  max: {ORANGE}{COMMA}
 
STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH                              :{BLACK}Cargo needed for town growth:
 
STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_REQUIRED                     :{ORANGE}{STRING}{BLACK} required
 
STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_REQUIRED_GENERAL             :{ORANGE}{STRING}{RED} required
 
STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_REQUIRED_WINTER              :{ORANGE}{STRING}{BLACK} required in winter
 
STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_LAST_MONTH                   :{ORANGE}{CARGO_LONG}{BLACK} delivered last month
 
STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_DELIVERED_GENERAL            :{ORANGE}{STRING}{GREEN} delivered
 
STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_REQUIRED                     :{ORANGE}{CARGO_TINY} / {CARGO_LONG}{RED} (still required)
 
STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_DELIVERED                    :{ORANGE}{CARGO_TINY} / {CARGO_LONG}{GREEN} (delivered)
 
STR_TOWN_VIEW_TOWN_GROWS_EVERY                                  :{BLACK}Town grows every {ORANGE}{COMMA}{BLACK} day{P "" s}
 
STR_TOWN_VIEW_TOWN_GROWS_EVERY_FUNDED                           :{BLACK}Town grows every {ORANGE}{COMMA}{BLACK} day{P "" s} (funded)
 
STR_TOWN_VIEW_TOWN_GROW_STOPPED                                 :{BLACK}Town is {RED}not{BLACK} growing
 
STR_TOWN_VIEW_NOISE_IN_TOWN                                     :{BLACK}Noise limit in town: {ORANGE}{COMMA}{BLACK}  max: {ORANGE}{COMMA}
 
STR_TOWN_VIEW_CENTER_TOOLTIP                                    :{BLACK}Centre the main view on town location. Ctrl+Click opens a new viewport on town location
 
STR_TOWN_VIEW_LOCAL_AUTHORITY_BUTTON                            :{BLACK}Local authority
 
STR_TOWN_VIEW_LOCAL_AUTHORITY_TOOLTIP                           :{BLACK}Show information on local authority
 
STR_TOWN_VIEW_RENAME_TOOLTIP                                    :{BLACK}Change town name
 

	
src/saveload/oldloader_sl.cpp
Show inline comments
 
@@ -563,13 +563,13 @@ static const OldChunks town_chunk[] = {
 
	OCL_SVAR( OC_INT16, Town, ratings[7] ),
 

	
 
	OCL_SVAR( OC_FILE_U32 | OC_VAR_U16, Town, have_ratings ),
 
	OCL_SVAR( OC_FILE_U32 | OC_VAR_U16, Town, statues ),
 
	OCL_NULL( 2 ),         ///< num_houses,        no longer in use
 
	OCL_SVAR(  OC_FILE_U8 | OC_VAR_U16, Town, time_until_rebuild ),
 
	OCL_SVAR(  OC_FILE_U8 | OC_VAR_I16, Town, growth_rate ),
 
	OCL_SVAR(  OC_FILE_U8 | OC_VAR_U16, Town, growth_rate ),
 

	
 
	OCL_SVAR( OC_FILE_U16 | OC_VAR_U32, Town, supplied[CT_PASSENGERS].new_max ),
 
	OCL_SVAR( OC_FILE_U16 | OC_VAR_U32, Town, supplied[CT_MAIL].new_max ),
 
	OCL_SVAR( OC_FILE_U16 | OC_VAR_U32, Town, supplied[CT_PASSENGERS].new_act ),
 
	OCL_SVAR( OC_FILE_U16 | OC_VAR_U32, Town, supplied[CT_MAIL].new_act ),
 
	OCL_SVAR( OC_FILE_U16 | OC_VAR_U32, Town, supplied[CT_PASSENGERS].old_max ),
src/saveload/town_sl.cpp
Show inline comments
 
@@ -150,19 +150,23 @@ static const SaveLoad _town_desc[] = {
 

	
 
	SLE_CONDVAR(Town, received[TE_FOOD].old_act,       SLE_UINT16,                 0, 164),
 
	SLE_CONDVAR(Town, received[TE_WATER].old_act,      SLE_UINT16,                 0, 164),
 
	SLE_CONDVAR(Town, received[TE_FOOD].new_act,       SLE_UINT16,                 0, 164),
 
	SLE_CONDVAR(Town, received[TE_WATER].new_act,      SLE_UINT16,                 0, 164),
 

	
 
	SLE_CONDARR(Town, goal, SLE_UINT32, NUM_TE, 165, SL_MAX_VERSION),
 

	
 
	SLE_CONDVAR(Town, time_until_rebuild,    SLE_FILE_U8 | SLE_VAR_U16,  0, 53),
 
	SLE_CONDVAR(Town, grow_counter,          SLE_FILE_U8 | SLE_VAR_U16,  0, 53),
 
	SLE_CONDVAR(Town, growth_rate,           SLE_FILE_U8 | SLE_VAR_I16,  0, 53),
 

	
 
	SLE_CONDVAR(Town, time_until_rebuild,    SLE_UINT16,                54, SL_MAX_VERSION),
 
	SLE_CONDVAR(Town, grow_counter,          SLE_UINT16,                54, SL_MAX_VERSION),
 
	SLE_CONDVAR(Town, growth_rate,           SLE_INT16,                 54, SL_MAX_VERSION),
 

	
 
	SLE_CONDVAR(Town, growth_rate,           SLE_FILE_I16 | SLE_VAR_U16, 54, 164),
 
	SLE_CONDVAR(Town, growth_rate,           SLE_UINT16,                 165, SL_MAX_VERSION),
 

	
 
	    SLE_VAR(Town, fund_buildings_months, SLE_UINT8),
 
	    SLE_VAR(Town, road_build_months,     SLE_UINT8),
 

	
 
	SLE_CONDVAR(Town, exclusivity,           SLE_UINT8,                  2, SL_MAX_VERSION),
 
	SLE_CONDVAR(Town, exclusive_counter,     SLE_UINT8,                  2, SL_MAX_VERSION),
src/town.h
Show inline comments
 
@@ -29,12 +29,15 @@ struct BuildingCounts {
 

	
 
static const uint CUSTOM_TOWN_NUMBER_DIFFICULTY  = 4; ///< value for custom town number in difficulty settings
 
static const uint CUSTOM_TOWN_MAX_NUMBER = 5000;  ///< this is the maximum number of towns a user can specify in customisation
 

	
 
static const uint INVALID_TOWN = 0xFFFF;
 

	
 
static const uint TOWN_GROWTH_WINTER = 0xFFFFFFFE; ///< The town only needs this cargo in the winter (any amount)
 
static const uint TOWN_GROWTH_DESERT = 0xFFFFFFFF; ///< The town needs the cargo for growth when on desert (any amount)
 

	
 
typedef Pool<Town, TownID, 64, 64000> TownPool;
 
extern TownPool _town_pool;
 

	
 
/** Town data structure. */
 
struct Town : TownPool::PoolItem<&_town_pool> {
 
	TileIndex xy;                  ///< town center tile
 
@@ -66,19 +69,20 @@ struct Town : TownPool::PoolItem<&_town_
 
	CompanyByte exclusivity;       ///< which company has exclusivity
 
	uint8 exclusive_counter;       ///< months till the exclusivity expires
 
	int16 ratings[MAX_COMPANIES];  ///< ratings of each company for this town
 

	
 
	TransportedCargoStat<uint32> supplied[NUM_CARGO]; ///< Cargo statistics about supplied cargo.
 
	TransportedCargoStat<uint16> received[NUM_TE];    ///< Cargo statistics about received cargotypes.
 
	uint32 goal[NUM_TE];                              ///< Amount of cargo required for the town to grow.
 

	
 
	inline byte GetPercentTransported(CargoID cid) const { return this->supplied[cid].old_act * 256 / (this->supplied[cid].old_max + 1); }
 

	
 
	uint16 time_until_rebuild;     ///< time until we rebuild a house
 

	
 
	uint16 grow_counter;           ///< counter to count when to grow
 
	int16 growth_rate;             ///< town growth rate
 
	uint16 growth_rate;            ///< town growth rate
 

	
 
	byte fund_buildings_months;    ///< fund buildings program in action?
 
	byte road_build_months;        ///< fund road reconstruction in action?
 

	
 
	bool larger_town;              ///< if this is a larger town and should grow more quickly
 
	TownLayoutByte layout;         ///< town specific road layout
 
@@ -175,12 +179,13 @@ CommandCost CheckIfAuthorityAllowsNewSta
 
Town *ClosestTownFromTile(TileIndex tile, uint threshold);
 
void ChangeTownRating(Town *t, int add, int max, DoCommandFlag flags);
 
HouseZonesBits GetTownRadiusGroup(const Town *t, TileIndex tile);
 
void SetTownRatingTestMode(bool mode);
 
uint GetMaskOfTownActions(int *nump, CompanyID cid, const Town *t);
 
bool GenerateTowns(TownLayout layout);
 
const CargoSpec *FindFirstCargoWithTownEffect(TownEffect effect);
 

	
 

	
 
/** Town actions of a company. */
 
enum TownActions {
 
	TACT_NONE             = 0x00, ///< Empty action set.
 

	
src/town_cmd.cpp
Show inline comments
 
@@ -1412,12 +1412,24 @@ static void DoCreateTown(Town *t, TileIn
 
	UpdateTownRadius(t);
 
	t->flags = 0;
 
	t->population = 0;
 
	t->grow_counter = 0;
 
	t->growth_rate = 250;
 

	
 
	/* Set the default cargo requirement for town growth */
 
	switch (_settings_game.game_creation.landscape) {
 
		case LT_ARCTIC:
 
			if (FindFirstCargoWithTownEffect(TE_FOOD) != NULL) t->goal[TE_FOOD] = TOWN_GROWTH_WINTER;
 
			break;
 

	
 
		case LT_TROPIC:
 
			if (FindFirstCargoWithTownEffect(TE_FOOD) != NULL) t->goal[TE_FOOD] = TOWN_GROWTH_DESERT;
 
			if (FindFirstCargoWithTownEffect(TE_WATER) != NULL) t->goal[TE_WATER] = TOWN_GROWTH_DESERT;
 
			break;
 
	}
 

	
 
	t->fund_buildings_months = 0;
 

	
 
	for (uint i = 0; i != MAX_COMPANIES; i++) t->ratings[i] = RATING_INITIAL;
 

	
 
	t->have_ratings = 0;
 
	t->exclusivity = INVALID_COMPANY;
 
@@ -2322,12 +2334,26 @@ CommandCost CmdRenameTown(TileIndex tile
 
		UpdateAllStationVirtCoords();
 
	}
 
	return CommandCost();
 
}
 

	
 
/**
 
 * Determines the first cargo with a certain town effect
 
 * @param effect Town effect of interest
 
 * @return first active cargo slot with that effect
 
 */
 
const CargoSpec *FindFirstCargoWithTownEffect(TownEffect effect)
 
{
 
	const CargoSpec *cs;
 
	FOR_ALL_CARGOSPECS(cs) {
 
		if (cs->town_effect == effect) return cs;
 
	}
 
	return NULL;
 
}
 

	
 
/**
 
 * Expand a town (scenario editor only).
 
 * @param tile Unused.
 
 * @param flags Type of operation.
 
 * @param p1 Town ID to expand.
 
 * @param p2 Unused.
 
 * @param text Unused.
 
@@ -2556,12 +2582,14 @@ static CommandCost TownActionFundBuildin
 
		/* Build next tick */
 
		t->grow_counter = 1;
 
		/* If we were not already growing */
 
		SetBit(t->flags, TOWN_IS_FUNDED);
 
		/* And grow for 3 months */
 
		t->fund_buildings_months = 3;
 

	
 
		SetWindowDirty(WC_TOWN_VIEW, t->index);
 
	}
 
	return CommandCost();
 
}
 

	
 
static CommandCost TownActionBuyRights(Town *t, DoCommandFlag flags)
 
{
 
@@ -2696,29 +2724,26 @@ CommandCost CmdDoTownAction(TileIndex ti
 
		SetWindowDirty(WC_TOWN_AUTHORITY, p1);
 
	}
 

	
 
	return cost;
 
}
 

	
 
static void UpdateTownGrowRate(Town *t)
 
static void UpdateTownRating(Town *t)
 
{
 
	/* Increase company ratings if they're low */
 
	const Company *c;
 
	FOR_ALL_COMPANIES(c) {
 
		if (t->ratings[c->index] < RATING_GROWTH_MAXIMUM) {
 
			t->ratings[c->index] = min((int)RATING_GROWTH_MAXIMUM, t->ratings[c->index] + RATING_GROWTH_UP_STEP);
 
		}
 
	}
 

	
 
	int n = 0;
 

	
 
	const Station *st;
 
	FOR_ALL_STATIONS(st) {
 
		if (DistanceSquare(st->xy, t->xy) <= t->squared_town_zone_radius[0]) {
 
			if (st->time_since_load <= 20 || st->time_since_unload <= 20) {
 
				n++;
 
				if (Company::IsValidID(st->owner)) {
 
					int new_rating = t->ratings[st->owner] + RATING_STATION_UP_STEP;
 
					t->ratings[st->owner] = min(new_rating, INT16_MAX); // do not let it overflow
 
				}
 
			} else {
 
				if (Company::IsValidID(st->owner)) {
 
@@ -2732,42 +2757,58 @@ static void UpdateTownGrowRate(Town *t)
 
	/* clamp all ratings to valid values */
 
	for (uint i = 0; i < MAX_COMPANIES; i++) {
 
		t->ratings[i] = Clamp(t->ratings[i], RATING_MINIMUM, RATING_MAXIMUM);
 
	}
 

	
 
	SetWindowDirty(WC_TOWN_AUTHORITY, t->index);
 

	
 
}
 

	
 
static void UpdateTownGrowRate(Town *t)
 
{
 
	ClrBit(t->flags, TOWN_IS_FUNDED);
 
	SetWindowDirty(WC_TOWN_VIEW, t->index);
 

	
 
	if (_settings_game.economy.town_growth_rate == 0 && t->fund_buildings_months == 0) return;
 

	
 
	/* Check if all goals are reached for this town to grow */
 
	for (int i = TE_BEGIN; i < TE_END; i++) {
 
		if (t->goal[i] == TOWN_GROWTH_WINTER && TileHeight(t->xy) >= GetSnowLine() && t->received[i].old_act == 0 && t->population > 90) return;
 
		if (t->goal[i] == TOWN_GROWTH_DESERT && GetTropicZone(t->xy) == TROPICZONE_DESERT && t->received[i].old_act == 0 && t->population > 60) return;
 
		if (t->goal[i] > t->received[i].old_act) return;
 
	}
 

	
 
	/**
 
	 * Towns are processed every TOWN_GROWTH_TICKS ticks, and this is the
 
	 * number of times towns are processed before a new building is built.
 
	 */
 
	static const uint16 _grow_count_values[2][6] = {
 
		{ 120, 120, 120, 100,  80,  60 }, // Fund new buildings has been activated
 
		{ 320, 420, 300, 220, 160, 100 }  // Normal values
 
	};
 

	
 
	int n = 0;
 

	
 
	const Station *st;
 
	FOR_ALL_STATIONS(st) {
 
		if (DistanceSquare(st->xy, t->xy) <= t->squared_town_zone_radius[0]) {
 
			if (st->time_since_load <= 20 || st->time_since_unload <= 20) {
 
				n++;
 
			}
 
		}
 
	}
 

	
 
	uint16 m;
 

	
 
	if (t->fund_buildings_months != 0) {
 
		m = _grow_count_values[0][min(n, 5)];
 
		t->fund_buildings_months--;
 
	} else {
 
		m = _grow_count_values[1][min(n, 5)];
 
		if (n == 0 && !Chance16(1, 12)) return;
 
	}
 

	
 
	if (_settings_game.game_creation.landscape == LT_ARCTIC) {
 
		if (TileHeight(t->xy) >= GetSnowLine() && t->received[TE_FOOD].old_act == 0 && t->population > 90) return;
 

	
 
	} else if (_settings_game.game_creation.landscape == LT_TROPIC) {
 
		if (GetTropicZone(t->xy) == TROPICZONE_DESERT && (t->received[TE_FOOD].old_act == 0 || t->received[TE_WATER].old_act == 0) && t->population > 60) return;
 
	}
 

	
 
	/* Use the normal growth rate values if new buildings have been funded in
 
	 * this town and the growth rate is set to none. */
 
	uint growth_multiplier = _settings_game.economy.town_growth_rate != 0 ? _settings_game.economy.town_growth_rate - 1 : 1;
 

	
 
	m >>= growth_multiplier;
 
	if (t->larger_town) m /= 2;
 
@@ -2775,12 +2816,13 @@ static void UpdateTownGrowRate(Town *t)
 
	t->growth_rate = m / (t->num_houses / 50 + 1);
 
	if (m <= t->grow_counter) {
 
		t->grow_counter = m;
 
	}
 

	
 
	SetBit(t->flags, TOWN_IS_FUNDED);
 
	SetWindowDirty(WC_TOWN_VIEW, t->index);
 
}
 

	
 
static void UpdateTownAmounts(Town *t)
 
{
 
	for (CargoID i = 0; i < NUM_CARGO; i++) t->supplied[i].NewMonth();
 
	for (int i = TE_BEGIN; i < TE_END; i++) t->received[i].NewMonth();
 
@@ -3003,14 +3045,15 @@ void TownsMonthlyLoop()
 
		if (t->road_build_months != 0) t->road_build_months--;
 

	
 
		if (t->exclusive_counter != 0) {
 
			if (--t->exclusive_counter == 0) t->exclusivity = INVALID_COMPANY;
 
		}
 

	
 
		UpdateTownAmounts(t);
 
		UpdateTownRating(t);
 
		UpdateTownGrowRate(t);
 
		UpdateTownAmounts(t);
 
		UpdateTownUnwanted(t);
 
	}
 
}
 

	
 
void TownsYearlyLoop()
 
{
src/town_gui.cpp
Show inline comments
 
@@ -341,26 +341,12 @@ public:
 

	
 
	virtual void SetStringParameters(int widget) const
 
	{
 
		if (widget == TVW_CAPTION) SetDParam(0, this->town->index);
 
	}
 

	
 
	/**
 
	 * Determines the first cargo with a certain town effect
 
	 * @param effect Town effect of interest
 
	 * @return first active cargo slot with that effect
 
	 */
 
	const CargoSpec *FindFirstCargoWithTownEffect(TownEffect effect) const
 
	{
 
		const CargoSpec *cs;
 
		FOR_ALL_CARGOSPECS(cs) {
 
			if (cs->town_effect == effect) return cs;
 
		}
 
		return NULL;
 
	}
 

	
 
	virtual void DrawWidget(const Rect &r, int widget) const
 
	{
 
		if (widget != TVW_INFOPANEL) return;
 

	
 
		uint y = r.top + WD_FRAMERECT_TOP;
 

	
 
@@ -373,61 +359,62 @@ public:
 
		DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += FONT_HEIGHT_NORMAL, STR_TOWN_VIEW_PASSENGERS_LAST_MONTH_MAX);
 

	
 
		SetDParam(0, this->town->supplied[CT_MAIL].old_act);
 
		SetDParam(1, this->town->supplied[CT_MAIL].old_max);
 
		DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += FONT_HEIGHT_NORMAL, STR_TOWN_VIEW_MAIL_LAST_MONTH_MAX);
 

	
 
		StringID required_text = STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_REQUIRED;
 
		uint cargo_needed_for_growth = 0;
 
		switch (_settings_game.game_creation.landscape) {
 
			case LT_ARCTIC:
 
				if (TileHeight(this->town->xy) >= LowestSnowLine()) cargo_needed_for_growth = 1;
 
				if (TileHeight(this->town->xy) < GetSnowLine()) required_text = STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_REQUIRED_WINTER;
 
				break;
 
		bool first = true;
 
		for (int i = TE_BEGIN; i < TE_END; i++) {
 
			if (this->town->goal[i] == 0) continue;
 
			if (this->town->goal[i] == TOWN_GROWTH_WINTER && TileHeight(this->town->xy) < LowestSnowLine()) continue;
 

	
 
			case LT_TROPIC:
 
				if (GetTropicZone(this->town->xy) == TROPICZONE_DESERT) cargo_needed_for_growth = 2;
 
				break;
 

	
 
			default: break;
 
		}
 

	
 
		if (cargo_needed_for_growth > 0) {
 
			DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += FONT_HEIGHT_NORMAL, STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH);
 
			if (first) {
 
				DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += FONT_HEIGHT_NORMAL, STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH);
 
				first = false;
 
			}
 

	
 
			bool rtl = _current_text_dir == TD_RTL;
 
			uint cargo_text_left = r.left + WD_FRAMERECT_LEFT + (rtl ? 0 : 20);
 
			uint cargo_text_right = r.right - WD_FRAMERECT_RIGHT - (rtl ? 20 : 0);
 

	
 
			const CargoSpec *food = FindFirstCargoWithTownEffect(TE_FOOD);
 
			CargoID first_food_cargo = (food != NULL) ? food->Index() : (CargoID)CT_INVALID;
 
			StringID food_name       = (food != NULL) ? food->name    : STR_CARGO_PLURAL_FOOD;
 
			const CargoSpec *cargo = FindFirstCargoWithTownEffect((TownEffect)i);
 
			assert(cargo != NULL);
 

	
 
			StringID string;
 

	
 
			const CargoSpec *water = FindFirstCargoWithTownEffect(TE_WATER);
 
			CargoID first_water_cargo = (water != NULL) ? water->Index() : (CargoID)CT_INVALID;
 
			StringID water_name       = (water != NULL) ? water->name    : STR_CARGO_PLURAL_WATER;
 
			if (this->town->goal[i] == TOWN_GROWTH_DESERT || this->town->goal[i] == TOWN_GROWTH_WINTER) {
 
				/* For 'original' gameplay, don't show the amount required (you need 1 or more ..) */
 
				string = STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_DELIVERED_GENERAL;
 
				if (this->town->received[i].old_act < this->town->goal[i]) {
 
					string = STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_REQUIRED_GENERAL;
 

	
 
			if (first_food_cargo != CT_INVALID && this->town->received[TE_FOOD].old_act > 0) {
 
				SetDParam(0, first_food_cargo);
 
				SetDParam(1, this->town->received[TE_FOOD].old_act);
 
				DrawString(cargo_text_left, cargo_text_right, y += FONT_HEIGHT_NORMAL, STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_LAST_MONTH);
 
					if (this->town->goal[i] == TOWN_GROWTH_WINTER && TileHeight(this->town->xy) < GetSnowLine()) {
 
						string = STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_REQUIRED_WINTER;
 
					}
 
				}
 

	
 
				SetDParam(0, cargo->name);
 
			} else {
 
				SetDParam(0, food_name);
 
				DrawString(cargo_text_left, cargo_text_right, y += FONT_HEIGHT_NORMAL, required_text);
 
			}
 
				string = STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_DELIVERED;
 
				if (this->town->received[i].old_act < this->town->goal[i]) {
 
					string = STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_REQUIRED;
 
				}
 

	
 
			if (cargo_needed_for_growth > 1) {
 
				if (first_water_cargo != CT_INVALID && this->town->received[TE_WATER].old_act > 0) {
 
					SetDParam(0, first_water_cargo);
 
					SetDParam(1, this->town->received[TE_WATER].old_act);
 
					DrawString(cargo_text_left, cargo_text_right, y += FONT_HEIGHT_NORMAL, STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_LAST_MONTH);
 
				} else {
 
					SetDParam(0, water_name);
 
					DrawString(cargo_text_left, cargo_text_right, y += FONT_HEIGHT_NORMAL, required_text);
 
				}
 
				SetDParam(0, cargo->Index());
 
				SetDParam(1, this->town->received[i].old_act);
 
				SetDParam(2, cargo->Index());
 
				SetDParam(3, this->town->goal[i]);
 
			}
 
			DrawString(cargo_text_left, cargo_text_right, y += FONT_HEIGHT_NORMAL, string);
 
		}
 

	
 
		if (HasBit(this->town->flags, TOWN_IS_FUNDED)) {
 
			SetDParam(0, (this->town->growth_rate * TOWN_GROWTH_TICKS + DAY_TICKS) / DAY_TICKS);
 
			DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += FONT_HEIGHT_NORMAL, this->town->fund_buildings_months == 0 ? STR_TOWN_VIEW_TOWN_GROWS_EVERY : STR_TOWN_VIEW_TOWN_GROWS_EVERY_FUNDED);
 
		} else {
 
			DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += FONT_HEIGHT_NORMAL, STR_TOWN_VIEW_TOWN_GROW_STOPPED);
 
		}
 

	
 
		/* only show the town noise, if the noise option is activated. */
 
		if (_settings_game.economy.station_noise_level) {
 
			SetDParam(0, this->town->noise_reached);
 
			SetDParam(1, this->town->MaxTownNoise());
 
@@ -488,23 +475,22 @@ public:
 
	 * @return the desired height in pixels.
 
	 */
 
	uint GetDesiredInfoHeight() const
 
	{
 
		uint aimed_height = 3 * FONT_HEIGHT_NORMAL + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
 

	
 
		switch (_settings_game.game_creation.landscape) {
 
			case LT_ARCTIC:
 
				if (TileHeight(this->town->xy) >= LowestSnowLine()) aimed_height += 2 * FONT_HEIGHT_NORMAL;
 
				break;
 

	
 
			case LT_TROPIC:
 
				if (GetTropicZone(this->town->xy) == TROPICZONE_DESERT) aimed_height += 3 * FONT_HEIGHT_NORMAL;
 
				break;
 

	
 
			default: break;
 
		bool first = true;
 
		for (int i = TE_BEGIN; i < TE_END; i++) {
 
			if (this->town->goal[i] == 0) continue;
 
			if (first) {
 
				aimed_height += FONT_HEIGHT_NORMAL;
 
				first = false;
 
			}
 
			aimed_height += FONT_HEIGHT_NORMAL;
 
		}
 
		aimed_height += FONT_HEIGHT_NORMAL;
 

	
 
		if (_settings_game.economy.station_noise_level) aimed_height += FONT_HEIGHT_NORMAL;
 

	
 
		return aimed_height;
 
	}
 

	
0 comments (0 inline, 0 general)