glob2-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[glob2-devel] Bug in Map.cpp Checksum computation


From: simon schuler
Subject: [glob2-devel] Bug in Map.cpp Checksum computation
Date: Tue, 25 Jan 2005 02:21:57 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20041229

The checksum computation here is almost useless: It returned the same value for over a minute, until i quit the game...

   Sint32 Map::checkSum(bool heavy)
   {
       Sint32 cs=size;
       if (heavy)
           for (int y=0; y<h; y++)
               for (int x=0; x<w; x++)
               {
                   ...
                   cs=(cs<<1)|(cs>>31);
               }
       return cs;
   }

The rotate Statement cs=(cs<<1)|(cs>>31); is wrong for signed integers and will overwrite the whole integer with 0xFFFFFFFF when cs is negative. Game.cpp expects an Uint32 as return type anyway, so we just have to change the type of cs to Uint32, and make Map::checkSum return an Uint32. After changing this, it returned usable values...

Simon




reply via email to

[Prev in Thread] Current Thread [Next in Thread]