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.115 by root, Tue Apr 26 14:41:36 2011 UTC vs.
Revision 1.116 by root, Sat Dec 31 06:18:01 2011 UTC

86void cleanup (const char *cause, bool make_core = false); 86void cleanup (const char *cause, bool make_core = false);
87void fork_abort (const char *msg); 87void fork_abort (const char *msg);
88 88
89// rationale for using (U) not (T) is to reduce signed/unsigned issues, 89// rationale for using (U) not (T) is to reduce signed/unsigned issues,
90// as a is often a constant while b is the variable. it is still a bug, though. 90// as a is often a constant while b is the variable. it is still a bug, though.
91template<typename T, typename U> static inline T min (T a, U b) { return (U)a < b ? (U)a : b; } 91template<typename T, typename U> static inline T min (T a, U b) { return a < (T)b ? a : (T)b; }
92template<typename T, typename U> static inline T max (T a, U b) { return (U)a > b ? (U)a : b; } 92template<typename T, typename U> static inline T max (T a, U b) { return a > (T)b ? a : (T)b; }
93template<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; } 93template<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; }
94 94
95template<typename T, typename U> static inline void min_it (T &v, U m) { v = min (v, (T)m); } 95template<typename T, typename U> static inline void min_it (T &v, U m) { v = min (v, (T)m); }
96template<typename T, typename U> static inline void max_it (T &v, U m) { v = max (v, (T)m); } 96template<typename T, typename U> static inline void max_it (T &v, U m) { v = max (v, (T)m); }
97template<typename T, typename U, typename V> static inline void clamp_it (T &v, U a, V b) { v = clamp (v, (T)a, (T)b); } 97template<typename T, typename U, typename V> static inline void clamp_it (T &v, U a, V b) { v = clamp (v, (T)a, (T)b); }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines