1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-21 21:49:10 +00:00

(svn r117) Feature: Performance details window in company league menu (TrueLight)

This commit is contained in:
dominik
2004-08-23 10:59:03 +00:00
parent cce45b44d8
commit a6f2257600
11 changed files with 373 additions and 26 deletions

15
misc.c
View File

@@ -601,11 +601,18 @@ void IncreaseDate()
/* XXX: check if year 2050 was reached */
}
int FindFirstBit(uint32 x)
int FindFirstBit(uint32 value)
{
int i = 0;
assert(x != 0);
for(;!(x&1);i++,x>>=1);
// This is much faster then the one that was before here.
// Created by Darkvater.. blame him if it is wrong ;)
// Btw, the macro FINDFIRSTBIT is better to use when your value is
// not more then 128.
byte i = 0;
if (value & 0xffff0000) { value >>= 16; i += 16; }
if (value & 0x0000ff00) { value >>= 8; i += 8; }
if (value & 0x000000f0) { value >>= 4; i += 4; }
if (value & 0x0000000c) { value >>= 2; i += 2; }
if (value & 0x00000002) { i += 1; }
return i;
}