diff --git a/src/ground_vehicle.hpp b/src/ground_vehicle.hpp index 196c96d61d..42055558b8 100644 --- a/src/ground_vehicle.hpp +++ b/src/ground_vehicle.hpp @@ -398,7 +398,7 @@ struct GroundVehicle : public SpecializedVehicle { if (this->cur_speed != this->gcache.last_speed) { SetWindowWidgetDirty(WC_VEHICLE_VIEW, this->index, WID_VV_START_STOP); this->gcache.last_speed = this->cur_speed; - if (HasBit(this->vcache.cached_veh_flags, VCF_REDRAW_ON_SPEED_CHANGE)) { + if (HasBit(this->vcache.cached_veh_flags, VCF_REDRAW_ON_SPEED_CHANGE) && !_settings_client.gui.disable_vehicle_image_update) { this->InvalidateImageCacheOfChain(); } } diff --git a/src/lang/english.txt b/src/lang/english.txt index 19e075564f..62c9251a9d 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1388,6 +1388,9 @@ STR_CONFIG_SETTING_LINKGRAPH_COLOURS_GREEN_TO_BLUE :Green to blue STR_CONFIG_SETTING_LINKGRAPH_COLOURS_GREY_TO_RED :Grey to red STR_CONFIG_SETTING_LINKGRAPH_COLOURS_GREYSCALE :Greyscale +STR_CONFIG_SETTING_DISABLE_VEHICLE_IMAGE_UPDATE :Disable vehicle image update: {STRING2} +STR_CONFIG_SETTING_DISABLE_VEHICLE_IMAGE_UPDATE_HELPTEXT :When enabled, prevent NewGRF vehicles from continuously updating the sprite used to draw vehicles as the vehicle moves. This can be used to prevent performance problems when there are many vehicles from computationally expensive NewGRFs. + STR_CONFIG_SETTING_ADV_SIG_BRIDGE_TUN_MODES :Enable signals on bridges/tunnels advanced modes: {STRING2} STR_CONFIG_SETTING_ADV_SIG_BRIDGE_TUN_MODES_HELPTEXT :Enables use of advanced modes of signal simulation on bridges and tunnels. When disabled, bridges/tunnels which are not already in an advanced mode cannot be changed to an advanced mode, however other players may choose to enable this setting and use an advanced mode. diff --git a/src/settings.cpp b/src/settings.cpp index c71c0146b1..4eb0f01750 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1364,6 +1364,14 @@ static bool UpdateLinkgraphColours(int32 p1) return RedrawScreen(p1); } +static bool InvalidateAllVehicleImageCaches(int32 p1) +{ + for (Vehicle *v : Vehicle::Iterate()) { + v->InvalidateImageCache(); + } + return true; +} + /** Checks if any settings are set to incorrect values, and sets them to correct values in that case. */ static void ValidateSettings() { diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 6166b90dd5..ceb5df8c05 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1585,6 +1585,7 @@ static SettingsContainer &GetSettingsTree() graphics->Add(new SettingEntry("gui.show_vehicle_route")); graphics->Add(new SettingEntry("gui.dash_level_of_route_lines")); graphics->Add(new SettingEntry("gui.show_restricted_signal_default")); + graphics->Add(new SettingEntry("gui.disable_vehicle_image_update")); } SettingsPage *sound = main->Add(new SettingsPage(STR_CONFIG_SETTING_SOUND)); diff --git a/src/settings_type.h b/src/settings_type.h index fc40867b52..cbe03281ab 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -204,6 +204,7 @@ struct GUISettings : public TimeSettings { bool show_depot_sell_gui; ///< Show go to depot and sell in UI bool open_vehicle_gui_clone_share; ///< Open vehicle GUI when share-cloning vehicle from depot GUI uint8 linkgraph_colours; ///< linkgraph overlay colours + bool disable_vehicle_image_update; ///< Disable NewGRFs from continuously updating vehicle images uint16 console_backlog_timeout; ///< the minimum amount of time items should be in the console backlog before they will be removed in ~3 seconds granularity. uint16 console_backlog_length; ///< the minimum amount of items in the console backlog before items will be removed. diff --git a/src/table/settings.ini b/src/table/settings.ini index ae7c18c786..d969e0d9d8 100644 --- a/src/table/settings.ini +++ b/src/table/settings.ini @@ -56,6 +56,7 @@ static bool CheckYapfRailSignalPenalties(int32 p1); static bool ViewportMapShowTunnelModeChanged(int32 p1); static bool ViewportMapLandscapeModeChanged(int32 p1); static bool UpdateLinkgraphColours(int32 p1); +static bool InvalidateAllVehicleImageCaches(int32 p1); static bool UpdateClientName(int32 p1); static bool UpdateServerPassword(int32 p1); @@ -5025,6 +5026,15 @@ strval = STR_CONFIG_SETTING_LINKGRAPH_COLOURS_GREEN_TO_RED proc = UpdateLinkgraphColours cat = SC_BASIC +[SDTC_BOOL] +var = gui.disable_vehicle_image_update +flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC +def = false +str = STR_CONFIG_SETTING_DISABLE_VEHICLE_IMAGE_UPDATE +strhelp = STR_CONFIG_SETTING_DISABLE_VEHICLE_IMAGE_UPDATE_HELPTEXT +proc = InvalidateAllVehicleImageCaches +cat = SC_ADVANCED + ; For the dedicated build we'll enable dates in logs by default. [SDTC_BOOL] ifdef = DEDICATED diff --git a/src/vehicle_base.h b/src/vehicle_base.h index 56b0b47241..2adc6b9e80 100644 --- a/src/vehicle_base.h +++ b/src/vehicle_base.h @@ -1280,7 +1280,7 @@ struct SpecializedVehicle : public Vehicle { _sprite_group_resolve_check_veh_check = true; VehicleSpriteSeq seq; ((T *)this)->T::GetImage(current_direction, EIT_ON_MAP, &seq); - this->cur_image_valid_dir = _sprite_group_resolve_check_veh_check ? current_direction : INVALID_DIR; + this->cur_image_valid_dir = (_sprite_group_resolve_check_veh_check || _settings_client.gui.disable_vehicle_image_update) ? current_direction : INVALID_DIR; _sprite_group_resolve_check_veh_check = false; if (force_update || this->sprite_seq != seq) { this->sprite_seq = seq;