|
@@ -643,55 +643,55 @@ static void ini_save_setting_list(IniFil
|
|
|
}
|
|
|
|
|
|
/* Begin - Callback Functions for the various settings
|
|
|
* virtual PositionMainToolbar function, calls the right one.*/
|
|
|
static bool v_PositionMainToolbar(int32 p1)
|
|
|
{
|
|
|
if (_game_mode != GM_MENU) PositionMainToolbar(NULL);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static bool PopulationInLabelActive(int32 p1)
|
|
|
{
|
|
|
UpdateAllTownVirtCoords();
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static bool RedrawScreen(int32 p1)
|
|
|
{
|
|
|
MarkWholeScreenDirty();
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static bool InvalidateDetailsWindow(int32 p1)
|
|
|
{
|
|
|
InvalidateWindowClasses(WC_VEHICLE_DETAILS);
|
|
|
SetWindowClassesDirty(WC_VEHICLE_DETAILS);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static bool InvalidateStationBuildWindow(int32 p1)
|
|
|
{
|
|
|
InvalidateWindow(WC_BUILD_STATION, 0);
|
|
|
SetWindowDirty(WC_BUILD_STATION, 0);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static bool InvalidateBuildIndustryWindow(int32 p1)
|
|
|
{
|
|
|
InvalidateWindowData(WC_BUILD_INDUSTRY, 0);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static bool CloseSignalGUI(int32 p1)
|
|
|
{
|
|
|
if (p1 == 0) {
|
|
|
DeleteWindowByClass(WC_BUILD_SIGNAL);
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static bool InvalidateTownViewWindow(int32 p1)
|
|
|
{
|
|
|
InvalidateWindowClassesData(WC_TOWN_VIEW, p1);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static bool DeleteSelectStationWindow(int32 p1)
|
|
@@ -731,49 +731,49 @@ static bool CheckInterval(int32 p1)
|
|
|
vds->servint_aircraft = 360;
|
|
|
vds->servint_ships = 100;
|
|
|
}
|
|
|
|
|
|
InvalidateDetailsWindow(0);
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static bool TrainAccelerationModelChanged(int32 p1)
|
|
|
{
|
|
|
Train *t;
|
|
|
FOR_ALL_TRAINS(t) {
|
|
|
if (t->IsFrontEngine()) {
|
|
|
t->tcache.cached_max_curve_speed = GetTrainCurveSpeedLimit(t);
|
|
|
UpdateTrainAcceleration(t);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static bool DragSignalsDensityChanged(int32)
|
|
|
{
|
|
|
InvalidateWindow(WC_BUILD_SIGNAL, 0);
|
|
|
SetWindowDirty(WC_BUILD_SIGNAL, 0);
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* A: competitors
|
|
|
* B: competitor start time. Deprecated since savegame version 110.
|
|
|
* C: town count (3 = high, 0 = very low)
|
|
|
* D: industry count (4 = high, 0 = none)
|
|
|
* E: inital loan (in GBP)
|
|
|
* F: interest rate
|
|
|
* G: running costs (0 = low, 2 = high)
|
|
|
* H: construction speed of competitors (0 = very slow, 4 = very fast)
|
|
|
* I: competitor intelligence. Deprecated since savegame version 110.
|
|
|
* J: breakdowns (0 = off, 2 = normal)
|
|
|
* K: subsidy multiplier (0 = 1.5, 3 = 4.0)
|
|
|
* L: construction cost (0-2)
|
|
|
* M: terrain type (0 = very flat, 3 = mountainous)
|
|
|
* N: amount of water (0 = very low, 3 = high)
|
|
|
* O: economy (0 = steady, 1 = fluctuating)
|
|
|
* P: Train reversing (0 = end of line + stations, 1 = end of line)
|
|
|
* Q: disasters
|
|
|
* R: area restructuring (0 = permissive, 2 = hostile)
|
|
|
* S: the difficulty level
|
|
@@ -799,49 +799,49 @@ void SetDifficultyLevel(int mode, Diffic
|
|
|
/**
|
|
|
* Checks the difficulty levels read from the configuration and
|
|
|
* forces them to be correct when invalid.
|
|
|
*/
|
|
|
void CheckDifficultyLevels()
|
|
|
{
|
|
|
if (_settings_newgame.difficulty.diff_level != 3) {
|
|
|
SetDifficultyLevel(_settings_newgame.difficulty.diff_level, &_settings_newgame.difficulty);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
static bool DifficultyReset(int32 level)
|
|
|
{
|
|
|
SetDifficultyLevel(level, (_game_mode == GM_MENU) ? &_settings_newgame.difficulty : &_settings_game.difficulty);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static bool DifficultyChange(int32)
|
|
|
{
|
|
|
if (_game_mode == GM_MENU) {
|
|
|
if (_settings_newgame.difficulty.diff_level != 3) {
|
|
|
ShowErrorMessage(INVALID_STRING_ID, STR_WARNING_DIFFICULTY_TO_CUSTOM, 0, 0);
|
|
|
_settings_newgame.difficulty.diff_level = 3;
|
|
|
}
|
|
|
InvalidateWindowClasses(WC_SELECT_GAME);
|
|
|
SetWindowClassesDirty(WC_SELECT_GAME);
|
|
|
} else {
|
|
|
_settings_game.difficulty.diff_level = 3;
|
|
|
}
|
|
|
|
|
|
/* 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
|
|
|
* the new difficulty settings */
|
|
|
if (_networking && FindWindowById(WC_GAME_OPTIONS, 0) != NULL) {
|
|
|
ShowGameDifficulty();
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static bool DifficultyNoiseChange(int32 i)
|
|
|
{
|
|
|
if (_game_mode == GM_NORMAL) {
|
|
|
UpdateAirportsNoise();
|
|
|
if (_settings_game.economy.station_noise_level) {
|
|
|
InvalidateWindowClassesData(WC_TOWN_VIEW, 0);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return DifficultyChange(i);
|
|
@@ -1425,112 +1425,112 @@ CommandCost CmdChangeSetting(TileIndex t
|
|
|
|
|
|
if (flags & DC_EXEC) {
|
|
|
GameSettings *s = (_game_mode == GM_MENU) ? &_settings_newgame : &_settings_game;
|
|
|
void *var = GetVariableAddress(s, &sd->save);
|
|
|
|
|
|
int32 oldval = (int32)ReadValue(var, sd->save.conv);
|
|
|
int32 newval = (int32)p2;
|
|
|
|
|
|
Write_ValidateSetting(var, sd, newval);
|
|
|
newval = (int32)ReadValue(var, sd->save.conv);
|
|
|
|
|
|
if (oldval == newval) return CommandCost();
|
|
|
|
|
|
if (sd->desc.proc != NULL && !sd->desc.proc(newval)) {
|
|
|
WriteValue(var, sd->save.conv, (int64)oldval);
|
|
|
return CommandCost();
|
|
|
}
|
|
|
|
|
|
if (sd->desc.flags & SGF_NO_NETWORK) {
|
|
|
GamelogStartAction(GLAT_SETTING);
|
|
|
GamelogSetting(sd->desc.name, oldval, newval);
|
|
|
GamelogStopAction();
|
|
|
}
|
|
|
|
|
|
InvalidateWindow(WC_GAME_OPTIONS, 0);
|
|
|
SetWindowDirty(WC_GAME_OPTIONS, 0);
|
|
|
}
|
|
|
|
|
|
return CommandCost();
|
|
|
}
|
|
|
|
|
|
/** Change one of the per-company settings.
|
|
|
* @param tile unused
|
|
|
* @param flags operation to perform
|
|
|
* @param p1 the index of the setting in the _company_settings array which identifies it
|
|
|
* @param p2 the new value for the setting
|
|
|
* The new value is properly clamped to its minimum/maximum when setting
|
|
|
*/
|
|
|
CommandCost CmdChangeCompanySetting(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
|
|
{
|
|
|
if (p1 >= lengthof(_company_settings)) return CMD_ERROR;
|
|
|
const SettingDesc *sd = &_company_settings[p1];
|
|
|
|
|
|
if (flags & DC_EXEC) {
|
|
|
void *var = GetVariableAddress(&Company::Get(_current_company)->settings, &sd->save);
|
|
|
|
|
|
int32 oldval = (int32)ReadValue(var, sd->save.conv);
|
|
|
int32 newval = (int32)p2;
|
|
|
|
|
|
Write_ValidateSetting(var, sd, newval);
|
|
|
newval = (int32)ReadValue(var, sd->save.conv);
|
|
|
|
|
|
if (oldval == newval) return CommandCost();
|
|
|
|
|
|
if (sd->desc.proc != NULL && !sd->desc.proc(newval)) {
|
|
|
WriteValue(var, sd->save.conv, (int64)oldval);
|
|
|
return CommandCost();
|
|
|
}
|
|
|
|
|
|
InvalidateWindow(WC_GAME_OPTIONS, 0);
|
|
|
SetWindowDirty(WC_GAME_OPTIONS, 0);
|
|
|
}
|
|
|
|
|
|
return CommandCost();
|
|
|
}
|
|
|
|
|
|
/** Top function to save the new value of an element of the Settings struct
|
|
|
* @param index offset in the SettingDesc array of the Settings struct which
|
|
|
* identifies the setting member we want to change
|
|
|
* @param object pointer to a valid settings struct that has its settings change.
|
|
|
* This only affects setting-members that are not needed to be the same on all
|
|
|
* clients in a network game.
|
|
|
* @param value new value of the setting */
|
|
|
bool SetSettingValue(uint index, int32 value)
|
|
|
{
|
|
|
const SettingDesc *sd = &_settings[index];
|
|
|
/* If an item is company-based, we do not send it over the network
|
|
|
* (if any) to change. Also *hack*hack* we update the _newgame version
|
|
|
* of settings because changing a company-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((_game_mode == GM_MENU) ? &_settings_newgame : &_settings_game, &sd->save);
|
|
|
Write_ValidateSetting(var, sd, value);
|
|
|
|
|
|
if (_game_mode != GM_MENU) {
|
|
|
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);
|
|
|
SetWindowDirty(WC_GAME_OPTIONS, 0);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
/* send non-company-based settings over the network */
|
|
|
if (!_networking || (_networking && _network_server)) {
|
|
|
return DoCommandP(0, index, value, CMD_CHANGE_SETTING);
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
/** Top function to save the new value of an element of the Settings struct
|
|
|
* @param index offset in the SettingDesc array of the CompanySettings struct
|
|
|
* which identifies the setting member we want to change
|
|
|
* @param object pointer to a valid CompanySettings struct that has its settings changed.
|
|
|
* @param value new value of the setting */
|
|
|
void SetCompanySetting(uint index, int32 value)
|
|
|
{
|
|
|
const SettingDesc *sd = &_company_settings[index];
|
|
|
if (Company::IsValidID(_local_company) && _game_mode != GM_MENU) {
|
|
|
DoCommandP(0, index, value, CMD_CHANGE_COMPANY_SETTING);
|
|
|
} else {
|
|
|
void *var = GetVariableAddress(&_settings_client.company, &sd->save);
|
|
|
Write_ValidateSetting(var, sd, value);
|
|
|
if (sd->desc.proc != NULL) sd->desc.proc((int32)ReadValue(var, sd->save.conv));
|