|
@@ -798,462 +798,316 @@ const IntSettingDesc *SettingDesc::AsInt
|
|
|
* Get the setting description of this setting as a string setting.
|
|
|
* @return The string setting description.
|
|
|
*/
|
|
|
const StringSettingDesc *SettingDesc::AsStringSetting() const
|
|
|
{
|
|
|
assert(this->IsStringSetting());
|
|
|
return static_cast<const StringSettingDesc *>(this);
|
|
|
}
|
|
|
|
|
|
/* Begin - Callback Functions for the various settings. */
|
|
|
|
|
|
/** Reposition the main toolbar as the setting changed. */
|
|
|
static bool v_PositionMainToolbar(int32 p1)
|
|
|
static void v_PositionMainToolbar(int32 new_value)
|
|
|
{
|
|
|
if (_game_mode != GM_MENU) PositionMainToolbar(nullptr);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
/** Reposition the statusbar as the setting changed. */
|
|
|
static bool v_PositionStatusbar(int32 p1)
|
|
|
static void v_PositionStatusbar(int32 new_value)
|
|
|
{
|
|
|
if (_game_mode != GM_MENU) {
|
|
|
PositionStatusbar(nullptr);
|
|
|
PositionNewsMessage(nullptr);
|
|
|
PositionNetworkChatWindow(nullptr);
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static bool PopulationInLabelActive(int32 p1)
|
|
|
{
|
|
|
UpdateAllTownVirtCoords();
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static bool RedrawScreen(int32 p1)
|
|
|
{
|
|
|
MarkWholeScreenDirty();
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Redraw the smallmap after a colour scheme change.
|
|
|
* @param p1 Callback parameter.
|
|
|
* @return Always true.
|
|
|
*/
|
|
|
static bool RedrawSmallmap(int32 p1)
|
|
|
static void RedrawSmallmap(int32 new_value)
|
|
|
{
|
|
|
BuildLandLegend();
|
|
|
BuildOwnerLegend();
|
|
|
SetWindowClassesDirty(WC_SMALLMAP);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static bool InvalidateDetailsWindow(int32 p1)
|
|
|
{
|
|
|
SetWindowClassesDirty(WC_VEHICLE_DETAILS);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static bool StationSpreadChanged(int32 p1)
|
|
|
static void StationSpreadChanged(int32 p1)
|
|
|
{
|
|
|
InvalidateWindowData(WC_SELECT_STATION, 0);
|
|
|
InvalidateWindowData(WC_BUILD_STATION, 0);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static bool InvalidateBuildIndustryWindow(int32 p1)
|
|
|
static void CloseSignalGUI(int32 new_value)
|
|
|
{
|
|
|
InvalidateWindowData(WC_BUILD_INDUSTRY, 0);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static bool CloseSignalGUI(int32 p1)
|
|
|
{
|
|
|
if (p1 == 0) {
|
|
|
if (new_value == 0) {
|
|
|
DeleteWindowByClass(WC_BUILD_SIGNAL);
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static bool InvalidateTownViewWindow(int32 p1)
|
|
|
{
|
|
|
InvalidateWindowClassesData(WC_TOWN_VIEW, p1);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static bool DeleteSelectStationWindow(int32 p1)
|
|
|
{
|
|
|
DeleteWindowById(WC_SELECT_STATION, 0);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static bool UpdateConsists(int32 p1)
|
|
|
static void UpdateConsists(int32 new_value)
|
|
|
{
|
|
|
for (Train *t : Train::Iterate()) {
|
|
|
/* Update the consist of all trains so the maximum speed is set correctly. */
|
|
|
if (t->IsFrontEngine() || t->IsFreeWagon()) t->ConsistChanged(CCF_TRACK);
|
|
|
}
|
|
|
InvalidateWindowClassesData(WC_BUILD_VEHICLE, 0);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
/* Check service intervals of vehicles, p1 is value of % or day based servicing */
|
|
|
static bool CheckInterval(int32 p1)
|
|
|
/* Check service intervals of vehicles, newvalue is value of % or day based servicing */
|
|
|
static void UpdateServiceInterval(int32 new_value)
|
|
|
{
|
|
|
bool update_vehicles;
|
|
|
VehicleDefaultSettings *vds;
|
|
|
if (_game_mode == GM_MENU || !Company::IsValidID(_current_company)) {
|
|
|
vds = &_settings_client.company.vehicle;
|
|
|
update_vehicles = false;
|
|
|
} else {
|
|
|
vds = &Company::Get(_current_company)->settings.vehicle;
|
|
|
update_vehicles = true;
|
|
|
}
|
|
|
|
|
|
if (p1 != 0) {
|
|
|
if (new_value != 0) {
|
|
|
vds->servint_trains = 50;
|
|
|
vds->servint_roadveh = 50;
|
|
|
vds->servint_aircraft = 50;
|
|
|
vds->servint_ships = 50;
|
|
|
} else {
|
|
|
vds->servint_trains = 150;
|
|
|
vds->servint_roadveh = 150;
|
|
|
vds->servint_aircraft = 100;
|
|
|
vds->servint_ships = 360;
|
|
|
}
|
|
|
|
|
|
if (update_vehicles) {
|
|
|
const Company *c = Company::Get(_current_company);
|
|
|
for (Vehicle *v : Vehicle::Iterate()) {
|
|
|
if (v->owner == _current_company && v->IsPrimaryVehicle() && !v->ServiceIntervalIsCustom()) {
|
|
|
v->SetServiceInterval(CompanyServiceInterval(c, v->type));
|
|
|
v->SetServiceIntervalIsPercent(p1 != 0);
|
|
|
v->SetServiceIntervalIsPercent(new_value != 0);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
InvalidateDetailsWindow(0);
|
|
|
|
|
|
return true;
|
|
|
SetWindowClassesDirty(WC_VEHICLE_DETAILS);
|
|
|
}
|
|
|
|
|
|
static bool UpdateInterval(VehicleType type, int32 p1)
|
|
|
static bool CanUpdateServiceInterval(VehicleType type, int32 &new_value)
|
|
|
{
|
|
|
bool update_vehicles;
|
|
|
VehicleDefaultSettings *vds;
|
|
|
if (_game_mode == GM_MENU || !Company::IsValidID(_current_company)) {
|
|
|
vds = &_settings_client.company.vehicle;
|
|
|
update_vehicles = false;
|
|
|
} else {
|
|
|
vds = &Company::Get(_current_company)->settings.vehicle;
|
|
|
update_vehicles = true;
|
|
|
}
|
|
|
|
|
|
/* Test if the interval is valid */
|
|
|
uint16 interval = GetServiceIntervalClamped(p1, vds->servint_ispercent);
|
|
|
if (interval != p1) return false;
|
|
|
int32 interval = GetServiceIntervalClamped(new_value, vds->servint_ispercent);
|
|
|
return interval == new_value;
|
|
|
}
|
|
|
|
|
|
if (update_vehicles) {
|
|
|
static void UpdateServiceInterval(VehicleType type, int32 new_value)
|
|
|
{
|
|
|
if (_game_mode != GM_MENU && Company::IsValidID(_current_company)) {
|
|
|
for (Vehicle *v : Vehicle::Iterate()) {
|
|
|
if (v->owner == _current_company && v->type == type && v->IsPrimaryVehicle() && !v->ServiceIntervalIsCustom()) {
|
|
|
v->SetServiceInterval(p1);
|
|
|
v->SetServiceInterval(new_value);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
InvalidateDetailsWindow(0);
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static bool UpdateIntervalTrains(int32 p1)
|
|
|
{
|
|
|
return UpdateInterval(VEH_TRAIN, p1);
|
|
|
SetWindowClassesDirty(WC_VEHICLE_DETAILS);
|
|
|
}
|
|
|
|
|
|
static bool UpdateIntervalRoadVeh(int32 p1)
|
|
|
{
|
|
|
return UpdateInterval(VEH_ROAD, p1);
|
|
|
}
|
|
|
|
|
|
static bool UpdateIntervalShips(int32 p1)
|
|
|
{
|
|
|
return UpdateInterval(VEH_SHIP, p1);
|
|
|
}
|
|
|
|
|
|
static bool UpdateIntervalAircraft(int32 p1)
|
|
|
{
|
|
|
return UpdateInterval(VEH_AIRCRAFT, p1);
|
|
|
}
|
|
|
|
|
|
static bool TrainAccelerationModelChanged(int32 p1)
|
|
|
static void TrainAccelerationModelChanged(int32 new_value)
|
|
|
{
|
|
|
for (Train *t : Train::Iterate()) {
|
|
|
if (t->IsFrontEngine()) {
|
|
|
t->tcache.cached_max_curve_speed = t->GetCurveSpeedLimit();
|
|
|
t->UpdateAcceleration();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/* These windows show acceleration values only when realistic acceleration is on. They must be redrawn after a setting change. */
|
|
|
SetWindowClassesDirty(WC_ENGINE_PREVIEW);
|
|
|
InvalidateWindowClassesData(WC_BUILD_VEHICLE, 0);
|
|
|
SetWindowClassesDirty(WC_VEHICLE_DETAILS);
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* This function updates the train acceleration cache after a steepness change.
|
|
|
* @param p1 Callback parameter.
|
|
|
* @return Always true.
|
|
|
* @param new_value Unused new value of setting.
|
|
|
*/
|
|
|
static bool TrainSlopeSteepnessChanged(int32 p1)
|
|
|
static void TrainSlopeSteepnessChanged(int32 new_value)
|
|
|
{
|
|
|
for (Train *t : Train::Iterate()) {
|
|
|
if (t->IsFrontEngine()) t->CargoChanged();
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* This function updates realistic acceleration caches when the setting "Road vehicle acceleration model" is set.
|
|
|
* @param p1 Callback parameter
|
|
|
* @return Always true
|
|
|
* @param new_value Unused new value of setting.
|
|
|
*/
|
|
|
static bool RoadVehAccelerationModelChanged(int32 p1)
|
|
|
static void RoadVehAccelerationModelChanged(int32 new_value)
|
|
|
{
|
|
|
if (_settings_game.vehicle.roadveh_acceleration_model != AM_ORIGINAL) {
|
|
|
for (RoadVehicle *rv : RoadVehicle::Iterate()) {
|
|
|
if (rv->IsFrontEngine()) {
|
|
|
rv->CargoChanged();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/* These windows show acceleration values only when realistic acceleration is on. They must be redrawn after a setting change. */
|
|
|
SetWindowClassesDirty(WC_ENGINE_PREVIEW);
|
|
|
InvalidateWindowClassesData(WC_BUILD_VEHICLE, 0);
|
|
|
SetWindowClassesDirty(WC_VEHICLE_DETAILS);
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* This function updates the road vehicle acceleration cache after a steepness change.
|
|
|
* @param p1 Callback parameter.
|
|
|
* @return Always true.
|
|
|
* @param new_value Unused new value of setting.
|
|
|
*/
|
|
|
static bool RoadVehSlopeSteepnessChanged(int32 p1)
|
|
|
static void RoadVehSlopeSteepnessChanged(int32 new_value)
|
|
|
{
|
|
|
for (RoadVehicle *rv : RoadVehicle::Iterate()) {
|
|
|
if (rv->IsFrontEngine()) rv->CargoChanged();
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static bool DragSignalsDensityChanged(int32)
|
|
|
{
|
|
|
InvalidateWindowData(WC_BUILD_SIGNAL, 0);
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static bool TownFoundingChanged(int32 p1)
|
|
|
static void TownFoundingChanged(int32 new_value)
|
|
|
{
|
|
|
if (_game_mode != GM_EDITOR && _settings_game.economy.found_town == TF_FORBIDDEN) {
|
|
|
DeleteWindowById(WC_FOUND_TOWN, 0);
|
|
|
return true;
|
|
|
} else {
|
|
|
InvalidateWindowData(WC_FOUND_TOWN, 0);
|
|
|
}
|
|
|
InvalidateWindowData(WC_FOUND_TOWN, 0);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static bool InvalidateVehTimetableWindow(int32 p1)
|
|
|
{
|
|
|
InvalidateWindowClassesData(WC_VEHICLE_TIMETABLE, VIWD_MODIFY_ORDERS);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static bool ZoomMinMaxChanged(int32 p1)
|
|
|
static void ZoomMinMaxChanged(int32 new_value)
|
|
|
{
|
|
|
extern void ConstrainAllViewportsZoom();
|
|
|
ConstrainAllViewportsZoom();
|
|
|
GfxClearSpriteCache();
|
|
|
if (_settings_client.gui.zoom_min > _gui_zoom) {
|
|
|
/* Restrict GUI zoom if it is no longer available. */
|
|
|
_gui_zoom = _settings_client.gui.zoom_min;
|
|
|
UpdateCursorSize();
|
|
|
LoadStringWidthTable();
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static bool SpriteZoomMinChanged(int32 p1) {
|
|
|
static void SpriteZoomMinChanged(int32 new_value)
|
|
|
{
|
|
|
GfxClearSpriteCache();
|
|
|
/* Force all sprites to redraw at the new chosen zoom level */
|
|
|
MarkWholeScreenDirty();
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 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
|
|
|
* newgrf debug button.
|
|
|
* @param p1 unused.
|
|
|
* @return Always true.
|
|
|
* @param new_value unused.
|
|
|
*/
|
|
|
static bool InvalidateNewGRFChangeWindows(int32 p1)
|
|
|
static void InvalidateNewGRFChangeWindows(int32 new_value)
|
|
|
{
|
|
|
InvalidateWindowClassesData(WC_SAVELOAD);
|
|
|
DeleteWindowByClass(WC_GAME_OPTIONS);
|
|
|
ReInitAllWindows(_gui_zoom_cfg);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static bool InvalidateCompanyLiveryWindow(int32 p1)
|
|
|
static void InvalidateCompanyLiveryWindow(int32 new_value)
|
|
|
{
|
|
|
InvalidateWindowClassesData(WC_COMPANY_COLOUR, -1);
|
|
|
ResetVehicleColourMap();
|
|
|
return RedrawScreen(p1);
|
|
|
}
|
|
|
|
|
|
static bool InvalidateIndustryViewWindow(int32 p1)
|
|
|
{
|
|
|
InvalidateWindowClassesData(WC_INDUSTRY_VIEW);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static bool InvalidateAISettingsWindow(int32 p1)
|
|
|
{
|
|
|
InvalidateWindowClassesData(WC_AI_SETTINGS);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Update the town authority window after a town authority setting change.
|
|
|
* @param p1 Unused.
|
|
|
* @return Always true.
|
|
|
*/
|
|
|
static bool RedrawTownAuthority(int32 p1)
|
|
|
{
|
|
|
SetWindowClassesDirty(WC_TOWN_AUTHORITY);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Invalidate the company infrastructure details window after a infrastructure maintenance setting change.
|
|
|
* @param p1 Unused.
|
|
|
* @return Always true.
|
|
|
*/
|
|
|
static bool InvalidateCompanyInfrastructureWindow(int32 p1)
|
|
|
{
|
|
|
InvalidateWindowClassesData(WC_COMPANY_INFRASTRUCTURE);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Invalidate the company details window after the shares setting changed.
|
|
|
* @param p1 Unused.
|
|
|
* @return Always true.
|
|
|
*/
|
|
|
static bool InvalidateCompanyWindow(int32 p1)
|
|
|
{
|
|
|
InvalidateWindowClassesData(WC_COMPANY);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
/** Checks if any settings are set to incorrect values, and sets them to correct values in that case. */
|
|
|
static void ValidateSettings()
|
|
|
{
|
|
|
/* Do not allow a custom sea level with the original land generator. */
|
|
|
if (_settings_newgame.game_creation.land_generator == LG_ORIGINAL &&
|
|
|
_settings_newgame.difficulty.quantity_sea_lakes == CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY) {
|
|
|
_settings_newgame.difficulty.quantity_sea_lakes = CUSTOM_SEA_LEVEL_MIN_PERCENTAGE;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
static bool DifficultyNoiseChange(int32 i)
|
|
|
static void DifficultyNoiseChange(int32 new_value)
|
|
|
{
|
|
|
if (_game_mode == GM_NORMAL) {
|
|
|
UpdateAirportsNoise();
|
|
|
if (_settings_game.economy.station_noise_level) {
|
|
|
InvalidateWindowClassesData(WC_TOWN_VIEW, 0);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static bool MaxNoAIsChange(int32 i)
|
|
|
static void MaxNoAIsChange(int32 new_value)
|
|
|
{
|
|
|
if (GetGameSettings().difficulty.max_no_competitors != 0 &&
|
|
|
AI::GetInfoList()->size() == 0 &&
|
|
|
(!_networking || _network_server)) {
|
|
|
ShowErrorMessage(STR_WARNING_NO_SUITABLE_AI, INVALID_STRING_ID, WL_CRITICAL);
|
|
|
}
|
|
|
|
|
|
InvalidateWindowClassesData(WC_GAME_OPTIONS, 0);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Check whether the road side may be changed.
|
|
|
* @param p1 unused
|
|
|
* @param new_value unused
|
|
|
* @return true if the road side may be changed.
|
|
|
*/
|
|
|
static bool CheckRoadSide(int p1)
|
|
|
static bool CheckRoadSide(int32 &new_value)
|
|
|
{
|
|
|
extern bool RoadVehiclesAreBuilt();
|
|
|
return _game_mode == GM_MENU || !RoadVehiclesAreBuilt();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Conversion callback for _gameopt_settings_game.landscape
|
|
|
* It converts (or try) between old values and the new ones,
|
|
|
* without losing initial setting of the user
|
|
|
* @param value that was read from config file
|
|
|
* @return the "hopefully" converted value
|
|
|
*/
|
|
|
static size_t ConvertLandscape(const char *value)
|
|
|
{
|
|
|
/* try with the old values */
|
|
|
static std::vector<std::string> _old_landscape_values{"normal", "hilly", "desert", "candy"};
|
|
|
return OneOfManySettingDesc::ParseSingleValue(value, strlen(value), _old_landscape_values);
|
|
|
}
|
|
|
|
|
|
static bool CheckFreeformEdges(int32 p1)
|
|
|
static bool CheckFreeformEdges(int32 &new_value)
|
|
|
{
|
|
|
if (_game_mode == GM_MENU) return true;
|
|
|
if (p1 != 0) {
|
|
|
if (new_value != 0) {
|
|
|
for (Ship *s : Ship::Iterate()) {
|
|
|
/* Check if there is a ship on the northern border. */
|
|
|
if (TileX(s->tile) == 0 || TileY(s->tile) == 0) {
|
|
|
ShowErrorMessage(STR_CONFIG_SETTING_EDGES_NOT_EMPTY, INVALID_STRING_ID, WL_ERROR);
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
for (const BaseStation *st : BaseStation::Iterate()) {
|
|
|
/* Check if there is a non-deleted buoy on the northern border. */
|
|
|
if (st->IsInUse() && (TileX(st->xy) == 0 || TileY(st->xy) == 0)) {
|
|
|
ShowErrorMessage(STR_CONFIG_SETTING_EDGES_NOT_EMPTY, INVALID_STRING_ID, WL_ERROR);
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
for (uint x = 0; x < MapSizeX(); x++) MakeVoid(TileXY(x, 0));
|
|
|
for (uint y = 0; y < MapSizeY(); y++) MakeVoid(TileXY(0, y));
|
|
|
} else {
|
|
|
for (uint i = 0; i < MapMaxX(); i++) {
|
|
|
if (TileHeight(TileXY(i, 1)) != 0) {
|
|
|
ShowErrorMessage(STR_CONFIG_SETTING_EDGES_NOT_WATER, INVALID_STRING_ID, WL_ERROR);
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
for (uint i = 1; i < MapMaxX(); i++) {
|
|
|
if (!IsTileType(TileXY(i, MapMaxY() - 1), MP_WATER) || TileHeight(TileXY(1, MapMaxY())) != 0) {
|
|
|
ShowErrorMessage(STR_CONFIG_SETTING_EDGES_NOT_WATER, INVALID_STRING_ID, WL_ERROR);
|
|
|
return false;
|
|
|
}
|
|
@@ -1261,114 +1115,113 @@ static bool CheckFreeformEdges(int32 p1)
|
|
|
for (uint i = 0; i < MapMaxY(); i++) {
|
|
|
if (TileHeight(TileXY(1, i)) != 0) {
|
|
|
ShowErrorMessage(STR_CONFIG_SETTING_EDGES_NOT_WATER, INVALID_STRING_ID, WL_ERROR);
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
for (uint i = 1; i < MapMaxY(); i++) {
|
|
|
if (!IsTileType(TileXY(MapMaxX() - 1, i), MP_WATER) || TileHeight(TileXY(MapMaxX(), i)) != 0) {
|
|
|
ShowErrorMessage(STR_CONFIG_SETTING_EDGES_NOT_WATER, INVALID_STRING_ID, WL_ERROR);
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static void UpdateFreeformEdges(int32 new_value)
|
|
|
{
|
|
|
if (_game_mode == GM_MENU) return;
|
|
|
|
|
|
if (new_value != 0) {
|
|
|
for (uint x = 0; x < MapSizeX(); x++) MakeVoid(TileXY(x, 0));
|
|
|
for (uint y = 0; y < MapSizeY(); y++) MakeVoid(TileXY(0, y));
|
|
|
} else {
|
|
|
/* Make tiles at the border water again. */
|
|
|
for (uint i = 0; i < MapMaxX(); i++) {
|
|
|
SetTileHeight(TileXY(i, 0), 0);
|
|
|
SetTileType(TileXY(i, 0), MP_WATER);
|
|
|
}
|
|
|
for (uint i = 0; i < MapMaxY(); i++) {
|
|
|
SetTileHeight(TileXY(0, i), 0);
|
|
|
SetTileType(TileXY(0, i), MP_WATER);
|
|
|
}
|
|
|
}
|
|
|
MarkWholeScreenDirty();
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Changing the setting "allow multiple NewGRF sets" is not allowed
|
|
|
* if there are vehicles.
|
|
|
*/
|
|
|
static bool ChangeDynamicEngines(int32 p1)
|
|
|
static bool CheckDynamicEngines(int32 &new_value)
|
|
|
{
|
|
|
if (_game_mode == GM_MENU) return true;
|
|
|
|
|
|
if (!EngineOverrideManager::ResetToCurrentNewGRFConfig()) {
|
|
|
ShowErrorMessage(STR_CONFIG_SETTING_DYNAMIC_ENGINES_EXISTING_VEHICLES, INVALID_STRING_ID, WL_ERROR);
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static bool ChangeMaxHeightLevel(int32 p1)
|
|
|
static bool CheckMaxHeightLevel(int32 &new_value)
|
|
|
{
|
|
|
if (_game_mode == GM_NORMAL) return false;
|
|
|
if (_game_mode != GM_EDITOR) return true;
|
|
|
|
|
|
/* Check if at least one mountain on the map is higher than the new value.
|
|
|
* If yes, disallow the change. */
|
|
|
for (TileIndex t = 0; t < MapSize(); t++) {
|
|
|
if ((int32)TileHeight(t) > p1) {
|
|
|
if ((int32)TileHeight(t) > new_value) {
|
|
|
ShowErrorMessage(STR_CONFIG_SETTING_TOO_HIGH_MOUNTAIN, INVALID_STRING_ID, WL_ERROR);
|
|
|
/* Return old, unchanged value */
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/* The smallmap uses an index from heightlevels to colours. Trigger rebuilding it. */
|
|
|
InvalidateWindowClassesData(WC_SMALLMAP, 2);
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static bool StationCatchmentChanged(int32 p1)
|
|
|
static void StationCatchmentChanged(int32 new_value)
|
|
|
{
|
|
|
Station::RecomputeCatchmentForAll();
|
|
|
MarkWholeScreenDirty();
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static bool MaxVehiclesChanged(int32 p1)
|
|
|
static void MaxVehiclesChanged(int32 new_value)
|
|
|
{
|
|
|
InvalidateWindowClassesData(WC_BUILD_TOOLBAR);
|
|
|
MarkWholeScreenDirty();
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static bool InvalidateShipPathCache(int32 p1)
|
|
|
static void InvalidateShipPathCache(int32 new_value)
|
|
|
{
|
|
|
for (Ship *s : Ship::Iterate()) {
|
|
|
s->path.clear();
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Replace a passwords that are a literal asterisk with an empty string.
|
|
|
* @param newval The new string value for this password field.
|
|
|
* @return Always true.
|
|
|
*/
|
|
|
static bool ReplaceAsteriskWithEmptyPassword(std::string &newval)
|
|
|
{
|
|
|
if (newval.compare("*") == 0) newval.clear();
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
static bool UpdateClientConfigValues(int32 p1)
|
|
|
{
|
|
|
UpdateClientConfigValues();
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
/** Update the game info, and send it to the clients when we are running as a server. */
|
|
|
static void UpdateClientConfigValues()
|
|
|
{
|
|
|
NetworkServerUpdateGameInfo();
|
|
|
if (_network_server) NetworkServerSendConfigUpdate();
|
|
|
}
|
|
|
|
|
|
/* End - Callback Functions */
|
|
|
|
|
|
/**
|
|
|
* Prepare for reading and old diff_custom by zero-ing the memory.
|
|
|
*/
|
|
@@ -1829,35 +1682,30 @@ void DeleteGRFPresetFromConfig(const cha
|
|
|
delete ini;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Handle changing a value. This performs validation of the input value and
|
|
|
* calls the appropriate callbacks, and saves it when the value is changed.
|
|
|
* @param object The object the setting is in.
|
|
|
* @param newval The new value for the setting.
|
|
|
*/
|
|
|
void IntSettingDesc::ChangeValue(const void *object, int32 newval) const
|
|
|
{
|
|
|
int32 oldval = this->Read(object);
|
|
|
|
|
|
this->MakeValueValidAndWrite(object, newval);
|
|
|
newval = this->Read(object);
|
|
|
|
|
|
this->MakeValueValid(newval);
|
|
|
if (this->pre_check != nullptr && !this->pre_check(newval)) return;
|
|
|
if (oldval == newval) return;
|
|
|
|
|
|
if (this->proc != nullptr && !this->proc(newval)) {
|
|
|
/* The change was not allowed, so revert. */
|
|
|
this->Write(object, oldval);
|
|
|
return;
|
|
|
}
|
|
|
this->Write(object, newval);
|
|
|
if (this->post_callback != nullptr) this->post_callback(newval);
|
|
|
|
|
|
if (this->flags & SGF_NO_NETWORK) {
|
|
|
GamelogStartAction(GLAT_SETTING);
|
|
|
GamelogSetting(this->name, oldval, newval);
|
|
|
GamelogStopAction();
|
|
|
}
|
|
|
|
|
|
SetWindowClassesDirty(WC_GAME_OPTIONS);
|
|
|
|
|
|
if (_save_config) SaveToConfig();
|
|
|
}
|
|
|
|