Update: Translations from eints
[openttd-github.git] / src / autoreplace_func.h
blob0943985e7d2aa0d3f6af16453448307287a1cc41
1 /*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
8 /** @file autoreplace_func.h Functions related to autoreplacing. */
10 #ifndef AUTOREPLACE_FUNC_H
11 #define AUTOREPLACE_FUNC_H
13 #include "command_type.h"
14 #include "company_base.h"
16 void RemoveAllEngineReplacement(EngineRenewList *erl);
17 EngineID EngineReplacement(EngineRenewList erl, EngineID engine, GroupID group, bool *replace_when_old = nullptr);
18 CommandCost AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, EngineID new_engine, GroupID group, bool replace_when_old, DoCommandFlag flags);
19 CommandCost RemoveEngineReplacement(EngineRenewList *erl, EngineID engine, GroupID group, DoCommandFlag flags);
21 /**
22 * Remove all engine replacement settings for the given company.
23 * @param c the company.
25 inline void RemoveAllEngineReplacementForCompany(Company *c)
27 RemoveAllEngineReplacement(&c->engine_renew_list);
30 /**
31 * Retrieve the engine replacement for the given company and original engine type.
32 * @param c company.
33 * @param engine Engine type.
34 * @param group The group related to this replacement.
35 * @param[out] replace_when_old Set to true if the replacement should be done when old.
36 * @return The engine type to replace with, or INVALID_ENGINE if no
37 * replacement is in the list.
39 inline EngineID EngineReplacementForCompany(const Company *c, EngineID engine, GroupID group, bool *replace_when_old = nullptr)
41 return EngineReplacement(c->engine_renew_list, engine, group, replace_when_old);
44 /**
45 * Check if a company has a replacement set up for the given engine.
46 * @param c Company.
47 * @param engine Engine type to be replaced.
48 * @param group The group related to this replacement.
49 * @return true if a replacement was set up, false otherwise.
51 inline bool EngineHasReplacementForCompany(const Company *c, EngineID engine, GroupID group)
53 return EngineReplacementForCompany(c, engine, group) != INVALID_ENGINE;
56 /**
57 * Check if a company has a replacement set up for the given engine when it gets old.
58 * @param c Company.
59 * @param engine Engine type to be replaced.
60 * @param group The group related to this replacement.
61 * @return True if a replacement when old was set up, false otherwise.
63 inline bool EngineHasReplacementWhenOldForCompany(const Company *c, EngineID engine, GroupID group)
65 bool replace_when_old;
66 EngineReplacement(c->engine_renew_list, engine, group, &replace_when_old);
67 return replace_when_old;
70 /**
71 * Add an engine replacement for the company.
72 * @param c Company.
73 * @param old_engine The original engine type.
74 * @param new_engine The replacement engine type.
75 * @param group The group related to this replacement.
76 * @param replace_when_old Replace when old or always?
77 * @param flags The calling command flags.
78 * @return 0 on success, CMD_ERROR on failure.
80 inline CommandCost AddEngineReplacementForCompany(Company *c, EngineID old_engine, EngineID new_engine, GroupID group, bool replace_when_old, DoCommandFlag flags)
82 return AddEngineReplacement(&c->engine_renew_list, old_engine, new_engine, group, replace_when_old, flags);
85 /**
86 * Remove an engine replacement for the company.
87 * @param c Company.
88 * @param engine The original engine type.
89 * @param group The group related to this replacement.
90 * @param flags The calling command flags.
91 * @return 0 on success, CMD_ERROR on failure.
93 inline CommandCost RemoveEngineReplacementForCompany(Company *c, EngineID engine, GroupID group, DoCommandFlag flags)
95 return RemoveEngineReplacement(&c->engine_renew_list, engine, group, flags);
98 bool CheckAutoreplaceValidity(EngineID from, EngineID to, CompanyID company);
100 #endif /* AUTOREPLACE_FUNC_H */