summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2013-07-26 08:45:44 -0400
committerAdam <Adam@anope.org>2013-07-26 08:45:44 -0400
commit3dc64bac4d436ba27683270b88c0cc5bfa346acc (patch)
treeaa1dd95d1c5d4618c06cb8662d9d888c0e5793c8 /src
parent2450a64bf4dc55635c9f4c1c829f149dc6621b41 (diff)
Fix issues with 'Me' related to previous commit
Diffstat (limited to 'src')
-rw-r--r--src/bots.cpp14
-rw-r--r--src/config.cpp1
-rw-r--r--src/init.cpp11
-rw-r--r--src/uplink.cpp53
4 files changed, 47 insertions, 32 deletions
diff --git a/src/bots.cpp b/src/bots.cpp
index 0a65393bb..b85bd2534 100644
--- a/src/bots.cpp
+++ b/src/bots.cpp
@@ -106,13 +106,25 @@ Serializable* BotInfo::Unserialize(Serializable *obj, Serialize::Data &data)
return bi;
}
-void BotInfo::GenerateUID()
+void BotInfo::Up()
{
if (!this->uid.empty())
throw CoreException("Bot already has a uid?");
+
this->uid = Servers::TS6_UID_Retrieve();
(*BotListByUID)[this->uid] = this;
UserListByUID[this->uid] = this;
+ this->server = Me;
+ ++this->server->users;
+}
+
+void BotInfo::Down()
+{
+ BotListByUID->erase(this->uid);
+ UserListByUID.erase(this->uid);
+ --this->server->users;
+ this->server = NULL;
+ this->uid = "";
}
void BotInfo::SetNewNick(const Anope::string &newnick)
diff --git a/src/config.cpp b/src/config.cpp
index 27c3eccdc..f748383ab 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -149,7 +149,6 @@ Conf::Conf() : Block("")
{"serverinfo", "name"},
{"serverinfo", "description"},
{"serverinfo", "localhost"},
- {"serverinfo", "id"},
{"serverinfo", "pid"},
{"networkinfo", "nicklen"},
{"networkinfo", "userlen"},
diff --git a/src/init.cpp b/src/init.cpp
index d76a631f5..e8ee21b19 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -428,15 +428,6 @@ void Anope::Init(int ac, char **av)
/* Write our PID to the PID file. */
write_pidfile();
- /* Create me */
- Configuration::Block *block = Config->GetBlock("serverinfo");
- Me = new Server(NULL, block->Get<const Anope::string>("name"), 0, block->Get<const Anope::string>("description"), block->Get<const Anope::string>("id"));
- for (botinfo_map::const_iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it)
- {
- it->second->server = Me;
- ++Me->users;
- }
-
/* Announce ourselves to the logfile. */
Log() << "Anope " << Anope::Version() << " starting up" << (Anope::Debug || Anope::ReadOnly ? " (options:" : "") << (Anope::Debug ? " debug" : "") << (Anope::ReadOnly ? " readonly" : "") << (Anope::Debug || Anope::ReadOnly ? ")" : "");
@@ -446,7 +437,7 @@ void Anope::Init(int ac, char **av)
Language::InitLanguages();
/* Initialize random number generator */
- block = Config->GetBlock("options");
+ Configuration::Block *block = Config->GetBlock("options");
srand(block->Get<unsigned>("seed"));
/* load modules */
diff --git a/src/uplink.cpp b/src/uplink.cpp
index 282d8be05..100b58310 100644
--- a/src/uplink.cpp
+++ b/src/uplink.cpp
@@ -61,42 +61,55 @@ void Uplink::Connect()
UplinkSocket::UplinkSocket() : Socket(-1, Config->Uplinks[Anope::CurrentUplink].ipv6), ConnectionSocket(), BufferedSocket()
{
+ /* Create me */
+ Configuration::Block *block = Config->GetBlock("serverinfo");
+ Anope::string id = block->Get<const Anope::string>("id");
+ if (id.empty())
+ /* Defalt to a valid ts6 sid if this ircd is ts6 */
+ id = Servers::TS6_SID_Retrieve();
+ Me = new Server(NULL, block->Get<const Anope::string>("name"), 0, block->Get<const Anope::string>("description"), id);
+
+ for (botinfo_map::const_iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it)
+ {
+ BotInfo *bi = it->second;
+ bi->Up();
+ }
+
UplinkSock = this;
}
UplinkSocket::~UplinkSocket()
{
- if (IRCD && Servers::GetUplink() && Servers::GetUplink()->IsSynced())
+ for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
{
- FOREACH_MOD(OnServerDisconnect, ());
+ User *u = it->second;
- for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
+ if (u->server == Me)
{
- User *u = it->second;
-
- if (u->server == Me)
+ /* Don't use quitmsg here, it may contain information you don't want people to see */
+ IRCD->SendQuit(u, "Shutting down");
+ BotInfo* bi = BotInfo::Find(u->nick);
+ if (bi != NULL)
{
- /* Don't use quitmsg here, it may contain information you don't want people to see */
- IRCD->SendQuit(u, "Shutting down");
- BotInfo* bi = BotInfo::Find(u->nick);
- if (bi != NULL)
- bi->introduced = false;
+ bi->introduced = false;
+ bi->Down();
}
+ else
+ /* Enforcer client or some other non-service bot */
+ u->Quit("Shutting down");
}
+ }
- IRCD->SendSquit(Me, Anope::QuitReason);
+ User::QuitUsers();
- this->ProcessWrite(); // Write out the last bit
- }
+ FOREACH_MOD(OnServerDisconnect, ());
- if (Me)
- for (unsigned i = Me->GetLinks().size(); i > 0; --i)
- if (!Me->GetLinks()[i - 1]->IsJuped())
- Me->GetLinks()[i - 1]->Delete(Me->GetName() + " " + Me->GetLinks()[i - 1]->GetName());
+ IRCD->SendSquit(Me, Anope::QuitReason);
+ Me = NULL;
- UplinkSock = NULL;
+ this->ProcessWrite(); // Write out the last bit
- Me->Unsync();
+ UplinkSock = NULL;
if (Anope::AtTerm())
{