Changeset - r9354:358e967da2ca
[Not reviewed]
src/ai/ai.cpp
Show inline comments
 
@@ -151,13 +151,13 @@ static void AI_RunTick(PlayerID player)
 
{
 
	extern void AiNewDoGameLoop(Player *p);
 

	
 
	Player *p = GetPlayer(player);
 
	_current_player = player;
 

	
 
	if (_patches.ainew_active) {
 
	if (_settings.ai.ainew_active) {
 
		AiNewDoGameLoop(p);
 
	} else {
 
		/* Enable all kind of cheats the old AI needs in order to operate correctly... */
 
		_is_old_ai_player = true;
 
		AiDoGameLoop(p);
 
		_is_old_ai_player = false;
 
@@ -175,13 +175,13 @@ static void AI_RunTick(PlayerID player)
 
void AI_RunGameLoop()
 
{
 
	/* Don't do anything if ai is disabled */
 
	if (!_ai.enabled) return;
 

	
 
	/* Don't do anything if we are a network-client, or the AI has been disabled */
 
	if (_networking && (!_network_server || !_patches.ai_in_multiplayer)) return;
 
	if (_networking && (!_network_server || !_settings.ai.ai_in_multiplayer)) return;
 

	
 
	/* New tick */
 
	_ai.tick++;
 

	
 
	/* Make sure the AI follows the difficulty rule.. */
 
	assert(_opt.diff.competitor_speed <= 4);
src/ai/ai.h
Show inline comments
 
@@ -64,20 +64,20 @@ static inline bool AI_AllowNewAI()
 
	if (_networking && !_network_server)
 
		return false;
 

	
 
	/* If in network, and server, possible AI */
 
	if (_networking && _network_server) {
 
		/* Do we want AIs in multiplayer? */
 
		if (!_patches.ai_in_multiplayer)
 
		if (!_settings.ai.ai_in_multiplayer)
 
			return false;
 

	
 
		/* Only the NewAI is allowed... sadly enough the old AI just doesn't support this
 
		 *  system, because all commands are delayed by at least 1 tick, which causes
 
		 *  a big problem, because it uses variables that are only set AFTER the command
 
		 *  is really executed... */
 
		if (!_patches.ainew_active)
 
		if (!_settings.ai.ainew_active)
 
			return false;
 
	}
 

	
 
	return true;
 
}
 

	
src/ai/default/default.cpp
Show inline comments
 
@@ -1567,27 +1567,27 @@ static void AiStateWantNewRoute(Player *
 
	}
 

	
 
	i = 200;
 
	for (;;) {
 
		r = (uint16)Random();
 

	
 
		if (_patches.ai_disable_veh_train &&
 
				_patches.ai_disable_veh_roadveh &&
 
				_patches.ai_disable_veh_aircraft &&
 
				_patches.ai_disable_veh_ship) {
 
		if (_settings.ai.ai_disable_veh_train &&
 
				_settings.ai.ai_disable_veh_roadveh &&
 
				_settings.ai.ai_disable_veh_aircraft &&
 
				_settings.ai.ai_disable_veh_ship) {
 
			return;
 
		}
 

	
 
		if (r < 0x7626) {
 
			if (_patches.ai_disable_veh_train) continue;
 
			if (_settings.ai.ai_disable_veh_train) continue;
 
			AiWantTrainRoute(p);
 
		} else if (r < 0xC4EA) {
 
			if (_patches.ai_disable_veh_roadveh) continue;
 
			if (_settings.ai.ai_disable_veh_roadveh) continue;
 
			AiWantRoadRoute(p);
 
		} else if (r < 0xD89B) {
 
			if (_patches.ai_disable_veh_aircraft) continue;
 
			if (_settings.ai.ai_disable_veh_aircraft) continue;
 
			AiWantAircraftRoute(p);
 
		} else {
 
			/* Ships are not implemented in this (broken) AI */
 
		}
 

	
 
		// got a route?
 
@@ -1600,13 +1600,13 @@ static void AiStateWantNewRoute(Player *
 
		}
 
	}
 
}
 

	
 
static bool AiCheckTrackResources(TileIndex tile, const AiDefaultBlockData *p, byte cargo)
 
{
 
	uint rad = (_patches.modified_catchment) ? CA_TRAIN : CA_UNMODIFIED;
 
	uint rad = (_settings.station.modified_catchment) ? CA_TRAIN : CA_UNMODIFIED;
 

	
 
	for (; p->mode != 4; p++) {
 
		AcceptedCargo values;
 
		TileIndex tile2;
 
		uint w;
 
		uint h;
 
@@ -2596,13 +2596,13 @@ static void AiStateDeleteRailBlocks(Play
 

	
 
static bool AiCheckRoadResources(TileIndex tile, const AiDefaultBlockData *p, byte cargo)
 
{
 
	uint values[NUM_CARGO];
 
	int rad;
 

	
 
	if (_patches.modified_catchment) {
 
	if (_settings.station.modified_catchment) {
 
		rad = CA_TRUCK; // Same as CA_BUS at the moment?
 
	} else { // change that at some point?
 
		rad = 4;
 
	}
 

	
 
	for (;; p++) {
 
@@ -3420,13 +3420,13 @@ static bool AiCheckAirportResources(Tile
 

	
 
	for (; p->mode == 0; p++) {
 
		TileIndex tile2 = TILE_ADD(tile, ToTileIndexDiff(p->tileoffs));
 
		const AirportFTAClass* airport = GetAirport(p->attr);
 
		uint w = airport->size_x;
 
		uint h = airport->size_y;
 
		uint rad = _patches.modified_catchment ? airport->catchment : (uint)CA_UNMODIFIED;
 
		uint rad = _settings.station.modified_catchment ? airport->catchment : (uint)CA_UNMODIFIED;
 

	
 
		if (cargo & 0x80) {
 
			GetProductionAroundTiles(values, tile2, w, h, rad);
 
			return values[cargo & 0x7F] != 0;
 
		} else {
 
			GetAcceptanceAroundTiles(values, tile2, w, h, rad);
 
@@ -3972,13 +3972,13 @@ void AiDoGameLoop(Player *p)
 
	}
 

	
 
	// Ugly hack to make sure the service interval of the AI is good, not looking
 
	//  to the patch-setting
 
	// Also, it takes into account the setting if the service-interval is in days
 
	//  or in %
 
	_ai_service_interval = _patches.servint_ispercent ? 80 : 180;
 
	_ai_service_interval = _settings.vehicle.servint_ispercent ? 80 : 180;
 

	
 
	if (IsHumanPlayer(_current_player)) return;
 

	
 
	AiAdjustLoan(p);
 
	AiBuildCompanyHQ(p);
 

	
src/ai/trolly/trolly.cpp
Show inline comments
 
@@ -127,24 +127,24 @@ static void AiNew_State_WakeUp(Player *p
 
				c < 10) {
 
			_players_ainew[p->index].action = AI_ACTION_REPAY_LOAN;
 
		} else if (_players_ainew[p->index].last_vehiclecheck_date + AI_DAYS_BETWEEN_VEHICLE_CHECKS < _date) {
 
			// Check all vehicles once in a while
 
			_players_ainew[p->index].action = AI_ACTION_CHECK_ALL_VEHICLES;
 
			_players_ainew[p->index].last_vehiclecheck_date = _date;
 
		} else if (c < 100 && !_patches.ai_disable_veh_roadveh) {
 
		} else if (c < 100 && !_settings.ai.ai_disable_veh_roadveh) {
 
			// Do we have any spots for road-vehicles left open?
 
			if (GetFreeUnitNumber(VEH_ROAD) <= _patches.max_roadveh) {
 
			if (GetFreeUnitNumber(VEH_ROAD) <= _settings.vehicle.max_roadveh) {
 
				if (c < 85) {
 
					_players_ainew[p->index].action = AI_ACTION_TRUCK_ROUTE;
 
				} else {
 
					_players_ainew[p->index].action = AI_ACTION_BUS_ROUTE;
 
				}
 
			}
 
#if 0
 
		} else if (c < 200 && !_patches.ai_disable_veh_train) {
 
			if (GetFreeUnitNumber(VEH_TRAIN) <= _patches.max_trains) {
 
		} else if (c < 200 && !_settings.ai.ai_disable_veh_train) {
 
			if (GetFreeUnitNumber(VEH_TRAIN) <= _settings.vehicle.max_trains) {
 
				_players_ainew[p->index].action = AI_ACTION_TRAIN_ROUTE;
 
			}
 
#endif
 
		}
 

	
 
		_players_ainew[p->index].counter = 0;
 
@@ -152,13 +152,13 @@ static void AiNew_State_WakeUp(Player *p
 

	
 
	if (_players_ainew[p->index].counter++ > AI_MAX_TRIES_FOR_SAME_ROUTE) {
 
		_players_ainew[p->index].action = AI_ACTION_NONE;
 
		return;
 
	}
 

	
 
	if (_patches.ai_disable_veh_roadveh && (
 
	if (_settings.ai.ai_disable_veh_roadveh && (
 
				_players_ainew[p->index].action == AI_ACTION_BUS_ROUTE ||
 
				_players_ainew[p->index].action == AI_ACTION_TRUCK_ROUTE
 
			)) {
 
		_players_ainew[p->index].action = AI_ACTION_NONE;
 
		return;
 
	}
 
@@ -176,24 +176,24 @@ static void AiNew_State_WakeUp(Player *p
 
	}
 

	
 
	// It is useless to start finding a route if we don't have enough money
 
	//  to build the route anyway..
 
	if (_players_ainew[p->index].action == AI_ACTION_BUS_ROUTE &&
 
			money > AI_MINIMUM_BUS_ROUTE_MONEY) {
 
		if (GetFreeUnitNumber(VEH_ROAD) > _patches.max_roadveh) {
 
		if (GetFreeUnitNumber(VEH_ROAD) > _settings.vehicle.max_roadveh) {
 
			_players_ainew[p->index].action = AI_ACTION_NONE;
 
			return;
 
		}
 
		_players_ainew[p->index].cargo = AI_NEED_CARGO;
 
		_players_ainew[p->index].state = AI_STATE_LOCATE_ROUTE;
 
		_players_ainew[p->index].tbt = AI_BUS; // Bus-route
 
		return;
 
	}
 
	if (_players_ainew[p->index].action == AI_ACTION_TRUCK_ROUTE &&
 
			money > AI_MINIMUM_TRUCK_ROUTE_MONEY) {
 
		if (GetFreeUnitNumber(VEH_ROAD) > _patches.max_roadveh) {
 
		if (GetFreeUnitNumber(VEH_ROAD) > _settings.vehicle.max_roadveh) {
 
			_players_ainew[p->index].action = AI_ACTION_NONE;
 
			return;
 
		}
 
		_players_ainew[p->index].cargo = AI_NEED_CARGO;
 
		_players_ainew[p->index].last_id = 0;
 
		_players_ainew[p->index].state = AI_STATE_LOCATE_ROUTE;
 
@@ -1032,13 +1032,13 @@ static void AiNew_State_BuildPath(Player
 
	_players_ainew[p->index].path_info.position++;
 
	// Build route
 
	AiNew_Build_RoutePart(p, &_players_ainew[p->index].path_info, DC_EXEC);
 
	if (_players_ainew[p->index].path_info.position == -2) {
 
		// This means we are done building!
 

	
 
		if (_players_ainew[p->index].tbt == AI_TRUCK && !_patches.roadveh_queue) {
 
		if (_players_ainew[p->index].tbt == AI_TRUCK && !_settings.pf.roadveh_queue) {
 
			// If they not queue, they have to go up and down to try again at a station...
 
			// We don't want that, so try building some road left or right of the station
 
			DiagDirection dir1, dir2, dir3;
 
			TileIndex tile;
 
			CommandCost ret;
 
			for (int i = 0; i < 2; i++) {
 
@@ -1183,13 +1183,13 @@ static void AiNew_State_GiveOrders(Playe
 
		return;
 
	} else {
 
		_players_ainew[p->index].veh_main_id = _players_ainew[p->index].veh_id;
 
	}
 

	
 
	// Very handy for AI, goto depot.. but yeah, it needs to be activated ;)
 
	if (_patches.gotodepot) {
 
	if (_settings.order.gotodepot) {
 
		idx = 0;
 
		order.MakeGoToDepot(GetDepotByTile(_players_ainew[p->index].depot_tile)->index, ODTFB_PART_OF_ORDERS);
 
		AI_DoCommand(0, _players_ainew[p->index].veh_id + (idx << 16), order.Pack(), DC_EXEC, CMD_INSERT_ORDER);
 
	}
 

	
 
	idx = 0;
src/aircraft_cmd.cpp
Show inline comments
 
@@ -284,13 +284,13 @@ CommandCost CmdBuildAircraft(TileIndex t
 
	Vehicle *vl[3];
 
	if (!Vehicle::AllocateList(vl, avi->subtype & AIR_CTOL ? 2 : 3)) {
 
		return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
 
	}
 

	
 
	UnitID unit_num = HasBit(p2, 0) ? 0 : GetFreeUnitNumber(VEH_AIRCRAFT);
 
	if (unit_num > _patches.max_aircraft)
 
	if (unit_num > _settings.vehicle.max_aircraft)
 
		return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
 

	
 
	if (flags & DC_EXEC) {
 
		Vehicle *v = vl[0]; // aircraft
 
		Vehicle *u = vl[1]; // shadow
 

	
 
@@ -401,13 +401,13 @@ CommandCost CmdBuildAircraft(TileIndex t
 

	
 
		v->u.air.state = HANGAR;
 
		v->u.air.previous_pos = v->u.air.pos;
 
		v->u.air.targetairport = GetStationIndex(tile);
 
		v->SetNext(u);
 

	
 
		v->service_interval = _patches.servint_aircraft;
 
		v->service_interval = _settings.vehicle.servint_aircraft;
 

	
 
		v->date_of_last_service = _date;
 
		v->build_year = u->build_year = _cur_year;
 

	
 
		v->cur_image = u->cur_image = 0xEA0;
 

	
 
@@ -661,13 +661,13 @@ CommandCost CmdRefitAircraft(TileIndex t
 
	return cost;
 
}
 

	
 

	
 
static void CheckIfAircraftNeedsService(Vehicle *v)
 
{
 
	if (_patches.servint_aircraft == 0 || !v->NeedsAutomaticServicing()) return;
 
	if (_settings.vehicle.servint_aircraft == 0 || !v->NeedsAutomaticServicing()) return;
 
	if (v->IsInDepot()) {
 
		VehicleServiceInDepot(v);
 
		return;
 
	}
 

	
 
	const Station *st = GetStation(v->current_order.GetDestination());
 
@@ -881,13 +881,13 @@ static int UpdateAircraftSpeed(Vehicle *
 
{
 
	uint spd = v->acceleration * 16;
 
	byte t;
 

	
 
	/* Adjust speed limits by plane speed factor to prevent taxiing
 
	 * and take-off speeds being too low. */
 
	speed_limit *= _patches.plane_speed;
 
	speed_limit *= _settings.vehicle.plane_speed;
 

	
 
	if (v->u.air.cached_max_speed < speed_limit) {
 
		if (v->cur_speed < speed_limit) hard_limit = false;
 
		speed_limit = v->u.air.cached_max_speed;
 
	}
 

	
 
@@ -899,29 +899,29 @@ static int UpdateAircraftSpeed(Vehicle *
 
	 * forced to slow down rapidly in the short distance needed. The magic
 
	 * value 16384 was determined to give similar results to the old speed/48
 
	 * method at slower speeds. This also results in less reduction at slow
 
	 * speeds to that aircraft do not get to taxi speed straight after
 
	 * touchdown. */
 
	if (!hard_limit && v->cur_speed > speed_limit) {
 
		speed_limit = v->cur_speed - max(1, ((v->cur_speed * v->cur_speed) / 16384) / _patches.plane_speed);
 
		speed_limit = v->cur_speed - max(1, ((v->cur_speed * v->cur_speed) / 16384) / _settings.vehicle.plane_speed);
 
	}
 

	
 
	spd = min(v->cur_speed + (spd >> 8) + (v->subspeed < t), speed_limit);
 

	
 
	/* adjust speed for broken vehicles */
 
	if (v->vehstatus & VS_AIRCRAFT_BROKEN) spd = min(spd, SPEED_LIMIT_BROKEN);
 

	
 
	/* updates statusbar only if speed have changed to save CPU time */
 
	if (spd != v->cur_speed) {
 
		v->cur_speed = spd;
 
		if (_patches.vehicle_speed)
 
		if (_settings.gui.vehicle_speed)
 
			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
	}
 

	
 
	/* Adjust distance moved by plane speed setting */
 
	if (_patches.plane_speed > 1) spd /= _patches.plane_speed;
 
	if (_settings.vehicle.plane_speed > 1) spd /= _settings.vehicle.plane_speed;
 

	
 
	if (!(v->direction & 1)) spd = spd * 3 / 4;
 

	
 
	spd += v->progress;
 
	v->progress = (byte)spd;
 
	return spd >> 8;
 
@@ -1596,13 +1596,13 @@ static void AircraftEventHandler_AtTermi
 
{
 
	/* if we just arrived, execute EnterTerminal first */
 
	if (v->u.air.previous_pos != v->u.air.pos) {
 
		AircraftEventHandler_EnterTerminal(v, apc);
 
		/* on an airport with helipads, a helicopter will always land there
 
		 * and get serviced at the same time - patch setting */
 
		if (_patches.serviceathelipad) {
 
		if (_settings.order.serviceathelipad) {
 
			if (v->subtype == AIR_HELICOPTER && apc->helipads != NULL) {
 
				/* an exerpt of ServiceAircraft, without the invisibility stuff */
 
				v->date_of_last_service = _date;
 
				v->breakdowns_since_last_service = 0;
 
				v->reliability = GetEngine(v->engine_type)->reliability;
 
				InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
src/airport.cpp
Show inline comments
 
@@ -474,13 +474,13 @@ const AirportFTAClass *GetAirport(const 
 

	
 

	
 
uint32 GetValidAirports()
 
{
 
	uint32 mask = 0;
 

	
 
	if (_cur_year <  1960 || _patches.always_small_airport) SetBit(mask, 0);  // small airport
 
	if (_cur_year <  1960 || _settings.station.always_small_airport) SetBit(mask, 0);  // small airport
 
	if (_cur_year >= 1955) SetBit(mask, 1); // city airport
 
	if (_cur_year >= 1963) SetBit(mask, 2); // heliport
 
	if (_cur_year >= 1980) SetBit(mask, 3); // metropolitan airport
 
	if (_cur_year >= 1990) SetBit(mask, 4); // international airport
 
	if (_cur_year >= 1983) SetBit(mask, 5); // commuter airport
 
	if (_cur_year >= 1976) SetBit(mask, 6); // helidepot
src/airport_gui.cpp
Show inline comments
 
@@ -67,18 +67,18 @@ static OnButtonClick * const _build_air_
 
};
 

	
 
struct BuildAirToolbarWindow : Window {
 
	BuildAirToolbarWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
 
	{
 
		this->FindWindowPlacementAndResize(desc);
 
		if (_patches.link_terraform_toolbar) ShowTerraformToolbar(this);
 
		if (_settings.gui.link_terraform_toolbar) ShowTerraformToolbar(this);
 
	}
 

	
 
	~BuildAirToolbarWindow()
 
	{
 
		if (_patches.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0);
 
		if (_settings.gui.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0);
 
	}
 

	
 
	virtual void OnPaint()
 
	{
 
		this->DrawWidgets();
 
	}
 
@@ -175,13 +175,13 @@ public:
 
	AirportPickerWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent)
 
	{
 
		this->SetWidgetLoweredState(BAW_BTN_DONTHILIGHT, !_station_show_coverage);
 
		this->SetWidgetLoweredState(BAW_BTN_DOHILIGHT, _station_show_coverage);
 
		this->LowerWidget(_selected_airport_type + BAW_SMALL_AIRPORT);
 

	
 
		if (_patches.station_noise_level) {
 
		if (_settings.economy.station_noise_level) {
 
			ResizeWindowForWidget(this, BAW_BOTTOMPANEL, 0, 10);
 
		}
 

	
 
		this->FindWindowPlacementAndResize(desc);
 
	}
 

	
 
@@ -208,20 +208,20 @@ public:
 
		for (i = 0; i < BAW_AIRPORT_COUNT; i++) this->SetWidgetDisabledState(i + BAW_SMALL_AIRPORT, !HasBit(avail_airports, i));
 

	
 
		/* select default the coverage area to 'Off' (16) */
 
		airport = GetAirport(_selected_airport_type);
 
		SetTileSelectSize(airport->size_x, airport->size_y);
 

	
 
		int rad = _patches.modified_catchment ? airport->catchment : (uint)CA_UNMODIFIED;
 
		int rad = _settings.station.modified_catchment ? airport->catchment : (uint)CA_UNMODIFIED;
 

	
 
		if (_station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
 

	
 
		this->DrawWidgets();
 

	
 
		/* only show the station (airport) noise, if the noise option is activated */
 
		if (_patches.station_noise_level) {
 
		if (_settings.economy.station_noise_level) {
 
			/* show the noise of the selected airport */
 
			SetDParam(0, airport->noise_level);
 
			DrawString(2, 206, STR_STATION_NOISE, 0);
 
			y_noise_offset = 10;
 
		}
 

	
src/autoslope.h
Show inline comments
 
@@ -35,12 +35,12 @@ static inline bool AutoslopeCheckForEntr
 
 * Autoslope is disabled for town/industry construction and old ai players.
 
 *
 
 * @return true iff autoslope is enabled.
 
 */
 
static inline bool AutoslopeEnabled()
 
{
 
	return (_patches.autoslope &&
 
	return (_settings.construction.autoslope &&
 
	        ((IsValidPlayer(_current_player) && !_is_old_ai_player) ||
 
	         (_current_player == OWNER_NONE && _game_mode == GM_EDITOR)));
 
}
 

	
 
#endif /* AUTOSLOPE_H */
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -503,13 +503,13 @@ static int DrawRailWagonPurchaseInfo(int
 
	SetDParam(0, weight);
 
	SetDParam(1, (GetCargo(rvi->cargo_type)->weight * GetEngineProperty(engine_number, 0x14, rvi->capacity) >> 4) + weight);
 
	DrawString(x, y, STR_PURCHASE_INFO_WEIGHT_CWEIGHT, TC_FROMSTRING);
 
	y += 10;
 

	
 
	/* Wagon speed limit, displayed if above zero */
 
	if (_patches.wagon_speed_limits) {
 
	if (_settings.vehicle.wagon_speed_limits) {
 
		uint max_speed = GetEngineProperty(engine_number, 0x09, rvi->max_speed);
 
		if (max_speed > 0) {
 
			SetDParam(0, max_speed * 10 / 16);
 
			DrawString(x, y, STR_PURCHASE_INFO_SPEED, TC_FROMSTRING);
 
			y += 10;
 
		}
 
@@ -541,13 +541,13 @@ static int DrawRailEnginePurchaseInfo(in
 
	SetDParam(0, GetEngineProperty(engine_number, 0x09, rvi->max_speed) * 10 / 16);
 
	SetDParam(1, GetEngineProperty(engine_number, 0x0B, rvi->power));
 
	DrawString(x, y, STR_PURCHASE_INFO_SPEED_POWER, TC_FROMSTRING);
 
	y += 10;
 

	
 
	/* Max tractive effort - not applicable if old acceleration or maglev */
 
	if (_patches.realistic_acceleration && rvi->railtype != RAILTYPE_MAGLEV) {
 
	if (_settings.vehicle.realistic_acceleration && rvi->railtype != RAILTYPE_MAGLEV) {
 
		SetDParam(0, ((weight << multihead) * 10 * GetEngineProperty(engine_number, 0x1F, rvi->tractive_effort)) / 256);
 
		DrawString(x, y, STR_PURCHASE_INFO_MAX_TE, TC_FROMSTRING);
 
		y += 10;
 
	}
 

	
 
	/* Running cost */
src/clear_cmd.cpp
Show inline comments
 
@@ -343,13 +343,13 @@ static void ChangeTileOwner_Clear(TileIn
 
{
 
	return;
 
}
 

	
 
void InitializeClearLand()
 
{
 
	_opt.snow_line = _patches.snow_line_height * TILE_HEIGHT;
 
	_opt.snow_line = _settings.game_creation.snow_line_height * TILE_HEIGHT;
 
}
 

	
 
static CommandCost TerraformTile_Clear(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new)
 
{
 
	return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
 
}
src/console_cmds.cpp
Show inline comments
 
@@ -923,27 +923,27 @@ DEF_CONSOLE_CMD(ConRestart)
 
		IConsoleHelp("Restart game. Usage: 'restart'");
 
		IConsoleHelp("Restarts a game. It tries to reproduce the exact same map as the game started with.");
 
		return true;
 
	}
 

	
 
	/* Don't copy the _newgame pointers to the real pointers, so call SwitchMode directly */
 
	_patches.map_x = MapLogX();
 
	_patches.map_y = FindFirstBit(MapSizeY());
 
	_settings.game_creation.map_x = MapLogX();
 
	_settings.game_creation.map_y = FindFirstBit(MapSizeY());
 
	SwitchMode(SM_NEWGAME);
 
	return true;
 
}
 

	
 
DEF_CONSOLE_CMD(ConGetSeed)
 
{
 
	if (argc == 0) {
 
		IConsoleHelp("Returns the seed used to create this game. Usage: 'getseed'");
 
		IConsoleHelp("The seed can be used to reproduce the exact same map as the game started with.");
 
		return true;
 
	}
 

	
 
	IConsolePrintF(CC_DEFAULT, "Generation Seed: %u", _patches.generation_seed);
 
	IConsolePrintF(CC_DEFAULT, "Generation Seed: %u", _settings.game_creation.generation_seed);
 
	return true;
 
}
 

	
 
DEF_CONSOLE_CMD(ConGetDate)
 
{
 
	if (argc == 0) {
 
@@ -1080,13 +1080,13 @@ DEF_CONSOLE_CMD(ConExit)
 
{
 
	if (argc == 0) {
 
		IConsoleHelp("Exit the game. Usage: 'exit'");
 
		return true;
 
	}
 

	
 
	if (_game_mode == GM_NORMAL && _patches.autosave_on_exit) DoExitSave();
 
	if (_game_mode == GM_NORMAL && _settings.gui.autosave_on_exit) DoExitSave();
 

	
 
	_exit_game = true;
 
	return true;
 
}
 

	
 
DEF_CONSOLE_CMD(ConPart)
src/date.cpp
Show inline comments
 
@@ -280,16 +280,16 @@ void IncreaseDate()
 
	TrainsYearlyLoop();
 
	RoadVehiclesYearlyLoop();
 
	AircraftYearlyLoop();
 
	ShipsYearlyLoop();
 
	if (_network_server) NetworkServerYearlyLoop();
 

	
 
	if (_cur_year == _patches.semaphore_build_before) ResetSignalVariant();
 
	if (_cur_year == _settings.gui.semaphore_build_before) ResetSignalVariant();
 

	
 
	/* check if we reached end of the game */
 
	if (_cur_year == _patches.ending_year) {
 
	if (_cur_year == _settings.gui.ending_year) {
 
			ShowEndGameChart();
 
	/* check if we reached the maximum year, decrement dates by a year */
 
	} else if (_cur_year == MAX_YEAR + 1) {
 
		Vehicle *v;
 
		uint days_this_year;
 

	
 
@@ -300,8 +300,8 @@ void IncreaseDate()
 

	
 
		/* Because the _date wraps here, and text-messages expire by game-days, we have to clean out
 
		 *  all of them if the date is set back, else those messages will hang for ever */
 
		InitChatMessage();
 
	}
 

	
 
	if (_patches.auto_euro) CheckSwitchToEuro();
 
	if (_settings.gui.auto_euro) CheckSwitchToEuro();
 
}
src/dock_gui.cpp
Show inline comments
 
@@ -133,18 +133,18 @@ static OnButtonClick * const _build_dock
 
};
 

	
 
struct BuildDocksToolbarWindow : Window {
 
	BuildDocksToolbarWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
 
	{
 
		this->FindWindowPlacementAndResize(desc);
 
		if (_patches.link_terraform_toolbar) ShowTerraformToolbar(this);
 
		if (_settings.gui.link_terraform_toolbar) ShowTerraformToolbar(this);
 
	}
 

	
 
	~BuildDocksToolbarWindow()
 
	{
 
		if (_patches.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0);
 
		if (_settings.gui.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0);
 
	}
 

	
 
	virtual void OnPaint()
 
	{
 
		this->SetWidgetsDisabledState(!CanBuildVehicleInfrastructure(VEH_SHIP), DTW_DEPOT, DTW_STATION, DTW_BUOY, WIDGET_LIST_END);
 
		this->DrawWidgets();
 
@@ -260,13 +260,13 @@ public:
 
		this->LowerWidget(_station_show_coverage + BDSW_LT_OFF);
 
		this->FindWindowPlacementAndResize(desc);
 
	}
 

	
 
	virtual void OnPaint()
 
	{
 
		int rad = (_patches.modified_catchment) ? CA_DOCK : CA_UNMODIFIED;
 
		int rad = (_settings.station.modified_catchment) ? CA_DOCK : CA_UNMODIFIED;
 

	
 
		this->DrawWidgets();
 

	
 
		if (_station_show_coverage) {
 
			SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
 
		} else {
src/economy.cpp
Show inline comments
 
@@ -651,13 +651,13 @@ static void AddInflation()
 
	 * inflation mechanism during the first 170 years (the amount of years that
 
	 * one had in the original TTD) and stop doing the inflation after that
 
	 * because it only causes problems that can't be solved nicely and the
 
	 * inflation doesn't add anything after that either; it even makes playing
 
	 * it impossible due to the diverging cost and income rates.
 
	 */
 
	if ((_cur_year - _patches.starting_year) >= (ORIGINAL_MAX_YEAR - ORIGINAL_BASE_YEAR)) return;
 
	if ((_cur_year - _settings.game_creation.starting_year) >= (ORIGINAL_MAX_YEAR - ORIGINAL_BASE_YEAR)) return;
 

	
 
	/* Approximation for (100 + infl_amount)% ** (1 / 12) - 100%
 
	 * scaled by 65536
 
	 * 12 -> months per year
 
	 * This is only a good approxiamtion for small values
 
	 */
 
@@ -1205,13 +1205,13 @@ static void DeliverGoodsToIndustry(TileI
 
	uint accepted_cargo_index = 0;  ///< unlikely value, just for warning removing
 

	
 
	/* Check if there's an industry close to the station that accepts the cargo
 
	 * XXX - Think of something better to
 
	 *       1) Only deliver to industries which are withing the catchment radius
 
	 *       2) Distribute between industries if more then one is present */
 
	best_dist = (_patches.station_spread + 8) * 2;
 
	best_dist = (_settings.station.station_spread + 8) * 2;
 
	FOR_ALL_INDUSTRIES(ind) {
 
		indspec = GetIndustrySpec(ind->type);
 
		uint i;
 

	
 
		for (i = 0; i < lengthof(ind->accepts_cargo); i++) {
 
			if (cargo_type == ind->accepts_cargo[i]) break;
 
@@ -1478,13 +1478,13 @@ void VehiclePayment(Vehicle *front_v)
 
static void LoadUnloadVehicle(Vehicle *v, int *cargo_left)
 
{
 
	assert(v->current_order.IsType(OT_LOADING));
 

	
 
	/* We have not waited enough time till the next round of loading/unloading */
 
	if (--v->load_unload_time_rem != 0) {
 
		if (_patches.improved_load && (v->current_order.GetLoadType() & OLFB_FULL_LOAD)) {
 
		if (_settings.order.improved_load && (v->current_order.GetLoadType() & OLFB_FULL_LOAD)) {
 
			/* 'Reserve' this cargo for this vehicle, because we were first. */
 
			for (; v != NULL; v = v->Next()) {
 
				if (v->cargo_cap != 0) cargo_left[v->cargo_type] -= v->cargo_cap - v->cargo.Count();
 
			}
 
		}
 
		return;
 
@@ -1514,22 +1514,22 @@ static void LoadUnloadVehicle(Vehicle *v
 
	v->cur_speed = 0;
 

	
 
	for (; v != NULL; v = v->Next()) {
 
		if (v->cargo_cap == 0) continue;
 

	
 
		byte load_amount = EngInfo(v->engine_type)->load_amount;
 
		if (_patches.gradual_loading && HasBit(EngInfo(v->engine_type)->callbackmask, CBM_VEHICLE_LOAD_AMOUNT)) {
 
		if (_settings.order.gradual_loading && HasBit(EngInfo(v->engine_type)->callbackmask, CBM_VEHICLE_LOAD_AMOUNT)) {
 
			uint16 cb_load_amount = GetVehicleCallback(CBID_VEHICLE_LOAD_AMOUNT, 0, 0, v->engine_type, v);
 
			if (cb_load_amount != CALLBACK_FAILED && GB(cb_load_amount, 0, 8) != 0) load_amount = GB(cb_load_amount, 0, 8);
 
		}
 

	
 
		GoodsEntry *ge = &st->goods[v->cargo_type];
 

	
 
		if (HasBit(v->vehicle_flags, VF_CARGO_UNLOADING) && (u->current_order.GetUnloadType() & OUFB_NO_UNLOAD) == 0) {
 
			uint cargo_count = v->cargo.Count();
 
			uint amount_unloaded = _patches.gradual_loading ? min(cargo_count, load_amount) : cargo_count;
 
			uint amount_unloaded = _settings.order.gradual_loading ? min(cargo_count, load_amount) : cargo_count;
 
			bool remaining; // Are there cargo entities in this vehicle that can still be unloaded here?
 

	
 
			if (HasBit(ge->acceptance_pickup, GoodsEntry::ACCEPTANCE) && !(u->current_order.GetUnloadType() & OUFB_TRANSFER)) {
 
				/* The cargo has reached it's final destination, the packets may now be destroyed */
 
				remaining = v->cargo.MoveTo(NULL, amount_unloaded, CargoList::MTA_FINAL_DELIVERY, last_visited);
 

	
 
@@ -1549,13 +1549,13 @@ static void LoadUnloadVehicle(Vehicle *v
 
			/* Deliver goods to the station */
 
			st->time_since_unload = 0;
 

	
 
			unloading_time += amount_unloaded;
 

	
 
			anything_unloaded = true;
 
			if (_patches.gradual_loading && remaining) {
 
			if (_settings.order.gradual_loading && remaining) {
 
				completely_emptied = false;
 
			} else {
 
				/* We have finished unloading (cargo count == 0) */
 
				ClrBit(v->vehicle_flags, VF_CARGO_UNLOADING);
 
			}
 

	
 
@@ -1583,20 +1583,20 @@ static void LoadUnloadVehicle(Vehicle *v
 
		if (!ge->cargo.Empty() &&
 
				(cap = v->cargo_cap - v->cargo.Count()) != 0) {
 
			uint count = ge->cargo.Count();
 

	
 
			/* Skip loading this vehicle if another train/vehicle is already handling
 
			 * the same cargo type at this station */
 
			if (_patches.improved_load && cargo_left[v->cargo_type] <= 0) {
 
			if (_settings.order.improved_load && cargo_left[v->cargo_type] <= 0) {
 
				SetBit(cargo_not_full, v->cargo_type);
 
				continue;
 
			}
 

	
 
			if (cap > count) cap = count;
 
			if (_patches.gradual_loading) cap = min(cap, load_amount);
 
			if (_patches.improved_load) {
 
			if (_settings.order.gradual_loading) cap = min(cap, load_amount);
 
			if (_settings.order.improved_load) {
 
				/* Don't load stuff that is already 'reserved' for other vehicles */
 
				cap = min((uint)cargo_left[v->cargo_type], cap);
 
				cargo_left[v->cargo_type] -= cap;
 
			}
 

	
 
			if (v->cargo.Empty()) TriggerVehicle(v, VEHICLE_TRIGGER_NEW_CARGO);
 
@@ -1634,23 +1634,23 @@ static void LoadUnloadVehicle(Vehicle *v
 
	completely_emptied &= anything_unloaded;
 

	
 
	/* We update these variables here, so gradual loading still fills
 
	 * all wagons at the same time instead of using the same 'improved'
 
	 * loading algorithm for the wagons (only fill wagon when there is
 
	 * enough to fill the previous wagons) */
 
	if (_patches.improved_load && (u->current_order.GetLoadType() & OLFB_FULL_LOAD)) {
 
	if (_settings.order.improved_load && (u->current_order.GetLoadType() & OLFB_FULL_LOAD)) {
 
		/* Update left cargo */
 
		for (v = u; v != NULL; v = v->Next()) {
 
			if (v->cargo_cap != 0) cargo_left[v->cargo_type] -= v->cargo_cap - v->cargo.Count();
 
		}
 
	}
 

	
 
	v = u;
 

	
 
	if (anything_loaded || anything_unloaded) {
 
		if (_patches.gradual_loading) {
 
		if (_settings.order.gradual_loading) {
 
			/* The time it takes to load one 'slice' of cargo or passengers depends
 
			* on the vehicle type - the values here are those found in TTDPatch */
 
			const uint gradual_loading_wait_time[] = { 40, 20, 10, 20 };
 

	
 
			unloading_time = gradual_loading_wait_time[v->type];
 
		}
 
@@ -1681,17 +1681,17 @@ static void LoadUnloadVehicle(Vehicle *v
 
			unloading_time += (overhang * unloading_time) / 8;
 
		}
 
	}
 

	
 
	/* Calculate the loading indicator fill percent and display
 
	 * In the Game Menu do not display indicators
 
	 * If _patches.loading_indicators == 2, show indicators (bool can be promoted to int as 0 or 1 - results in 2 > 0,1 )
 
	 * if _patches.loading_indicators == 1, _local_player must be the owner or must be a spectator to show ind., so 1 > 0
 
	 * if _patches.loading_indicators == 0, do not display indicators ... 0 is never greater than anything
 
	 * If _settings.gui.loading_indicators == 2, show indicators (bool can be promoted to int as 0 or 1 - results in 2 > 0,1 )
 
	 * if _settings.gui.loading_indicators == 1, _local_player must be the owner or must be a spectator to show ind., so 1 > 0
 
	 * if _settings.gui.loading_indicators == 0, do not display indicators ... 0 is never greater than anything
 
	 */
 
	if (_game_mode != GM_MENU && (_patches.loading_indicators > (uint)(v->owner != _local_player && _local_player != PLAYER_SPECTATOR))) {
 
	if (_game_mode != GM_MENU && (_settings.gui.loading_indicators > (uint)(v->owner != _local_player && _local_player != PLAYER_SPECTATOR))) {
 
		StringID percent_up_down = STR_NULL;
 
		int percent = CalcPercentVehicleFilled(v, &percent_up_down);
 
		if (v->fill_percent_te_id == INVALID_TE_ID) {
 
			v->fill_percent_te_id = ShowFillingPercent(v->x_pos, v->y_pos, v->z_pos + 20, percent, percent_up_down);
 
		} else {
 
			UpdateFillingPercent(v->fill_percent_te_id, percent, percent_up_down);
 
@@ -1733,13 +1733,13 @@ void LoadUnloadStation(Station *st)
 
	}
 
}
 

	
 
void PlayersMonthlyLoop()
 
{
 
	PlayersGenStatistics();
 
	if (_patches.inflation && _cur_year < MAX_YEAR)
 
	if (_settings.economy.inflation && _cur_year < MAX_YEAR)
 
		AddInflation();
 
	PlayersPayInterest();
 
	/* Reset the _current_player flag */
 
	_current_player = OWNER_NONE;
 
	HandleEconomyFluctuations();
 
	SubsidyMonthlyHandler();
 
@@ -1799,13 +1799,13 @@ CommandCost CmdBuyShareInCompany(TileInd
 
{
 
	Player *p;
 
	CommandCost cost(EXPENSES_OTHER);
 

	
 
	/* Check if buying shares is allowed (protection against modified clients) */
 
	/* Cannot buy own shares */
 
	if (!IsValidPlayer((PlayerID)p1) || !_patches.allow_shares || _current_player == (PlayerID)p1) return CMD_ERROR;
 
	if (!IsValidPlayer((PlayerID)p1) || !_settings.economy.allow_shares || _current_player == (PlayerID)p1) return CMD_ERROR;
 

	
 
	p = GetPlayer((PlayerID)p1);
 

	
 
	/* Cannot buy shares of non-existent nor bankrupted company */
 
	if (!p->is_active) return CMD_ERROR;
 

	
 
@@ -1848,13 +1848,13 @@ CommandCost CmdSellShareInCompany(TileIn
 
{
 
	Player *p;
 
	Money cost;
 

	
 
	/* Check if selling shares is allowed (protection against modified clients) */
 
	/* Cannot sell own shares */
 
	if (!IsValidPlayer((PlayerID)p1) || !_patches.allow_shares || _current_player == (PlayerID)p1) return CMD_ERROR;
 
	if (!IsValidPlayer((PlayerID)p1) || !_settings.economy.allow_shares || _current_player == (PlayerID)p1) return CMD_ERROR;
 

	
 
	p = GetPlayer((PlayerID)p1);
 

	
 
	/* Cannot sell shares of non-existent nor bankrupted company */
 
	if (!p->is_active) return CMD_ERROR;
 

	
src/elrail_func.h
Show inline comments
 
@@ -22,21 +22,21 @@ static inline bool HasCatenary(RailType 
 
/**
 
 * Test if we should draw rail catenary
 
 * @param rt Rail type to test
 
 */
 
static inline bool HasCatenaryDrawn(RailType rt)
 
{
 
	return HasCatenary(rt) && !IsInvisibilitySet(TO_CATENARY) && !_patches.disable_elrails;
 
	return HasCatenary(rt) && !IsInvisibilitySet(TO_CATENARY) && !_settings.vehicle.disable_elrails;
 
}
 

	
 
/**
 
 * Draws overhead wires and pylons for electric railways.
 
 * @param ti The TileInfo struct of the tile being drawn
 
 * @see DrawCatenaryRailway
 
 */
 
void DrawCatenary(const TileInfo *ti);
 
void DrawCatenaryOnTunnel(const TileInfo *ti);
 
void DrawCatenaryOnBridge(const TileInfo *ti);
 

	
 
int32 SettingsDisableElrail(int32 p1); ///< _patches.disable_elrail callback
 
int32 SettingsDisableElrail(int32 p1); ///< _settings.disable_elrail callback
 

	
 
#endif /* ELRAIL_FUNC_H */
src/engine.cpp
Show inline comments
 
@@ -214,26 +214,26 @@ void LoadCustomEngineNames()
 

	
 
static void CalcEngineReliability(Engine *e)
 
{
 
	uint age = e->age;
 

	
 
	/* Check for early retirement */
 
	if (e->player_avail != 0 && !_patches.never_expire_vehicles) {
 
	if (e->player_avail != 0 && !_settings.vehicle.never_expire_vehicles) {
 
		int retire_early = e->info.retire_early;
 
		uint retire_early_max_age = max(0, e->duration_phase_1 + e->duration_phase_2 - retire_early * 12);
 
		if (retire_early != 0 && age >= retire_early_max_age) {
 
			/* Early retirement is enabled and we're past the date... */
 
			e->player_avail = 0;
 
			AddRemoveEngineFromAutoreplaceAndBuildWindows(e->type);
 
		}
 
	}
 

	
 
	if (age < e->duration_phase_1) {
 
		uint start = e->reliability_start;
 
		e->reliability = age * (e->reliability_max - start) / e->duration_phase_1 + start;
 
	} else if ((age -= e->duration_phase_1) < e->duration_phase_2 || _patches.never_expire_vehicles) {
 
	} else if ((age -= e->duration_phase_1) < e->duration_phase_2 || _settings.vehicle.never_expire_vehicles) {
 
		/* We are at the peak of this engines life. It will have max reliability.
 
		 * This is also true if the engines never expire. They will not go bad over time */
 
		e->reliability = e->reliability_max;
 
	} else if ((age -= e->duration_phase_2) < e->duration_phase_3) {
 
		uint max = e->reliability_max;
 
		e->reliability = (int)age * (int)(e->reliability_final - max) / e->duration_phase_3 + max;
 
@@ -290,13 +290,13 @@ void StartupEngines()
 
		if (ei->unk2 & 0x80) {
 
			e->age = 0xFFFF;
 
		} else {
 
			CalcEngineReliability(e);
 
		}
 

	
 
		e->lifelength = ei->lifelength + _patches.extend_vehicle_life;
 
		e->lifelength = ei->lifelength + _settings.vehicle.extend_vehicle_life;
 

	
 
		/* prevent certain engines from ever appearing. */
 
		if (!HasBit(ei->climates, _opt.landscape)) {
 
			e->flags |= ENGINE_AVAILABLE;
 
			e->player_avail = 0;
 
		}
src/genworld.cpp
Show inline comments
 
@@ -88,27 +88,27 @@ bool IsGenerateWorldThreaded()
 
static void * CDECL _GenerateWorld(void *arg)
 
{
 
	try {
 
		_generating_world = true;
 
		if (_network_dedicated) DEBUG(net, 0, "Generating map, please wait...");
 
		/* Set the Random() seed to generation_seed so we produce the same map with the same seed */
 
		if (_patches.generation_seed == GENERATE_NEW_SEED) _patches.generation_seed = _patches_newgame.generation_seed = InteractiveRandom();
 
		_random.SetSeed(_patches.generation_seed);
 
		if (_settings.game_creation.generation_seed == GENERATE_NEW_SEED) _settings.game_creation.generation_seed = _settings_newgame.game_creation.generation_seed = InteractiveRandom();
 
		_random.SetSeed(_settings.game_creation.generation_seed);
 
		SetGeneratingWorldProgress(GWP_MAP_INIT, 2);
 
		SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, VHM_NONE, WC_MAIN_WINDOW, 0);
 

	
 
		IncreaseGeneratingWorldProgress(GWP_MAP_INIT);
 
		/* Must start economy early because of the costs. */
 
		StartupEconomy();
 

	
 
		/* Don't generate landscape items when in the scenario editor. */
 
		if (_gw.mode == GW_EMPTY) {
 
			SetGeneratingWorldProgress(GWP_UNMOVABLE, 1);
 

	
 
			/* Make the map the height of the patch setting */
 
			if (_game_mode != GM_MENU) FlatEmptyWorld(_patches.se_flat_world_height);
 
			if (_game_mode != GM_MENU) FlatEmptyWorld(_settings.game_creation.se_flat_world_height);
 

	
 
			ConvertGroundTilesIntoWaterTiles();
 
			IncreaseGeneratingWorldProgress(GWP_UNMOVABLE);
 
		} else {
 
			GenerateLandscape(_gw.mode);
 
			GenerateClearTile();
 
@@ -162,13 +162,13 @@ static void * CDECL _GenerateWorld(void 
 

	
 
		DeleteWindowById(WC_GENERATE_PROGRESS_WINDOW, 0);
 
		MarkWholeScreenDirty();
 

	
 
		if (_network_dedicated) DEBUG(net, 0, "Map generated, starting game");
 

	
 
		if (_patches.pause_on_newgame && _game_mode == GM_NORMAL) DoCommandP(0, 1, 0, NULL, CMD_PAUSE);
 
		if (_settings.gui.pause_on_newgame && _game_mode == GM_NORMAL) DoCommandP(0, 1, 0, NULL, CMD_PAUSE);
 
	} catch (...) {
 
		_generating_world = false;
 
		throw;
 
	}
 
	return NULL;
 
}
 
@@ -270,13 +270,13 @@ void GenerateWorld(int mode, uint size_x
 
	/* This disables some commands and stuff */
 
	SetLocalPlayer(PLAYER_SPECTATOR);
 
	/* Make sure everything is done via OWNER_NONE */
 
	_current_player = OWNER_NONE;
 

	
 
	/* Set the date before loading sprites as some newgrfs check it */
 
	SetDate(ConvertYMDToDate(_patches.starting_year, 0, 1));
 
	SetDate(ConvertYMDToDate(_settings.game_creation.starting_year, 0, 1));
 

	
 
	/* Load the right landscape stuff */
 
	GfxLoadSprites();
 
	LoadStringWidthTable();
 

	
 
	InitializeGame(IG_NONE, _gw.size_x, _gw.size_y);
src/genworld_gui.cpp
Show inline comments
 
@@ -253,13 +253,13 @@ struct GenerateLandscapeWindow : public 
 
	glwp_modes mode;
 

	
 
	GenerateLandscapeWindow(const WindowDesc *desc, WindowNumber number = 0) : QueryStringBaseWindow(desc, number)
 
	{
 
		this->LowerWidget(_opt_newgame.landscape + GLAND_TEMPERATE);
 

	
 
		snprintf(this->edit_str_buf, sizeof(this->edit_str_buf), "%u", _patches_newgame.generation_seed);
 
		snprintf(this->edit_str_buf, sizeof(this->edit_str_buf), "%u", _settings_newgame.game_creation.generation_seed);
 
		InitializeTextBuffer(&this->text, this->edit_str_buf, lengthof(this->edit_str_buf), 120);
 
		this->caption = STR_NULL;
 
		this->afilter = CS_NUMERAL;
 

	
 
		this->mode = (glwp_modes)this->window_number;
 

	
 
@@ -267,25 +267,25 @@ struct GenerateLandscapeWindow : public 
 
	}
 

	
 
	virtual void OnPaint()
 
	{
 
		/* You can't select smoothness if not terragenesis */
 
		if (mode == GLWP_GENERATE) {
 
			this->SetWidgetDisabledState(GLAND_SMOOTHNESS_PULLDOWN, _patches_newgame.land_generator == 0);
 
			this->SetWidgetDisabledState(GLAND_SMOOTHNESS_PULLDOWN, _settings_newgame.game_creation.land_generator == 0);
 
		}
 
		/* Disable snowline if not hilly */
 
		this->SetWidgetDisabledState(GLAND_SNOW_LEVEL_TEXT, _opt_newgame.landscape != LT_ARCTIC);
 
		/* Disable town, industry and trees in SE */
 
		this->SetWidgetDisabledState(GLAND_TOWN_PULLDOWN,     _game_mode == GM_EDITOR);
 
		this->SetWidgetDisabledState(GLAND_INDUSTRY_PULLDOWN, _game_mode == GM_EDITOR);
 
		this->SetWidgetDisabledState(GLAND_TREE_PULLDOWN,     _game_mode == GM_EDITOR);
 

	
 
		this->SetWidgetDisabledState(GLAND_START_DATE_DOWN, _patches_newgame.starting_year <= MIN_YEAR);
 
		this->SetWidgetDisabledState(GLAND_START_DATE_UP,   _patches_newgame.starting_year >= MAX_YEAR);
 
		this->SetWidgetDisabledState(GLAND_SNOW_LEVEL_DOWN, _patches_newgame.snow_line_height <= 2 || _opt_newgame.landscape != LT_ARCTIC);
 
		this->SetWidgetDisabledState(GLAND_SNOW_LEVEL_UP,   _patches_newgame.snow_line_height >= MAX_SNOWLINE_HEIGHT || _opt_newgame.landscape != LT_ARCTIC);
 
		this->SetWidgetDisabledState(GLAND_START_DATE_DOWN, _settings_newgame.game_creation.starting_year <= MIN_YEAR);
 
		this->SetWidgetDisabledState(GLAND_START_DATE_UP,   _settings_newgame.game_creation.starting_year >= MAX_YEAR);
 
		this->SetWidgetDisabledState(GLAND_SNOW_LEVEL_DOWN, _settings_newgame.game_creation.snow_line_height <= 2 || _opt_newgame.landscape != LT_ARCTIC);
 
		this->SetWidgetDisabledState(GLAND_SNOW_LEVEL_UP,   _settings_newgame.game_creation.snow_line_height >= MAX_SNOWLINE_HEIGHT || _opt_newgame.landscape != LT_ARCTIC);
 

	
 
		this->SetWidgetLoweredState(GLAND_TEMPERATE, _opt_newgame.landscape == LT_TEMPERATE);
 
		this->SetWidgetLoweredState(GLAND_ARCTIC,    _opt_newgame.landscape == LT_ARCTIC);
 
		this->SetWidgetLoweredState(GLAND_TROPICAL,  _opt_newgame.landscape == LT_TROPIC);
 
		this->SetWidgetLoweredState(GLAND_TOYLAND,   _opt_newgame.landscape == LT_TOYLAND);
 

	
 
@@ -295,36 +295,36 @@ struct GenerateLandscapeWindow : public 
 
		} else {
 
			this->widget[GLAND_TOWN_PULLDOWN].data     = _num_towns[_opt_newgame.diff.number_towns];
 
			this->widget[GLAND_INDUSTRY_PULLDOWN].data = _num_inds[_opt_newgame.diff.number_industries];
 
		}
 

	
 
		if (mode == GLWP_GENERATE) {
 
			this->widget[GLAND_LANDSCAPE_PULLDOWN].data  = _landscape[_patches_newgame.land_generator];
 
			this->widget[GLAND_TREE_PULLDOWN].data       = _tree_placer[_patches_newgame.tree_placer];
 
			this->widget[GLAND_LANDSCAPE_PULLDOWN].data  = _landscape[_settings_newgame.game_creation.land_generator];
 
			this->widget[GLAND_TREE_PULLDOWN].data       = _tree_placer[_settings_newgame.game_creation.tree_placer];
 
			this->widget[GLAND_TERRAIN_PULLDOWN].data    = _elevations[_opt_newgame.diff.terrain_type];
 
			this->widget[GLAND_WATER_PULLDOWN].data      = _sea_lakes[_opt_newgame.diff.quantity_sea_lakes];
 
			this->widget[GLAND_SMOOTHNESS_PULLDOWN].data = _smoothness[_patches_newgame.tgen_smoothness];
 
			this->widget[GLAND_SMOOTHNESS_PULLDOWN].data = _smoothness[_settings_newgame.game_creation.tgen_smoothness];
 
		} else {
 
			this->widget[GLAND_TREE_PULLDOWN].data               = _tree_placer[_patches_newgame.tree_placer];
 
			this->widget[GLAND_HEIGHTMAP_ROTATION_PULLDOWN].data = _rotation[_patches_newgame.heightmap_rotation];
 
			this->widget[GLAND_TREE_PULLDOWN].data               = _tree_placer[_settings_newgame.game_creation.tree_placer];
 
			this->widget[GLAND_HEIGHTMAP_ROTATION_PULLDOWN].data = _rotation[_settings_newgame.game_creation.heightmap_rotation];
 
		}
 

	
 
		/* Set parameters for widget text that requires them. */
 
		SetDParam(0, ConvertYMDToDate(_patches_newgame.starting_year, 0, 1)); // GLAND_START_DATE_TEXT
 
		SetDParam(1, 1 << _patches_newgame.map_x); // GLAND_MAPSIZE_X_PULLDOWN
 
		SetDParam(2, 1 << _patches_newgame.map_y); // GLAND_MAPSIZE_Y_PULLDOWN
 
		SetDParam(3, _patches_newgame.snow_line_height); // GLAND_SNOW_LEVEL_TEXT
 
		SetDParam(0, ConvertYMDToDate(_settings_newgame.game_creation.starting_year, 0, 1)); // GLAND_START_DATE_TEXT
 
		SetDParam(1, 1 << _settings_newgame.game_creation.map_x); // GLAND_MAPSIZE_X_PULLDOWN
 
		SetDParam(2, 1 << _settings_newgame.game_creation.map_y); // GLAND_MAPSIZE_Y_PULLDOWN
 
		SetDParam(3, _settings_newgame.game_creation.snow_line_height); // GLAND_SNOW_LEVEL_TEXT
 

	
 
		this->DrawWidgets();
 

	
 
		this->DrawEditBox(GLAND_RANDOM_EDITBOX);
 

	
 
		if (mode != GLWP_GENERATE) {
 
			char buffer[512];
 

	
 
			if (_patches_newgame.heightmap_rotation == HM_CLOCKWISE) {
 
			if (_settings_newgame.game_creation.heightmap_rotation == HM_CLOCKWISE) {
 
				SetDParam(0, this->y);
 
				SetDParam(1, this->x);
 
			} else {
 
				SetDParam(0, this->x);
 
				SetDParam(1, this->y);
 
			}
 
@@ -348,52 +348,52 @@ struct GenerateLandscapeWindow : public 
 
			case GLAND_TOYLAND:
 
				this->RaiseWidget(_opt_newgame.landscape + GLAND_TEMPERATE);
 
				SetNewLandscapeType(widget - GLAND_TEMPERATE);
 
				break;
 

	
 
			case GLAND_MAPSIZE_X_PULLDOWN: // Mapsize X
 
				ShowDropDownList(this, BuildMapsizeDropDown(), _patches_newgame.map_x, GLAND_MAPSIZE_X_PULLDOWN);
 
				ShowDropDownList(this, BuildMapsizeDropDown(), _settings_newgame.game_creation.map_x, GLAND_MAPSIZE_X_PULLDOWN);
 
				break;
 

	
 
			case GLAND_MAPSIZE_Y_PULLDOWN: // Mapsize Y
 
				ShowDropDownList(this, BuildMapsizeDropDown(), _patches_newgame.map_y, GLAND_MAPSIZE_Y_PULLDOWN);
 
				ShowDropDownList(this, BuildMapsizeDropDown(), _settings_newgame.game_creation.map_y, GLAND_MAPSIZE_Y_PULLDOWN);
 
				break;
 

	
 
			case GLAND_TOWN_PULLDOWN: // Number of towns
 
				ShowDropDownMenu(this, _num_towns, _opt_newgame.diff.number_towns, GLAND_TOWN_PULLDOWN, 0, 0);
 
				break;
 

	
 
			case GLAND_INDUSTRY_PULLDOWN: // Number of industries
 
				ShowDropDownMenu(this, _num_inds, _opt_newgame.diff.number_industries, GLAND_INDUSTRY_PULLDOWN, 0, 0);
 
				break;
 

	
 
			case GLAND_RANDOM_BUTTON: // Random seed
 
				_patches_newgame.generation_seed = InteractiveRandom();
 
				snprintf(this->edit_str_buf, lengthof(this->edit_str_buf), "%u", _patches_newgame.generation_seed);
 
				_settings_newgame.game_creation.generation_seed = InteractiveRandom();
 
				snprintf(this->edit_str_buf, lengthof(this->edit_str_buf), "%u", _settings_newgame.game_creation.generation_seed);
 
				UpdateTextBufferSize(&this->text);
 
				this->SetDirty();
 
				break;
 

	
 
			case GLAND_RANDOM_EDITBOX: // edit box for random seed
 
				ShowOnScreenKeyboard(this, GLAND_RANDOM_EDITBOX, 0, 0);
 
				break;
 

	
 
			case GLAND_GENERATE_BUTTON: // Generate
 
				UpdatePatches();
 

	
 
				if (_patches.town_layout == TL_NO_ROADS) {
 
				if (_settings.economy.town_layout == TL_NO_ROADS) {
 
					ShowQuery(
 
						STR_TOWN_LAYOUT_WARNING_CAPTION,
 
						STR_TOWN_LAYOUT_WARNING_MESSAGE,
 
						this,
 
						LandscapeGenerationCallback);
 
				} else if (mode == GLWP_HEIGHTMAP &&
 
						(this->x * 2 < (1U << _patches_newgame.map_x) ||
 
						this->x / 2 > (1U << _patches_newgame.map_x) ||
 
						this->y * 2 < (1U << _patches_newgame.map_y) ||
 
						this->y / 2 > (1U << _patches_newgame.map_y))) {
 
						(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))) {
 
					ShowQuery(
 
						STR_HEIGHTMAP_SCALE_WARNING_CAPTION,
 
						STR_HEIGHTMAP_SCALE_WARNING_MESSAGE,
 
						this,
 
						LandscapeGenerationCallback);
 
				} else {
 
@@ -405,64 +405,64 @@ struct GenerateLandscapeWindow : public 
 
			case GLAND_START_DATE_UP: // Year buttons
 
				/* Don't allow too fast scrolling */
 
				if ((this->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
 
					this->HandleButtonClick(widget);
 
					this->SetDirty();
 

	
 
					_patches_newgame.starting_year = Clamp(_patches_newgame.starting_year + widget - GLAND_START_DATE_TEXT, MIN_YEAR, MAX_YEAR);
 
					_settings_newgame.game_creation.starting_year = Clamp(_settings_newgame.game_creation.starting_year + widget - GLAND_START_DATE_TEXT, MIN_YEAR, MAX_YEAR);
 
				}
 
				_left_button_clicked = false;
 
				break;
 

	
 
			case GLAND_START_DATE_TEXT: // Year text
 
				this->widget_id = GLAND_START_DATE_TEXT;
 
				SetDParam(0, _patches_newgame.starting_year);
 
				SetDParam(0, _settings_newgame.game_creation.starting_year);
 
				ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_START_DATE_QUERY_CAPT, 8, 100, this, CS_NUMERAL);
 
				break;
 

	
 
			case GLAND_SNOW_LEVEL_DOWN:
 
			case GLAND_SNOW_LEVEL_UP: // Snow line buttons
 
				/* Don't allow too fast scrolling */
 
				if ((this->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
 
					this->HandleButtonClick(widget);
 
					this->SetDirty();
 

	
 
					_patches_newgame.snow_line_height = Clamp(_patches_newgame.snow_line_height + widget - GLAND_SNOW_LEVEL_TEXT, 2, MAX_SNOWLINE_HEIGHT);
 
					_settings_newgame.game_creation.snow_line_height = Clamp(_settings_newgame.game_creation.snow_line_height + widget - GLAND_SNOW_LEVEL_TEXT, 2, MAX_SNOWLINE_HEIGHT);
 
				}
 
				_left_button_clicked = false;
 
				break;
 

	
 
			case GLAND_SNOW_LEVEL_TEXT: // Snow line text
 
				this->widget_id = GLAND_SNOW_LEVEL_TEXT;
 
				SetDParam(0, _patches_newgame.snow_line_height);
 
				SetDParam(0, _settings_newgame.game_creation.snow_line_height);
 
				ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_SNOW_LINE_QUERY_CAPT, 3, 100, this, CS_NUMERAL);
 
				break;
 

	
 
			case GLAND_TREE_PULLDOWN: // Tree placer
 
				ShowDropDownMenu(this, _tree_placer, _patches_newgame.tree_placer, GLAND_TREE_PULLDOWN, 0, 0);
 
				ShowDropDownMenu(this, _tree_placer, _settings_newgame.game_creation.tree_placer, GLAND_TREE_PULLDOWN, 0, 0);
 
				break;
 

	
 
			case GLAND_LANDSCAPE_PULLDOWN: // Landscape generator OR Heightmap rotation
 
			/* case GLAND_HEIGHTMAP_ROTATION_TEXT: case GLAND_HEIGHTMAP_ROTATION_PULLDOWN:*/
 
				if (mode == GLWP_HEIGHTMAP) {
 
					ShowDropDownMenu(this, _rotation, _patches_newgame.heightmap_rotation, GLAND_HEIGHTMAP_ROTATION_PULLDOWN, 0, 0);
 
					ShowDropDownMenu(this, _rotation, _settings_newgame.game_creation.heightmap_rotation, GLAND_HEIGHTMAP_ROTATION_PULLDOWN, 0, 0);
 
				} else {
 
					ShowDropDownMenu(this, _landscape, _patches_newgame.land_generator, GLAND_LANDSCAPE_PULLDOWN, 0, 0);
 
					ShowDropDownMenu(this, _landscape, _settings_newgame.game_creation.land_generator, GLAND_LANDSCAPE_PULLDOWN, 0, 0);
 
				}
 
				break;
 

	
 
			case GLAND_TERRAIN_PULLDOWN: // Terrain type
 
				ShowDropDownMenu(this, _elevations, _opt_newgame.diff.terrain_type, GLAND_TERRAIN_PULLDOWN, 0, 0);
 
				break;
 

	
 
			case GLAND_WATER_PULLDOWN: // Water quantity
 
				ShowDropDownMenu(this, _sea_lakes, _opt_newgame.diff.quantity_sea_lakes, GLAND_WATER_PULLDOWN, 0, 0);
 
				break;
 

	
 
			case GLAND_SMOOTHNESS_PULLDOWN: // Map smoothness
 
				ShowDropDownMenu(this, _smoothness, _patches_newgame.tgen_smoothness, GLAND_SMOOTHNESS_PULLDOWN, 0, 0);
 
				ShowDropDownMenu(this, _smoothness, _settings_newgame.game_creation.tgen_smoothness, GLAND_SMOOTHNESS_PULLDOWN, 0, 0);
 
				break;
 
		}
 
	}
 

	
 
	virtual void OnMouseLoop()
 
	{
 
@@ -475,23 +475,23 @@ struct GenerateLandscapeWindow : public 
 
		this->HandleEditBoxKey(GLAND_RANDOM_EDITBOX, key, keycode, state);
 
		/* the seed is unsigned, therefore atoi cannot be used.
 
			* As 2^32 - 1 (MAX_UVALUE(uint32)) is a 'magic' value
 
			* (use random seed) it should not be possible to be
 
			* entered into the input field; the generate seed
 
			* button can be used instead. */
 
		_patches_newgame.generation_seed = minu(strtoul(this->edit_str_buf, NULL, sizeof(this->edit_str_buf) - 1), MAX_UVALUE(uint32) - 1);
 
		_settings_newgame.game_creation.generation_seed = minu(strtoul(this->edit_str_buf, NULL, sizeof(this->edit_str_buf) - 1), MAX_UVALUE(uint32) - 1);
 
		return state;
 
	}
 

	
 
	virtual void OnDropdownSelect(int widget, int index)
 
	{
 
		switch (widget) {
 
			case GLAND_MAPSIZE_X_PULLDOWN:  _patches_newgame.map_x = index; break;
 
			case GLAND_MAPSIZE_Y_PULLDOWN:  _patches_newgame.map_y = index; break;
 
			case GLAND_TREE_PULLDOWN:       _patches_newgame.tree_placer = index; break;
 
			case GLAND_SMOOTHNESS_PULLDOWN: _patches_newgame.tgen_smoothness = index;  break;
 
			case GLAND_MAPSIZE_X_PULLDOWN:  _settings_newgame.game_creation.map_x = index; break;
 
			case GLAND_MAPSIZE_Y_PULLDOWN:  _settings_newgame.game_creation.map_y = index; break;
 
			case GLAND_TREE_PULLDOWN:       _settings_newgame.game_creation.tree_placer = index; break;
 
			case GLAND_SMOOTHNESS_PULLDOWN: _settings_newgame.game_creation.tgen_smoothness = index;  break;
 

	
 
			case GLAND_TOWN_PULLDOWN:
 
				_opt_newgame.diff.number_towns = index;
 
				if (_opt_newgame.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0);
 
				DoCommandP(0, 2, _opt_newgame.diff.number_towns, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
 
				break;
 
@@ -502,15 +502,15 @@ struct GenerateLandscapeWindow : public 
 
				DoCommandP(0, 3, _opt_newgame.diff.number_industries, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
 
				break;
 

	
 
			case GLAND_LANDSCAPE_PULLDOWN:
 
			/* case GLAND_HEIGHTMAP_PULLDOWN: */
 
				if (mode == GLWP_HEIGHTMAP) {
 
					_patches_newgame.heightmap_rotation = index;
 
					_settings_newgame.game_creation.heightmap_rotation = index;
 
				} else {
 
					_patches_newgame.land_generator = index;
 
					_settings_newgame.game_creation.land_generator = index;
 
				}
 
				break;
 

	
 
			case GLAND_TERRAIN_PULLDOWN:
 
				_opt_newgame.diff.terrain_type = index;
 
				if (_opt_newgame.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0);
 
@@ -531,18 +531,18 @@ struct GenerateLandscapeWindow : public 
 
		if (!StrEmpty(str)) {
 
			int32 value = atoi(str);
 

	
 
			switch (this->widget_id) {
 
				case GLAND_START_DATE_TEXT:
 
					this->InvalidateWidget(GLAND_START_DATE_TEXT);
 
					_patches_newgame.starting_year = Clamp(value, MIN_YEAR, MAX_YEAR);
 
					_settings_newgame.game_creation.starting_year = Clamp(value, MIN_YEAR, MAX_YEAR);
 
					break;
 

	
 
				case GLAND_SNOW_LEVEL_TEXT:
 
					this->InvalidateWidget(GLAND_SNOW_LEVEL_TEXT);
 
					_patches_newgame.snow_line_height = Clamp(value, 2, MAX_SNOWLINE_HEIGHT);
 
					_settings_newgame.game_creation.snow_line_height = Clamp(value, 2, MAX_SNOWLINE_HEIGHT);
 
					break;
 
			}
 

	
 
			this->SetDirty();
 
		}
 
	}
 
@@ -567,13 +567,13 @@ static void _ShowGenerateLandscape(glwp_
 
	uint x = 0;
 
	uint y = 0;
 

	
 
	DeleteWindowByClass(WC_GENERATE_LANDSCAPE);
 

	
 
	/* Always give a new seed if not editor */
 
	if (_game_mode != GM_EDITOR) _patches_newgame.generation_seed = InteractiveRandom();
 
	if (_game_mode != GM_EDITOR) _settings_newgame.game_creation.generation_seed = InteractiveRandom();
 

	
 
	if (mode == GLWP_HEIGHTMAP) {
 
		/* If the function returns negative, it means there was a problem loading the heightmap */
 
		if (!GetHeightmapDimensions(_file_to_saveload.name, &x, &y)) return;
 
	}
 

	
 
@@ -597,23 +597,23 @@ void ShowHeightmapLoad()
 
{
 
	_ShowGenerateLandscape(GLWP_HEIGHTMAP);
 
}
 

	
 
void StartScenarioEditor()
 
{
 
	if (_patches_newgame.town_layout == TL_NO_ROADS) {
 
		_patches_newgame.town_layout = TL_ORIGINAL;
 
	if (_settings_newgame.economy.town_layout == TL_NO_ROADS) {
 
		_settings_newgame.economy.town_layout = TL_ORIGINAL;
 
	}
 

	
 
	StartGeneratingLandscape(GLWP_SCENARIO);
 
}
 

	
 
void StartNewGameWithoutGUI(uint seed)
 
{
 
	/* GenerateWorld takes care of the possible GENERATE_NEW_SEED value in 'seed' */
 
	_patches_newgame.generation_seed = seed;
 
	_settings_newgame.game_creation.generation_seed = seed;
 

	
 
	StartGeneratingLandscape(GLWP_GENERATE);
 
}
 

	
 
enum CreateScenarioWindowWidgets {
 
	CSCEN_TEMPERATE = 3,
 
@@ -646,27 +646,27 @@ struct CreateScenarioWindow : public Win
 
		this->LowerWidget(_opt_newgame.landscape + CSCEN_TEMPERATE);
 
		this->FindWindowPlacementAndResize(desc);
 
	}
 

	
 
	virtual void OnPaint()
 
	{
 
		this->SetWidgetDisabledState(CSCEN_START_DATE_DOWN,       _patches_newgame.starting_year <= MIN_YEAR);
 
		this->SetWidgetDisabledState(CSCEN_START_DATE_UP,         _patches_newgame.starting_year >= MAX_YEAR);
 
		this->SetWidgetDisabledState(CSCEN_FLAT_LAND_HEIGHT_DOWN, _patches_newgame.se_flat_world_height <= 0);
 
		this->SetWidgetDisabledState(CSCEN_FLAT_LAND_HEIGHT_UP,   _patches_newgame.se_flat_world_height >= MAX_TILE_HEIGHT);
 
		this->SetWidgetDisabledState(CSCEN_START_DATE_DOWN,       _settings_newgame.game_creation.starting_year <= MIN_YEAR);
 
		this->SetWidgetDisabledState(CSCEN_START_DATE_UP,         _settings_newgame.game_creation.starting_year >= MAX_YEAR);
 
		this->SetWidgetDisabledState(CSCEN_FLAT_LAND_HEIGHT_DOWN, _settings_newgame.game_creation.se_flat_world_height <= 0);
 
		this->SetWidgetDisabledState(CSCEN_FLAT_LAND_HEIGHT_UP,   _settings_newgame.game_creation.se_flat_world_height >= MAX_TILE_HEIGHT);
 

	
 
		this->SetWidgetLoweredState(CSCEN_TEMPERATE, _opt_newgame.landscape == LT_TEMPERATE);
 
		this->SetWidgetLoweredState(CSCEN_ARCTIC,    _opt_newgame.landscape == LT_ARCTIC);
 
		this->SetWidgetLoweredState(CSCEN_TROPICAL,  _opt_newgame.landscape == LT_TROPIC);
 
		this->SetWidgetLoweredState(CSCEN_TOYLAND,   _opt_newgame.landscape == LT_TOYLAND);
 

	
 
		/* Set parameters for widget text that requires them */
 
		SetDParam(0, ConvertYMDToDate(_patches_newgame.starting_year, 0, 1)); // CSCEN_START_DATE_TEXT
 
		SetDParam(1, 1 << _patches_newgame.map_x); // CSCEN_MAPSIZE_X_PULLDOWN
 
		SetDParam(2, 1 << _patches_newgame.map_y); // CSCEN_MAPSIZE_Y_PULLDOWN
 
		SetDParam(3, _patches_newgame.se_flat_world_height); // CSCEN_FLAT_LAND_HEIGHT_TEXT
 
		SetDParam(0, ConvertYMDToDate(_settings_newgame.game_creation.starting_year, 0, 1)); // CSCEN_START_DATE_TEXT
 
		SetDParam(1, 1 << _settings_newgame.game_creation.map_x); // CSCEN_MAPSIZE_X_PULLDOWN
 
		SetDParam(2, 1 << _settings_newgame.game_creation.map_y); // CSCEN_MAPSIZE_Y_PULLDOWN
 
		SetDParam(3, _settings_newgame.game_creation.se_flat_world_height); // CSCEN_FLAT_LAND_HEIGHT_TEXT
 

	
 
		this->DrawWidgets();
 
	}
 

	
 
	virtual void OnClick(Point pt, int widget)
 
	{
 
@@ -677,17 +677,17 @@ struct CreateScenarioWindow : public Win
 
			case CSCEN_TOYLAND:
 
				this->RaiseWidget(_opt_newgame.landscape + CSCEN_TEMPERATE);
 
				SetNewLandscapeType(widget - CSCEN_TEMPERATE);
 
				break;
 

	
 
			case CSCEN_MAPSIZE_X_PULLDOWN: // Mapsize X
 
				ShowDropDownList(this, BuildMapsizeDropDown(), _patches_newgame.map_x, CSCEN_MAPSIZE_X_PULLDOWN);
 
				ShowDropDownList(this, BuildMapsizeDropDown(), _settings_newgame.game_creation.map_x, CSCEN_MAPSIZE_X_PULLDOWN);
 
				break;
 

	
 
			case CSCEN_MAPSIZE_Y_PULLDOWN: // Mapsize Y
 
				ShowDropDownList(this, BuildMapsizeDropDown(), _patches_newgame.map_y, CSCEN_MAPSIZE_Y_PULLDOWN);
 
				ShowDropDownList(this, BuildMapsizeDropDown(), _settings_newgame.game_creation.map_y, CSCEN_MAPSIZE_Y_PULLDOWN);
 
				break;
 

	
 
			case CSCEN_EMPTY_WORLD: // Empty world / flat world
 
				StartGeneratingLandscape(GLWP_SCENARIO);
 
				break;
 

	
 
@@ -699,66 +699,66 @@ struct CreateScenarioWindow : public Win
 
			case CSCEN_START_DATE_UP: // Year buttons
 
				/* Don't allow too fast scrolling */
 
				if ((this->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
 
					this->HandleButtonClick(widget);
 
					this->SetDirty();
 

	
 
					_patches_newgame.starting_year = Clamp(_patches_newgame.starting_year + widget - CSCEN_START_DATE_TEXT, MIN_YEAR, MAX_YEAR);
 
					_settings_newgame.game_creation.starting_year = Clamp(_settings_newgame.game_creation.starting_year + widget - CSCEN_START_DATE_TEXT, MIN_YEAR, MAX_YEAR);
 
				}
 
				_left_button_clicked = false;
 
				break;
 

	
 
			case CSCEN_START_DATE_TEXT: // Year text
 
				this->widget_id = CSCEN_START_DATE_TEXT;
 
				SetDParam(0, _patches_newgame.starting_year);
 
				SetDParam(0, _settings_newgame.game_creation.starting_year);
 
				ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_START_DATE_QUERY_CAPT, 8, 100, this, CS_NUMERAL);
 
				break;
 

	
 
			case CSCEN_FLAT_LAND_HEIGHT_DOWN:
 
			case CSCEN_FLAT_LAND_HEIGHT_UP: // Height level buttons
 
				/* Don't allow too fast scrolling */
 
				if ((this->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
 
					this->HandleButtonClick(widget);
 
					this->SetDirty();
 

	
 
					_patches_newgame.se_flat_world_height = Clamp(_patches_newgame.se_flat_world_height + widget - CSCEN_FLAT_LAND_HEIGHT_TEXT, 0, MAX_TILE_HEIGHT);
 
					_settings_newgame.game_creation.se_flat_world_height = Clamp(_settings_newgame.game_creation.se_flat_world_height + widget - CSCEN_FLAT_LAND_HEIGHT_TEXT, 0, MAX_TILE_HEIGHT);
 
				}
 
				_left_button_clicked = false;
 
				break;
 

	
 
			case CSCEN_FLAT_LAND_HEIGHT_TEXT: // Height level text
 
				this->widget_id = CSCEN_FLAT_LAND_HEIGHT_TEXT;
 
				SetDParam(0, _patches_newgame.se_flat_world_height);
 
				SetDParam(0, _settings_newgame.game_creation.se_flat_world_height);
 
				ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_FLAT_WORLD_HEIGHT_QUERY_CAPT, 3, 100, this, CS_NUMERAL);
 
				break;
 
		}
 
	}
 

	
 
	virtual void OnDropdownSelect(int widget, int index)
 
	{
 
		switch (widget) {
 
			case CSCEN_MAPSIZE_X_PULLDOWN: _patches_newgame.map_x = index; break;
 
			case CSCEN_MAPSIZE_Y_PULLDOWN: _patches_newgame.map_y = index; break;
 
			case CSCEN_MAPSIZE_X_PULLDOWN: _settings_newgame.game_creation.map_x = index; break;
 
			case CSCEN_MAPSIZE_Y_PULLDOWN: _settings_newgame.game_creation.map_y = index; break;
 
		}
 
		this->SetDirty();
 
	}
 

	
 
	virtual void OnQueryTextFinished(char *str)
 
	{
 
		if (!StrEmpty(str)) {
 
			int32 value = atoi(str);
 

	
 
			switch (this->widget_id) {
 
				case CSCEN_START_DATE_TEXT:
 
					this->InvalidateWidget(CSCEN_START_DATE_TEXT);
 
					_patches_newgame.starting_year = Clamp(value, MIN_YEAR, MAX_YEAR);
 
					_settings_newgame.game_creation.starting_year = Clamp(value, MIN_YEAR, MAX_YEAR);
 
					break;
 

	
 
				case CSCEN_FLAT_LAND_HEIGHT_TEXT:
 
					this->InvalidateWidget(CSCEN_FLAT_LAND_HEIGHT_TEXT);
 
					_patches_newgame.se_flat_world_height = Clamp(value, 0, MAX_TILE_HEIGHT);
 
					_settings_newgame.game_creation.se_flat_world_height = Clamp(value, 0, MAX_TILE_HEIGHT);
 
					break;
 
			}
 

	
 
			this->SetDirty();
 
		}
 
	}
src/heightmap.cpp
Show inline comments
 
@@ -294,13 +294,13 @@ static void GrayscaleToMapHeights(uint i
 
	uint row_pad = 0, col_pad = 0;
 
	uint img_scale;
 
	uint img_row, img_col;
 
	TileIndex tile;
 

	
 
	/* Get map size and calculate scale and padding values */
 
	switch (_patches.heightmap_rotation) {
 
	switch (_settings.game_creation.heightmap_rotation) {
 
		default: NOT_REACHED();
 
		case HM_COUNTER_CLOCKWISE:
 
			width   = MapSizeX();
 
			height  = MapSizeY();
 
			break;
 
		case HM_CLOCKWISE:
 
@@ -319,13 +319,13 @@ static void GrayscaleToMapHeights(uint i
 
		col_pad = (1 + width - ((img_width * img_scale) / num_div)) / 2;
 
	}
 

	
 
	/* Form the landscape */
 
	for (row = 0; row < height - 1; row++) {
 
		for (col = 0; col < width - 1; col++) {
 
			switch (_patches.heightmap_rotation) {
 
			switch (_settings.game_creation.heightmap_rotation) {
 
				default: NOT_REACHED();
 
				case HM_COUNTER_CLOCKWISE: tile = TileXY(col, row); break;
 
				case HM_CLOCKWISE:         tile = TileXY(row, col); break;
 
			}
 

	
 
			/* Check if current tile is within the 1-pixel map edge or padding regions */
 
@@ -334,13 +334,13 @@ static void GrayscaleToMapHeights(uint i
 
					(col < col_pad) || (col >= (width  - col_pad - 1))) {
 
				SetTileHeight(tile, 0);
 
			} else {
 
				/* Use nearest neighbor resizing to scale map data.
 
				 *  We rotate the map 45 degrees (counter)clockwise */
 
				img_row = (((row - row_pad) * num_div) / img_scale);
 
				switch (_patches.heightmap_rotation) {
 
				switch (_settings.game_creation.heightmap_rotation) {
 
					default: NOT_REACHED();
 
					case HM_COUNTER_CLOCKWISE:
 
						img_col = (((width - 1 - col - col_pad) * num_div) / img_scale);
 
						break;
 
					case HM_CLOCKWISE:
 
						img_col = (((col - col_pad) * num_div) / img_scale);
src/industry_cmd.cpp
Show inline comments
 
@@ -1072,25 +1072,25 @@ static bool CheckNewIndustry_Forest(Tile
 
	return true;
 
}
 

	
 
static bool CheckNewIndustry_OilRefinery(TileIndex tile)
 
{
 
	if (_game_mode == GM_EDITOR) return true;
 
	if (DistanceFromEdge(TILE_ADDXY(tile, 1, 1)) < _patches.oil_refinery_limit) return true;
 
	if (DistanceFromEdge(TILE_ADDXY(tile, 1, 1)) < _settings.game_creation.oil_refinery_limit) return true;
 

	
 
	_error_message = STR_483B_CAN_ONLY_BE_POSITIONED;
 
	return false;
 
}
 

	
 
extern bool _ignore_restrictions;
 

	
 
static bool CheckNewIndustry_OilRig(TileIndex tile)
 
{
 
	if (_game_mode == GM_EDITOR && _ignore_restrictions) return true;
 
	if (TileHeight(tile) == 0 &&
 
			DistanceFromEdge(TILE_ADDXY(tile, 1, 1)) < _patches.oil_refinery_limit) return true;
 
			DistanceFromEdge(TILE_ADDXY(tile, 1, 1)) < _settings.game_creation.oil_refinery_limit) return true;
 

	
 
	_error_message = STR_483B_CAN_ONLY_BE_POSITIONED;
 
	return false;
 
}
 

	
 
static bool CheckNewIndustry_Farm(TileIndex tile)
 
@@ -1168,13 +1168,13 @@ static const Town *CheckMultipleIndustry
 
{
 
	const Town *t;
 
	const Industry *i;
 

	
 
	t = ClosestTownFromTile(tile, (uint)-1);
 

	
 
	if (_patches.multiple_industry_per_town) return t;
 
	if (_settings.economy.multiple_industry_per_town) return t;
 

	
 
	FOR_ALL_INDUSTRIES(i) {
 
		if (i->type == (byte)type &&
 
				i->town == t) {
 
			_error_message = STR_0287_ONLY_ONE_ALLOWED_PER_TOWN;
 
			return NULL;
 
@@ -1254,13 +1254,13 @@ static bool CheckIfIndustryTilesAreFree(
 

	
 
	if (custom_shape_check != NULL) *custom_shape_check = custom_shape;
 

	
 
	/* It is almost impossible to have a fully flat land in TG, so what we
 
	 *  do is that we check if we can make the land flat later on. See
 
	 *  CheckIfCanLevelIndustryPlatform(). */
 
	return !refused_slope || (_patches.land_generator == LG_TERRAGENESIS && _generating_world && !custom_shape && !_ignore_restrictions);
 
	return !refused_slope || (_settings.game_creation.land_generator == LG_TERRAGENESIS && _generating_world && !custom_shape && !_ignore_restrictions);
 
}
 

	
 
static bool CheckIfIndustryIsAllowed(TileIndex tile, int type, const Town *t)
 
{
 
	if ((GetIndustrySpec(type)->behaviour & INDUSTRYBEH_TOWN1200_MORE) && t->population < 1200) {
 
		_error_message = STR_029D_CAN_ONLY_BE_BUILT_IN_TOWNS;
 
@@ -1384,13 +1384,13 @@ static bool CheckIfCanLevelIndustryPlatf
 

	
 
static bool CheckIfFarEnoughFromIndustry(TileIndex tile, int type)
 
{
 
	const IndustrySpec *indspec = GetIndustrySpec(type);
 
	const Industry *i;
 

	
 
	if (_patches.same_industry_close && indspec->IsRawIndustry())
 
	if (_settings.economy.same_industry_close && indspec->IsRawIndustry())
 
		/* Allow primary industries to be placed close to any other industry */
 
		return true;
 

	
 
	FOR_ALL_INDUSTRIES(i) {
 
		/* Within 14 tiles from another industry is considered close */
 
		bool in_low_distance = DistanceMax(tile, i->xy) <= 14;
 
@@ -1398,14 +1398,14 @@ static bool CheckIfFarEnoughFromIndustry
 
		/* check if an industry that accepts the same goods is nearby */
 
		if (in_low_distance &&
 
				!indspec->IsRawIndustry() && // not a primary industry?
 
				indspec->accepts_cargo[0] == i->accepts_cargo[0] && (
 
				/* at least one of those options must be true */
 
				_game_mode != GM_EDITOR || // editor must not be stopped
 
				!_patches.same_industry_close ||
 
				!_patches.multiple_industry_per_town)) {
 
				!_settings.economy.same_industry_close ||
 
				!_settings.economy.multiple_industry_per_town)) {
 
			_error_message = STR_INDUSTRY_TOO_CLOSE;
 
			return false;
 
		}
 

	
 
		/* check if there are any conflicting industry types around */
 
		if ((i->type == indspec->conflicting[0] ||
 
@@ -1446,13 +1446,13 @@ static void DoCreateNewIndustry(Industry
 
	i->accepts_cargo[1] = indspec->accepts_cargo[1];
 
	i->accepts_cargo[2] = indspec->accepts_cargo[2];
 
	i->production_rate[0] = indspec->production_rate[0];
 
	i->production_rate[1] = indspec->production_rate[1];
 

	
 
	/* don't use smooth economy for industries using production related callbacks */
 
	if (_patches.smooth_economy &&
 
	if (_settings.economy.smooth_economy &&
 
	    !(HasBit(indspec->callback_flags, CBM_IND_PRODUCTION_256_TICKS) || HasBit(indspec->callback_flags, CBM_IND_PRODUCTION_CARGO_ARRIVAL)) && // production callbacks
 
	    !(HasBit(indspec->callback_flags, CBM_IND_MONTHLYPROD_CHANGE) || HasBit(indspec->callback_flags, CBM_IND_PRODUCTION_CHANGE))             // production change callbacks
 
	) {
 
		i->production_rate[0] = min((RandomRange(256) + 128) * i->production_rate[0] >> 8 , 255);
 
		i->production_rate[1] = min((RandomRange(256) + 128) * i->production_rate[1] >> 8 , 255);
 
	}
 
@@ -1574,13 +1574,13 @@ static Industry *CreateNewIndustryHelper
 
	if (HasBit(GetIndustrySpec(type)->callback_flags, CBM_IND_LOCATION)) {
 
		if (!CheckIfCallBackAllowsCreation(tile, type, itspec_index, seed)) return NULL;
 
	} else {
 
		if (!_check_new_industry_procs[indspec->check_proc](tile)) return NULL;
 
	}
 

	
 
	if (!custom_shape_check && _patches.land_generator == LG_TERRAGENESIS && _generating_world && !_ignore_restrictions && !CheckIfCanLevelIndustryPlatform(tile, 0, it, type)) return NULL;
 
	if (!custom_shape_check && _settings.game_creation.land_generator == LG_TERRAGENESIS && _generating_world && !_ignore_restrictions && !CheckIfCanLevelIndustryPlatform(tile, 0, it, type)) return NULL;
 
	if (!CheckIfFarEnoughFromIndustry(tile, type)) return NULL;
 

	
 
	const Town *t = CheckMultipleIndustryInTown(tile, type);
 
	if (t == NULL) return NULL;
 

	
 
	if (!CheckIfIndustryIsAllowed(tile, type, t)) return NULL;
 
@@ -1618,17 +1618,17 @@ CommandCost CmdBuildIndustry(TileIndex t
 
	if (!indspec->enabled) {
 
		return CMD_ERROR;
 
	}
 

	
 
	/* If the patch for raw-material industries is not on, you cannot build raw-material industries.
 
	 * Raw material industries are industries that do not accept cargo (at least for now) */
 
	if (_game_mode != GM_EDITOR && _patches.raw_industry_construction == 0 && indspec->IsRawIndustry()) {
 
	if (_game_mode != GM_EDITOR && _settings.construction.raw_industry_construction == 0 && indspec->IsRawIndustry()) {
 
		return CMD_ERROR;
 
	}
 

	
 
	if (_game_mode != GM_EDITOR && _patches.raw_industry_construction == 2 && indspec->IsRawIndustry()) {
 
	if (_game_mode != GM_EDITOR && _settings.construction.raw_industry_construction == 2 && indspec->IsRawIndustry()) {
 
		if (flags & DC_EXEC) {
 
			/* Prospecting has a chance to fail, however we cannot guarantee that something can
 
			 * be built on the map, so the chance gets lower when the map is fuller, but there
 
			 * is nothing we can really do about that. */
 
			if (Random() <= indspec->prospecting_chance) {
 
				for (int i = 0; i < 5000; i++) {
 
@@ -2028,13 +2028,13 @@ static void ChangeIndustryProduction(Ind
 
	StringID str = STR_NULL;
 
	bool closeit = false;
 
	const IndustrySpec *indspec = GetIndustrySpec(i->type);
 
	bool standard = true;
 
	bool suppress_message = false;
 
	/* don't use smooth economy for industries using production related callbacks */
 
	bool smooth_economy = _patches.smooth_economy &&
 
	bool smooth_economy = _settings.economy.smooth_economy &&
 
	                      !(HasBit(indspec->callback_flags, CBM_IND_PRODUCTION_256_TICKS) || HasBit(indspec->callback_flags, CBM_IND_PRODUCTION_CARGO_ARRIVAL)) && // production callbacks
 
	                      !(HasBit(indspec->callback_flags, CBM_IND_MONTHLYPROD_CHANGE) || HasBit(indspec->callback_flags, CBM_IND_PRODUCTION_CHANGE));            // production change callbacks
 
	byte div = 0;
 
	byte mul = 0;
 
	int8 increment = 0;
 

	
 
@@ -2254,13 +2254,13 @@ bool IndustrySpec::IsRawIndustry() const
 
			(this->behaviour & INDUSTRYBEH_CUT_TREES) == 0;
 
}
 

	
 
Money IndustrySpec::GetConstructionCost() const
 
{
 
	return (_price.build_industry *
 
			(_patches.raw_industry_construction == 1 && this->IsRawIndustry() ?
 
			(_settings.construction.raw_industry_construction == 1 && this->IsRawIndustry() ?
 
					this->raw_industry_cost_multiplier :
 
					this->cost_multiplier
 
			)) >> 8;
 
}
 

	
 
Money IndustrySpec::GetRemovalCost() const
src/industry_gui.cpp
Show inline comments
 
@@ -128,13 +128,13 @@ class BuildIndustryWindow : public Windo
 
		for (ind = 0; ind < NUM_INDUSTRYTYPES; ind++) {
 
			indsp = GetIndustrySpec(ind);
 
			if (indsp->enabled){
 
				/* Rule is that editor mode loads all industries.
 
				 * In game mode, all non raw industries are loaded too
 
				 * and raw ones are loaded only when setting allows it */
 
				if (_game_mode != GM_EDITOR && indsp->IsRawIndustry() && _patches.raw_industry_construction == 0) {
 
				if (_game_mode != GM_EDITOR && indsp->IsRawIndustry() && _settings.construction.raw_industry_construction == 0) {
 
					/* Unselect if the industry is no longer in the list */
 
					if (this->selected_type == ind) this->selected_index = -1;
 
					continue;
 
				}
 
				this->index[this->count] = ind;
 
				this->enabled[this->count] = (_game_mode == GM_EDITOR) || CheckIfCallBackAllowsAvailability(ind, IACT_USERCREATION);
 
@@ -195,13 +195,13 @@ public:
 
		 * In Editor, you just build, while ingame, or you fund or you prospect */
 
		if (_game_mode == GM_EDITOR) {
 
			/* We've chosen many random industries but no industries have been specified */
 
			if (indsp == NULL) this->enabled[this->selected_index] = _opt.diff.number_industries != 0;
 
			this->widget[DPIW_FUND_WIDGET].data = STR_BUILD_NEW_INDUSTRY;
 
		} else {
 
			this->widget[DPIW_FUND_WIDGET].data = (_patches.raw_industry_construction == 2 && indsp->IsRawIndustry()) ? STR_PROSPECT_NEW_INDUSTRY : STR_FUND_NEW_INDUSTRY;
 
			this->widget[DPIW_FUND_WIDGET].data = (_settings.construction.raw_industry_construction == 2 && indsp->IsRawIndustry()) ? STR_PROSPECT_NEW_INDUSTRY : STR_FUND_NEW_INDUSTRY;
 
		}
 
		this->SetWidgetDisabledState(DPIW_FUND_WIDGET, !this->enabled[this->selected_index]);
 

	
 
		SetVScrollCount(this, this->count);
 

	
 
		this->DrawWidgets();
 
@@ -301,13 +301,13 @@ public:
 
					this->selected_index = y;
 
					this->selected_type = this->index[y];
 
					indsp = (this->selected_type == INVALID_INDUSTRYTYPE) ? NULL : GetIndustrySpec(this->selected_type);
 

	
 
					this->SetDirty();
 

	
 
					if ((_game_mode != GM_EDITOR && _patches.raw_industry_construction == 2 && indsp != NULL && indsp->IsRawIndustry()) ||
 
					if ((_game_mode != GM_EDITOR && _settings.construction.raw_industry_construction == 2 && indsp != NULL && indsp->IsRawIndustry()) ||
 
							this->selected_type == INVALID_INDUSTRYTYPE) {
 
						/* Reset the button state if going to prospecting or "build many industries" */
 
						this->RaiseButtons();
 
						ResetObjectToPlace();
 
					}
 
				}
 
@@ -322,13 +322,13 @@ public:
 
					} else {
 
						extern void GenerateIndustries();
 
						_generating_world = true;
 
						GenerateIndustries();
 
						_generating_world = false;
 
					}
 
				} else if (_game_mode != GM_EDITOR && _patches.raw_industry_construction == 2 && GetIndustrySpec(this->selected_type)->IsRawIndustry()) {
 
				} else if (_game_mode != GM_EDITOR && _settings.construction.raw_industry_construction == 2 && GetIndustrySpec(this->selected_type)->IsRawIndustry()) {
 
					DoCommandP(0, this->selected_type, InteractiveRandom(), NULL, CMD_BUILD_INDUSTRY | CMD_MSG(STR_4830_CAN_T_CONSTRUCT_THIS_INDUSTRY));
 
					this->HandleButtonClick(DPIW_FUND_WIDGET);
 
				} else {
 
					HandlePlacePushButton(this, DPIW_FUND_WIDGET, SPR_CURSOR_INDUSTRY, VHM_RECT, NULL);
 
				}
 
			} break;
src/landscape.cpp
Show inline comments
 
@@ -818,13 +818,13 @@ void GenerateLandscape(byte mode)
 
	static const int gwp_desert_amount = 4 + 8;
 

	
 
	if (mode == GW_HEIGHTMAP) {
 
		SetGeneratingWorldProgress(GWP_LANDSCAPE, (_opt.landscape == LT_TROPIC) ? 1 + gwp_desert_amount : 1);
 
		LoadHeightmap(_file_to_saveload.name);
 
		IncreaseGeneratingWorldProgress(GWP_LANDSCAPE);
 
	} else if (_patches.land_generator == LG_TERRAGENESIS) {
 
	} else if (_settings.game_creation.land_generator == LG_TERRAGENESIS) {
 
		SetGeneratingWorldProgress(GWP_LANDSCAPE, (_opt.landscape == LT_TROPIC) ? 3 + gwp_desert_amount : 3);
 
		GenerateTerrainPerlin();
 
	} else {
 
		switch (_opt.landscape) {
 
			case LT_ARCTIC: {
 
				SetGeneratingWorldProgress(GWP_LANDSCAPE, 2);
src/main_gui.cpp
Show inline comments
 
@@ -45,13 +45,13 @@
 
static int _rename_id = 1;
 
static int _rename_what = -1;
 

	
 
void CcGiveMoney(bool success, TileIndex tile, uint32 p1, uint32 p2)
 
{
 
#ifdef ENABLE_NETWORK
 
	if (!success || !_patches.give_money) return;
 
	if (!success || !_settings.economy.give_money) return;
 

	
 
	char msg[20];
 
	/* Inform the player of this action */
 
	snprintf(msg, sizeof(msg), "%d", p1);
 

	
 
	if (!_network_server) {
 
@@ -341,13 +341,13 @@ struct MainWindow : Window
 
					const NetworkClientInfo *cio = NetworkFindClientInfoFromIndex(_network_own_client_index);
 
					bool teamchat = false;
 

	
 
					if (cio == NULL) break;
 

	
 
					/* Only players actually playing can speak to team. Eg spectators cannot */
 
					if (_patches.prefer_teamchat && IsValidPlayer(cio->client_playas)) {
 
					if (_settings.gui.prefer_teamchat && IsValidPlayer(cio->client_playas)) {
 
						const NetworkClientInfo *ci;
 
						FOR_ALL_ACTIVE_CLIENT_INFOS(ci) {
 
							if (ci->client_playas == cio->client_playas && ci != cio) {
 
								teamchat = true;
 
								break;
 
							}
src/misc.cpp
Show inline comments
 
@@ -66,13 +66,13 @@ void InitializeGame(int mode, uint size_
 
	_tick_counter = 0;
 
	_realtime_tick = 0;
 
	_date_fract = 0;
 
	_cur_tileloop_tile = 0;
 

	
 
	if ((mode & IG_DATE_RESET) == IG_DATE_RESET) {
 
		SetDate(ConvertYMDToDate(_patches.starting_year, 0, 1));
 
		SetDate(ConvertYMDToDate(_settings.game_creation.starting_year, 0, 1));
 
		InitializeOldNames();
 
	}
 

	
 
	InitializeEngines();
 
	InitializeVehicles();
 
	InitializeWaypoints();
src/misc_cmd.cpp
Show inline comments
 
@@ -143,13 +143,13 @@ CommandCost CmdIncreaseLoan(TileIndex ti
 
	}
 

	
 
	Money loan;
 
	switch (p2) {
 
		default: return CMD_ERROR; // Invalid method
 
		case 0: // Take some extra loan
 
			loan = (IsHumanPlayer(_current_player) || _patches.ainew_active) ? LOAN_INTERVAL : LOAN_INTERVAL_OLD_AI;
 
			loan = (IsHumanPlayer(_current_player) || _settings.ai.ainew_active) ? LOAN_INTERVAL : LOAN_INTERVAL_OLD_AI;
 
			break;
 
		case 1: // Take a loan as big as possible
 
			loan = _economy.max_loan - p->current_loan;
 
			break;
 
	}
 

	
 
@@ -179,13 +179,13 @@ CommandCost CmdDecreaseLoan(TileIndex ti
 
	if (p->current_loan == 0) return_cmd_error(STR_702D_LOAN_ALREADY_REPAYED);
 

	
 
	Money loan;
 
	switch (p2) {
 
		default: return CMD_ERROR; // Invalid method
 
		case 0: // Pay back one step
 
			loan = min(p->current_loan, (Money)(IsHumanPlayer(_current_player) || _patches.ainew_active) ? LOAN_INTERVAL : LOAN_INTERVAL_OLD_AI);
 
			loan = min(p->current_loan, (Money)(IsHumanPlayer(_current_player) || _settings.ai.ainew_active) ? LOAN_INTERVAL : LOAN_INTERVAL_OLD_AI);
 
			break;
 
		case 1: // Pay back as much as possible
 
			loan = max(min(p->current_loan, p->player_money), (Money)LOAN_INTERVAL);
 
			loan -= loan % LOAN_INTERVAL;
 
			break;
 
	}
 
@@ -357,13 +357,13 @@ CommandCost CmdMoneyCheat(TileIndex tile
 
 * @param flags operation to perform
 
 * @param p1 the amount of money to transfer; max 20.000.000
 
 * @param p2 the player to transfer the money to
 
 */
 
CommandCost CmdGiveMoney(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	if (!_patches.give_money) return CMD_ERROR;
 
	if (!_settings.economy.give_money) return CMD_ERROR;
 

	
 
	const Player *p = GetPlayer(_current_player);
 
	CommandCost amount(EXPENSES_OTHER, min((Money)p1, (Money)20000000LL));
 

	
 
	/* You can only transfer funds that is in excess of your loan */
 
	if (p->player_money - p->current_loan < amount.GetCost() || amount.GetCost() <= 0) return CMD_ERROR;
 
@@ -406,13 +406,13 @@ CommandCost CmdChangeDifficultyLevel(Til
 
		}
 

	
 
		/* Since the tolerance of the town council has a direct impact on the noise generation/tolerance,
 
		 * launch a re-evaluation of the actual values only when setting has changed */
 
		if (p2 == GAME_DIFFICULTY_TOWNCOUNCIL_TOLERANCE && _game_mode == GM_NORMAL) {
 
			UpdateAirportsNoise();
 
			if (_patches.station_noise_level) {
 
			if (_settings.economy.station_noise_level) {
 
				InvalidateWindowClassesData(WC_TOWN_VIEW, 0);
 
			}
 
		}
 

	
 
		/* If we are a network-client, update the difficult setting (if it is open).
 
		 * Use this instead of just dirtying the window because we need to load in
src/misc_gui.cpp
Show inline comments
 
@@ -99,13 +99,13 @@ public:
 

	
 
		if (!StrEmpty(this->landinfo_data[LAND_INFO_MULTICENTER_LINE])) DrawStringMultiCenter(140, y, BindCString(this->landinfo_data[LAND_INFO_MULTICENTER_LINE]), this->width - 4);
 
	}
 

	
 
	LandInfoWindow(TileIndex tile) : Window(&_land_info_desc) {
 
		Player *p = GetPlayer(IsValidPlayer(_local_player) ? _local_player : PLAYER_FIRST);
 
		Town *t = ClosestTownFromTile(tile, _patches.dist_local_authority);
 
		Town *t = ClosestTownFromTile(tile, _settings.economy.dist_local_authority);
 

	
 
		Money old_money = p->player_money;
 
		p->player_money = INT64_MAX;
 
		CommandCost costclear = DoCommand(tile, 0, 0, 0, CMD_LANDSCAPE_CLEAR);
 
		p->player_money = old_money;
 

	
 
@@ -393,13 +393,13 @@ private:
 

	
 
public:
 
	ErrmsgWindow(Point pt, int width, int height, StringID msg1, StringID msg2, const Widget *widget, bool show_player_face) :
 
			Window(pt.x, pt.y, width, height, WC_ERRMSG, widget),
 
			show_player_face(show_player_face)
 
	{
 
		this->duration = _patches.errmsg_duration;
 
		this->duration = _settings.gui.errmsg_duration;
 
		CopyOutDParam(this->decode_params, 0, lengthof(this->decode_params));
 
		this->message_1 = msg1;
 
		this->message_2 = msg2;
 
		this->desc_flags = WDF_STD_BTN | WDF_DEF_WIDGET;
 
		this->FindWindowPlacementAndResize(width, height);
 
	}
 
@@ -462,13 +462,13 @@ public:
 
};
 

	
 
void ShowErrorMessage(StringID msg_1, StringID msg_2, int x, int y)
 
{
 
	DeleteWindowById(WC_ERRMSG, 0);
 

	
 
	if (!_patches.errmsg_duration) return;
 
	if (!_settings.gui.errmsg_duration) return;
 

	
 
	if (msg_2 == STR_NULL) msg_2 = STR_EMPTY;
 

	
 
	Point pt;
 
	const ViewPort *vp;
 

	
 
@@ -617,13 +617,13 @@ struct TooltipsWindow : public Window
 
 * added to a tooltip; currently only supports parameters of {NUM} (integer) */
 
void GuiShowTooltipsWithArgs(StringID str, uint paramcount, const uint64 params[])
 
{
 
	DeleteWindowById(WC_TOOLTIPS, 0);
 

	
 
	/* We only show measurement tooltips with patch setting on */
 
	if (str == STR_NULL || (paramcount != 0 && !_patches.measure_tooltip)) return;
 
	if (str == STR_NULL || (paramcount != 0 && !_settings.gui.measure_tooltip)) return;
 

	
 
	for (uint i = 0; i != paramcount; i++) SetDParam(i, params[i]);
 
	char buffer[512];
 
	GetString(buffer, str, lastof(buffer));
 

	
 
	Dimension br = GetStringBoundingBox(buffer);
src/network/network.cpp
Show inline comments
 
@@ -1006,13 +1006,13 @@ static void NetworkInitGameInfo()
 
		_network_game_info.dedicated = false;
 
	}
 

	
 
	_network_game_info.spectators_on = 0;
 

	
 
	_network_game_info.game_date = _date;
 
	_network_game_info.start_date = ConvertYMDToDate(_patches.starting_year, 0, 1);
 
	_network_game_info.start_date = ConvertYMDToDate(_settings.game_creation.starting_year, 0, 1);
 
	_network_game_info.map_width = MapSizeX();
 
	_network_game_info.map_height = MapSizeY();
 
	_network_game_info.map_set = _opt.landscape;
 

	
 
	_network_game_info.use_password = (_network_server_password[0] != '\0');
 

	
src/network/network_client.cpp
Show inline comments
 
@@ -80,13 +80,13 @@ static const char *GenerateCompanyPasswo
 
 * Hash the current company password; used when the server 'player' sets his/her password.
 
 */
 
void HashCurrentCompanyPassword()
 
{
 
	if (StrEmpty(_network_player_info[_local_player].password)) return;
 

	
 
	_password_game_seed = _patches.generation_seed;
 
	_password_game_seed = _settings.game_creation.generation_seed;
 
	ttd_strlcpy(_password_server_unique_id, _network_unique_id, sizeof(_password_server_unique_id));
 

	
 
	const char *new_pw = GenerateCompanyPasswordHash(_network_player_info[_local_player].password);
 
	ttd_strlcpy(_network_player_info[_local_player].password, new_pw, sizeof(_network_player_info[_local_player].password));
 
}
 

	
src/network/network_gui.cpp
Show inline comments
 
@@ -1339,13 +1339,13 @@ struct NetworkClientListPopupWindow : Wi
 
		}
 
		GetString(this->action[i], STR_NETWORK_CLIENTLIST_SPEAK_TO_ALL, lastof(this->action[i]));
 
		this->proc[i++] = &ClientList_SpeakToAll;
 

	
 
		if (_network_own_client_index != ci->client_index) {
 
			/* We are no spectator and the player we want to give money to is no spectator and money gifts are allowed */
 
			if (IsValidPlayer(_network_playas) && IsValidPlayer(ci->client_playas) && _patches.give_money) {
 
			if (IsValidPlayer(_network_playas) && IsValidPlayer(ci->client_playas) && _settings.economy.give_money) {
 
				GetString(this->action[i], STR_NETWORK_CLIENTLIST_GIVE_MONEY, lastof(this->action[i]));
 
				this->proc[i++] = &ClientList_GiveMoney;
 
			}
 
		}
 

	
 
		/* A server can kick clients (but not himself) */
src/network/network_server.cpp
Show inline comments
 
@@ -226,13 +226,13 @@ DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SER
 
	if (cs->status >= STATUS_AUTH) return;
 

	
 
	cs->status = STATUS_AUTHORIZING;
 

	
 
	Packet *p = NetworkSend_Init(PACKET_SERVER_NEED_PASSWORD);
 
	p->Send_uint8(type);
 
	p->Send_uint32(_patches.generation_seed);
 
	p->Send_uint32(_settings.game_creation.generation_seed);
 
	p->Send_string(_network_unique_id);
 
	cs->Send_Packet(p);
 
}
 

	
 
DEF_SERVER_SEND_COMMAND(PACKET_SERVER_WELCOME)
 
{
 
@@ -251,13 +251,13 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_WE
 

	
 
	cs->status = STATUS_AUTH;
 
	_network_game_info.clients_on++;
 

	
 
	p = NetworkSend_Init(PACKET_SERVER_WELCOME);
 
	p->Send_uint16(cs->index);
 
	p->Send_uint32(_patches.generation_seed);
 
	p->Send_uint32(_settings.game_creation.generation_seed);
 
	p->Send_string(_network_unique_id);
 
	cs->Send_Packet(p);
 

	
 
		// Transmit info about all the active clients
 
	FOR_ALL_CLIENTS(new_cs) {
 
		if (new_cs != cs && new_cs->status > STATUS_AUTH)
src/newgrf.cpp
Show inline comments
 
@@ -323,13 +323,13 @@ static void SetNewGRFOverride(uint32 sou
 

	
 
static Engine *GetNewEngine(const GRFFile *file, VehicleType type, uint16 internal_id)
 
{
 
	/* Hack for add-on GRFs that need to modify another GRF's engines. This lets
 
	 * them use the same engine slots. */
 
	const GRFFile *grf_match = NULL;
 
	if (_patches.dynamic_engines) {
 
	if (_settings.vehicle.dynamic_engines) {
 
		uint32 override = _grf_id_overrides[file->grfid];
 
		if (override != 0) {
 
			grf_match = GetFileByGRFID(override);
 
			if (grf_match == NULL) {
 
				grfmsg(5, "Tried mapping from GRFID %x to %x but target is not loaded", BSWAP32(file->grfid), BSWAP32(override));
 
			} else {
 
@@ -338,13 +338,13 @@ static Engine *GetNewEngine(const GRFFil
 
		}
 
	}
 

	
 
	/* Check if this vehicle is already defined... */
 
	Engine *e = NULL;
 
	FOR_ALL_ENGINES(e) {
 
		if (_patches.dynamic_engines && e->grffile != NULL && e->grffile != file && e->grffile != grf_match) continue;
 
		if (_settings.vehicle.dynamic_engines && e->grffile != NULL && e->grffile != file && e->grffile != grf_match) continue;
 
		if (e->type != type) continue;
 
		if (e->internal_id != internal_id) continue;
 

	
 
		if (e->grffile == NULL) {
 
			e->grffile = file;
 
			grfmsg(5, "Replaced engine at index %d for GRFID %x, type %d, index %d", e->index, BSWAP32(file->grfid), type, internal_id);
 
@@ -374,20 +374,20 @@ static Engine *GetNewEngine(const GRFFil
 

	
 
EngineID GetNewEngineID(const GRFFile *file, VehicleType type, uint16 internal_id)
 
{
 
	extern uint32 GetNewGRFOverride(uint32 grfid);
 

	
 
	const GRFFile *grf_match = NULL;
 
	if (_patches.dynamic_engines) {
 
	if (_settings.vehicle.dynamic_engines) {
 
		uint32 override = _grf_id_overrides[file->grfid];
 
		if (override != 0) grf_match = GetFileByGRFID(override);
 
	}
 

	
 
	const Engine *e = NULL;
 
	FOR_ALL_ENGINES(e) {
 
		if (_patches.dynamic_engines && e->grffile != file && (grf_match == NULL || e->grffile != grf_match)) continue;
 
		if (_settings.vehicle.dynamic_engines && e->grffile != file && (grf_match == NULL || e->grffile != grf_match)) continue;
 
		if (e->type != type) continue;
 
		if (e->internal_id != internal_id) continue;
 

	
 
		return e->index;
 
	}
 

	
 
@@ -3589,13 +3589,13 @@ bool GetGlobalVariable(byte param, uint3
 
			*value = _traininfo_vehicle_pitch;
 
			return true;
 

	
 
		case 0x0F: // Rail track type cost factors
 
			*value = 0;
 
			SB(*value, 0, 8, _railtype_cost_multiplier[0]); // normal rail
 
			if (_patches.disable_elrails) {
 
			if (_settings.vehicle.disable_elrails) {
 
				/* skip elrail multiplier - disabled */
 
				SB(*value, 8, 8, _railtype_cost_multiplier[2]); // monorail
 
			} else {
 
				SB(*value, 8, 8, _railtype_cost_multiplier[1]); // electified railway
 
				/* Skip monorail multiplier - no space in result */
 
			}
 
@@ -4185,25 +4185,25 @@ static void SafeParamSet(byte *buf, size
 

	
 

	
 
static uint32 GetPatchVariable(uint8 param)
 
{
 
	switch (param) {
 
		/* start year - 1920 */
 
		case 0x0B: return max(_patches.starting_year, ORIGINAL_BASE_YEAR) - ORIGINAL_BASE_YEAR;
 
		case 0x0B: return max(_settings.game_creation.starting_year, ORIGINAL_BASE_YEAR) - ORIGINAL_BASE_YEAR;
 

	
 
		/* freight trains weight factor */
 
		case 0x0E: return _patches.freight_trains;
 
		case 0x0E: return _settings.vehicle.freight_trains;
 

	
 
		/* empty wagon speed increase */
 
		case 0x0F: return 0;
 

	
 
		/* plane speed factor; our patch option is reversed from TTDPatch's,
 
		 * the following is good for 1x, 2x and 4x (most common?) and...
 
		 * well not really for 3x. */
 
		case 0x10:
 
			switch (_patches.plane_speed) {
 
			switch (_settings.vehicle.plane_speed) {
 
				default:
 
				case 4: return 1;
 
				case 3: return 2;
 
				case 2: return 2;
 
				case 1: return 4;
 
			}
 
@@ -4379,13 +4379,13 @@ static void ParamSet(byte *buf, size_t l
 
				} else if (_cur_stage == GLS_ACTIVATION) {
 
					switch (feature) {
 
						case 0x00: // Trains
 
						case 0x01: // Road Vehicles
 
						case 0x02: // Ships
 
						case 0x03: // Aircraft
 
							if (!_patches.dynamic_engines) {
 
							if (!_settings.vehicle.dynamic_engines) {
 
								src1 = PerformGRM(&_grm_engines[_engine_offsets[feature]], _engine_counts[feature], count, op, target, "vehicles");
 
								if (_skip_sprites == -1) return;
 
							} else {
 
								// GRM does not apply for dynamic engine allocation.
 
								switch (op) {
 
									case 2:
 
@@ -4541,13 +4541,13 @@ static void ParamSet(byte *buf, size_t l
 
		case 0x8E: // Y-Offset for train sprites
 
			_traininfo_vehicle_pitch = res;
 
			break;
 

	
 
		case 0x8F: // Rail track type cost factors
 
			_railtype_cost_multiplier[0] = GB(res, 0, 8);
 
			if (_patches.disable_elrails) {
 
			if (_settings.vehicle.disable_elrails) {
 
				_railtype_cost_multiplier[1] = GB(res, 0, 8);
 
				_railtype_cost_multiplier[2] = GB(res, 8, 8);
 
			} else {
 
				_railtype_cost_multiplier[1] = GB(res, 8, 8);
 
				_railtype_cost_multiplier[2] = GB(res, 16, 8);
 
			}
 
@@ -5076,90 +5076,90 @@ static void GRFUnsafe(byte *buf, size_t 
 
	_skip_sprites = -1;
 
}
 

	
 

	
 
static void InitializeGRFSpecial()
 
{
 
	_ttdpatch_flags[0] =  ((_patches.always_small_airport ? 1 : 0) << 0x0C)  // keepsmallairport
 
	                   |                                        (1 << 0x0D)  // newairports
 
	                   |                                        (1 << 0x0E)  // largestations
 
	                   |           ((_patches.longbridges ? 1 : 0) << 0x0F)  // longbridges
 
	                   |                                        (0 << 0x10)  // loadtime
 
	                   |                                        (1 << 0x12)  // presignals
 
	                   |                                        (1 << 0x13)  // extpresignals
 
	                   | ((_patches.never_expire_vehicles ? 1 : 0) << 0x16)  // enginespersist
 
	                   |                                        (1 << 0x1B)  // multihead
 
	                   |                                        (1 << 0x1D)  // lowmemory
 
	                   |                                        (1 << 0x1E); // generalfixes
 

	
 
	_ttdpatch_flags[1] =   ((_patches.station_noise_level ? 1 : 0) << 0x07)  // moreairports - based on units of noise
 
	                   |        ((_patches.mammoth_trains ? 1 : 0) << 0x08)  // mammothtrains
 
	                   |                                        (1 << 0x09)  // trainrefit
 
	                   |                                        (0 << 0x0B)  // subsidiaries
 
	                   |       ((_patches.gradual_loading ? 1 : 0) << 0x0C)  // gradualloading
 
	                   |                                        (1 << 0x12)  // unifiedmaglevmode - set bit 0 mode. Not revelant to OTTD
 
	                   |                                        (1 << 0x13)  // unifiedmaglevmode - set bit 1 mode
 
	                   |                                        (1 << 0x14)  // bridgespeedlimits
 
	                   |                                        (1 << 0x16)  // eternalgame
 
	                   |                                        (1 << 0x17)  // newtrains
 
	                   |                                        (1 << 0x18)  // newrvs
 
	                   |                                        (1 << 0x19)  // newships
 
	                   |                                        (1 << 0x1A)  // newplanes
 
	                   |           ((_patches.signal_side ? 1 : 0) << 0x1B)  // signalsontrafficside
 
	                   |       ((_patches.disable_elrails ? 0 : 1) << 0x1C); // electrifiedrailway
 

	
 
	_ttdpatch_flags[2] =                                        (1 << 0x01)  // loadallgraphics - obsolote
 
	                   |                                        (1 << 0x03)  // semaphores
 
	                   |                                        (0 << 0x0B)  // enhancedgui
 
	                   |                                        (0 << 0x0C)  // newagerating
 
	                   |       ((_patches.build_on_slopes ? 1 : 0) << 0x0D)  // buildonslopes
 
	                   |                                        (1 << 0x0E)  // fullloadany
 
	                   |                                        (1 << 0x0F)  // planespeed
 
	                   |                                        (0 << 0x10)  // moreindustriesperclimate - obsolete
 
	                   |                                        (0 << 0x11)  // moretoylandfeatures
 
	                   |                                        (1 << 0x12)  // newstations
 
	                   |                                        (1 << 0x13)  // tracktypecostdiff
 
	                   |                                        (1 << 0x14)  // manualconvert
 
	                   |       ((_patches.build_on_slopes ? 1 : 0) << 0x15)  // buildoncoasts
 
	                   |                                        (1 << 0x16)  // canals
 
	                   |                                        (1 << 0x17)  // newstartyear
 
	                   |    ((_patches.freight_trains > 1 ? 1 : 0) << 0x18)  // freighttrains
 
	                   |                                        (1 << 0x19)  // newhouses
 
	                   |                                        (1 << 0x1A)  // newbridges
 
	                   |                                        (1 << 0x1B)  // newtownnames
 
	                   |                                        (1 << 0x1C)  // moreanimation
 
	                   |    ((_patches.wagon_speed_limits ? 1 : 0) << 0x1D)  // wagonspeedlimits
 
	                   |                                        (1 << 0x1E)  // newshistory
 
	                   |                                        (0 << 0x1F); // custombridgeheads
 

	
 
	_ttdpatch_flags[3] =                                        (0 << 0x00)  // newcargodistribution
 
	                   |                                        (1 << 0x01)  // windowsnap
 
	                   |                                        (0 << 0x02)  // townbuildnoroad
 
	                   |                                        (0 << 0x03)  // pathbasedsignalling. To enable if ever pbs is back
 
	                   |                                        (0 << 0x04)  // aichoosechance
 
	                   |                                        (1 << 0x05)  // resolutionwidth
 
	                   |                                        (1 << 0x06)  // resolutionheight
 
	                   |                                        (1 << 0x07)  // newindustries
 
	                   |         ((_patches.improved_load ? 1 : 0) << 0x08)  // fifoloading
 
	                   |                                        (0 << 0x09)  // townroadbranchprob
 
	                   |                                        (0 << 0x0A)  // tempsnowline
 
	                   |                                        (1 << 0x0B)  // newcargo
 
	                   |                                        (1 << 0x0C)  // enhancemultiplayer
 
	                   |                                        (1 << 0x0D)  // onewayroads
 
	                   |   ((_patches.nonuniform_stations ? 1 : 0) << 0x0E)  // irregularstations
 
	                   |                                        (1 << 0x0F)  // statistics
 
	                   |                                        (1 << 0x10)  // newsounds
 
	                   |                                        (1 << 0x11)  // autoreplace
 
	                   |                                        (1 << 0x12)  // autoslope
 
	                   |                                        (0 << 0x13)  // followvehicle
 
	                   |                                        (1 << 0x14)  // trams
 
	                   |                                        (0 << 0x15)  // enhancetunnels
 
	                   |                                        (1 << 0x16)  // shortrvs
 
	                   |                                        (1 << 0x17)  // articulatedrvs
 
	                   |       ((_patches.dynamic_engines ? 1 : 0) << 0x18)  // dynamic engines
 
	                   |                                        (1 << 0x1E); // variablerunningcosts
 
	_ttdpatch_flags[0] =  ((_settings.station.always_small_airport ? 1 : 0) << 0x0C)  // keepsmallairport
 
	                   |                                                 (1 << 0x0D)  // newairports
 
	                   |                                                 (1 << 0x0E)  // largestations
 
	                   |      ((_settings.construction.longbridges ? 1 : 0) << 0x0F)  // longbridges
 
	                   |                                                 (0 << 0x10)  // loadtime
 
	                   |                                                 (1 << 0x12)  // presignals
 
	                   |                                                 (1 << 0x13)  // extpresignals
 
	                   | ((_settings.vehicle.never_expire_vehicles ? 1 : 0) << 0x16)  // enginespersist
 
	                   |                                                 (1 << 0x1B)  // multihead
 
	                   |                                                 (1 << 0x1D)  // lowmemory
 
	                   |                                                 (1 << 0x1E); // generalfixes
 

	
 
	_ttdpatch_flags[1] =   ((_settings.economy.station_noise_level ? 1 : 0) << 0x07)  // moreairports - based on units of noise
 
	                   |        ((_settings.vehicle.mammoth_trains ? 1 : 0) << 0x08)  // mammothtrains
 
	                   |                                                 (1 << 0x09)  // trainrefit
 
	                   |                                                 (0 << 0x0B)  // subsidiaries
 
	                   |         ((_settings.order.gradual_loading ? 1 : 0) << 0x0C)  // gradualloading
 
	                   |                                                 (1 << 0x12)  // unifiedmaglevmode - set bit 0 mode. Not revelant to OTTD
 
	                   |                                                 (1 << 0x13)  // unifiedmaglevmode - set bit 1 mode
 
	                   |                                                 (1 << 0x14)  // bridgespeedlimits
 
	                   |                                                 (1 << 0x16)  // eternalgame
 
	                   |                                                 (1 << 0x17)  // newtrains
 
	                   |                                                 (1 << 0x18)  // newrvs
 
	                   |                                                 (1 << 0x19)  // newships
 
	                   |                                                 (1 << 0x1A)  // newplanes
 
	                   |      ((_settings.construction.signal_side ? 1 : 0) << 0x1B)  // signalsontrafficside
 
	                   |       ((_settings.vehicle.disable_elrails ? 0 : 1) << 0x1C); // electrifiedrailway
 

	
 
	_ttdpatch_flags[2] =                                                 (1 << 0x01)  // loadallgraphics - obsolote
 
	                   |                                                 (1 << 0x03)  // semaphores
 
	                   |                                                 (0 << 0x0B)  // enhancedgui
 
	                   |                                                 (0 << 0x0C)  // newagerating
 
	                   |  ((_settings.construction.build_on_slopes ? 1 : 0) << 0x0D)  // buildonslopes
 
	                   |                                                 (1 << 0x0E)  // fullloadany
 
	                   |                                                 (1 << 0x0F)  // planespeed
 
	                   |                                                 (0 << 0x10)  // moreindustriesperclimate - obsolete
 
	                   |                                                 (0 << 0x11)  // moretoylandfeatures
 
	                   |                                                 (1 << 0x12)  // newstations
 
	                   |                                                 (1 << 0x13)  // tracktypecostdiff
 
	                   |                                                 (1 << 0x14)  // manualconvert
 
	                   |  ((_settings.construction.build_on_slopes ? 1 : 0) << 0x15)  // buildoncoasts
 
	                   |                                                 (1 << 0x16)  // canals
 
	                   |                                                 (1 << 0x17)  // newstartyear
 
	                   |    ((_settings.vehicle.freight_trains > 1 ? 1 : 0) << 0x18)  // freighttrains
 
	                   |                                                 (1 << 0x19)  // newhouses
 
	                   |                                                 (1 << 0x1A)  // newbridges
 
	                   |                                                 (1 << 0x1B)  // newtownnames
 
	                   |                                                 (1 << 0x1C)  // moreanimation
 
	                   |    ((_settings.vehicle.wagon_speed_limits ? 1 : 0) << 0x1D)  // wagonspeedlimits
 
	                   |                                                 (1 << 0x1E)  // newshistory
 
	                   |                                                 (0 << 0x1F); // custombridgeheads
 

	
 
	_ttdpatch_flags[3] =                                                 (0 << 0x00)  // newcargodistribution
 
	                   |                                                 (1 << 0x01)  // windowsnap
 
	                   |                                                 (0 << 0x02)  // townbuildnoroad
 
	                   |                                                 (0 << 0x03)  // pathbasedsignalling. To enable if ever pbs is back
 
	                   |                                                 (0 << 0x04)  // aichoosechance
 
	                   |                                                 (1 << 0x05)  // resolutionwidth
 
	                   |                                                 (1 << 0x06)  // resolutionheight
 
	                   |                                                 (1 << 0x07)  // newindustries
 
	                   |           ((_settings.order.improved_load ? 1 : 0) << 0x08)  // fifoloading
 
	                   |                                                 (0 << 0x09)  // townroadbranchprob
 
	                   |                                                 (0 << 0x0A)  // tempsnowline
 
	                   |                                                 (1 << 0x0B)  // newcargo
 
	                   |                                                 (1 << 0x0C)  // enhancemultiplayer
 
	                   |                                                 (1 << 0x0D)  // onewayroads
 
	                   |   ((_settings.station.nonuniform_stations ? 1 : 0) << 0x0E)  // irregularstations
 
	                   |                                                 (1 << 0x0F)  // statistics
 
	                   |                                                 (1 << 0x10)  // newsounds
 
	                   |                                                 (1 << 0x11)  // autoreplace
 
	                   |                                                 (1 << 0x12)  // autoslope
 
	                   |                                                 (0 << 0x13)  // followvehicle
 
	                   |                                                 (1 << 0x14)  // trams
 
	                   |                                                 (0 << 0x15)  // enhancetunnels
 
	                   |                                                 (1 << 0x16)  // shortrvs
 
	                   |                                                 (1 << 0x17)  // articulatedrvs
 
	                   |       ((_settings.vehicle.dynamic_engines ? 1 : 0) << 0x18)  // dynamic engines
 
	                   |                                                 (1 << 0x1E); // variablerunningcosts
 
}
 

	
 
static void ResetCustomStations()
 
{
 
	for (GRFFile *file = _first_grffile; file != NULL; file = file->next) {
 
		if (file->stations == NULL) continue;
src/newgrf_engine.cpp
Show inline comments
 
@@ -1120,13 +1120,13 @@ void CommitRailVehListOrderChanges()
 
		Engine *source_e = GetEngine(engine);
 
		Engine *target_e = NULL;
 

	
 
		/* Populate map with current list positions */
 
		Engine *e;
 
		FOR_ALL_ENGINES_OF_TYPE(e, VEH_TRAIN) {
 
			if (!_patches.dynamic_engines || e->grffile == source_e->grffile) {
 
			if (!_settings.vehicle.dynamic_engines || e->grffile == source_e->grffile) {
 
				if (e->internal_id == target) target_e = e;
 
				lptr_map[e->list_position] = e;
 
			}
 
		}
 

	
 
		/* Get the target position, if it exists */
src/newgrf_town.cpp
Show inline comments
 
@@ -18,13 +18,13 @@
 
 * @return the value stored in the corresponding variable*/
 
uint32 TownGetVariable(byte variable, byte parameter, bool *available, const Town *t)
 
{
 
	switch (variable) {
 
		/* Larger towns */
 
		case 0x40:
 
			if (_patches.larger_towns == 0) return 2;
 
			if (_settings.economy.larger_towns == 0) return 2;
 
			if (t->larger_town) return 1;
 
			return 0;
 

	
 
		/* Town index */
 
		case 0x41: return t->index;
 

	
src/news_gui.cpp
Show inline comments
 
@@ -395,13 +395,13 @@ void AddNewsItem(StringID string, NewsSu
 

	
 
	ni->string_id = string;
 
	ni->subtype = subtype;
 
	ni->flags = _news_subtype_data[subtype].flags;
 

	
 
	/* show this news message in color? */
 
	if (_cur_year >= _patches.colored_news_year) ni->flags |= NF_INCOLOR;
 
	if (_cur_year >= _settings.gui.colored_news_year) ni->flags |= NF_INCOLOR;
 

	
 
	ni->data_a = data_a;
 
	ni->data_b = data_b;
 
	ni->date = _date;
 
	CopyOutDParam(ni->params, 0, lengthof(ni->params));
 

	
src/npf.cpp
Show inline comments
 
@@ -210,13 +210,13 @@ static uint NPFSlopeCost(AyStarNode* cur
 
	 */
 
	int z1 = GetSlopeZ(x1 + dx4, y1 + dy4);
 
	int z2 = GetSlopeZ(x2 - dx4, y2 - dy4);
 

	
 
	if (z2 - z1 > 1) {
 
		/* Slope up */
 
		return _patches.npf_rail_slope_penalty;
 
		return _settings.pf.npf.npf_rail_slope_penalty;
 
	}
 
	return 0;
 
	/* Should we give a bonus for slope down? Probably not, we
 
	 * could just substract that bonus from the penalty, because
 
	 * there is only one level of steepness... */
 
}
 
@@ -257,16 +257,16 @@ static int32 NPFWaterPathCost(AyStar* as
 
	int32 cost = 0;
 
	Trackdir trackdir = (Trackdir)current->direction;
 

	
 
	cost = _trackdir_length[trackdir]; // Should be different for diagonal tracks
 

	
 
	if (IsBuoyTile(current->tile) && IsDiagonalTrackdir(trackdir))
 
		cost += _patches.npf_buoy_penalty; // A small penalty for going over buoys
 
		cost += _settings.pf.npf.npf_buoy_penalty; // A small penalty for going over buoys
 

	
 
	if (current->direction != NextTrackdir((Trackdir)parent->path.node.direction))
 
		cost += _patches.npf_water_curve_penalty;
 
		cost += _settings.pf.npf.npf_water_curve_penalty;
 

	
 
	/* @todo More penalties? */
 

	
 
	return cost;
 
}
 

	
 
@@ -282,19 +282,19 @@ static int32 NPFRoadPathCost(AyStar* as,
 
			cost = IsTunnel(tile) ? NPFTunnelCost(current) : NPFBridgeCost(current);
 
			break;
 

	
 
		case MP_ROAD:
 
			cost = NPF_TILE_LENGTH;
 
			/* Increase the cost for level crossings */
 
			if (IsLevelCrossing(tile)) cost += _patches.npf_crossing_penalty;
 
			if (IsLevelCrossing(tile)) cost += _settings.pf.npf.npf_crossing_penalty;
 
			break;
 

	
 
		case MP_STATION:
 
			cost = NPF_TILE_LENGTH;
 
			/* Increase the cost for drive-through road stops */
 
			if (IsDriveThroughStopTile(tile)) cost += _patches.npf_road_drive_through_penalty;
 
			if (IsDriveThroughStopTile(tile)) cost += _settings.pf.npf.npf_road_drive_through_penalty;
 
			break;
 

	
 
		default:
 
			break;
 
	}
 

	
 
@@ -303,13 +303,13 @@ static int32 NPFRoadPathCost(AyStar* as,
 
	/* Check for slope */
 
	cost += NPFSlopeCost(current);
 

	
 
	/* Check for turns. Road vehicles only really drive diagonal, turns are
 
	 * represented by non-diagonal tracks */
 
	if (!IsDiagonalTrackdir((Trackdir)current->direction))
 
		cost += _patches.npf_road_curve_penalty;
 
		cost += _settings.pf.npf.npf_road_curve_penalty;
 

	
 
	NPFMarkTile(tile);
 
	DEBUG(npf, 4, "Calculating G for: (%d, %d). Result: %d", TileX(current->tile), TileY(current->tile), cost);
 
	return cost;
 
}
 

	
 
@@ -341,13 +341,13 @@ static int32 NPFRailPathCost(AyStar* as,
 
			/* We give a station tile a penalty. Logically we would only want to give
 
			 * station tiles that are not our destination this penalty. This would
 
			 * discourage trains to drive through busy stations. But, we can just
 
			 * give any station tile a penalty, because every possible route will get
 
			 * this penalty exactly once, on its end tile (if it's a station) and it
 
			 * will therefore not make a difference. */
 
			cost = NPF_TILE_LENGTH + _patches.npf_rail_station_penalty;
 
			cost = NPF_TILE_LENGTH + _settings.pf.npf.npf_rail_station_penalty;
 
			break;
 

	
 
		default:
 
			break;
 
	}
 

	
 
@@ -363,15 +363,15 @@ static int32 NPFRailPathCost(AyStar* as,
 
				 * encounter, if it is red */
 

	
 
				/* Is this a presignal exit or combo? */
 
				SignalType sigtype = GetSignalType(tile, TrackdirToTrack(trackdir));
 
				if (sigtype == SIGTYPE_EXIT || sigtype == SIGTYPE_COMBO) {
 
					/* Penalise exit and combo signals differently (heavier) */
 
					cost += _patches.npf_rail_firstred_exit_penalty;
 
					cost += _settings.pf.npf.npf_rail_firstred_exit_penalty;
 
				} else {
 
					cost += _patches.npf_rail_firstred_penalty;
 
					cost += _settings.pf.npf.npf_rail_firstred_penalty;
 
				}
 
			}
 
			/* Record the state of this signal */
 
			NPFSetFlag(current, NPF_FLAG_LAST_SIGNAL_RED, true);
 
		} else {
 
			/* Record the state of this signal */
 
@@ -383,29 +383,29 @@ static int32 NPFRailPathCost(AyStar* as,
 
	/* Penalise the tile if it is a target tile and the last signal was
 
	 * red */
 
	/* HACK: We create a new_node here so we can call EndNodeCheck. Ugly as hell
 
	 * of course... */
 
	new_node.path.node = *current;
 
	if (as->EndNodeCheck(as, &new_node) == AYSTAR_FOUND_END_NODE && NPFGetFlag(current, NPF_FLAG_LAST_SIGNAL_RED))
 
		cost += _patches.npf_rail_lastred_penalty;
 
		cost += _settings.pf.npf.npf_rail_lastred_penalty;
 

	
 
	/* Check for slope */
 
	cost += NPFSlopeCost(current);
 

	
 
	/* Check for turns */
 
	if (current->direction != NextTrackdir((Trackdir)parent->path.node.direction))
 
		cost += _patches.npf_rail_curve_penalty;
 
		cost += _settings.pf.npf.npf_rail_curve_penalty;
 
	/*TODO, with realistic acceleration, also the amount of straight track between
 
	 *      curves should be taken into account, as this affects the speed limit. */
 

	
 
	/* Check for reverse in depot */
 
	if (IsRailDepotTile(tile) && as->EndNodeCheck(as, &new_node) != AYSTAR_FOUND_END_NODE) {
 
		/* Penalise any depot tile that is not the last tile in the path. This
 
		 * _should_ penalise every occurence of reversing in a depot (and only
 
		 * that) */
 
		cost += _patches.npf_rail_depot_reverse_penalty;
 
		cost += _settings.pf.npf.npf_rail_depot_reverse_penalty;
 
	}
 

	
 
	/* Check for occupied track */
 
	//TODO
 

	
 
	NPFMarkTile(tile);
 
@@ -631,13 +631,13 @@ static TrackdirBits GetDriveableTrackdir
 
	DEBUG(npf, 4, "Next node: (%d, %d) [%d], possible trackdirs: 0x%X", TileX(dst_tile), TileY(dst_tile), dst_tile, trackdirbits);
 

	
 
	/* Select only trackdirs we can reach from our current trackdir */
 
	trackdirbits &= TrackdirReachesTrackdirs(src_trackdir);
 

	
 
	/* Filter out trackdirs that would make 90 deg turns for trains */
 
	if (_patches.forbid_90_deg && (type == TRANSPORT_RAIL || type == TRANSPORT_WATER)) trackdirbits &= ~TrackdirCrossesTrackdirs(src_trackdir);
 
	if (_settings.pf.forbid_90_deg && (type == TRANSPORT_RAIL || type == TRANSPORT_WATER)) trackdirbits &= ~TrackdirCrossesTrackdirs(src_trackdir);
 

	
 
	DEBUG(npf, 6, "After filtering: (%d, %d), possible trackdirs: 0x%X", TileX(dst_tile), TileY(dst_tile), trackdirbits);
 

	
 
	return trackdirbits;
 
}
 

	
 
@@ -967,13 +967,13 @@ void InitializeNPF()
 
	}
 
	_npf_aystar.loops_per_tick = 0;
 
	_npf_aystar.max_path_cost = 0;
 
	//_npf_aystar.max_search_nodes = 0;
 
	/* We will limit the number of nodes for now, until we have a better
 
	 * solution to really fix performance */
 
	_npf_aystar.max_search_nodes = _patches.npf_max_search_nodes;
 
	_npf_aystar.max_search_nodes = _settings.pf.npf.npf_max_search_nodes;
 
}
 

	
 
void NPFFillWithOrderData(NPFFindStationOrTileData* fstd, Vehicle* v)
 
{
 
	/* Ships don't really reach their stations, but the tile in front. So don't
 
	 * save the station id for ships. For roadvehs we don't store it either,
src/openttd.cpp
Show inline comments
 
@@ -482,14 +482,14 @@ int ttd_main(int argc, char *argv[])
 
	/* override config? */
 
	if (!StrEmpty(musicdriver)) ttd_strlcpy(_ini_musicdriver, musicdriver, sizeof(_ini_musicdriver));
 
	if (!StrEmpty(sounddriver)) ttd_strlcpy(_ini_sounddriver, sounddriver, sizeof(_ini_sounddriver));
 
	if (!StrEmpty(videodriver)) ttd_strlcpy(_ini_videodriver, videodriver, sizeof(_ini_videodriver));
 
	if (!StrEmpty(blitter))     ttd_strlcpy(_ini_blitter, blitter, sizeof(_ini_blitter));
 
	if (resolution[0] != 0) { _cur_resolution[0] = resolution[0]; _cur_resolution[1] = resolution[1]; }
 
	if (startyear != INVALID_YEAR) _patches_newgame.starting_year = startyear;
 
	if (generation_seed != GENERATE_NEW_SEED) _patches_newgame.generation_seed = generation_seed;
 
	if (startyear != INVALID_YEAR) _settings_newgame.game_creation.starting_year = startyear;
 
	if (generation_seed != GENERATE_NEW_SEED) _settings_newgame.game_creation.generation_seed = generation_seed;
 

	
 
	/* The width and height must be at least 1 pixel, this
 
	 * way all internal drawing routines work correctly. */
 
	if (_cur_resolution[0] == 0) _cur_resolution[0] = 1;
 
	if (_cur_resolution[1] == 0) _cur_resolution[1] = 1;
 

	
 
@@ -649,13 +649,13 @@ int ttd_main(int argc, char *argv[])
 
}
 

	
 
void HandleExitGameRequest()
 
{
 
	if (_game_mode == GM_MENU) { // do not ask to quit on the main screen
 
		_exit_game = true;
 
	} else if (_patches.autosave_on_exit) {
 
	} else if (_settings.gui.autosave_on_exit) {
 
		DoExitSave();
 
		_exit_game = true;
 
	} else {
 
		AskExitGame();
 
	}
 
}
 
@@ -681,15 +681,15 @@ static void MakeNewGameDone()
 

	
 
	/* Create a single player */
 
	DoStartupNewPlayer(false);
 

	
 
	SetLocalPlayer(PLAYER_FIRST);
 
	_current_player = _local_player;
 
	DoCommandP(0, (_patches.autorenew << 15 ) | (_patches.autorenew_months << 16) | 4, _patches.autorenew_money, NULL, CMD_SET_AUTOREPLACE);
 
	DoCommandP(0, (_settings.gui.autorenew << 15 ) | (_settings.gui.autorenew_months << 16) | 4, _settings.gui.autorenew_money, NULL, CMD_SET_AUTOREPLACE);
 

	
 
	SettingsDisableElrail(_patches.disable_elrails);
 
	SettingsDisableElrail(_settings.vehicle.disable_elrails);
 
	InitializeRailGUI();
 

	
 
#ifdef ENABLE_NETWORK
 
	/* We are the server, we start a new player (not dedicated),
 
	 * so set the default password *if* needed. */
 
	if (_network_server && !StrEmpty(_network_default_company_pass)) {
 
@@ -708,13 +708,13 @@ static void MakeNewGame(bool from_height
 
	ResetGRFConfig(true);
 
	_house_mngr.ResetMapping();
 
	_industile_mngr.ResetMapping();
 
	_industry_mngr.ResetMapping();
 

	
 
	GenerateWorldSetCallback(&MakeNewGameDone);
 
	GenerateWorld(from_heightmap ? GW_HEIGHTMAP : GW_NEWGAME, 1 << _patches.map_x, 1 << _patches.map_y);
 
	GenerateWorld(from_heightmap ? GW_HEIGHTMAP : GW_NEWGAME, 1 << _settings.game_creation.map_x, 1 << _settings.game_creation.map_y);
 
}
 

	
 
static void MakeNewEditorWorldDone()
 
{
 
	SetLocalPlayer(OWNER_NONE);
 

	
 
@@ -725,13 +725,13 @@ static void MakeNewEditorWorld()
 
{
 
	_game_mode = GM_EDITOR;
 

	
 
	ResetGRFConfig(true);
 

	
 
	GenerateWorldSetCallback(&MakeNewEditorWorldDone);
 
	GenerateWorld(GW_EMPTY, 1 << _patches.map_x, 1 << _patches.map_y);
 
	GenerateWorld(GW_EMPTY, 1 << _settings.game_creation.map_x, 1 << _settings.game_creation.map_y);
 
}
 

	
 
void StartupPlayers();
 
void StartupDisasters();
 
extern void StartupEconomy();
 

	
 
@@ -775,13 +775,13 @@ static void StartScenario()
 
	StartupPlayers();
 
	StartupEngines();
 
	StartupDisasters();
 

	
 
	SetLocalPlayer(PLAYER_FIRST);
 
	_current_player = _local_player;
 
	DoCommandP(0, (_patches.autorenew << 15 ) | (_patches.autorenew_months << 16) | 4, _patches.autorenew_money, NULL, CMD_SET_AUTOREPLACE);
 
	DoCommandP(0, (_settings.gui.autorenew << 15 ) | (_settings.gui.autorenew_months << 16) | 4, _settings.gui.autorenew_money, NULL, CMD_SET_AUTOREPLACE);
 

	
 
	MarkWholeScreenDirty();
 
}
 

	
 
/** Load the specified savegame but on error do different things.
 
 * If loading fails due to corrupt savegame, bad version, etc. go back to
 
@@ -834,13 +834,13 @@ void SwitchMode(int new_mode)
 
		if (_is_network_server) {
 
			/* But not if we are going to the menu */
 
			if (new_mode != SM_MENU) {
 
				/* check if we should reload the config */
 
				if (_network_reload_cfg) {
 
					LoadFromConfig();
 
					_patches = _patches_newgame;
 
					_settings = _settings_newgame;
 
					_opt = _opt_newgame;
 
					ResetGRFConfig(false);
 
				}
 
				NetworkServerStart();
 
			} else {
 
				/* This client no longer wants to be a network-server */
 
@@ -908,20 +908,20 @@ void SwitchMode(int new_mode)
 
			MakeNewGame(true);
 
			break;
 

	
 
		case SM_LOAD_HEIGHTMAP: /* Load heightmap from scenario editor */
 
			SetLocalPlayer(OWNER_NONE);
 

	
 
			GenerateWorld(GW_HEIGHTMAP, 1 << _patches.map_x, 1 << _patches.map_y);
 
			GenerateWorld(GW_HEIGHTMAP, 1 << _settings.game_creation.map_x, 1 << _settings.game_creation.map_y);
 
			MarkWholeScreenDirty();
 
			break;
 

	
 
		case SM_LOAD_SCENARIO: { /* Load scenario from scenario editor */
 
			if (SafeSaveOrLoad(_file_to_saveload.name, _file_to_saveload.mode, GM_EDITOR, NO_DIRECTORY)) {
 
				SetLocalPlayer(OWNER_NONE);
 
				_patches_newgame.starting_year = _cur_year;
 
				_settings_newgame.game_creation.starting_year = _cur_year;
 
			} else {
 
				SetDParamStr(0, GetSaveLoadErrorString());
 
				ShowErrorMessage(INVALID_STRING_ID, STR_012D, 0, 0);
 
			}
 
			break;
 
		}
 
@@ -941,13 +941,13 @@ void SwitchMode(int new_mode)
 
			}
 
			if (_networking && _pause_game == 2) _pause_game = 1;
 
			break;
 

	
 
		case SM_GENRANDLAND: /* Generate random land within scenario editor */
 
			SetLocalPlayer(OWNER_NONE);
 
			GenerateWorld(GW_RANDOM, 1 << _patches.map_x, 1 << _patches.map_y);
 
			GenerateWorld(GW_RANDOM, 1 << _settings.game_creation.map_x, 1 << _settings.game_creation.map_y);
 
			/* XXX: set date */
 
			MarkWholeScreenDirty();
 
			break;
 
	}
 

	
 
	if (_switch_mode_errorstr != INVALID_STRING_ID) {
 
@@ -1057,22 +1057,22 @@ static void DoAutosave()
 

	
 
#if defined(PSP)
 
	/* Autosaving in networking is too time expensive for the PSP */
 
	if (_networking) return;
 
#endif /* PSP */
 

	
 
	if (_patches.keep_all_autosave && _local_player != PLAYER_SPECTATOR) {
 
	if (_settings.gui.keep_all_autosave && _local_player != PLAYER_SPECTATOR) {
 
		SetDParam(0, _local_player);
 
		SetDParam(1, _date);
 
		GetString(buf, STR_4004, lastof(buf));
 
		ttd_strlcat(buf, ".sav", lengthof(buf));
 
	} else {
 
		/* generate a savegame name and number according to _patches.max_num_autosaves */
 
		/* generate a savegame name and number according to _settings.gui.max_num_autosaves */
 
		snprintf(buf, sizeof(buf), "autosave%d.sav", _autosave_ctr);
 

	
 
		if (++_autosave_ctr >= _patches.max_num_autosaves) _autosave_ctr = 0;
 
		if (++_autosave_ctr >= _settings.gui.max_num_autosaves) _autosave_ctr = 0;
 
	}
 

	
 
	DEBUG(sl, 2, "Autosaving to '%s'", buf);
 
	if (SaveOrLoad(buf, SL_SAVE, AUTOSAVE_DIR) != SL_OK) {
 
		ShowErrorMessage(INVALID_STRING_ID, STR_AUTOSAVE_FAILED, 0, 0);
 
	}
 
@@ -1425,13 +1425,13 @@ bool AfterLoadGame()
 

	
 
	/* Update current year
 
	 * must be done before loading sprites as some newgrfs check it */
 
	SetDate(_date);
 

	
 
	/* Force dynamic engines off when loading older savegames */
 
	if (CheckSavegameVersion(95)) _patches.dynamic_engines = 0;
 
	if (CheckSavegameVersion(95)) _settings.vehicle.dynamic_engines = 0;
 

	
 
	/* Load the sprites */
 
	GfxLoadSprites();
 
	LoadStringWidthTable();
 

	
 
	/* Copy temporary data to Engine pool */
 
@@ -1632,15 +1632,15 @@ bool AfterLoadGame()
 
		 * happen. In case we are not a dedicated server, the local player always
 
		 * becomes player 0, unless we are in the scenario editor where all the
 
		 * players are 'invalid'.
 
		 */
 
		if (!_network_dedicated && IsValidPlayer(PLAYER_FIRST)) {
 
			p = GetPlayer(PLAYER_FIRST);
 
			p->engine_renew        = _patches.autorenew;
 
			p->engine_renew_months = _patches.autorenew_months;
 
			p->engine_renew_money  = _patches.autorenew_money;
 
			p->engine_renew        = _settings.gui.autorenew;
 
			p->engine_renew_months = _settings.gui.autorenew_months;
 
			p->engine_renew_money  = _settings.gui.autorenew_money;
 
		}
 
	}
 

	
 
	if (CheckSavegameVersion(48)) {
 
		for (TileIndex t = 0; t < map_size; t++) {
 
			switch (GetTileType(t)) {
 
@@ -2019,15 +2019,15 @@ bool AfterLoadGame()
 
			v->current_order.SetRefit(CT_NO_REFIT);
 
		}
 
	}
 

	
 
	/* from version 38 we have optional elrails, since we cannot know the
 
	 * preference of a user, let elrails enabled; it can be disabled manually */
 
	if (CheckSavegameVersion(38)) _patches.disable_elrails = false;
 
	if (CheckSavegameVersion(38)) _settings.vehicle.disable_elrails = false;
 
	/* do the same as when elrails were enabled/disabled manually just now */
 
	SettingsDisableElrail(_patches.disable_elrails);
 
	SettingsDisableElrail(_settings.vehicle.disable_elrails);
 
	InitializeRailGUI();
 

	
 
	/* From version 53, the map array was changed for house tiles to allow
 
	 * space for newhouses grf features. A new byte, m7, was also added. */
 
	if (CheckSavegameVersion(53)) {
 
		for (TileIndex t = 0; t < map_size; t++) {
 
@@ -2186,13 +2186,13 @@ bool AfterLoadGame()
 
	 * fast was added in version 54. From version 56 this is now saved in the
 
	 * town as cities can be built specifically in the scenario editor. */
 
	if (CheckSavegameVersion(56)) {
 
		Town *t;
 

	
 
		FOR_ALL_TOWNS(t) {
 
			if (_patches.larger_towns != 0 && (t->index % _patches.larger_towns) == 0) {
 
			if (_settings.economy.larger_towns != 0 && (t->index % _settings.economy.larger_towns) == 0) {
 
				t->larger_town = true;
 
			}
 
		}
 
	}
 

	
 
	if (CheckSavegameVersion(57)) {
 
@@ -2461,28 +2461,28 @@ bool AfterLoadGame()
 
					}
 
				}
 
			}
 
		}
 

	
 
		/* Convert old PF settings to new */
 
		if (_patches.yapf.rail_use_yapf || CheckSavegameVersion(28)) {
 
			_patches.pathfinder_for_trains = VPF_YAPF;
 
		if (_settings.pf.yapf.rail_use_yapf || CheckSavegameVersion(28)) {
 
			_settings.pf.pathfinder_for_trains = VPF_YAPF;
 
		} else {
 
			_patches.pathfinder_for_trains = (_patches.new_pathfinding_all ? VPF_NPF : VPF_NTP);
 
			_settings.pf.pathfinder_for_trains = (_settings.pf.new_pathfinding_all ? VPF_NPF : VPF_NTP);
 
		}
 

	
 
		if (_patches.yapf.road_use_yapf || CheckSavegameVersion(28)) {
 
			_patches.pathfinder_for_roadvehs = VPF_YAPF;
 
		if (_settings.pf.yapf.road_use_yapf || CheckSavegameVersion(28)) {
 
			_settings.pf.pathfinder_for_roadvehs = VPF_YAPF;
 
		} else {
 
			_patches.pathfinder_for_roadvehs = (_patches.new_pathfinding_all ? VPF_NPF : VPF_OPF);
 
			_settings.pf.pathfinder_for_roadvehs = (_settings.pf.new_pathfinding_all ? VPF_NPF : VPF_OPF);
 
		}
 

	
 
		if (_patches.yapf.ship_use_yapf) {
 
			_patches.pathfinder_for_ships = VPF_YAPF;
 
		if (_settings.pf.yapf.ship_use_yapf) {
 
			_settings.pf.pathfinder_for_ships = VPF_YAPF;
 
		} else {
 
			_patches.pathfinder_for_ships = (_patches.new_pathfinding_all ? VPF_NPF : VPF_OPF);
 
			_settings.pf.pathfinder_for_ships = (_settings.pf.new_pathfinding_all ? VPF_NPF : VPF_OPF);
 
		}
 
	}
 

	
 
	if (CheckSavegameVersion(88)) {
 
		/* Profits are now with 8 bit fract */
 
		Vehicle *v;
src/order_cmd.cpp
Show inline comments
 
@@ -150,13 +150,13 @@ Order::Order(uint32 packed)
 
	this->travel_time   = 0;
 
}
 

	
 
void Order::ConvertFromOldSavegame()
 
{
 
	/* First handle non-stop, because those bits are going to be reused. */
 
	if (_patches.sg_new_nonstop) {
 
	if (_settings.gui.sg_new_nonstop) {
 
		this->SetNonStopType((this->flags & 0x08) ? ONSF_NO_STOP_AT_ANY_STATION : ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
 
	} else {
 
		this->SetNonStopType((this->flags & 0x08) ? ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS : ONSF_STOP_EVERYWHERE);
 
	}
 

	
 
	switch (this->GetType()) {
 
@@ -168,13 +168,13 @@ void Order::ConvertFromOldSavegame()
 
	/* Then the load/depot action flags because those bits are going to be reused too
 
	 * and they reuse the non-stop bits. */
 
	if (this->GetType() != OT_GOTO_DEPOT) {
 
		if ((this->flags & 4) == 0) {
 
			this->SetLoadType(OLF_LOAD_IF_POSSIBLE);
 
		} else {
 
			this->SetLoadType(_patches.sg_full_load_any ? OLF_FULL_LOAD_ANY : OLFB_FULL_LOAD);
 
			this->SetLoadType(_settings.gui.sg_full_load_any ? OLF_FULL_LOAD_ANY : OLFB_FULL_LOAD);
 
		}
 
	} else {
 
		this->SetDepotActionType(((this->flags & 6) == 4) ? ODATFB_HALT : ODATF_SERVICE_ONLY);
 
	}
 

	
 
	/* Finally fix the unload/depot type flags. */
 
@@ -448,13 +448,13 @@ CommandCost CmdInsertOrder(TileIndex til
 
	}
 

	
 
	if (sel_ord > v->num_orders) return CMD_ERROR;
 

	
 
	if (!HasOrderPoolFree(1)) return_cmd_error(STR_8831_NO_MORE_SPACE_FOR_ORDERS);
 

	
 
	if (v->type == VEH_SHIP && IsHumanPlayer(v->owner) && _patches.pathfinder_for_ships != VPF_NPF) {
 
	if (v->type == VEH_SHIP && IsHumanPlayer(v->owner) && _settings.pf.pathfinder_for_ships != VPF_NPF) {
 
		/* Make sure the new destination is not too far away from the previous */
 
		const Order *prev = NULL;
 
		uint n = 0;
 

	
 
		/* Find the last goto station or depot order before the insert location.
 
		 * If the order is to be inserted at the beginning of the order list this
 
@@ -1270,13 +1270,13 @@ void RestoreVehicleOrders(const Vehicle 
 
			if (!DoCommandP(0, v->index + (i << 16), bak->order[i].Pack(), NULL,
 
					CMD_INSERT_ORDER | CMD_NO_TEST_IF_IN_NETWORK)) {
 
				break;
 
			}
 

	
 
			/* Copy timetable if enabled */
 
			if (_patches.timetabling && !DoCommandP(0, v->index | (i << 16) | (1 << 25),
 
			if (_settings.order.timetabling && !DoCommandP(0, v->index | (i << 16) | (1 << 25),
 
					bak->order[i].wait_time << 16 | bak->order[i].travel_time, NULL,
 
					CMD_CHANGE_TIMETABLE | CMD_NO_TEST_IF_IN_NETWORK)) {
 
				break;
 
			}
 
		}
 
	}
 
@@ -1383,19 +1383,19 @@ static TileIndex GetStationTileForVehicl
 
 * Check the orders of a vehicle, to see if there are invalid orders and stuff
 
 *
 
 */
 
void CheckOrders(const Vehicle* v)
 
{
 
	/* Does the user wants us to check things? */
 
	if (_patches.order_review_system == 0) return;
 
	if (_settings.gui.order_review_system == 0) return;
 

	
 
	/* Do nothing for crashed vehicles */
 
	if (v->vehstatus & VS_CRASHED) return;
 

	
 
	/* Do nothing for stopped vehicles if setting is '1' */
 
	if (_patches.order_review_system == 1 && v->vehstatus & VS_STOPPED)
 
	if (_settings.gui.order_review_system == 1 && v->vehstatus & VS_STOPPED)
 
		return;
 

	
 
	/* do nothing we we're not the first vehicle in a share-chain */
 
	if (v->next_shared != NULL) return;
 

	
 
	/* Only check every 20 days, so that we don't flood the message log */
 
@@ -1568,13 +1568,13 @@ void DeleteVehicleOrders(Vehicle *v)
 
		cur->FreeChain(); // Free the orders.
 
	}
 
}
 

	
 
Date GetServiceIntervalClamped(uint index)
 
{
 
	return (_patches.servint_ispercent) ? Clamp(index, MIN_SERVINT_PERCENT, MAX_SERVINT_PERCENT) : Clamp(index, MIN_SERVINT_DAYS, MAX_SERVINT_DAYS);
 
	return (_settings.vehicle.servint_ispercent) ? Clamp(index, MIN_SERVINT_PERCENT, MAX_SERVINT_PERCENT) : Clamp(index, MIN_SERVINT_DAYS, MAX_SERVINT_DAYS);
 
}
 

	
 
/**
 
 *
 
 * Check if a vehicle has any valid orders
 
 *
src/order_gui.cpp
Show inline comments
 
@@ -262,28 +262,28 @@ static Order GetOrderCmdFromTile(const V
 
{
 
	Order order;
 
	order.next  = NULL;
 
	order.index = 0;
 

	
 
	/* check depot first */
 
	if (_patches.gotodepot) {
 
	if (_settings.order.gotodepot) {
 
		switch (GetTileType(tile)) {
 
			case MP_RAILWAY:
 
				if (v->type == VEH_TRAIN && IsTileOwner(tile, _local_player)) {
 
					if (IsRailDepot(tile)) {
 
						order.MakeGoToDepot(GetDepotByTile(tile)->index, ODTFB_PART_OF_ORDERS);
 
						if (_patches.new_nonstop) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
 
						if (_settings.gui.new_nonstop) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
 
						return order;
 
					}
 
				}
 
				break;
 

	
 
			case MP_ROAD:
 
				if (IsRoadDepot(tile) && v->type == VEH_ROAD && IsTileOwner(tile, _local_player)) {
 
					order.MakeGoToDepot(GetDepotByTile(tile)->index, ODTFB_PART_OF_ORDERS);
 
					if (_patches.new_nonstop) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
 
					if (_settings.gui.new_nonstop) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
 
					return order;
 
				}
 
				break;
 

	
 
			case MP_STATION:
 
				if (v->type != VEH_AIRCRAFT) break;
 
@@ -310,13 +310,13 @@ static Order GetOrderCmdFromTile(const V
 
	/* check waypoint */
 
	if (IsTileType(tile, MP_RAILWAY) &&
 
			v->type == VEH_TRAIN &&
 
			IsTileOwner(tile, _local_player) &&
 
			IsRailWaypoint(tile)) {
 
		order.MakeGoToWaypoint(GetWaypointByTile(tile)->index);
 
		if (_patches.new_nonstop) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
 
		if (_settings.gui.new_nonstop) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
 
		return order;
 
	}
 

	
 
	if (IsTileType(tile, MP_STATION)) {
 
		StationID st_index = GetStationIndex(tile);
 
		const Station *st = GetStation(st_index);
 
@@ -327,13 +327,13 @@ static Order GetOrderCmdFromTile(const V
 
			(facil = FACIL_TRAIN, v->type == VEH_TRAIN) ||
 
			(facil = FACIL_AIRPORT, v->type == VEH_AIRCRAFT) ||
 
			(facil = FACIL_BUS_STOP, v->type == VEH_ROAD && IsCargoInClass(v->cargo_type, CC_PASSENGERS)) ||
 
			(facil = FACIL_TRUCK_STOP, 1);
 
			if (st->facilities & facil) {
 
				order.MakeGoToStation(st_index);
 
				if (_patches.new_nonstop && (v->type == VEH_TRAIN || v->type == VEH_ROAD)) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
 
				if (_settings.gui.new_nonstop && (v->type == VEH_TRAIN || v->type == VEH_ROAD)) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
 
				return order;
 
			}
 
		}
 
	}
 

	
 
	/* not found */
 
@@ -608,13 +608,13 @@ public:
 
	{
 
		this->caption_color = v->owner;
 
		this->vscroll.cap = 6;
 
		this->resize.step_height = 10;
 
		this->selected_order = -1;
 
		this->vehicle = v;
 
		if (_patches.timetabling) {
 
		if (_settings.order.timetabling) {
 
			this->widget[ORDER_WIDGET_CAPTION].right -= 61;
 
		} else {
 
			this->HideWidget(ORDER_WIDGET_TIMETABLE_VIEW);
 
		}
 
		this->FindWindowPlacementAndResize(desc);
 
	}
src/pathfind.cpp
Show inline comments
 
@@ -775,13 +775,13 @@ void NewTrainPathfind(TileIndex tile, Ti
 

	
 
	tpf->dest = dest;
 
	tpf->userdata = data;
 
	tpf->enum_proc = enum_proc;
 
	tpf->tracktype = TRANSPORT_RAIL;
 
	tpf->railtypes = railtypes;
 
	tpf->maxlength = min(_patches.pf_maxlength * 3, 10000);
 
	tpf->maxlength = min(_settings.pf.opf.pf_maxlength * 3, 10000);
 
	tpf->nstack = 0;
 
	tpf->new_link = tpf->links;
 
	tpf->num_links_left = lengthof(tpf->links);
 
	memset(tpf->hash_head, 0, sizeof(tpf->hash_head));
 

	
 
	NTPEnum(tpf, tile, direction);
src/player_gui.cpp
Show inline comments
 
@@ -1188,13 +1188,13 @@ struct PlayerCompanyWindow : Window
 
		this->SetWidgetHiddenState(PCW_WIDGET_RELOCATE_HQ,      !local || p->location_of_house == 0);
 
		this->SetWidgetHiddenState(PCW_WIDGET_BUY_SHARE,        local);
 
		this->SetWidgetHiddenState(PCW_WIDGET_SELL_SHARE,       local);
 
		this->SetWidgetHiddenState(PCW_WIDGET_COMPANY_PASSWORD, !local || !_networking);
 

	
 
		if (!local) {
 
			if (_patches.allow_shares) { // Shares are allowed
 
			if (_settings.economy.allow_shares) { // Shares are allowed
 
				/* If all shares are owned by someone (none by nobody), disable buy button */
 
				this->SetWidgetDisabledState(PCW_WIDGET_BUY_SHARE, GetAmountOwnedBy(p, PLAYER_SPECTATOR) == 0 ||
 
						/* Only 25% left to buy. If the player is human, disable buying it up.. TODO issues! */
 
						(GetAmountOwnedBy(p, PLAYER_SPECTATOR) == 1 && !p->is_ai) ||
 
						/* Spectators cannot do anything of course */
 
						_local_player == PLAYER_SPECTATOR);
 
@@ -1542,13 +1542,13 @@ struct HighScoreWindow : EndGameHighScor
 
	{
 
		const HighScore *hs = _highscore_table[this->window_number];
 
		uint x, y;
 

	
 
		this->SetupHighScoreEndWindow(&x, &y);
 

	
 
		SetDParam(0, _patches.ending_year);
 
		SetDParam(0, _settings.gui.ending_year);
 
		SetDParam(1, this->window_number + STR_6801_EASY);
 
		DrawStringMultiCenter(x + (640 / 2), y + 62, !_networking ? STR_0211_TOP_COMPANIES_WHO_REACHED : STR_TOP_COMPANIES_NETWORK_GAME, 500);
 

	
 
		/* Draw Highscore peepz */
 
		for (uint8 i = 0; i < lengthof(_highscore_table[0]); i++) {
 
			SetDParam(0, i + 1);
src/players.cpp
Show inline comments
 
@@ -62,15 +62,15 @@ void SetLocalPlayer(PlayerID new_player)
 

	
 
	_local_player = new_player;
 

	
 
	/* Do not update the patches if we are in the intro GUI */
 
	if (IsValidPlayer(new_player) && _game_mode != GM_MENU) {
 
		const Player *p = GetPlayer(new_player);
 
		_patches.autorenew        = p->engine_renew;
 
		_patches.autorenew_months = p->engine_renew_months;
 
		_patches.autorenew_money  = p->engine_renew_money;
 
		_settings.gui.autorenew        = p->engine_renew;
 
		_settings.gui.autorenew_months = p->engine_renew_months;
 
		_settings.gui.autorenew_money  = p->engine_renew_money;
 
		InvalidateWindow(WC_GAME_OPTIONS, 0);
 
	}
 
}
 

	
 
bool IsHumanPlayer(PlayerID pi)
 
{
 
@@ -538,15 +538,15 @@ Player *DoStartupNewPlayer(bool is_ai)
 
	p->inaugurated_year = _cur_year;
 
	RandomPlayerFaceBits(p->face, (GenderEthnicity)Random(), false); // create a random player face
 

	
 
	/* Engine renewal settings */
 
	p->engine_renew_list = NULL;
 
	p->renew_keep_length = false;
 
	p->engine_renew = _patches_newgame.autorenew;
 
	p->engine_renew_months = _patches_newgame.autorenew_months;
 
	p->engine_renew_money = _patches_newgame.autorenew_money;
 
	p->engine_renew = _settings_newgame.gui.autorenew;
 
	p->engine_renew_months = _settings_newgame.gui.autorenew_months;
 
	p->engine_renew_money = _settings_newgame.gui.autorenew_money;
 

	
 
	GeneratePresidentName(p);
 

	
 
	InvalidateWindow(WC_GRAPH_LEGEND, 0);
 
	InvalidateWindow(WC_TOOLBAR_MENU, 0);
 
	InvalidateWindow(WC_CLIENT_LIST, 0);
 
@@ -627,13 +627,13 @@ void PlayersYearlyLoop()
 
			memmove(&p->yearly_expenses[1], &p->yearly_expenses[0], sizeof(p->yearly_expenses) - sizeof(p->yearly_expenses[0]));
 
			memset(&p->yearly_expenses[0], 0, sizeof(p->yearly_expenses[0]));
 
			InvalidateWindow(WC_FINANCES, p->index);
 
		}
 
	}
 

	
 
	if (_patches.show_finances && _local_player != PLAYER_SPECTATOR) {
 
	if (_settings.gui.show_finances && _local_player != PLAYER_SPECTATOR) {
 
		ShowPlayerFinances(_local_player);
 
		p = GetPlayer(_local_player);
 
		if (p->num_valid_stat_ent > 5 && p->old_economy[0].performance_history < p->old_economy[4].performance_history) {
 
			SndPlayFx(SND_01_BAD_YEAR);
 
		} else {
 
			SndPlayFx(SND_00_GOOD_YEAR);
 
@@ -692,39 +692,39 @@ CommandCost CmdSetAutoReplace(TileIndex 
 
		case 0:
 
			if (p->engine_renew == HasBit(p2, 0)) return CMD_ERROR;
 

	
 
			if (flags & DC_EXEC) {
 
				p->engine_renew = HasBit(p2, 0);
 
				if (IsLocalPlayer()) {
 
					_patches.autorenew = p->engine_renew;
 
					_settings.gui.autorenew = p->engine_renew;
 
					InvalidateWindow(WC_GAME_OPTIONS, 0);
 
				}
 
			}
 
			break;
 

	
 
		case 1:
 
			if (Clamp((int16)p2, -12, 12) != (int16)p2) return CMD_ERROR;
 
			if (p->engine_renew_months == (int16)p2) return CMD_ERROR;
 

	
 
			if (flags & DC_EXEC) {
 
				p->engine_renew_months = (int16)p2;
 
				if (IsLocalPlayer()) {
 
					_patches.autorenew_months = p->engine_renew_months;
 
					_settings.gui.autorenew_months = p->engine_renew_months;
 
					InvalidateWindow(WC_GAME_OPTIONS, 0);
 
				}
 
			}
 
			break;
 

	
 
		case 2:
 
			if (ClampU(p2, 0, 2000000) != p2) return CMD_ERROR;
 
			if (p->engine_renew_money == p2) return CMD_ERROR;
 

	
 
			if (flags & DC_EXEC) {
 
				p->engine_renew_money = p2;
 
				if (IsLocalPlayer()) {
 
					_patches.autorenew_money = p->engine_renew_money;
 
					_settings.gui.autorenew_money = p->engine_renew_money;
 
					InvalidateWindow(WC_GAME_OPTIONS, 0);
 
				}
 
			}
 
			break;
 

	
 
		case 3: {
 
@@ -768,15 +768,15 @@ CommandCost CmdSetAutoReplace(TileIndex 
 
			if (flags & DC_EXEC) {
 
				p->engine_renew = HasBit(p1, 15);
 
				p->engine_renew_months = (int16)GB(p1, 16, 16);
 
				p->engine_renew_money = p2;
 

	
 
				if (IsLocalPlayer()) {
 
					_patches.autorenew = p->engine_renew;
 
					_patches.autorenew_months = p->engine_renew_months;
 
					_patches.autorenew_money = p->engine_renew_money;
 
					_settings.gui.autorenew = p->engine_renew;
 
					_settings.gui.autorenew_months = p->engine_renew_months;
 
					_settings.gui.autorenew_money = p->engine_renew_money;
 
					InvalidateWindow(WC_GAME_OPTIONS, 0);
 
				}
 
			}
 
			break;
 

	
 
		case 5:
 
@@ -873,14 +873,14 @@ CommandCost CmdPlayerCtrl(TileIndex tile
 
			MarkWholeScreenDirty();
 
		}
 

	
 
		/* Now that we have a new player, broadcast its autorenew settings to
 
		 * all clients so everything is in sync */
 
		DoCommand(0,
 
			(_patches.autorenew << 15 ) | (_patches.autorenew_months << 16) | 4,
 
			_patches.autorenew_money,
 
			(_settings.gui.autorenew << 15 ) | (_settings.gui.autorenew_months << 16) | 4,
 
			_settings.gui.autorenew_money,
 
			DC_EXEC,
 
			CMD_SET_AUTOREPLACE
 
		);
 

	
 
#ifdef ENABLE_NETWORK
 
		if (_network_server) {
 
@@ -1119,13 +1119,13 @@ void LoadFromHighScore()
 
			}
 
		}
 
		fclose(fp);
 
	}
 

	
 
	/* Initialize end of game variable (when to show highscore chart) */
 
	_patches.ending_year = 2051;
 
	_settings.gui.ending_year = 2051;
 
}
 

	
 
/* Save/load of players */
 
static const SaveLoad _player_desc[] = {
 
	    SLE_VAR(Player, name_2,          SLE_UINT32),
 
	    SLE_VAR(Player, name_1,          SLE_STRINGID),
src/rail_cmd.cpp
Show inline comments
 
@@ -289,13 +289,13 @@ static CommandCost CheckRailSlope(Slope 
 
	}
 

	
 
	Foundation f_new = GetRailFoundation(tileh, rail_bits | existing);
 

	
 
	/* check track/slope combination */
 
	if ((f_new == FOUNDATION_INVALID) ||
 
	    ((f_new != FOUNDATION_NONE) && (!_patches.build_on_slopes || _is_old_ai_player))
 
	    ((f_new != FOUNDATION_NONE) && (!_settings.construction.build_on_slopes || _is_old_ai_player))
 
	   ) return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION);
 

	
 
	Foundation f_old = GetRailFoundation(tileh, existing);
 
	return CommandCost(EXPENSES_CONSTRUCTION, f_new != f_old ? _price.terraform : (Money)0);
 
}
 

	
 
@@ -753,13 +753,13 @@ CommandCost CmdBuildTrainDepot(TileIndex
 
	 * 3) the tile is steep i.e. spans two height levels
 
	 * 4) the exit points in the wrong direction
 
	 */
 

	
 
	if (tileh != SLOPE_FLAT && (
 
				_is_old_ai_player ||
 
				!_patches.build_on_slopes ||
 
				!_settings.construction.build_on_slopes ||
 
				IsSteepSlope(tileh) ||
 
				!CanBuildDepotByTileh(dir, tileh)
 
			)) {
 
		return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
 
	}
 

	
 
@@ -1221,13 +1221,13 @@ CommandCost CmdConvertRail(TileIndex til
 
			}
 

	
 
			/* Original railtype we are converting from */
 
			RailType type = GetRailType(tile);
 

	
 
			/* Converting to the same type or converting 'hidden' elrail -> rail */
 
			if (type == totype || (_patches.disable_elrails && totype == RAILTYPE_RAIL && type == RAILTYPE_ELECTRIC)) continue;
 
			if (type == totype || (_settings.vehicle.disable_elrails && totype == RAILTYPE_RAIL && type == RAILTYPE_ELECTRIC)) continue;
 

	
 
			/* Trying to convert other's rail */
 
			if (!CheckTileOwnership(tile)) continue;
 

	
 
			/* Vehicle on the tile when not converting Rail <-> ElRail
 
			 * Tunnels and bridges have special check later */
 
@@ -1417,13 +1417,13 @@ static uint GetSaveSlopeZ(uint x, uint y
 
	}
 
	return GetSlopeZ(x, y);
 
}
 

	
 
static void DrawSingleSignal(TileIndex tile, Track track, byte condition, uint image, uint pos)
 
{
 
	bool side = (_opt.road_side != 0) && _patches.signal_side;
 
	bool side = (_opt.road_side != 0) && _settings.construction.signal_side;
 
	static const Point SignalPositions[2][12] = {
 
		{      /* Signals on the left side */
 
		/*  LEFT      LEFT      RIGHT     RIGHT     UPPER     UPPER */
 
			{ 8,  5}, {14,  1}, { 1, 14}, { 9, 11}, { 1,  0}, { 3, 10},
 
		/*  LOWER     LOWER     X         X         Y         Y     */
 
			{11,  4}, {14, 14}, {11,  3}, { 4, 13}, { 3,  4}, {11, 13}
 
@@ -2326,13 +2326,13 @@ static VehicleEnterTileStatus VehicleEnt
 
 * @param z_new New TileZ.
 
 * @param tileh_new New TileSlope.
 
 * @param rail_bits Trackbits.
 
 */
 
static CommandCost TestAutoslopeOnRailTile(TileIndex tile, uint flags, uint z_old, Slope tileh_old, uint z_new, Slope tileh_new, TrackBits rail_bits)
 
{
 
	if (!_patches.build_on_slopes || !AutoslopeEnabled()) return CMD_ERROR;
 
	if (!_settings.construction.build_on_slopes || !AutoslopeEnabled()) return CMD_ERROR;
 

	
 
	/* Is the slope-rail_bits combination valid in general? I.e. is it save to call GetRailFoundation() ? */
 
	if (CmdFailed(CheckRailSlope(tileh_new, rail_bits, TRACK_BIT_NONE, tile))) return CMD_ERROR;
 

	
 
	/* Get the slopes on top of the foundations */
 
	z_old += ApplyFoundationToSlope(GetRailFoundation(tileh_old, rail_bits), &tileh_old);
 
@@ -2402,13 +2402,13 @@ static CommandCost TerraformTile_Track(T
 
		/* Make the ground dirty */
 
		if ((flags & DC_EXEC) != 0) SetRailGroundType(tile, RAIL_GROUND_BARREN);
 

	
 
		/* allow terraforming */
 
		return CommandCost(EXPENSES_CONSTRUCTION, was_water ? _price.clear_water : (Money)0);
 
	} else {
 
		if (_patches.build_on_slopes && AutoslopeEnabled()) {
 
		if (_settings.construction.build_on_slopes && AutoslopeEnabled()) {
 
			switch (GetRailTileType(tile)) {
 
				case RAIL_TILE_WAYPOINT: {
 
					CommandCost cost = TestAutoslopeOnRailTile(tile, flags, z_old, tileh_old, z_new, tileh_new, GetRailWaypointBits(tile));
 
					if (!CmdFailed(cost)) return cost; // allow autoslope
 
					break;
 
				}
src/rail_gui.cpp
Show inline comments
 
@@ -179,13 +179,13 @@ static void PlaceRail_Station(TileIndex 
 
{
 
	if (_remove_button_clicked) {
 
		VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED, DDSP_REMOVE_STATION);
 
		VpSetPlaceSizingLimit(-1);
 
	} else if (_railstation.dragdrop) {
 
		VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED, DDSP_BUILD_STATION);
 
		VpSetPlaceSizingLimit(_patches.station_spread);
 
		VpSetPlaceSizingLimit(_settings.station.station_spread);
 
	} else {
 
		DoCommandP(tile,
 
				_railstation.orientation | (_railstation.numtracks << 8) | (_railstation.platlength << 16) | (_ctrl_pressed << 24),
 
				_cur_railtype | (_railstation.station_class << 8) | (_railstation.station_type << 16), CcStation,
 
				CMD_BUILD_RAILROAD_STATION | CMD_NO_WATER | CMD_MSG(STR_100F_CAN_T_BUILD_RAILROAD_STATION));
 
	}
 
@@ -224,13 +224,13 @@ static void GenericPlaceSignals(TileInde
 
			SB(p1, 3, 1, _ctrl_pressed);
 
			SB(p1, 4, 1, _cur_signal_variant);
 
			SB(p1, 5, 2, _cur_signal_type);
 
			SB(p1, 7, 1, _convert_signal_button);
 
		} else {
 
			SB(p1, 3, 1, _ctrl_pressed);
 
			SB(p1, 4, 1, (_cur_year < _patches.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC));
 
			SB(p1, 4, 1, (_cur_year < _settings.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC));
 
			SB(p1, 5, 2, SIGTYPE_NORMAL);
 
			SB(p1, 7, 1, 0);
 
		}
 

	
 
		DoCommandP(tile, p1, 0, CcPlaySound1E, CMD_BUILD_SIGNALS |
 
			CMD_MSG((w != NULL && _convert_signal_button) ? STR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE : STR_1010_CAN_T_BUILD_SIGNALS_HERE));
 
@@ -426,13 +426,13 @@ static void BuildRailClick_Station(Windo
 
 * Start ShowSignalBuilder() and/or HandleAutoSignalPlacement().
 
 * @param w Build-rail toolbar window
 
 * @see BuildRailToolbWndProc()
 
 */
 
static void BuildRailClick_AutoSignals(Window *w)
 
{
 
	if (_patches.enable_signal_gui != _ctrl_pressed) {
 
	if (_settings.gui.enable_signal_gui != _ctrl_pressed) {
 
		if (HandlePlacePushButton(w, RTW_BUILD_SIGNALS, ANIMCURSOR_BUILDSIGNALS, VHM_RECT, PlaceRail_AutoSignals)) ShowSignalBuilder(w);
 
	} else {
 
		HandlePlacePushButton(w, RTW_BUILD_SIGNALS, ANIMCURSOR_BUILDSIGNALS, VHM_RECT, PlaceRail_AutoSignals);
 
	}
 
}
 

	
 
@@ -481,13 +481,13 @@ static void BuildRailClick_Remove(Window
 
			if (!_railstation.dragdrop) {
 
				int x = _railstation.numtracks;
 
				int y = _railstation.platlength;
 
				if (_railstation.orientation == 0) Swap(x, y);
 
				SetTileSelectSize(x, y);
 
			} else {
 
				VpSetPlaceSizingLimit(_patches.station_spread);
 
				VpSetPlaceSizingLimit(_settings.station.station_spread);
 
			}
 
		}
 
	}
 
}
 

	
 
/**
 
@@ -544,21 +544,21 @@ static void HandleAutoSignalPlacement()
 

	
 
	if (w != NULL) {
 
		/* signal GUI is used */
 
		SB(p2,  3, 1, 0);
 
		SB(p2,  4, 1, _cur_signal_variant);
 
		SB(p2,  6, 1, _ctrl_pressed);
 
		SB(p2, 24, 8, _patches.drag_signals_density);
 
		SB(p2, 24, 8, _settings.gui.drag_signals_density);
 
	} else {
 
		SB(p2,  3, 1, 0);
 
		SB(p2,  4, 1, (_cur_year < _patches.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC));
 
		SB(p2,  4, 1, (_cur_year < _settings.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC));
 
		SB(p2,  6, 1, _ctrl_pressed);
 
		SB(p2, 24, 8, _patches.drag_signals_density);
 
		SB(p2, 24, 8, _settings.gui.drag_signals_density);
 
	}
 

	
 
	/* _patches.drag_signals_density is given as a parameter such that each user
 
	/* _settings.gui.drag_signals_density is given as a parameter such that each user
 
	 * in a network game can specify his/her own signal density */
 
	DoCommandP(
 
		TileVirtXY(thd->selstart.x, thd->selstart.y),
 
		TileVirtXY(thd->selend.x, thd->selend.y),
 
		p2,
 
		CcPlaySound1E,
 
@@ -614,18 +614,18 @@ static const uint16 _rail_keycodes[] = {
 
struct BuildRailToolbarWindow : Window {
 
	BuildRailToolbarWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
 
	{
 
		this->DisableWidget(RTW_REMOVE);
 

	
 
		this->FindWindowPlacementAndResize(desc);
 
		if (_patches.link_terraform_toolbar) ShowTerraformToolbar(this);
 
		if (_settings.gui.link_terraform_toolbar) ShowTerraformToolbar(this);
 
	}
 

	
 
	~BuildRailToolbarWindow()
 
	{
 
		if (_patches.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0);
 
		if (_settings.gui.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0);
 
	}
 

	
 
	void UpdateRemoveWidgetStatus(int clicked_widget)
 
	{
 
		switch (clicked_widget) {
 
			case RTW_REMOVE:
 
@@ -1005,19 +1005,19 @@ public:
 
			int y = _railstation.platlength;
 
			if (_railstation.orientation == 0) Swap(x, y);
 
			if (!_remove_button_clicked)
 
				SetTileSelectSize(x, y);
 
		}
 

	
 
		int rad = (_patches.modified_catchment) ? CA_TRAIN : CA_UNMODIFIED;
 
		int rad = (_settings.station.modified_catchment) ? CA_TRAIN : CA_UNMODIFIED;
 

	
 
		if (_station_show_coverage)
 
			SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
 

	
 
		for (uint bits = 0; bits < 7; bits++) {
 
			bool disable = bits >= _patches.station_spread;
 
			bool disable = bits >= _settings.station.station_spread;
 
			if (statspec == NULL) {
 
				this->SetWidgetDisabledState(bits + BRSW_PLATFORM_NUM_1, disable);
 
				this->SetWidgetDisabledState(bits + BRSW_PLATFORM_LEN_1, disable);
 
			} else {
 
				this->SetWidgetDisabledState(bits + BRSW_PLATFORM_NUM_1, HasBit(statspec->disallowed_platforms, bits) || disable);
 
				this->SetWidgetDisabledState(bits + BRSW_PLATFORM_LEN_1, HasBit(statspec->disallowed_lengths,   bits) || disable);
 
@@ -1387,14 +1387,14 @@ public:
 
	virtual void OnPaint()
 
	{
 
		this->LowerWidget((_cur_signal_variant == SIG_ELECTRIC ? BSW_ELECTRIC_NORM : BSW_SEMAPHORE_NORM) + _cur_signal_type);
 

	
 
		this->SetWidgetLoweredState(BSW_CONVERT, _convert_signal_button);
 

	
 
		this->SetWidgetDisabledState(BSW_DRAG_SIGNALS_DENSITY_DECREASE, _patches.drag_signals_density == 1);
 
		this->SetWidgetDisabledState(BSW_DRAG_SIGNALS_DENSITY_INCREASE, _patches.drag_signals_density == 20);
 
		this->SetWidgetDisabledState(BSW_DRAG_SIGNALS_DENSITY_DECREASE, _settings.gui.drag_signals_density == 1);
 
		this->SetWidgetDisabledState(BSW_DRAG_SIGNALS_DENSITY_INCREASE, _settings.gui.drag_signals_density == 20);
 

	
 
		this->DrawWidgets();
 

	
 
		/* The 'hardcoded' off sets are needed because they are reused sprites. */
 
		this->DrawSignalSprite(BSW_SEMAPHORE_NORM,  SPR_IMG_SIGNAL_SEMAPHORE_NORM,   0, 12); // xsize of sprite + 1 ==  9
 
		this->DrawSignalSprite(BSW_SEMAPHORE_ENTRY, SPR_IMG_SIGNAL_SEMAPHORE_ENTRY, -1, 13); // xsize of sprite + 1 == 10
 
@@ -1403,13 +1403,13 @@ public:
 
		this->DrawSignalSprite(BSW_ELECTRIC_NORM,   SPR_IMG_SIGNAL_ELECTRIC_NORM,   -1,  4);
 
		this->DrawSignalSprite(BSW_ELECTRIC_ENTRY,  SPR_IMG_SIGNAL_ELECTRIC_ENTRY,  -2,  6);
 
		this->DrawSignalSprite(BSW_ELECTRIC_EXIT,   SPR_IMG_SIGNAL_ELECTRIC_EXIT,   -2,  6);
 
		this->DrawSignalSprite(BSW_ELECTRIC_COMBO,  SPR_IMG_SIGNAL_ELECTRIC_COMBO,  -2,  6);
 

	
 
		/* Draw dragging signal density value in the BSW_DRAG_SIGNALS_DENSITY widget */
 
		SetDParam(0, _patches.drag_signals_density);
 
		SetDParam(0, _settings.gui.drag_signals_density);
 
		DrawStringCentered(this->widget[BSW_DRAG_SIGNALS_DENSITY].left + (this->widget[BSW_DRAG_SIGNALS_DENSITY].right -
 
				this->widget[BSW_DRAG_SIGNALS_DENSITY].left) / 2 + 1,
 
				this->widget[BSW_DRAG_SIGNALS_DENSITY].top + 2, STR_JUST_INT, TC_ORANGE);
 
	}
 

	
 
	virtual void OnClick(Point pt, int widget)
 
@@ -1431,21 +1431,21 @@ public:
 

	
 
			case BSW_CONVERT:
 
				_convert_signal_button = !_convert_signal_button;
 
				break;
 

	
 
			case BSW_DRAG_SIGNALS_DENSITY_DECREASE:
 
				if (_patches.drag_signals_density > 1) {
 
					_patches.drag_signals_density--;
 
				if (_settings.gui.drag_signals_density > 1) {
 
					_settings.gui.drag_signals_density--;
 
					SetWindowDirty(FindWindowById(WC_GAME_OPTIONS, 0));
 
				}
 
				break;
 

	
 
			case BSW_DRAG_SIGNALS_DENSITY_INCREASE:
 
				if (_patches.drag_signals_density < 20) {
 
					_patches.drag_signals_density++;
 
				if (_settings.gui.drag_signals_density < 20) {
 
					_settings.gui.drag_signals_density++;
 
					SetWindowDirty(FindWindowById(WC_GAME_OPTIONS, 0));
 
				}
 
				break;
 

	
 
			default: break;
 
		}
 
@@ -1698,13 +1698,13 @@ void ReinitGuiAfterToggleElrail(bool dis
 
/** Set the initial (default) railtype to use */
 
static void SetDefaultRailGui()
 
{
 
	if (_local_player == PLAYER_SPECTATOR || !IsValidPlayer(_local_player)) return;
 

	
 
	extern RailType _last_built_railtype;
 
	RailType rt = (RailType)_patches.default_rail_type;
 
	RailType rt = (RailType)_settings.gui.default_rail_type;
 
	if (rt >= RAILTYPE_END) {
 
		if (rt == RAILTYPE_END + 2) {
 
			/* Find the most used rail type */
 
			RailType count[RAILTYPE_END];
 
			memset(count, 0, sizeof(count));
 
			for (TileIndex t = 0; t < MapSize(); t++) {
 
@@ -1750,13 +1750,13 @@ static void SetDefaultRailGui()
 
 * to the one adequate to current year.
 
 * @param 0 needed to be called when a patch setting changes
 
 * @return success, needed for patch settings
 
 */
 
int32 ResetSignalVariant(int32 = 0)
 
{
 
	SignalVariant new_variant = (_cur_year < _patches.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC);
 
	SignalVariant new_variant = (_cur_year < _settings.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC);
 

	
 
	if (new_variant != _cur_signal_variant) {
 
		Window *w = FindWindowById(WC_BUILD_SIGNAL, 0);
 
		if (w != NULL) {
 
			w->SetDirty();
 
			w->RaiseWidget((_cur_signal_variant == SIG_ELECTRIC ? BSW_ELECTRIC_NORM : BSW_SEMAPHORE_NORM) + _cur_signal_type);
src/road_cmd.cpp
Show inline comments
 
@@ -179,13 +179,13 @@ bool CheckAllowRemoveRoad(TileIndex tile
 

	
 
	int rating_decrease = RATING_ROAD_DOWN_STEP_EDGE;
 
	/* If 0 or 1 bits are set in n, or if no bits that match the bits to remove,
 
	 * then allow it */
 
	if (KillFirstBit(n) != ROAD_NONE && (n & remove) != ROAD_NONE) {
 
		/* you can remove all kind of roads with extra dynamite */
 
		if (!_patches.extra_dynamite) {
 
		if (!_settings.construction.extra_dynamite) {
 
			SetDParam(0, t->index);
 
			_error_message = STR_2009_LOCAL_AUTHORITY_REFUSES;
 
			return false;
 
		}
 
		rating_decrease = RATING_ROAD_DOWN_STEP_INNER;
 
	}
 
@@ -276,13 +276,13 @@ static CommandCost RemoveRoad(TileIndex 
 
			/* Autocomplete to a straight road
 
			 * @li on steep slopes
 
			 * @li if the bits of the other roadtypes result in another foundation
 
			 * @li if build on slopes is disabled */
 
			if (IsSteepSlope(tileh) || (IsStraightRoad(other) &&
 
					(other & _invalid_tileh_slopes_road[0][tileh & SLOPE_ELEVATED]) != ROAD_NONE) ||
 
					(tileh != SLOPE_FLAT && !_patches.build_on_slopes)) {
 
					(tileh != SLOPE_FLAT && !_settings.construction.build_on_slopes)) {
 
				pieces |= MirrorRoadBits(pieces);
 
			}
 

	
 
			/* limit the bits to delete to the existing bits. */
 
			pieces &= present;
 
			if (pieces == ROAD_NONE) return CMD_ERROR;
 
@@ -416,13 +416,13 @@ static CommandCost CheckRoadSlope(Slope 
 
	}
 

	
 
	/* Save the merge of all bits of the current type */
 
	RoadBits type_bits = existing | *pieces;
 

	
 
	/* Roads on slopes */
 
	if (_patches.build_on_slopes && (_invalid_tileh_slopes_road[0][tileh] & (other | type_bits)) == ROAD_NONE) {
 
	if (_settings.construction.build_on_slopes && (_invalid_tileh_slopes_road[0][tileh] & (other | type_bits)) == ROAD_NONE) {
 

	
 
		/* If we add leveling we've got to pay for it */
 
		if ((other | existing) == ROAD_NONE) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
 

	
 
		return CommandCost();
 
	}
 
@@ -436,13 +436,13 @@ static CommandCost CheckRoadSlope(Slope 
 
			(_invalid_tileh_slopes_road[1][tileh] & (other | type_bits)) == ROAD_NONE) {
 

	
 
		/* Slopes with foundation ? */
 
		if (IsSlopeWithOneCornerRaised(tileh)) {
 

	
 
			/* Prevent build on slopes if it isn't allowed */
 
			if (_patches.build_on_slopes) {
 
			if (_settings.construction.build_on_slopes) {
 

	
 
				/* If we add foundation we've got to pay for it */
 
				if ((other | existing) == ROAD_NONE) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
 

	
 
				return CommandCost();
 
			}
 
@@ -591,13 +591,13 @@ do_clear:;
 

	
 
	if (other_bits != pieces) {
 
		/* Check the foundation/slopes when adding road/tram bits */
 
		CommandCost ret = CheckRoadSlope(tileh, &pieces, existing, other_bits);
 
		/* Return an error if we need to build a foundation (ret != 0) but the
 
		 * current patch-setting is turned off (or stupid AI@work) */
 
		if (CmdFailed(ret) || (ret.GetCost() != 0 && !_patches.build_on_slopes)) {
 
		if (CmdFailed(ret) || (ret.GetCost() != 0 && !_settings.construction.build_on_slopes)) {
 
			return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION);
 
		}
 
		cost.AddCost(ret);
 
	}
 

	
 
	if (IsTileType(tile, MP_ROAD)) {
 
@@ -846,13 +846,13 @@ CommandCost CmdBuildRoadDepot(TileIndex 
 
	RoadType rt = (RoadType)GB(p1, 2, 2);
 

	
 
	if (!IsValidRoadType(rt) || !ValParamRoadType(rt)) return CMD_ERROR;
 

	
 
	Slope tileh = GetTileSlope(tile, NULL);
 
	if (tileh != SLOPE_FLAT && (
 
				!_patches.build_on_slopes ||
 
				!_settings.construction.build_on_slopes ||
 
				IsSteepSlope(tileh) ||
 
				!CanBuildDepotByTileh(dir, tileh)
 
			)) {
 
		return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
 
	}
 

	
 
@@ -1356,13 +1356,13 @@ static void TileLoop_Road(TileIndex tile
 
			SetRoadside(tile, cur_rs);
 
			MarkTileDirtyByTile(tile);
 
		}
 
	} else if (IncreaseRoadWorksCounter(tile)) {
 
		TerminateRoadWorks(tile);
 

	
 
		if (_patches.mod_road_rebuild) {
 
		if (_settings.economy.mod_road_rebuild) {
 
			/* Generate a nicer town surface */
 
			const RoadBits old_rb = GetAnyRoadBits(tile, ROADTYPE_ROAD);
 
			const RoadBits new_rb = CleanUpRoadBits(tile, old_rb);
 

	
 
			if (old_rb != new_rb) {
 
				RemoveRoad(tile, DC_EXEC | DC_AUTO | DC_NO_WATER, (old_rb ^ new_rb), ROADTYPE_ROAD, true);
 
@@ -1567,13 +1567,13 @@ static void ChangeTileOwner_Road(TileInd
 
		}
 
	}
 
}
 

	
 
static CommandCost TerraformTile_Road(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new)
 
{
 
	if (_patches.build_on_slopes && AutoslopeEnabled()) {
 
	if (_settings.construction.build_on_slopes && AutoslopeEnabled()) {
 
		switch (GetRoadTileType(tile)) {
 
			case ROAD_TILE_CROSSING:
 
				if (!IsSteepSlope(tileh_new) && (GetTileMaxZ(tile) == z_new + GetSlopeMaxZ(tileh_new)) && HasBit(VALID_LEVEL_CROSSING_SLOPES, tileh_new)) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
 
				break;
 

	
 
			case ROAD_TILE_DEPOT:
src/road_gui.cpp
Show inline comments
 
@@ -406,18 +406,18 @@ struct BuildRoadToolbarWindow : Window {
 
		this->SetWidgetsDisabledState(true,
 
			RTW_REMOVE,
 
			RTW_ONE_WAY,
 
			WIDGET_LIST_END);
 

	
 
		this->FindWindowPlacementAndResize(desc);
 
		if (_patches.link_terraform_toolbar) ShowTerraformToolbar(this);
 
		if (_settings.gui.link_terraform_toolbar) ShowTerraformToolbar(this);
 
	}
 

	
 
	~BuildRoadToolbarWindow()
 
	{
 
		if (_patches.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0);
 
		if (_settings.gui.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0);
 
	}
 

	
 
	/**
 
	 * Update the remove button lowered state of the road toolbar
 
	 *
 
	 * @param clicked_widget The widget which the player clicked just now
 
@@ -836,13 +836,13 @@ public:
 

	
 
	virtual void OnPaint()
 
	{
 
		this->DrawWidgets();
 

	
 
		if (_station_show_coverage) {
 
			int rad = _patches.modified_catchment ? CA_TRUCK /* = CA_BUS */ : CA_UNMODIFIED;
 
			int rad = _settings.station.modified_catchment ? CA_TRUCK /* = CA_BUS */ : CA_UNMODIFIED;
 
			SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
 
		} else {
 
			SetTileSelectSize(1, 1);
 
		}
 

	
 
		StationType st = (this->window_class == WC_BUS_STATION) ? STATION_BUS : STATION_TRUCK;
src/roadveh_cmd.cpp
Show inline comments
 
@@ -202,13 +202,13 @@ CommandCost CmdBuildRoadVeh(TileIndex ti
 
	}
 

	
 
	v = vl[0];
 

	
 
	/* find the first free roadveh id */
 
	unit_num = HasBit(p2, 0) ? 0 : GetFreeUnitNumber(VEH_ROAD);
 
	if (unit_num > _patches.max_roadveh)
 
	if (unit_num > _settings.vehicle.max_roadveh)
 
		return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
 

	
 
	if (flags & DC_EXEC) {
 
		int x;
 
		int y;
 

	
 
@@ -254,13 +254,13 @@ CommandCost CmdBuildRoadVeh(TileIndex ti
 
		v->reliability_spd_dec = e->reliability_spd_dec;
 
		v->max_age = e->lifelength * 366;
 
		_new_vehicle_id = v->index;
 

	
 
		v->name = NULL;
 

	
 
		v->service_interval = _patches.servint_roadveh;
 
		v->service_interval = _settings.vehicle.servint_roadveh;
 

	
 
		v->date_of_last_service = _date;
 
		v->build_year = _cur_year;
 

	
 
		v->cur_image = 0xC15;
 
		v->random_bits = VehicleRandomBits();
 
@@ -416,13 +416,13 @@ static bool EnumRoadSignalFindDepot(Tile
 
	}
 
	return false;
 
}
 

	
 
static const Depot* FindClosestRoadDepot(const Vehicle* v)
 
{
 
	switch (_patches.pathfinder_for_roadvehs) {
 
	switch (_settings.pf.pathfinder_for_roadvehs) {
 
		case VPF_YAPF: /* YAPF */
 
			return YapfFindNearestRoadDepot(v);
 

	
 
		case VPF_NPF: { /* NPF */
 
			/* See where we are now */
 
			Trackdir trackdir = GetVehicleTrackdir(v);
 
@@ -860,13 +860,13 @@ static bool RoadVehAccelerate(Vehicle *v
 
		spd = min(spd, GetBridgeSpec(GetBridgeType(v->tile))->speed * 2);
 
	}
 

	
 
	/* updates statusbar only if speed have changed to save CPU time */
 
	if (spd != v->cur_speed) {
 
		v->cur_speed = spd;
 
		if (_patches.vehicle_speed) {
 
		if (_settings.gui.vehicle_speed) {
 
			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
		}
 
	}
 

	
 
	/* Decrease somewhat when turning */
 
	if (!(v->direction & 1)) spd = spd * 3 >> 2;
 
@@ -1082,13 +1082,13 @@ static Trackdir RoadFindPathToDest(Vehic
 

	
 
			if (GetRoadStopType(tile) != rstype) {
 
				/* Wrong station type */
 
				trackdirs = TRACKDIR_BIT_NONE;
 
			} else {
 
				/* Proper station type, check if there is free loading bay */
 
				if (!_patches.roadveh_queue && IsStandardRoadStopTile(tile) &&
 
				if (!_settings.pf.roadveh_queue && IsStandardRoadStopTile(tile) &&
 
						!GetRoadStopByTile(tile, rstype)->HasFreeBay()) {
 
					/* Station is full and RV queuing is off */
 
					trackdirs = TRACKDIR_BIT_NONE;
 
				}
 
			}
 
		}
 
@@ -1121,13 +1121,13 @@ static Trackdir RoadFindPathToDest(Vehic
 

	
 
	/* Only one track to choose between? */
 
	if (KillFirstBit(trackdirs) == TRACKDIR_BIT_NONE) {
 
		return_track(FindFirstBit2x64(trackdirs));
 
	}
 

	
 
	switch (_patches.pathfinder_for_roadvehs) {
 
	switch (_settings.pf.pathfinder_for_roadvehs) {
 
		case VPF_YAPF: { /* YAPF */
 
			Trackdir trackdir = YapfChooseRoadTrack(v, tile, enterdir);
 
			if (trackdir != INVALID_TRACKDIR) return_track(trackdir);
 
			return_track(PickRandomBit(trackdirs));
 
		} break;
 

	
 
@@ -1208,13 +1208,13 @@ found_best_track:;
 

	
 
	return best_track;
 
}
 

	
 
static uint RoadFindPathToStop(const Vehicle *v, TileIndex tile)
 
{
 
	if (_patches.pathfinder_for_roadvehs == VPF_YAPF) {
 
	if (_settings.pf.pathfinder_for_roadvehs == VPF_YAPF) {
 
		/* use YAPF */
 
		return YapfRoadVehDistanceToTile(v, tile);
 
	}
 

	
 
	/* use NPF */
 
	Trackdir trackdir = GetVehicleTrackdir(v);
 
@@ -1884,13 +1884,13 @@ void RoadVehicle::Tick()
 
	}
 
}
 

	
 
static void CheckIfRoadVehNeedsService(Vehicle *v)
 
{
 
	/* If we already got a slot at a stop, use that FIRST, and go to a depot later */
 
	if (v->u.road.slot != NULL || _patches.servint_roadveh == 0 || !v->NeedsAutomaticServicing()) return;
 
	if (v->u.road.slot != NULL || _settings.vehicle.servint_roadveh == 0 || !v->NeedsAutomaticServicing()) return;
 
	if (v->IsInDepot()) {
 
		VehicleServiceInDepot(v);
 
		return;
 
	}
 

	
 
	/* XXX If we already have a depot order, WHY do we search over and over? */
src/saveload.cpp
Show inline comments
 
@@ -1773,13 +1773,13 @@ SaveOrLoadResult SaveOrLoad(const char *
 

	
 
		/* A saver/loader exception!! reinitialize all variables to prevent crash! */
 
		return (mode == SL_LOAD) ? SL_REINIT : SL_ERROR;
 
	}
 
}
 

	
 
/** Do a save when exiting the game (patch option) _patches.autosave_on_exit */
 
/** Do a save when exiting the game (patch option) _settings.gui.autosave_on_exit */
 
void DoExitSave()
 
{
 
	SaveOrLoad("exit.sav", SL_SAVE, AUTOSAVE_DIR);
 
}
 

	
 
#if 0
src/settings.cpp
Show inline comments
 
@@ -62,14 +62,14 @@
 
#include "blitter/factory.hpp"
 

	
 
#include "table/strings.h"
 

	
 
GameOptions _opt;
 
GameOptions _opt_newgame;
 
Patches _patches;
 
Patches _patches_newgame;
 
Settings _settings;
 
Settings _settings_newgame;
 

	
 
struct IniFile;
 
struct IniItem;
 
struct IniGroup;
 
struct SettingsMemoryPool;
 

	
 
@@ -340,12 +340,34 @@ static IniGroup *ini_getgroup(IniFile *i
 
	/* otherwise make a new one */
 
	group = ini_group_alloc(ini, name, len);
 
	group->comment = (char*)pool_strdup(&ini->pool, "\n", 1);
 
	return group;
 
}
 

	
 
static void ini_removegroup(IniFile *ini, const char *name)
 
{
 
	size_t len = strlen(name);
 
	IniGroup *prev = NULL;
 
	IniGroup *group;
 

	
 
	/* does it exist already? */
 
	for (group = ini->group; group != NULL; prev = group, group = group->next) {
 
		if (memcmp(group->name, name, len) == 0) {
 
			break;
 
		}
 
	}
 

	
 
	if (group == NULL) return;
 

	
 
	if (prev != NULL) {
 
		prev->next = prev->next->next;
 
	} else {
 
		ini->group = ini->group->next;
 
	}
 
}
 

	
 
/** lookup an item or make a new one */
 
static IniItem *ini_getitem(IniGroup *group, const char *name, bool create)
 
{
 
	IniItem *item;
 
	size_t len = strlen(name);
 

	
 
@@ -717,23 +739,35 @@ static void ini_load_settings(IniFile *i
 
	for (; sd->save.cmd != SL_END; sd++) {
 
		const SettingDescBase *sdb = &sd->desc;
 
		const SaveLoad        *sld = &sd->save;
 

	
 
		if (!SlIsObjectCurrentlyValid(sld->version_from, sld->version_to)) continue;
 

	
 
		/* XXX - wtf is this?? (group override?) */
 
		/* For patches.xx.yy load the settings from [xx] yy = ? */
 
		s = strchr(sdb->name, '.');
 
		if (s != NULL) {
 
			group = ini_getgroup(ini, sdb->name, s - sdb->name);
 
			s++;
 
		} else {
 
			s = sdb->name;
 
			group = group_def;
 
		}
 

	
 
		item = ini_getitem(group, s, false);
 
		if (item == NULL && group != group_def) {
 
			/* For patches.xx.yy load the settings from [patches] yy = ? in case the previous
 
			 * did not exist (e.g. loading old config files with a [patches] section */
 
			item = ini_getitem(group_def, s, false);
 
		}
 
		if (item == NULL) {
 
			/* For patches.xx.zz.yy load the settings from [zz] yy = ? in case the previous
 
			 * did not exist (e.g. loading old config files with a [yapf] section */
 
			const char *sc = strchr(s, '.');
 
			if (sc != NULL) item = ini_getitem(ini_getgroup(ini, s, sc - s), sc + 1, false);
 
		}
 

	
 
		p = (item == NULL) ? sdb->def : string_to_val(sdb, item->value);
 
		ptr = GetVariableAddress(object, sld);
 

	
 
		switch (sdb->cmd) {
 
		case SDT_BOOLX: /* All four are various types of (integer) numbers */
 
		case SDT_NUMX:
 
@@ -1117,13 +1151,13 @@ static int32 AiNew_PatchActive_Warning(i
 
}
 

	
 
static int32 Ai_In_Multiplayer_Warning(int32 p1)
 
{
 
	if (p1 == 1) {
 
		ShowErrorMessage(INVALID_STRING_ID, TEMP_AI_MULTIPLAYER, 0, 0);
 
		_patches.ainew_active = true;
 
		_settings.ai.ainew_active = true;
 
	}
 
	return 0;
 
}
 

	
 
static int32 PopulationInLabelActive(int32 p1)
 
{
 
@@ -1183,13 +1217,13 @@ static int32 UpdateConsists(int32 p1)
 
}
 

	
 
/* Check service intervals of vehicles, p1 is value of % or day based servicing */
 
static int32 CheckInterval(int32 p1)
 
{
 
	bool warning;
 
	const Patches *ptc = (_game_mode == GM_MENU) ? &_patches_newgame : &_patches;
 
	const VehicleSettings *ptc = (_game_mode == GM_MENU) ? &_settings_newgame.vehicle : &_settings.vehicle;
 

	
 
	if (p1) {
 
		warning = ( (IsInsideMM(ptc->servint_trains,   5, 90 + 1) || ptc->servint_trains   == 0) &&
 
								(IsInsideMM(ptc->servint_roadveh,  5, 90 + 1) || ptc->servint_roadveh  == 0) &&
 
								(IsInsideMM(ptc->servint_aircraft, 5, 90 + 1) || ptc->servint_aircraft == 0) &&
 
								(IsInsideMM(ptc->servint_ships,    5, 90 + 1) || ptc->servint_ships    == 0) );
 
@@ -1205,25 +1239,25 @@ static int32 CheckInterval(int32 p1)
 

	
 
	return InValidateDetailsWindow(0);
 
}
 

	
 
static int32 EngineRenewUpdate(int32 p1)
 
{
 
	DoCommandP(0, 0, _patches.autorenew, NULL, CMD_SET_AUTOREPLACE);
 
	DoCommandP(0, 0, _settings.gui.autorenew, NULL, CMD_SET_AUTOREPLACE);
 
	return 0;
 
}
 

	
 
static int32 EngineRenewMonthsUpdate(int32 p1)
 
{
 
	DoCommandP(0, 1, _patches.autorenew_months, NULL, CMD_SET_AUTOREPLACE);
 
	DoCommandP(0, 1, _settings.gui.autorenew_months, NULL, CMD_SET_AUTOREPLACE);
 
	return 0;
 
}
 

	
 
static int32 EngineRenewMoneyUpdate(int32 p1)
 
{
 
	DoCommandP(0, 2, _patches.autorenew_money, NULL, CMD_SET_AUTOREPLACE);
 
	DoCommandP(0, 2, _settings.gui.autorenew_money, NULL, CMD_SET_AUTOREPLACE);
 
	return 0;
 
}
 

	
 
static int32 RealisticAccelerationChanged(int32 p1)
 
{
 
	Vehicle *v;
 
@@ -1249,15 +1283,15 @@ static int32 DragSignalsDensityChanged(i
 
 * he can easily remove them himself. This would create less confusion
 
 * @param p1 unused
 
 * @return always 0
 
 */
 
static int32 CheckTownLayout(int32 p1)
 
{
 
	if (_patches.town_layout == TL_NO_ROADS && _game_mode == GM_EDITOR) {
 
	if (_settings.economy.town_layout == TL_NO_ROADS && _game_mode == GM_EDITOR) {
 
		ShowErrorMessage(INVALID_STRING_ID, STR_CONFIG_PATCHES_TOWN_LAYOUT_INVALID, 0, 0);
 
		_patches.town_layout = TL_ORIGINAL;
 
		_settings.economy.town_layout = TL_ORIGINAL;
 
	}
 
	return 0;
 
}
 

	
 
/** Conversion callback for _gameopt_settings.landscape
 
 * It converts (or try) between old values and the new ones,
 
@@ -1276,15 +1310,15 @@ static int32 ConvertLandscape(const char
 
 * The primary idea is to avoid division by zero in game mode.
 
 * The secondary idea is to make it so the values will be somewhat sane and that towns will
 
 * not be overcrowed with airports.  It would be easy to abuse such a feature
 
 * So basically, 200, 400, 800 are the lowest allowed values */
 
static int32 CheckNoiseToleranceLevel(const char *value)
 
{
 
	Patches *patches_ptr = (_game_mode == GM_MENU) ? &_patches_newgame : &_patches;
 
	for (uint16 i = 0; i < lengthof(patches_ptr->town_noise_population); i++) {
 
		patches_ptr->town_noise_population[i] = max(uint16(200 * (i + 1)), patches_ptr->town_noise_population[i]);
 
	Settings *s = (_game_mode == GM_MENU) ? &_settings_newgame : &_settings;
 
	for (uint16 i = 0; i < lengthof(s->economy.town_noise_population); i++) {
 
		s->economy.town_noise_population[i] = max(uint16(200 * (i + 1)), s->economy.town_noise_population[i]);
 
	}
 
	return 0;
 
}
 

	
 
/* End - Callback Functions */
 

	
 
@@ -1418,263 +1452,205 @@ static const SettingDesc _gameopt_settin
 
 * service_interval value to the v->service_interval, meaning that every client
 
 * assigns his value. If the setting was player-based, that would mean that
 
 * vehicles could decide on different moments that they are heading back to a
 
 * service depot, causing desyncs on a massive scale. */
 
const SettingDesc _patch_settings[] = {
 
	/***************************************************************************/
 
	/* User-interface section of the GUI-configure patches window */
 
	SDT_BOOL(Patches, vehicle_speed,                 S, 0,  true,        STR_CONFIG_PATCHES_VEHICLESPEED,          NULL),
 
	SDT_BOOL(Patches, status_long_date,              S, 0,  true,        STR_CONFIG_PATCHES_LONGDATE,              NULL),
 
	SDT_BOOL(Patches, show_finances,                 S, 0,  true,        STR_CONFIG_PATCHES_SHOWFINANCES,          NULL),
 
	SDT_BOOL(Patches, autoscroll,                    S, 0, false,        STR_CONFIG_PATCHES_AUTOSCROLL,            NULL),
 
	SDT_BOOL(Patches, reverse_scroll,                S, 0, false,        STR_CONFIG_PATCHES_REVERSE_SCROLLING,     NULL),
 
	SDT_BOOL(Patches, smooth_scroll,                 S, 0, false,        STR_CONFIG_PATCHES_SMOOTH_SCROLLING,      NULL),
 
	SDT_BOOL(Patches, measure_tooltip,               S, 0, false,        STR_CONFIG_PATCHES_MEASURE_TOOLTIP,       NULL),
 
	 SDT_VAR(Patches, errmsg_duration,    SLE_UINT8, S, 0,  5, 0, 20, 0, STR_CONFIG_PATCHES_ERRMSG_DURATION,       NULL),
 
	 SDT_VAR(Patches, toolbar_pos,        SLE_UINT8, S,MS,  0, 0,  2, 0, STR_CONFIG_PATCHES_TOOLBAR_POS,           v_PositionMainToolbar),
 
	 SDT_VAR(Patches, window_snap_radius, SLE_UINT8, S,D0, 10, 1, 32, 0, STR_CONFIG_PATCHES_SNAP_RADIUS,           NULL),
 
	SDT_BOOL(Patches, population_in_label,           S, 0,  true,        STR_CONFIG_PATCHES_POPULATION_IN_LABEL,   PopulationInLabelActive),
 
	 SDT_VAR(Patches, map_x,              SLE_UINT8, S, 0,  8, 6, 11, 0, STR_CONFIG_PATCHES_MAP_X,                 NULL),
 
	 SDT_VAR(Patches, map_y,              SLE_UINT8, S, 0,  8, 6, 11, 0, STR_CONFIG_PATCHES_MAP_Y,                 NULL),
 
	SDT_BOOL(Patches, link_terraform_toolbar,        S, 0, false,        STR_CONFIG_PATCHES_LINK_TERRAFORM_TOOLBAR,NULL),
 
	 SDT_VAR(Patches, liveries,           SLE_UINT8, S,MS,  2, 0,  2, 0, STR_CONFIG_PATCHES_LIVERIES,              RedrawScreen),
 
	SDT_BOOL(Patches, prefer_teamchat,               S, 0, false,        STR_CONFIG_PATCHES_PREFER_TEAMCHAT,       NULL),
 
	SDT_VAR(Patches, scrollwheel_scrolling,SLE_UINT8,S,MS, 0,  0,  2, 0, STR_CONFIG_PATCHES_SCROLLWHEEL_SCROLLING, NULL),
 
	SDT_VAR(Patches,scrollwheel_multiplier,SLE_UINT8,S, 0, 5,  1, 15, 1, STR_CONFIG_PATCHES_SCROLLWHEEL_MULTIPLIER,NULL),
 
	SDT_BOOL(Patches, pause_on_newgame,              S, 0, false,        STR_CONFIG_PATCHES_PAUSE_ON_NEW_GAME,     NULL),
 
	 SDT_VAR(Patches,advanced_vehicle_list,SLE_UINT8,S,MS, 1,  0,  2, 0, STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS,NULL),
 
	SDT_BOOL(Patches, timetable_in_ticks,            S, 0, false,        STR_CONFIG_PATCHES_TIMETABLE_IN_TICKS,    NULL),
 
	 SDT_VAR(Patches, loading_indicators, SLE_UINT8, S,MS,  1, 0,  2, 0, STR_CONFIG_PATCHES_LOADING_INDICATORS,    RedrawScreen),
 
	 SDT_VAR(Patches, default_rail_type,  SLE_UINT8, S,MS,  4, 0,  6, 0, STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE,     NULL),
 
	/* Saved patch variables. */
 

	
 
	    SDT_BOOL(Settings, construction.build_on_slopes,                                        0,NN,  true,                    STR_CONFIG_PATCHES_BUILDONSLOPES,          NULL),
 
	SDT_CONDBOOL(Settings, construction.autoslope,                          75, SL_MAX_VERSION, 0, 0,  true,                    STR_CONFIG_PATCHES_AUTOSLOPE,              NULL),
 
	    SDT_BOOL(Settings, construction.extra_dynamite,                                         0, 0, false,                    STR_CONFIG_PATCHES_EXTRADYNAMITE,          NULL),
 
	    SDT_BOOL(Settings, construction.longbridges,                                            0,NN,  true,                    STR_CONFIG_PATCHES_LONGBRIDGES,            NULL),
 
	    SDT_BOOL(Settings, construction.signal_side,                                            N,NN,  true,                    STR_CONFIG_PATCHES_SIGNALSIDE,             RedrawScreen),
 
	    SDT_BOOL(Settings, station.always_small_airport,                                        0,NN, false,                    STR_CONFIG_PATCHES_SMALL_AIRPORTS,         NULL),
 
	 SDT_CONDVAR(Settings, 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_BOOL(Settings, vehicle.realistic_acceleration,                                      0, 0, false,                    STR_CONFIG_PATCHES_REALISTICACCEL,         RealisticAccelerationChanged),
 
	    SDT_BOOL(Settings, pf.forbid_90_deg,                                                    0, 0, false,                    STR_CONFIG_PATCHES_FORBID_90_DEG,          NULL),
 
	    SDT_BOOL(Settings, vehicle.mammoth_trains,                                              0,NN,  true,                    STR_CONFIG_PATCHES_MAMMOTHTRAINS,          NULL),
 
	    SDT_BOOL(Settings, order.gotodepot,                                                     0, 0,  true,                    STR_CONFIG_PATCHES_GOTODEPOT,              NULL),
 
	    SDT_BOOL(Settings, pf.roadveh_queue,                                                    0, 0,  true,                    STR_CONFIG_PATCHES_ROADVEH_QUEUE,          NULL),
 

	
 
	SDT_CONDBOOL(Settings, pf.new_pathfinding_all,                           0,             86, 0, 0, false,                    STR_NULL,                                  NULL),
 
	SDT_CONDBOOL(Settings, pf.yapf.ship_use_yapf,                           28,             86, 0, 0, false,                    STR_NULL,                                  NULL),
 
	SDT_CONDBOOL(Settings, pf.yapf.road_use_yapf,                           28,             86, 0, 0,  true,                    STR_NULL,                                  NULL),
 
	SDT_CONDBOOL(Settings, pf.yapf.rail_use_yapf,                           28,             86, 0, 0,  true,                    STR_NULL,                                  NULL),
 

	
 
	 SDT_CONDVAR(Settings, pf.pathfinder_for_trains,             SLE_UINT8, 87, SL_MAX_VERSION, 0, MS,    2,     0,       2, 1, STR_CONFIG_PATCHES_PATHFINDER_FOR_TRAINS,  NULL),
 
	 SDT_CONDVAR(Settings, pf.pathfinder_for_roadvehs,           SLE_UINT8, 87, SL_MAX_VERSION, 0, MS,    2,     0,       2, 1, STR_CONFIG_PATCHES_PATHFINDER_FOR_ROADVEH, NULL),
 
	 SDT_CONDVAR(Settings, pf.pathfinder_for_ships,              SLE_UINT8, 87, SL_MAX_VERSION, 0, MS,    0,     0,       2, 1, STR_CONFIG_PATCHES_PATHFINDER_FOR_SHIPS,   NULL),
 

	
 
	/***************************************************************************/
 
	/* Construction section of the GUI-configure patches window */
 
	SDT_BOOL(Patches, build_on_slopes,               0,NN,  true,        STR_CONFIG_PATCHES_BUILDONSLOPES,       NULL),
 
	SDT_CONDBOOL(Patches, autoslope,                75, SL_MAX_VERSION, 0, 0, true,  STR_CONFIG_PATCHES_AUTOSLOPE,            NULL),
 
	SDT_BOOL(Patches, extra_dynamite,                0, 0, false,        STR_CONFIG_PATCHES_EXTRADYNAMITE,       NULL),
 
	SDT_BOOL(Patches, longbridges,                   0,NN,  true,        STR_CONFIG_PATCHES_LONGBRIDGES,         NULL),
 
	SDT_BOOL(Patches, signal_side,                   N,NN,  true,        STR_CONFIG_PATCHES_SIGNALSIDE,          RedrawScreen),
 
	SDT_BOOL(Patches, always_small_airport,          0,NN, false,        STR_CONFIG_PATCHES_SMALL_AIRPORTS,      NULL),
 
	SDT_BOOL(Patches, enable_signal_gui,             S, 0, false,        STR_CONFIG_PATCHES_ENABLE_SIGNAL_GUI,   CloseSignalGUI),
 
	 SDT_VAR(Patches, drag_signals_density,SLE_UINT8,S, 0,  4, 1, 20, 0, STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY,DragSignalsDensityChanged),
 
	 SDT_VAR(Patches, semaphore_build_before,SLE_INT32, S, NC, 1975, MIN_YEAR, MAX_YEAR, 1, STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE, ResetSignalVariant),
 
	SDT_CONDVAR(Patches, 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_BOOL(Settings, vehicle.never_expire_vehicles,                                       0,NN, false,                    STR_CONFIG_PATCHES_NEVER_EXPIRE_VEHICLES,  NULL),
 
	     SDT_VAR(Settings, vehicle.max_trains,                  SLE_UINT16,                     0, 0,   500,     0,    5000, 0, STR_CONFIG_PATCHES_MAX_TRAINS,             RedrawScreen),
 
	     SDT_VAR(Settings, vehicle.max_roadveh,                 SLE_UINT16,                     0, 0,   500,     0,    5000, 0, STR_CONFIG_PATCHES_MAX_ROADVEH,            RedrawScreen),
 
	     SDT_VAR(Settings, vehicle.max_aircraft,                SLE_UINT16,                     0, 0,   200,     0,    5000, 0, STR_CONFIG_PATCHES_MAX_AIRCRAFT,           RedrawScreen),
 
	     SDT_VAR(Settings, vehicle.max_ships,                   SLE_UINT16,                     0, 0,   300,     0,    5000, 0, STR_CONFIG_PATCHES_MAX_SHIPS,              RedrawScreen),
 
	    SDT_BOOL(Settings, vehicle.servint_ispercent,                                           0, 0, false,                    STR_CONFIG_PATCHES_SERVINT_ISPERCENT,      CheckInterval),
 
	     SDT_VAR(Settings, vehicle.servint_trains,              SLE_UINT16,                     0,D0,   150,     5,     800, 0, STR_CONFIG_PATCHES_SERVINT_TRAINS,         InValidateDetailsWindow),
 
	     SDT_VAR(Settings, vehicle.servint_roadveh,             SLE_UINT16,                     0,D0,   150,     5,     800, 0, STR_CONFIG_PATCHES_SERVINT_ROADVEH,        InValidateDetailsWindow),
 
	     SDT_VAR(Settings, vehicle.servint_ships,               SLE_UINT16,                     0,D0,   360,     5,     800, 0, STR_CONFIG_PATCHES_SERVINT_SHIPS,          InValidateDetailsWindow),
 
	     SDT_VAR(Settings, vehicle.servint_aircraft,            SLE_UINT16,                     0,D0,   100,     5,     800, 0, STR_CONFIG_PATCHES_SERVINT_AIRCRAFT,       InValidateDetailsWindow),
 
	    SDT_BOOL(Settings, order.no_servicing_if_no_breakdowns,                                 0, 0, false,                    STR_CONFIG_PATCHES_NOSERVICE,              NULL),
 
	    SDT_BOOL(Settings, vehicle.wagon_speed_limits,                                          0,NN,  true,                    STR_CONFIG_PATCHES_WAGONSPEEDLIMITS,       UpdateConsists),
 
	SDT_CONDBOOL(Settings, vehicle.disable_elrails,                         38, SL_MAX_VERSION, 0,NN, false,                    STR_CONFIG_PATCHES_DISABLE_ELRAILS,        SettingsDisableElrail),
 
	 SDT_CONDVAR(Settings, vehicle.freight_trains,               SLE_UINT8, 39, SL_MAX_VERSION, 0,NN,     1,     1,     255, 1, STR_CONFIG_PATCHES_FREIGHT_TRAINS,         NULL),
 
	SDT_CONDBOOL(Settings, order.timetabling,                               67, SL_MAX_VERSION, 0, 0,  true,                    STR_CONFIG_PATCHES_TIMETABLE_ALLOW,        NULL),
 
	 SDT_CONDVAR(Settings, vehicle.plane_speed,                  SLE_UINT8, 90, SL_MAX_VERSION, 0, 0,     4,     1,       4, 0, STR_CONFIG_PATCHES_PLANE_SPEED,            NULL),
 
	SDT_CONDBOOL(Settings, vehicle.dynamic_engines,                         95, SL_MAX_VERSION, 0,NN, false,                    STR_CONFIG_PATCHES_DYNAMIC_ENGINES,        NULL),
 

	
 
	/***************************************************************************/
 
	/* Vehicle section of the GUI-configure patches window */
 
	SDT_BOOL(Patches, realistic_acceleration,        0, 0, false,                    STR_CONFIG_PATCHES_REALISTICACCEL,       RealisticAccelerationChanged),
 
	SDT_BOOL(Patches, forbid_90_deg,                 0, 0, false,                    STR_CONFIG_PATCHES_FORBID_90_DEG,        NULL),
 
	SDT_BOOL(Patches, mammoth_trains,                0,NN,  true,                    STR_CONFIG_PATCHES_MAMMOTHTRAINS,        NULL),
 
	SDT_BOOL(Patches, gotodepot,                     0, 0,  true,                    STR_CONFIG_PATCHES_GOTODEPOT,            NULL),
 
	SDT_BOOL(Patches, roadveh_queue,                 0, 0,  true,                    STR_CONFIG_PATCHES_ROADVEH_QUEUE,        NULL),
 

	
 
	SDT_CONDBOOL(Patches, new_pathfinding_all, 0,86, 0, 0, false,                    STR_NULL,                                NULL),
 
	SDT_CONDBOOL(Patches, yapf.ship_use_yapf, 28,86, 0, 0, false,                    STR_NULL,                                NULL),
 
	SDT_CONDBOOL(Patches, yapf.road_use_yapf, 28,86, 0, 0,  true,                    STR_NULL,                                NULL),
 
	SDT_CONDBOOL(Patches, yapf.rail_use_yapf, 28,86, 0, 0,  true,                    STR_NULL,                                NULL),
 

	
 
	SDT_CONDVAR(Patches, pathfinder_for_trains,   SLE_UINT8, 87, SL_MAX_VERSION, 0, MS, 2, 0, 2, 1, STR_CONFIG_PATCHES_PATHFINDER_FOR_TRAINS,  NULL),
 
	SDT_CONDVAR(Patches, pathfinder_for_roadvehs, SLE_UINT8, 87, SL_MAX_VERSION, 0, MS, 2, 0, 2, 1, STR_CONFIG_PATCHES_PATHFINDER_FOR_ROADVEH, NULL),
 
	SDT_CONDVAR(Patches, pathfinder_for_ships,    SLE_UINT8, 87, SL_MAX_VERSION, 0, MS, 0, 0, 2, 1, STR_CONFIG_PATCHES_PATHFINDER_FOR_SHIPS,   NULL),
 
	    SDT_BOOL(Settings, station.join_stations,                                               0, 0,  true,                    STR_CONFIG_PATCHES_JOINSTATIONS,           NULL),
 
	SDT_CONDBOOL(Settings, gui.sg_full_load_any,                             0,             92, 0, 0 , true,                    STR_NULL,                                  NULL),
 
	    SDT_BOOL(Settings, order.improved_load,                                                 0,NN,  true,                    STR_CONFIG_PATCHES_IMPROVEDLOAD,           NULL),
 
	    SDT_BOOL(Settings, order.selectgoods,                                                   0, 0,  true,                    STR_CONFIG_PATCHES_SELECTGOODS,            NULL),
 
	SDT_CONDBOOL(Settings, gui.sg_new_nonstop,                               0,             92, 0, 0, false,                    STR_NULL,                                  NULL),
 
	    SDT_BOOL(Settings, station.nonuniform_stations,                                         0,NN,  true,                    STR_CONFIG_PATCHES_NONUNIFORM_STATIONS,    NULL),
 
	     SDT_VAR(Settings, station.station_spread,               SLE_UINT8,                     0, 0,    12,     4,      64, 0, STR_CONFIG_PATCHES_STATION_SPREAD,         InvalidateStationBuildWindow),
 
	    SDT_BOOL(Settings, order.serviceathelipad,                                              0, 0,  true,                    STR_CONFIG_PATCHES_SERVICEATHELIPAD,       NULL),
 
	    SDT_BOOL(Settings, station.modified_catchment,                                          0, 0,  true,                    STR_CONFIG_PATCHES_CATCHMENT,              NULL),
 
	SDT_CONDBOOL(Settings, order.gradual_loading,                           40, SL_MAX_VERSION, 0, 0,  true,                    STR_CONFIG_PATCHES_GRADUAL_LOADING,        NULL),
 
	SDT_CONDBOOL(Settings, construction.road_stop_on_town_road,             47, SL_MAX_VERSION, 0, 0,  true,                    STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD,      NULL),
 
	SDT_CONDBOOL(Settings, station.adjacent_stations,                       62, SL_MAX_VERSION, 0, 0,  true,                    STR_CONFIG_PATCHES_ADJACENT_STATIONS,      NULL),
 
	SDT_CONDBOOL(Settings, economy.station_noise_level,                     96, SL_MAX_VERSION, 0, 0, false,                    STR_CONFIG_PATCHES_NOISE_LEVEL,            InvalidateTownViewWindow),
 

	
 
	SDT_BOOL(Patches, train_income_warn,             S, 0,  true,                    STR_CONFIG_PATCHES_WARN_INCOME_LESS,     NULL),
 
	 SDT_VAR(Patches, order_review_system,SLE_UINT8, S,MS,     2,     0,       2, 0, STR_CONFIG_PATCHES_ORDER_REVIEW,         NULL),
 
	SDT_BOOL(Patches, never_expire_vehicles,         0,NN, false,                    STR_CONFIG_PATCHES_NEVER_EXPIRE_VEHICLES,NULL),
 
	SDT_BOOL(Patches, lost_train_warn,               S, 0,  true,                    STR_CONFIG_PATCHES_WARN_LOST_TRAIN,      NULL),
 
	SDT_BOOL(Patches, autorenew,                     S, 0, false,                    STR_CONFIG_PATCHES_AUTORENEW_VEHICLE,    EngineRenewUpdate),
 
	 SDT_VAR(Patches, autorenew_months,   SLE_INT16, S, 0,     6,   -12,      12, 0, STR_CONFIG_PATCHES_AUTORENEW_MONTHS,     EngineRenewMonthsUpdate),
 
	 SDT_VAR(Patches, autorenew_money,     SLE_UINT, S,CR,100000,     0, 2000000, 0, STR_CONFIG_PATCHES_AUTORENEW_MONEY,      EngineRenewMoneyUpdate),
 
	SDT_BOOL(Patches, always_build_infrastructure,   S, 0, false,                    STR_CONFIG_PATCHES_ALWAYS_BUILD_INFRASTRUCTURE, RedrawScreen),
 
	 SDT_VAR(Patches, max_trains,        SLE_UINT16, 0, 0,   500,     0,    5000, 0, STR_CONFIG_PATCHES_MAX_TRAINS,           RedrawScreen),
 
	 SDT_VAR(Patches, max_roadveh,       SLE_UINT16, 0, 0,   500,     0,    5000, 0, STR_CONFIG_PATCHES_MAX_ROADVEH,          RedrawScreen),
 
	 SDT_VAR(Patches, max_aircraft,      SLE_UINT16, 0, 0,   200,     0,    5000, 0, STR_CONFIG_PATCHES_MAX_AIRCRAFT,         RedrawScreen),
 
	 SDT_VAR(Patches, max_ships,         SLE_UINT16, 0, 0,   300,     0,    5000, 0, STR_CONFIG_PATCHES_MAX_SHIPS,            RedrawScreen),
 
	SDT_BOOL(Patches, servint_ispercent,             0, 0, false,                    STR_CONFIG_PATCHES_SERVINT_ISPERCENT,    CheckInterval),
 
	 SDT_VAR(Patches, servint_trains,    SLE_UINT16, 0,D0,   150,     5,     800, 0, STR_CONFIG_PATCHES_SERVINT_TRAINS,       InValidateDetailsWindow),
 
	 SDT_VAR(Patches, servint_roadveh,   SLE_UINT16, 0,D0,   150,     5,     800, 0, STR_CONFIG_PATCHES_SERVINT_ROADVEH,      InValidateDetailsWindow),
 
	 SDT_VAR(Patches, servint_ships,     SLE_UINT16, 0,D0,   360,     5,     800, 0, STR_CONFIG_PATCHES_SERVINT_SHIPS,        InValidateDetailsWindow),
 
	 SDT_VAR(Patches, servint_aircraft,  SLE_UINT16, 0,D0,   100,     5,     800, 0, STR_CONFIG_PATCHES_SERVINT_AIRCRAFT,     InValidateDetailsWindow),
 
	SDT_BOOL(Patches, no_servicing_if_no_breakdowns, 0, 0, false,                    STR_CONFIG_PATCHES_NOSERVICE,            NULL),
 
	SDT_BOOL(Patches, wagon_speed_limits,            0,NN,  true,                    STR_CONFIG_PATCHES_WAGONSPEEDLIMITS,     UpdateConsists),
 
	SDT_CONDBOOL(Patches, disable_elrails, 38, SL_MAX_VERSION, 0, NN, false,         STR_CONFIG_PATCHES_DISABLE_ELRAILS,      SettingsDisableElrail),
 
	SDT_CONDVAR(Patches, freight_trains, SLE_UINT8, 39, SL_MAX_VERSION, 0,NN, 1, 1, 255, 1, STR_CONFIG_PATCHES_FREIGHT_TRAINS, NULL),
 
	SDT_CONDBOOL(Patches, timetabling,              67, SL_MAX_VERSION, 0, 0, true,  STR_CONFIG_PATCHES_TIMETABLE_ALLOW,      NULL),
 
	SDT_CONDVAR(Patches, plane_speed,    SLE_UINT8, 90, SL_MAX_VERSION, 0, 0, 4, 1,   4, 0, STR_CONFIG_PATCHES_PLANE_SPEED,   NULL),
 
	SDT_CONDBOOL(Patches, dynamic_engines,          95, SL_MAX_VERSION, 0,NN, false, STR_CONFIG_PATCHES_DYNAMIC_ENGINES,      NULL),
 
	    SDT_BOOL(Settings, economy.inflation,                                                   0, 0,  true,                    STR_CONFIG_PATCHES_INFLATION,              NULL),
 
	     SDT_VAR(Settings, construction.raw_industry_construction, SLE_UINT8,                   0,MS,     0,     0,       2, 0, STR_CONFIG_PATCHES_RAW_INDUSTRY_CONSTRUCTION_METHOD, InvalidateBuildIndustryWindow),
 
	    SDT_BOOL(Settings, economy.multiple_industry_per_town,                                  0, 0, false,                    STR_CONFIG_PATCHES_MULTIPINDTOWN,          NULL),
 
	    SDT_BOOL(Settings, economy.same_industry_close,                                         0, 0, false,                    STR_CONFIG_PATCHES_SAMEINDCLOSE,           NULL),
 
	    SDT_BOOL(Settings, economy.bribe,                                                       0, 0,  true,                    STR_CONFIG_PATCHES_BRIBE,                  NULL),
 
	SDT_CONDBOOL(Settings, economy.exclusive_rights,                        79, SL_MAX_VERSION, 0, 0,  true,                    STR_CONFIG_PATCHES_ALLOW_EXCLUSIVE,        NULL),
 
	SDT_CONDBOOL(Settings, economy.give_money,                              79, SL_MAX_VERSION, 0, 0,  true,                    STR_CONFIG_PATCHES_ALLOW_GIVE_MONEY,       NULL),
 
	     SDT_VAR(Settings, game_creation.snow_line_height,       SLE_UINT8,                     0, 0,     7,     2,      13, 0, STR_CONFIG_PATCHES_SNOWLINE_HEIGHT,        NULL),
 
	     SDT_VAR(Settings, gui.colored_news_year,                SLE_INT32,                     0,NC,  2000,MIN_YEAR,MAX_YEAR,1,STR_CONFIG_PATCHES_COLORED_NEWS_YEAR,      NULL),
 
	     SDT_VAR(Settings, game_creation.starting_year,          SLE_INT32,                     0,NC,  1950,MIN_YEAR,MAX_YEAR,1,STR_CONFIG_PATCHES_STARTING_YEAR,          NULL),
 
	     SDT_VAR(Settings, gui.ending_year,                      SLE_INT32,                    0,NC|NO,2051,MIN_YEAR,MAX_YEAR,1,STR_CONFIG_PATCHES_ENDING_YEAR,            NULL),
 
	    SDT_BOOL(Settings, economy.smooth_economy,                                              0, 0,  true,                    STR_CONFIG_PATCHES_SMOOTH_ECONOMY,         NULL),
 
	    SDT_BOOL(Settings, economy.allow_shares,                                                0, 0, false,                    STR_CONFIG_PATCHES_ALLOW_SHARES,           NULL),
 
	 SDT_CONDVAR(Settings, economy.town_growth_rate,             SLE_UINT8, 54, SL_MAX_VERSION, 0, MS,    2,     0,       4, 0, STR_CONFIG_PATCHES_TOWN_GROWTH,            NULL),
 
	 SDT_CONDVAR(Settings, economy.larger_towns,                 SLE_UINT8, 54, SL_MAX_VERSION, 0, D0,    4,     0,     255, 1, STR_CONFIG_PATCHES_LARGER_TOWNS,           NULL),
 
	 SDT_CONDVAR(Settings, economy.initial_city_size,            SLE_UINT8, 56, SL_MAX_VERSION, 0, 0,     2,     1,      10, 1, STR_CONFIG_PATCHES_CITY_SIZE_MULTIPLIER,   NULL),
 
	SDT_CONDBOOL(Settings, economy.mod_road_rebuild,                        77, SL_MAX_VERSION, 0, 0, false,                    STR_CONFIG_MODIFIED_ROAD_REBUILD,          NULL),
 

	
 
	    SDT_BOOL(Settings, ai.ainew_active,                                                     0, 0, false,                    STR_CONFIG_PATCHES_AINEW_ACTIVE,           AiNew_PatchActive_Warning),
 
	    SDT_BOOL(Settings, ai.ai_in_multiplayer,                                                0, 0, false,                    STR_CONFIG_PATCHES_AI_IN_MULTIPLAYER,      Ai_In_Multiplayer_Warning),
 
	    SDT_BOOL(Settings, ai.ai_disable_veh_train,                                             0, 0, false,                    STR_CONFIG_PATCHES_AI_BUILDS_TRAINS,       NULL),
 
	    SDT_BOOL(Settings, ai.ai_disable_veh_roadveh,                                           0, 0, false,                    STR_CONFIG_PATCHES_AI_BUILDS_ROADVEH,      NULL),
 
	    SDT_BOOL(Settings, ai.ai_disable_veh_aircraft,                                          0, 0, false,                    STR_CONFIG_PATCHES_AI_BUILDS_AIRCRAFT,     NULL),
 
	    SDT_BOOL(Settings, ai.ai_disable_veh_ship,                                              0, 0, false,                    STR_CONFIG_PATCHES_AI_BUILDS_SHIPS,        NULL),
 

	
 
	     SDT_VAR(Settings, vehicle.extend_vehicle_life,          SLE_UINT8,                     0, 0,     0,     0,     100, 0, STR_NULL,                                  NULL),
 
	     SDT_VAR(Settings, economy.dist_local_authority,         SLE_UINT8,                     0, 0,    20,     5,      60, 0, STR_NULL,                                  NULL),
 
	     SDT_VAR(Settings, pf.wait_oneway_signal,                SLE_UINT8,                     0, 0,    15,     2,     100, 0, STR_NULL,                                  NULL),
 
	     SDT_VAR(Settings, pf.wait_twoway_signal,                SLE_UINT8,                     0, 0,    41,     2,     100, 0, STR_NULL,                                  NULL),
 
	SDT_CONDLISTO(Settings, economy.town_noise_population, 3,   SLE_UINT16, 96, SL_MAX_VERSION, 0,D0, "800,2000,4000",          STR_NULL,                                  NULL, CheckNoiseToleranceLevel),
 

	
 
	     SDT_VAR(Settings, pf.opf.pf_maxlength,                          SLE_UINT16,                     0, 0,  4096,                    64,   65535, 0, STR_NULL,         NULL),
 
	     SDT_VAR(Settings, pf.opf.pf_maxdepth,                            SLE_UINT8,                     0, 0,    48,                     4,     255, 0, STR_NULL,         NULL),
 

	
 
	/***************************************************************************/
 
	/* Station section of the GUI-configure patches window */
 
	SDT_BOOL(Patches, join_stations,           0, 0,  true,        STR_CONFIG_PATCHES_JOINSTATIONS,       NULL),
 
	SDT_CONDBOOL(Patches, sg_full_load_any, 0, 92, 0, 0, true,     STR_NULL,                              NULL),
 
	SDT_BOOL(Patches, improved_load,           0,NN, false,        STR_CONFIG_PATCHES_IMPROVEDLOAD,       NULL),
 
	SDT_BOOL(Patches, selectgoods,             0, 0,  true,        STR_CONFIG_PATCHES_SELECTGOODS,        NULL),
 
	SDT_BOOL(Patches, new_nonstop,             S, 0, false,        STR_CONFIG_PATCHES_NEW_NONSTOP,        NULL),
 
	SDT_CONDBOOL(Patches, sg_new_nonstop, 0, 92, 0, 0, false,      STR_NULL,                              NULL),
 
	SDT_BOOL(Patches, nonuniform_stations,     0,NN,  true,        STR_CONFIG_PATCHES_NONUNIFORM_STATIONS,NULL),
 
	 SDT_VAR(Patches, station_spread,SLE_UINT8,0, 0, 12, 4, 64, 0, STR_CONFIG_PATCHES_STATION_SPREAD,     InvalidateStationBuildWindow),
 
	SDT_BOOL(Patches, serviceathelipad,        0, 0,  true,        STR_CONFIG_PATCHES_SERVICEATHELIPAD,   NULL),
 
	SDT_BOOL(Patches, modified_catchment,      0, 0,  true,        STR_CONFIG_PATCHES_CATCHMENT,          NULL),
 
	SDT_CONDBOOL(Patches, gradual_loading, 40, SL_MAX_VERSION, 0, 0,  true, STR_CONFIG_PATCHES_GRADUAL_LOADING,    NULL),
 
	SDT_CONDBOOL(Patches, road_stop_on_town_road, 47, SL_MAX_VERSION, 0, 0, false, STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD, NULL),
 
	SDT_CONDBOOL(Patches, adjacent_stations,      62, SL_MAX_VERSION, 0, 0, true,  STR_CONFIG_PATCHES_ADJACENT_STATIONS, NULL),
 
	SDT_CONDBOOL(Patches, station_noise_level,    96, SL_MAX_VERSION, 0, 0, false, STR_CONFIG_PATCHES_NOISE_LEVEL,       InvalidateTownViewWindow),
 
	     SDT_VAR(Settings, pf.npf.npf_max_search_nodes,                    SLE_UINT,                     0, 0, 10000,                   500,  100000, 0, STR_NULL,         NULL),
 
	     SDT_VAR(Settings, pf.npf.npf_rail_firstred_penalty,               SLE_UINT,                     0, 0, ( 10 * NPF_TILE_LENGTH),   0,  100000, 0, STR_NULL,         NULL),
 
	     SDT_VAR(Settings, pf.npf.npf_rail_firstred_exit_penalty,          SLE_UINT,                     0, 0, (100 * NPF_TILE_LENGTH),   0,  100000, 0, STR_NULL,         NULL),
 
	     SDT_VAR(Settings, pf.npf.npf_rail_lastred_penalty,                SLE_UINT,                     0, 0, ( 10 * NPF_TILE_LENGTH),   0,  100000, 0, STR_NULL,         NULL),
 
	     SDT_VAR(Settings, pf.npf.npf_rail_station_penalty,                SLE_UINT,                     0, 0, (  1 * NPF_TILE_LENGTH),   0,  100000, 0, STR_NULL,         NULL),
 
	     SDT_VAR(Settings, pf.npf.npf_rail_slope_penalty,                  SLE_UINT,                     0, 0, (  1 * NPF_TILE_LENGTH),   0,  100000, 0, STR_NULL,         NULL),
 
	     SDT_VAR(Settings, pf.npf.npf_rail_curve_penalty,                  SLE_UINT,                     0, 0, 1,                         0,  100000, 0, STR_NULL,         NULL),
 
	     SDT_VAR(Settings, pf.npf.npf_rail_depot_reverse_penalty,          SLE_UINT,                     0, 0, ( 50 * NPF_TILE_LENGTH),   0,  100000, 0, STR_NULL,         NULL),
 
	     SDT_VAR(Settings, pf.npf.npf_buoy_penalty,                        SLE_UINT,                     0, 0, (  2 * NPF_TILE_LENGTH),   0,  100000, 0, STR_NULL,         NULL),
 
	     SDT_VAR(Settings, pf.npf.npf_water_curve_penalty,                 SLE_UINT,                     0, 0, (NPF_TILE_LENGTH / 4),     0,  100000, 0, STR_NULL,         NULL),
 
	     SDT_VAR(Settings, pf.npf.npf_road_curve_penalty,                  SLE_UINT,                     0, 0, 1,                         0,  100000, 0, STR_NULL,         NULL),
 
	     SDT_VAR(Settings, pf.npf.npf_crossing_penalty,                    SLE_UINT,                     0, 0, (  3 * NPF_TILE_LENGTH),   0,  100000, 0, STR_NULL,         NULL),
 
	 SDT_CONDVAR(Settings, pf.npf.npf_road_drive_through_penalty,          SLE_UINT, 47, SL_MAX_VERSION, 0, 0, (  8 * NPF_TILE_LENGTH),   0,  100000, 0, STR_NULL,         NULL),
 

	
 

	
 
	/***************************************************************************/
 
	/* Economy section of the GUI-configure patches window */
 
	SDT_BOOL(Patches, inflation,                  0, 0,  true,            STR_CONFIG_PATCHES_INFLATION,        NULL),
 
	 SDT_VAR(Patches, raw_industry_construction,SLE_UINT8,0,MS,0,0, 2, 0, STR_CONFIG_PATCHES_RAW_INDUSTRY_CONSTRUCTION_METHOD, InvalidateBuildIndustryWindow),
 
	SDT_BOOL(Patches, multiple_industry_per_town, 0, 0, false,            STR_CONFIG_PATCHES_MULTIPINDTOWN,    NULL),
 
	SDT_BOOL(Patches, same_industry_close,        0, 0, false,            STR_CONFIG_PATCHES_SAMEINDCLOSE,     NULL),
 
	SDT_BOOL(Patches, bribe,                      0, 0,  true,            STR_CONFIG_PATCHES_BRIBE,            NULL),
 
	SDT_CONDBOOL(Patches, exclusive_rights,           79, SL_MAX_VERSION, 0, 0, true,           STR_CONFIG_PATCHES_ALLOW_EXCLUSIVE, NULL),
 
	SDT_CONDBOOL(Patches, give_money,                 79, SL_MAX_VERSION, 0, 0, true,           STR_CONFIG_PATCHES_ALLOW_GIVE_MONEY, NULL),
 
	 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),
 
	SDT_CONDVAR(Patches, initial_city_size, SLE_UINT8, 56, SL_MAX_VERSION, 0, 0,  2, 1,  10, 1, STR_CONFIG_PATCHES_CITY_SIZE_MULTIPLIER, NULL),
 
	SDT_CONDBOOL(Patches, mod_road_rebuild,            77, SL_MAX_VERSION, 0, 0, false,         STR_CONFIG_MODIFIED_ROAD_REBUILD,        NULL),
 
	SDT_CONDBOOL(Settings, pf.yapf.disable_node_optimization,                        28, SL_MAX_VERSION, 0, 0, false,                                    STR_NULL,         NULL),
 
	 SDT_CONDVAR(Settings, pf.yapf.max_search_nodes,                       SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 10000,                   500, 1000000, 0, STR_NULL,         NULL),
 
	SDT_CONDBOOL(Settings, pf.yapf.rail_firstred_twoway_eol,                         28, SL_MAX_VERSION, 0, 0,  true,                                    STR_NULL,         NULL),
 
	 SDT_CONDVAR(Settings, pf.yapf.rail_firstred_penalty,                  SLE_UINT, 28, SL_MAX_VERSION, 0, 0,    10 * YAPF_TILE_LENGTH,  0, 1000000, 0, STR_NULL,         NULL),
 
	 SDT_CONDVAR(Settings, pf.yapf.rail_firstred_exit_penalty,             SLE_UINT, 28, SL_MAX_VERSION, 0, 0,   100 * YAPF_TILE_LENGTH,  0, 1000000, 0, STR_NULL,         NULL),
 
	 SDT_CONDVAR(Settings, pf.yapf.rail_lastred_penalty,                   SLE_UINT, 28, SL_MAX_VERSION, 0, 0,    10 * YAPF_TILE_LENGTH,  0, 1000000, 0, STR_NULL,         NULL),
 
	 SDT_CONDVAR(Settings, pf.yapf.rail_lastred_exit_penalty,              SLE_UINT, 28, SL_MAX_VERSION, 0, 0,   100 * YAPF_TILE_LENGTH,  0, 1000000, 0, STR_NULL,         NULL),
 
	 SDT_CONDVAR(Settings, pf.yapf.rail_station_penalty,                   SLE_UINT, 28, SL_MAX_VERSION, 0, 0,    30 * YAPF_TILE_LENGTH,  0, 1000000, 0, STR_NULL,         NULL),
 
	 SDT_CONDVAR(Settings, pf.yapf.rail_slope_penalty,                     SLE_UINT, 28, SL_MAX_VERSION, 0, 0,     2 * YAPF_TILE_LENGTH,  0, 1000000, 0, STR_NULL,         NULL),
 
	 SDT_CONDVAR(Settings, pf.yapf.rail_curve45_penalty,                   SLE_UINT, 28, SL_MAX_VERSION, 0, 0,     1 * YAPF_TILE_LENGTH,  0, 1000000, 0, STR_NULL,         NULL),
 
	 SDT_CONDVAR(Settings, pf.yapf.rail_curve90_penalty,                   SLE_UINT, 28, SL_MAX_VERSION, 0, 0,     6 * YAPF_TILE_LENGTH,  0, 1000000, 0, STR_NULL,         NULL),
 
	 SDT_CONDVAR(Settings, pf.yapf.rail_depot_reverse_penalty,             SLE_UINT, 28, SL_MAX_VERSION, 0, 0,    50 * YAPF_TILE_LENGTH,  0, 1000000, 0, STR_NULL,         NULL),
 
	 SDT_CONDVAR(Settings, pf.yapf.rail_crossing_penalty,                  SLE_UINT, 28, SL_MAX_VERSION, 0, 0,     3 * YAPF_TILE_LENGTH,  0, 1000000, 0, STR_NULL,         NULL),
 
	 SDT_CONDVAR(Settings, pf.yapf.rail_look_ahead_max_signals,            SLE_UINT, 28, SL_MAX_VERSION, 0, 0,    10,                     1,     100, 0, STR_NULL,         NULL),
 
	 SDT_CONDVAR(Settings, pf.yapf.rail_look_ahead_signal_p0,               SLE_INT, 28, SL_MAX_VERSION, 0, 0,   500,              -1000000, 1000000, 0, STR_NULL,         NULL),
 
	 SDT_CONDVAR(Settings, pf.yapf.rail_look_ahead_signal_p1,               SLE_INT, 28, SL_MAX_VERSION, 0, 0,  -100,              -1000000, 1000000, 0, STR_NULL,         NULL),
 
	 SDT_CONDVAR(Settings, pf.yapf.rail_look_ahead_signal_p2,               SLE_INT, 28, SL_MAX_VERSION, 0, 0,     5,              -1000000, 1000000, 0, STR_NULL,         NULL),
 
	 SDT_CONDVAR(Settings, pf.yapf.rail_longer_platform_penalty,           SLE_UINT, 33, SL_MAX_VERSION, 0, 0,     8 * YAPF_TILE_LENGTH,  0,   20000, 0, STR_NULL,         NULL),
 
	 SDT_CONDVAR(Settings, pf.yapf.rail_longer_platform_per_tile_penalty,  SLE_UINT, 33, SL_MAX_VERSION, 0, 0,     0 * YAPF_TILE_LENGTH,  0,   20000, 0, STR_NULL,         NULL),
 
	 SDT_CONDVAR(Settings, pf.yapf.rail_shorter_platform_penalty,          SLE_UINT, 33, SL_MAX_VERSION, 0, 0,    40 * YAPF_TILE_LENGTH,  0,   20000, 0, STR_NULL,         NULL),
 
	 SDT_CONDVAR(Settings, pf.yapf.rail_shorter_platform_per_tile_penalty, SLE_UINT, 33, SL_MAX_VERSION, 0, 0,     0 * YAPF_TILE_LENGTH,  0,   20000, 0, STR_NULL,         NULL),
 
	 SDT_CONDVAR(Settings, pf.yapf.road_slope_penalty,                     SLE_UINT, 33, SL_MAX_VERSION, 0, 0,     2 * YAPF_TILE_LENGTH,  0, 1000000, 0, STR_NULL,         NULL),
 
	 SDT_CONDVAR(Settings, pf.yapf.road_curve_penalty,                     SLE_UINT, 33, SL_MAX_VERSION, 0, 0,     1 * YAPF_TILE_LENGTH,  0, 1000000, 0, STR_NULL,         NULL),
 
	 SDT_CONDVAR(Settings, pf.yapf.road_crossing_penalty,                  SLE_UINT, 33, SL_MAX_VERSION, 0, 0,     3 * YAPF_TILE_LENGTH,  0, 1000000, 0, STR_NULL,         NULL),
 
	 SDT_CONDVAR(Settings, pf.yapf.road_stop_penalty,                      SLE_UINT, 47, SL_MAX_VERSION, 0, 0,     8 * YAPF_TILE_LENGTH,  0, 1000000, 0, STR_NULL,         NULL),
 

	
 
	 SDT_CONDVAR(Settings, game_creation.land_generator,                  SLE_UINT8, 30, SL_MAX_VERSION, 0,MS,     1,                     0,       1, 0, STR_CONFIG_PATCHES_LAND_GENERATOR,        NULL),
 
	 SDT_CONDVAR(Settings, game_creation.oil_refinery_limit,              SLE_UINT8, 30, SL_MAX_VERSION, 0, 0,    32,                    12,      48, 0, STR_CONFIG_PATCHES_OIL_REF_EDGE_DISTANCE, NULL),
 
	 SDT_CONDVAR(Settings, game_creation.tgen_smoothness,                 SLE_UINT8, 30, SL_MAX_VERSION, 0,MS,     1,                     0,       3, 0, STR_CONFIG_PATCHES_ROUGHNESS_OF_TERRAIN,  NULL),
 
	 SDT_CONDVAR(Settings, game_creation.generation_seed,                SLE_UINT32, 30, SL_MAX_VERSION, 0, 0,      GENERATE_NEW_SEED, 0, UINT32_MAX, 0, STR_NULL,                                 NULL),
 
	 SDT_CONDVAR(Settings, game_creation.tree_placer,                     SLE_UINT8, 30, SL_MAX_VERSION, 0,MS,     2,                     0,       2, 0, STR_CONFIG_PATCHES_TREE_PLACER,           NULL),
 
	     SDT_VAR(Settings, game_creation.heightmap_rotation,              SLE_UINT8,                     S,MS,     0,                     0,       1, 0, STR_CONFIG_PATCHES_HEIGHTMAP_ROTATION,    NULL),
 
	     SDT_VAR(Settings, game_creation.se_flat_world_height,            SLE_UINT8,                     S, 0,     0,                     0,      15, 0, STR_CONFIG_PATCHES_SE_FLAT_WORLD_HEIGHT,  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),
 
	SDT_BOOL(Patches, ai_disable_veh_roadveh, 0, 0, false, STR_CONFIG_PATCHES_AI_BUILDS_ROADVEH, NULL),
 
	SDT_BOOL(Patches, ai_disable_veh_aircraft,0, 0, false, STR_CONFIG_PATCHES_AI_BUILDS_AIRCRAFT,NULL),
 
	SDT_BOOL(Patches, ai_disable_veh_ship,    0, 0, false, STR_CONFIG_PATCHES_AI_BUILDS_SHIPS,   NULL),
 

	
 
	/***************************************************************************/
 
	/* Patches without any GUI representation */
 
	SDT_BOOL(Patches, keep_all_autosave,              S, 0, false,         STR_NULL, NULL),
 
	SDT_BOOL(Patches, autosave_on_exit,               S, 0, false,         STR_NULL, NULL),
 
	 SDT_VAR(Patches, max_num_autosaves,   SLE_UINT8, S, 0, 16, 0, 255, 0, STR_NULL, NULL),
 
	SDT_BOOL(Patches, bridge_pillars,                 S, 0,  true,         STR_NULL, NULL),
 
	 SDT_VAR(Patches, extend_vehicle_life, SLE_UINT8, 0, 0,  0, 0, 100, 0, STR_NULL, NULL),
 
	SDT_BOOL(Patches, auto_euro,                      S, 0,  true,         STR_NULL, NULL),
 
	 SDT_VAR(Patches, dist_local_authority,SLE_UINT8, 0, 0, 20, 5,  60, 0, STR_NULL, NULL),
 
	 SDT_VAR(Patches, wait_oneway_signal,  SLE_UINT8, 0, 0, 15, 2, 100, 0, STR_NULL, NULL),
 
	 SDT_VAR(Patches, wait_twoway_signal,  SLE_UINT8, 0, 0, 41, 2, 100, 0, STR_NULL, NULL),
 
	SDT_CONDLISTO(Patches, town_noise_population, 3, SLE_UINT16, 96, SL_MAX_VERSION, 0, D0, "800,2000,4000", STR_NULL, NULL, CheckNoiseToleranceLevel),
 

	
 
	/***************************************************************************/
 
	/* New Pathfinding patch settings */
 
	SDT_VAR(Patches, pf_maxlength,      SLE_UINT16, 0, 0,  4096,  64,  65535, 0, STR_NULL, NULL),
 
	SDT_VAR(Patches, pf_maxdepth,        SLE_UINT8, 0, 0,    48,   4,    255, 0, STR_NULL, NULL),
 
	/* The maximum number of nodes to search */
 
	SDT_VAR(Patches, npf_max_search_nodes,SLE_UINT, 0, 0, 10000, 500, 100000, 0, STR_NULL, NULL),
 
	/* Unsaved patch variables. */
 
	SDT_BOOL(Settings, gui.vehicle_speed,                     S, 0,  true,                        STR_CONFIG_PATCHES_VEHICLESPEED,                NULL),
 
	SDT_BOOL(Settings, gui.status_long_date,                  S, 0,  true,                        STR_CONFIG_PATCHES_LONGDATE,                    NULL),
 
	SDT_BOOL(Settings, gui.show_finances,                     S, 0,  true,                        STR_CONFIG_PATCHES_SHOWFINANCES,                NULL),
 
	SDT_BOOL(Settings, gui.autoscroll,                        S, 0, false,                        STR_CONFIG_PATCHES_AUTOSCROLL,                  NULL),
 
	SDT_BOOL(Settings, gui.reverse_scroll,                    S, 0, false,                        STR_CONFIG_PATCHES_REVERSE_SCROLLING,           NULL),
 
	SDT_BOOL(Settings, gui.smooth_scroll,                     S, 0, false,                        STR_CONFIG_PATCHES_SMOOTH_SCROLLING,            NULL),
 
	SDT_BOOL(Settings, gui.measure_tooltip,                   S, 0, false,                        STR_CONFIG_PATCHES_MEASURE_TOOLTIP,             NULL),
 
	 SDT_VAR(Settings, gui.errmsg_duration,        SLE_UINT8, S, 0,     5,        0,       20, 0, STR_CONFIG_PATCHES_ERRMSG_DURATION,             NULL),
 
	 SDT_VAR(Settings, gui.toolbar_pos,            SLE_UINT8, S,MS,     0,        0,        2, 0, STR_CONFIG_PATCHES_TOOLBAR_POS,                 v_PositionMainToolbar),
 
	 SDT_VAR(Settings, gui.window_snap_radius,     SLE_UINT8, S,D0,    10,        1,       32, 0, STR_CONFIG_PATCHES_SNAP_RADIUS,                 NULL),
 
	SDT_BOOL(Settings, gui.population_in_label,               S, 0,  true,                        STR_CONFIG_PATCHES_POPULATION_IN_LABEL,         PopulationInLabelActive),
 
	SDT_BOOL(Settings, gui.link_terraform_toolbar,            S, 0, false,                        STR_CONFIG_PATCHES_LINK_TERRAFORM_TOOLBAR,      NULL),
 
	 SDT_VAR(Settings, gui.liveries,               SLE_UINT8, S,MS,     2,        0,        2, 0, STR_CONFIG_PATCHES_LIVERIES,                    RedrawScreen),
 
	SDT_BOOL(Settings, gui.prefer_teamchat,                   S, 0, false,                        STR_CONFIG_PATCHES_PREFER_TEAMCHAT,             NULL),
 
	 SDT_VAR(Settings, gui.scrollwheel_scrolling,  SLE_UINT8, S,MS,     0,        0,        2, 0, STR_CONFIG_PATCHES_SCROLLWHEEL_SCROLLING,       NULL),
 
	 SDT_VAR(Settings, gui.scrollwheel_multiplier, SLE_UINT8, S, 0,     5,        1,       15, 1, STR_CONFIG_PATCHES_SCROLLWHEEL_MULTIPLIER,      NULL),
 
	SDT_BOOL(Settings, gui.pause_on_newgame,                  S, 0, false,                        STR_CONFIG_PATCHES_PAUSE_ON_NEW_GAME,           NULL),
 
	 SDT_VAR(Settings, gui.advanced_vehicle_list,  SLE_UINT8, S,MS,     1,        0,        2, 0, STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS,      NULL),
 
	SDT_BOOL(Settings, gui.timetable_in_ticks,                S, 0, false,                        STR_CONFIG_PATCHES_TIMETABLE_IN_TICKS,          NULL),
 
	 SDT_VAR(Settings, gui.loading_indicators,     SLE_UINT8, S,MS,     1,        0,        2, 0, STR_CONFIG_PATCHES_LOADING_INDICATORS,          RedrawScreen),
 
	 SDT_VAR(Settings, gui.default_rail_type,      SLE_UINT8, S,MS,     4,        0,        6, 0, STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE,           NULL),
 
	SDT_BOOL(Settings, gui.enable_signal_gui,                 S, 0, false,                        STR_CONFIG_PATCHES_ENABLE_SIGNAL_GUI,           CloseSignalGUI),
 
	 SDT_VAR(Settings, gui.drag_signals_density,   SLE_UINT8, S, 0,     4,        1,       20, 0, STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY,        DragSignalsDensityChanged),
 
	 SDT_VAR(Settings, gui.semaphore_build_before, SLE_INT32, S, NC, 1975, MIN_YEAR, MAX_YEAR, 1, STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE, ResetSignalVariant),
 
	SDT_BOOL(Settings, gui.train_income_warn,                 S, 0,  true,                        STR_CONFIG_PATCHES_WARN_INCOME_LESS,            NULL),
 
	 SDT_VAR(Settings, gui.order_review_system,    SLE_UINT8, S,MS,     2,        0,        2, 0, STR_CONFIG_PATCHES_ORDER_REVIEW,                NULL),
 
	SDT_BOOL(Settings, gui.lost_train_warn,                   S, 0,  true,                        STR_CONFIG_PATCHES_WARN_LOST_TRAIN,             NULL),
 
	SDT_BOOL(Settings, gui.autorenew,                         S, 0, false,                        STR_CONFIG_PATCHES_AUTORENEW_VEHICLE,           EngineRenewUpdate),
 
	 SDT_VAR(Settings, gui.autorenew_months,       SLE_INT16, S, 0,     6,      -12,       12, 0, STR_CONFIG_PATCHES_AUTORENEW_MONTHS,            EngineRenewMonthsUpdate),
 
	 SDT_VAR(Settings, gui.autorenew_money,         SLE_UINT, S,CR,100000,        0,  2000000, 0, STR_CONFIG_PATCHES_AUTORENEW_MONEY,             EngineRenewMoneyUpdate),
 
	SDT_BOOL(Settings, gui.always_build_infrastructure,       S, 0, false,                        STR_CONFIG_PATCHES_ALWAYS_BUILD_INFRASTRUCTURE, RedrawScreen),
 
	SDT_BOOL(Settings, gui.new_nonstop,                       S, 0, false,                        STR_CONFIG_PATCHES_NEW_NONSTOP,                 NULL),
 
	SDT_BOOL(Settings, gui.keep_all_autosave,                 S, 0, false,                        STR_NULL,                                       NULL),
 
	SDT_BOOL(Settings, gui.autosave_on_exit,                  S, 0, false,                        STR_NULL,                                       NULL),
 
	 SDT_VAR(Settings, gui.max_num_autosaves,      SLE_UINT8, S, 0,    16,        0,      255, 0, STR_NULL,                                       NULL),
 
	SDT_BOOL(Settings, gui.bridge_pillars,                    S, 0,  true,                        STR_NULL,                                       NULL),
 
	SDT_BOOL(Settings, gui.auto_euro,                         S, 0,  true,                        STR_NULL,                                       NULL),
 

	
 
	/* When a red signal is encountered, a small detour can be made around
 
	 * it. This specifically occurs when a track is doubled, in which case
 
	 * the detour is typically 2 tiles. It is also often used at station
 
	 * entrances, when there is a choice of multiple platforms. If we take
 
	 * a typical 4 platform station, the detour is 4 tiles. To properly
 
	 * support larger stations we increase this value.
 
	 * We want to prevent that trains that want to leave at one side of a
 
	 * station, leave through the other side, turn around, enter the
 
	 * station on another platform and exit the station on the right side
 
	 * again, just because the sign at the right side was red. If we take
 
	 * a typical 5 length station, this detour is 10 or 11 tiles (not
 
	 * sure), so we set the default penalty at 10 (the station tile
 
	 * penalty will further prevent this.
 
	 * We give presignal exits (and combo's) a different (larger) penalty, because
 
	 * we really don't want trains waiting in front of a presignal exit. */
 
	SDT_VAR(Patches, npf_rail_firstred_penalty,     SLE_UINT, 0, 0, (10 * NPF_TILE_LENGTH), 0, 100000, 0, STR_NULL, NULL),
 
	SDT_VAR(Patches, npf_rail_firstred_exit_penalty,SLE_UINT, 0, 0, (100 * NPF_TILE_LENGTH),0, 100000, 0, STR_NULL, NULL),
 
	/* This penalty is for when the last signal before the target is red.
 
	 * This is useful for train stations, where there are multiple
 
	 * platforms to choose from, which lie in different signal blocks.
 
	 * Every target in a occupied signal block (ie an occupied platform)
 
	 * will get this penalty. */
 
	SDT_VAR(Patches, npf_rail_lastred_penalty, SLE_UINT, 0, 0, (10 * NPF_TILE_LENGTH), 0, 100000, 0, STR_NULL, NULL),
 
	/* When a train plans a route over a station tile, this penalty is
 
	 * applied. We want that trains plan a route around a typical, 4x5
 
	 * station, which means two tiles to the right, and two tiles back to
 
	 * the left around it, or 5 tiles of station through it. If we assign
 
	 * a penalty of 1 tile for every station tile passed, the route will
 
	 * be around it. */
 
	SDT_VAR(Patches, npf_rail_station_penalty, SLE_UINT, 0, 0, (1 * NPF_TILE_LENGTH), 0, 100000, 0, STR_NULL, NULL),
 
	SDT_VAR(Patches, npf_rail_slope_penalty,   SLE_UINT, 0, 0, (1 * NPF_TILE_LENGTH), 0, 100000, 0, STR_NULL, NULL),
 
	/* This penalty is applied when a train makes a turn. Its value of 1 makes
 
	 * sure that it has a minimal impact on the pathfinding, only when two
 
	 * paths have equal length it will make a difference */
 
	SDT_VAR(Patches, npf_rail_curve_penalty,        SLE_UINT, 0, 0, 1,                      0, 100000, 0, STR_NULL, NULL),
 
	/* Ths penalty is applied when a vehicle reverses inside a depot (doesn't
 
	 * apply to ships, as they can just come out the other end). XXX: Is this a
 
	 * good value? */
 
	SDT_VAR(Patches, npf_rail_depot_reverse_penalty,SLE_UINT, 0, 0, (NPF_TILE_LENGTH * 50), 0, 100000, 0, STR_NULL, NULL),
 
	SDT_VAR(Patches, npf_buoy_penalty,              SLE_UINT, 0, 0, (2 * NPF_TILE_LENGTH),  0, 100000, 0, STR_NULL, NULL),
 
	/* This penalty is applied when a ship makes a turn. It is bigger than the
 
	 * rail curve penalty, since ships (realisticly) have more trouble with
 
	 * making turns */
 
	SDT_VAR(Patches, npf_water_curve_penalty,       SLE_UINT, 0, 0, (NPF_TILE_LENGTH / 4),  0, 100000, 0, STR_NULL, NULL),
 
	/* This is the penalty for road, same as for rail. */
 
	SDT_VAR(Patches, npf_road_curve_penalty,        SLE_UINT, 0, 0, 1,                      0, 100000, 0, STR_NULL, NULL),
 
	/* This is the penalty for level crossings, for both road and rail vehicles */
 
	SDT_VAR(Patches, npf_crossing_penalty,          SLE_UINT, 0, 0, (3 * NPF_TILE_LENGTH),  0, 100000, 0, STR_NULL, NULL),
 
	/* This is the penalty for drive-through road, stops. */
 
	SDT_CONDVAR (Patches, npf_road_drive_through_penalty, SLE_UINT, 47, SL_MAX_VERSION, 0, 0,  8 * NPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
 

	
 

	
 
	/* The maximum number of nodes to search */
 
	SDT_CONDBOOL(Patches, yapf.disable_node_optimization  ,           28, SL_MAX_VERSION, 0, 0, false                   ,                       STR_NULL, NULL),
 
	SDT_CONDVAR (Patches, yapf.max_search_nodes           , SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 10000                   ,      500, 1000000, 0, STR_NULL, NULL),
 
	SDT_CONDBOOL(Patches, yapf.rail_firstred_twoway_eol   ,           28, SL_MAX_VERSION, 0, 0,  true                   ,                       STR_NULL, NULL),
 
	SDT_CONDVAR (Patches, yapf.rail_firstred_penalty      , SLE_UINT, 28, SL_MAX_VERSION, 0, 0,    10 * YAPF_TILE_LENGTH,        0, 1000000, 0, STR_NULL, NULL),
 
	SDT_CONDVAR (Patches, yapf.rail_firstred_exit_penalty , SLE_UINT, 28, SL_MAX_VERSION, 0, 0,   100 * YAPF_TILE_LENGTH,        0, 1000000, 0, STR_NULL, NULL),
 
	SDT_CONDVAR (Patches, yapf.rail_lastred_penalty       , SLE_UINT, 28, SL_MAX_VERSION, 0, 0,    10 * YAPF_TILE_LENGTH,        0, 1000000, 0, STR_NULL, NULL),
 
	SDT_CONDVAR (Patches, yapf.rail_lastred_exit_penalty  , SLE_UINT, 28, SL_MAX_VERSION, 0, 0,   100 * YAPF_TILE_LENGTH,        0, 1000000, 0, STR_NULL, NULL),
 
	SDT_CONDVAR (Patches, yapf.rail_station_penalty       , SLE_UINT, 28, SL_MAX_VERSION, 0, 0,    30 * YAPF_TILE_LENGTH,        0, 1000000, 0, STR_NULL, NULL),
 
	SDT_CONDVAR (Patches, yapf.rail_slope_penalty         , SLE_UINT, 28, SL_MAX_VERSION, 0, 0,     2 * YAPF_TILE_LENGTH,        0, 1000000, 0, STR_NULL, NULL),
 
	SDT_CONDVAR (Patches, yapf.rail_curve45_penalty       , SLE_UINT, 28, SL_MAX_VERSION, 0, 0,     1 * YAPF_TILE_LENGTH,        0, 1000000, 0, STR_NULL, NULL),
 
	SDT_CONDVAR (Patches, yapf.rail_curve90_penalty       , SLE_UINT, 28, SL_MAX_VERSION, 0, 0,     6 * YAPF_TILE_LENGTH,        0, 1000000, 0, STR_NULL, NULL),
 
	/* This penalty is applied when a train reverses inside a depot */
 
	SDT_CONDVAR (Patches, yapf.rail_depot_reverse_penalty , SLE_UINT, 28, SL_MAX_VERSION, 0, 0,    50 * YAPF_TILE_LENGTH,        0, 1000000, 0, STR_NULL, NULL),
 
	/* This is the penalty for level crossings (for trains only) */
 
	SDT_CONDVAR (Patches, yapf.rail_crossing_penalty      , SLE_UINT, 28, SL_MAX_VERSION, 0, 0,     3 * YAPF_TILE_LENGTH,        0, 1000000, 0, STR_NULL, NULL),
 
	/* look-ahead how many signals are checked */
 
	SDT_CONDVAR (Patches, yapf.rail_look_ahead_max_signals, SLE_UINT, 28, SL_MAX_VERSION, 0, 0,    10                   ,        1,     100, 0, STR_NULL, NULL),
 
	/* look-ahead n-th red signal penalty polynomial: penalty = p2 * n^2 + p1 * n + p0 */
 
	SDT_CONDVAR (Patches, yapf.rail_look_ahead_signal_p0  , SLE_INT , 28, SL_MAX_VERSION, 0, 0,   500                   , -1000000, 1000000, 0, STR_NULL, NULL),
 
	SDT_CONDVAR (Patches, yapf.rail_look_ahead_signal_p1  , SLE_INT , 28, SL_MAX_VERSION, 0, 0,  -100                   , -1000000, 1000000, 0, STR_NULL, NULL),
 
	SDT_CONDVAR (Patches, yapf.rail_look_ahead_signal_p2  , SLE_INT , 28, SL_MAX_VERSION, 0, 0,     5                   , -1000000, 1000000, 0, STR_NULL, NULL),
 
	/* penalties for too long or too short station platforms */
 
	SDT_CONDVAR (Patches, yapf.rail_longer_platform_penalty,           SLE_UINT, 33, SL_MAX_VERSION, 0, 0,  8 * YAPF_TILE_LENGTH, 0,   20000, 0, STR_NULL, NULL),
 
	SDT_CONDVAR (Patches, yapf.rail_longer_platform_per_tile_penalty,  SLE_UINT, 33, SL_MAX_VERSION, 0, 0,  0 * YAPF_TILE_LENGTH, 0,   20000, 0, STR_NULL, NULL),
 
	SDT_CONDVAR (Patches, yapf.rail_shorter_platform_penalty,          SLE_UINT, 33, SL_MAX_VERSION, 0, 0, 40 * YAPF_TILE_LENGTH, 0,   20000, 0, STR_NULL, NULL),
 
	SDT_CONDVAR (Patches, yapf.rail_shorter_platform_per_tile_penalty, SLE_UINT, 33, SL_MAX_VERSION, 0, 0,  0 * YAPF_TILE_LENGTH, 0,   20000, 0, STR_NULL, NULL),
 
	/* road vehicles - penalties */
 
	SDT_CONDVAR (Patches, yapf.road_slope_penalty                    , SLE_UINT, 33, SL_MAX_VERSION, 0, 0,  2 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
 
	SDT_CONDVAR (Patches, yapf.road_curve_penalty                    , SLE_UINT, 33, SL_MAX_VERSION, 0, 0,  1 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
 
	SDT_CONDVAR (Patches, yapf.road_crossing_penalty                 , SLE_UINT, 33, SL_MAX_VERSION, 0, 0,  3 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
 
	SDT_CONDVAR (Patches, yapf.road_stop_penalty                     , SLE_UINT, 47, SL_MAX_VERSION, 0, 0,  8 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
 

	
 
	/***************************************************************************/
 
	/* Terrain genation related patch options */
 
	SDT_CONDVAR(Patches,      land_generator,           SLE_UINT8,  30, SL_MAX_VERSION, 0, MS,   1,                   0,    1,               0, STR_CONFIG_PATCHES_LAND_GENERATOR,           NULL),
 
	SDT_CONDVAR(Patches,      oil_refinery_limit,       SLE_UINT8,  30, SL_MAX_VERSION, 0, 0,   32,                  12,   48,               0, STR_CONFIG_PATCHES_OIL_REF_EDGE_DISTANCE,    NULL),
 
	SDT_CONDVAR(Patches,      tgen_smoothness,          SLE_UINT8,  30, SL_MAX_VERSION, 0, MS,   1,                   0,    3,               0, STR_CONFIG_PATCHES_ROUGHNESS_OF_TERRAIN,     NULL),
 
	SDT_CONDVAR(Patches,      generation_seed,          SLE_UINT32, 30, SL_MAX_VERSION, 0, 0,    GENERATE_NEW_SEED,   0, MAX_UVALUE(uint32), 0, STR_NULL,                                    NULL),
 
	SDT_CONDVAR(Patches,      tree_placer,              SLE_UINT8,  30, SL_MAX_VERSION, 0, MS,   2,                   0,    2,               0, STR_CONFIG_PATCHES_TREE_PLACER,              NULL),
 
	SDT_VAR    (Patches,      heightmap_rotation,       SLE_UINT8,                      S, MS,   0,                   0,    1,               0, STR_CONFIG_PATCHES_HEIGHTMAP_ROTATION,       NULL),
 
	SDT_VAR    (Patches,      se_flat_world_height,     SLE_UINT8,                      S, 0,    0,                   0,   15,               0, STR_CONFIG_PATCHES_SE_FLAT_WORLD_HEIGHT,     NULL),
 
	 SDT_VAR(Settings, game_creation.map_x,        SLE_UINT8, S, 0,     8,        6,       11, 0, STR_CONFIG_PATCHES_MAP_X,                       NULL),
 
	 SDT_VAR(Settings, game_creation.map_y,        SLE_UINT8, S, 0,     8,        6,       11, 0, STR_CONFIG_PATCHES_MAP_Y,                       NULL),
 

	
 
	/*
 
	 * Since the network code (CmdChangePatchSetting and friends) use the index in this array to decide
 
	 * which patch the server is talking about all conditional compilation of this array must be at the
 
	 * end. This isn't really the best solution, the patches the server can tell the client about should
 
	 * either use a seperate array or some other form of identifier.
 
	 */
 

	
 
#ifdef __APPLE__
 
	/* We might need to emulate a right mouse button on mac */
 
	SDT_VAR(Patches,right_mouse_btn_emulation,SLE_UINT8,S,MS,0, 0, 2, 0, STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU,   NULL),
 
	     SDT_VAR(Settings, gui.right_mouse_btn_emulation, SLE_UINT8, S, MS, 0, 0, 2, 0, STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU, NULL),
 
#endif
 

	
 
	SDT_END()
 
};
 

	
 
static const SettingDesc _currency_settings[] = {
 
@@ -1860,13 +1836,13 @@ static void HandleSettingDescs(IniFile *
 
	proc(ini, (const SettingDesc*)_music_settings,   "music", &msf);
 
#ifdef WIN32
 
	proc(ini, (const SettingDesc*)_win32_settings,   "win32", NULL);
 
#endif /* WIN32 */
 

	
 
	proc(ini, _gameopt_settings, "gameopt",  &_opt_newgame);
 
	proc(ini, _patch_settings,   "patches",  &_patches_newgame);
 
	proc(ini, _patch_settings,   "patches",  &_settings_newgame);
 
	proc(ini, _currency_settings,"currency", &_custom_currency);
 

	
 
#ifdef ENABLE_NETWORK
 
	proc(ini, (const SettingDesc*)_network_settings, "network", NULL);
 
	proc_list(ini, "servers", _network_host_list, lengthof(_network_host_list), NULL);
 
	proc_list(ini, "bans",    _network_ban_list,  lengthof(_network_ban_list), NULL);
 
@@ -1889,12 +1865,17 @@ void LoadFromConfig()
 
}
 

	
 
/** Save the values to the configuration file */
 
void SaveToConfig()
 
{
 
	IniFile *ini = ini_load(_config_file);
 

	
 
	/* Remove some obsolete groups. These have all been loaded into other groups. */
 
	ini_removegroup(ini, "patches");
 
	ini_removegroup(ini, "yapf");
 

	
 
	HandleSettingDescs(ini, ini_save_settings, ini_save_setting_list);
 
	GRFSaveConfig(ini, "newgrf", _grfconfig_newgame);
 
	GRFSaveConfig(ini, "newgrf-static", _grfconfig_static);
 
	NewsDisplaySaveConfig(ini, "news_display");
 
	SaveVersionInConfig(ini);
 
	ini_save(_config_file, ini);
 
@@ -1923,14 +1904,14 @@ CommandCost CmdChangePatchSetting(TileIn
 
	if (!SlIsObjectCurrentlyValid(sd->save.version_from, sd->save.version_to)) return CMD_ERROR;
 

	
 
	if ((sd->desc.flags & SGF_NETWORK_ONLY) && !_networking) return CMD_ERROR;
 
	if ((sd->desc.flags & SGF_NO_NETWORK) && _networking) return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
 
		Patches *patches_ptr = (_game_mode == GM_MENU) ? &_patches_newgame : &_patches;
 
		void *var = GetVariableAddress(patches_ptr, &sd->save);
 
		Settings *s = (_game_mode == GM_MENU) ? &_settings_newgame : &_settings;
 
		void *var = GetVariableAddress(s, &sd->save);
 
		Write_ValidateSetting(var, sd, (int32)p2);
 
		if (sd->desc.proc != NULL) sd->desc.proc((int32)ReadValue(var, sd->save.conv));
 

	
 
		InvalidateWindow(WC_GAME_OPTIONS, 0);
 
	}
 

	
 
@@ -1941,25 +1922,25 @@ CommandCost CmdChangePatchSetting(TileIn
 
 * @param index offset in the SettingDesc array of the Patches struct which
 
 * identifies the patch member we want to change
 
 * @param object pointer to a valid patches struct that has its settings change.
 
 * This only affects patch-members that are not needed to be the same on all
 
 * clients in a network game.
 
 * @param value new value of the patch */
 
bool SetPatchValue(uint index, const Patches *object, int32 value)
 
bool SetPatchValue(uint index, const Settings *object, int32 value)
 
{
 
	const SettingDesc *sd = &_patch_settings[index];
 
	/* If an item is player-based, we do not send it over the network
 
	 * (if any) to change. Also *hack*hack* we update the _newgame version
 
	 * of patches because changing a player-based setting in a game also
 
	 * changes its defaults. At least that is the convention we have chosen */
 
	if (sd->save.conv & SLF_NETWORK_NO) {
 
		void *var = GetVariableAddress(object, &sd->save);
 
		Write_ValidateSetting(var, sd, value);
 

	
 
		if (_game_mode != GM_MENU) {
 
			void *var2 = GetVariableAddress(&_patches_newgame, &sd->save);
 
			void *var2 = GetVariableAddress(&_settings_newgame, &sd->save);
 
			Write_ValidateSetting(var2, sd, value);
 
		}
 
		if (sd->desc.proc != NULL) sd->desc.proc((int32)ReadValue(var, sd->save.conv));
 
		InvalidateWindow(WC_GAME_OPTIONS, 0);
 
		return true;
 
	}
 
@@ -1987,24 +1968,23 @@ const SettingDesc *GetPatchFromName(cons
 
 * and besides, it is also better to keep stuff like this at the same place */
 
bool IConsoleSetPatchSetting(const char *name, int32 value)
 
{
 
	bool success;
 
	uint index;
 
	const SettingDesc *sd = GetPatchFromName(name, &index);
 
	const Patches *patches_ptr;
 
	void *ptr;
 

	
 
	if (sd == NULL) {
 
		IConsolePrintF(CC_WARNING, "'%s' is an unknown patch setting.", name);
 
		return true;
 
	}
 

	
 
	patches_ptr = (_game_mode == GM_MENU) ? &_patches_newgame : &_patches;
 
	ptr = GetVariableAddress(patches_ptr, &sd->save);
 
	Settings *s = (_game_mode == GM_MENU) ? &_settings_newgame : &_settings;
 
	ptr = GetVariableAddress(s, &sd->save);
 

	
 
	success = SetPatchValue(index, patches_ptr, value);
 
	success = SetPatchValue(index, s, value);
 
	return success;
 
}
 

	
 
void IConsoleGetPatchSetting(const char *name)
 
{
 
	char value[20];
 
@@ -2014,13 +1994,13 @@ void IConsoleGetPatchSetting(const char 
 

	
 
	if (sd == NULL) {
 
		IConsolePrintF(CC_WARNING, "'%s' is an unknown patch setting.", name);
 
		return;
 
	}
 

	
 
	ptr = GetVariableAddress((_game_mode == GM_MENU) ? &_patches_newgame : &_patches, &sd->save);
 
	ptr = GetVariableAddress((_game_mode == GM_MENU) ? &_settings_newgame : &_settings, &sd->save);
 

	
 
	if (sd->desc.cmd == SDT_BOOLX) {
 
		snprintf(value, sizeof(value), (*(bool*)ptr == 1) ? "on" : "off");
 
	} else {
 
		snprintf(value, sizeof(value), "%d", (int32)ReadValue(ptr, sd->save.conv));
 
	}
 
@@ -2032,13 +2012,13 @@ void IConsoleGetPatchSetting(const char 
 
void IConsoleListPatches()
 
{
 
	IConsolePrintF(CC_WARNING, "All patches with their current value:");
 

	
 
	for (const SettingDesc *sd = _patch_settings; sd->save.cmd != SL_END; sd++) {
 
		char value[80];
 
		const void *ptr = GetVariableAddress((_game_mode == GM_MENU) ? &_patches_newgame : &_patches, &sd->save);
 
		const void *ptr = GetVariableAddress((_game_mode == GM_MENU) ? &_settings_newgame : &_settings, &sd->save);
 

	
 
		if (sd->desc.cmd == SDT_BOOLX) {
 
			snprintf(value, lengthof(value), (*(bool*)ptr == 1) ? "on" : "off");
 
		} else {
 
			snprintf(value, lengthof(value), "%d", (uint32)ReadValue(ptr, sd->save.conv));
 
		}
 
@@ -2117,37 +2097,37 @@ static void Save_OPTS()
 

	
 
static void Load_PATS()
 
{
 
	/* Copy over default setting since some might not get loaded in
 
	 * a networking environment. This ensures for example that the local
 
	 * signal_side stays when joining a network-server */
 
	_patches = _patches_newgame;
 
	LoadSettings(_patch_settings, &_patches);
 
	_settings = _settings_newgame;
 
	LoadSettings(_patch_settings, &_settings);
 
}
 

	
 
static void Save_PATS()
 
{
 
	SaveSettings(_patch_settings, &_patches);
 
	SaveSettings(_patch_settings, &_settings);
 
}
 

	
 
void CheckConfig()
 
{
 
	// Increase old default values for pf_maxdepth and pf_maxlength
 
	// to support big networks.
 
	if (_patches_newgame.pf_maxdepth == 16 && _patches_newgame.pf_maxlength == 512) {
 
		_patches_newgame.pf_maxdepth = 48;
 
		_patches_newgame.pf_maxlength = 4096;
 
	if (_settings_newgame.pf.opf.pf_maxdepth == 16 && _settings_newgame.pf.opf.pf_maxlength == 512) {
 
		_settings_newgame.pf.opf.pf_maxdepth = 48;
 
		_settings_newgame.pf.opf.pf_maxlength = 4096;
 
	}
 
}
 

	
 
void UpdatePatches()
 
{
 
	/* Since old(er) savegames don't have any patches saved, we initialise
 
	 * them with the default values just as it was in the old days.
 
	 * Also new games need this copying-over */
 
	_patches = _patches_newgame; /* backwards compatibility */
 
	_settings = _settings_newgame; /* backwards compatibility */
 
}
 

	
 
extern const ChunkHandler _setting_chunk_handlers[] = {
 
	{ 'OPTS', Save_OPTS, Load_OPTS, CH_RIFF},
 
	{ 'PATS', Save_PATS, Load_PATS, CH_RIFF | CH_LAST},
 
};
src/settings_gui.cpp
Show inline comments
 
@@ -664,131 +664,131 @@ void ShowGameDifficulty()
 
{
 
	DeleteWindowById(WC_GAME_OPTIONS, 0);
 
	new GameDifficultyWindow();
 
}
 

	
 
static const char *_patches_ui[] = {
 
	"vehicle_speed",
 
	"status_long_date",
 
	"show_finances",
 
	"autoscroll",
 
	"reverse_scroll",
 
	"smooth_scroll",
 
	"errmsg_duration",
 
	"toolbar_pos",
 
	"measure_tooltip",
 
	"window_snap_radius",
 
	"population_in_label",
 
	"link_terraform_toolbar",
 
	"liveries",
 
	"prefer_teamchat",
 
	"gui.vehicle_speed",
 
	"gui.status_long_date",
 
	"gui.show_finances",
 
	"gui.autoscroll",
 
	"gui.reverse_scroll",
 
	"gui.smooth_scroll",
 
	"gui.errmsg_duration",
 
	"gui.toolbar_pos",
 
	"gui.measure_tooltip",
 
	"gui.window_snap_radius",
 
	"gui.population_in_label",
 
	"gui.link_terraform_toolbar",
 
	"gui.liveries",
 
	"gui.prefer_teamchat",
 
	/* While the horizontal scrollwheel scrolling is written as general code, only
 
	 *  the cocoa (OSX) driver generates input for it.
 
	 *  Since it's also able to completely disable the scrollwheel will we display it on all platforms anyway */
 
	"scrollwheel_scrolling",
 
	"scrollwheel_multiplier",
 
	"gui.scrollwheel_scrolling",
 
	"gui.scrollwheel_multiplier",
 
#ifdef __APPLE__
 
	/* We might need to emulate a right mouse button on mac */
 
	"right_mouse_btn_emulation",
 
	"gui.right_mouse_btn_emulation",
 
#endif
 
	"pause_on_newgame",
 
	"advanced_vehicle_list",
 
	"loading_indicators",
 
	"timetable_in_ticks",
 
	"default_rail_type",
 
	"always_build_infrastructure",
 
	"gui.pause_on_newgame",
 
	"gui.advanced_vehicle_list",
 
	"gui.loading_indicators",
 
	"gui.timetable_in_ticks",
 
	"gui.default_rail_type",
 
	"gui.always_build_infrastructure",
 
};
 

	
 
static const char *_patches_construction[] = {
 
	"build_on_slopes",
 
	"autoslope",
 
	"extra_dynamite",
 
	"longbridges",
 
	"signal_side",
 
	"always_small_airport",
 
	"enable_signal_gui",
 
	"drag_signals_density",
 
	"oil_refinery_limit",
 
	"semaphore_build_before",
 
	"construction.build_on_slopes",
 
	"construction.autoslope",
 
	"construction.extra_dynamite",
 
	"construction.longbridges",
 
	"construction.signal_side",
 
	"station.always_small_airport",
 
	"gui.enable_signal_gui",
 
	"gui.drag_signals_density",
 
	"game_creation.oil_refinery_limit",
 
	"gui.semaphore_build_before",
 
};
 

	
 
static const char *_patches_stations[] = {
 
	"join_stations",
 
	"improved_load",
 
	"selectgoods",
 
	"new_nonstop",
 
	"nonuniform_stations",
 
	"station_spread",
 
	"serviceathelipad",
 
	"modified_catchment",
 
	"gradual_loading",
 
	"road_stop_on_town_road",
 
	"adjacent_stations",
 
	"station_noise_level",
 
	"station.join_stations",
 
	"order.improved_load",
 
	"order.selectgoods",
 
	"gui.new_nonstop",
 
	"station.nonuniform_stations",
 
	"station.station_spread",
 
	"order.serviceathelipad",
 
	"station.modified_catchment",
 
	"order.gradual_loading",
 
	"construction.road_stop_on_town_road",
 
	"station.adjacent_stations",
 
	"economy.station_noise_level",
 
};
 

	
 
static const char *_patches_economy[] = {
 
	"inflation",
 
	"raw_industry_construction",
 
	"multiple_industry_per_town",
 
	"same_industry_close",
 
	"bribe",
 
	"exclusive_rights",
 
	"give_money",
 
	"colored_news_year",
 
	"ending_year",
 
	"smooth_economy",
 
	"allow_shares",
 
	"town_layout",
 
	"mod_road_rebuild",
 
	"town_growth_rate",
 
	"larger_towns",
 
	"initial_city_size",
 
	"economy.inflation",
 
	"construction.raw_industry_construction",
 
	"economy.multiple_industry_per_town",
 
	"economy.same_industry_close",
 
	"economy.bribe",
 
	"economy.exclusive_rights",
 
	"economy.give_money",
 
	"gui.colored_news_year",
 
	"gui.ending_year",
 
	"economy.smooth_economy",
 
	"economy.allow_shares",
 
	"economy.town_layout",
 
	"economy.mod_road_rebuild",
 
	"economy.town_growth_rate",
 
	"economy.larger_towns",
 
	"economy.initial_city_size",
 
};
 

	
 
static const char *_patches_ai[] = {
 
	"ainew_active",
 
	"ai_in_multiplayer",
 
	"ai_disable_veh_train",
 
	"ai_disable_veh_roadveh",
 
	"ai_disable_veh_aircraft",
 
	"ai_disable_veh_ship",
 
	"ai.ainew_active",
 
	"ai.ai_in_multiplayer",
 
	"ai.ai_disable_veh_train",
 
	"ai.ai_disable_veh_roadveh",
 
	"ai.ai_disable_veh_aircraft",
 
	"ai.ai_disable_veh_ship",
 
};
 

	
 
static const char *_patches_vehicles[] = {
 
	"realistic_acceleration",
 
	"forbid_90_deg",
 
	"mammoth_trains",
 
	"gotodepot",
 
	"roadveh_queue",
 
	"pathfinder_for_trains",
 
	"pathfinder_for_roadvehs",
 
	"pathfinder_for_ships",
 
	"train_income_warn",
 
	"order_review_system",
 
	"never_expire_vehicles",
 
	"lost_train_warn",
 
	"autorenew",
 
	"autorenew_months",
 
	"autorenew_money",
 
	"max_trains",
 
	"max_roadveh",
 
	"max_aircraft",
 
	"max_ships",
 
	"servint_ispercent",
 
	"servint_trains",
 
	"servint_roadveh",
 
	"servint_ships",
 
	"servint_aircraft",
 
	"no_servicing_if_no_breakdowns",
 
	"wagon_speed_limits",
 
	"disable_elrails",
 
	"freight_trains",
 
	"plane_speed",
 
	"timetabling",
 
	"dynamic_engines",
 
	"vehicle.realistic_acceleration",
 
	"pf.forbid_90_deg",
 
	"vehicle.mammoth_trains",
 
	"order.gotodepot",
 
	"pf.roadveh_queue",
 
	"pf.pathfinder_for_trains",
 
	"pf.pathfinder_for_roadvehs",
 
	"pf.pathfinder_for_ships",
 
	"gui.train_income_warn",
 
	"gui.order_review_system",
 
	"vehicle.never_expire_vehicles",
 
	"gui.lost_train_warn",
 
	"gui.autorenew",
 
	"gui.autorenew_months",
 
	"gui.autorenew_money",
 
	"vehicle.max_trains",
 
	"vehicle.max_roadveh",
 
	"vehicle.max_aircraft",
 
	"vehicle.max_ships",
 
	"vehicle.servint_ispercent",
 
	"vehicle.servint_trains",
 
	"vehicle.servint_roadveh",
 
	"vehicle.servint_ships",
 
	"vehicle.servint_aircraft",
 
	"order.no_servicing_if_no_breakdowns",
 
	"vehicle.wagon_speed_limits",
 
	"vehicle.disable_elrails",
 
	"vehicle.freight_trains",
 
	"vehicle.plane_speed",
 
	"order.timetabling",
 
	"vehicle.dynamic_engines",
 
};
 

	
 
struct PatchEntry {
 
	const SettingDesc *setting;
 
	uint index;
 
};
 
@@ -819,24 +819,24 @@ enum PatchesSelectionWidgets {
 
	PATCHSEL_STATIONS,
 
	PATCHSEL_ECONOMY,
 
	PATCHSEL_COMPETITORS
 
};
 

	
 
struct PatchesSelectionWindow : Window {
 
	static Patches *patches_ptr;
 
	static Settings *patches_ptr;
 
	static int patches_max;
 

	
 
	int page;
 
	int entry;
 
	int click;
 

	
 
	PatchesSelectionWindow(const WindowDesc *desc) : Window(desc)
 
	{
 
		static bool first_time = true;
 

	
 
		patches_ptr = (_game_mode == GM_MENU) ? &_patches_newgame : &_patches;
 
		patches_ptr = (_game_mode == GM_MENU) ? &_settings_newgame : &_settings;
 

	
 
		/* Build up the dynamic settings-array only once per OpenTTD session */
 
		if (first_time) {
 
			PatchPage *page;
 
			for (page = &_patches_page[0]; page != endof(_patches_page); page++) {
 
				uint i;
 
@@ -1042,13 +1042,13 @@ struct PatchesSelectionWindow : Window {
 
			SetPatchValue(pe->index, patches_ptr, value);
 
			this->SetDirty();
 
		}
 
	}
 
};
 

	
 
Patches *PatchesSelectionWindow::patches_ptr = NULL;
 
Settings *PatchesSelectionWindow::patches_ptr = NULL;
 
int PatchesSelectionWindow::patches_max = 0;
 

	
 
static const Widget _patches_selection_widgets[] = {
 
{   WWT_CLOSEBOX,   RESIZE_NONE,    10,     0,    10,     0,    13, STR_00C5,                        STR_018B_CLOSE_WINDOW},
 
{    WWT_CAPTION,   RESIZE_NONE,    10,    11,   369,     0,    13, STR_CONFIG_PATCHES_CAPTION,      STR_018C_WINDOW_TITLE_DRAG_THIS},
 
{      WWT_PANEL,   RESIZE_NONE,    10,     0,   369,    14,    41, 0x0,                             STR_NULL},
src/settings_internal.h
Show inline comments
 
@@ -81,9 +81,9 @@ typedef SettingDesc SettingDescGlobVarLi
 
enum IniGroupType {
 
	IGT_VARIABLES = 0, ///< values of the form "landscape = hilly"
 
	IGT_LIST      = 1, ///< a list of values, seperated by \n and terminated by the next group block
 
};
 

	
 
const SettingDesc *GetPatchFromName(const char *name, uint *i);
 
bool SetPatchValue(uint index, const Patches *object, int32 value);
 
bool SetPatchValue(uint index, const Settings *object, int32 value);
 

	
 
#endif /* SETTINGS_H */

Changeset was too big and was cut off... Show full diff anyway

0 comments (0 inline, 0 general)