author | smatz |
Fri, 13 Jun 2008 00:00:04 +0000 | |
changeset 10948 | 66145f71ebb9 |
parent 8750 | fdd6054e7bae |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
8708
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
3 |
/** @file autoreplace_func.h Functions related to autoreplacing. */ |
6500
08ea5741ee39
(svn r8944) -Codechange: Move the enum describing the bitmask of Engine.flags to engine.h and give the enum values better names.
maedhros
parents:
6451
diff
changeset
|
4 |
|
8708
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
5 |
#ifndef AUTOREPLACE_FUNC_H |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
6 |
#define AUTOREPLACE_FUNC_H |
1786
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1477
diff
changeset
|
7 |
|
8708
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
8 |
#include "autoreplace_type.h" |
8750
fdd6054e7bae
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
8708
diff
changeset
|
9 |
#include "player_base.h" |
2848 | 10 |
|
11 |
/** |
|
12 |
* Remove all engine replacement settings for the player. |
|
6977
67b989528f3d
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6585
diff
changeset
|
13 |
* @param erl The renewlist for a given player. |
2848 | 14 |
* @return The new renewlist for the player. |
15 |
*/ |
|
7814
fe643468ad64
(svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents:
7439
diff
changeset
|
16 |
void RemoveAllEngineReplacement(EngineRenewList *erl); |
2848 | 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 |
*/ |
|
7139
4ae3ab180d05
(svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
7134
diff
changeset
|
25 |
EngineID EngineReplacement(EngineRenewList erl, EngineID engine, GroupID group); |
2848 | 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 |
*/ |
|
7814
fe643468ad64
(svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents:
7439
diff
changeset
|
35 |
CommandCost AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, EngineID new_engine, GroupID group, uint32 flags); |
2848 | 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 |
*/ |
|
7814
fe643468ad64
(svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents:
7439
diff
changeset
|
44 |
CommandCost RemoveEngineReplacement(EngineRenewList *erl, EngineID engine, GroupID group, uint32 flags); |
2848 | 45 |
|
8708
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
46 |
/** |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
47 |
* Remove all engine replacement settings for the given player. |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
48 |
* @param p Player. |
6195
b90cf92697b9
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents:
6119
diff
changeset
|
49 |
*/ |
8708
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
50 |
static inline void RemoveAllEngineReplacementForPlayer(Player *p) |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
51 |
{ |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
52 |
RemoveAllEngineReplacement(&p->engine_renew_list); |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
53 |
} |
6195
b90cf92697b9
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni
parents:
6119
diff
changeset
|
54 |
|
8708
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
55 |
/** |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
56 |
* Retrieve the engine replacement for the given player and original engine type. |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
57 |
* @param p Player. |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
58 |
* @param engine Engine type. |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
59 |
* @return The engine type to replace with, or INVALID_ENGINE if no |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
60 |
* replacement is in the list. |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
61 |
*/ |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
62 |
static inline EngineID EngineReplacementForPlayer(const Player *p, EngineID engine, GroupID group) |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
63 |
{ |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
64 |
return EngineReplacement(p->engine_renew_list, engine, group); |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
65 |
} |
5187
d1f4e447a7eb
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5037
diff
changeset
|
66 |
|
8708
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
67 |
/** |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
68 |
* Check if a player has a replacement set up for the given engine. |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
69 |
* @param p Player. |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
70 |
* @param engine Engine type to be replaced. |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
71 |
* @return true if a replacement was set up, false otherwise. |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
72 |
*/ |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
73 |
static inline bool EngineHasReplacementForPlayer(const Player *p, EngineID engine, GroupID group) |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
74 |
{ |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
75 |
return EngineReplacementForPlayer(p, engine, group) != INVALID_ENGINE; |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
76 |
} |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
77 |
|
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
78 |
/** |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
79 |
* Add an engine replacement for the player. |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
80 |
* @param p Player. |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
81 |
* @param old_engine The original engine type. |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
82 |
* @param new_engine The replacement engine type. |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
83 |
* @param flags The calling command flags. |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
84 |
* @return 0 on success, CMD_ERROR on failure. |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
85 |
*/ |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
86 |
static inline CommandCost AddEngineReplacementForPlayer(Player *p, EngineID old_engine, EngineID new_engine, GroupID group, uint32 flags) |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
87 |
{ |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
88 |
return AddEngineReplacement(&p->engine_renew_list, old_engine, new_engine, group, flags); |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
89 |
} |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
90 |
|
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
91 |
/** |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
92 |
* Remove an engine replacement for the player. |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
93 |
* @param p Player. |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
94 |
* @param engine The original engine type. |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
95 |
* @param flags The calling command flags. |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
96 |
* @return 0 on success, CMD_ERROR on failure. |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
97 |
*/ |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
98 |
static inline CommandCost RemoveEngineReplacementForPlayer(Player *p, EngineID engine, GroupID group, uint32 flags) |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
99 |
{ |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
100 |
return RemoveEngineReplacement(&p->engine_renew_list, engine, group, flags); |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
101 |
} |
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
102 |
|
0c29fbc79be4
(svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents:
8653
diff
changeset
|
103 |
#endif /* AUTOREPLACE_FUNC_H */ |