summaryrefslogtreecommitdiff
path: root/engine.c
diff options
context:
space:
mode:
authorcelestar <celestar@openttd.org>2005-07-20 22:02:58 +0000
committercelestar <celestar@openttd.org>2005-07-20 22:02:58 +0000
commit18a93cca3d4c590949015ff56e34d8906c60199a (patch)
tree0116afc35d1c231116095467d18c2295cbffa8f1 /engine.c
parent030c37160db989c0c67ab3817381787e6c8d8d20 (diff)
downloadopenttd-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 'engine.c')
-rw-r--r--engine.c32
1 files changed, 6 insertions, 26 deletions
diff --git a/engine.c b/engine.c
index 45fbdb2f6..a17841dd8 100644
--- a/engine.c
+++ b/engine.c
@@ -12,8 +12,6 @@
#include "saveload.h"
#include "sprite.h"
-#define UPDATE_PLAYER_RAILTYPE(e,p) if ((byte)(e->railtype + 1) > p->max_railtype) p->max_railtype = e->railtype + 1;
-
enum {
ENGINE_AVAILABLE = 1,
ENGINE_INTRODUCING = 2,
@@ -755,9 +753,9 @@ void AcceptEnginePreview(Engine *e, PlayerID player)
{
Player *p = GetPlayer(player);
+ assert(e->railtype < RAILTYPE_END);
SETBIT(e->player_avail, player);
-
- UPDATE_PLAYER_RAILTYPE(e, p);
+ SETBIT(p->avail_railtypes, e->railtype);
e->preview_player = 0xFF;
InvalidateWindowClasses(WC_BUILD_VEHICLE);
@@ -897,8 +895,10 @@ static void NewVehicleAvailable(Engine *e)
// make maglev / monorail available
FOR_ALL_PLAYERS(p) {
- if (p->is_active)
- UPDATE_PLAYER_RAILTYPE(e,p);
+ if (p->is_active) {
+ assert(e->railtype < RAILTYPE_END);
+ SETBIT(p->avail_railtypes, e->railtype);
+ }
}
if ((byte)index < NUM_TRAIN_ENGINES) {
@@ -967,26 +967,6 @@ int32 CmdRenameEngine(int x, int y, uint32 flags, uint32 p1, uint32 p2)
return 0;
}
-int GetPlayerMaxRailtype(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;
-
- if ((i >= 27 && i < 54) || (i >= 57 && i < 84) || (i >= 89 && i < 116))
- continue;
-
- if (rt < e->railtype)
- rt = e->railtype;
- }
-
- return rt + 1;
-}
-
static const SaveLoad _engine_desc[] = {
SLE_VAR(Engine,intro_date, SLE_UINT16),