From df37ab42f454e3a96d59a2a86eb76bcb4af0818a Mon Sep 17 00:00:00 2001 From: danieldg Date: Sun, 15 Nov 2009 18:26:25 +0000 Subject: Hide channel mode structures git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12132 e03df62e-2008-0410-955e-edbf42e46eb7 --- include/channels.h | 42 +++++++++++++++--------------------------- include/modes/cmode_t.h | 3 +-- src/modes/cmode_t.cpp | 16 +--------------- src/modules/m_knock.cpp | 2 +- src/modules/m_override.cpp | 6 +++--- src/modules/m_redirect.cpp | 2 +- 6 files changed, 22 insertions(+), 49 deletions(-) diff --git a/include/channels.h b/include/channels.h index 9b4e40375..3ad26ceda 100644 --- a/include/channels.h +++ b/include/channels.h @@ -55,14 +55,6 @@ class BanItem : public HostItem { }; -/** used to hold a channel and a users modes on that channel, e.g. +v, +h, +o - */ -enum UserChannelModes { - UCMODE_OP = 1, /* Opped user */ - UCMODE_VOICE = 2, /* Voiced user */ - UCMODE_HOP = 4 /* Halfopped user */ -}; - /** Holds all relevent information for a channel. * This class represents a channel, and contains its name, modes, topic, topic set time, * etc, and an instance of the BanList type. @@ -81,6 +73,19 @@ class CoreExport Channel : public Extensible */ int maxbans; + /** Modes for the channel. + * This is not a null terminated string! It is a bitset where + * each item in it represents if a mode is set. For example + * for mode +A, index 0. Use modechar-65 to calculate which + * field to check. + */ + std::bitset<64> modes; + + /** Parameters for custom modes. + * One for each custom mode letter. + */ + CustomModeList custom_mode_params; + public: /** Creates a channel record and initialises it with default values * @throw Nothing at present. @@ -89,33 +94,20 @@ class CoreExport Channel : public Extensible /** The channel's name. */ - std::string name; /* CHANMAX */ + std::string name; /** Time that the object was instantiated (used for TS calculation etc) */ time_t age; - /** Modes for the channel. - * This is not a null terminated string! It is a bitset where - * each item in it represents if a mode is set. For example - * for mode +A, index 0. Use modechar-65 to calculate which - * field to check. - */ - std::bitset<64> modes; - /** User list. */ UserMembList userlist; - /** Parameters for custom modes. - * One for each custom mode letter. - */ - CustomModeList custom_mode_params; - /** Channel topic. * If this is an empty string, no channel topic is set. */ - std::string topic; /* MAXTOPIC */ + std::string topic; /** Time topic was set. * If no topic was ever set, this will be equal to Channel::created @@ -398,10 +390,6 @@ class CoreExport Channel : public Extensible /** Clears the cached max bans value */ void ResetMaxBans(); - - /** Destructor for Channel - */ - virtual ~Channel() { /* stub */ } }; #endif diff --git a/include/modes/cmode_t.h b/include/modes/cmode_t.h index 6d0ce4777..5f4bb9c60 100644 --- a/include/modes/cmode_t.h +++ b/include/modes/cmode_t.h @@ -17,9 +17,8 @@ class InspIRCd; /** Channel mode +t */ -class ModeChannelTopicOps : public ModeHandler +class ModeChannelTopicOps : public SimpleChannelModeHandler { public: ModeChannelTopicOps(); - ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding); }; diff --git a/src/modes/cmode_t.cpp b/src/modes/cmode_t.cpp index b85922b06..b9b108f5f 100644 --- a/src/modes/cmode_t.cpp +++ b/src/modes/cmode_t.cpp @@ -17,20 +17,6 @@ #include "users.h" #include "modes/cmode_t.h" -ModeChannelTopicOps::ModeChannelTopicOps() : ModeHandler(NULL, "topic", 't', PARAM_NONE, MODETYPE_CHANNEL) +ModeChannelTopicOps::ModeChannelTopicOps() : SimpleChannelModeHandler(NULL, "topic", 't') { } - -ModeAction ModeChannelTopicOps::OnModeChange(User*, User*, Channel* channel, std::string&, bool adding) -{ - if (channel->modes[CM_TOPICLOCK] != adding) - { - channel->modes[CM_TOPICLOCK] = adding; - return MODEACTION_ALLOW; - } - else - { - return MODEACTION_DENY; - } -} - diff --git a/src/modules/m_knock.cpp b/src/modules/m_knock.cpp index 3e794547e..04b843c86 100644 --- a/src/modules/m_knock.cpp +++ b/src/modules/m_knock.cpp @@ -49,7 +49,7 @@ class CommandKnock : public Command return CMD_FAILURE; } - if (!c->modes[CM_INVITEONLY]) + if (!c->IsModeSet('i')) { user->WriteNumeric(480, "%s :Can't KNOCK on %s, channel is not invite only so knocking is pointless!",user->nick.c_str(), c->name.c_str()); return CMD_FAILURE; diff --git a/src/modules/m_override.cpp b/src/modules/m_override.cpp index cf18495b5..d931891c2 100644 --- a/src/modules/m_override.cpp +++ b/src/modules/m_override.cpp @@ -132,7 +132,7 @@ class ModuleOverride : public Module { if (chan) { - if ((chan->modes[CM_INVITEONLY]) && (CanOverride(user,"INVITE"))) + if (chan->IsModeSet('i') && (CanOverride(user,"INVITE"))) { irc::string x(chan->name.c_str()); if (!IS_LOCAL(user)->IsInvited(x)) @@ -151,7 +151,7 @@ class ModuleOverride : public Module return MOD_RES_ALLOW; } - if ((chan->modes[CM_KEY]) && (CanOverride(user,"KEY")) && keygiven != chan->GetModeParameter('k')) + if (chan->IsModeSet('k') && (CanOverride(user,"KEY")) && keygiven != chan->GetModeParameter('k')) { if (RequireKey && keygiven != "override") { @@ -166,7 +166,7 @@ class ModuleOverride : public Module return MOD_RES_ALLOW; } - if ((chan->modes[CM_LIMIT]) && (chan->GetUserCounter() >= atoi(chan->GetModeParameter('l').c_str())) && (CanOverride(user,"LIMIT"))) + if (chan->IsModeSet('l') && (chan->GetUserCounter() >= atoi(chan->GetModeParameter('l').c_str())) && (CanOverride(user,"LIMIT"))) { if (RequireKey && keygiven != "override") { diff --git a/src/modules/m_redirect.cpp b/src/modules/m_redirect.cpp index 50d2e929f..ff7fb6ac4 100644 --- a/src/modules/m_redirect.cpp +++ b/src/modules/m_redirect.cpp @@ -96,7 +96,7 @@ class ModuleRedirect : public Module { if (chan) { - if (chan->IsModeSet('L') && chan->modes[CM_LIMIT]) + if (chan->IsModeSet('L') && chan->IsModeSet('l')) { if (chan->GetUserCounter() >= atoi(chan->GetModeParameter('l').c_str())) { -- cgit v1.2.3