summaryrefslogtreecommitdiff
path: root/players.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2005-10-25 18:29:32 +0000
committertron <tron@openttd.org>2005-10-25 18:29:32 +0000
commit66e688cba3e42d80419ce7224f14ed3505644290 (patch)
treebf01ead9cab0dfbbf1a5ec6eb93eab1aafdd3d55 /players.c
parent7cace07e01b555b88d234f58e36aec8d487e0636 (diff)
downloadopenttd-66e688cba3e42d80419ce7224f14ed3505644290.tar.xz
(svn r3087) Rewrite GetPlayerRailtypes() so it doesn't depend on magical numbers to sort out wagons
Diffstat (limited to 'players.c')
-rw-r--r--players.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/players.c b/players.c
index b03314f3f..257db5b9e 100644
--- a/players.c
+++ b/players.c
@@ -617,20 +617,18 @@ void DeletePlayerWindows(PlayerID pi)
byte GetPlayerRailtypes(PlayerID p)
{
- Engine *e;
- int rt = 0;
- int i;
-
- for(e = _engines, i = 0; i != lengthof(_engines); e++, i++) {
- if (!HASBIT(e->player_avail, p))
- continue;
+ byte rt = 0;
+ uint i;
- /* Skip all wagons */
- if ((i >= 27 && i < 54) || (i >= 57 && i < 84) || (i >= 89 && i < 116))
- continue;
+ for (i = 0; i != TOTAL_NUM_ENGINES; i++) {
+ const Engine* e = GetEngine(i);
- assert(e->railtype < RAILTYPE_END);
- SETBIT(rt, e->railtype);
+ if (e->type == VEH_Train &&
+ HASBIT(e->player_avail, p) &&
+ !(RailVehInfo(i)->flags & RVI_WAGON)) {
+ assert(e->railtype < RAILTYPE_END);
+ SETBIT(rt, e->railtype);
+ }
}
return rt;