Allow various settings to be changed in multiplayer

If the corresponding TTDPatch flag bit has not been observed by a NewGRF
pull/451/head
Jonathan G Rennison 2 years ago
parent 2f4f862480
commit 2af2c56d19

@ -2538,6 +2538,9 @@ STR_CONFIG_SETTING_SCENARIO_HOUSE_IGNORE_ZONES_OFF :Off
STR_CONFIG_SETTING_SCENARIO_HOUSE_IGNORE_ZONES_WITHIN_TOWN :Within town
STR_CONFIG_SETTING_SCENARIO_HOUSE_IGNORE_ZONES_ANYWHERE :Anywhere
STR_CONFIG_SETTING_NETWORK_CHANGE_NOT_ALLOWED :{WHITE}Can't change setting...
STR_CONFIG_SETTING_NETWORK_CHANGE_NOT_ALLOWED_NEWGRF :{WHITE}...setting is observed by a NewGRF
# Config errors
STR_CONFIG_ERROR :{WHITE}Error with the configuration file...
STR_CONFIG_ERROR_ARRAY :{WHITE}... error in array '{RAW_STRING}'

@ -86,6 +86,7 @@ byte _misc_grf_features = 0;
/** 32 * 8 = 256 flags. Apparently TTDPatch uses this many.. */
static uint32 _ttdpatch_flags[8];
static uint32 _observed_ttdpatch_flags[8];
/** Indicates which are the newgrf features currently loaded ingame */
GRFLoadedFeatures _loaded_newgrf_features;
@ -7315,8 +7316,14 @@ static uint32 GetParamVal(byte param, uint32 *cond_val)
return 0;
} else {
uint32 index = *cond_val / 0x20;
uint32 param_val = index < lengthof(_ttdpatch_flags) ? _ttdpatch_flags[index] : 0;
*cond_val %= 0x20;
uint32 param_val = 0;
if (index < lengthof(_ttdpatch_flags)) {
param_val = _ttdpatch_flags[index];
if (!HasBit(_cur.grfconfig->flags, GCF_STATIC) && !HasBit(_cur.grfconfig->flags, GCF_SYSTEM)) {
SetBit(_observed_ttdpatch_flags[index], *cond_val);
}
}
return param_val;
}
@ -9954,6 +9961,15 @@ static void InitializeGRFSpecial()
_ttdpatch_flags[4] = (1U << 0x00) // larger persistent storage
| ((_settings_game.economy.inflation ? 1U : 0U) << 0x01); // inflation is on
MemSetT(_observed_ttdpatch_flags, 0, lengthof(_observed_ttdpatch_flags));
}
bool HasTTDPatchFlagBeenObserved(uint flag)
{
uint index = flag / 0x20;
flag %= 0x20;
if (index >= lengthof(_ttdpatch_flags)) return false;
return HasBit(_observed_ttdpatch_flags[index], flag);
}
/** Reset and clear all NewGRF stations */

@ -1701,6 +1701,17 @@ static void TownZoneCustomValueChanged(int32 new_value)
if (_settings_game.economy.town_zone_calc_mode) UpdateTownRadii();
}
static bool CheckTTDPatchSettingFlag(uint flag)
{
extern bool HasTTDPatchFlagBeenObserved(uint flag);
if (_networking && HasTTDPatchFlagBeenObserved(flag)) {
ShowErrorMessage(STR_CONFIG_SETTING_NETWORK_CHANGE_NOT_ALLOWED, STR_CONFIG_SETTING_NETWORK_CHANGE_NOT_ALLOWED_NEWGRF, WL_ERROR);
return false;
}
return true;
}
/**
* Replace a passwords that are a literal asterisk with an empty string.
* @param newval The new string value for this password field.

@ -71,6 +71,7 @@ static bool CheckSharingWater(int32 &new_value);
static bool CheckSharingAir(int32 &new_value);
static void TownZoneModeChanged(int32 new_value);
static void TownZoneCustomValueChanged(int32 new_value);
static bool CheckTTDPatchSettingFlag(uint flag);
/* End - Callback Functions for the various settings */
@ -777,7 +778,6 @@ strhelp = STR_CONFIG_SETTING_EXTRADYNAMITE_HELPTEXT
var = construction.max_bridge_length
type = SLE_UINT16
from = SLV_159
flags = SF_NO_NETWORK
def = 64
min = 1
max = 4096
@ -785,6 +785,7 @@ interval = 1
str = STR_CONFIG_SETTING_MAX_BRIDGE_LENGTH
strhelp = STR_CONFIG_SETTING_MAX_BRIDGE_LENGTH_HELPTEXT
strval = STR_CONFIG_SETTING_TILE_LENGTH
pre_cb = [](int32 &new_value) -> bool { return CheckTTDPatchSettingFlag(0x0F); }
[SDT_XREF]
extver = SlXvFeatureTest(XSLFTO_AND, XSLFI_SPRINGPP, 2)
@ -862,22 +863,23 @@ to = SLV_159
[SDT_VAR]
var = construction.train_signal_side
type = SLE_UINT8
flags = SF_GUI_DROPDOWN | SF_NO_NETWORK
flags = SF_GUI_DROPDOWN
def = 1
min = 0
max = 2
str = STR_CONFIG_SETTING_SIGNALSIDE
strhelp = STR_CONFIG_SETTING_SIGNALSIDE_HELPTEXT
strval = STR_CONFIG_SETTING_SIGNALSIDE_LEFT
pre_cb = [](int32 &new_value) -> bool { return CheckTTDPatchSettingFlag(0x3B); }
post_cb = [](auto) { MarkWholeScreenDirty(); }
cat = SC_BASIC
[SDT_BOOL]
var = station.never_expire_airports
flags = SF_NO_NETWORK
def = false
str = STR_CONFIG_SETTING_NEVER_EXPIRE_AIRPORTS
strhelp = STR_CONFIG_SETTING_NEVER_EXPIRE_AIRPORTS_HELPTEXT
pre_cb = [](int32 &new_value) -> bool { return CheckTTDPatchSettingFlag(0x0C); }
[SDT_VAR]
var = economy.town_layout
@ -911,10 +913,10 @@ extver = SlXvFeatureTest(XSLFTO_AND, XSLFI_SPRINGPP, 7)
[SDT_BOOL]
var = economy.allow_town_roads
from = SLV_113
flags = SF_NO_NETWORK
def = true
str = STR_CONFIG_SETTING_ALLOW_TOWN_ROADS
strhelp = STR_CONFIG_SETTING_ALLOW_TOWN_ROADS_HELPTEXT
pre_cb = [](int32 &new_value) -> bool { return CheckTTDPatchSettingFlag(0x62); }
[SDT_XREF]
xref = ""economy.old_town_cargo_factor""
@ -1736,10 +1738,10 @@ strhelp = STR_CONFIG_SETTING_NOSERVICE_HELPTEXT
[SDT_BOOL]
var = vehicle.wagon_speed_limits
flags = SF_NO_NETWORK
def = true
str = STR_CONFIG_SETTING_WAGONSPEEDLIMITS
strhelp = STR_CONFIG_SETTING_WAGONSPEEDLIMITS_HELPTEXT
pre_cb = [](int32 &new_value) -> bool { return CheckTTDPatchSettingFlag(0x5D); }
post_cb = UpdateConsists
;; vehicle.slow_road_vehicles_in_curves
@ -1782,7 +1784,6 @@ cat = SC_EXPERT
var = vehicle.freight_trains
type = SLE_UINT8
from = SLV_39
flags = SF_NO_NETWORK
def = 1
min = 1
max = 255
@ -1790,6 +1791,7 @@ interval = 1
str = STR_CONFIG_SETTING_FREIGHT_TRAINS
strhelp = STR_CONFIG_SETTING_FREIGHT_TRAINS_HELPTEXT
strval = STR_JUST_COMMA
pre_cb = [](int32 &new_value) -> bool { return CheckTTDPatchSettingFlag(0x58); }
post_cb = UpdateConsists
;; vehicle.freight_mult_to_passengers
@ -2200,11 +2202,11 @@ extver = SlXvFeatureTest(XSLFTO_AND, XSLFI_SPRINGPP)
##
[SDT_BOOL]
var = economy.inflation
flags = SF_NO_NETWORK
def = false
str = STR_CONFIG_SETTING_INFLATION
strhelp = STR_CONFIG_SETTING_INFLATION_HELPTEXT
cat = SC_BASIC
pre_cb = [](int32 &new_value) -> bool { return CheckTTDPatchSettingFlag(0x81); }
[SDT_BOOL]
var = economy.inflation_fixed_dates

Loading…
Cancel
Save