]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_chghost.cpp
So much stuff changed in this one, i forgot most of it.
[user/henk/code/inspircd.git] / src / modules / m_chghost.cpp
index 1a547f54883bce59db5bf3f3cf0511cf39f01dce..fc5507822eb927bf7298ff01c0f921b93bc860a9 100644 (file)
@@ -22,10 +22,12 @@ using namespace std;
 #include "channels.h"
 #include "modules.h"
 #include "helperfuncs.h"
+#include "inspircd.h"
 
 /* $ModDesc: Provides support for the CHGHOST command */
 
 static Server *Srv;
+extern InspIRCd* ServerInstance;
 
 class cmd_chghost : public command_t
 {
@@ -33,11 +35,12 @@ class cmd_chghost : public command_t
        cmd_chghost () : command_t("CHGHOST",'o',2)
        {
                this->source = "m_chghost.so";
+               syntax = "<nick> <newhost>";
        }
         
-       void Handle(char **parameters, int pcnt, userrec *user)
+       void Handle(const char** parameters, int pcnt, userrec *user)
        {
-               char * x = parameters[1];
+               const char * x = parameters[1];
 
                for (; *x; x++)
                {
@@ -45,24 +48,23 @@ class cmd_chghost : public command_t
                        {
                                if (((*x < '0') || (*x > '9')) && (*x != '-'))
                                {
-                                       Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+" :*** Invalid characters in hostname");
+                                       user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Invalid characters in hostname");
                                        return;
                                }
                        }
                }
                if ((parameters[1] - x) > 63)
                {
-                       WriteServ(user->fd,"NOTICE %s :*** CHGHOST: Host too long",user->nick);
+                       user->WriteServ("NOTICE %s :*** CHGHOST: Host too long",user->nick);
                        return;
                }
-               userrec* dest = Srv->FindNick(std::string(parameters[0]));
+               userrec* dest = ServerInstance->FindNick(parameters[0]);
                if (dest)
                {
-                       Srv->ChangeHost(dest,parameters[1]);
-                       if (!Srv->IsUlined(user->server))
+                       if ((dest->ChangeDisplayedHost(parameters[1])) && (!Srv->IsUlined(user->server)))
                        {
                                // fix by brain - ulines set hosts silently
-                               Srv->SendOpers(std::string(user->nick)+" used CHGHOST to make the displayed host of "+std::string(dest->nick)+" become "+std::string(parameters[1]));
+                               ServerInstance->WriteOpers(std::string(user->nick)+" used CHGHOST to make the displayed host of "+dest->nick+" become "+parameters[1]);
                        }
                }
        }