mirror of https://github.com/OpenTTD/OpenTTD
Feature: Allow vehicle replacements even if new road or rail type is not compatible.
parent
b5e04974be
commit
ced241ed87
|
@ -71,7 +71,10 @@ bool CheckAutoreplaceValidity(EngineID from, EngineID to, CompanyID company)
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case VEH_TRAIN: {
|
case VEH_TRAIN: {
|
||||||
/* make sure the railtypes are compatible */
|
/* make sure the railtypes are compatible */
|
||||||
if ((GetRailTypeInfo(e_from->u.rail.railtype)->compatible_railtypes & GetRailTypeInfo(e_to->u.rail.railtype)->compatible_railtypes) == 0) return false;
|
if (!_settings_game.depot.allow_no_comp_railtype_replacements &&
|
||||||
|
(GetRailTypeInfo(e_from->u.rail.railtype)->compatible_railtypes & GetRailTypeInfo(e_to->u.rail.railtype)->compatible_railtypes) == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* make sure we do not replace wagons with engines or vice versa */
|
/* make sure we do not replace wagons with engines or vice versa */
|
||||||
if ((e_from->u.rail.railveh_type == RAILVEH_WAGON) != (e_to->u.rail.railveh_type == RAILVEH_WAGON)) return false;
|
if ((e_from->u.rail.railveh_type == RAILVEH_WAGON) != (e_to->u.rail.railveh_type == RAILVEH_WAGON)) return false;
|
||||||
|
@ -79,11 +82,15 @@ bool CheckAutoreplaceValidity(EngineID from, EngineID to, CompanyID company)
|
||||||
}
|
}
|
||||||
|
|
||||||
case VEH_ROAD:
|
case VEH_ROAD:
|
||||||
|
if (!_settings_game.depot.allow_no_comp_roadtype_replacements) {
|
||||||
/* make sure the roadtypes are compatible */
|
/* make sure the roadtypes are compatible */
|
||||||
if ((GetRoadTypeInfo(e_from->u.road.roadtype)->powered_roadtypes & GetRoadTypeInfo(e_to->u.road.roadtype)->powered_roadtypes) == ROADTYPES_NONE) return false;
|
if ((GetRoadTypeInfo(e_from->u.road.roadtype)->powered_roadtypes & GetRoadTypeInfo(e_to->u.road.roadtype)->powered_roadtypes) == ROADTYPES_NONE) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* make sure that we do not replace a tram with a normal road vehicles or vice versa */
|
/* make sure that we do not replace a tram with a normal road vehicles or vice versa */
|
||||||
if (HasBit(e_from->info.misc_flags, EF_ROAD_TRAM) != HasBit(e_to->info.misc_flags, EF_ROAD_TRAM)) return false;
|
if (HasBit(e_from->info.misc_flags, EF_ROAD_TRAM) != HasBit(e_to->info.misc_flags, EF_ROAD_TRAM)) return false;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VEH_AIRCRAFT:
|
case VEH_AIRCRAFT:
|
||||||
|
|
|
@ -1464,6 +1464,7 @@ STR_CONFIG_SETTING_STOP_ON_TOWN_ROAD_HELPTEXT :Allow construct
|
||||||
STR_CONFIG_SETTING_STOP_ON_COMPETITOR_ROAD :Allow drive-through road stops on roads owned by competitors: {STRING2}
|
STR_CONFIG_SETTING_STOP_ON_COMPETITOR_ROAD :Allow drive-through road stops on roads owned by competitors: {STRING2}
|
||||||
STR_CONFIG_SETTING_STOP_ON_COMPETITOR_ROAD_HELPTEXT :Allow construction of drive-through road stops on roads owned by other companies
|
STR_CONFIG_SETTING_STOP_ON_COMPETITOR_ROAD_HELPTEXT :Allow construction of drive-through road stops on roads owned by other companies
|
||||||
STR_CONFIG_SETTING_DYNAMIC_ENGINES_EXISTING_VEHICLES :{WHITE}Changing this setting is not possible when there are vehicles
|
STR_CONFIG_SETTING_DYNAMIC_ENGINES_EXISTING_VEHICLES :{WHITE}Changing this setting is not possible when there are vehicles
|
||||||
|
STR_CONFIG_SETTING_REPLACEMENTS_DIFF_TYPE :{WHITE}Disabling this setting is not possible during a game
|
||||||
|
|
||||||
STR_CONFIG_SETTING_INFRASTRUCTURE_MAINTENANCE :Infrastructure maintenance: {STRING2}
|
STR_CONFIG_SETTING_INFRASTRUCTURE_MAINTENANCE :Infrastructure maintenance: {STRING2}
|
||||||
STR_CONFIG_SETTING_INFRASTRUCTURE_MAINTENANCE_HELPTEXT :When enabled, infrastructure causes maintenance costs. The cost grows over-proportional with the network size, thus affecting bigger companies more than smaller ones
|
STR_CONFIG_SETTING_INFRASTRUCTURE_MAINTENANCE_HELPTEXT :When enabled, infrastructure causes maintenance costs. The cost grows over-proportional with the network size, thus affecting bigger companies more than smaller ones
|
||||||
|
@ -1621,6 +1622,10 @@ STR_CONFIG_SETTING_DISTANT_JOIN_DEPOTS :Allow to join d
|
||||||
STR_CONFIG_SETTING_DISTANT_JOIN_DEPOTS_HELPTEXT :Allow adding parts to a depot without directly touching the existing parts. Needs Ctrl+Click while placing the new parts
|
STR_CONFIG_SETTING_DISTANT_JOIN_DEPOTS_HELPTEXT :Allow adding parts to a depot without directly touching the existing parts. Needs Ctrl+Click while placing the new parts
|
||||||
STR_CONFIG_SETTING_DEPOT_SPREAD :Maximum depot spread: {STRING2}
|
STR_CONFIG_SETTING_DEPOT_SPREAD :Maximum depot spread: {STRING2}
|
||||||
STR_CONFIG_SETTING_DEPOT_SPREAD_HELPTEXT :Maximum area the parts of a single depot may be spread out on.
|
STR_CONFIG_SETTING_DEPOT_SPREAD_HELPTEXT :Maximum area the parts of a single depot may be spread out on.
|
||||||
|
STR_CONFIG_SETTING_REPLACE_INCOMPATIBLE_RAIL :Allow replacing rail vehicles with incompatible rail types: {STRING2}
|
||||||
|
STR_CONFIG_SETTING_REPLACE_INCOMPATIBLE_RAIL_HELPTEXT :Allow replacing rail vehicles even if they are not compatible by rail type.
|
||||||
|
STR_CONFIG_SETTING_REPLACE_INCOMPATIBLE_ROAD :Allow replacing road vehicles with incompatible road types: {STRING2}
|
||||||
|
STR_CONFIG_SETTING_REPLACE_INCOMPATIBLE_ROAD_HELPTEXT :Allow replacing road vehicles even if they are not compatible by road type.
|
||||||
|
|
||||||
STR_CONFIG_SETTING_STATION_SPREAD :Maximum station spread: {STRING2}
|
STR_CONFIG_SETTING_STATION_SPREAD :Maximum station spread: {STRING2}
|
||||||
STR_CONFIG_SETTING_STATION_SPREAD_HELPTEXT :Maximum area the parts of a single station may be spread out on. Note that high values will slow the game
|
STR_CONFIG_SETTING_STATION_SPREAD_HELPTEXT :Maximum area the parts of a single station may be spread out on. Note that high values will slow the game
|
||||||
|
|
|
@ -814,6 +814,11 @@ bool AfterLoadGame()
|
||||||
_settings_game.depot.distant_join_depots = true;
|
_settings_game.depot.distant_join_depots = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IsSavegameVersionBefore(SLV_ALLOW_INCOMPATIBLE_REPLACEMENTS)) {
|
||||||
|
_settings_game.depot.allow_no_comp_railtype_replacements = false;
|
||||||
|
_settings_game.depot.allow_no_comp_roadtype_replacements = false;
|
||||||
|
}
|
||||||
|
|
||||||
/* Load the sprites */
|
/* Load the sprites */
|
||||||
GfxLoadSprites();
|
GfxLoadSprites();
|
||||||
LoadStringWidthTable();
|
LoadStringWidthTable();
|
||||||
|
|
|
@ -393,6 +393,7 @@ enum SaveLoadVersion : uint16_t {
|
||||||
SLV_DEPOTS_ALIGN_RAIL_DEPOT_BITS, ///< 316 PR#XXXXX Align one bit for rail depots.
|
SLV_DEPOTS_ALIGN_RAIL_DEPOT_BITS, ///< 316 PR#XXXXX Align one bit for rail depots.
|
||||||
SLV_ADD_MEMBERS_TO_DEPOT_STRUCT, ///< 317 PR#XXXXX Add some members to depot struct.
|
SLV_ADD_MEMBERS_TO_DEPOT_STRUCT, ///< 317 PR#XXXXX Add some members to depot struct.
|
||||||
SLV_DEPOT_SPREAD, ///< 318 PR#XXXXX Add a setting for max depot spread.
|
SLV_DEPOT_SPREAD, ///< 318 PR#XXXXX Add a setting for max depot spread.
|
||||||
|
SLV_ALLOW_INCOMPATIBLE_REPLACEMENTS, ///< 319 PR#XXXXX Allow incompatible vehicle replacements.
|
||||||
|
|
||||||
SL_MAX_VERSION, ///< Highest possible saveload version
|
SL_MAX_VERSION, ///< Highest possible saveload version
|
||||||
};
|
};
|
||||||
|
|
|
@ -2149,6 +2149,9 @@ static SettingsContainer &GetSettingsTree()
|
||||||
{
|
{
|
||||||
depots->Add(new SettingEntry("depot.depot_spread"));
|
depots->Add(new SettingEntry("depot.depot_spread"));
|
||||||
depots->Add(new SettingEntry("depot.distant_join_depots"));
|
depots->Add(new SettingEntry("depot.distant_join_depots"));
|
||||||
|
|
||||||
|
depots->Add(new SettingEntry("depot.allow_no_comp_railtype_replacements"));
|
||||||
|
depots->Add(new SettingEntry("depot.allow_no_comp_roadtype_replacements"));
|
||||||
}
|
}
|
||||||
|
|
||||||
limitations->Add(new SettingEntry("construction.command_pause_level"));
|
limitations->Add(new SettingEntry("construction.command_pause_level"));
|
||||||
|
|
|
@ -380,6 +380,22 @@ static void SpriteZoomMinChanged(int32_t)
|
||||||
MarkWholeScreenDirty();
|
MarkWholeScreenDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool CheckDifferentRailRoadTypesReplacements(int32_t &new_value)
|
||||||
|
{
|
||||||
|
if (_game_mode == GM_NORMAL) {
|
||||||
|
if (new_value == 0) {
|
||||||
|
ShowErrorMessage(STR_CONFIG_SETTING_REPLACEMENTS_DIFF_TYPE, INVALID_STRING_ID, WL_ERROR);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void InvalidateReplacementWindows(int32_t)
|
||||||
|
{
|
||||||
|
InvalidateWindowClassesData(WC_REPLACE_VEHICLE);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update any possible saveload window and delete any newgrf dialogue as
|
* Update any possible saveload window and delete any newgrf dialogue as
|
||||||
* its widget parts might change. Reinit all windows as it allows access to the
|
* its widget parts might change. Reinit all windows as it allows access to the
|
||||||
|
|
|
@ -575,6 +575,9 @@ struct DepotSettings {
|
||||||
uint8_t depot_spread; ///< amount a depot may spread
|
uint8_t depot_spread; ///< amount a depot may spread
|
||||||
bool adjacent_depots; ///< allow depots to be built directly adjacent to other depots
|
bool adjacent_depots; ///< allow depots to be built directly adjacent to other depots
|
||||||
bool distant_join_depots; ///< allow to join non-adjacent depots
|
bool distant_join_depots; ///< allow to join non-adjacent depots
|
||||||
|
|
||||||
|
bool allow_no_comp_railtype_replacements; ///< allow replacing rail vehicles even if rail type is not compatible
|
||||||
|
bool allow_no_comp_roadtype_replacements; ///< allow replacing road vehicles even if road type is not compatible
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Default settings for vehicles. */
|
/** Default settings for vehicles. */
|
||||||
|
|
|
@ -21,6 +21,8 @@ static bool CheckRoadSide(int32_t &new_value);
|
||||||
static bool CheckDynamicEngines(int32_t &new_value);
|
static bool CheckDynamicEngines(int32_t &new_value);
|
||||||
static void StationCatchmentChanged(int32_t new_value);
|
static void StationCatchmentChanged(int32_t new_value);
|
||||||
static void MaxVehiclesChanged(int32_t new_value);
|
static void MaxVehiclesChanged(int32_t new_value);
|
||||||
|
static bool CheckDifferentRailRoadTypesReplacements(int32_t &new_value);
|
||||||
|
static void InvalidateReplacementWindows(int32_t new_value);
|
||||||
|
|
||||||
static const SettingVariant _game_settings_table[] = {
|
static const SettingVariant _game_settings_table[] = {
|
||||||
[post-amble]
|
[post-amble]
|
||||||
|
@ -172,6 +174,26 @@ strval = STR_CONFIG_SETTING_TILE_LENGTH
|
||||||
post_cb = [](auto) { CloseWindowByClass(WC_SELECT_DEPOT); }
|
post_cb = [](auto) { CloseWindowByClass(WC_SELECT_DEPOT); }
|
||||||
cat = SC_BASIC
|
cat = SC_BASIC
|
||||||
|
|
||||||
|
[SDT_BOOL]
|
||||||
|
var = depot.allow_no_comp_railtype_replacements
|
||||||
|
from = SLV_ALLOW_INCOMPATIBLE_REPLACEMENTS
|
||||||
|
def = false
|
||||||
|
str = STR_CONFIG_SETTING_REPLACE_INCOMPATIBLE_RAIL
|
||||||
|
strhelp = STR_CONFIG_SETTING_REPLACE_INCOMPATIBLE_RAIL_HELPTEXT
|
||||||
|
pre_cb = CheckDifferentRailRoadTypesReplacements
|
||||||
|
post_cb = InvalidateReplacementWindows
|
||||||
|
cat = SC_EXPERT
|
||||||
|
|
||||||
|
[SDT_BOOL]
|
||||||
|
var = depot.allow_no_comp_roadtype_replacements
|
||||||
|
from = SLV_ALLOW_INCOMPATIBLE_REPLACEMENTS
|
||||||
|
def = false
|
||||||
|
str = STR_CONFIG_SETTING_REPLACE_INCOMPATIBLE_ROAD
|
||||||
|
strhelp = STR_CONFIG_SETTING_REPLACE_INCOMPATIBLE_ROAD_HELPTEXT
|
||||||
|
pre_cb = CheckDifferentRailRoadTypesReplacements
|
||||||
|
post_cb = InvalidateReplacementWindows
|
||||||
|
cat = SC_EXPERT
|
||||||
|
|
||||||
[SDT_OMANY]
|
[SDT_OMANY]
|
||||||
var = vehicle.road_side
|
var = vehicle.road_side
|
||||||
type = SLE_UINT8
|
type = SLE_UINT8
|
||||||
|
|
Loading…
Reference in New Issue