diff --git a/common/data_verification.h b/common/data_verification.h index 9da85a579..fe1152cb4 100644 --- a/common/data_verification.h +++ b/common/data_verification.h @@ -1,5 +1,6 @@ /* EQEMu: Everquest Server Emulator - Copyright (C) 2001-2014 EQEMu Development Team (http://eqemulator.net) + + Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -13,36 +14,42 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + #ifndef COMMON_DATA_VERIFICATION_H #define COMMON_DATA_VERIFICATION_H #include + namespace EQEmu { + template + T Clamp(const T& value, const T& lower, const T& upper) { + return std::max(lower, std::min(value, upper)); + } -template -T Clamp(const T& value, const T& lower, const T& upper) { - return std::max(lower, std::min(value, upper)); -} + template + T ClampLower(const T& value, const T& lower) { + return std::max(lower, value); + } -template -T ClampLower(const T& value, const T& lower) { - return std::max(lower, value); -} + template + T ClampUpper(const T& value, const T& upper) { + return std::min(value, upper); + } -template -T ClampUpper(const T& value, const T& upper) { - return std::min(value, upper); -} + template + bool ValueWithin(const T& value, const T& lower, const T& upper) { + return value >= lower && value <= upper; + } -template -bool ValueWithin(const T& value, const T& lower, const T& upper) { - return value >= lower && value <= upper; -} + template + bool ValueWithin(const T1& value, const T2& lower, const T3& upper) { + return value >= (T1)lower && value <= (T1)upper; + } -} +} /*EQEmu*/ -#endif +#endif /*COMMON_DATA_VERIFICATION_H*/