From 9ab0c3e066b2c0b48daed461e80c7bb22bc6803f Mon Sep 17 00:00:00 2001 From: manuel Date: Thu, 14 Apr 2011 23:29:50 +0200 Subject: fix wrong left shift which fixes the invisible fourth player :) --- pacman-c++/util.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'pacman-c++/util.cpp') diff --git a/pacman-c++/util.cpp b/pacman-c++/util.cpp index b1848e1..2a3b78a 100644 --- a/pacman-c++/util.cpp +++ b/pacman-c++/util.cpp @@ -248,6 +248,20 @@ namespace Util return data; } + int floorLog2(unsigned int n) + { + if (n == 0) + return -1; + + int pos = 0; + if (n >= 1<<16) { n >>= 16; pos += 16; } + if (n >= 1<< 8) { n >>= 8; pos += 8; } + if (n >= 1<< 4) { n >>= 4; pos += 4; } + if (n >= 1<< 2) { n >>= 2; pos += 2; } + if (n >= 1<< 1) { pos += 1; } + return pos; + } + #if 0 void hexdump(void *pAddressIn, long lSize) { -- cgit v1.2.3