2008-01-07 09:19:53 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
/** @file autoreplace_func.h Functions related to autoreplacing. */
|
|
|
|
|
|
|
|
#ifndef AUTOREPLACE_FUNC_H
|
|
|
|
#define AUTOREPLACE_FUNC_H
|
|
|
|
|
|
|
|
#include "autoreplace_type.h"
|
2008-09-30 20:51:04 +00:00
|
|
|
#include "company_base.h"
|
2008-01-07 09:19:53 +00:00
|
|
|
|
|
|
|
/**
|
2008-09-30 20:39:50 +00:00
|
|
|
* Remove all engine replacement settings for the company.
|
|
|
|
* @param erl The renewlist for a given company.
|
|
|
|
* @return The new renewlist for the company.
|
2008-01-07 09:19:53 +00:00
|
|
|
*/
|
|
|
|
void RemoveAllEngineReplacement(EngineRenewList *erl);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieve the engine replacement in a given renewlist for an original engine type.
|
|
|
|
* @param erl The renewlist to search in.
|
|
|
|
* @param engine Engine type to be replaced.
|
|
|
|
* @return The engine type to replace with, or INVALID_ENGINE if no
|
|
|
|
* replacement is in the list.
|
|
|
|
*/
|
|
|
|
EngineID EngineReplacement(EngineRenewList erl, EngineID engine, GroupID group);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add an engine replacement to the given renewlist.
|
|
|
|
* @param erl The renewlist to add to.
|
|
|
|
* @param old_engine The original engine type.
|
|
|
|
* @param new_engine The replacement engine type.
|
|
|
|
* @param flags The calling command flags.
|
|
|
|
* @return 0 on success, CMD_ERROR on failure.
|
|
|
|
*/
|
|
|
|
CommandCost AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, EngineID new_engine, GroupID group, uint32 flags);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove an engine replacement from a given renewlist.
|
|
|
|
* @param erl The renewlist from which to remove the replacement
|
|
|
|
* @param engine The original engine type.
|
|
|
|
* @param flags The calling command flags.
|
|
|
|
* @return 0 on success, CMD_ERROR on failure.
|
|
|
|
*/
|
|
|
|
CommandCost RemoveEngineReplacement(EngineRenewList *erl, EngineID engine, GroupID group, uint32 flags);
|
|
|
|
|
|
|
|
/**
|
2008-09-30 20:39:50 +00:00
|
|
|
* Remove all engine replacement settings for the given company.
|
|
|
|
* @param c the company.
|
2008-01-07 09:19:53 +00:00
|
|
|
*/
|
2008-09-30 20:39:50 +00:00
|
|
|
static inline void RemoveAllEngineReplacementForCompany(Company *c)
|
2008-01-07 09:19:53 +00:00
|
|
|
{
|
2008-09-30 20:39:50 +00:00
|
|
|
RemoveAllEngineReplacement(&c->engine_renew_list);
|
2008-01-07 09:19:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-09-30 20:39:50 +00:00
|
|
|
* Retrieve the engine replacement for the given company and original engine type.
|
|
|
|
* @param c company.
|
2008-01-07 09:19:53 +00:00
|
|
|
* @param engine Engine type.
|
|
|
|
* @return The engine type to replace with, or INVALID_ENGINE if no
|
|
|
|
* replacement is in the list.
|
|
|
|
*/
|
2008-09-30 20:39:50 +00:00
|
|
|
static inline EngineID EngineReplacementForCompany(const Company *c, EngineID engine, GroupID group)
|
2008-01-07 09:19:53 +00:00
|
|
|
{
|
2008-09-30 20:39:50 +00:00
|
|
|
return EngineReplacement(c->engine_renew_list, engine, group);
|
2008-01-07 09:19:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-09-30 20:39:50 +00:00
|
|
|
* Check if a company has a replacement set up for the given engine.
|
|
|
|
* @param c Company.
|
2008-01-07 09:19:53 +00:00
|
|
|
* @param engine Engine type to be replaced.
|
|
|
|
* @return true if a replacement was set up, false otherwise.
|
|
|
|
*/
|
2008-09-30 20:39:50 +00:00
|
|
|
static inline bool EngineHasReplacementForCompany(const Company *c, EngineID engine, GroupID group)
|
2008-01-07 09:19:53 +00:00
|
|
|
{
|
2008-09-30 20:39:50 +00:00
|
|
|
return EngineReplacementForCompany(c, engine, group) != INVALID_ENGINE;
|
2008-01-07 09:19:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-09-30 20:39:50 +00:00
|
|
|
* Add an engine replacement for the company.
|
|
|
|
* @param c Company.
|
2008-01-07 09:19:53 +00:00
|
|
|
* @param old_engine The original engine type.
|
|
|
|
* @param new_engine The replacement engine type.
|
|
|
|
* @param flags The calling command flags.
|
|
|
|
* @return 0 on success, CMD_ERROR on failure.
|
|
|
|
*/
|
2008-09-30 20:39:50 +00:00
|
|
|
static inline CommandCost AddEngineReplacementForCompany(Company *c, EngineID old_engine, EngineID new_engine, GroupID group, uint32 flags)
|
2008-01-07 09:19:53 +00:00
|
|
|
{
|
2008-09-30 20:39:50 +00:00
|
|
|
return AddEngineReplacement(&c->engine_renew_list, old_engine, new_engine, group, flags);
|
2008-01-07 09:19:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-09-30 20:39:50 +00:00
|
|
|
* Remove an engine replacement for the company.
|
|
|
|
* @param c Company.
|
2008-01-07 09:19:53 +00:00
|
|
|
* @param engine The original engine type.
|
|
|
|
* @param flags The calling command flags.
|
|
|
|
* @return 0 on success, CMD_ERROR on failure.
|
|
|
|
*/
|
2008-09-30 20:39:50 +00:00
|
|
|
static inline CommandCost RemoveEngineReplacementForCompany(Company *c, EngineID engine, GroupID group, uint32 flags)
|
2008-01-07 09:19:53 +00:00
|
|
|
{
|
2008-09-30 20:39:50 +00:00
|
|
|
return RemoveEngineReplacement(&c->engine_renew_list, engine, group, flags);
|
2008-01-07 09:19:53 +00:00
|
|
|
}
|
|
|
|
|
2008-09-30 20:39:50 +00:00
|
|
|
bool CheckAutoreplaceValidity(EngineID from, EngineID to, CompanyID company);
|
2008-08-10 15:02:21 +00:00
|
|
|
|
2008-01-07 09:19:53 +00:00
|
|
|
#endif /* AUTOREPLACE_FUNC_H */
|