mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-08 23:19:40 +00:00
Fix: if vehicles only refit to cargo-slots >= 32, the default cargo was wrong. (#9744)
This commit is contained in:
parent
762b656b53
commit
bc22e9333e
@ -24,7 +24,7 @@ const uint8 _ffb_64[64] = {
|
||||
};
|
||||
|
||||
/**
|
||||
* Search the first set bit in a 32 bit variable.
|
||||
* Search the first set bit in a 64 bit variable.
|
||||
*
|
||||
* This algorithm is a static implementation of a log
|
||||
* congruence search algorithm. It checks the first half
|
||||
@ -34,7 +34,7 @@ const uint8 _ffb_64[64] = {
|
||||
* @param x The value to search
|
||||
* @return The position of the first bit set
|
||||
*/
|
||||
uint8 FindFirstBit(uint32 x)
|
||||
uint8 FindFirstBit(uint64 x)
|
||||
{
|
||||
if (x == 0) return 0;
|
||||
/* The macro FIND_FIRST_BIT is better to use when your x is
|
||||
@ -42,11 +42,12 @@ uint8 FindFirstBit(uint32 x)
|
||||
|
||||
uint8 pos = 0;
|
||||
|
||||
if ((x & 0x0000ffff) == 0) { x >>= 16; pos += 16; }
|
||||
if ((x & 0x000000ff) == 0) { x >>= 8; pos += 8; }
|
||||
if ((x & 0x0000000f) == 0) { x >>= 4; pos += 4; }
|
||||
if ((x & 0x00000003) == 0) { x >>= 2; pos += 2; }
|
||||
if ((x & 0x00000001) == 0) { pos += 1; }
|
||||
if ((x & 0xffffffffULL) == 0) { x >>= 32; pos += 32; }
|
||||
if ((x & 0x0000ffffULL) == 0) { x >>= 16; pos += 16; }
|
||||
if ((x & 0x000000ffULL) == 0) { x >>= 8; pos += 8; }
|
||||
if ((x & 0x0000000fULL) == 0) { x >>= 4; pos += 4; }
|
||||
if ((x & 0x00000003ULL) == 0) { x >>= 2; pos += 2; }
|
||||
if ((x & 0x00000001ULL) == 0) { pos += 1; }
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ static inline uint8 FindFirstBit2x64(const int value)
|
||||
}
|
||||
}
|
||||
|
||||
uint8 FindFirstBit(uint32 x);
|
||||
uint8 FindFirstBit(uint64 x);
|
||||
uint8 FindLastBit(uint64 x);
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user