(svn r11031) -Codechange: reduce the amount of duplication of bit counting functions. Based on patches by skidd13, SmatZ and Belugas.
This commit is contained in:
@@ -1083,7 +1083,7 @@ static void RoadZPosAffectSpeed(Vehicle *v, byte old_z)
|
||||
static int PickRandomBit(uint bits)
|
||||
{
|
||||
uint i;
|
||||
uint num = RandomRange(CountBitsSet(bits));
|
||||
uint num = RandomRange(COUNTBITS(bits));
|
||||
|
||||
for (i = 0; !(bits & 1) || (int)--num >= 0; bits >>= 1, i++) {}
|
||||
return i;
|
||||
|
Reference in New Issue
Block a user