Changeset - r2554:a8921592802f
[Not reviewed]
master
0 1 0
tron - 18 years ago 2005-10-25 18:29:32
tron@openttd.org
(svn r3087) Rewrite GetPlayerRailtypes() so it doesn't depend on magical numbers to sort out wagons
1 file changed with 11 insertions and 13 deletions:
players.c
11
13
0 comments (0 inline, 0 general)
players.c
Show inline comments
 
@@ -617,20 +617,18 @@ void DeletePlayerWindows(PlayerID pi)
 

	
 
byte GetPlayerRailtypes(PlayerID p)
 
{
 
	Engine *e;
 
	int rt = 0;
 
	int i;
 
	byte rt = 0;
 
	uint i;
 

	
 
	for (i = 0; i != TOTAL_NUM_ENGINES; i++) {
 
		const Engine* e = GetEngine(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);
 
		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;
0 comments (0 inline, 0 general)