* | Inspire Internet Relay Chat Daemon |
* +------------------------------------+
*
- * InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ * InspIRCd: (C) 2002-2008 InspIRCd Development Team
* See: http://www.inspircd.org/wiki/index.php/Credits
*
* This program is free but copyrighted software; see
#include "wildcard.h"
#include "mode.h"
-Channel::Channel(InspIRCd* Instance, const std::string &name, time_t ts) : ServerInstance(Instance)
+Channel::Channel(InspIRCd* Instance, const std::string &cname, time_t ts) : ServerInstance(Instance)
{
- (*(ServerInstance->chanlist))[name.c_str()] = this;
- strlcpy(this->name, name.c_str(), CHANMAX);
- this->created = ts ? ts : ServerInstance->Time(true);
+ chan_hash::iterator findchan = ServerInstance->chanlist->find(name);
+ if (findchan != Instance->chanlist->end())
+ throw CoreException("Cannot create duplicate channel " + cname);
+
+ (*(ServerInstance->chanlist))[cname.c_str()] = this;
+ strlcpy(this->name, cname.c_str(), CHANMAX);
+ this->created = ts ? ts : ServerInstance->Time();
this->age = this->created;
if (!IS_LOCAL(user))
{
if (!TS)
- Instance->Log(DEBUG,"*** BUG *** Channel::JoinUser called for REMOTE user '%s' on channel '%s' but no TS given!", user->nick, cn);
+ Instance->Logs->Log("CHANNEL",DEBUG,"*** BUG *** Channel::JoinUser called for REMOTE user '%s' on channel '%s' but no TS given!", user->nick, cn);
}
else
{
ModeHandler* mh = Instance->Modes->FindPrefix(status);
if (mh)
{
+ /* Set, and make sure that the mode handler knows this mode was now set */
Ptr->SetPrefix(user, status, mh->GetPrefixRank(), true);
- /* Make sure that the mode handler knows this mode was now set */
mh->OnModeChange(Instance->FakeClient, Instance->FakeClient, Ptr, nick, true);
switch (mh->GetPrefix())
{
- /* These logic ops are SAFE IN THIS CASE
- * because if the entry doesnt exist,
- * addressing operator[] creates it.
- * If they do exist, it points to it.
- * At all other times where we dont want
- * to create an item if it doesnt exist, we
+ /* These logic ops are SAFE IN THIS CASE because if the entry doesnt exist,
+ * addressing operator[] creates it. If they do exist, it points to it.
+ * At all other times where we dont want to create an item if it doesnt exist, we
* must stick to ::find().
*/
case '@':
/* kill the record */
if (iter != ServerInstance->chanlist->end())
{
- FOREACH_MOD(I_OnChannelDelete,OnChannelDelete(this));
+ int MOD_RESULT = 0;
+ FOREACH_RESULT_I(ServerInstance,I_OnChannelPreDelete, OnChannelPreDelete(this));
+ if (MOD_RESULT == 1)
+ return 1; // delete halted by module
+ FOREACH_MOD(I_OnChannelDelete, OnChannelDelete(this));
ServerInstance->chanlist->erase(iter);
}
return 0;
/* kill the record */
if (iter != ServerInstance->chanlist->end())
{
- FOREACH_MOD(I_OnChannelDelete,OnChannelDelete(this));
+ int MOD_RESULT = 0;
+ FOREACH_RESULT_I(ServerInstance,I_OnChannelPreDelete, OnChannelPreDelete(this));
+ if (MOD_RESULT == 1)
+ return 1; // delete halted by module
+ FOREACH_MOD(I_OnChannelDelete, OnChannelDelete(this));
ServerInstance->chanlist->erase(iter);
}
return 0;
/* kill the record */
if (iter != ServerInstance->chanlist->end())
{
- FOREACH_MOD(I_OnChannelDelete,OnChannelDelete(this));
+ int MOD_RESULT = 0;
+ FOREACH_RESULT_I(ServerInstance,I_OnChannelPreDelete, OnChannelPreDelete(this));
+ if (MOD_RESULT == 1)
+ return 1; // delete halted by module
+ FOREACH_MOD(I_OnChannelDelete, OnChannelDelete(this));
ServerInstance->chanlist->erase(iter);
}
return 0;
return this->GetUserCounter();
}
-void Channel::WriteChannel(User* user, char* text, ...)
+void Channel::WriteChannel(User* user, const char* text, ...)
{
char textbuffer[MAXBUF];
va_list argsPtr;
/* write formatted text from a source user to all users on a channel except
* for the sender (for privmsg etc) */
-void Channel::WriteAllExceptSender(User* user, bool serversource, char status, char* text, ...)
+void Channel::WriteAllExceptSender(User* user, bool serversource, char status, const char* text, ...)
{
char textbuffer[MAXBUF];
va_list argsPtr;
this->WriteAllExceptSender(user, serversource, status, std::string(textbuffer));
}
-void Channel::WriteAllExcept(User* user, bool serversource, char status, CUList &except_list, char* text, ...)
+void Channel::WriteAllExcept(User* user, bool serversource, char status, CUList &except_list, const char* text, ...)
{
char textbuffer[MAXBUF];
va_list argsPtr;