00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #ifndef AUTOREPLACE_FUNC_H
00013 #define AUTOREPLACE_FUNC_H
00014
00015 #include "command_type.h"
00016 #include "company_base.h"
00017
00018 void RemoveAllEngineReplacement(EngineRenewList *erl);
00019 EngineID EngineReplacement(EngineRenewList erl, EngineID engine, GroupID group, bool *replace_when_old = NULL);
00020 CommandCost AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, EngineID new_engine, GroupID group, bool replace_when_old, DoCommandFlag flags);
00021 CommandCost RemoveEngineReplacement(EngineRenewList *erl, EngineID engine, GroupID group, DoCommandFlag flags);
00022
00027 static inline void RemoveAllEngineReplacementForCompany(Company *c)
00028 {
00029 RemoveAllEngineReplacement(&c->engine_renew_list);
00030 }
00031
00041 static inline EngineID EngineReplacementForCompany(const Company *c, EngineID engine, GroupID group, bool *replace_when_old = NULL)
00042 {
00043 return EngineReplacement(c->engine_renew_list, engine, group, replace_when_old);
00044 }
00045
00053 static inline bool EngineHasReplacementForCompany(const Company *c, EngineID engine, GroupID group)
00054 {
00055 return EngineReplacementForCompany(c, engine, group) != INVALID_ENGINE;
00056 }
00057
00065 static inline bool EngineHasReplacementWhenOldForCompany(const Company *c, EngineID engine, GroupID group)
00066 {
00067 bool replace_when_old;
00068 EngineReplacement(c->engine_renew_list, engine, group, &replace_when_old);
00069 return replace_when_old;
00070 }
00071
00082 static inline CommandCost AddEngineReplacementForCompany(Company *c, EngineID old_engine, EngineID new_engine, GroupID group, bool replace_when_old, DoCommandFlag flags)
00083 {
00084 return AddEngineReplacement(&c->engine_renew_list, old_engine, new_engine, group, replace_when_old, flags);
00085 }
00086
00095 static inline CommandCost RemoveEngineReplacementForCompany(Company *c, EngineID engine, GroupID group, DoCommandFlag flags)
00096 {
00097 return RemoveEngineReplacement(&c->engine_renew_list, engine, group, flags);
00098 }
00099
00100 bool CheckAutoreplaceValidity(EngineID from, EngineID to, CompanyID company);
00101
00102 #endif