summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/init.cpp8
-rw-r--r--src/messages.cpp11
-rw-r--r--src/modules.cpp39
3 files changed, 16 insertions, 42 deletions
diff --git a/src/init.cpp b/src/init.cpp
index 544dcbd7c..69bb88539 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -14,11 +14,6 @@
Uplink *uplink_server;
-extern void moduleAddMsgs();
-extern void moduleAddIRCDMsgs();
-
-/*************************************************************************/
-
void introduce_user(const Anope::string &user)
{
/* Watch out for infinite loops... */
@@ -379,9 +374,6 @@ void Init(int ac, char **av)
throw FatalException(ex.GetReason());
}
- /* Add Core MSG handles */
- moduleAddMsgs();
-
#ifndef _WIN32
if (!nofork)
{
diff --git a/src/messages.cpp b/src/messages.cpp
index 5378164ea..e22f856c6 100644
--- a/src/messages.cpp
+++ b/src/messages.cpp
@@ -304,10 +304,7 @@ int m_whois(const Anope::string &source, const Anope::string &who)
return MOD_CONT;
}
-/* *INDENT-OFF* */
-void moduleAddMsgs()
-{
- Anope::AddMessage("STATS", m_stats);
- Anope::AddMessage("TIME", m_time);
- Anope::AddMessage("VERSION", m_version);
-}
+Message message_stats("STATS", m_stats);
+Message message_time("TIME", m_time);
+Message message_verssion("VERSION", m_version);
+
diff --git a/src/modules.cpp b/src/modules.cpp
index 902b940db..0f6771c3a 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -87,49 +87,34 @@ Module *FindModule(const Anope::string &name)
return NULL;
}
-/** Add a message to Anope
- * @param name The message name as sent by the IRCd
- * @param func A callback function that will be called when this message is received
- * @return The new message object
+/** Message constructor, adds the message to Anope
+ * @param n The message name
+ * @param f A callback function
*/
-Message *Anope::AddMessage(const Anope::string &name, bool (*func)(const Anope::string &source, const std::vector<Anope::string> &params))
+Message::Message(const Anope::string &n, bool (*f)(const Anope::string &, const std::vector<Anope::string> &)) : name(n), func(f)
{
- Message *m = new Message();
-
- m->name = name;
- m->func = func;
-
- MessageMap.insert(std::make_pair(m->name, m));
-
- return m;
+ MessageMap.insert(std::make_pair(this->name, this));
}
-/** Deletes a message from Anope
- * XXX Im not sure what will happen if this function is called indirectly from a message function pointed to by this message and there
- * is more than one hook for this message.. must check
- * @param m The message
- * @return true if the message was found and deleted, else false
+/** Message destructor
*/
-bool Anope::DelMessage(Message *m)
+Message::~Message()
{
- message_map::iterator it = MessageMap.find(m->name);
+ message_map::iterator it = MessageMap.find(this->name);
if (it == MessageMap.end())
- return false;
+ return;
- message_map::iterator upper = MessageMap.upper_bound(m->name);
+ message_map::iterator upper = MessageMap.upper_bound(this->name);
for (; it != upper; ++it)
{
- if (it->second == m)
+ if (it->second == this)
{
- delete m;
MessageMap.erase(it);
- return true;
+ break;
}
}
-
- return false;
}
/** Find message in the message table