summaryrefslogtreecommitdiff
path: root/src/cmd_topic.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-03-07 11:37:57 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-03-07 11:37:57 +0000
commitcb38f65d8f5d6bb804b4a530ea334126def097dd (patch)
tree81fd5acc696ec622f71cd8817e154957af078dda /src/cmd_topic.cpp
parent2dab2f5663f435c8d6a4a8c817aa79d9e8df80b0 (diff)
TOPIC optimizations, fixes to mode setting with new custom_modes system
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3512 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/cmd_topic.cpp')
-rw-r--r--src/cmd_topic.cpp99
1 files changed, 44 insertions, 55 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]);
+ }
}
}