diff options
author | Adam <Adam@anope.org> | 2013-11-01 04:58:38 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2013-11-01 04:58:38 -0400 |
commit | 4ee9021adbb10140c30d6027a97e4748cb2f5903 (patch) | |
tree | f587e7492f142f8d4e7a908190c83a22087559b0 /include/anope.h | |
parent | c8db362bca238aaedf9113383a731d18ba88594f (diff) |
Compare access entries created with the levels access system by access level and not by privilege set, as two entries can have the same privset but different levels, but still represent two different levels of access. This prevented users from adding other users at a lower access level when that level had the same privset as them. Spotted by TSG.
Diffstat (limited to 'include/anope.h')
-rw-r--r-- | include/anope.h | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/include/anope.h b/include/anope.h index 51ece1cd6..07ed29ebf 100644 --- a/include/anope.h +++ b/include/anope.h @@ -762,17 +762,31 @@ template<typename T> inline T convertTo(const Anope::string &s, bool failIfLefto */ #ifdef DEBUG_BUILD # include <typeinfo> -#endif -template<typename T, typename O> inline T anope_dynamic_static_cast(O ptr) + +template<typename T, typename O> inline T anope_dynamic_static_cast(O* ptr) { -#ifdef DEBUG_BUILD T ret = dynamic_cast<T>(ptr); if (ptr != NULL && ret == NULL) - throw CoreException(Anope::string("anope_dynamic_static_cast<") + typeid(T).name() + ">(" + typeid(O).name() + ") fail"); + throw CoreException(Anope::string("anope_dynamic_static_cast<") + typeid(T).name() + ">(" + typeid(O*).name() + ") fail"); return ret; +} + +template<typename T, typename O> inline T anope_dynamic_static_cast(O& ref) +{ + try + { + return dynamic_cast<T>(ref); + } + catch (const std::bad_cast &ex) + { + throw CoreException(Anope::string("std::bad_cast from anope_dynamic_static_cast<") + typeid(T).name() + ">(" + typeid(O&).name() + "): " + ex.what()); + } +} #else +template<typename T, typename O> inline T anope_dynamic_static_cast(O ptr) +{ return static_cast<T>(ptr); -#endif } +#endif #endif // ANOPE_H |