summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/inspircd.cpp1
-rw-r--r--src/modules.cpp29
2 files changed, 14 insertions, 16 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index cccf3fe89..b3c4ca27d 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -347,6 +347,7 @@ InspIRCd::InspIRCd(int argc, char** argv) :
this->SNO = new SnomaskManager;
this->BanCache = new BanCacheManager;
this->Modules = new ModuleManager();
+ dynamic_reference_base::reset_all();
this->stats = new serverstats();
this->Timers = new TimerManager;
this->Parser = new CommandParser;
diff --git a/src/modules.cpp b/src/modules.cpp
index 56f50eb29..b09639b2e 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -37,13 +37,15 @@
#endif
static std::vector<dynamic_reference_base*>* dynrefs = NULL;
+static bool dynref_init_complete = false;
void dynamic_reference_base::reset_all()
{
+ dynref_init_complete = true;
if (!dynrefs)
return;
for(unsigned int i = 0; i < dynrefs->size(); i++)
- (*dynrefs)[i]->ClearCache();
+ (*dynrefs)[i]->resolve();
}
// Version is a simple class for holding a modules version number
@@ -449,6 +451,7 @@ void ModuleManager::AddService(ServiceProvider& item)
DataProviders.insert(std::make_pair(item.name.substr(0, slash), &item));
DataProviders.insert(std::make_pair(item.name.substr(slash + 1), &item));
}
+ dynamic_reference_base::reset_all();
return;
}
default:
@@ -505,6 +508,8 @@ dynamic_reference_base::dynamic_reference_base(Module* Creator, const std::strin
if (!dynrefs)
dynrefs = new std::vector<dynamic_reference_base*>;
dynrefs->push_back(this);
+ if (dynref_init_complete)
+ resolve();
}
dynamic_reference_base::~dynamic_reference_base()
@@ -530,24 +535,16 @@ dynamic_reference_base::~dynamic_reference_base()
void dynamic_reference_base::SetProvider(const std::string& newname)
{
name = newname;
- ClearCache();
-}
-
-void dynamic_reference_base::lookup()
-{
- if (!*this)
- throw ModuleException("Dynamic reference to '" + name + "' failed to resolve");
+ resolve();
}
-dynamic_reference_base::operator bool()
+void dynamic_reference_base::resolve()
{
- if (!value)
- {
- std::multimap<std::string, ServiceProvider*>::iterator i = ServerInstance->Modules->DataProviders.find(name);
- if (i != ServerInstance->Modules->DataProviders.end())
- value = static_cast<DataProvider*>(i->second);
- }
- return (value != NULL);
+ std::multimap<std::string, ServiceProvider*>::iterator i = ServerInstance->Modules->DataProviders.find(name);
+ if (i != ServerInstance->Modules->DataProviders.end())
+ value = static_cast<DataProvider*>(i->second);
+ else
+ value = NULL;
}
void InspIRCd::SendMode(const std::vector<std::string>& parameters, User *user)