1
0
mirror of https://github.com/anope/anope.git synced 2026-07-03 06:13:13 +02:00

Changed 'char *' fields in BotInfo to 'std::string', cleanup of bots.cpp, changed many other functions to use 'const std::string &' arguments as a chain reaction.

git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2733 5417fbe8-f217-4b02-8779-1006273d7864
This commit is contained in:
cyberbotx
2010-01-04 06:40:24 +00:00
parent 2708eea5d1
commit b462814760
33 changed files with 202 additions and 264 deletions
+26 -73
View File
@@ -12,75 +12,42 @@
#include "services.h"
#include "modules.h"
BotInfo::BotInfo(const char *nnick)
BotInfo::BotInfo(const std::string &nnick, const std::string &nuser, const std::string &nhost, const std::string &nreal)
{
this->nick = sstrdup(nnick);
this->nick = nnick;
this->user = nuser;
this->host = nhost;
this->real = nreal;
this->lastmsg = this->created = time(NULL);
this->uid = ts6_uid_retrieve(); // XXX is this safe? has ts6 been setup yet?
nbots++;
++nbots;
this->cmdTable = NULL;
this->chancount = 0;
if (Config.s_ChanServ && !stricmp(Config.s_ChanServ, nnick))
ci::string ci_nick(nnick.c_str());
if (Config.s_ChanServ && ci_nick == Config.s_ChanServ)
this->SetFlag(BI_CHANSERV);
else if (Config.s_BotServ && !stricmp(Config.s_BotServ, nnick))
else if (Config.s_BotServ && ci_nick == Config.s_BotServ)
this->SetFlag(BI_BOTSERV);
else if (Config.s_HostServ && !stricmp(Config.s_HostServ, nnick))
else if (Config.s_HostServ && ci_nick == Config.s_HostServ)
this->SetFlag(BI_HOSTSERV);
else if (Config.s_OperServ && !stricmp(Config.s_OperServ, nnick))
else if (Config.s_OperServ && ci_nick == Config.s_OperServ)
this->SetFlag(BI_OPERSERV);
else if (Config.s_MemoServ && !stricmp(Config.s_MemoServ, nnick))
else if (Config.s_MemoServ && ci_nick == Config.s_MemoServ)
this->SetFlag(BI_MEMOSERV);
else if (Config.s_NickServ && !stricmp(Config.s_NickServ, nnick))
else if (Config.s_NickServ && ci_nick == Config.s_NickServ)
this->SetFlag(BI_NICKSERV);
else if (Config.s_GlobalNoticer && !stricmp(Config.s_GlobalNoticer, nnick))
else if (Config.s_GlobalNoticer && ci_nick == Config.s_GlobalNoticer)
this->SetFlag(BI_GLOBAL);
FOREACH_MOD(I_OnBotPreLoad, OnBotPreLoad(this));
insert_bot(this); // XXX, this is ugly, but it needs to stay until hashing of bots is redone in STL.
// If we're synchronised with the uplink already, call introduce_user() for this bot.
alog("serv_uplink is %p and status is %d", static_cast<void *>(serv_uplink), serv_uplink ? serv_uplink->sync == SSYNC_DONE : 0);
if (serv_uplink && serv_uplink->sync == SSYNC_DONE)
ircdproto->SendClientIntroduction(this->nick, this->user, this->host, this->real, ircd->pseudoclient_mode, this->uid.c_str());
}
BotInfo::BotInfo(const char *nnick, const char *nuser, const char *nhost, const char *nreal)
{
this->nick = sstrdup(nnick);
this->user = sstrdup(nuser);
this->host = sstrdup(nhost);
this->real = sstrdup(nreal);
this->lastmsg = this->created = time(NULL);
this->uid = ts6_uid_retrieve(); // XXX is this safe? has ts6 been setup yet?
nbots++;
this->cmdTable = NULL;
this->chancount = 0;
if (Config.s_ChanServ && !stricmp(Config.s_ChanServ, nnick))
this->SetFlag(BI_CHANSERV);
else if (Config.s_BotServ && !stricmp(Config.s_BotServ, nnick))
this->SetFlag(BI_BOTSERV);
else if (Config.s_HostServ && !stricmp(Config.s_HostServ, nnick))
this->SetFlag(BI_HOSTSERV);
else if (Config.s_OperServ && !stricmp(Config.s_OperServ, nnick))
this->SetFlag(BI_OPERSERV);
else if (Config.s_MemoServ && !stricmp(Config.s_MemoServ, nnick))
this->SetFlag(BI_MEMOSERV);
else if (Config.s_NickServ && !stricmp(Config.s_NickServ, nnick))
this->SetFlag(BI_NICKSERV);
else if (Config.s_GlobalNoticer && !stricmp(Config.s_GlobalNoticer, nnick))
this->SetFlag(BI_GLOBAL);
FOREACH_MOD(I_OnBotPreLoad, OnBotPreLoad(this));
insert_bot(this); // XXX, this is ugly, but it needs to stay until hashing of bots is redone in STL.
// If we're synchronised with the uplink already, call introduce_user() for this bot.
alog("serv_uplink is %p and status is %d", static_cast<void *>(serv_uplink), serv_uplink ? serv_uplink->sync == SSYNC_DONE : 0);
if (serv_uplink && serv_uplink->sync == SSYNC_DONE)
ircdproto->SendClientIntroduction(this->nick, this->user, this->host, this->real, ircd->pseudoclient_mode, this->uid.c_str());
ircdproto->SendClientIntroduction(this->nick, this->user, this->host, this->real, ircd->pseudoclient_mode, this->uid);
}
BotInfo::~BotInfo()
@@ -88,7 +55,7 @@ BotInfo::~BotInfo()
int i;
ChannelInfo *ci;
for (i = 0; i < 256; i++)
for (i = 0; i < 256; ++i)
for (ci = chanlists[i]; ci; ci = ci->next)
if (ci->bi == this)
ci->bi = NULL;
@@ -98,14 +65,9 @@ BotInfo::~BotInfo()
if (this->prev)
this->prev->next = this->next;
else
botlists[tolower(*this->nick)] = this->next;
botlists[tolower(this->nick[0])] = this->next;
nbots--;
delete [] this->nick;
delete [] this->user;
delete [] this->host;
delete [] this->real;
--nbots;
}
@@ -116,11 +78,9 @@ void BotInfo::ChangeNick(const char *newnick)
if (this->prev)
this->prev->next = this->next;
else
botlists[tolower(*this->nick)] = this->next;
botlists[tolower(this->nick[0])] = this->next;
if (this->nick)
delete [] this->nick;
this->nick = sstrdup(newnick);
this->nick = newnick;
insert_bot(this);
}
@@ -130,7 +90,7 @@ void BotInfo::RejoinAll()
int i;
ChannelInfo *ci;
for (i = 0; i < 256; i++)
for (i = 0; i < 256; ++i)
for (ci = chanlists[i]; ci; ci = ci->next)
if (ci->bi == this && ci->c && (ci->c->usercount >= Config.BSMinUsers))
bot_join(ci);
@@ -144,15 +104,10 @@ void BotInfo::Assign(User *u, ChannelInfo *ci)
return;
if (ci->bi)
{
if (u)
ci->bi->UnAssign(u, ci);
else
ci->bi->UnAssign(NULL, ci);
}
ci->bi->UnAssign(u, ci);
ci->bi = this;
this->chancount++;
++this->chancount;
if (ci->c && ci->c->usercount >= Config.BSMinUsers)
bot_join(ci);
}
@@ -172,8 +127,6 @@ void BotInfo::UnAssign(User *u, ChannelInfo *ci)
ircdproto->SendPart(ci->bi, ci->c, "");
}
ci->bi->chancount--;
--ci->bi->chancount;
ci->bi = NULL;
}