(svn r24136) -Feature [FS#4465]: Autoreplace vehicles only when they get old. (Vikthor)
This commit is contained in:
@@ -16,8 +16,8 @@
|
||||
#include "company_base.h"
|
||||
|
||||
void RemoveAllEngineReplacement(EngineRenewList *erl);
|
||||
EngineID EngineReplacement(EngineRenewList erl, EngineID engine, GroupID group);
|
||||
CommandCost AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, EngineID new_engine, GroupID group, DoCommandFlag flags);
|
||||
EngineID EngineReplacement(EngineRenewList erl, EngineID engine, GroupID group, bool *replace_when_old = NULL);
|
||||
CommandCost AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, EngineID new_engine, GroupID group, bool replace_when_old, DoCommandFlag flags);
|
||||
CommandCost RemoveEngineReplacement(EngineRenewList *erl, EngineID engine, GroupID group, DoCommandFlag flags);
|
||||
|
||||
/**
|
||||
@@ -34,12 +34,13 @@ static inline void RemoveAllEngineReplacementForCompany(Company *c)
|
||||
* @param c company.
|
||||
* @param engine Engine type.
|
||||
* @param group The group related to this replacement.
|
||||
* @param[out] replace_when_old Set to true if the replacement should be done when old.
|
||||
* @return The engine type to replace with, or INVALID_ENGINE if no
|
||||
* replacement is in the list.
|
||||
*/
|
||||
static inline EngineID EngineReplacementForCompany(const Company *c, EngineID engine, GroupID group)
|
||||
static inline EngineID EngineReplacementForCompany(const Company *c, EngineID engine, GroupID group, bool *replace_when_old = NULL)
|
||||
{
|
||||
return EngineReplacement(c->engine_renew_list, engine, group);
|
||||
return EngineReplacement(c->engine_renew_list, engine, group, replace_when_old);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,18 +55,33 @@ static inline bool EngineHasReplacementForCompany(const Company *c, EngineID eng
|
||||
return EngineReplacementForCompany(c, engine, group) != INVALID_ENGINE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a company has a replacement set up for the given engine when it gets old.
|
||||
* @param c Company.
|
||||
* @param engine Engine type to be replaced.
|
||||
* @param group The group related to this replacement.
|
||||
* @return True if a replacement when old was set up, false otherwise.
|
||||
*/
|
||||
static inline bool EngineHasReplacementWhenOldForCompany(const Company *c, EngineID engine, GroupID group)
|
||||
{
|
||||
bool replace_when_old;
|
||||
EngineReplacement(c->engine_renew_list, engine, group, &replace_when_old);
|
||||
return replace_when_old;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an engine replacement for the company.
|
||||
* @param c Company.
|
||||
* @param old_engine The original engine type.
|
||||
* @param new_engine The replacement engine type.
|
||||
* @param group The group related to this replacement.
|
||||
* @param replace_when_old Replace when old or always?
|
||||
* @param flags The calling command flags.
|
||||
* @return 0 on success, CMD_ERROR on failure.
|
||||
*/
|
||||
static inline CommandCost AddEngineReplacementForCompany(Company *c, EngineID old_engine, EngineID new_engine, GroupID group, DoCommandFlag flags)
|
||||
static inline CommandCost AddEngineReplacementForCompany(Company *c, EngineID old_engine, EngineID new_engine, GroupID group, bool replace_when_old, DoCommandFlag flags)
|
||||
{
|
||||
return AddEngineReplacement(&c->engine_renew_list, old_engine, new_engine, group, flags);
|
||||
return AddEngineReplacement(&c->engine_renew_list, old_engine, new_engine, group, replace_when_old, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user