diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/channels.cpp | 4 | ||||
-rw-r--r-- | src/commands.cpp | 22 | ||||
-rw-r--r-- | src/inspircd.cpp | 27 | ||||
-rw-r--r-- | src/message.cpp | 2 | ||||
-rw-r--r-- | src/mode.cpp | 128 | ||||
-rw-r--r-- | src/modules/m_knock.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_override.cpp | 2 | ||||
-rw-r--r-- | src/users.cpp | 1 |
8 files changed, 104 insertions, 84 deletions
diff --git a/src/channels.cpp b/src/channels.cpp index 4e46c3b30..5ba38a9e6 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -117,8 +117,8 @@ chanrec::chanrec() strcpy(topic,""); strcpy(setby,""); strcpy(key,""); - created = topicset = limit = users = 0; - topiclock = noexternal = inviteonly = moderated = secret = c_private = false; + created = topicset = limit = 0; + binarymodes = 0; internal_userlist.clear(); } diff --git a/src/commands.cpp b/src/commands.cpp index f98ad5eb2..d04a79f4d 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -473,7 +473,7 @@ void handle_invite(char **parameters, int pcnt, userrec *user) } else { - if (c->inviteonly) + if (c->binarymodes & CM_INVITEONLY) { WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]); } @@ -482,7 +482,7 @@ void handle_invite(char **parameters, int pcnt, userrec *user) return; } - if (c->inviteonly) + if (c->binarymodes & CM_INVITEONLY) { if (cstatus(user,c) < STATUS_HOP) { @@ -528,7 +528,7 @@ void handle_topic(char **parameters, int pcnt, userrec *user) Ptr = FindChan(parameters[0]); if (Ptr) { - if (((Ptr) && (!has_channel(user,Ptr))) && (Ptr->secret)) + if (((Ptr) && (!has_channel(user,Ptr))) && (Ptr->binarymodes & CM_SECRET)) { WriteServ(user->fd,"442 %s %s :You're not on that channel!",user->nick, Ptr->name); return; @@ -562,7 +562,7 @@ void handle_topic(char **parameters, int pcnt, userrec *user) WriteServ(user->fd,"442 %s %s :You're not on that channel!",user->nick, Ptr->name); return; } - if ((Ptr->topiclock) && (cstatus(user,Ptr)<STATUS_HOP)) + 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; @@ -616,7 +616,7 @@ void handle_names(char **parameters, int pcnt, userrec *user) c = FindChan(parameters[0]); if (c) { - if (((c) && (!has_channel(user,c))) && (c->secret)) + if (((c) && (!has_channel(user,c))) && (c->binarymodes & CM_SECRET)) { WriteServ(user->fd,"442 %s %s :You're not on that channel!",user->nick, c->name); return; @@ -644,12 +644,12 @@ void handle_privmsg(char **parameters, int pcnt, userrec *user) chan = FindChan(parameters[0]); if (chan) { - if ((chan->noexternal) && (!has_channel(user,chan))) + if ((chan->binarymodes & CM_NOEXTERNAL) && (!has_channel(user,chan))) { WriteServ(user->fd,"404 %s %s :Cannot send to channel (no external messages)", user->nick, chan->name); return; } - if ((chan->moderated) && (cstatus(user,chan)<STATUS_VOICE)) + if ((chan->binarymodes & CM_MODERATED) && (cstatus(user,chan)<STATUS_VOICE)) { WriteServ(user->fd,"404 %s %s :Cannot send to channel (+m)", user->nick, chan->name); return; @@ -738,12 +738,12 @@ void handle_notice(char **parameters, int pcnt, userrec *user) chan = FindChan(parameters[0]); if (chan) { - if ((chan->noexternal) && (!has_channel(user,chan))) + if ((chan->binarymodes & CM_NOEXTERNAL) && (!has_channel(user,chan))) { WriteServ(user->fd,"404 %s %s :Cannot send to channel (no external messages)", user->nick, chan->name); return; } - if ((chan->moderated) && (cstatus(user,chan)<STATUS_VOICE)) + if ((chan->binarymodes & CM_MODERATED) && (cstatus(user,chan)<STATUS_VOICE)) { WriteServ(user->fd,"404 %s %s :Cannot send to channel (+m)", user->nick, chan->name); return; @@ -1121,7 +1121,7 @@ void handle_list(char **parameters, int pcnt, userrec *user) for (chan_hash::const_iterator i = chanlist.begin(); i != chanlist.end(); i++) { // if the channel is not private/secret, OR the user is on the channel anyway - if (((!i->second->c_private) && (!i->second->secret)) || (has_channel(user,i->second))) + if (((!(i->second->binarymodes & CM_PRIVATE)) && (!(i->second->binarymodes & CM_SECRET))) || (has_channel(user,i->second))) { WriteServ(user->fd,"322 %s %s %d :[+%s] %s",user->nick,i->second->name,usercount_i(i->second),chanmodes(i->second),i->second->topic); } @@ -2421,7 +2421,7 @@ void handle_N(char token,char* params,serverrec* source,serverrec* reply, char* strlcpy(clientlist[nick]->server, server,256); strlcpy(clientlist[nick]->ident, ident,10); // +1 char to compensate for tilde strlcpy(clientlist[nick]->fullname, gecos,128); - strlcpy(clientlist[nick]->ip,ipaddr,32); + strlcpy(clientlist[nick]->ip,ipaddr,16); clientlist[nick]->signon = TS; clientlist[nick]->nping = 0; // this is ignored for a remote user anyway. clientlist[nick]->lastping = 1; diff --git a/src/inspircd.cpp b/src/inspircd.cpp index f11386a26..635effbeb 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -1437,11 +1437,11 @@ char* chanmodes(chanrec *chan) strcpy(scratch,""); strcpy(sparam,""); - if (chan->noexternal) + if (chan->binarymodes & CM_NOEXTERNAL) { strlcat(scratch,"n",MAXMODES); } - if (chan->topiclock) + if (chan->binarymodes & CM_TOPICLOCK) { strlcat(scratch,"t",MAXMODES); } @@ -1453,19 +1453,19 @@ char* chanmodes(chanrec *chan) { strlcat(scratch,"l",MAXMODES); } - if (chan->inviteonly) + if (chan->binarymodes & CM_INVITEONLY) { strlcat(scratch,"i",MAXMODES); } - if (chan->moderated) + if (chan->binarymodes & CM_MODERATED) { strlcat(scratch,"m",MAXMODES); } - if (chan->secret) + if (chan->binarymodes & CM_SECRET) { strlcat(scratch,"s",MAXMODES); } - if (chan->c_private) + if (chan->binarymodes & CM_PRIVATE) { strlcat(scratch,"p",MAXMODES); } @@ -1639,8 +1639,7 @@ chanrec* add_channel(userrec *user, const char* cn, const char* key, bool overri chanlist[cname] = new chanrec(); strlcpy(chanlist[cname]->name, cname,CHANMAX); - chanlist[cname]->topiclock = 1; - chanlist[cname]->noexternal = 1; + chanlist[cname]->binarymodes = CM_TOPICLOCK | CM_NOEXTERNAL; chanlist[cname]->created = TIME; strcpy(chanlist[cname]->topic, ""); strncpy(chanlist[cname]->setby, user->nick,NICKMAX); @@ -1705,7 +1704,7 @@ chanrec* add_channel(userrec *user, const char* cn, const char* key, bool overri FOREACH_RESULT(OnCheckInvite(user, Ptr)); if (MOD_RESULT == 0) { - if (Ptr->inviteonly) + if (Ptr->binarymodes & CM_INVITEONLY) { log(DEBUG,"add_channel: channel is +i"); if (user->IsInvited(Ptr->name)) @@ -2450,9 +2449,9 @@ void AddWhoWas(userrec* u) user_hash::iterator iter = whowas.find(u->nick); userrec *a = new userrec(); strlcpy(a->nick,u->nick,NICKMAX); - strlcpy(a->ident,u->ident,64); - strlcpy(a->dhost,u->dhost,256); - strlcpy(a->host,u->host,256); + strlcpy(a->ident,u->ident,15); + strlcpy(a->dhost,u->dhost,160); + strlcpy(a->host,u->host,160); strlcpy(a->fullname,u->fullname,128); strlcpy(a->server,u->server,256); a->signon = u->signon; @@ -2541,12 +2540,12 @@ void AddClient(int socket, char* host, int port, bool iscached, char* ip) strncpy(clientlist[tempnick]->host, host,160); strncpy(clientlist[tempnick]->dhost, host,160); strncpy(clientlist[tempnick]->server, ServerName,256); - strncpy(clientlist[tempnick]->ident, "unknown",12); + strncpy(clientlist[tempnick]->ident, "unknown",15); clientlist[tempnick]->registered = 0; clientlist[tempnick]->signon = TIME+dns_timeout; clientlist[tempnick]->lastping = 1; clientlist[tempnick]->port = port; - strncpy(clientlist[tempnick]->ip,ip,32); + strncpy(clientlist[tempnick]->ip,ip,16); // set the registration timeout for this user unsigned long class_regtimeout = 90; diff --git a/src/message.cpp b/src/message.cpp index 59e961d9a..2f372b5d8 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -483,7 +483,7 @@ char* chlist(userrec *user,userrec* source) if (!strstr(lst,cmp)) { // if the channel is NOT private/secret, OR the source user is on the channel - if (((!user->chans[i].channel->c_private) && (!user->chans[i].channel->secret)) || (has_channel(source,user->chans[i].channel))) + if (((!(user->chans[i].channel->binarymodes & CM_PRIVATE)) && (!(user->chans[i].channel->binarymodes & CM_SECRET))) || (has_channel(source,user->chans[i].channel))) { strlcat(lst,cmode(user,user->chans[i].channel),MAXBUF); strlcat(lst,user->chans[i].channel->name,MAXBUF); diff --git a/src/mode.cpp b/src/mode.cpp index 69284ab5c..67f3785d8 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -882,7 +882,7 @@ void process_modes(char **parameters,userrec* user,chanrec *chan,int status, int // reported by mech: large values cause underflow if (chan->limit < 0) - chan->limit = 0x7FFFFF; + chan->limit = 0x7FFF; } if (chan->limit) @@ -899,11 +899,16 @@ void process_modes(char **parameters,userrec* user,chanrec *chan,int status, int FOREACH_RESULT(OnRawMode(user, chan, 'i', "", mdir, 0)); if (!MOD_RESULT) { - if (chan->inviteonly != mdir) + if (mdir) { - strlcat(outlist,"i",MAXBUF); + if (!(chan->binarymodes & CM_INVITEONLY)) strlcat(outlist,"i",MAXBUF); + chan->binarymodes |= CM_INVITEONLY; + } + else + { + if (chan->binarymodes & CM_INVITEONLY) strlcat(outlist,"i",MAXBUF); + chan->binarymodes &= ~CM_INVITEONLY; } - chan->inviteonly = mdir; } break; @@ -912,11 +917,16 @@ void process_modes(char **parameters,userrec* user,chanrec *chan,int status, int FOREACH_RESULT(OnRawMode(user, chan, 't', "", mdir, 0)); if (!MOD_RESULT) { - if (chan->topiclock != mdir) - { - strlcat(outlist,"t",MAXBUF); - } - chan->topiclock = mdir; + if (mdir) + { + if (!(chan->binarymodes & CM_TOPICLOCK)) strlcat(outlist,"t",MAXBUF); + chan->binarymodes |= CM_TOPICLOCK; + } + else + { + if (chan->binarymodes & CM_NOEXTERNAL) strlcat(outlist,"t",MAXBUF); + chan->binarymodes &= ~CM_TOPICLOCK; + } } break; @@ -925,11 +935,16 @@ void process_modes(char **parameters,userrec* user,chanrec *chan,int status, int FOREACH_RESULT(OnRawMode(user, chan, 'n', "", mdir, 0)); if (!MOD_RESULT) { - if (chan->noexternal != mdir) - { - strlcat(outlist,"n",MAXBUF); - } - chan->noexternal = mdir; + if (mdir) + { + if (!(chan->binarymodes & CM_NOEXTERNAL)) strlcat(outlist,"n",MAXBUF); + chan->binarymodes |= CM_NOEXTERNAL; + } + else + { + if (chan->binarymodes & CM_NOEXTERNAL) strlcat(outlist,"n",MAXBUF); + chan->binarymodes &= ~CM_NOEXTERNAL; + } } break; @@ -938,11 +953,16 @@ void process_modes(char **parameters,userrec* user,chanrec *chan,int status, int FOREACH_RESULT(OnRawMode(user, chan, 'm', "", mdir, 0)); if (!MOD_RESULT) { - if (chan->moderated != mdir) - { - strlcat(outlist,"m",MAXBUF); - } - chan->moderated = mdir; + if (mdir) + { + if (!(chan->binarymodes & CM_MODERATED)) strlcat(outlist,"m",MAXBUF); + chan->binarymodes |= CM_MODERATED; + } + else + { + if (chan->binarymodes & CM_MODERATED) strlcat(outlist,"m",MAXBUF); + chan->binarymodes &= ~CM_MODERATED; + } } break; @@ -951,23 +971,24 @@ void process_modes(char **parameters,userrec* user,chanrec *chan,int status, int FOREACH_RESULT(OnRawMode(user, chan, 's', "", mdir, 0)); if (!MOD_RESULT) { - if (chan->secret != mdir) - { - strcat(outlist,"s"); - if (chan->c_private) - { - chan->c_private = 0; - if (mdir) - { - strlcat(outlist,"-p+",MAXBUF); - } - else - { - strlcat(outlist,"+p-",MAXBUF); - } - } - } - chan->secret = mdir; + if (mdir) + { + if (!(chan->binarymodes & CM_SECRET)) strlcat(outlist,"s",MAXBUF); + chan->binarymodes |= CM_SECRET; + if (chan->binarymodes & CM_PRIVATE) + { + chan->binarymodes &= ~CM_PRIVATE; + if (mdir) + { + strlcat(outlist,"-p+",MAXBUF); + } + } + } + else + { + if (chan->binarymodes & CM_SECRET) strlcat(outlist,"s",MAXBUF); + chan->binarymodes &= ~CM_SECRET; + } } break; @@ -976,23 +997,24 @@ void process_modes(char **parameters,userrec* user,chanrec *chan,int status, int FOREACH_RESULT(OnRawMode(user, chan, 'p', "", mdir, 0)); if (!MOD_RESULT) { - if (chan->c_private != mdir) - { - strlcat(outlist,"p",MAXBUF); - if (chan->secret) - { - chan->secret = 0; - if (mdir) - { - strlcat(outlist,"-s+",MAXBUF); - } - else - { - strlcat(outlist,"+s-",MAXBUF); - } - } - } - chan->c_private = mdir; + if (mdir) + { + if (!(chan->binarymodes & CM_PRIVATE)) strlcat(outlist,"p",MAXBUF); + chan->binarymodes |= CM_PRIVATE; + if (chan->binarymodes & CM_SECRET) + { + chan->binarymodes &= ~CM_SECRET; + if (mdir) + { + strlcat(outlist,"-s+",MAXBUF); + } + } + } + else + { + if (chan->binarymodes & CM_PRIVATE) strlcat(outlist,"p",MAXBUF); + chan->binarymodes &= ~CM_PRIVATE; + } } break; diff --git a/src/modules/m_knock.cpp b/src/modules/m_knock.cpp index 649c210b8..e1654c181 100644 --- a/src/modules/m_knock.cpp +++ b/src/modules/m_knock.cpp @@ -40,7 +40,7 @@ void handle_knock(char **parameters, int pcnt, userrec *user) WriteServ(user->fd,"480 %s :Can't KNOCK on %s, +K is set.",user->nick, c->name); return; } - if (c->inviteonly) + if (c->binarymodes & CM_INVITEONLY) { WriteChannelWithServ((char*)Srv->GetServerName().c_str(),c,"NOTICE %s :User %s is KNOCKing on %s (%s)",c->name,user->nick,c->name,line.c_str()); WriteServ(user->fd,"NOTICE %s :KNOCKing on %s",user->nick,c->name); diff --git a/src/modules/m_override.cpp b/src/modules/m_override.cpp index 063e94b12..916acb36e 100644 --- a/src/modules/m_override.cpp +++ b/src/modules/m_override.cpp @@ -165,7 +165,7 @@ class ModuleOverride : public Module { if (chan) { - if ((chan->inviteonly) && (CanOverride(user,"INVITE"))) + if ((chan->binarymodes & CM_INVITEONLY) && (CanOverride(user,"INVITE"))) { if (NoisyOverride) { diff --git a/src/users.cpp b/src/users.cpp index 0060b45ee..7a8878106 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -36,7 +36,6 @@ userrec::userrec() strcpy(dhost,""); strcpy(fullname,""); strcpy(modes,""); - strcpy(inbuf,""); strcpy(server,""); strcpy(awaymsg,""); strcpy(oper,""); |