summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-11-17 22:25:16 +0000
committerrubidium <rubidium@openttd.org>2007-11-17 22:25:16 +0000
commit7305a1f1fe4099a7b34e4f19356b775d1b5628b4 (patch)
tree5a088947831b7e86a3d18c2749d6dd39296de048 /src
parent2e8d37dcdf08afc074cbff9b610ddf9954af088e (diff)
downloadopenttd-7305a1f1fe4099a7b34e4f19356b775d1b5628b4.tar.xz
(svn r11452) -Change: do not allow configuration changes, that NewGRFs can directly use to change their behaviour, during network games as this can cause desyncs.
Diffstat (limited to 'src')
-rw-r--r--src/console_cmds.cpp6
-rw-r--r--src/settings.cpp27
-rw-r--r--src/settings.h3
-rw-r--r--src/settings_gui.cpp4
4 files changed, 25 insertions, 15 deletions
diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp
index 6002da263..764b7d6ae 100644
--- a/src/console_cmds.cpp
+++ b/src/console_cmds.cpp
@@ -1423,7 +1423,11 @@ DEF_CONSOLE_CMD(ConPatch)
if (GetArgumentInteger(&val, argv[2])) {
if (!IConsoleSetPatchSetting(argv[1], val)) {
- IConsoleError("This command/variable is only available to a network server.");
+ if (_network_server) {
+ IConsoleError("This command/variable is not available during network games.");
+ } else {
+ IConsoleError("This command/variable is only available to a network server.");
+ }
}
}
}
diff --git a/src/settings.cpp b/src/settings.cpp
index d268ff1df..b744e8ef8 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -1080,6 +1080,7 @@ static void ini_save_setting_list(IniFile *ini, const char *grpname, char **list
#define MS SGF_MULTISTRING
#define NO SGF_NETWORK_ONLY
#define CR SGF_CURRENCY
+#define NN SGF_NO_NETWORK
#include "table/strings.h"
@@ -1375,12 +1376,12 @@ const SettingDesc _patch_settings[] = {
/***************************************************************************/
/* Construction section of the GUI-configure patches window */
- SDT_BOOL(Patches, build_on_slopes, 0, 0, true, STR_CONFIG_PATCHES_BUILDONSLOPES, NULL),
+ 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, 0, true, STR_CONFIG_PATCHES_LONGBRIDGES, NULL),
- SDT_BOOL(Patches, signal_side, N, 0, true, STR_CONFIG_PATCHES_SIGNALSIDE, RedrawScreen),
- SDT_BOOL(Patches, always_small_airport, 0, 0, false, STR_CONFIG_PATCHES_SMALL_AIRPORTS, 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_VAR(Patches, drag_signals_density,SLE_UINT8,S, 0, 4, 1, 20, 0, STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY,NULL),
SDT_VAR(Patches, semaphore_build_before,SLE_INT32, S, NC, 1975, MIN_YEAR, MAX_YEAR, 1, STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE, NULL),
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),
@@ -1389,7 +1390,7 @@ const SettingDesc _patch_settings[] = {
/* Vehicle section of the GUI-configure patches window */
SDT_BOOL(Patches, realistic_acceleration, 0, 0, false, STR_CONFIG_PATCHES_REALISTICACCEL, NULL),
SDT_BOOL(Patches, forbid_90_deg, 0, 0, false, STR_CONFIG_PATCHES_FORBID_90_DEG, NULL),
- SDT_BOOL(Patches, mammoth_trains, 0, 0, true, STR_CONFIG_PATCHES_MAMMOTHTRAINS, 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_BOOL(Patches, new_pathfinding_all, 0, 0, false, STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL, NULL),
@@ -1400,7 +1401,7 @@ const SettingDesc _patch_settings[] = {
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, 0, false, STR_CONFIG_PATCHES_NEVER_EXPIRE_VEHICLES,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),
@@ -1416,19 +1417,19 @@ const SettingDesc _patch_settings[] = {
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, 0, true, STR_CONFIG_PATCHES_WAGONSPEEDLIMITS, UpdateConsists),
- SDT_CONDBOOL(Patches, disable_elrails, 38, SL_MAX_VERSION, 0, 0, false, STR_CONFIG_PATCHES_DISABLE_ELRAILS, SettingsDisableElrail),
- SDT_CONDVAR(Patches, freight_trains, SLE_UINT8, 39, SL_MAX_VERSION, 0, 0, 1, 1, 255, 1, STR_CONFIG_PATCHES_FREIGHT_TRAINS, 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),
/***************************************************************************/
/* Station section of the GUI-configure patches window */
SDT_BOOL(Patches, join_stations, 0, 0, true, STR_CONFIG_PATCHES_JOINSTATIONS, NULL),
- SDT_BOOL(Patches, full_load_any, 0, 0, true, STR_CONFIG_PATCHES_FULLLOADANY, NULL),
- SDT_BOOL(Patches, improved_load, 0, 0, false, STR_CONFIG_PATCHES_IMPROVEDLOAD, NULL),
+ SDT_BOOL(Patches, full_load_any, 0,NN, true, STR_CONFIG_PATCHES_FULLLOADANY, 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, 0, 0, false, STR_CONFIG_PATCHES_NEW_NONSTOP, NULL),
- SDT_BOOL(Patches, nonuniform_stations, 0, 0, true, STR_CONFIG_PATCHES_NONUNIFORM_STATIONS,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),
@@ -1803,6 +1804,8 @@ CommandCost CmdChangePatchSetting(TileIndex tile, uint32 flags, uint32 p1, uint3
if (sd == NULL) return CMD_ERROR;
if (!SlIsObjectCurrentlyValid(sd->save.version_from, sd->save.version_to)) 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);
diff --git a/src/settings.h b/src/settings.h
index 7d00a44a6..426744d16 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -37,7 +37,8 @@ enum SettingGuiFlagLong {
SGF_MULTISTRING = 1 << 2, ///< the value represents a limited number of string-options (internally integer)
SGF_NETWORK_ONLY = 1 << 3, ///< this setting only applies to network games
SGF_CURRENCY = 1 << 4, ///< the number represents money, so when reading value multiply by exchange rate
- SGF_END = 1 << 5,
+ SGF_NO_NETWORK = 1 << 5, ///< this setting does not apply to network games; it may not be changed during the game
+ SGF_END = 1 << 6,
/* 3 more possible flags */
};
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index aa255f31d..7c670fd14 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -827,6 +827,7 @@ static void PatchesSelectionWndProc(Window *w, WindowEvent *e)
// We do not allow changes of some items when we are a client in a networkgame
if (!(sd->save.conv & SLF_NETWORK_NO) && _networking && !_network_server) editable = false;
if ((sdb->flags & SGF_NETWORK_ONLY) && !_networking) editable = false;
+ if ((sdb->flags & SGF_NO_NETWORK) && _networking) editable = false;
if (sdb->cmd == SDT_BOOLX) {
static const int _bool_ctabs[2][2] = {{9, 4}, {7, 6}};
@@ -886,8 +887,9 @@ static void PatchesSelectionWndProc(Window *w, WindowEvent *e)
sd = page->entries[btn].setting;
/* return if action is only active in network, or only settable by server */
- if ((sd->desc.flags & SGF_NETWORK_ONLY) && !_networking) return;
if (!(sd->save.conv & SLF_NETWORK_NO) && _networking && !_network_server) return;
+ if ((sd->desc.flags & SGF_NETWORK_ONLY) && !_networking) return;
+ if ((sd->desc.flags & SGF_NO_NETWORK) && _networking) return;
var = GetVariableAddress(patches_ptr, &sd->save);
value = (int32)ReadValue(var, sd->save.conv);