chanrec::chanrec(InspIRCd* Instance) : ServerInstance(Instance)
{
*name = *topic = *setby = *key = 0;
- created = topicset = limit = 0;
+ maxbans = created = topicset = limit = 0;
memset(&modes,0,64);
age = ServerInstance->Time(true);
}
void chanrec::SetModeParam(char mode,const char* parameter,bool mode_on)
{
- ServerInstance->Log(DEBUG,"SetModeParam called");
-
CustomModeList::iterator n = custom_mode_params.find(mode);
if (mode_on)
{
if (n == custom_mode_params.end())
- {
custom_mode_params[mode] = strdup(parameter);
- ServerInstance->Log(DEBUG,"Custom mode parameter %c %s added",mode,parameter);
- }
- else
- {
- ServerInstance->Log(DEBUG, "Tried to set custom mode parameter for %c '%s' when it was already '%s'", mode, parameter, n->second);
- }
}
else
{
std::string chanrec::GetModeParameter(char mode)
{
- if (mode == 'k')
- {
- return this->key;
- }
- else if (mode == 'l')
- {
- return ConvToStr(this->limit);
- }
- else
+ switch (mode)
{
- CustomModeList::iterator n = custom_mode_params.find(mode);
- if (n != custom_mode_params.end())
- {
- return n->second;
- }
- return "";
+ case 'k':
+ return this->key;
+ case 'l':
+ return ConvToStr(this->limit);
+ default:
+ CustomModeList::iterator n = custom_mode_params.find(mode);
+ if (n != custom_mode_params.end())
+ return n->second;
+ return "";
+ break;
}
}
*Ptr->topic = 0;
*Ptr->setby = 0;
Ptr->topicset = 0;
- Instance->Log(DEBUG,"chanrec::JoinUser(): created: %s",cname);
new_channel = true;
}
else
}
}
}
- else
- {
- Instance->Log(DEBUG,"chanrec::JoinUser(): Overridden checks");
- }
}
/* NOTE: If the user is an oper here, we can extend their user->chans by up to
if (new_channel)
{
- Instance->Log(DEBUG,"BLAMMO, Whacking channel.");
/* Things went seriously pear shaped, so take this away. bwahaha. */
chan_hash::iterator n = Instance->chanlist->find(cname);
if (n != Instance->chanlist->end())
* must stick to ::find().
*/
case '@':
- user->chans[Ptr] |= STATUS_OP;
+ user->chans[Ptr] |= UCMODE_OP;
break;
case '%':
- user->chans[Ptr] |= STATUS_HOP;
+ user->chans[Ptr] |= UCMODE_HOP;
break;
case '+':
- user->chans[Ptr] |= STATUS_VOICE;
+ user->chans[Ptr] |= UCMODE_VOICE;
break;
}
}
/* kill the record */
if (iter != ServerInstance->chanlist->end())
{
- ServerInstance->Log(DEBUG,"del_channel: destroyed: %s", this->name);
FOREACH_MOD(I_OnChannelDelete,OnChannelDelete(this));
ServerInstance->chanlist->erase(iter);
}
void chanrec::WriteChannel(userrec* user, const std::string &text)
{
CUList *ulist = this->GetUsers();
+ char tb[MAXBUF];
if (!user)
return;
+ snprintf(tb,MAXBUF,":%s %s",user->GetFullHost(),text.c_str());
+ std::string out = tb;
+
for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
{
if (IS_LOCAL(i->second))
- user->WriteTo(i->second,text);
+ i->second->Write(out);
}
}
void chanrec::WriteChannelWithServ(const char* ServName, const std::string &text)
{
CUList *ulist = this->GetUsers();
+ char tb[MAXBUF];
+
+ snprintf(tb,MAXBUF,":%s %s",ServName ? ServName : ServerInstance->Config->ServerName, text.c_str());
+ std::string out = tb;
for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
{
if (IS_LOCAL(i->second))
- i->second->WriteServ(text);
+ i->second->Write(out);
}
}
void chanrec::WriteAllExcept(userrec* user, bool serversource, char status, CUList &except_list, const std::string &text)
{
CUList *ulist;
+ char tb[MAXBUF];
switch (status)
{
break;
}
+ snprintf(tb,MAXBUF,":%s %s",user->GetFullHost(),text.c_str());
+ std::string out = tb;
+
for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
{
if ((IS_LOCAL(i->second)) && (except_list.find(i->second) == except_list.end()))
if (serversource)
i->second->WriteServ(text);
else
- i->second->WriteFrom(user,text);
+ i->second->Write(out);
}
}
}
static char scratch[MAXBUF];
static char sparam[MAXBUF];
char* offset = scratch;
- std::string extparam = "";
+ std::string extparam;
*scratch = '\0';
*sparam = '\0';
return;
FOREACH_RESULT(I_OnUserList,OnUserList(user, this));
- ServerInstance->Log(DEBUG,"MOD_RESULT for UserList = %d",MOD_RESULT);
if (MOD_RESULT == 1)
return;
- ServerInstance->Log(DEBUG,"Using builtin NAMES list generation");
-
dlen = curlen = snprintf(list,MAXBUF,"353 %s = %s :", user->nick, this->name);
int numusers = 0;
long chanrec::GetMaxBans()
{
+ /* Return the cached value if there is one */
+ if (this->maxbans)
+ return this->maxbans;
+
+ /* If there isnt one, we have to do some O(n) hax to find it the first time. (ick) */
for (std::map<std::string,int>::iterator n = ServerInstance->Config->maxbans.begin(); n != ServerInstance->Config->maxbans.end(); n++)
{
if (match(this->name,n->first.c_str()))
{
+ this->maxbans = n->second;
return n->second;
}
}
- return 64;
+
+ /* Screw it, just return the default of 64 */
+ this->maxbans = 64;
+ return this->maxbans;
}
+void chanrec::ResetMaxBans()
+{
+ this->maxbans = 0;
+}
/* returns the status character for a given user on a channel, e.g. @ for op,
* % for halfop etc. If the user has several modes set, the highest mode
n->second.erase(x);
}
}
- ServerInstance->Log(DEBUG,"Added prefix %c to %s for %s, prefixlist size is now %d", prefix, this->name, user->nick, prefixes.size());
}
void chanrec::RemoveAllPrefixes(userrec* user)
prefixlist::iterator n = prefixes.find(user);
if (n != prefixes.end())
{
- ServerInstance->Log(DEBUG,"Removed prefixes from %s for %s, prefixlist size is now %d", this->name, user->nick, prefixes.size());
prefixes.erase(n);
}
}