X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fchannels.cpp;h=f067646d3358656ff94647e8846d1bf2ee7058e5;hb=0a58b25ad736e7cec4944eb89e10f617d74225a0;hp=19cf14d550a8de4fb8ee417332fb64007f28ba0d;hpb=3816f3dd12c47cf7dfb241eaa98db6a555749893;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/channels.cpp b/src/channels.cpp index 19cf14d55..f067646d3 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -173,7 +173,61 @@ void chanrec::DelUser(char* castuser) internal_userlist.erase(a); return; } - log(DEBUG,"BUG BUG BUG! Attempt to remove an uncasted user from the internal list of %s!",name); + /* Tidy up any others */ + DelOppedUser(castuser); + DelHalfoppedUser(castuser); + DelVoicedUser(castuser); +} + +void chanrec::AddOppedUser(char* castuser) +{ + internal_op_userlist[castuser] = castuser; + log(DEBUG,"Added casted user to channel's internal list"); +} + +void chanrec::DelOppedUser(char* castuser) +{ + std::map::iterator a = internal_op_userlist.find(castuser); + if (a != internal_op_userlist.end()) + { + log(DEBUG,"Removed casted user from channel's internal list"); + internal_op_userlist.erase(a); + return; + } +} + +void chanrec::AddHalfoppedUser(char* castuser) +{ + internal_halfop_userlist[castuser] = castuser; + log(DEBUG,"Added casted user to channel's internal list"); +} + +void chanrec::DelHalfoppedUser(char* castuser) +{ + std::map::iterator a = internal_halfop_userlist.find(castuser); + if (a != internal_halfop_userlist.end()) + { + log(DEBUG,"Removed casted user from channel's internal list"); + internal_halfop_userlist.erase(a); + return; + } +} + +void chanrec::AddVoicedUser(char* castuser) +{ + internal_voice_userlist[castuser] = castuser; + log(DEBUG,"Added casted user to channel's internal list"); +} + +void chanrec::DelVoicedUser(char* castuser) +{ + std::map::iterator a = internal_voice_userlist.find(castuser); + if (a != internal_voice_userlist.end()) + { + log(DEBUG,"Removed casted user from channel's internal list"); + internal_voice_userlist.erase(a); + return; + } } std::map *chanrec::GetUsers() @@ -181,6 +235,21 @@ std::map *chanrec::GetUsers() return &internal_userlist; } +std::map *chanrec::GetOppedUsers() +{ + return &internal_op_userlist; +} + +std::map *chanrec::GetHalfoppedUsers() +{ + return &internal_halfop_userlist; +} + +std::map *chanrec::GetVoicedUsers() +{ + return &internal_voice_userlist; +} + /* add a channel to a user, creating the record for it if needed and linking * it to the user record */ @@ -369,6 +438,7 @@ chanrec* ForceChan(chanrec* Ptr,ucrec &a,userrec* user, int created) { /* first user in is given ops */ a.uc_modes = UCMODE_OP; + Ptr->AddOppedUser((char*)user); } else { @@ -458,12 +528,15 @@ void server_kick_channel(userrec* user, chanrec* Ptr, char* reason, bool trigger return; } - if (!has_channel(user,Ptr)) + if (IS_LOCAL(user)) { - /* Not on channel */ - return; + if (!has_channel(user,Ptr)) + { + /* Not on channel */ + return; + } } - + if (triggerevents) { FOREACH_MOD(I_OnUserKick,OnUserKick(NULL,user,Ptr,reason)); @@ -508,41 +581,42 @@ void kick_channel(userrec *src,userrec *user, chanrec *Ptr, char* reason) log(DEBUG,"kick_channel: removing: %s %s %s",user->nick,Ptr->name,src->nick); - if (!has_channel(user,Ptr)) - { - WriteServ(src->fd,"441 %s %s %s :They are not on that channel",src->nick, user->nick, Ptr->name); - return; - } - - int MOD_RESULT = 0; - FOREACH_RESULT(I_OnAccessCheck,OnAccessCheck(src,user,Ptr,AC_KICK)); - if ((MOD_RESULT == ACR_DENY) && (!is_uline(src->server))) - return; - - if ((MOD_RESULT == ACR_DEFAULT) || (!is_uline(src->server))) - { - if ((cstatus(src,Ptr) < STATUS_HOP) || (cstatus(src,Ptr) < cstatus(user,Ptr))) - { - if (cstatus(src,Ptr) == STATUS_HOP) - { - WriteServ(src->fd,"482 %s %s :You must be a channel operator",src->nick, Ptr->name); - } - else - { - WriteServ(src->fd,"482 %s %s :You must be at least a half-operator to change modes on this channel",src->nick, Ptr->name); - } - - return; - } - } - - if (!is_uline(src->server)) - { - MOD_RESULT = 0; - FOREACH_RESULT(I_OnUserPreKick,OnUserPreKick(src,user,Ptr,reason)); - if (MOD_RESULT) - return; - } + if (IS_LOCAL(user)) + { + if (!has_channel(user,Ptr)) + { + WriteServ(src->fd,"441 %s %s %s :They are not on that channel",src->nick, user->nick, Ptr->name); + return; + } + int MOD_RESULT = 0; + FOREACH_RESULT(I_OnAccessCheck,OnAccessCheck(src,user,Ptr,AC_KICK)); + if ((MOD_RESULT == ACR_DENY) && (!is_uline(src->server))) + return; + + if ((MOD_RESULT == ACR_DEFAULT) || (!is_uline(src->server))) + { + if ((cstatus(src,Ptr) < STATUS_HOP) || (cstatus(src,Ptr) < cstatus(user,Ptr))) + { + if (cstatus(src,Ptr) == STATUS_HOP) + { + WriteServ(src->fd,"482 %s %s :You must be a channel operator",src->nick, Ptr->name); + } + else + { + WriteServ(src->fd,"482 %s %s :You must be at least a half-operator to change modes on this channel",src->nick, Ptr->name); + } + + return; + } + } + if (!is_uline(src->server)) + { + MOD_RESULT = 0; + FOREACH_RESULT(I_OnUserPreKick,OnUserPreKick(src,user,Ptr,reason)); + if (MOD_RESULT) + return; + } + } FOREACH_MOD(I_OnUserKick,OnUserKick(src,user,Ptr,reason));