diff options
author | Adam <Adam@anope.org> | 2014-02-27 22:42:54 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2014-02-27 22:42:54 -0500 |
commit | fee016bb84ba9a951000dac581261827a11cb668 (patch) | |
tree | 251d5d5755652f0eb8b9154b4d52603ea6f98c23 /src/bots.cpp | |
parent | d24fb039172786e0fb3e3164140b337c85cdeeca (diff) |
Handle nick collisions somewhat instead of blindly overwriting the nicks
in memory, which does weird things.
For fun different ircds implement this differently (Unreal compares
timestamps, TS6 compares timestamps and user username/host), and whether
or not we get a kill for our user also varies, so just kill everyone.
This can't really happen anyway with properly set qlines, only if
services haven't yet set the qlines, or possibly in a bot add/nick
user introduce race, or with enforcers, which not many ircds require.
Diffstat (limited to 'src/bots.cpp')
-rw-r--r-- | src/bots.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/bots.cpp b/src/bots.cpp index feedacc63..77b7d1c35 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -108,14 +108,31 @@ Serializable* BotInfo::Unserialize(Serializable *obj, Serialize::Data &data) void BotInfo::GenerateUID() { + if (this->introduced) + throw CoreException("Changing bot UID when it is introduced?"); + if (!this->uid.empty()) - throw CoreException("Bot already has a uid?"); + { + BotListByUID->erase(this->uid); + UserListByUID.erase(this->uid); + } this->uid = Servers::TS6_UID_Retrieve(); (*BotListByUID)[this->uid] = this; UserListByUID[this->uid] = this; } +void BotInfo::OnKill() +{ + this->introduced = false; + this->GenerateUID(); + IRCD->SendClientIntroduction(this); + this->introduced = true; + + for (User::ChanUserList::const_iterator cit = this->chans.begin(), cit_end = this->chans.end(); cit != cit_end; ++cit) + IRCD->SendJoin(this, cit->second->chan, &cit->second->status); +} + void BotInfo::SetNewNick(const Anope::string &newnick) { UserListByNick.erase(this->nick); |