diff options
| author | Adam <Adam@drink-coca-cola.info> | 2010-05-19 16:59:16 -0400 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2010-06-18 21:03:44 -0400 |
| commit | 3a2c2a916a26f4fa1844e71a9f1c2fc25337fd2b (patch) | |
| tree | 93cb603a579699b51b74a450db092ab8db595e1f /src/regchannel.cpp | |
| parent | 0358ae062b771a3e018ef147f607eae7d0bd8647 (diff) | |
Dont load mlock from the database until after Anope is connected, it doesnt know all of the available modes until then
Diffstat (limited to 'src/regchannel.cpp')
| -rw-r--r-- | src/regchannel.cpp | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/src/regchannel.cpp b/src/regchannel.cpp index 15a72ca87..d214eb6bd 100644 --- a/src/regchannel.cpp +++ b/src/regchannel.cpp @@ -371,6 +371,79 @@ void ChannelInfo::ClearBadWords() } } +/** Loads MLocked modes from extensible. This is used from database loading because Anope doesn't know what modes exist + * until after it connects to the IRCd. + */ +void ChannelInfo::LoadMLock() +{ + std::vector<std::string> modenames; + + if (this->GetExtRegular("db_mlock_modes_on", modenames)) + { + for (std::vector<std::string>::iterator it = modenames.begin(); it != modenames.end(); ++it) + { + for (std::list<Mode *>::iterator mit = ModeManager::Modes.begin(); mit != ModeManager::Modes.end(); ++mit) + { + if ((*mit)->Class == MC_CHANNEL) + { + ChannelMode *cm = dynamic_cast<ChannelMode *>(*mit); + + if (cm->NameAsString == *it) + { + this->SetMLock(cm->Name, true); + } + } + } + } + + this->Shrink("db_mlock_modes_on"); + } + + if (this->GetExtRegular("db_mlock_modes_off", modenames)) + { + for (std::vector<std::string>::iterator it = modenames.begin(); it != modenames.end(); ++it) + { + for (std::list<Mode *>::iterator mit = ModeManager::Modes.begin(); mit != ModeManager::Modes.end(); ++mit) + { + if ((*mit)->Class == MC_CHANNEL) + { + ChannelMode *cm = dynamic_cast<ChannelMode *>(*mit); + + if (cm->NameAsString == *it) + { + this->SetMLock(cm->Name, false); + } + } + } + } + + this->Shrink("db_mlock_modes_off"); + } + + std::vector<std::pair<std::string, std::string> > params; + + if (this->GetExtRegular("db_mlp", params)) + { + for (std::vector<std::pair<std::string, std::string> >::iterator it = params.begin(); it != params.end(); ++it) + { + for (std::list<Mode *>::iterator mit = ModeManager::Modes.begin(); mit != ModeManager::Modes.end(); ++mit) + { + if ((*mit)->Class == MC_CHANNEL) + { + ChannelMode *cm = dynamic_cast<ChannelMode *>(*mit); + + if (cm->NameAsString == it->first) + { + this->SetMLock(cm->Name, true, it->second); + } + } + } + } + + this->Shrink("db_mlp"); + } +} + /** Check if a mode is mlocked * @param Name The mode * @param status True to check mlock on, false for mlock off |
