ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/util.h
(Generate patch)

Comparing deliantra/server/include/util.h (file contents):
Revision 1.37 by root, Thu Feb 15 15:43:36 2007 UTC vs.
Revision 1.38 by root, Thu Feb 15 18:09:34 2007 UTC

48template<typename T, typename U> static inline void swap (T& a, U& b) { T t=a; a=(T)b; b=(U)t; } 48template<typename T, typename U> static inline void swap (T& a, U& b) { T t=a; a=(T)b; b=(U)t; }
49 49
50// lots of stuff taken from FXT 50// lots of stuff taken from FXT
51 51
52/* Rotate right. This is used in various places for checksumming */ 52/* Rotate right. This is used in various places for checksumming */
53//TODO: this sucks, use a better checksum algo 53//TODO: that sucks, use a better checksum algo
54static inline uint32_t 54static inline uint32_t
55rotate_right (uint32_t c) 55rotate_right (uint32_t c, uint32_t count = 1)
56{ 56{
57 return (c << 31) | (c >> 1); 57 return (c << (32 - count)) | (c >> count);
58}
59
60static inline uint32_t
61rotate_left (uint32_t c, uint32_t count = 1)
62{
63 return (c >> (32 - count)) | (c << count);
58} 64}
59 65
60// Return abs(a-b) 66// Return abs(a-b)
61// Both a and b must not have the most significant bit set 67// Both a and b must not have the most significant bit set
62static inline uint32_t 68static inline uint32_t

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines