diff options
| author | 2024-10-16 12:03:52 +0100 | |
|---|---|---|
| committer | 2024-10-16 12:25:20 +0100 | |
| commit | fc9d49641f4308089abb3e61764895beb148fdff (patch) | |
| tree | 9525d9908f93ea5e6c993364fa87ff31ee3a7afc /src | |
| parent | Allow ConfigTag::getCharacter to return NUL for an empty field. (diff) | |
Add support for extbans without letters.
Diffstat (limited to 'src')
| -rw-r--r-- | src/coremods/core_channel/extban.cpp | 29 | ||||
| -rw-r--r-- | src/modules/m_spanningtree/capab.cpp | 10 |
2 files changed, 25 insertions, 14 deletions
diff --git a/src/coremods/core_channel/extban.cpp b/src/coremods/core_channel/extban.cpp index f3d0ba34f..57cac5835 100644 --- a/src/coremods/core_channel/extban.cpp +++ b/src/coremods/core_channel/extban.cpp @@ -22,15 +22,20 @@ void ExtBanManager::AddExtBan(ExtBan::Base* extban) { - auto lit = byletter.emplace(extban->GetLetter(), extban); - if (!lit.second) - throw ModuleException(creator, INSP_FORMAT("ExtBan letter \"{}\" is already in use by the {} extban from {}", - extban->GetLetter(), lit.first->second->GetName(), lit.first->second->creator->ModuleFile)); + if (extban->GetLetter()) + { + auto lit = byletter.emplace(extban->GetLetter(), extban); + if (!lit.second) + throw ModuleException(creator, INSP_FORMAT("ExtBan letter \"{}\" is already in use by the {} extban from {}", + extban->GetLetter(), lit.first->second->GetName(), lit.first->second->creator->ModuleFile)); + } auto nit = byname.emplace(extban->GetName(), extban); if (!nit.second) { - byletter.erase(extban->GetLetter()); + if (extban->GetLetter()) + byletter.erase(extban->GetLetter()); + throw ModuleException(creator, INSP_FORMAT("ExtBan name \"{}\" is already in use by the {} extban from {}", extban->GetName(), nit.first->second->GetLetter(), nit.first->second->creator->ModuleFile)); } @@ -63,7 +68,10 @@ bool ExtBanManager::Canonicalize(std::string& text) const break; case ExtBan::Format::LETTER: - text.append(1, extban->GetLetter()); + if (extban->GetLetter()) + text.push_back(extban->GetLetter()); + else + text.append(extban->GetName()); // ExtBan has no letter. break; default: @@ -153,9 +161,12 @@ ModResult ExtBanManager::GetStatus(ExtBan::ActingBase* extban, User* user, Chann void ExtBanManager::DelExtBan(ExtBan::Base* extban) { - auto lit = byletter.find(extban->GetLetter()); - if (lit != byletter.end() && lit->second->creator.ptr() == extban->creator.ptr()) - byletter.erase(lit); + if (extban->GetLetter()) + { + auto lit = byletter.find(extban->GetLetter()); + if (lit != byletter.end() && lit->second->creator.ptr() == extban->creator.ptr()) + byletter.erase(lit); + } auto nit = byname.find(extban->GetName()); if (nit != byname.end() && nit->second->creator.ptr() == extban->creator.ptr()) diff --git a/src/modules/m_spanningtree/capab.cpp b/src/modules/m_spanningtree/capab.cpp index 363da853b..85b41f56c 100644 --- a/src/modules/m_spanningtree/capab.cpp +++ b/src/modules/m_spanningtree/capab.cpp @@ -300,8 +300,8 @@ bool TreeSocket::BuildExtBanList(std::string& out) if (!extbanmgr) return false; - const ExtBan::Manager::LetterMap& extbans = extbanmgr->GetLetterMap(); - for (ExtBan::Manager::LetterMap::const_iterator iter = extbans.begin(); iter != extbans.end(); ++iter) + const auto& extbans = extbanmgr->GetNameMap(); + for (auto iter = extbans.begin(); iter != extbans.end(); ++iter) { if (iter != extbans.begin()) out.push_back(' '); @@ -317,9 +317,9 @@ bool TreeSocket::BuildExtBanList(std::string& out) break; } - out.append(extban->GetName()) - .append("=") - .push_back(extban->GetLetter()); + out.append(extban->GetName()); + if (extban->GetLetter()) + out.append("=").push_back(extban->GetLetter()); } return true; } |
