mirror of
https://github.com/anope/anope.git
synced 2026-07-09 08:23:13 +02:00
Fixed some issues and desyncs with creating empty permanent channels on startup & dropping empty channels
This commit is contained in:
+21
-19
@@ -78,13 +78,10 @@ void Channel::Reset()
|
||||
this->SetMode(NULL, ModeManager::FindChannelModeByName(f.Modes()[i]), uc->user->GetUID(), false);
|
||||
}
|
||||
|
||||
this->CheckModes();
|
||||
|
||||
for (ChanUserList::const_iterator it = this->users.begin(), it_end = this->users.end(); it != it_end; ++it)
|
||||
this->SetCorrectModes(it->second->user, true, false);
|
||||
|
||||
if (this->ci && Me && Me->IsSynced())
|
||||
this->ci->RestoreTopic();
|
||||
this->Sync();
|
||||
}
|
||||
|
||||
void Channel::Sync()
|
||||
@@ -153,6 +150,25 @@ void Channel::CheckModes()
|
||||
}
|
||||
}
|
||||
|
||||
bool Channel::CheckDelete()
|
||||
{
|
||||
/* Channel is persistent, it shouldn't be deleted and the service bot should stay */
|
||||
if (this->HasExt("PERSIST") || (this->ci && this->ci->HasExt("PERSIST")))
|
||||
return false;
|
||||
|
||||
/* Channel is syncing from a netburst, don't destroy it as more users are probably wanting to join immediatly
|
||||
* We also don't part the bot here either, if necessary we will part it after the sync
|
||||
*/
|
||||
if (this->HasExt("SYNCING"))
|
||||
return false;
|
||||
|
||||
/* Additionally, do not delete this channel if ChanServ/a BotServ bot is inhabiting it */
|
||||
if (this->HasExt("INHABIT"))
|
||||
return false;
|
||||
|
||||
return this->users.empty();
|
||||
}
|
||||
|
||||
ChanUserContainer* Channel::JoinUser(User *user)
|
||||
{
|
||||
if (user->server && user->server->IsSynced())
|
||||
@@ -190,21 +206,7 @@ void Channel::DeleteUser(User *user)
|
||||
Log(LOG_DEBUG) << "Channel::DeleteUser() tried to delete nonexistant channel " << this->name << " from " << user->nick << "'s channel list";
|
||||
delete cu;
|
||||
|
||||
/* Channel is persistent, it shouldn't be deleted and the service bot should stay */
|
||||
if (this->HasExt("PERSIST") || (this->ci && this->ci->HasExt("PERSIST")))
|
||||
return;
|
||||
|
||||
/* Channel is syncing from a netburst, don't destroy it as more users are probably wanting to join immediatly
|
||||
* We also don't part the bot here either, if necessary we will part it after the sync
|
||||
*/
|
||||
if (this->HasExt("SYNCING"))
|
||||
return;
|
||||
|
||||
/* Additionally, do not delete this channel if ChanServ/a BotServ bot is inhabiting it */
|
||||
if (this->HasExt("INHABIT"))
|
||||
return;
|
||||
|
||||
if (this->users.empty())
|
||||
if (this->CheckDelete())
|
||||
delete this;
|
||||
}
|
||||
|
||||
|
||||
+8
-1
@@ -361,9 +361,16 @@ ChannelInfo::~ChannelInfo()
|
||||
{
|
||||
if (this->bi && this->c->FindUser(this->bi))
|
||||
this->bi->Part(this->c);
|
||||
|
||||
/* Parting the service bot can cause the channel to go away */
|
||||
|
||||
if (this->c)
|
||||
this->c->ci = NULL;
|
||||
{
|
||||
if (this->c && this->c->CheckDelete())
|
||||
delete this->c;
|
||||
|
||||
this->c = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
RegisteredChannelList->erase(this->name);
|
||||
|
||||
+11
-7
@@ -254,35 +254,39 @@ void Server::Sync(bool sync_links)
|
||||
{
|
||||
bool created;
|
||||
ci->c = Channel::FindOrCreate(ci->name, created, ci->time_registered);
|
||||
|
||||
if (ModeManager::FindChannelModeByName("PERM") != NULL)
|
||||
{
|
||||
ci->c->SetMode(NULL, "PERM");
|
||||
if (created)
|
||||
IRCD->SendChannel(ci->c);
|
||||
ci->c->SetMode(NULL, "PERM");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!ci->bi)
|
||||
ci->WhoSends()->Assign(NULL, ci);
|
||||
if (ci->c->FindUser(ci->bi) == NULL)
|
||||
ci->bi->Join(ci->c);
|
||||
{
|
||||
ChannelStatus status(Config->GetModule("botserv")->Get<const Anope::string>("botmodes"));
|
||||
ci->bi->Join(ci->c, &status);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FOREACH_MOD(I_OnPreUplinkSync, OnPreUplinkSync(this));
|
||||
|
||||
IRCD->SendEOB();
|
||||
Me->Sync(false);
|
||||
|
||||
FOREACH_MOD(I_OnUplinkSync, OnUplinkSync(this));
|
||||
|
||||
for (channel_map::const_iterator it = ChannelList.begin(), it_end = ChannelList.end(); it != it_end; ++it)
|
||||
{
|
||||
Channel *c = it->second;
|
||||
c->Sync();
|
||||
}
|
||||
|
||||
IRCD->SendEOB();
|
||||
Me->Sync(false);
|
||||
|
||||
FOREACH_MOD(I_OnUplinkSync, OnUplinkSync(this));
|
||||
|
||||
if (!Anope::NoFork && Anope::AtTerm())
|
||||
{
|
||||
Log(LOG_TERMINAL) << "Successfully linked, launching into background...";
|
||||
|
||||
Reference in New Issue
Block a user