}
/* chanrec::PartUser
- * remove a channel from a users record, and remove the record from the hash
- * if the channel has become empty
+ * remove a channel from a users record, and return the number of users left.
+ * Therefore, if this function returns 0 the caller should delete the chanrec.
*/
long chanrec::PartUser(userrec *user, const char* reason)
{
/* zap it from the channel list of the user */
if (user->chans[i]->channel == this)
{
- if (reason)
- {
- FOREACH_MOD(I_OnUserPart,OnUserPart(user, this, reason));
- this->WriteChannel(user, "PART %s :%s", this->name, reason);
- }
- else
- {
- FOREACH_MOD(I_OnUserPart,OnUserPart(user, this, ""));
- this->WriteChannel(user, "PART :%s", this->name);
- }
+ FOREACH_MOD(I_OnUserPart,OnUserPart(user, this, reason ? reason : ""));
+ this->WriteChannel(user, "PART %s%s%s", this->name, reason ? " :" : "", reason ? reason : "");
user->chans[i]->uc_modes = 0;
user->chans[i]->channel = NULL;
user->ModChannelCount(-1);
int us = this->GetStatus(user);
if ((them < STATUS_HOP) || (them < us))
{
- if (them == STATUS_HOP)
- {
- src->WriteServ("482 %s %s :You must be a channel operator",src->nick, this->name);
- }
- else
- {
- src->WriteServ("482 %s %s :You must be at least a half-operator",src->nick, this->name);
- }
+ src->WriteServ("482 %s %s :You must be a channel %soperator",src->nick, this->name, them == STATUS_HOP ? "" : "half-");
return this->GetUserCounter();
}
}
*scratch = '\0';
*sparam = '\0';
- /* This was still iterating up to 190, chanrec::custom_modes is only 64 elements -- Om */
+ /* This was still iterating up to 190, chanrec::modes is only 64 elements -- Om */
for(int n = 0; n < 64; n++)
{
if(this->modes[n])
size_t dlen, curlen;
int MOD_RESULT = 0;
+ if (!IS_LOCAL(user))
+ return;
+
FOREACH_RESULT(I_OnUserList,OnUserList(user, this));
ServerInstance->Log(DEBUG,"MOD_RESULT for UserList = %d",MOD_RESULT);
if (MOD_RESULT == 1)
long chanrec::GetMaxBans()
{
- std::string x;
for (std::map<std::string,int>::iterator n = ServerInstance->Config->maxbans.begin(); n != ServerInstance->Config->maxbans.end(); n++)
{
- x = n->first;
- if (match(this->name,x.c_str()))
+ if (match(this->name,n->first.c_str()))
{
return n->second;
}
*/
const char* chanrec::GetPrefixChar(userrec *user)
{
- static char px[2];
- unsigned int mx = 0;
-
- *px = 0;
- *(px+1) = 0;
-
+ static char pf[2] = {0, 0};
+
prefixlist::iterator n = prefixes.find(user);
if (n != prefixes.end())
{
- for (std::vector<prefixtype>::iterator x = n->second.begin(); x != n->second.end(); x++)
+ if (n->second.size())
{
- if (x->second > mx)
- {
- *px = x->first;
- mx = x->second;
- }
+ *pf = n->second.begin()->first;
+ return pf;
}
}
- return px;
+ *pf = 0;
+ return pf;
}
const char* chanrec::GetAllPrefixChars(userrec* user)
unsigned int chanrec::GetPrefixValue(userrec* user)
{
- unsigned int mx = 0;
-
prefixlist::iterator n = prefixes.find(user);
if (n != prefixes.end())
{
- for (std::vector<prefixtype>::iterator x = n->second.begin(); x != n->second.end(); x++)
- {
- if (x->second > mx)
- mx = x->second;
- }
+ if (n->second.size())
+ return n->second.begin()->second;
}
-
- return mx;
+ return 0;
}