]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/mode.cpp
Remove a few unnecessary .c_str() calls
[user/henk/code/inspircd.git] / src / mode.cpp
index bdf0400b7eb41af6d7bb12b66c233712f16c1871..ad46e602de1e39390dd3304b785be9266e289c8b 100644 (file)
@@ -145,10 +145,12 @@ bool ParamChannelModeHandler::ParamValidate(std::string& parameter)
 ModeWatcher::ModeWatcher(Module* Creator, const std::string& modename, ModeType type)
        : mode(modename), m_type(type), creator(Creator)
 {
+       ServerInstance->Modes->AddModeWatcher(this);
 }
 
 ModeWatcher::~ModeWatcher()
 {
+       ServerInstance->Modes->DelModeWatcher(this);
 }
 
 ModeType ModeWatcher::GetModeType()
@@ -205,7 +207,12 @@ PrefixMode::PrefixMode(Module* Creator, const std::string& Name, char ModeLetter
 
 ModeAction PrefixMode::OnModeChange(User* source, User*, Channel* chan, std::string& parameter, bool adding)
 {
-       User* target = ServerInstance->FindNick(parameter);
+       User* target;
+       if (IS_LOCAL(source))
+               target = ServerInstance->FindNickOnly(parameter);
+       else
+               target = ServerInstance->FindNick(parameter);
+
        if (!target)
        {
                source->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameter.c_str());
@@ -345,9 +352,16 @@ ModeAction ModeParser::TryMode(User* user, User* targetuser, Channel* chan, bool
 
 void ModeParser::Process(const std::vector<std::string>& parameters, User* user, ModeProcessFlag flags)
 {
-       std::string target = parameters[0];
+       const std::string& target = parameters[0];
        Channel* targetchannel = ServerInstance->FindChan(target);
-       User* targetuser  = ServerInstance->FindNick(target);
+       User* targetuser = NULL;
+       if (!targetchannel)
+       {
+               if (IS_LOCAL(user))
+                       targetuser = ServerInstance->FindNickOnly(target);
+               else
+                       targetuser = ServerInstance->FindNick(target);
+       }
        ModeType type = targetchannel ? MODETYPE_CHANNEL : MODETYPE_USER;
 
        LastParse.clear();
@@ -370,7 +384,7 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User* user,
 
        bool SkipAccessChecks = false;
 
-       if (!IS_LOCAL(user) || ServerInstance->ULine(user->server) || MOD_RESULT == MOD_RES_ALLOW)
+       if (!IS_LOCAL(user) || MOD_RESULT == MOD_RES_ALLOW)
                SkipAccessChecks = true;
        else if (MOD_RESULT == MOD_RES_DENY)
                return;