31 while (er !=
nullptr) {
32 if (er->from == engine &&
GroupIsInGroup(group, er->group_id))
return er;
48 while (er !=
nullptr) {
72 if (replace_when_old !=
nullptr) {
75 *replace_when_old =
false;
76 }
else if (er->to == engine) {
78 *replace_when_old =
true;
113 er->group_id = group;
137 while (er !=
nullptr) {
138 if (er->from == engine && er->group_id == group) {
140 if (prev ==
nullptr) {
145 prev->next = er->next;
CommandCost AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, EngineID new_engine, GroupID group, bool replace_when_old, DoCommandFlag flags)
Add an engine replacement to the given renewlist.
CommandCost RemoveEngineReplacement(EngineRenewList *erl, EngineID engine, GroupID group, DoCommandFlag flags)
Remove an engine replacement from a given renewlist.
EngineRenewPool _enginerenew_pool("EngineRenew")
The pool of autoreplace "orders".
void RemoveAllEngineReplacement(EngineRenewList *erl)
Remove all engine replacement settings for the company.
EngineID EngineReplacement(EngineRenewList erl, EngineID engine, GroupID group, bool *replace_when_old)
Retrieve the engine replacement in a given renewlist for an original engine type.
static EngineRenew * GetEngineReplacement(EngineRenewList erl, EngineID engine, GroupID group)
Retrieves the EngineRenew that specifies the replacement of the given engine type from the given rene...
Base class for autoreplaces/autorenews.
EngineRenew * EngineRenewList
A list to group EngineRenew directives together (such as per-company).
Functions related to bit mathematics.
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
Common return value for all commands.
Functions related to commands.
static const CommandCost CMD_ERROR
Define a default return value for a failed command.
DoCommandFlag
List of flags for a command.
@ DC_EXEC
execute the given command
static const EngineID INVALID_ENGINE
Constant denoting an invalid engine.
uint16_t EngineID
Unique identification number of an engine.
Base class for groups and group functions.
@ GF_REPLACE_PROTECTION
If set to true, the global autoreplace has no effect on the group.
bool GroupIsInGroup(GroupID search, GroupID group)
Test if GroupID group is a descendant of (or is) GroupID search.
uint16_t GroupID
Type for all group identifiers.
static const GroupID DEFAULT_GROUP
Ungrouped vehicles are in this group.
static const GroupID ALL_GROUP
All vehicles are in this group.
Some methods of Pool are placed here in order to reduce compilation time and binary size.
#define INSTANTIATE_POOL_METHODS(name)
Force instantiation of pool methods so we don't get linker errors.
A number of safeguards to prevent using unsafe methods.
Definition of base types and functions in a cross-platform compatible way.
Struct to store engine replacements.
bool replace_when_old
Do replacement only when vehicle is old.
static Titem * Get(size_t index)
Returns Titem with given index.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function()
Base class for all pools.