summaryrefslogtreecommitdiff
path: root/src/helperfuncs.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-03-09 12:23:04 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-03-09 12:23:04 +0000
commit98fd8145d87a16a8bca10102f42fe0de954af967 (patch)
treee07aa92eeb6ef0eebaff010173118e1e0c26651f /src/helperfuncs.cpp
parent2dfc364baceefedf21a8eae766e615fc8d497d6e (diff)
Fixed to correctly use iterator
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3583 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/helperfuncs.cpp')
-rw-r--r--src/helperfuncs.cpp45
1 files changed, 18 insertions, 27 deletions
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index f728516f9..27bc22007 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -715,7 +715,6 @@ void WriteCommon(userrec *u, char* text, ...)
char textbuffer[MAXBUF];
va_list argsPtr;
bool sent_to_at_least_one = false;
- unsigned int y;
if (!u)
{
@@ -735,13 +734,12 @@ void WriteCommon(userrec *u, char* text, ...)
// FIX: Stops a message going to the same person more than once
memset(&already_sent,0,MAX_DESCRIPTORS);
- y = u->chans.size();
- for (unsigned int i = 0; i < y; i++)
+ for (std::vector<ucrec*>::const_iterator v = u->chans.begin(); v != u->chans.end(); v++)
{
- if (u->chans[i].channel)
+ if (((ucrec*)(*v))->channel)
{
- CUList *ulist= u->chans[i].channel->GetUsers();
+ CUList *ulist= ((ucrec*)(*v))->channel->GetUsers();
for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
{
@@ -768,7 +766,6 @@ void WriteCommon(userrec *u, char* text, ...)
void WriteCommon_NoFormat(userrec *u, const char* text)
{
bool sent_to_at_least_one = false;
- unsigned int y;
if (!u)
{
@@ -784,13 +781,12 @@ void WriteCommon_NoFormat(userrec *u, const char* text)
// FIX: Stops a message going to the same person more than once
memset(&already_sent,0,MAX_DESCRIPTORS);
- y = u->chans.size();
- for (unsigned int i = 0; i < y; i++)
+ for (std::vector<ucrec*>::const_iterator v = u->chans.begin(); v != u->chans.end(); v++)
{
- if (u->chans[i].channel)
+ if (((ucrec*)(*v))->channel)
{
- CUList *ulist= u->chans[i].channel->GetUsers();
+ CUList *ulist= ((ucrec*)(*v))->channel->GetUsers();
for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
{
@@ -826,7 +822,6 @@ void WriteCommonExcept(userrec *u, char* text, ...)
bool quit_munge = false;
va_list argsPtr;
int total;
- unsigned int y;
if (!u)
{
@@ -886,13 +881,12 @@ void WriteCommonExcept(userrec *u, char* text, ...)
}
memset(&already_sent,0,MAX_DESCRIPTORS);
- y = u->chans.size();
- for (unsigned int i = 0; i < y; i++)
+ for (std::vector<ucrec*>::const_iterator v = u->chans.begin(); v != u->chans.end(); v++)
{
- if (u->chans[i].channel)
+ if (((ucrec*)(*v))->channel)
{
- CUList *ulist= u->chans[i].channel->GetUsers();
+ CUList *ulist= ((ucrec*)(*v))->channel->GetUsers();
for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
{
@@ -917,8 +911,6 @@ void WriteCommonExcept(userrec *u, char* text, ...)
void WriteCommonExcept_NoFormat(userrec *u, const char* text)
{
- unsigned int y;
-
if (!u)
{
log(DEFAULT,"*** BUG *** WriteCommon was given an invalid parameter");
@@ -932,13 +924,12 @@ void WriteCommonExcept_NoFormat(userrec *u, const char* text)
}
memset(&already_sent,0,MAX_DESCRIPTORS);
- y = u->chans.size();
- for (unsigned int i = 0; i < y; i++)
+ for (std::vector<ucrec*>::const_iterator v = u->chans.begin(); v != u->chans.end(); v++)
{
- if (u->chans[i].channel)
+ if (((ucrec*)(*v))->channel)
{
- CUList *ulist= u->chans[i].channel->GetUsers();
+ CUList *ulist= ((ucrec*)(*v))->channel->GetUsers();
for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
{
@@ -1218,24 +1209,24 @@ long GetMaxBans(char* name)
void purge_empty_chans(userrec* u)
{
- int purge = 0;
std::vector<chanrec*> to_delete;
// firstly decrement the count on each channel
for (std::vector<ucrec*>::iterator f = u->chans.begin(); f != u->chans.end(); f++)
{
- ucrec* (ucrec*)*f;
- if (f->channel)
+ if (((ucrec*)(*f))->channel)
{
- if (f->channel->DelUser(u) == 0)
+ if (((ucrec*)(*f))->channel->DelUser(u) == 0)
{
/* No users left in here, mark it for deletion */
- to_delete.push_back(f->channel);
- f->channel = NULL;
+ to_delete.push_back(((ucrec*)(*f))->channel);
+ ((ucrec*)(*f))->channel = NULL;
}
}
}
+ log(DEBUG,"purge_empty_chans: %d channels to delete",to_delete.size());
+
for (std::vector<chanrec*>::iterator n = to_delete.begin(); n != to_delete.end(); n++)
{
chanrec* thischan = (chanrec*)*n;