summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cmd_topic.cpp99
-rw-r--r--src/mode.cpp2
2 files changed, 45 insertions, 56 deletions
diff --git a/src/cmd_topic.cpp b/src/cmd_topic.cpp
index c1eb50532..cb852dabc 100644
--- a/src/cmd_topic.cpp
+++ b/src/cmd_topic.cpp
@@ -68,83 +68,72 @@ void cmd_topic::Handle (char **parameters, int pcnt, userrec *user)
if (pcnt == 1)
{
- if (strlen(parameters[0]) <= CHANMAX)
+ Ptr = FindChan(parameters[0]);
+ if (Ptr)
{
- Ptr = FindChan(parameters[0]);
- if (Ptr)
+ if (((Ptr) && (!has_channel(user,Ptr))) && (Ptr->binarymodes & CM_SECRET))
{
- if (((Ptr) && (!has_channel(user,Ptr))) && (Ptr->binarymodes & CM_SECRET))
- {
- WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, Ptr->name);
- return;
- }
- if (Ptr->topicset)
- {
- WriteServ(user->fd,"332 %s %s :%s", user->nick, Ptr->name, Ptr->topic);
- WriteServ(user->fd,"333 %s %s %s %d", user->nick, Ptr->name, Ptr->setby, Ptr->topicset);
- }
- else
- {
- WriteServ(user->fd,"331 %s %s :No topic is set.", user->nick, Ptr->name);
- }
+ WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, Ptr->name);
+ return;
+ }
+ if (Ptr->topicset)
+ {
+ WriteServ(user->fd,"332 %s %s :%s", user->nick, Ptr->name, Ptr->topic);
+ WriteServ(user->fd,"333 %s %s %s %d", user->nick, Ptr->name, Ptr->setby, Ptr->topicset);
}
else
{
- WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
+ WriteServ(user->fd,"331 %s %s :No topic is set.", user->nick, Ptr->name);
}
}
+ else
+ {
+ WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
+ }
return;
}
else if (pcnt>1)
{
- if (strlen(parameters[0]) <= CHANMAX)
+ Ptr = FindChan(parameters[0]);
+ if (Ptr)
{
- Ptr = FindChan(parameters[0]);
- if (Ptr)
+ if (IS_LOCAL(user))
{
- if (IS_LOCAL(user))
+ if ((Ptr) && (!has_channel(user,Ptr)))
{
- if ((Ptr) && (!has_channel(user,Ptr)))
- {
- WriteServ(user->fd,"442 %s %s :You're not on that channel!",user->nick, Ptr->name);
- return;
- }
- if ((Ptr->binarymodes & CM_TOPICLOCK) && (cstatus(user,Ptr)<STATUS_HOP))
- {
- WriteServ(user->fd,"482 %s %s :You must be at least a half-operator to change modes on this channel", user->nick, Ptr->name);
- return;
- }
+ WriteServ(user->fd,"442 %s %s :You're not on that channel!",user->nick, Ptr->name);
+ return;
}
-
- char topic[MAXBUF];
- strlcpy(topic,parameters[1],MAXBUF);
- if (strlen(topic)>MAXTOPIC)
+ if ((Ptr->binarymodes & CM_TOPICLOCK) && (cstatus(user,Ptr)<STATUS_HOP))
{
- topic[MAXTOPIC] = '\0';
+ WriteServ(user->fd,"482 %s %s :You must be at least a half-operator to change modes on this channel", user->nick, Ptr->name);
+ return;
}
+ }
+ char topic[MAXTOPIC];
+ strlcpy(topic,parameters[1],MAXTOPIC-1);
- if (IS_LOCAL(user))
- {
- int MOD_RESULT = 0;
- FOREACH_RESULT(I_OnLocalTopicChange,OnLocalTopicChange(user,Ptr,topic));
- if (MOD_RESULT)
- return;
- }
+ if (IS_LOCAL(user))
+ {
+ int MOD_RESULT = 0;
+ FOREACH_RESULT(I_OnLocalTopicChange,OnLocalTopicChange(user,Ptr,topic));
+ if (MOD_RESULT)
+ return;
+ }
- strlcpy(Ptr->topic,topic,MAXTOPIC);
- strlcpy(Ptr->setby,user->nick,NICKMAX-1);
- Ptr->topicset = TIME;
- WriteChannel(Ptr,user,"TOPIC %s :%s",Ptr->name, Ptr->topic);
- if (IS_LOCAL(user))
- {
- FOREACH_MOD(I_OnPostLocalTopicChange,OnPostLocalTopicChange(user,Ptr,topic));
- }
- }
- else
+ strlcpy(Ptr->topic,topic,MAXTOPIC-1);
+ strlcpy(Ptr->setby,user->nick,NICKMAX-1);
+ Ptr->topicset = TIME;
+ WriteChannel(Ptr,user,"TOPIC %s :%s",Ptr->name, Ptr->topic);
+ if (IS_LOCAL(user))
{
- WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
+ FOREACH_MOD(I_OnPostLocalTopicChange,OnPostLocalTopicChange(user,Ptr,topic));
}
}
+ else
+ {
+ WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
+ }
}
}
diff --git a/src/mode.cpp b/src/mode.cpp
index 18d8ba3f3..6ce15e203 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -881,7 +881,7 @@ void ModeParser::ProcessModes(char **parameters,userrec* user,chanrec *chan,int
default:
string_list p;
p.clear();
- bool x = strchr(chan->custom_modes,*modechar);
+ bool x = chan->custom_modes[*modechar-65];
if ((!x && !mdir) || (x && mdir))
{
if (!ModeIsListMode(*modechar,MT_CHANNEL))