src/misc.cpp
branchgamebalance
changeset 9913 e79cd19772dd
parent 9911 0b8b245a2391
equal deleted inserted replaced
9912:1ac8aac92385 9913:e79cd19772dd
   270 	if ((value & 0x00000001) == 0) { i += 1; }
   270 	if ((value & 0x00000001) == 0) { i += 1; }
   271 
   271 
   272 	return i;
   272 	return i;
   273 }
   273 }
   274 
   274 
       
   275 int CountBitsSet(uint32 value)
       
   276 {
       
   277 	int num;
       
   278 
       
   279 	/* This loop is only called once for every bit set by clearing the lowest
       
   280 	 * bit in each loop. The number of bits is therefore equal to the number of
       
   281 	 * times the loop was called. It was found at the following website:
       
   282 	 * http://graphics.stanford.edu/~seander/bithacks.html */
       
   283 
       
   284 	for (num = 0; value != 0; num++) {
       
   285 		value &= value - 1;
       
   286 	}
       
   287 
       
   288 	return num;
       
   289 }
   275 
   290 
   276 static void Save_NAME()
   291 static void Save_NAME()
   277 {
   292 {
   278 	int i;
   293 	int i;
   279 
   294