diff options
| author | 2024-10-16 12:03:52 +0100 | |
|---|---|---|
| committer | 2024-10-16 12:25:20 +0100 | |
| commit | fc9d49641f4308089abb3e61764895beb148fdff (patch) | |
| tree | 9525d9908f93ea5e6c993364fa87ff31ee3a7afc /src/coremods | |
| parent | Allow ConfigTag::getCharacter to return NUL for an empty field. (diff) | |
Add support for extbans without letters.
Diffstat (limited to 'src/coremods')
| -rw-r--r-- | src/coremods/core_channel/extban.cpp | 29 |
1 files changed, 20 insertions, 9 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()) |
