engine.c
changeset 2147 42efdf5020d1
parent 2140 d708eb80ab8b
child 2159 3b634157c3b2
--- a/engine.c	Wed Jul 20 19:15:23 2005 +0000
+++ b/engine.c	Wed Jul 20 22:02:58 2005 +0000
@@ -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 @@
 {
 	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 @@
 
 	// 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 @@
 	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),