summaryrefslogtreecommitdiff
path: root/src/config.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2014-05-28 12:11:45 -0400
committerAdam <Adam@anope.org>2014-05-28 12:22:39 -0400
commitf97e339314257fa37cfcab0c2289fb6812e32e85 (patch)
treea1c9d352a771e0bb7d39d42178a7246d6f2c5434 /src/config.cpp
parentf29e1cf383529a1a29f02b0669d973f5ee0b7a66 (diff)
parentba46b8e4abd8fef991732d5c52c858a229894a25 (diff)
Merge branch '2.0' into 2.1
Conflicts: .travis.yml src/config.cpp src/version.sh
Diffstat (limited to 'src/config.cpp')
-rw-r--r--src/config.cpp70
1 files changed, 40 insertions, 30 deletions
diff --git a/src/config.cpp b/src/config.cpp
index 7e918e079..2fb38107b 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -538,48 +538,58 @@ Conf::Conf() : Block("")
/* always enable icase and optimize */
if (regex_flags)
regex_flags |= std::regex::icase | std::regex::optimize;
+}
- /* apply changes from an older config? */
- if (Config)
+Conf::~Conf()
+{
+ for (unsigned i = 0; i < MyOperTypes.size(); ++i)
+ delete MyOperTypes[i];
+ for (unsigned i = 0; i < Opers.size(); ++i)
+ delete Opers[i];
+}
+
+void Conf::Post(Conf *old)
+{
+ /* Apply module changes */
+ for (unsigned i = 0; i < old->ModulesAutoLoad.size(); ++i)
+ if (std::find(this->ModulesAutoLoad.begin(), this->ModulesAutoLoad.end(), old->ModulesAutoLoad[i]) == this->ModulesAutoLoad.end())
+ ModuleManager::UnloadModule(ModuleManager::FindModule(old->ModulesAutoLoad[i]), NULL);
+ for (unsigned i = 0; i < this->ModulesAutoLoad.size(); ++i)
+ if (std::find(old->ModulesAutoLoad.begin(), old->ModulesAutoLoad.end(), this->ModulesAutoLoad[i]) == old->ModulesAutoLoad.end())
+ ModuleManager::LoadModule(this->ModulesAutoLoad[i], NULL);
+
+ /* Apply opertype changes, as non-conf opers still point to the old oper types */
+ for (unsigned i = Oper::opers.size(); i > 0; --i)
{
- /* Apply module chnages */
- for (unsigned i = 0; i < Config->ModulesAutoLoad.size(); ++i)
- if (std::find(this->ModulesAutoLoad.begin(), this->ModulesAutoLoad.end(), Config->ModulesAutoLoad[i]) == this->ModulesAutoLoad.end())
- ModuleManager::UnloadModule(ModuleManager::FindModule(Config->ModulesAutoLoad[i]), NULL);
- for (unsigned i = 0; i < this->ModulesAutoLoad.size(); ++i)
- if (std::find(Config->ModulesAutoLoad.begin(), Config->ModulesAutoLoad.end(), this->ModulesAutoLoad[i]) == Config->ModulesAutoLoad.end())
- ModuleManager::LoadModule(this->ModulesAutoLoad[i], NULL);
-
- /* Apply opertype changes, as non-conf opers still point to the old oper types */
- for (unsigned i = Oper::opers.size(); i > 0; --i)
+ Oper *o = Oper::opers[i - 1];
+
+ /* Oper's type is in the old config, so update it */
+ if (std::find(old->MyOperTypes.begin(), old->MyOperTypes.end(), o->ot) != old->MyOperTypes.end())
{
- Oper *o = Oper::opers[i - 1];
+ OperType *ot = o->ot;
+ o->ot = NULL;
+
+ for (unsigned j = 0; j < MyOperTypes.size(); ++j)
+ if (ot->GetName() == MyOperTypes[j]->GetName())
+ o->ot = MyOperTypes[j];
- /* Oper's type is in the old config, so update it */
- if (std::find(Config->MyOperTypes.begin(), Config->MyOperTypes.end(), o->ot) != Config->MyOperTypes.end())
+ if (o->ot == NULL)
{
- OperType *ot = o->ot;
- o->ot = NULL;
+ /* Oper block has lost type */
+ std::vector<Oper *>::iterator it = std::find(old->Opers.begin(), old->Opers.end(), o);
+ if (it != old->Opers.end())
+ old->Opers.erase(it);
- for (unsigned j = 0; j < MyOperTypes.size(); ++j)
- if (ot->GetName() == MyOperTypes[j]->GetName())
- o->ot = MyOperTypes[j];
+ it = std::find(this->Opers.begin(), this->Opers.end(), o);
+ if (it != this->Opers.end())
+ this->Opers.erase(it);
- if (o->ot == NULL)
- delete o; /* Oper block has lost type */
+ delete o;
}
}
}
}
-Conf::~Conf()
-{
- for (unsigned i = 0; i < MyOperTypes.size(); ++i)
- delete MyOperTypes[i];
- for (unsigned i = 0; i < Opers.size(); ++i)
- delete Opers[i];
-}
-
Block *Conf::GetModule(Module *m)
{
if (!m)