OpenTTD Source 20241224-master-gf74b0cf984
autoreplace_gui.h File Reference

Functions related to the autoreplace GUIs. More...

#include "engine_type.h"
#include "group_type.h"
#include "vehicle_type.h"

Go to the source code of this file.

Functions

void AddRemoveEngineFromAutoreplaceAndBuildWindows (VehicleType type)
 When an engine is made buildable or is removed from being buildable, add/remove it from the build/autoreplace lists.
 
void InvalidateAutoreplaceWindow (EngineID e, GroupID id_g)
 Rebuild the left autoreplace list if an engine is removed or added.
 
void ShowReplaceGroupVehicleWindow (GroupID group, VehicleType veh)
 Show the autoreplace configuration window for a particular group.
 

Detailed Description

Functions related to the autoreplace GUIs.

Definition in file autoreplace_gui.h.

Function Documentation

◆ AddRemoveEngineFromAutoreplaceAndBuildWindows()

void AddRemoveEngineFromAutoreplaceAndBuildWindows ( VehicleType  type)

When an engine is made buildable or is removed from being buildable, add/remove it from the build/autoreplace lists.

Parameters
typeThe type of engine

Definition at line 65 of file autoreplace_gui.cpp.

References InvalidateWindowClassesData(), InvalidateWindowData(), WC_BUILD_VEHICLE, and WC_REPLACE_VEHICLE.

Referenced by CalcEngineReliability(), CmdSetVehicleVisibility(), DisableEngineForCompany(), EnableEngineForCompany(), and NewVehicleAvailable().

◆ InvalidateAutoreplaceWindow()

void InvalidateAutoreplaceWindow ( EngineID  e,
GroupID  id_g 
)

Rebuild the left autoreplace list if an engine is removed or added.

Parameters
eEngine to check if it is removed or added
id_gThe group the engine belongs to Note: this function only works if it is called either
  • when a new vehicle is build, but before it's counted in num_engines
  • when a vehicle is deleted and after it's subtracted from num_engines
  • when not changing the count (used when changing replace orders)

Definition at line 51 of file autoreplace_gui.cpp.

References _local_company, ALL_GROUP, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), GetGroupNumEngines(), InvalidateWindowData(), and WC_REPLACE_VEHICLE.

Referenced by CmdBuildVehicle(), CmdSetAutoReplace(), and Vehicle::PreDestructor().

◆ ShowReplaceGroupVehicleWindow()

void ShowReplaceGroupVehicleWindow ( GroupID  id_g,
VehicleType  vehicletype 
)

Show the autoreplace configuration window for a particular group.

Parameters
id_gThe group to replace the vehicles for.
vehicletypeThe type of vehicles in the group.

Definition at line 889 of file autoreplace_gui.cpp.

References CloseWindowById(), VEH_ROAD, VEH_TRAIN, and WC_REPLACE_VEHICLE.

Referenced by VehicleGroupWindow::OnDropdownSelect(), and VehicleListWindow::OnDropdownSelect().