Add setting to disable continuously updating NewGRF vehicle image

pull/203/head
Jonathan G Rennison 4 years ago
parent 760a1f0163
commit cde5e8c79d

@ -398,7 +398,7 @@ struct GroundVehicle : public SpecializedVehicle<T, Type> {
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();
}
}

@ -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.

@ -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()
{

@ -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));

@ -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.

@ -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

@ -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;

Loading…
Cancel
Save