Changeset - r6454:106dbc6c677f
[Not reviewed]
master
0 7 0
maedhros - 17 years ago 2007-04-12 17:24:34
maedhros@openttd.org
(svn r9613) -Feature: Make it possible to have some control over the town growth. The
default rate is TTD's original rate, and to approximate OpenTTD's previous
behaviour the rate should be set to "Fast" or "Very Fast". Town growth can be
switched off entirely, and if so, buildings will not be rebuilt. It is also
possible to specify a proportion of towns that grow twice as fast as the
others.
7 files changed with 52 insertions and 30 deletions:
0 comments (0 inline, 0 general)
src/lang/english.txt
Show inline comments
 
@@ -1132,12 +1132,20 @@ STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFOR
 
STR_CONFIG_PATCHES_TOOLBAR_POS                                  :{LTBLUE}Position of main toolbar: {ORANGE}{STRING1}
 
STR_CONFIG_PATCHES_TOOLBAR_POS_LEFT                             :Left
 
STR_CONFIG_PATCHES_TOOLBAR_POS_CENTER                           :Centre
 
STR_CONFIG_PATCHES_TOOLBAR_POS_RIGHT                            :Right
 
STR_CONFIG_PATCHES_SNAP_RADIUS                                  :{LTBLUE}Window snap radius: {ORANGE}{STRING1} px
 
STR_CONFIG_PATCHES_SNAP_RADIUS_DISABLED                         :{LTBLUE}Window snap radius: {ORANGE}disabled
 
STR_CONFIG_PATCHES_TOWN_GROWTH                                  :{LTBLUE}Town growth speed: {ORANGE}{STRING1}
 
STR_CONFIG_PATCHES_TOWN_GROWTH_NONE                             :None
 
STR_CONFIG_PATCHES_TOWN_GROWTH_SLOW                             :Slow
 
STR_CONFIG_PATCHES_TOWN_GROWTH_NORMAL                           :Normal
 
STR_CONFIG_PATCHES_TOWN_GROWTH_FAST                             :Fast
 
STR_CONFIG_PATCHES_TOWN_GROWTH_VERY_FAST                        :Very fast
 
STR_CONFIG_PATCHES_LARGER_TOWNS                                 :{LTBLUE}Proportion of towns that will grow twice as fast: {ORANGE}1 in {STRING1}
 
STR_CONFIG_PATCHES_LARGER_TOWNS_DISABLED                        :{LTBLUE}Proportion of towns that will grow twice as fast: {ORANGE}None
 

	
 
STR_CONFIG_PATCHES_GUI                                          :{BLACK}Interface
 
STR_CONFIG_PATCHES_CONSTRUCTION                                 :{BLACK}Construction
 
STR_CONFIG_PATCHES_VEHICLES                                     :{BLACK}Vehicles
 
STR_CONFIG_PATCHES_STATIONS                                     :{BLACK}Stations
 
STR_CONFIG_PATCHES_ECONOMY                                      :{BLACK}Economy
src/saveload.cpp
Show inline comments
 
@@ -25,13 +25,13 @@
 
#include "player.h"
 
#include "saveload.h"
 
#include "network/network.h"
 
#include "variables.h"
 
#include <setjmp.h>
 

	
 
extern const uint16 SAVEGAME_VERSION = 53;
 
extern const uint16 SAVEGAME_VERSION = 54;
 
uint16 _sl_version;       ///< the major savegame version identifier
 
byte   _sl_minor_version; ///< the minor savegame version, DO NOT USE!
 

	
 
typedef void WriterProc(uint len);
 
typedef uint ReaderProc();
 

	
src/settings.cpp
Show inline comments
 
@@ -1389,12 +1389,14 @@ const SettingDesc _patch_settings[] = {
 
	 SDT_VAR(Patches, snow_line_height,SLE_UINT8, 0, 0,     7,  2, 13, 0, STR_CONFIG_PATCHES_SNOWLINE_HEIGHT,  NULL),
 
	 SDT_VAR(Patches, colored_news_year,SLE_INT32, 0,NC,  2000, MIN_YEAR, MAX_YEAR, 1, STR_CONFIG_PATCHES_COLORED_NEWS_YEAR,NULL),
 
	 SDT_VAR(Patches, starting_year,    SLE_INT32, 0,NC,  1950, MIN_YEAR, MAX_YEAR, 1, STR_CONFIG_PATCHES_STARTING_YEAR,NULL),
 
	 SDT_VAR(Patches, ending_year,      SLE_INT32,0,NC|NO,2051, MIN_YEAR, MAX_YEAR, 1, STR_CONFIG_PATCHES_ENDING_YEAR,  NULL),
 
	SDT_BOOL(Patches, smooth_economy,             0, 0,  true,            STR_CONFIG_PATCHES_SMOOTH_ECONOMY,   NULL),
 
	SDT_BOOL(Patches, allow_shares,               0, 0, false,            STR_CONFIG_PATCHES_ALLOW_SHARES,     NULL),
 
	SDT_CONDVAR(Patches, town_growth_rate, SLE_UINT8, 54, SL_MAX_VERSION, 0, MS, 2, 0,   4, 0, STR_CONFIG_PATCHES_TOWN_GROWTH,  NULL),
 
	SDT_CONDVAR(Patches, larger_towns,     SLE_UINT8, 54, SL_MAX_VERSION, 0, D0, 4, 0, 255, 1, STR_CONFIG_PATCHES_LARGER_TOWNS, NULL),
 

	
 
	/***************************************************************************/
 
	/* AI section of the GUI-configure patches window */
 
	SDT_BOOL(Patches, ainew_active,           0, 0, false, STR_CONFIG_PATCHES_AINEW_ACTIVE,      AiNew_PatchActive_Warning),
 
	SDT_BOOL(Patches, ai_in_multiplayer,      0, 0, false, STR_CONFIG_PATCHES_AI_IN_MULTIPLAYER, Ai_In_Multiplayer_Warning),
 
	SDT_BOOL(Patches, ai_disable_veh_train,   0, 0, false, STR_CONFIG_PATCHES_AI_BUILDS_TRAINS,  NULL),
src/settings_gui.cpp
Show inline comments
 
@@ -634,12 +634,14 @@ static const char *_patches_economy[] = 
 
	"same_industry_close",
 
	"bribe",
 
	"colored_news_year",
 
	"ending_year",
 
	"smooth_economy",
 
	"allow_shares",
 
	"town_growth_rate",
 
	"larger_towns",
 
};
 

	
 
static const char *_patches_ai[] = {
 
	"ainew_active",
 
	"ai_in_multiplayer",
 
	"ai_disable_veh_train",
src/town.h
Show inline comments
 
@@ -123,17 +123,17 @@ struct Town {
 
	uint16 act_food;
 
	uint16 act_water;
 
	uint16 new_act_food;
 
	uint16 new_act_water;
 

	
 
	/* Time until we rebuild a house. */
 
	byte time_until_rebuild;
 
	uint16 time_until_rebuild;
 

	
 
	/* When to grow town next time. */
 
	byte grow_counter;
 
	byte growth_rate;
 
	uint16 grow_counter;
 
	int16 growth_rate;
 

	
 
	/* Fund buildings program in action? */
 
	byte fund_buildings_months;
 

	
 
	/* Fund road reconstruction in action? */
 
	byte road_build_months;
 
@@ -231,20 +231,20 @@ enum {
 

	
 
	RATING_BRIBE_UP_STEP = 200,
 
	RATING_BRIBE_MAXIMUM = 800,
 
	RATING_BRIBE_DOWN_TO = -50        // XXX SHOULD BE SOMETHING LOWER?
 
};
 

	
 
enum {
 
/* This is the base "normal" number of towns on the 8x8 map, when
 
 * one town should get grown per tick. The other numbers of towns
 
 * are then scaled based on that. */
 
	TOWN_GROWTH_FREQUENCY = 23,
 
/* Simple value that indicates the house has reached final stage of construction*/
 
	TOWN_HOUSE_COMPLETED  =  3,
 
};
 
/** This is the number of ticks between towns being processed for building new
 
 * houses or roads. This value originally came from the size of the town array
 
 * in TTD. */
 
static const byte TOWN_GROWTH_FREQUENCY = 70;
 

	
 
/** Simple value that indicates the house has reached the final stage of
 
 * construction. */
 
static const byte TOWN_HOUSE_COMPLETED = 3;
 

	
 
/** This enum is used in conjonction with town->flags12.
 
 * IT simply states what bit is used for.
 
 * It is pretty unrealistic (IMHO) to only have one church/stadium
 
 * per town, NO MATTER the population of it.
 
 * And there are 5 more bits available on flags12...
src/town_cmd.cpp
Show inline comments
 
@@ -360,17 +360,17 @@ static void TileLoop_Town(TileIndex tile
 
		t->new_act_mail += moved;
 
	}
 

	
 
	_current_player = OWNER_TOWN;
 

	
 
	if (hs->building_flags & BUILDING_HAS_1_TILE && HASBIT(t->flags12, TOWN_IS_FUNDED) && CanDeleteHouse(tile) && --t->time_until_rebuild == 0) {
 
		t->time_until_rebuild = GB(r, 16, 6) + 130;
 
		t->time_until_rebuild = GB(r, 16, 8) + 192;
 

	
 
		ClearTownHouse(t, tile);
 

	
 
		/* rebuild with another house? */
 
		/* Rebuild with another house? */
 
		if (GB(r, 24, 8) >= 12) DoBuildTownHouse(t, tile);
 
	}
 

	
 
	_current_player = OWNER_NONE;
 
}
 

	
 
@@ -1659,13 +1659,13 @@ int32 CmdDoTownAction(TileIndex tile, ui
 
}
 

	
 
static void UpdateTownGrowRate(Town *t)
 
{
 
	int n;
 
	Station *st;
 
	byte m;
 
	uint16 m;
 
	Player *p;
 

	
 
	/* Reset player ratings if they're low */
 
	FOR_ALL_PLAYERS(p) {
 
		if (p->is_active && t->ratings[p->index] <= 200) {
 
			t->ratings[p->index] += 5;
 
@@ -1684,38 +1684,40 @@ static void UpdateTownGrowRate(Town *t)
 
					t->ratings[st->owner] -= 15;
 
			}
 
		}
 
	}
 

	
 
	CLRBIT(t->flags12, TOWN_IS_FUNDED);
 
	if (_patches.town_growth_rate == 0) return;
 

	
 
	/** Towns are processed every TOWN_GROWTH_FREQUENCY 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
 
	};
 

	
 
	if (t->fund_buildings_months != 0) {
 
		static const byte _grow_count_values[6] = {
 
			60, 60, 60, 50, 40, 30
 
		};
 
		m = _grow_count_values[min(n, 5)];
 
		m = _grow_count_values[0][min(n, 5)];
 
		t->fund_buildings_months--;
 
	} else if (n == 0) {
 
		m = 160;
 
		if (!CHANCE16(1, 12))
 
			return;
 
	} else {
 
		static const byte _grow_count_values[5] = {
 
			210, 150, 110, 80, 50
 
		};
 
		m = _grow_count_values[min(n, 5) - 1];
 
		m = _grow_count_values[1][min(n, 5)];
 
		if (n == 0 && !CHANCE16(1, 12)) return;
 
	}
 

	
 
	if (_opt.landscape == LT_ARCTIC) {
 
		if (TilePixelHeight(t->xy) >= GetSnowLine() && t->act_food == 0 && t->population > 90)
 
			return;
 
	} else if (_opt.landscape == LT_TROPIC) {
 
		if (GetTropicZone(t->xy) == TROPICZONE_DESERT && (t->act_food==0 || t->act_water==0) && t->population > 60)
 
			return;
 
	}
 

	
 
	m >>= (_patches.town_growth_rate - 1);
 
	if (_patches.larger_towns != 0 && (t->index % _patches.larger_towns) == 0) m /= 2;
 

	
 
	t->growth_rate = m / (t->num_houses / 50 + 1);
 
	if (m <= t->grow_counter)
 
		t->grow_counter = m;
 

	
 
	SETBIT(t->flags12, TOWN_IS_FUNDED);
 
}
 
@@ -1954,15 +1956,20 @@ static const SaveLoad _town_desc[] = {
 

	
 
	    SLE_VAR(Town, act_food,              SLE_UINT16),
 
	    SLE_VAR(Town, act_water,             SLE_UINT16),
 
	    SLE_VAR(Town, new_act_food,          SLE_UINT16),
 
	    SLE_VAR(Town, new_act_water,         SLE_UINT16),
 

	
 
	    SLE_VAR(Town, time_until_rebuild,    SLE_UINT8),
 
	    SLE_VAR(Town, grow_counter,          SLE_UINT8),
 
	    SLE_VAR(Town, growth_rate,           SLE_UINT8),
 
	SLE_CONDVAR(Town, time_until_rebuild,    SLE_UINT8,                  0, 53),
 
	SLE_CONDVAR(Town, grow_counter,          SLE_UINT8,                  0, 53),
 
	SLE_CONDVAR(Town, growth_rate,           SLE_UINT8,                  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_VAR(Town, fund_buildings_months, SLE_UINT8),
 
	    SLE_VAR(Town, road_build_months,     SLE_UINT8),
 

	
 
	    SLE_VAR(Town, exclusivity,           SLE_UINT8),
 
	    SLE_VAR(Town, exclusive_counter,     SLE_UINT8),
 
	/* reserve extra space in savegame here. (currently 30 bytes) */
src/variables.h
Show inline comments
 
@@ -222,12 +222,15 @@ struct Patches {
 

	
 
	/** YAPF settings */
 
	YapfSettings  yapf;
 

	
 
	uint8 scrollwheel_scrolling;
 
	uint8 scrollwheel_multiplier;
 

	
 
	uint8 town_growth_rate; ///< Town growth rate
 
	uint8 larger_towns;     ///< 1 in the specified number of towns will grow twice as fast
 
};
 

	
 
VARDEF Patches _patches;
 

	
 

	
 
struct Cheat {
0 comments (0 inline, 0 general)