aboutsummaryrefslogtreecommitdiff
path: root/src/modules/m_hidemode.cpp
diff options
context:
space:
mode:
authorGravatar linuxdaemon2018-12-18 19:06:56 -0600
committerGravatar Peter Powell2018-12-19 01:06:56 +0000
commit4fbd6681fedbff9b4cb04cc774f785cbe8b5c35b (patch)
tree9df58ec3e4cf2c191b4ae0051118606957d89db6 /src/modules/m_hidemode.cpp
parentFix not propagating rehashes properly across the network. (diff)
Make more modules rehash atomically (#1535)
Have each module validate the values it loads before setting them, so any errors don't result in partial application of the configs
Diffstat (limited to 'src/modules/m_hidemode.cpp')
-rw-r--r--src/modules/m_hidemode.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/modules/m_hidemode.cpp b/src/modules/m_hidemode.cpp
index d6ae05801..d5ac57115 100644
--- a/src/modules/m_hidemode.cpp
+++ b/src/modules/m_hidemode.cpp
@@ -37,20 +37,24 @@ class Settings
void Load()
{
- rankstosee.clear();
+ RanksToSeeMap newranks;
ConfigTagList tags = ServerInstance->Config->ConfTags("hidemode");
for (ConfigIter i = tags.first; i != tags.second; ++i)
{
ConfigTag* tag = i->second;
- std::string modename = tag->getString("mode");
- unsigned int rank = tag->getInt("rank", 0, 0);
- if (!modename.empty() && rank)
- {
- ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Hiding the %s mode from users below rank %u", modename.c_str(), rank);
- rankstosee.insert(std::make_pair(modename, rank));
- }
+ const std::string modename = tag->getString("mode");
+ if (modename.empty())
+ throw ModuleException("<hidemode:mode> is empty at " + tag->getTagLocation());
+
+ unsigned int rank = tag->getUInt("rank", 0);
+ if (!rank)
+ throw ModuleException("<hidemode:rank> must be greater than 0 at " + tag->getTagLocation());
+
+ ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Hiding the %s mode from users below rank %u", modename.c_str(), rank);
+ newranks.insert(std::make_pair(modename, rank));
}
+ rankstosee.swap(newranks);
}
};