From 8d7e3fab28008e6353c7520c711aefc4a10e282d Mon Sep 17 00:00:00 2001 From: w00t Date: Mon, 25 Aug 2008 13:20:38 +0000 Subject: Allow Channel::SetTopic with a NULL user record, which sets a blank topic. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10270 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/channels.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/channels.cpp') diff --git a/src/channels.cpp b/src/channels.cpp index ac7c461d6..2884b2d3b 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -74,7 +74,7 @@ std::string Channel::GetModeParameter(char mode) int Channel::SetTopic(User *u, std::string &ntopic, bool forceset) { - if (IS_LOCAL(u)) + if (u && IS_LOCAL(u)) { if(!forceset) { @@ -102,11 +102,20 @@ int Channel::SetTopic(User *u, std::string &ntopic, bool forceset) } this->topic.assign(ntopic, 0, ServerInstance->Config->Limits.MaxTopic); - this->setby.assign(ServerInstance->Config->FullHostInTopic ? u->GetFullHost() : u->nick, 0, 128); + if (u) + { + this->setby.assign(ServerInstance->Config->FullHostInTopic ? u->GetFullHost() : u->nick, 0, 128); + this->WriteChannel(u, "TOPIC %s :%s", this->name.c_str(), this->topic.c_str()); + } + else + { + this->setby.assign(ServerInstance->Config->ServerName); + this->WriteChannelWithServ(ServerInstance->Config->ServerName, "TOPIC %s :%s", this->name.c_str(), this->topic.c_str()); + } + this->topicset = ServerInstance->Time(); - this->WriteChannel(u, "TOPIC %s :%s", this->name.c_str(), this->topic.c_str()); - if (IS_LOCAL(u)) + if (u && IS_LOCAL(u)) { FOREACH_MOD(I_OnPostLocalTopicChange,OnPostLocalTopicChange(u, this, this->topic)); } -- cgit v1.2.3