]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules.cpp
Correctly use iterators and pointer to ucrec
[user/henk/code/inspircd.git] / src / modules.cpp
index 7640f0edc2c7dcb7db624b6baf1701242b3723bc..9a420a25eb44b0bb1cc1afda51ebe47085fe7025 100644 (file)
@@ -50,7 +50,6 @@ using namespace std;
 #include "typedefs.h"
 #include "modules.h"
 #include "command_parse.h"
-#include "timer.h"
 
 extern ServerConfig *Config;
 extern InspIRCd* ServerInstance;
@@ -417,7 +416,7 @@ chanrec* Server::GetChannelIndex(long index)
 
 void Server::AddTimer(InspTimer* T)
 {
-       AddTimer(T);
+       ::AddTimer(T);
 }
 
 void Server::SendOpers(std::string s)
@@ -452,12 +451,9 @@ chanuserlist Server::GetUsers(chanrec* chan)
 {
        chanuserlist userl;
        userl.clear();
-       std::map<char*,char*> *list = chan->GetUsers();
-       for (std::map<char*,char*>::iterator i = list->begin(); i != list->end(); i++)
-       {
-               char* o = i->second;
-               userl.push_back((userrec*)o);
-       }
+       CUList *list = chan->GetUsers();
+       for (CUList::iterator i = list->begin(); i != list->end(); i++)
+               userl.push_back(i->second);
        return userl;
 }
 void Server::ChangeUserNick(userrec* user, std::string nickname)
@@ -487,9 +483,9 @@ bool Server::IsUlined(std::string server)
        return is_uline(server.c_str());
 }
 
-void Server::CallCommandHandler(std::string commandname, char** parameters, int pcnt, userrec* user)
+bool Server::CallCommandHandler(std::string commandname, char** parameters, int pcnt, userrec* user)
 {
-       ServerInstance->Parser->CallHandler(commandname,parameters,pcnt,user);
+       return ServerInstance->Parser->CallHandler(commandname,parameters,pcnt,user);
 }
 
 bool Server::IsValidModuleCommand(std::string commandname, int pcnt, userrec* user)
@@ -536,7 +532,7 @@ void Server::SendTo(userrec* Source, userrec* Dest, std::string s)
        if (!Source)
        {
                // if source is NULL, then the message originates from the local server
-               Write(Dest->fd,":%s %s",this->GetServerName().c_str(),s.c_str());
+               WriteServ_NoFormat(Dest->fd,s.c_str());
        }
        else
        {
@@ -567,6 +563,22 @@ bool Server::CommonChannels(userrec* u1, userrec* u2)
        return (common_channels(u1,u2) != 0);
 }
 
+void Server::DumpText(userrec* User, std::string LinePrefix, stringstream &TextStream)
+{
+       std::string CompleteLine = LinePrefix;
+       std::string Word = "";
+       while (TextStream >> Word)
+       {
+               if (CompleteLine.length() + Word.length() + 3 > 500)
+               {
+                       WriteServ_NoFormat(User->fd,CompleteLine.c_str());
+                       CompleteLine = LinePrefix;
+               }
+               CompleteLine = CompleteLine + Word + " ";
+       }
+       WriteServ_NoFormat(User->fd,CompleteLine.c_str());
+}
+
 void Server::SendCommon(userrec* User, std::string text,bool IncludeSender)
 {
        if (IncludeSender)
@@ -619,11 +631,6 @@ std::string Server::ChanMode(userrec* User, chanrec* Chan)
        return cmode(User,Chan);
 }
 
-bool Server::IsOnChannel(userrec* User, chanrec* Chan)
-{
-       return has_channel(User,Chan);
-}
-
 std::string Server::GetServerName()
 {
        return Config->ServerName;
@@ -733,13 +740,11 @@ bool Server::PseudoToUser(userrec* alive,userrec* zombie,std::string message)
        // Fix by brain - cant write the user until their fd table entry is updated
        fd_ref_table[zombie->fd] = zombie;
        Write(zombie->fd,":%s!%s@%s NICK %s",oldnick.c_str(),oldident.c_str(),oldhost.c_str(),zombie->nick);
-        for (unsigned int i = 0; i < zombie->chans.size(); i++)
+        for (std::vector<ucrec*>::const_iterator i = zombie->chans.begin(); i != zombie->chans.end(); i++)
         {
-                if (zombie->chans[i].channel != NULL)
+                if (((ucrec*)(*i))->channel != NULL)
                 {
-                        if (zombie->chans[i].channel->name)
-                        {
-                               chanrec* Ptr = zombie->chans[i].channel;
+                               chanrec* Ptr = ((ucrec*)(*i))->channel;
                                WriteFrom(zombie->fd,zombie,"JOIN %s",Ptr->name);
                                if (Ptr->topicset)
                                {
@@ -748,8 +753,6 @@ bool Server::PseudoToUser(userrec* alive,userrec* zombie,std::string message)
                                }
                                userlist(zombie,Ptr);
                                WriteServ(zombie->fd,"366 %s %s :End of /NAMES list.", zombie->nick, Ptr->name);
-
-                        }
                 }
         }
        if ((find(local_users.begin(),local_users.end(),zombie) == local_users.end()) && (zombie->fd != FD_MAGIC_NUMBER))