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.43 by root, Mon Apr 23 18:09:57 2007 UTC vs.
Revision 1.44 by root, Fri May 11 08:00:00 2007 UTC

44template<typename T, typename U> static inline T min (T a, U b) { return (U)a < b ? (U)a : b; } 44template<typename T, typename U> static inline T min (T a, U b) { return (U)a < b ? (U)a : b; }
45template<typename T, typename U> static inline T max (T a, U b) { return (U)a > b ? (U)a : b; } 45template<typename T, typename U> static inline T max (T a, U b) { return (U)a > b ? (U)a : b; }
46template<typename T, typename U, typename V> static inline T clamp (T v, U a, V b) { return v < (T)a ? (T)a : v >(T)b ? (T)b : v; } 46template<typename T, typename U, typename V> static inline T clamp (T v, U a, V b) { return v < (T)a ? (T)a : v >(T)b ? (T)b : v; }
47 47
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
50template<typename T>
51static inline T
52lerp (T val, T min_in, T max_in, T min_out, T max_out)
53{
54 return (val - min_in) * (max_out - min_out) / (max_in - min_in) + min_out;
55}
49 56
50// lots of stuff taken from FXT 57// lots of stuff taken from FXT
51 58
52/* Rotate right. This is used in various places for checksumming */ 59/* Rotate right. This is used in various places for checksumming */
53//TODO: that sucks, use a better checksum algo 60//TODO: that sucks, use a better checksum algo

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines