aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/coremods/core_channel/extban.cpp29
-rw-r--r--src/modules/m_spanningtree/capab.cpp10
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;
}