29 auto it = std::ranges::find_if(erl, [engine](
const auto &er) {
return er.from >= engine; });
30 if (it == erl.end() || it->from != engine)
return nullptr;
47 if (er !=
nullptr || !search)
return er;
53 if (er !=
nullptr || !search)
return er;
66 if (c ==
nullptr)
return;
72 if (g->owner != company)
continue;
73 g->engine_renew_list.clear();
107 if (engine == new_engine) replace_when_old =
true;
111 auto it = std::ranges::lower_bound(erl, engine, std::less{}, &
EngineRenew::from);
112 if (it == erl.end() || it->from != engine) {
114 erl.emplace(it, engine, new_engine, replace_when_old);
118 it->replace_when_old = replace_when_old;
136 auto it = std::ranges::lower_bound(erl, engine, std::less{}, &
EngineRenew::from);
137 if (it == erl.end() || it->from != engine)
return CMD_ERROR;
CommandCost AddEngineReplacement(DoCommandFlags flags, CompanyID company, GroupID group, EngineID engine, EngineID new_engine, bool replace_when_old)
Add an engine replacement to the given renewlist.
void RemoveAllEngineReplacementForCompany(CompanyID company)
Remove all engine replacements for a company.
EngineRenewList & GetEngineRenewList(CompanyID company, GroupID group)
Get the Engine Renew List for a company/group.
const EngineRenew * GetEngineRenew(const EngineRenewList &erl, EngineID engine)
Search within a single engine renew list for an engine to renew.
CommandCost RemoveEngineReplacement(DoCommandFlags flags, CompanyID company, GroupID group, EngineID engine)
Remove an engine replacement from a given renewlist.
Functions related to autoreplacing.
Types related to autoreplacing.
std::vector< EngineRenew > EngineRenewList
A list to group EngineRenew directives together (such as per-company).
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit 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.
@ Execute
execute the given command
EnumBitSet< DoCommandFlag, uint16_t > DoCommandFlags
Bitset of DoCommandFlag elements.
Definition of stuff that is very close to a company, like the company struct itself.
PoolID< uint16_t, struct EngineIDTag, 64000, 0xFFFF > EngineID
Unique identification number of an engine.
Base class for groups and group functions.
@ ReplaceProtection
If set, the global autoreplace has no effect on the group.
static constexpr GroupID DEFAULT_GROUP
Ungrouped vehicles are in this group.
static constexpr GroupID ALL_GROUP
All vehicles are in this group.
A number of safeguards to prevent using unsafe methods.
Definition of base types and functions in a cross-platform compatible way.
EngineRenewList all_engine_renew_list
Engine renewals of this company for all vehicles.
EngineRenewList ungrouped_engine_renew_list
Engine renewals of this company for ungrouped vehicles.
Information about engine autorenews and autoreplacements.
EngineID from
Engine to replace from.
EngineRenewList engine_renew_list
Engine renewals of this group.
static Pool::IterateWrapper< Group > Iterate(size_t from=0)
static Company * Get(auto index)
static Group * GetIfValid(auto index)