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.42 by root, Sat Apr 21 23:03:54 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
434// return current time as timestampe 441// return current time as timestampe
435tstamp now (); 442tstamp now ();
436 443
437int similar_direction (int a, int b); 444int similar_direction (int a, int b);
438 445
446// like printf, but returns a std::string
447const std::string format (const char *format, ...);
448
439#endif 449#endif
440 450

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines