diff options
author | celestar <celestar@openttd.org> | 2005-07-20 22:02:58 +0000 |
---|---|---|
committer | celestar <celestar@openttd.org> | 2005-07-20 22:02:58 +0000 |
commit | 18a93cca3d4c590949015ff56e34d8906c60199a (patch) | |
tree | 0116afc35d1c231116095467d18c2295cbffa8f1 /players.c | |
parent | 030c37160db989c0c67ab3817381787e6c8d8d20 (diff) | |
download | openttd-18a93cca3d4c590949015ff56e34d8906c60199a.tar.xz |
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
that railtypes do not be in ascending order of appearance. Allows easier
implementation or more railtypes
Diffstat (limited to 'players.c')
-rw-r--r-- | players.c | 25 |
1 files changed, 23 insertions, 2 deletions
@@ -487,7 +487,7 @@ Player *DoStartupNewPlayer(bool is_ai) p->ai.state = 5; /* AIS_WANT_NEW_ROUTE */ p->share_owners[0] = p->share_owners[1] = p->share_owners[2] = p->share_owners[3] = 0xFF; - p->max_railtype = GetPlayerMaxRailtype(index); + p->avail_railtypes = GetPlayerRailtypes(index); p->inaugurated_year = _cur_year; p->face = Random(); @@ -622,6 +622,27 @@ void DeletePlayerWindows(int pi) DeleteWindowById(WC_BUY_COMPANY, pi); } +byte GetPlayerRailtypes(int 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; + + /* Skip all wagons */ + if ((i >= 27 && i < 54) || (i >= 57 && i < 84) || (i >= 89 && i < 116)) + continue; + + assert(e->railtype < RAILTYPE_END); + SETBIT(rt, e->railtype); + } + + return rt; +} + static void DeletePlayerStuff(int pi) { Player *p; @@ -969,7 +990,7 @@ static const SaveLoad _player_desc[] = { SLE_VAR(Player,player_color, SLE_UINT8), SLE_VAR(Player,player_money_fraction,SLE_UINT8), - SLE_VAR(Player,max_railtype, SLE_UINT8), + SLE_VAR(Player,avail_railtypes, SLE_UINT8), SLE_VAR(Player,block_preview, SLE_UINT8), SLE_VAR(Player,cargo_types, SLE_UINT16), |