# autoreplace_func.h

Go to the documentation of this file.

    00001 /* $Id: autoreplace_func.h 18809 2010-01-15 16:41:15Z rubidium $ */
    00002
    00003 /*
    00004  * This file is part of OpenTTD.
    00005  * 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.
    00006  * 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.
    00007  * 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/>.
    00008  */
    00009
    00012 #ifndef AUTOREPLACE_FUNC_H
    00013 #define AUTOREPLACE_FUNC_H
    00014
    00015 #include "command_type.h"
    00016 #include "company_base.h"
    00017 #include "engine_type.h"
    00018 #include "group_type.h"
    00019
    00025 void RemoveAllEngineReplacement(EngineRenewList *erl);
    00026
    00035 EngineID EngineReplacement(EngineRenewList erl, EngineID engine, GroupID group);
    00036
    00046 CommandCost AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, EngineID new_engine, GroupID group, DoCommandFlag flags);
    00047
    00056 CommandCost RemoveEngineReplacement(EngineRenewList *erl, EngineID engine, GroupID group, DoCommandFlag flags);
    00057
    00062 static inline void RemoveAllEngineReplacementForCompany(Company *c)
    00063 {
    00064   RemoveAllEngineReplacement(&c->engine_renew_list);
    00065 }
    00066
    00075 static inline EngineID EngineReplacementForCompany(const Company *c, EngineID engine, GroupID group)
    00076 {
    00077   return EngineReplacement(c->engine_renew_list, engine, group);
    00078 }
    00079
    00087 static inline bool EngineHasReplacementForCompany(const Company *c, EngineID engine, GroupID group)
    00088 {
    00089   return EngineReplacementForCompany(c, engine, group) != INVALID_ENGINE;
    00090 }
    00091
    00101 static inline CommandCost AddEngineReplacementForCompany(Company *c, EngineID old_engine, EngineID new_engine, GroupID group, DoCommandFlag flags)
    00102 {
    00103   return AddEngineReplacement(&c->engine_renew_list, old_engine, new_engine, group, flags);
    00104 }
    00105
    00114 static inline CommandCost RemoveEngineReplacementForCompany(Company *c, EngineID engine, GroupID group, DoCommandFlag flags)
    00115 {
    00116   return RemoveEngineReplacement(&c->engine_renew_list, engine, group, flags);
    00117 }
    00118
    00119 bool CheckAutoreplaceValidity(EngineID from, EngineID to, CompanyID company);
    00120
    00121 #endif /* AUTOREPLACE_FUNC_H */