mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-10 02:59:01 -04:00
Got rid of all that ugly char* cast crap (todo: change docs to reflect change)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3556 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
parent
b2f5fc1e32
commit
21cf60233c
@ -86,6 +86,12 @@ typedef std::vector<ExemptItem> ExemptList;
|
||||
*/
|
||||
typedef std::vector<InviteItem> InviteList;
|
||||
|
||||
class userrec;
|
||||
|
||||
/** A list of users on a channel
|
||||
*/
|
||||
typedef std::map<userrec*,userrec*> CUList;
|
||||
|
||||
/** Holds all relevent information for a channel.
|
||||
* This class represents a channel, and contains its name, modes, time created, topic, topic set time,
|
||||
* etc, and an instance of the BanList type.
|
||||
@ -104,10 +110,10 @@ class chanrec : public Extensible
|
||||
/** User list (casted to char*'s to stop forward declaration stuff)
|
||||
* (chicken and egg scenario!)
|
||||
*/
|
||||
std::map<char*,char*> internal_userlist;
|
||||
std::map<char*,char*> internal_op_userlist;
|
||||
std::map<char*,char*> internal_halfop_userlist;
|
||||
std::map<char*,char*> internal_voice_userlist;
|
||||
CUList internal_userlist;
|
||||
CUList internal_op_userlist;
|
||||
CUList internal_halfop_userlist;
|
||||
CUList internal_voice_userlist;
|
||||
|
||||
/** Parameters for custom modes
|
||||
*/
|
||||
@ -194,10 +200,10 @@ class chanrec : public Extensible
|
||||
* an arbitary pointer compared to other users by its memory address,
|
||||
* as this is a very fast 32 or 64 bit integer comparison.
|
||||
*/
|
||||
void AddUser(char* castuser);
|
||||
void AddOppedUser(char* castuser);
|
||||
void AddHalfoppedUser(char* castuser);
|
||||
void AddVoicedUser(char* castuser);
|
||||
void AddUser(userrec* castuser);
|
||||
void AddOppedUser(userrec* castuser);
|
||||
void AddHalfoppedUser(userrec* castuser);
|
||||
void AddVoicedUser(userrec* castuser);
|
||||
|
||||
/** Delete a user pointer to the internal reference list
|
||||
* @param castuser This should be a pointer to a userrec, casted to char*
|
||||
@ -206,10 +212,10 @@ class chanrec : public Extensible
|
||||
* an arbitary pointer compared to other users by its memory address,
|
||||
* as this is a very fast 32 or 64 bit integer comparison.
|
||||
*/
|
||||
void DelUser(char* castuser);
|
||||
void DelOppedUser(char* castuser);
|
||||
void DelHalfoppedUser(char* castuser);
|
||||
void DelVoicedUser(char* castuser);
|
||||
void DelUser(userrec* castuser);
|
||||
void DelOppedUser(userrec* castuser);
|
||||
void DelHalfoppedUser(userrec* castuser);
|
||||
void DelVoicedUser(userrec* castuser);
|
||||
|
||||
/** Obrain the internal reference list
|
||||
* The internal reference list contains a list of userrec*
|
||||
@ -220,10 +226,10 @@ class chanrec : public Extensible
|
||||
*
|
||||
* @return This function returns a vector of userrec pointers, each of which has been casted to char* to prevent circular references
|
||||
*/
|
||||
std::map<char*,char*> *GetUsers();
|
||||
std::map<char*,char*> *GetOppedUsers();
|
||||
std::map<char*,char*> *GetHalfoppedUsers();
|
||||
std::map<char*,char*> *GetVoicedUsers();
|
||||
CUList *GetUsers();
|
||||
CUList *GetOppedUsers();
|
||||
CUList *GetHalfoppedUsers();
|
||||
CUList *GetVoicedUsers();
|
||||
|
||||
/** Creates a channel record and initialises it with default values
|
||||
*/
|
||||
|
@ -128,15 +128,15 @@ long chanrec::GetUserCounter()
|
||||
return (this->internal_userlist.size());
|
||||
}
|
||||
|
||||
void chanrec::AddUser(char* castuser)
|
||||
void chanrec::AddUser(userrec* castuser)
|
||||
{
|
||||
internal_userlist[castuser] = castuser;
|
||||
log(DEBUG,"Added casted user to channel's internal list");
|
||||
}
|
||||
|
||||
void chanrec::DelUser(char* castuser)
|
||||
void chanrec::DelUser(userrec* castuser)
|
||||
{
|
||||
std::map<char*,char*>::iterator a = internal_userlist.find(castuser);
|
||||
CUList::iterator a = internal_userlist.find(castuser);
|
||||
if (a != internal_userlist.end())
|
||||
{
|
||||
log(DEBUG,"Removed casted user from channel's internal list");
|
||||
@ -149,15 +149,15 @@ void chanrec::DelUser(char* castuser)
|
||||
}
|
||||
}
|
||||
|
||||
void chanrec::AddOppedUser(char* castuser)
|
||||
void chanrec::AddOppedUser(userrec* castuser)
|
||||
{
|
||||
internal_op_userlist[castuser] = castuser;
|
||||
log(DEBUG,"Added casted user to channel's internal list");
|
||||
}
|
||||
|
||||
void chanrec::DelOppedUser(char* castuser)
|
||||
void chanrec::DelOppedUser(userrec* castuser)
|
||||
{
|
||||
std::map<char*,char*>::iterator a = internal_op_userlist.find(castuser);
|
||||
CUList::iterator a = internal_op_userlist.find(castuser);
|
||||
if (a != internal_op_userlist.end())
|
||||
{
|
||||
log(DEBUG,"Removed casted user from channel's internal list");
|
||||
@ -166,15 +166,15 @@ void chanrec::DelOppedUser(char* castuser)
|
||||
}
|
||||
}
|
||||
|
||||
void chanrec::AddHalfoppedUser(char* castuser)
|
||||
void chanrec::AddHalfoppedUser(userrec* castuser)
|
||||
{
|
||||
internal_halfop_userlist[castuser] = castuser;
|
||||
log(DEBUG,"Added casted user to channel's internal list");
|
||||
}
|
||||
|
||||
void chanrec::DelHalfoppedUser(char* castuser)
|
||||
void chanrec::DelHalfoppedUser(userrec* castuser)
|
||||
{
|
||||
std::map<char*,char*>::iterator a = internal_halfop_userlist.find(castuser);
|
||||
CUList::iterator a = internal_halfop_userlist.find(castuser);
|
||||
if (a != internal_halfop_userlist.end())
|
||||
{
|
||||
log(DEBUG,"Removed casted user from channel's internal list");
|
||||
@ -183,15 +183,15 @@ void chanrec::DelHalfoppedUser(char* castuser)
|
||||
}
|
||||
}
|
||||
|
||||
void chanrec::AddVoicedUser(char* castuser)
|
||||
void chanrec::AddVoicedUser(userrec* castuser)
|
||||
{
|
||||
internal_voice_userlist[castuser] = castuser;
|
||||
log(DEBUG,"Added casted user to channel's internal list");
|
||||
}
|
||||
|
||||
void chanrec::DelVoicedUser(char* castuser)
|
||||
void chanrec::DelVoicedUser(userrec* castuser)
|
||||
{
|
||||
std::map<char*,char*>::iterator a = internal_voice_userlist.find(castuser);
|
||||
CUList::iterator a = internal_voice_userlist.find(castuser);
|
||||
if (a != internal_voice_userlist.end())
|
||||
{
|
||||
log(DEBUG,"Removed casted user from channel's internal list");
|
||||
@ -200,22 +200,22 @@ void chanrec::DelVoicedUser(char* castuser)
|
||||
}
|
||||
}
|
||||
|
||||
std::map<char*,char*> *chanrec::GetUsers()
|
||||
CUList *chanrec::GetUsers()
|
||||
{
|
||||
return &internal_userlist;
|
||||
}
|
||||
|
||||
std::map<char*,char*> *chanrec::GetOppedUsers()
|
||||
CUList *chanrec::GetOppedUsers()
|
||||
{
|
||||
return &internal_op_userlist;
|
||||
}
|
||||
|
||||
std::map<char*,char*> *chanrec::GetHalfoppedUsers()
|
||||
CUList *chanrec::GetHalfoppedUsers()
|
||||
{
|
||||
return &internal_halfop_userlist;
|
||||
}
|
||||
|
||||
std::map<char*,char*> *chanrec::GetVoicedUsers()
|
||||
CUList *chanrec::GetVoicedUsers()
|
||||
{
|
||||
return &internal_voice_userlist;
|
||||
}
|
||||
@ -417,7 +417,7 @@ chanrec* add_channel(userrec *user, const char* cn, const char* key, bool overri
|
||||
chan_hash::iterator n = chanlist.find(cname);
|
||||
if (n != chanlist.end())
|
||||
{
|
||||
Ptr->DelUser((char*)user);
|
||||
Ptr->DelUser(user);
|
||||
delete Ptr;
|
||||
chanlist.erase(n);
|
||||
for (unsigned int index =0; index < user->chans.size(); index++)
|
||||
@ -439,7 +439,7 @@ chanrec* ForceChan(chanrec* Ptr,ucrec &a,userrec* user, int created)
|
||||
{
|
||||
/* first user in is given ops */
|
||||
a.uc_modes = UCMODE_OP;
|
||||
Ptr->AddOppedUser((char*)user);
|
||||
Ptr->AddOppedUser(user);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -447,7 +447,7 @@ chanrec* ForceChan(chanrec* Ptr,ucrec &a,userrec* user, int created)
|
||||
}
|
||||
|
||||
a.channel = Ptr;
|
||||
Ptr->AddUser((char*)user);
|
||||
Ptr->AddUser(user);
|
||||
WriteChannel(Ptr,user,"JOIN :%s",Ptr->name);
|
||||
log(DEBUG,"Sent JOIN to client");
|
||||
|
||||
@ -505,7 +505,7 @@ chanrec* del_channel(userrec *user, const char* cname, const char* reason, bool
|
||||
}
|
||||
}
|
||||
|
||||
Ptr->DelUser((char*)user);
|
||||
Ptr->DelUser(user);
|
||||
|
||||
/* if there are no users left on the channel */
|
||||
if (!usercount(Ptr))
|
||||
@ -560,7 +560,7 @@ void server_kick_channel(userrec* user, chanrec* Ptr, char* reason, bool trigger
|
||||
}
|
||||
}
|
||||
|
||||
Ptr->DelUser((char*)user);
|
||||
Ptr->DelUser(user);
|
||||
|
||||
if (!usercount(Ptr))
|
||||
{
|
||||
@ -647,7 +647,7 @@ void kick_channel(userrec *src,userrec *user, chanrec *Ptr, char* reason)
|
||||
}
|
||||
}
|
||||
|
||||
Ptr->DelUser((char*)user);
|
||||
Ptr->DelUser(user);
|
||||
|
||||
/* if there are no users left on the channel */
|
||||
if (!usercount(Ptr))
|
||||
|
@ -458,7 +458,7 @@ void WriteChannel(chanrec* Ptr, userrec* user, char* text, ...)
|
||||
{
|
||||
char textbuffer[MAXBUF];
|
||||
va_list argsPtr;
|
||||
std::map<char*,char*> *ulist;
|
||||
CUList *ulist;
|
||||
|
||||
if ((!Ptr) || (!user) || (!text))
|
||||
{
|
||||
@ -472,18 +472,16 @@ void WriteChannel(chanrec* Ptr, userrec* user, char* text, ...)
|
||||
|
||||
ulist = Ptr->GetUsers();
|
||||
|
||||
for (std::map<char*,char*>::iterator i = ulist->begin(); i != ulist->end(); i++)
|
||||
for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
|
||||
{
|
||||
userrec* otheruser = (userrec*)i->second;
|
||||
|
||||
if (otheruser->fd != FD_MAGIC_NUMBER)
|
||||
WriteTo_NoFormat(user,otheruser,textbuffer);
|
||||
if (i->second->fd != FD_MAGIC_NUMBER)
|
||||
WriteTo_NoFormat(user,i->second,textbuffer);
|
||||
}
|
||||
}
|
||||
|
||||
void WriteChannel_NoFormat(chanrec* Ptr, userrec* user, const char* text)
|
||||
{
|
||||
std::map<char*,char*> *ulist;
|
||||
CUList *ulist;
|
||||
|
||||
if ((!Ptr) || (!user) || (!text))
|
||||
{
|
||||
@ -493,12 +491,10 @@ void WriteChannel_NoFormat(chanrec* Ptr, userrec* user, const char* text)
|
||||
|
||||
ulist = Ptr->GetUsers();
|
||||
|
||||
for (std::map<char*,char*>::iterator i = ulist->begin(); i != ulist->end(); i++)
|
||||
for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
|
||||
{
|
||||
userrec* otheruser = (userrec*)i->second;
|
||||
|
||||
if (otheruser->fd != FD_MAGIC_NUMBER)
|
||||
WriteTo_NoFormat(user,otheruser,text);
|
||||
if (i->second->fd != FD_MAGIC_NUMBER)
|
||||
WriteTo_NoFormat(user,i->second,text);
|
||||
}
|
||||
}
|
||||
|
||||
@ -511,7 +507,7 @@ void WriteChannelLocal(chanrec* Ptr, userrec* user, char* text, ...)
|
||||
{
|
||||
char textbuffer[MAXBUF];
|
||||
va_list argsPtr;
|
||||
std::map<char*,char*> *ulist;
|
||||
CUList *ulist;
|
||||
|
||||
if ((!Ptr) || (!text))
|
||||
{
|
||||
@ -525,19 +521,17 @@ void WriteChannelLocal(chanrec* Ptr, userrec* user, char* text, ...)
|
||||
|
||||
ulist = Ptr->GetUsers();
|
||||
|
||||
for (std::map<char*,char*>::iterator i = ulist->begin(); i != ulist->end(); i++)
|
||||
for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
|
||||
{
|
||||
userrec* otheruser = (userrec*)i->second;
|
||||
|
||||
if ((otheruser->fd != FD_MAGIC_NUMBER) && (otheruser != user))
|
||||
if ((i->second->fd != FD_MAGIC_NUMBER) && (i->second != user))
|
||||
{
|
||||
if (!user)
|
||||
{
|
||||
WriteServ_NoFormat(otheruser->fd,textbuffer);
|
||||
WriteServ_NoFormat(i->second->fd,textbuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteTo_NoFormat(user,otheruser,textbuffer);
|
||||
WriteTo_NoFormat(user,i->second,textbuffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -545,7 +539,7 @@ void WriteChannelLocal(chanrec* Ptr, userrec* user, char* text, ...)
|
||||
|
||||
void WriteChannelLocal_NoFormat(chanrec* Ptr, userrec* user, const char* text)
|
||||
{
|
||||
std::map<char*,char*> *ulist;
|
||||
CUList *ulist;
|
||||
|
||||
if ((!Ptr) || (!text))
|
||||
{
|
||||
@ -555,19 +549,17 @@ void WriteChannelLocal_NoFormat(chanrec* Ptr, userrec* user, const char* text)
|
||||
|
||||
ulist = Ptr->GetUsers();
|
||||
|
||||
for (std::map<char*,char*>::iterator i = ulist->begin(); i != ulist->end(); i++)
|
||||
for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
|
||||
{
|
||||
userrec* otheruser = (userrec*)i->second;
|
||||
|
||||
if ((otheruser->fd != FD_MAGIC_NUMBER) && (otheruser != user))
|
||||
if ((i->second->fd != FD_MAGIC_NUMBER) && (i->second != user))
|
||||
{
|
||||
if (!user)
|
||||
{
|
||||
WriteServ_NoFormat(otheruser->fd,text);
|
||||
WriteServ_NoFormat(i->second->fd,text);
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteTo_NoFormat(user,otheruser,text);
|
||||
WriteTo_NoFormat(user,i->second,text);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -579,7 +571,7 @@ void WriteChannelWithServ(char* ServName, chanrec* Ptr, char* text, ...)
|
||||
{
|
||||
char textbuffer[MAXBUF];
|
||||
va_list argsPtr;
|
||||
std::map<char*,char*> *ulist;
|
||||
CUList *ulist;
|
||||
|
||||
if ((!Ptr) || (!text))
|
||||
{
|
||||
@ -593,18 +585,16 @@ void WriteChannelWithServ(char* ServName, chanrec* Ptr, char* text, ...)
|
||||
|
||||
ulist = Ptr->GetUsers();
|
||||
|
||||
for (std::map<char*,char*>::iterator i = ulist->begin(); i != ulist->end(); i++)
|
||||
for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
|
||||
{
|
||||
userrec* otheruser = (userrec*)i->second;
|
||||
|
||||
if (IS_LOCAL(otheruser))
|
||||
WriteServ_NoFormat(otheruser->fd,textbuffer);
|
||||
if (IS_LOCAL(i->second))
|
||||
WriteServ_NoFormat(i->second->fd,textbuffer);
|
||||
}
|
||||
}
|
||||
|
||||
void WriteChannelWithServ_NoFormat(char* ServName, chanrec* Ptr, const char* text)
|
||||
{
|
||||
std::map<char*,char*> *ulist;
|
||||
CUList *ulist;
|
||||
|
||||
if ((!Ptr) || (!text))
|
||||
{
|
||||
@ -614,12 +604,10 @@ void WriteChannelWithServ_NoFormat(char* ServName, chanrec* Ptr, const char* tex
|
||||
|
||||
ulist = Ptr->GetUsers();
|
||||
|
||||
for (std::map<char*,char*>::iterator i = ulist->begin(); i != ulist->end(); i++)
|
||||
for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
|
||||
{
|
||||
userrec* otheruser = (userrec*)i->second;
|
||||
|
||||
if (IS_LOCAL(otheruser))
|
||||
WriteServ_NoFormat(otheruser->fd,text);
|
||||
if (IS_LOCAL(i->second))
|
||||
WriteServ_NoFormat(i->second->fd,text);
|
||||
}
|
||||
}
|
||||
|
||||
@ -632,7 +620,7 @@ void ChanExceptSender(chanrec* Ptr, userrec* user, char status, char* text, ...)
|
||||
{
|
||||
char textbuffer[MAXBUF];
|
||||
va_list argsPtr;
|
||||
std::map<char*,char*> *ulist;
|
||||
CUList *ulist;
|
||||
|
||||
if ((!Ptr) || (!user) || (!text))
|
||||
{
|
||||
@ -662,18 +650,16 @@ void ChanExceptSender(chanrec* Ptr, userrec* user, char status, char* text, ...)
|
||||
|
||||
log(DEBUG,"%d users to write to",ulist->size());
|
||||
|
||||
for (std::map<char*,char*>::iterator i = ulist->begin(); i != ulist->end(); i++)
|
||||
for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
|
||||
{
|
||||
userrec* otheruser = (userrec*)i->second;
|
||||
|
||||
if ((IS_LOCAL(otheruser)) && (user != otheruser))
|
||||
WriteFrom_NoFormat(otheruser->fd,user,textbuffer);
|
||||
if ((IS_LOCAL(i->second)) && (user != i->second))
|
||||
WriteFrom_NoFormat(i->second->fd,user,textbuffer);
|
||||
}
|
||||
}
|
||||
|
||||
void ChanExceptSender_NoFormat(chanrec* Ptr, userrec* user, char status, const char* text)
|
||||
{
|
||||
std::map<char*,char*> *ulist;
|
||||
CUList *ulist;
|
||||
|
||||
if ((!Ptr) || (!user) || (!text))
|
||||
{
|
||||
@ -697,12 +683,10 @@ void ChanExceptSender_NoFormat(chanrec* Ptr, userrec* user, char status, const c
|
||||
break;
|
||||
}
|
||||
|
||||
for (std::map<char*,char*>::iterator i = ulist->begin(); i != ulist->end(); i++)
|
||||
for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
|
||||
{
|
||||
userrec* otheruser = (userrec*)i->second;
|
||||
|
||||
if ((IS_LOCAL(otheruser)) && (user != otheruser))
|
||||
WriteFrom_NoFormat(otheruser->fd,user,text);
|
||||
if ((IS_LOCAL(i->second)) && (user != i->second))
|
||||
WriteFrom_NoFormat(i->second->fd,user,text);
|
||||
}
|
||||
}
|
||||
|
||||
@ -757,16 +741,14 @@ void WriteCommon(userrec *u, char* text, ...)
|
||||
{
|
||||
if (u->chans[i].channel)
|
||||
{
|
||||
std::map<char*,char*> *ulist= u->chans[i].channel->GetUsers();
|
||||
CUList *ulist= u->chans[i].channel->GetUsers();
|
||||
|
||||
for (std::map<char*,char*>::iterator i = ulist->begin(); i != ulist->end(); i++)
|
||||
for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
|
||||
{
|
||||
userrec* otheruser = (userrec*)i->second;
|
||||
|
||||
if ((otheruser->fd > -1) && (!already_sent[otheruser->fd]))
|
||||
if ((i->second->fd > -1) && (!already_sent[i->second->fd]))
|
||||
{
|
||||
already_sent[otheruser->fd] = 1;
|
||||
WriteFrom_NoFormat(otheruser->fd,u,textbuffer);
|
||||
already_sent[i->second->fd] = 1;
|
||||
WriteFrom_NoFormat(i->second->fd,u,textbuffer);
|
||||
sent_to_at_least_one = true;
|
||||
}
|
||||
}
|
||||
@ -808,16 +790,14 @@ void WriteCommon_NoFormat(userrec *u, const char* text)
|
||||
{
|
||||
if (u->chans[i].channel)
|
||||
{
|
||||
std::map<char*,char*> *ulist= u->chans[i].channel->GetUsers();
|
||||
CUList *ulist= u->chans[i].channel->GetUsers();
|
||||
|
||||
for (std::map<char*,char*>::iterator i = ulist->begin(); i != ulist->end(); i++)
|
||||
for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
|
||||
{
|
||||
userrec* otheruser = (userrec*)i->second;
|
||||
|
||||
if ((otheruser->fd > -1) && (!already_sent[otheruser->fd]))
|
||||
if ((i->second->fd > -1) && (!already_sent[i->second->fd]))
|
||||
{
|
||||
already_sent[otheruser->fd] = 1;
|
||||
WriteFrom_NoFormat(otheruser->fd,u,text);
|
||||
already_sent[i->second->fd] = 1;
|
||||
WriteFrom_NoFormat(i->second->fd,u,text);
|
||||
sent_to_at_least_one = true;
|
||||
}
|
||||
}
|
||||
@ -912,24 +892,22 @@ void WriteCommonExcept(userrec *u, char* text, ...)
|
||||
{
|
||||
if (u->chans[i].channel)
|
||||
{
|
||||
std::map<char*,char*> *ulist= u->chans[i].channel->GetUsers();
|
||||
CUList *ulist= u->chans[i].channel->GetUsers();
|
||||
|
||||
for (std::map<char*,char*>::iterator i = ulist->begin(); i != ulist->end(); i++)
|
||||
for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
|
||||
{
|
||||
userrec* otheruser = (userrec*)i->second;
|
||||
|
||||
if (u != otheruser)
|
||||
if (u != i->second)
|
||||
{
|
||||
if ((otheruser->fd > -1) && (!already_sent[otheruser->fd]))
|
||||
if ((i->second->fd > -1) && (!already_sent[i->second->fd]))
|
||||
{
|
||||
already_sent[otheruser->fd] = 1;
|
||||
already_sent[i->second->fd] = 1;
|
||||
|
||||
if (quit_munge)
|
||||
{
|
||||
WriteFrom_NoFormat(otheruser->fd,u,*otheruser->oper ? oper_quit : textbuffer);
|
||||
WriteFrom_NoFormat(i->second->fd,u,*i->second->oper ? oper_quit : textbuffer);
|
||||
}
|
||||
else
|
||||
WriteFrom_NoFormat(otheruser->fd,u,textbuffer);
|
||||
WriteFrom_NoFormat(i->second->fd,u,textbuffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -960,18 +938,16 @@ void WriteCommonExcept_NoFormat(userrec *u, const char* text)
|
||||
{
|
||||
if (u->chans[i].channel)
|
||||
{
|
||||
std::map<char*,char*> *ulist= u->chans[i].channel->GetUsers();
|
||||
CUList *ulist= u->chans[i].channel->GetUsers();
|
||||
|
||||
for (std::map<char*,char*>::iterator i = ulist->begin(); i != ulist->end(); i++)
|
||||
for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
|
||||
{
|
||||
userrec* otheruser = (userrec*)i->second;
|
||||
|
||||
if (u != otheruser)
|
||||
if (u != i->second)
|
||||
{
|
||||
if ((otheruser->fd > -1) && (!already_sent[otheruser->fd]))
|
||||
if ((i->second->fd > -1) && (!already_sent[i->second->fd]))
|
||||
{
|
||||
already_sent[otheruser->fd] = 1;
|
||||
WriteFrom_NoFormat(otheruser->fd,u,text);
|
||||
already_sent[i->second->fd] = 1;
|
||||
WriteFrom_NoFormat(i->second->fd,u,text);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1249,7 +1225,7 @@ void purge_empty_chans(userrec* u)
|
||||
{
|
||||
if (u->chans[f].channel)
|
||||
{
|
||||
u->chans[f].channel->DelUser((char*)u);
|
||||
u->chans[f].channel->DelUser(u);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1370,13 +1346,11 @@ void userlist(userrec *user,chanrec *c)
|
||||
size_t dlen = snprintf(list,MAXBUF,"353 %s = %s :", user->nick, c->name);
|
||||
size_t initial = dlen;
|
||||
|
||||
std::map<char*,char*> *ulist= c->GetUsers();
|
||||
CUList *ulist= c->GetUsers();
|
||||
|
||||
for (std::map<char*,char*>::iterator i = ulist->begin(); i != ulist->end(); i++)
|
||||
for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
|
||||
{
|
||||
userrec* otheruser = (userrec*)i->second;
|
||||
|
||||
if ((!has_channel(user,c)) && (strchr(otheruser->modes,'i')))
|
||||
if ((!has_channel(user,c)) && (strchr(i->second->modes,'i')))
|
||||
{
|
||||
/*
|
||||
* user is +i, and source not on the channel, does not show
|
||||
@ -1385,8 +1359,8 @@ void userlist(userrec *user,chanrec *c)
|
||||
continue;
|
||||
}
|
||||
|
||||
dlen += strlcat(list,cmode(otheruser,c),MAXBUF);
|
||||
dlen += strlcat(list,otheruser->nick,MAXBUF);
|
||||
dlen += strlcat(list,cmode(i->second,c),MAXBUF);
|
||||
dlen += strlcat(list,i->second->nick,MAXBUF);
|
||||
charlcat(list,' ',MAXBUF);
|
||||
dlen++;
|
||||
|
||||
@ -1416,11 +1390,10 @@ int usercount_i(chanrec *c)
|
||||
if (!c)
|
||||
return 0;
|
||||
|
||||
std::map<char*,char*> *ulist= c->GetUsers();
|
||||
for (std::map<char*,char*>::iterator i = ulist->begin(); i != ulist->end(); i++)
|
||||
CUList *ulist= c->GetUsers();
|
||||
for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
|
||||
{
|
||||
userrec* user = (userrec*)i->second;
|
||||
if (!strchr(user->modes,'i'))
|
||||
if (!strchr(i->second->modes,'i'))
|
||||
count++;
|
||||
}
|
||||
|
||||
|
12
src/mode.cpp
12
src/mode.cpp
@ -85,13 +85,13 @@ char* ModeParser::Grant(userrec *d,chanrec *chan,int MASK)
|
||||
switch (MASK)
|
||||
{
|
||||
case UCMODE_OP:
|
||||
d->chans[i].channel->AddOppedUser((char*)d);
|
||||
d->chans[i].channel->AddOppedUser(d);
|
||||
break;
|
||||
case UCMODE_HOP:
|
||||
d->chans[i].channel->AddHalfoppedUser((char*)d);
|
||||
d->chans[i].channel->AddHalfoppedUser(d);
|
||||
break;
|
||||
case UCMODE_VOICE:
|
||||
d->chans[i].channel->AddVoicedUser((char*)d);
|
||||
d->chans[i].channel->AddVoicedUser(d);
|
||||
break;
|
||||
}
|
||||
log(DEBUG,"grant: %s %s",d->chans[i].channel->name,d->nick);
|
||||
@ -116,13 +116,13 @@ char* ModeParser::Revoke(userrec *d,chanrec *chan,int MASK)
|
||||
switch (MASK)
|
||||
{
|
||||
case UCMODE_OP:
|
||||
d->chans[i].channel->DelOppedUser((char*)d);
|
||||
d->chans[i].channel->DelOppedUser(d);
|
||||
break;
|
||||
case UCMODE_HOP:
|
||||
d->chans[i].channel->DelHalfoppedUser((char*)d);
|
||||
d->chans[i].channel->DelHalfoppedUser(d);
|
||||
break;
|
||||
case UCMODE_VOICE:
|
||||
d->chans[i].channel->DelVoicedUser((char*)d);
|
||||
d->chans[i].channel->DelVoicedUser(d);
|
||||
break;
|
||||
}
|
||||
log(DEBUG,"revoke: %s %s",d->chans[i].channel->name,d->nick);
|
||||
|
@ -451,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)
|
||||
|
@ -1143,24 +1143,22 @@ class TreeSocket : public InspSocket
|
||||
size_t counter = snprintf(list,MAXBUF,":%s FJOIN %s %lu",Srv->GetServerName().c_str(),c->name,(unsigned long)c->age);
|
||||
size_t initial = counter;
|
||||
|
||||
std::map<char*,char*> *ulist = c->GetUsers();
|
||||
CUList *ulist = c->GetUsers();
|
||||
std::vector<userrec*> specific_halfop;
|
||||
std::vector<userrec*> specific_voice;
|
||||
|
||||
for (std::map<char*,char*>::iterator i = ulist->begin(); i != ulist->end(); i++)
|
||||
for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
|
||||
{
|
||||
char* o = i->second;
|
||||
userrec* otheruser = (userrec*)o;
|
||||
charlcat(list,' ',MAXBUF);
|
||||
counter++;
|
||||
int x = cflags(otheruser,c);
|
||||
int x = cflags(i->second,c);
|
||||
if ((x & UCMODE_HOP) && (x & UCMODE_OP))
|
||||
{
|
||||
specific_halfop.push_back(otheruser);
|
||||
specific_halfop.push_back(i->second);
|
||||
}
|
||||
if (((x & UCMODE_HOP) || (x & UCMODE_OP)) && (x & UCMODE_VOICE))
|
||||
{
|
||||
specific_voice.push_back(otheruser);
|
||||
specific_voice.push_back(i->second);
|
||||
}
|
||||
|
||||
char n = 0;
|
||||
@ -1183,7 +1181,7 @@ class TreeSocket : public InspSocket
|
||||
counter++;
|
||||
}
|
||||
|
||||
counter += strlcat(list,otheruser->nick,MAXBUF);
|
||||
counter += strlcat(list,i->second->nick,MAXBUF);
|
||||
|
||||
if (counter > (480-NICKMAX))
|
||||
{
|
||||
@ -2660,14 +2658,12 @@ void AddThisServer(TreeServer* server, std::deque<TreeServer*> &list)
|
||||
// returns a list of DIRECT servernames for a specific channel
|
||||
void GetListOfServersForChannel(chanrec* c, std::deque<TreeServer*> &list)
|
||||
{
|
||||
std::map<char*,char*> *ulist = c->GetUsers();
|
||||
for (std::map<char*,char*>::iterator i = ulist->begin(); i != ulist->end(); i++)
|
||||
CUList *ulist = c->GetUsers();
|
||||
for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
|
||||
{
|
||||
char* o = i->second;
|
||||
userrec* otheruser = (userrec*)o;
|
||||
if (otheruser->fd < 0)
|
||||
if (i->second->fd < 0)
|
||||
{
|
||||
TreeServer* best = BestRouteTo(otheruser->server);
|
||||
TreeServer* best = BestRouteTo(i->second->server);
|
||||
if (best)
|
||||
AddThisServer(best,list);
|
||||
}
|
||||
|
@ -70,13 +70,11 @@ void spy_userlist(userrec *user,chanrec *c)
|
||||
|
||||
snprintf(list,MAXBUF,"353 %s = %s :", user->nick, c->name);
|
||||
|
||||
std::map<char*,char*> *ulist= c->GetUsers();
|
||||
for (std::map<char*,char*>::iterator i = ulist->begin(); i != ulist->end(); i++)
|
||||
CUList *ulist= c->GetUsers();
|
||||
for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
|
||||
{
|
||||
char* o = i->second;
|
||||
userrec* otheruser = (userrec*)o;
|
||||
strlcat(list,cmode(otheruser,c),MAXBUF);
|
||||
strlcat(list,otheruser->nick,MAXBUF);
|
||||
strlcat(list,cmode(i->second,c),MAXBUF);
|
||||
strlcat(list,i->second->nick,MAXBUF);
|
||||
strlcat(list," ",MAXBUF);
|
||||
if (strlen(list)>(480-NICKMAX))
|
||||
{
|
||||
|
@ -1 +1 @@
|
||||
echo 3553
|
||||
echo 3555
|
||||
|
Loading…
x
Reference in New Issue
Block a user