mirror of https://github.com/OpenTTD/OpenTTD
(svn r15340) -Fix [FS#2121]: changing town road layout in-game caused ugly road networks
-Fix: use a flag instead of TL_NO_ROADS to forbid towns to build roads. The flag is ignored during world generation, so there won't be 'ghost' towns anymore -Feature: town layout is now stored per town, so it is possible to (manually) set different layout for each townrelease/0.7
parent
030984a763
commit
832e392855
|
@ -443,13 +443,7 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow {
|
||||||
case GLAND_GENERATE_BUTTON: // Generate
|
case GLAND_GENERATE_BUTTON: // Generate
|
||||||
MakeNewgameSettingsLive();
|
MakeNewgameSettingsLive();
|
||||||
|
|
||||||
if (_settings_game.economy.town_layout == TL_NO_ROADS) {
|
if (mode == GLWP_HEIGHTMAP &&
|
||||||
ShowQuery(
|
|
||||||
STR_TOWN_LAYOUT_WARNING_CAPTION,
|
|
||||||
STR_TOWN_LAYOUT_WARNING_MESSAGE,
|
|
||||||
this,
|
|
||||||
LandscapeGenerationCallback);
|
|
||||||
} else if (mode == GLWP_HEIGHTMAP &&
|
|
||||||
(this->x * 2 < (1U << _settings_newgame.game_creation.map_x) ||
|
(this->x * 2 < (1U << _settings_newgame.game_creation.map_x) ||
|
||||||
this->x / 2 > (1U << _settings_newgame.game_creation.map_x) ||
|
this->x / 2 > (1U << _settings_newgame.game_creation.map_x) ||
|
||||||
this->y * 2 < (1U << _settings_newgame.game_creation.map_y) ||
|
this->y * 2 < (1U << _settings_newgame.game_creation.map_y) ||
|
||||||
|
@ -685,10 +679,6 @@ void ShowHeightmapLoad()
|
||||||
|
|
||||||
void StartScenarioEditor()
|
void StartScenarioEditor()
|
||||||
{
|
{
|
||||||
if (_settings_newgame.economy.town_layout == TL_NO_ROADS) {
|
|
||||||
_settings_newgame.economy.town_layout = TL_ORIGINAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
StartGeneratingLandscape(GLWP_SCENARIO);
|
StartGeneratingLandscape(GLWP_SCENARIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1191,14 +1191,13 @@ STR_CONFIG_PATCHES_CYCLE_SIGNAL_NORMAL :Block signals o
|
||||||
STR_CONFIG_PATCHES_CYCLE_SIGNAL_PBS :Path signals only
|
STR_CONFIG_PATCHES_CYCLE_SIGNAL_PBS :Path signals only
|
||||||
STR_CONFIG_PATCHES_CYCLE_SIGNAL_ALL :All
|
STR_CONFIG_PATCHES_CYCLE_SIGNAL_ALL :All
|
||||||
|
|
||||||
STR_CONFIG_PATCHES_TOWN_LAYOUT_INVALID :{WHITE}The town layout "no more roads" isn't valid in the scenario editor
|
STR_CONFIG_PATCHES_TOWN_LAYOUT :{LTBLUE}Road layout for new towns: {ORANGE}{STRING1}
|
||||||
STR_CONFIG_PATCHES_TOWN_LAYOUT :{LTBLUE}Select town-road layout: {ORANGE}{STRING1}
|
STR_CONFIG_PATCHES_TOWN_LAYOUT_DEFAULT :original
|
||||||
STR_CONFIG_PATCHES_TOWN_LAYOUT_NO_ROADS :no more roads
|
|
||||||
STR_CONFIG_PATCHES_TOWN_LAYOUT_DEFAULT :default
|
|
||||||
STR_CONFIG_PATCHES_TOWN_LAYOUT_BETTER_ROADS :better roads
|
STR_CONFIG_PATCHES_TOWN_LAYOUT_BETTER_ROADS :better roads
|
||||||
STR_CONFIG_PATCHES_TOWN_LAYOUT_2X2_GRID :2x2 grid
|
STR_CONFIG_PATCHES_TOWN_LAYOUT_2X2_GRID :2x2 grid
|
||||||
STR_CONFIG_PATCHES_TOWN_LAYOUT_3X3_GRID :3x3 grid
|
STR_CONFIG_PATCHES_TOWN_LAYOUT_3X3_GRID :3x3 grid
|
||||||
STR_CONFIG_PATCHES_TOWN_LAYOUT_RANDOM :random
|
STR_CONFIG_PATCHES_TOWN_LAYOUT_RANDOM :random
|
||||||
|
STR_CONFIG_PATCHES_ALLOW_TOWN_ROADS :{LTBLUE}Towns are allowed to build roads: {ORANGE}{STRING1}
|
||||||
|
|
||||||
STR_CONFIG_PATCHES_TOOLBAR_POS :{LTBLUE}Position of main toolbar: {ORANGE}{STRING1}
|
STR_CONFIG_PATCHES_TOOLBAR_POS :{LTBLUE}Position of main toolbar: {ORANGE}{STRING1}
|
||||||
STR_CONFIG_PATCHES_TOOLBAR_POS_LEFT :Left
|
STR_CONFIG_PATCHES_TOOLBAR_POS_LEFT :Left
|
||||||
|
@ -3470,8 +3469,6 @@ STR_SNOW_LINE_QUERY_CAPT :{WHITE}Change s
|
||||||
STR_START_DATE_QUERY_CAPT :{WHITE}Change starting year
|
STR_START_DATE_QUERY_CAPT :{WHITE}Change starting year
|
||||||
STR_HEIGHTMAP_SCALE_WARNING_CAPTION :{WHITE}Scale warning
|
STR_HEIGHTMAP_SCALE_WARNING_CAPTION :{WHITE}Scale warning
|
||||||
STR_HEIGHTMAP_SCALE_WARNING_MESSAGE :{YELLOW}Resizing source map too much is not recommended. Continue with the generation?
|
STR_HEIGHTMAP_SCALE_WARNING_MESSAGE :{YELLOW}Resizing source map too much is not recommended. Continue with the generation?
|
||||||
STR_TOWN_LAYOUT_WARNING_CAPTION :{WHITE}Town layout warning
|
|
||||||
STR_TOWN_LAYOUT_WARNING_MESSAGE :{YELLOW}The town layout "no more roads" is not recommended. Continue with the generation?
|
|
||||||
STR_HEIGHTMAP_NAME :{BLACK}Heightmap name:
|
STR_HEIGHTMAP_NAME :{BLACK}Heightmap name:
|
||||||
STR_HEIGHTMAP_SIZE :{BLACK}Size: {ORANGE}{NUM} x {NUM}
|
STR_HEIGHTMAP_SIZE :{BLACK}Size: {ORANGE}{NUM} x {NUM}
|
||||||
STR_GENERATION_WORLD :{WHITE}Generating world...
|
STR_GENERATION_WORLD :{WHITE}Generating world...
|
||||||
|
|
|
@ -5307,7 +5307,7 @@ static void InitializeGRFSpecial()
|
||||||
|
|
||||||
_ttdpatch_flags[3] = (0 << 0x00) // newcargodistribution
|
_ttdpatch_flags[3] = (0 << 0x00) // newcargodistribution
|
||||||
| (1 << 0x01) // windowsnap
|
| (1 << 0x01) // windowsnap
|
||||||
| ((_settings_game.economy.town_layout == TL_NO_ROADS ? 1 : 0) << 0x02) // townbuildnoroad
|
| ((_settings_game.economy.allow_town_roads || _generating_world ? 0 : 1) << 0x02) // townbuildnoroad
|
||||||
| (1 << 0x03) // pathbasedsignalling
|
| (1 << 0x03) // pathbasedsignalling
|
||||||
| (0 << 0x04) // aichoosechance
|
| (0 << 0x04) // aichoosechance
|
||||||
| (1 << 0x05) // resolutionwidth
|
| (1 << 0x05) // resolutionwidth
|
||||||
|
|
|
@ -482,8 +482,6 @@ bool AfterLoadGame()
|
||||||
/* Update all waypoints */
|
/* Update all waypoints */
|
||||||
if (CheckSavegameVersion(12)) FixOldWaypoints();
|
if (CheckSavegameVersion(12)) FixOldWaypoints();
|
||||||
|
|
||||||
AfterLoadTown();
|
|
||||||
|
|
||||||
/* make sure there is a town in the game */
|
/* make sure there is a town in the game */
|
||||||
if (_game_mode == GM_NORMAL && !ClosestTownFromTile(0, UINT_MAX)) {
|
if (_game_mode == GM_NORMAL && !ClosestTownFromTile(0, UINT_MAX)) {
|
||||||
SetSaveLoadError(STR_NO_TOWN_IN_SCENARIO);
|
SetSaveLoadError(STR_NO_TOWN_IN_SCENARIO);
|
||||||
|
@ -1694,6 +1692,36 @@ bool AfterLoadGame()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (CheckSavegameVersion(113)) {
|
||||||
|
/* allow_town_roads is added, set it if town_layout wasn't TL_NO_ROADS */
|
||||||
|
if (_settings_game.economy.town_layout == 0) { // was TL_NO_ROADS
|
||||||
|
_settings_game.economy.allow_town_roads = false;
|
||||||
|
_settings_game.economy.town_layout = TL_BETTER_ROADS;
|
||||||
|
} else {
|
||||||
|
_settings_game.economy.allow_town_roads = true;
|
||||||
|
_settings_game.economy.town_layout = _settings_game.economy.town_layout - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Initialize layout of all towns. Older versions were using different
|
||||||
|
* generator for random town layout, use it if needed. */
|
||||||
|
Town *t;
|
||||||
|
FOR_ALL_TOWNS(t) {
|
||||||
|
if (_settings_game.economy.town_layout != TL_RANDOM) {
|
||||||
|
t->layout = _settings_game.economy.town_layout;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Use old layout randomizer code */
|
||||||
|
byte layout = TileHash(TileX(t->xy), TileY(t->xy)) % 6;
|
||||||
|
switch (layout) {
|
||||||
|
default: break;
|
||||||
|
case 5: layout = 1; break;
|
||||||
|
case 0: layout = 2; break;
|
||||||
|
}
|
||||||
|
t->layout = layout - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GamelogPrintDebug(1);
|
GamelogPrintDebug(1);
|
||||||
|
|
||||||
bool ret = InitializeWindowsAndCaches();
|
bool ret = InitializeWindowsAndCaches();
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
|
|
||||||
#include "saveload_internal.h"
|
#include "saveload_internal.h"
|
||||||
|
|
||||||
extern const uint16 SAVEGAME_VERSION = 112;
|
extern const uint16 SAVEGAME_VERSION = 113;
|
||||||
|
|
||||||
SavegameType _savegame_type; ///< type of savegame we are loading
|
SavegameType _savegame_type; ///< type of savegame we are loading
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@ void FixOldWaypoints();
|
||||||
void AfterLoadWaypoints();
|
void AfterLoadWaypoints();
|
||||||
void AfterLoadVehicles(bool part_of_load);
|
void AfterLoadVehicles(bool part_of_load);
|
||||||
void AfterLoadStations();
|
void AfterLoadStations();
|
||||||
void AfterLoadTown();
|
|
||||||
void UpdateHousesAndTowns();
|
void UpdateHousesAndTowns();
|
||||||
|
|
||||||
void UpdateOldAircraft();
|
void UpdateOldAircraft();
|
||||||
|
|
|
@ -127,6 +127,7 @@ static const SaveLoad _town_desc[] = {
|
||||||
SLE_CONDVAR(Town, exclusive_counter, SLE_UINT8, 2, SL_MAX_VERSION),
|
SLE_CONDVAR(Town, exclusive_counter, SLE_UINT8, 2, SL_MAX_VERSION),
|
||||||
|
|
||||||
SLE_CONDVAR(Town, larger_town, SLE_BOOL, 56, SL_MAX_VERSION),
|
SLE_CONDVAR(Town, larger_town, SLE_BOOL, 56, SL_MAX_VERSION),
|
||||||
|
SLE_CONDVAR(Town, layout, SLE_UINT8, 113, SL_MAX_VERSION),
|
||||||
|
|
||||||
/* reserve extra space in savegame here. (currently 30 bytes) */
|
/* reserve extra space in savegame here. (currently 30 bytes) */
|
||||||
SLE_CONDNULL(30, 2, SL_MAX_VERSION),
|
SLE_CONDNULL(30, 2, SL_MAX_VERSION),
|
||||||
|
@ -195,12 +196,6 @@ static void Load_TOWN()
|
||||||
_cur_town_ctr = 0;
|
_cur_town_ctr = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AfterLoadTown()
|
|
||||||
{
|
|
||||||
Town *t;
|
|
||||||
FOR_ALL_TOWNS(t) t->InitializeLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
extern const ChunkHandler _town_chunk_handlers[] = {
|
extern const ChunkHandler _town_chunk_handlers[] = {
|
||||||
{ 'HIDS', Save_HOUSEIDS, Load_HOUSEIDS, CH_ARRAY },
|
{ 'HIDS', Save_HOUSEIDS, Load_HOUSEIDS, CH_ARRAY },
|
||||||
{ 'CITY', Save_TOWN, Load_TOWN, CH_ARRAY | CH_LAST},
|
{ 'CITY', Save_TOWN, Load_TOWN, CH_ARRAY | CH_LAST},
|
||||||
|
|
|
@ -1030,23 +1030,6 @@ static bool DifficultyNoiseChange(int32 i)
|
||||||
return DifficultyChange(i);
|
return DifficultyChange(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check for right TownLayout usage in editor mode.
|
|
||||||
* The No Road mode is not desirable since towns have to be
|
|
||||||
* able to grow. If a user desires to have a town with no road,
|
|
||||||
* he can easily remove them himself. This would create less confusion
|
|
||||||
* @param p1 unused
|
|
||||||
* @return always true
|
|
||||||
*/
|
|
||||||
static bool CheckTownLayout(int32 p1)
|
|
||||||
{
|
|
||||||
if (_settings_game.economy.town_layout == TL_NO_ROADS && _game_mode == GM_EDITOR) {
|
|
||||||
ShowErrorMessage(INVALID_STRING_ID, STR_CONFIG_PATCHES_TOWN_LAYOUT_INVALID, 0, 0);
|
|
||||||
_settings_game.economy.town_layout = TL_ORIGINAL;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether the road side may be changed.
|
* Check whether the road side may be changed.
|
||||||
* @param p1 unused
|
* @param p1 unused
|
||||||
|
@ -1322,7 +1305,8 @@ const SettingDesc _patch_settings[] = {
|
||||||
SDT_BOOL(GameSettings, construction.longbridges, 0,NN, true, STR_CONFIG_PATCHES_LONGBRIDGES, NULL),
|
SDT_BOOL(GameSettings, construction.longbridges, 0,NN, true, STR_CONFIG_PATCHES_LONGBRIDGES, NULL),
|
||||||
SDT_BOOL(GameSettings, construction.signal_side, N,NN, true, STR_CONFIG_PATCHES_SIGNALSIDE, RedrawScreen),
|
SDT_BOOL(GameSettings, construction.signal_side, N,NN, true, STR_CONFIG_PATCHES_SIGNALSIDE, RedrawScreen),
|
||||||
SDT_BOOL(GameSettings, station.always_small_airport, 0,NN, false, STR_CONFIG_PATCHES_SMALL_AIRPORTS, NULL),
|
SDT_BOOL(GameSettings, station.always_small_airport, 0,NN, false, STR_CONFIG_PATCHES_SMALL_AIRPORTS, NULL),
|
||||||
SDT_CONDVAR(GameSettings, economy.town_layout, SLE_UINT8, 59, SL_MAX_VERSION, 0,MS,TL_ORIGINAL,TL_NO_ROADS,NUM_TLS-1,1, STR_CONFIG_PATCHES_TOWN_LAYOUT, CheckTownLayout),
|
SDT_CONDVAR(GameSettings, economy.town_layout, SLE_UINT8, 59, SL_MAX_VERSION, 0,MS,TL_BETTER_ROADS,TL_BEGIN,NUM_TLS-1,1, STR_CONFIG_PATCHES_TOWN_LAYOUT, NULL),
|
||||||
|
SDT_CONDBOOL(GameSettings, economy.allow_town_roads, 113, SL_MAX_VERSION, 0, 0, true, STR_CONFIG_PATCHES_ALLOW_TOWN_ROADS, NULL),
|
||||||
|
|
||||||
SDT_VAR(GameSettings, vehicle.train_acceleration_model, SLE_UINT8, 0,MS, 0, 0, 1, 1, STR_CONFIG_PATCHES_TRAIN_ACCELERATION_MODEL, TrainAccelerationModelChanged),
|
SDT_VAR(GameSettings, vehicle.train_acceleration_model, SLE_UINT8, 0,MS, 0, 0, 1, 1, STR_CONFIG_PATCHES_TRAIN_ACCELERATION_MODEL, TrainAccelerationModelChanged),
|
||||||
SDT_BOOL(GameSettings, pf.forbid_90_deg, 0, 0, false, STR_CONFIG_PATCHES_FORBID_90_DEG, NULL),
|
SDT_BOOL(GameSettings, pf.forbid_90_deg, 0, 0, false, STR_CONFIG_PATCHES_FORBID_90_DEG, NULL),
|
||||||
|
|
|
@ -1097,6 +1097,7 @@ static PatchEntry _patches_economy_towns[] = {
|
||||||
PatchEntry("economy.bribe"),
|
PatchEntry("economy.bribe"),
|
||||||
PatchEntry("economy.exclusive_rights"),
|
PatchEntry("economy.exclusive_rights"),
|
||||||
PatchEntry("economy.town_layout"),
|
PatchEntry("economy.town_layout"),
|
||||||
|
PatchEntry("economy.allow_town_roads"),
|
||||||
PatchEntry("economy.mod_road_rebuild"),
|
PatchEntry("economy.mod_road_rebuild"),
|
||||||
PatchEntry("economy.town_growth_rate"),
|
PatchEntry("economy.town_growth_rate"),
|
||||||
PatchEntry("economy.larger_towns"),
|
PatchEntry("economy.larger_towns"),
|
||||||
|
|
|
@ -320,6 +320,7 @@ struct EconomySettings {
|
||||||
uint8 larger_towns; ///< the number of cities to build. These start off larger and grow twice as fast
|
uint8 larger_towns; ///< the number of cities to build. These start off larger and grow twice as fast
|
||||||
uint8 initial_city_size; ///< multiplier for the initial size of the cities compared to towns
|
uint8 initial_city_size; ///< multiplier for the initial size of the cities compared to towns
|
||||||
TownLayoutByte town_layout; ///< select town layout
|
TownLayoutByte town_layout; ///< select town layout
|
||||||
|
bool allow_town_roads; ///< towns are allowed to build roads (always allowed when generating world / in SE)
|
||||||
bool station_noise_level; ///< build new airports when the town noise level is still within accepted limits
|
bool station_noise_level; ///< build new airports when the town noise level is still within accepted limits
|
||||||
uint16 town_noise_population[3]; ///< population to base decision on noise evaluation (@see town_council_tolerance)
|
uint16 town_noise_population[3]; ///< population to base decision on noise evaluation (@see town_council_tolerance)
|
||||||
};
|
};
|
||||||
|
|
18
src/town.h
18
src/town.h
|
@ -166,6 +166,7 @@ struct Town : PoolItem<Town, TownID, &_Town_pool> {
|
||||||
|
|
||||||
/* If this is a larger town, and should grow more quickly. */
|
/* If this is a larger town, and should grow more quickly. */
|
||||||
bool larger_town;
|
bool larger_town;
|
||||||
|
TownLayoutByte layout; ///< town specific road layout
|
||||||
|
|
||||||
/* NOSAVE: UpdateTownRadius updates this given the house count. */
|
/* NOSAVE: UpdateTownRadius updates this given the house count. */
|
||||||
uint32 squared_town_zone_radius[HZB_END];
|
uint32 squared_town_zone_radius[HZB_END];
|
||||||
|
@ -173,9 +174,6 @@ struct Town : PoolItem<Town, TownID, &_Town_pool> {
|
||||||
/* NOSAVE: The number of each type of building in the town. */
|
/* NOSAVE: The number of each type of building in the town. */
|
||||||
BuildingCounts building_counts;
|
BuildingCounts building_counts;
|
||||||
|
|
||||||
/* NOSAVE: The town specific road layout */
|
|
||||||
TownLayout layout;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new town
|
* Creates a new town
|
||||||
*/
|
*/
|
||||||
|
@ -188,30 +186,20 @@ struct Town : PoolItem<Town, TownID, &_Town_pool> {
|
||||||
|
|
||||||
void InitializeLayout();
|
void InitializeLayout();
|
||||||
|
|
||||||
inline TownLayout GetActiveLayout() const;
|
|
||||||
|
|
||||||
/** Calculate the max town noise
|
/** Calculate the max town noise
|
||||||
* The value is counted using the population divided by the content of the
|
* The value is counted using the population divided by the content of the
|
||||||
* entry in town_noise_population corespondig to the town's tolerance.
|
* entry in town_noise_population corespondig to the town's tolerance.
|
||||||
* To this result, we add 3, which is the noise of the lowest airport.
|
* To this result, we add 3, which is the noise of the lowest airport.
|
||||||
* So user can at least buld that airport
|
* So user can at least buld that airport
|
||||||
* @return the maximum noise level the town will tolerate */
|
* @return the maximum noise level the town will tolerate */
|
||||||
inline uint16 MaxTownNoise() const {
|
inline uint16 MaxTownNoise() const
|
||||||
|
{
|
||||||
if (this->population == 0) return 0; // no population? no noise
|
if (this->population == 0) return 0; // no population? no noise
|
||||||
|
|
||||||
return ((this->population / _settings_game.economy.town_noise_population[_settings_game.difficulty.town_council_tolerance]) + 3);
|
return ((this->population / _settings_game.economy.town_noise_population[_settings_game.difficulty.town_council_tolerance]) + 3);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the current valid layout for the town
|
|
||||||
* @return the active layout for this town
|
|
||||||
*/
|
|
||||||
inline TownLayout Town::GetActiveLayout() const
|
|
||||||
{
|
|
||||||
return (_settings_game.economy.town_layout == TL_RANDOM) ? this->layout : _settings_game.economy.town_layout;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct HouseSpec {
|
struct HouseSpec {
|
||||||
/* Standard properties */
|
/* Standard properties */
|
||||||
Year min_year; ///< introduction year of the house
|
Year min_year; ///< introduction year of the house
|
||||||
|
|
|
@ -113,20 +113,16 @@ Town::~Town()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a random town road layout.
|
* Assigns town layout. If Random, generates one based on TileHash.
|
||||||
*
|
|
||||||
* The layout is based on the TileHash.
|
|
||||||
*/
|
*/
|
||||||
void Town::InitializeLayout()
|
void Town::InitializeLayout()
|
||||||
{
|
{
|
||||||
this->layout = (TownLayout)(TileHash(TileX(this->xy), TileY(this->xy)) % NUM_TLS);
|
if (_settings_game.economy.town_layout != TL_RANDOM) {
|
||||||
|
this->layout = _settings_game.economy.town_layout;
|
||||||
/* Set invalid layouts to valid ones */
|
return;
|
||||||
switch (this->layout) {
|
|
||||||
default: break;
|
|
||||||
case TL_RANDOM: this->layout = TL_ORIGINAL; break;
|
|
||||||
case TL_NO_ROADS: this->layout = TL_BETTER_ROADS; break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->layout = TileHash(TileX(this->xy), TileY(this->xy)) % (NUM_TLS - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Money HouseSpec::GetRemovalCost() const
|
Money HouseSpec::GetRemovalCost() const
|
||||||
|
@ -785,7 +781,7 @@ static bool IsRoadAllowedHere(Town *t, TileIndex tile, DiagDirection dir)
|
||||||
if (cur_slope == SLOPE_FLAT) {
|
if (cur_slope == SLOPE_FLAT) {
|
||||||
no_slope:
|
no_slope:
|
||||||
/* Tile has no slope */
|
/* Tile has no slope */
|
||||||
switch (t->GetActiveLayout()) {
|
switch (t->layout) {
|
||||||
default: NOT_REACHED();
|
default: NOT_REACHED();
|
||||||
|
|
||||||
case TL_ORIGINAL: // Disallow the road if any neighboring tile has a road (distance: 1)
|
case TL_ORIGINAL: // Disallow the road if any neighboring tile has a road (distance: 1)
|
||||||
|
@ -858,7 +854,7 @@ static RoadBits GetTownRoadGridElement(Town *t, TileIndex tile, DiagDirection di
|
||||||
TileIndexDiffC grid_pos = TileIndexToTileIndexDiffC(t->xy, tile); // Vector from downtown to the tile
|
TileIndexDiffC grid_pos = TileIndexToTileIndexDiffC(t->xy, tile); // Vector from downtown to the tile
|
||||||
RoadBits rcmd = ROAD_NONE;
|
RoadBits rcmd = ROAD_NONE;
|
||||||
|
|
||||||
switch (t->GetActiveLayout()) {
|
switch (t->layout) {
|
||||||
default: NOT_REACHED();
|
default: NOT_REACHED();
|
||||||
|
|
||||||
case TL_2X2_GRID:
|
case TL_2X2_GRID:
|
||||||
|
@ -1018,7 +1014,6 @@ static bool GrowTownWithBridge(const Town *t, const TileIndex tile, const DiagDi
|
||||||
* @li TL_2X2_GRID
|
* @li TL_2X2_GRID
|
||||||
* @li TL_3X3_GRID
|
* @li TL_3X3_GRID
|
||||||
* @li Forbid roads, only build houses
|
* @li Forbid roads, only build houses
|
||||||
* @li TL_NO_ROADS
|
|
||||||
*
|
*
|
||||||
* @param tile_ptr The current tile
|
* @param tile_ptr The current tile
|
||||||
* @param cur_rb The current tiles RoadBits
|
* @param cur_rb The current tiles RoadBits
|
||||||
|
@ -1037,16 +1032,15 @@ static void GrowTownInTile(TileIndex *tile_ptr, RoadBits cur_rb, DiagDirection t
|
||||||
* to say that this is the last iteration. */
|
* to say that this is the last iteration. */
|
||||||
_grow_town_result = GROWTH_SEARCH_STOPPED;
|
_grow_town_result = GROWTH_SEARCH_STOPPED;
|
||||||
|
|
||||||
|
if (!_settings_game.economy.allow_town_roads && !_generating_world) return;
|
||||||
|
|
||||||
/* Remove hills etc */
|
/* Remove hills etc */
|
||||||
if (!_settings_game.construction.build_on_slopes || Chance16(1, 6)) LevelTownLand(tile);
|
if (!_settings_game.construction.build_on_slopes || Chance16(1, 6)) LevelTownLand(tile);
|
||||||
|
|
||||||
/* Is a road allowed here? */
|
/* Is a road allowed here? */
|
||||||
switch (t1->GetActiveLayout()) {
|
switch (t1->layout) {
|
||||||
default: NOT_REACHED();
|
default: NOT_REACHED();
|
||||||
|
|
||||||
case TL_NO_ROADS: /* Disallow Roads */
|
|
||||||
return;
|
|
||||||
|
|
||||||
case TL_3X3_GRID:
|
case TL_3X3_GRID:
|
||||||
case TL_2X2_GRID:
|
case TL_2X2_GRID:
|
||||||
rcmd = GetTownRoadGridElement(t1, tile, target_dir);
|
rcmd = GetTownRoadGridElement(t1, tile, target_dir);
|
||||||
|
@ -1089,11 +1083,10 @@ static void GrowTownInTile(TileIndex *tile_ptr, RoadBits cur_rb, DiagDirection t
|
||||||
* the fitting RoadBits */
|
* the fitting RoadBits */
|
||||||
_grow_town_result = GROWTH_SEARCH_STOPPED;
|
_grow_town_result = GROWTH_SEARCH_STOPPED;
|
||||||
|
|
||||||
switch (t1->GetActiveLayout()) {
|
if (!_settings_game.economy.allow_town_roads && !_generating_world) return;
|
||||||
default: NOT_REACHED();
|
|
||||||
|
|
||||||
case TL_NO_ROADS: /* Disallow Roads */
|
switch (t1->layout) {
|
||||||
return;
|
default: NOT_REACHED();
|
||||||
|
|
||||||
case TL_3X3_GRID:
|
case TL_3X3_GRID:
|
||||||
case TL_2X2_GRID:
|
case TL_2X2_GRID:
|
||||||
|
@ -1106,7 +1099,7 @@ static void GrowTownInTile(TileIndex *tile_ptr, RoadBits cur_rb, DiagDirection t
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bool allow_house = false; // Value which decides if we want to construct a house
|
bool allow_house = true; // Value which decides if we want to construct a house
|
||||||
|
|
||||||
/* Reached a tunnel/bridge? Then continue at the other side of it. */
|
/* Reached a tunnel/bridge? Then continue at the other side of it. */
|
||||||
if (IsTileType(tile, MP_TUNNELBRIDGE)) {
|
if (IsTileType(tile, MP_TUNNELBRIDGE)) {
|
||||||
|
@ -1129,13 +1122,10 @@ static void GrowTownInTile(TileIndex *tile_ptr, RoadBits cur_rb, DiagDirection t
|
||||||
|
|
||||||
if (!IsValidTile(house_tile) || !IsValidTile(house_tile + TileOffsByDiagDir(target_dir))) return;
|
if (!IsValidTile(house_tile) || !IsValidTile(house_tile + TileOffsByDiagDir(target_dir))) return;
|
||||||
|
|
||||||
switch (t1->GetActiveLayout()) {
|
if (_settings_game.economy.allow_town_roads || _generating_world) {
|
||||||
|
switch (t1->layout) {
|
||||||
default: NOT_REACHED();
|
default: NOT_REACHED();
|
||||||
|
|
||||||
case TL_NO_ROADS:
|
|
||||||
allow_house = true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TL_3X3_GRID: /* Use 2x2 grid afterwards! */
|
case TL_3X3_GRID: /* Use 2x2 grid afterwards! */
|
||||||
GrowTownWithExtraHouse(t1, TileAddByDiagDir(house_tile, target_dir));
|
GrowTownWithExtraHouse(t1, TileAddByDiagDir(house_tile, target_dir));
|
||||||
/* FALL THROUGH */
|
/* FALL THROUGH */
|
||||||
|
@ -1156,6 +1146,7 @@ static void GrowTownInTile(TileIndex *tile_ptr, RoadBits cur_rb, DiagDirection t
|
||||||
allow_house = (!IsRoadAllowedHere(t1, house_tile, target_dir) || Chance16(6, 10));
|
allow_house = (!IsRoadAllowedHere(t1, house_tile, target_dir) || Chance16(6, 10));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (allow_house) {
|
if (allow_house) {
|
||||||
/* Build a house, but not if there already is a house there. */
|
/* Build a house, but not if there already is a house there. */
|
||||||
|
@ -1207,7 +1198,7 @@ static int GrowTownAtRoad(Town *t, TileIndex tile)
|
||||||
/* Number of times to search.
|
/* Number of times to search.
|
||||||
* Better roads, 2X2 and 3X3 grid grow quite fast so we give
|
* Better roads, 2X2 and 3X3 grid grow quite fast so we give
|
||||||
* them a little handicap. */
|
* them a little handicap. */
|
||||||
switch (t->GetActiveLayout()) {
|
switch (t->layout) {
|
||||||
case TL_BETTER_ROADS:
|
case TL_BETTER_ROADS:
|
||||||
_grow_town_result = 10 + t->num_houses * 2 / 9;
|
_grow_town_result = 10 + t->num_houses * 2 / 9;
|
||||||
break;
|
break;
|
||||||
|
@ -1279,13 +1270,6 @@ static RoadBits GenRandomRoadBits()
|
||||||
*/
|
*/
|
||||||
static bool GrowTown(Town *t)
|
static bool GrowTown(Town *t)
|
||||||
{
|
{
|
||||||
/* Let the town be a ghost town
|
|
||||||
* The player wanted it in such a way. Thus there he has it. ;)
|
|
||||||
* Never reached in editor mode. */
|
|
||||||
if (_settings_game.economy.town_layout == TL_NO_ROADS && _generating_world) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const TileIndexDiffC _town_coord_mod[] = {
|
static const TileIndexDiffC _town_coord_mod[] = {
|
||||||
{-1, 0},
|
{-1, 0},
|
||||||
{ 1, 1},
|
{ 1, 1},
|
||||||
|
@ -1794,7 +1778,7 @@ static inline bool TownLayoutAllowsHouseHere(Town *t, TileIndex tile)
|
||||||
{
|
{
|
||||||
TileIndexDiffC grid_pos = TileIndexToTileIndexDiffC(t->xy, tile);
|
TileIndexDiffC grid_pos = TileIndexToTileIndexDiffC(t->xy, tile);
|
||||||
|
|
||||||
switch (t->GetActiveLayout()) {
|
switch (t->layout) {
|
||||||
case TL_2X2_GRID:
|
case TL_2X2_GRID:
|
||||||
if ((grid_pos.x % 3) == 0 || (grid_pos.y % 3) == 0) return false;
|
if ((grid_pos.x % 3) == 0 || (grid_pos.y % 3) == 0) return false;
|
||||||
break;
|
break;
|
||||||
|
@ -1825,7 +1809,7 @@ static inline bool TownLayoutAllows2x2HouseHere(Town *t, TileIndex tile)
|
||||||
uint dx = MapSize() + TileX(t->xy) - TileX(tile);
|
uint dx = MapSize() + TileX(t->xy) - TileX(tile);
|
||||||
uint dy = MapSize() + TileY(t->xy) - TileY(tile);
|
uint dy = MapSize() + TileY(t->xy) - TileY(tile);
|
||||||
|
|
||||||
switch (t->GetActiveLayout()) {
|
switch (t->layout) {
|
||||||
case TL_2X2_GRID:
|
case TL_2X2_GRID:
|
||||||
if ((dx % 3) != 0 || (dy % 3) != 0) return false;
|
if ((dx % 3) != 0 || (dy % 3) != 0) return false;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -65,8 +65,8 @@ enum {
|
||||||
* Town Layouts
|
* Town Layouts
|
||||||
*/
|
*/
|
||||||
enum TownLayout {
|
enum TownLayout {
|
||||||
TL_NO_ROADS = 0, ///< Build no more roads, but still build houses
|
TL_BEGIN = 0,
|
||||||
TL_ORIGINAL, ///< Original algorithm (min. 1 distance between roads)
|
TL_ORIGINAL = 0, ///< Original algorithm (min. 1 distance between roads)
|
||||||
TL_BETTER_ROADS, ///< Extended original algorithm (min. 2 distance between roads)
|
TL_BETTER_ROADS, ///< Extended original algorithm (min. 2 distance between roads)
|
||||||
TL_2X2_GRID, ///< Geometric 2x2 grid algorithm
|
TL_2X2_GRID, ///< Geometric 2x2 grid algorithm
|
||||||
TL_3X3_GRID, ///< Geometric 3x3 grid algorithm
|
TL_3X3_GRID, ///< Geometric 3x3 grid algorithm
|
||||||
|
@ -78,7 +78,7 @@ enum TownLayout {
|
||||||
|
|
||||||
/* It needs to be 8bits, because we save and load it as such */
|
/* It needs to be 8bits, because we save and load it as such */
|
||||||
/** Define basic enum properties */
|
/** Define basic enum properties */
|
||||||
template <> struct EnumPropsT<TownLayout> : MakeEnumPropsT<TownLayout, byte, TL_NO_ROADS, NUM_TLS, NUM_TLS> {};
|
template <> struct EnumPropsT<TownLayout> : MakeEnumPropsT<TownLayout, byte, TL_BEGIN, NUM_TLS, NUM_TLS> {};
|
||||||
typedef TinyEnumT<TownLayout> TownLayoutByte; //typedefing-enumification of TownLayout
|
typedef TinyEnumT<TownLayout> TownLayoutByte; //typedefing-enumification of TownLayout
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
|
Loading…
Reference in New Issue