]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modes/cmode_k.cpp
Fix user->host not being assigned correctly for new connections
[user/henk/code/inspircd.git] / src / modes / cmode_k.cpp
index 0ab35b954bcd2fb4ebc34159048fd61422b0fbc5..4d4453d4497b79161dec6aeaa04dce9269eb9c62 100644 (file)
@@ -63,31 +63,31 @@ bool ModeChannelKey::CheckTimeStamp(time_t, time_t, const std::string &their_par
 
 ModeAction ModeChannelKey::OnModeChange(User* source, User*, Channel* channel, std::string &parameter, bool adding, bool servermode)
 {
-       if ((channel->modes[CM_KEY] != adding) || (!IS_LOCAL(source)))
+       if ((channel->IsModeSet('k') != adding) || (!IS_LOCAL(source)))
        {
-               if (((channel->modes[CM_KEY]) && (strcasecmp(parameter.c_str(),channel->key))) && (IS_LOCAL(source)))
+               if (((channel->IsModeSet('k')) && (parameter != channel->key)) && (IS_LOCAL(source)))
                {
                        /* Key is currently set and the correct key wasnt given */
                        return MODEACTION_DENY;
                }
-               else if ((!channel->modes[CM_KEY]) || ((adding) && (!IS_LOCAL(source))))
+               else if ((!channel->IsModeSet('k')) || ((adding) && (!IS_LOCAL(source))))
                {
                        /* Key isnt currently set */
                        if ((parameter.length()) && (parameter.rfind(' ') == std::string::npos))
                        {
-                               strlcpy(channel->key,parameter.c_str(),32);
-                               channel->modes[CM_KEY] = adding;
+                               channel->key.assign(parameter, 0, 32);
+                               channel->SetMode('k', adding);
                                parameter = channel->key;
                                return MODEACTION_ALLOW;
                        }
                        else
                                return MODEACTION_DENY;
                }
-               else if (((channel->modes[CM_KEY]) && (!strcasecmp(parameter.c_str(),channel->key))) || ((!adding) && (!IS_LOCAL(source))))
+               else if (((channel->IsModeSet('k')) && (parameter == channel->key)) || ((!adding) && (!IS_LOCAL(source))))
                {
                        /* Key is currently set, and correct key was given */
-                       *channel->key = 0;
-                       channel->modes[CM_KEY] = adding;
+                       channel->key.clear();
+                       channel->SetMode('k', adding);
                        return MODEACTION_ALLOW;
                }
                return MODEACTION_DENY;