diff options
author | tron <tron@openttd.org> | 2005-10-25 18:29:32 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2005-10-25 18:29:32 +0000 |
commit | 66e688cba3e42d80419ce7224f14ed3505644290 (patch) | |
tree | bf01ead9cab0dfbbf1a5ec6eb93eab1aafdd3d55 /players.c | |
parent | 7cace07e01b555b88d234f58e36aec8d487e0636 (diff) | |
download | openttd-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.c | 22 |
1 files changed, 10 insertions, 12 deletions
@@ -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; |