9723
|
1 |
/* $Id$ */
|
|
2 |
|
|
3 |
/** @file autoreplace_func.h Functions related to autoreplacing. */
|
|
4 |
|
|
5 |
#ifndef AUTOREPLACE_FUNC_H
|
|
6 |
#define AUTOREPLACE_FUNC_H
|
|
7 |
|
|
8 |
#include "autoreplace_type.h"
|
|
9 |
#include "player.h"
|
|
10 |
|
|
11 |
/**
|
|
12 |
* Remove all engine replacement settings for the player.
|
|
13 |
* @param erl The renewlist for a given player.
|
|
14 |
* @return The new renewlist for the player.
|
|
15 |
*/
|
|
16 |
void RemoveAllEngineReplacement(EngineRenewList *erl);
|
|
17 |
|
|
18 |
/**
|
|
19 |
* Retrieve the engine replacement in a given renewlist for an original engine type.
|
|
20 |
* @param erl The renewlist to search in.
|
|
21 |
* @param engine Engine type to be replaced.
|
|
22 |
* @return The engine type to replace with, or INVALID_ENGINE if no
|
|
23 |
* replacement is in the list.
|
|
24 |
*/
|
|
25 |
EngineID EngineReplacement(EngineRenewList erl, EngineID engine, GroupID group);
|
|
26 |
|
|
27 |
/**
|
|
28 |
* Add an engine replacement to the given renewlist.
|
|
29 |
* @param erl The renewlist to add to.
|
|
30 |
* @param old_engine The original engine type.
|
|
31 |
* @param new_engine The replacement engine type.
|
|
32 |
* @param flags The calling command flags.
|
|
33 |
* @return 0 on success, CMD_ERROR on failure.
|
|
34 |
*/
|
|
35 |
CommandCost AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, EngineID new_engine, GroupID group, uint32 flags);
|
|
36 |
|
|
37 |
/**
|
|
38 |
* Remove an engine replacement from a given renewlist.
|
|
39 |
* @param erl The renewlist from which to remove the replacement
|
|
40 |
* @param engine The original engine type.
|
|
41 |
* @param flags The calling command flags.
|
|
42 |
* @return 0 on success, CMD_ERROR on failure.
|
|
43 |
*/
|
|
44 |
CommandCost RemoveEngineReplacement(EngineRenewList *erl, EngineID engine, GroupID group, uint32 flags);
|
|
45 |
|
|
46 |
/**
|
|
47 |
* Remove all engine replacement settings for the given player.
|
|
48 |
* @param p Player.
|
|
49 |
*/
|
|
50 |
static inline void RemoveAllEngineReplacementForPlayer(Player *p)
|
|
51 |
{
|
|
52 |
RemoveAllEngineReplacement(&p->engine_renew_list);
|
|
53 |
}
|
|
54 |
|
|
55 |
/**
|
|
56 |
* Retrieve the engine replacement for the given player and original engine type.
|
|
57 |
* @param p Player.
|
|
58 |
* @param engine Engine type.
|
|
59 |
* @return The engine type to replace with, or INVALID_ENGINE if no
|
|
60 |
* replacement is in the list.
|
|
61 |
*/
|
|
62 |
static inline EngineID EngineReplacementForPlayer(const Player *p, EngineID engine, GroupID group)
|
|
63 |
{
|
|
64 |
return EngineReplacement(p->engine_renew_list, engine, group);
|
|
65 |
}
|
|
66 |
|
|
67 |
/**
|
|
68 |
* Check if a player has a replacement set up for the given engine.
|
|
69 |
* @param p Player.
|
|
70 |
* @param engine Engine type to be replaced.
|
|
71 |
* @return true if a replacement was set up, false otherwise.
|
|
72 |
*/
|
|
73 |
static inline bool EngineHasReplacementForPlayer(const Player *p, EngineID engine, GroupID group)
|
|
74 |
{
|
|
75 |
return EngineReplacementForPlayer(p, engine, group) != INVALID_ENGINE;
|
|
76 |
}
|
|
77 |
|
|
78 |
/**
|
|
79 |
* Add an engine replacement for the player.
|
|
80 |
* @param p Player.
|
|
81 |
* @param old_engine The original engine type.
|
|
82 |
* @param new_engine The replacement engine type.
|
|
83 |
* @param flags The calling command flags.
|
|
84 |
* @return 0 on success, CMD_ERROR on failure.
|
|
85 |
*/
|
|
86 |
static inline CommandCost AddEngineReplacementForPlayer(Player *p, EngineID old_engine, EngineID new_engine, GroupID group, uint32 flags)
|
|
87 |
{
|
|
88 |
return AddEngineReplacement(&p->engine_renew_list, old_engine, new_engine, group, flags);
|
|
89 |
}
|
|
90 |
|
|
91 |
/**
|
|
92 |
* Remove an engine replacement for the player.
|
|
93 |
* @param p Player.
|
|
94 |
* @param engine The original engine type.
|
|
95 |
* @param flags The calling command flags.
|
|
96 |
* @return 0 on success, CMD_ERROR on failure.
|
|
97 |
*/
|
|
98 |
static inline CommandCost RemoveEngineReplacementForPlayer(Player *p, EngineID engine, GroupID group, uint32 flags)
|
|
99 |
{
|
|
100 |
return RemoveEngineReplacement(&p->engine_renew_list, engine, group, flags);
|
|
101 |
}
|
|
102 |
|
|
103 |
#endif /* AUTOREPLACE_FUNC_H */
|