summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/commands.cpp6
-rw-r--r--src/helperfuncs.cpp10
-rw-r--r--src/inspircd.cpp17
-rw-r--r--src/message.cpp14
-rw-r--r--src/mode.cpp12
-rw-r--r--src/modules.cpp2
-rw-r--r--src/modules/m_nonicks.cpp2
-rw-r--r--src/modules/m_park.cpp2
-rw-r--r--src/modules/m_spanningtree.cpp10
-rw-r--r--src/users.cpp7
10 files changed, 41 insertions, 41 deletions
diff --git a/src/commands.cpp b/src/commands.cpp
index 6b38e757a..6fe978514 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -958,7 +958,7 @@ void handle_who(char **parameters, int pcnt, userrec *user)
{
if ((!strcmp(parameters[0],"0")) || (!strcmp(parameters[0],"*")))
{
- if (user->chans[0].channel)
+ if ((user->chans.size()) (user->chans[0].channel))
{
int n_list = 0;
for (user_hash::const_iterator i = clientlist.begin(); i != clientlist.end(); i++)
@@ -1044,7 +1044,7 @@ void handle_who(char **parameters, int pcnt, userrec *user)
strlcat(tmp, "H" ,9);
}
if (strchr(u->modes,'o')) { strlcat(tmp, "*" ,9); }
- WriteServ(user->fd,"352 %s %s %s %s %s %s %s :0 %s",user->nick, u->chans[0].channel ? u->chans[0].channel->name
+ WriteServ(user->fd,"352 %s %s %s %s %s %s %s :0 %s",user->nick, u->chans.size() ? u->chans[0].channel->name
: "*", u->ident, u->dhost, u->server, u->nick, tmp, u->fullname);
}
WriteServ(user->fd,"315 %s %s :End of /WHO list.",user->nick, parameters[0]);
@@ -1065,7 +1065,7 @@ void handle_who(char **parameters, int pcnt, userrec *user)
} else {
strlcat(tmp, "H" ,9);
}
- WriteServ(user->fd,"352 %s %s %s %s %s %s %s* :0 %s", user->nick, oper->chans[0].channel ? oper->chans[0].channel->name
+ WriteServ(user->fd,"352 %s %s %s %s %s %s %s* :0 %s", user->nick, oper->chans.size() ? oper->chans[0].channel->name
: "*", oper->ident, oper->dhost, oper->server, oper->nick, tmp, oper->fullname);
}
WriteServ(user->fd,"315 %s %s :End of /WHO list.",user->nick, parameters[0]);
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index 479e20e24..bbf224883 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -416,7 +416,7 @@ void WriteCommon(userrec *u, char* text, ...)
bool sent_to_at_least_one = false;
- for (int i = 0; i < MAXCHANS; i++)
+ for (int i = 0; i < u->chans.size(); i++)
{
if (u->chans[i].channel)
{
@@ -466,7 +466,7 @@ void WriteCommonExcept(userrec *u, char* text, ...)
memset(&already_sent,0,65536);
- for (int i = 0; i < MAXCHANS; i++)
+ for (int i = 0; i < u->chans.size(); i++)
{
if (u->chans[i].channel)
{
@@ -607,7 +607,7 @@ bool CommonOnThisServer(userrec* u,const char* servername)
{
log(DEBUG,"ChanAnyOnThisServer");
- for (int i = 0; i < MAXCHANS; i++)
+ for (int i = 0; i < u->chans[i].size(); i++)
{
if (u->chans[i].channel)
{
@@ -803,7 +803,7 @@ void purge_empty_chans(userrec* u)
int go_again = 1, purge = 0;
// firstly decrement the count on each channel
- for (int f = 0; f < MAXCHANS; f++)
+ for (int f = 0; f < u->chans.size(); f++)
{
if (u->chans[f].channel)
{
@@ -811,7 +811,7 @@ void purge_empty_chans(userrec* u)
}
}
- for (int i = 0; i < MAXCHANS; i++)
+ for (int i = 0; i < u->chans.size(); i++)
{
if (u->chans[i].channel)
{
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 744a5ece9..3a7695fd2 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -716,7 +716,7 @@ chanrec* add_channel(userrec *user, const char* cn, const char* key, bool overri
log(DEBUG,"Passed channel checks");
- for (int index =0; index != MAXCHANS; index++)
+ for (int index =0; index < user->chans.size(); index++)
{
log(DEBUG,"Check location %d",index);
if (user->chans[index].channel == NULL)
@@ -751,6 +751,9 @@ chanrec* add_channel(userrec *user, const char* cn, const char* key, bool overri
return Ptr;
}
}
+ /* XXX: If the user is an oper here, we can just extend their user->chans vector by one
+ * and put the channel in here. Otherwise, nope, youre boned.
+ */
log(DEBUG,"add_channel: user channel max exceeded: %s %s",user->nick,cname);
WriteServ(user->fd,"405 %s %s :You are on too many channels",user->nick, cname);
return NULL;
@@ -784,7 +787,7 @@ chanrec* del_channel(userrec *user, const char* cname, const char* reason, bool
FOREACH_MOD OnUserPart(user,Ptr);
log(DEBUG,"del_channel: removing: %s %s",user->nick,Ptr->name);
- for (int i =0; i != MAXCHANS; i++)
+ for (int i =0; i < user->chans.size(); i++)
{
/* zap it from the channel list of the user */
if (user->chans[i].channel == Ptr)
@@ -879,7 +882,7 @@ void kick_channel(userrec *src,userrec *user, chanrec *Ptr, char* reason)
FOREACH_MOD OnUserKick(src,user,Ptr,reason);
- for (int i =0; i != MAXCHANS; i++)
+ for (int i =0; i < user->chans.size(); i++)
{
/* zap it from the channel list of the user */
if (user->chans[i].channel)
@@ -1443,11 +1446,11 @@ void AddClient(int socket, char* host, int port, bool iscached, char* ip)
clientlist[tempnick]->sendqmax = class_sqmax;
clientlist[tempnick]->recvqmax = class_rqmax;
+ ucrec a;
+ a.channel = NULL;
+ a.uc_modes = 0;
for (int i = 0; i < MAXCHANS; i++)
- {
- clientlist[tempnick]->chans[i].channel = NULL;
- clientlist[tempnick]->chans[i].uc_modes = 0;
- }
+ clientlist[tempnick]->chans.push_back(a);
if (clientlist.size() > SoftLimit)
{
diff --git a/src/message.cpp b/src/message.cpp
index 2f527c983..bb49d48ca 100644
--- a/src/message.cpp
+++ b/src/message.cpp
@@ -68,9 +68,9 @@ int common_channels(userrec *u, userrec *u2)
log(DEFAULT,"*** BUG *** common_channels was given an invalid parameter");
return 0;
}
- for (int i = 0; i != MAXCHANS; i++)
+ for (int i = 0; i < u->chans.size(); i++)
{
- for (int z = 0; z != MAXCHANS; z++)
+ for (int z = 0; z != u2->chans.size(); z++)
{
if ((u->chans[i].channel != NULL) && (u2->chans[z].channel != NULL))
{
@@ -193,7 +193,7 @@ int CleanAndResolve (char *resolvedHost, const char *unresolvedHost)
int c_count(userrec* u)
{
int z = 0;
- for (int i =0; i != MAXCHANS; i++)
+ for (int i =0; i < u->chans.size(); i++)
if (u->chans[i].channel != NULL)
z++;
return z;
@@ -311,7 +311,7 @@ char* cmode(userrec *user, chanrec *chan)
return "";
}
- for (int i = 0; i != MAXCHANS; i++)
+ for (int i = 0; i < user->chans.size(); i++)
{
if (user->chans[i].channel)
{
@@ -351,7 +351,7 @@ int cstatus(userrec *user, chanrec *chan)
if (is_uline(user->server))
return STATUS_OP;
- for (int i = 0; i != MAXCHANS; i++)
+ for (int i = 0; i < user->chans.size(); i++)
{
if (user->chans[i].channel)
{
@@ -385,7 +385,7 @@ int has_channel(userrec *u, chanrec *c)
log(DEFAULT,"*** BUG *** has_channel was given an invalid parameter");
return 0;
}
- for (int i =0; i != MAXCHANS; i++)
+ for (int i =0; i < u->chans.size(); i++)
{
if (u->chans[i].channel)
{
@@ -436,7 +436,7 @@ char* chlist(userrec *user,userrec* source)
{
return lst;
}
- for (int i = 0; i != MAXCHANS; i++)
+ for (int i = 0; i < user->chans.size(); i++)
{
if (user->chans[i].channel != NULL)
{
diff --git a/src/mode.cpp b/src/mode.cpp
index e9b6861c0..82e38e355 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -115,7 +115,7 @@ char* give_ops(userrec *user,char *dest,chanrec *chan,int status)
}
- for (unsigned int i = 0; i != MAXCHANS; i++)
+ for (unsigned int i = 0; i < d->chans.size(); i++)
{
if ((d->chans[i].channel != NULL) && (chan != NULL))
if (!strcasecmp(d->chans[i].channel->name,chan->name))
@@ -173,7 +173,7 @@ char* give_hops(userrec *user,char *dest,chanrec *chan,int status)
}
}
- for (unsigned int i = 0; i != MAXCHANS; i++)
+ for (unsigned int i = 0; i < d->chans.size(); i++)
{
if ((d->chans[i].channel != NULL) && (chan != NULL))
if (!strcasecmp(d->chans[i].channel->name,chan->name))
@@ -229,7 +229,7 @@ char* give_voice(userrec *user,char *dest,chanrec *chan,int status)
}
}
- for (unsigned int i = 0; i != MAXCHANS; i++)
+ for (unsigned int i = 0; i < d->chans.size(); i++)
{
if ((d->chans[i].channel != NULL) && (chan != NULL))
if (!strcasecmp(d->chans[i].channel->name,chan->name))
@@ -287,7 +287,7 @@ char* take_ops(userrec *user,char *dest,chanrec *chan,int status)
}
}
- for (unsigned int i = 0; i != MAXCHANS; i++)
+ for (unsigned int i = 0; i < d->chans.size(); i++)
{
if ((d->chans[i].channel != NULL) && (chan != NULL))
if (!strcasecmp(d->chans[i].channel->name,chan->name))
@@ -344,7 +344,7 @@ char* take_hops(userrec *user,char *dest,chanrec *chan,int status)
}
}
- for (unsigned int i = 0; i != MAXCHANS; i++)
+ for (unsigned int i = 0; i < d->chans.size(); i++)
{
if ((d->chans[i].channel != NULL) && (chan != NULL))
if (!strcasecmp(d->chans[i].channel->name,chan->name))
@@ -400,7 +400,7 @@ char* take_voice(userrec *user,char *dest,chanrec *chan,int status)
}
}
- for (unsigned int i = 0; i != MAXCHANS; i++)
+ for (unsigned int i = 0; i < d->chans.size(); i++)
{
if ((d->chans[i].channel != NULL) && (chan != NULL))
if (!strcasecmp(d->chans[i].channel->name,chan->name))
diff --git a/src/modules.cpp b/src/modules.cpp
index af8e2cbb6..f5728acde 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -675,7 +675,7 @@ bool Server::PseudoToUser(userrec* alive,userrec* zombie,std::string message)
Write(zombie->fd,":%s!%s@%s NICK %s",alive->nick,alive->ident,alive->host,zombie->nick);
kill_link(alive,message.c_str());
fd_ref_table[zombie->fd] = zombie;
- for (int i = 0; i != MAXCHANS; i++)
+ for (int i = 0; i < zombie->chans.size(); i++)
{
if (zombie->chans[i].channel != NULL)
{
diff --git a/src/modules/m_nonicks.cpp b/src/modules/m_nonicks.cpp
index 6c0a0163d..c2b18b49b 100644
--- a/src/modules/m_nonicks.cpp
+++ b/src/modules/m_nonicks.cpp
@@ -73,7 +73,7 @@ class ModuleNoNickChange : public Module
irc::string me = Srv->GetServerName().c_str();
if (server == me)
{
- for (int i =0; i != MAXCHANS; i++)
+ for (int i =0; i < user->chans.size(); i++)
{
if (user->chans[i].channel != NULL)
{
diff --git a/src/modules/m_park.cpp b/src/modules/m_park.cpp
index 716c91579..6a640f318 100644
--- a/src/modules/m_park.cpp
+++ b/src/modules/m_park.cpp
@@ -125,7 +125,7 @@ void handle_unpark(char **parameters, int pcnt, userrec *user)
if (key == atoi(parameters[1]))
{
// first part the user from all chans theyre on, so things dont get messy
- for (int i = 0; i != MAXCHANS; i++)
+ for (int i = 0; i < user->chans.size(); i++)
{
if (user->chans[i].channel != NULL)
{
diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp
index 8b8b28092..200ab1dfc 100644
--- a/src/modules/m_spanningtree.cpp
+++ b/src/modules/m_spanningtree.cpp
@@ -938,11 +938,13 @@ class TreeSocket : public InspSocket
clientlist[tempnick]->signon = age;
strlcpy(clientlist[tempnick]->modes, modes.c_str(),53);
strlcpy(clientlist[tempnick]->ip,ip.c_str(),16);
+
+ ucrec a;
+ a.channel = NULL;
+ a.uc_modes = 0;
for (int i = 0; i < MAXCHANS; i++)
- {
- clientlist[tempnick]->chans[i].channel = NULL;
- clientlist[tempnick]->chans[i].uc_modes = 0;
- }
+ clientlist[tempnick]->chans.push_back(a);
+
if (!this->bursting)
{
WriteOpers("*** Client connecting at %s: %s!%s@%s [%s]",clientlist[tempnick]->server,clientlist[tempnick]->nick,clientlist[tempnick]->ident,clientlist[tempnick]->host,clientlist[tempnick]->ip);
diff --git a/src/users.cpp b/src/users.cpp
index 1920e8dcd..46bf70744 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -57,11 +57,7 @@ userrec::userrec()
dns_done = false;
recvq = "";
sendq = "";
- for (int i = 0; i < MAXCHANS; i++)
- {
- this->chans[i].channel = NULL;
- this->chans[i].uc_modes = 0;
- }
+ chans.clear();
invites.clear();
}
@@ -86,7 +82,6 @@ int userrec::ReadData(void* buffer, size_t size)
{
if (this->fd > -1)
{
- log(DEBUG,"userrec::ReadData on fd %d",this->fd);
return read(this->fd, buffer, size);
}
else return 0;