From e820e1af0d01011dbe9d91d2971cc3518f7f3d42 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 28 Aug 2010 20:56:45 -0400 Subject: Properly store our clients internal channel status's and burst them if needed. Also made Flag::HasFlag use test() instead of operator[] to catch errors, and fixed an out of bounds access to a Flags bitset causing crashes on some systems. --- include/channels.h | 2 +- include/extern.h | 4 ++-- include/operserv.h | 4 ++-- include/regchannel.h | 4 ++-- include/services.h | 4 ++-- include/users.h | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) (limited to 'include') diff --git a/include/channels.h b/include/channels.h index d1e82fa8d..ec886c9ca 100644 --- a/include/channels.h +++ b/include/channels.h @@ -70,7 +70,7 @@ class CoreExport Channel : public Extensible, public Flags std::map Params; /* Modes set on the channel */ - Flags modes; + Flags modes; public: /** Default constructor diff --git a/include/extern.h b/include/extern.h index 05e43a980..9f2071a88 100644 --- a/include/extern.h +++ b/include/extern.h @@ -282,8 +282,8 @@ E bool str_is_cidr(const Anope::string &str, uint32 &ip, uint32 &mask, Anope::st /**** modes.cpp ****/ /* Number of generic modes we support */ E unsigned GenericChannelModes, GenericUserModes; -E Flags DefMLockOn; -E Flags DefMLockOff; +E Flags DefMLockOn; +E Flags DefMLockOff; E std::map DefMLockParams; E void SetDefaultMLock(ServerConfig *config); diff --git a/include/operserv.h b/include/operserv.h index 679a066a0..2711520cd 100644 --- a/include/operserv.h +++ b/include/operserv.h @@ -12,8 +12,8 @@ extern CoreExport std::vector News; extern CoreExport std::vector > DefCon; extern CoreExport bool DefConModesSet; -extern CoreExport Flags DefConModesOn; -extern CoreExport Flags DefConModesOff; +extern CoreExport Flags DefConModesOn; +extern CoreExport Flags DefConModesOff; extern CoreExport std::map DefConModesOnParams; class XLineManager; diff --git a/include/regchannel.h b/include/regchannel.h index e19b07f5e..80b25abfb 100644 --- a/include/regchannel.h +++ b/include/regchannel.h @@ -69,8 +69,8 @@ class CoreExport ChannelInfo : public Extensible, public Flags access; /* List of authorized users */ std::vector akick; /* List of users to kickban */ std::vector badwords; /* List of badwords */ - Flags mlock_on; /* Modes mlocked on */ - Flags mlock_off; /* Modes mlocked off */ + Flags mlock_on; /* Modes mlocked on */ + Flags mlock_off; /* Modes mlocked off */ public: /** Default constructor diff --git a/include/services.h b/include/services.h index f8f37be6e..4702dcff1 100644 --- a/include/services.h +++ b/include/services.h @@ -301,7 +301,7 @@ template inline T debug_cast(O ptr) { #ifdef DEBUG_BUILD T ret = dynamic_cast(ptr); - if (ret == NULL) + if (ptr != NULL && ret == NULL) throw CoreException(Anope::string("debug_cast<") + typeid(T).name() + ">(" + typeid(O).name() + ") fail"); return ret; #else @@ -342,7 +342,7 @@ template class Flags */ bool HasFlag(T Value) const { - return Flag_Values[Value]; + return Flag_Values.test(Value); } /** Check how many flags are set diff --git a/include/users.h b/include/users.h index e65068f33..596f5ee39 100644 --- a/include/users.h +++ b/include/users.h @@ -17,7 +17,7 @@ typedef unordered_map_namespace::unordered_map +class ChannelStatus : public Flags { public: Anope::string BuildCharPrefixList() const; @@ -43,7 +43,7 @@ class CoreExport User : public Extensible Anope::string ident; Anope::string uid; bool OnAccess; /* If the user is on the access list of the nick theyre on */ - Flags modes; /* Bitset of mode names the user has set on them */ + Flags modes; /* Bitset of mode names the user has set on them */ std::map Params; /* Map of user modes and the params this user has */ NickCore *nc; /* NickCore account the user is currently loggged in as */ -- cgit