Changeset - r13973:b91e25840bdc
[Not reviewed]
master
0 6 0
rubidium - 14 years ago 2009-12-17 16:59:33
rubidium@openttd.org
(svn r18522) -Feature: add the possibility to not make new tree tiles in-game
6 files changed with 28 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/lang/english.txt
Show inline comments
 
@@ -1238,24 +1238,29 @@ STR_CONFIG_SETTING_TOWN_LAYOUT          
 
STR_CONFIG_SETTING_TOWN_LAYOUT_DEFAULT                          :original
 
STR_CONFIG_SETTING_TOWN_LAYOUT_BETTER_ROADS                     :better roads
 
STR_CONFIG_SETTING_TOWN_LAYOUT_2X2_GRID                         :2x2 grid
 
STR_CONFIG_SETTING_TOWN_LAYOUT_3X3_GRID                         :3x3 grid
 
STR_CONFIG_SETTING_TOWN_LAYOUT_RANDOM                           :random
 
STR_CONFIG_SETTING_ALLOW_TOWN_ROADS                             :{LTBLUE}Towns are allowed to build roads: {ORANGE}{STRING1}
 
STR_CONFIG_SETTING_NOISE_LEVEL                                  :{LTBLUE}Allow town controlled noise level for airports: {ORANGE}{STRING}
 
STR_CONFIG_SETTING_TOWN_FOUNDING                                :{LTBLUE}Founding towns in game: {ORANGE}{STRING1}
 
STR_CONFIG_SETTING_TOWN_FOUNDING_FORBIDDEN                      :forbidden
 
STR_CONFIG_SETTING_TOWN_FOUNDING_ALLOWED                        :allowed
 
STR_CONFIG_SETTING_TOWN_FOUNDING_ALLOWED_CUSTOM_LAYOUT          :allowed, custom town layout
 

	
 
STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT                         :{LTBLUE}In game placement of trees: {ORANGE}{STRING1}
 
STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_NONE                    :none {RED}(breaks lumber mill)
 
STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_RAINFOREST              :only in rain forests
 
STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_ALL                     :everywhere
 

	
 
STR_CONFIG_SETTING_TOOLBAR_POS                                  :{LTBLUE}Position of main toolbar: {ORANGE}{STRING1}
 
STR_CONFIG_SETTING_TOOLBAR_POS_LEFT                             :Left
 
STR_CONFIG_SETTING_TOOLBAR_POS_CENTER                           :Centre
 
STR_CONFIG_SETTING_TOOLBAR_POS_RIGHT                            :Right
 
STR_CONFIG_SETTING_SNAP_RADIUS                                  :{LTBLUE}Window snap radius: {ORANGE}{STRING1} px
 
STR_CONFIG_SETTING_SNAP_RADIUS_DISABLED                         :{LTBLUE}Window snap radius: {ORANGE}disabled
 
STR_CONFIG_SETTING_SOFT_LIMIT                                   :{LTBLUE}Window soft limit (non-sticky): {ORANGE}{STRING1}
 
STR_CONFIG_SETTING_SOFT_LIMIT_DISABLED                          :{LTBLUE}Window soft limit (non-sticky): {ORANGE}disabled
 
STR_CONFIG_SETTING_TOWN_GROWTH                                  :{LTBLUE}Town growth speed: {ORANGE}{STRING1}
 
STR_CONFIG_SETTING_TOWN_GROWTH_NONE                             :None
 
STR_CONFIG_SETTING_TOWN_GROWTH_SLOW                             :Slow
 
STR_CONFIG_SETTING_TOWN_GROWTH_NORMAL                           :Normal
src/saveload/saveload.cpp
Show inline comments
 
@@ -38,25 +38,25 @@
 
#include "../autoreplace_base.h"
 
#include "../roadstop_base.h"
 
#include "../statusbar_gui.h"
 
#include "../fileio_func.h"
 
#include "../gamelog.h"
 
#include "../string_func.h"
 
#include "../engine_base.h"
 

	
 
#include "table/strings.h"
 

	
 
#include "saveload_internal.h"
 

	
 
extern const uint16 SAVEGAME_VERSION = 131;
 
extern const uint16 SAVEGAME_VERSION = 132;
 

	
 
SavegameType _savegame_type; ///< type of savegame we are loading
 

	
 
uint32 _ttdp_version;     ///< version of TTDP savegame (if applicable)
 
uint16 _sl_version;       ///< the major savegame version identifier
 
byte   _sl_minor_version; ///< the minor savegame version, DO NOT USE!
 
char _savegame_format[8]; ///< how to compress savegames
 

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

	
 
/** What are we currently doing? */
src/settings_gui.cpp
Show inline comments
 
@@ -1259,24 +1259,25 @@ static SettingEntry _settings_constructi
 
};
 
/** Signals subpage */
 
static SettingsPage _settings_construction_signals_page = {_settings_construction_signals, lengthof(_settings_construction_signals)};
 

	
 
static SettingEntry _settings_construction[] = {
 
	SettingEntry(&_settings_construction_signals_page, STR_CONFIG_SETTING_CONSTRUCTION_SIGNALS),
 
	SettingEntry("construction.build_on_slopes"),
 
	SettingEntry("construction.autoslope"),
 
	SettingEntry("construction.extra_dynamite"),
 
	SettingEntry("construction.longbridges"),
 
	SettingEntry("station.never_expire_airports"),
 
	SettingEntry("construction.freeform_edges"),
 
	SettingEntry("construction.extra_tree_placement"),
 
};
 
/** Construction sub-page */
 
static SettingsPage _settings_construction_page = {_settings_construction, lengthof(_settings_construction)};
 

	
 
static SettingEntry _settings_stations_cargo[] = {
 
	SettingEntry("order.improved_load"),
 
	SettingEntry("order.gradual_loading"),
 
	SettingEntry("order.selectgoods"),
 
};
 
/** Cargo handling sub-page */
 
static SettingsPage _settings_stations_cargo_page = {_settings_stations_cargo, lengthof(_settings_stations_cargo)};
 

	
src/settings_type.h
Show inline comments
 
@@ -173,24 +173,25 @@ struct GameCreationSettings {
 

	
 
/** Settings related to construction in-game */
 
struct ConstructionSettings {
 
	bool   build_on_slopes;                  ///< allow building on slopes
 
	bool   autoslope;                        ///< allow terraforming under things
 
	bool   longbridges;                      ///< allow 100 tile long bridges
 
	bool   signal_side;                      ///< show signals on right side
 
	bool   extra_dynamite;                   ///< extra dynamite
 
	bool   road_stop_on_town_road;           ///< allow building of drive-through road stops on town owned roads
 
	bool   road_stop_on_competitor_road;     ///< allow building of drive-through road stops on roads owned by competitors
 
	uint8  raw_industry_construction;        ///< type of (raw) industry construction (none, "normal", prospecting)
 
	bool   freeform_edges;                   ///< allow terraforming the tiles at the map edges
 
	uint8  extra_tree_placement;             ///< (dis)allow building extra trees in-game
 
};
 

	
 
/** Settings related to the AI. */
 
struct AISettings {
 
	bool   ai_in_multiplayer;                ///< so we allow AIs in multiplayer
 
	bool   ai_disable_veh_train;             ///< disable types for AI
 
	bool   ai_disable_veh_roadveh;           ///< disable types for AI
 
	bool   ai_disable_veh_aircraft;          ///< disable types for AI
 
	bool   ai_disable_veh_ship;              ///< disable types for AI
 
	uint32 ai_max_opcode_till_suspend;       ///< max opcode calls till AI will suspend
 
};
 

	
src/table/settings.h
Show inline comments
 
@@ -514,24 +514,25 @@ const SettingDesc _settings[] = {
 
	 SDT_CONDVAR(GameSettings, game_creation.oil_refinery_limit,              SLE_UINT8, 30, SL_MAX_VERSION, 0, 0,    32,                    12,      48, 0, STR_CONFIG_SETTING_OIL_REF_EDGE_DISTANCE, NULL),
 
	 SDT_CONDVAR(GameSettings, game_creation.tgen_smoothness,                 SLE_UINT8, 30, SL_MAX_VERSION, 0,MS,     1,                     0,       3, 0, STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN,  NULL),
 
	 SDT_CONDVAR(GameSettings, game_creation.generation_seed,                SLE_UINT32, 30, SL_MAX_VERSION, 0, 0,      GENERATE_NEW_SEED, 0, UINT32_MAX, 0, STR_NULL,                                 NULL),
 
	 SDT_CONDVAR(GameSettings, game_creation.tree_placer,                     SLE_UINT8, 30, SL_MAX_VERSION, 0,MS,     2,                     0,       2, 0, STR_CONFIG_SETTING_TREE_PLACER,           NULL),
 
	     SDT_VAR(GameSettings, game_creation.heightmap_rotation,              SLE_UINT8,                     S,MS,     0,                     0,       1, 0, STR_CONFIG_SETTING_HEIGHTMAP_ROTATION,    NULL),
 
	     SDT_VAR(GameSettings, game_creation.se_flat_world_height,            SLE_UINT8,                     S, 0,     1,                     0,      15, 0, STR_CONFIG_SETTING_SE_FLAT_WORLD_HEIGHT,  NULL),
 

	
 
	     SDT_VAR(GameSettings, game_creation.map_x,                           SLE_UINT8,                     S, 0,     8, MIN_MAP_SIZE_BITS, MAX_MAP_SIZE_BITS, 0, STR_CONFIG_SETTING_MAP_X,           NULL),
 
	     SDT_VAR(GameSettings, game_creation.map_y,                           SLE_UINT8,                     S, 0,     8, MIN_MAP_SIZE_BITS, MAX_MAP_SIZE_BITS, 0, STR_CONFIG_SETTING_MAP_Y,           NULL),
 
	SDT_CONDBOOL(GameSettings, construction.freeform_edges,                             111, SL_MAX_VERSION, 0, 0,  true,                                    STR_CONFIG_SETTING_ENABLE_FREEFORM_EDGES, CheckFreeformEdges),
 
	 SDT_CONDVAR(GameSettings, game_creation.water_borders,                   SLE_UINT8,111, SL_MAX_VERSION, 0, 0,    15,                     0,      16, 0, STR_NULL,                                 NULL),
 
	 SDT_CONDVAR(GameSettings, game_creation.custom_town_number,             SLE_UINT16,115, SL_MAX_VERSION, 0, 0,     1,                     1,    5000, 0, STR_NULL,                                 NULL),
 
	 SDT_CONDVAR(GameSettings, construction.extra_tree_placement,             SLE_UINT8,132, SL_MAX_VERSION, 0,MS,     2,                     0,       2, 0, STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT,  NULL),
 

	
 
 SDT_CONDOMANY(GameSettings, locale.currency,                               SLE_UINT8, 97, SL_MAX_VERSION, N, 0, 0, CUSTOM_CURRENCY_ID, _locale_currencies, STR_NULL, NULL, NULL),
 
 SDT_CONDOMANY(GameSettings, locale.units,                                  SLE_UINT8, 97, SL_MAX_VERSION, N, 0, 1, 2, _locale_units,                       STR_NULL, NULL, NULL),
 
   SDT_CONDSTR(GameSettings, locale.digit_group_separator,                   SLE_STRQ,118, SL_MAX_VERSION, N, 0, NULL,                                      STR_NULL, NULL),
 
   SDT_CONDSTR(GameSettings, locale.digit_group_separator_currency,          SLE_STRQ,118, SL_MAX_VERSION, N, 0, NULL,                                      STR_NULL, NULL),
 
   SDT_CONDSTR(GameSettings, locale.digit_decimal_separator,                 SLE_STRQ,126, SL_MAX_VERSION, N, 0, NULL,                                      STR_NULL, NULL),
 

	
 
	/***************************************************************************/
 
	/* Unsaved setting variables. */
 
	SDTC_OMANY(gui.autosave,                  SLE_UINT8, S,  0, 1, 4, _autosave_interval,     STR_NULL,                                       NULL),
 
	 SDTC_BOOL(gui.threaded_saves,                       S,  0,  true,                        STR_NULL,                                       NULL),
 
	SDTC_OMANY(gui.date_format_in_default_names,SLE_UINT8,S,MS, 0, 2, _savegame_date,         STR_CONFIG_SETTING_DATE_FORMAT_IN_SAVE_NAMES,   NULL),
src/tree_cmd.cpp
Show inline comments
 
@@ -36,24 +36,32 @@
 

	
 
/**
 
 * List of tree placer algorithm.
 
 *
 
 * This enumeration defines all possible tree placer algorithm in the game.
 
 */
 
enum TreePlacer {
 
	TP_NONE,     ///< No tree placer algorithm
 
	TP_ORIGINAL, ///< The original algorithm
 
	TP_IMPROVED, ///< A 'improved' algorithm
 
};
 

	
 
/** Where to place trees while in-game? */
 
enum ExtraTreePlacement {
 
	ETP_NONE,       ///< Place trees on no tiles
 
	ETP_RAINFOREST, ///< Place trees only on rainforest tiles
 
	ETP_ALL,        ///< Place trees on all tiles
 
};
 

	
 

	
 
/**
 
 * Tests if a tile can be converted to MP_TREES
 
 * This is true for clear ground without farms or rocks.
 
 *
 
 * @param tile the tile of interest
 
 * @param allow_desert Allow planting trees on CLEAR_DESERT?
 
 * @return true if trees can be built.
 
 */
 
static bool CanPlantTreesOnTile(TileIndex tile, bool allow_desert)
 
{
 
	switch (GetTileType(tile)) {
 
		case MP_WATER:
 
@@ -653,24 +661,31 @@ static void TileLoop_Trees(TileIndex til
 
						AddTreeGrowth(tile, 1);
 
						break;
 

	
 
					case 1: // add a tree
 
						if (GetTreeCount(tile) < 4) {
 
							AddTreeCount(tile, 1);
 
							SetTreeGrowth(tile, 0);
 
							break;
 
						}
 
						/* FALL THROUGH */
 

	
 
					case 2: { // add a neighbouring tree
 
						/* Don't plant extra trees if that's not allowed. */
 
						if ((_settings_game.game_creation.landscape == LT_TROPIC && GetTropicZone(tile) == TROPICZONE_RAINFOREST) ?
 
								_settings_game.construction.extra_tree_placement == ETP_NONE :
 
								_settings_game.construction.extra_tree_placement != ETP_ALL) {
 
							break;
 
						}
 

	
 
						TreeType treetype = GetTreeType(tile);
 

	
 
						tile += TileOffsByDir((Direction)(Random() & 7));
 

	
 
						/* Cacti don't spread */
 
						if (!CanPlantTreesOnTile(tile, false)) return;
 

	
 
						/* Don't plant trees, if ground was freshly cleared */
 
						if (IsTileType(tile, MP_CLEAR) && GetClearGround(tile) == CLEAR_GRASS && GetClearDensity(tile) != 3) return;
 

	
 
						PlantTreesOnTile(tile, treetype, 0, 0);
 

	
 
@@ -702,38 +717,41 @@ static void TileLoop_Trees(TileIndex til
 
			break;
 

	
 
		default:
 
			AddTreeGrowth(tile, 1);
 
			break;
 
	}
 

	
 
	MarkTileDirtyByTile(tile);
 
}
 

	
 
void OnTick_Trees()
 
{
 
	/* Don't place trees if that's not allowed */
 
	if (_settings_game.construction.extra_tree_placement == ETP_NONE) return;
 

	
 
	uint32 r;
 
	TileIndex tile;
 
	TreeType tree;
 

	
 
	/* place a tree at a random rainforest spot */
 
	if (_settings_game.game_creation.landscape == LT_TROPIC &&
 
			(r = Random(), tile = RandomTileSeed(r), GetTropicZone(tile) == TROPICZONE_RAINFOREST) &&
 
			CanPlantTreesOnTile(tile, false) &&
 
			(tree = GetRandomTreeType(tile, GB(r, 24, 8))) != TREE_INVALID) {
 
		PlantTreesOnTile(tile, tree, 0, 0);
 
	}
 

	
 
	/* byte underflow */
 
	if (--_trees_tick_ctr != 0) return;
 
	if (--_trees_tick_ctr != 0 || _settings_game.construction.extra_tree_placement != ETP_ALL) return;
 

	
 
	/* place a tree at a random spot */
 
	r = Random();
 
	tile = RandomTileSeed(r);
 
	if (CanPlantTreesOnTile(tile, false) && (tree = GetRandomTreeType(tile, GB(r, 24, 8))) != TREE_INVALID) {
 
		PlantTreesOnTile(tile, tree, 0, 0);
 
	}
 
}
 

	
 
static TrackStatus GetTileTrackStatus_Trees(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
 
{
 
	return 0;
0 comments (0 inline, 0 general)