]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules.cpp
Decide that it wasn't quite appropriate :(
[user/henk/code/inspircd.git] / src / modules.cpp
index b1ac75f8f310be72f42471100c02fbf40929282e..9b6a0d826a5afdc3d10c8adb6035c2ffce3dfa42 100644 (file)
@@ -391,6 +391,34 @@ void Server::DelSocket(InspSocket* sock)
        }
 }
 
+long Server::GetChannelCount()
+{
+       return (long)chanlist.size();
+}
+
+/* This is ugly, yes, but hash_map's arent designed to be
+ * addressed in this manner, and this is a bit of a kludge.
+ * Luckily its a specialist function and rarely used by
+ * many modules (in fact, it was specially created to make
+ * m_safelist possible, initially).
+ */
+
+chanrec* Server::GetChannelIndex(long index)
+{
+       int target = 0;
+       for (chan_hash::iterator n = chanlist.begin(); n != chanlist.end(); n++, target++)
+       {
+               if (index == target)
+                       return n->second;
+       }
+       return NULL;
+}
+
+void Server::AddTimer(InspTimer* T)
+{
+       ::AddTimer(T);
+}
+
 void Server::SendOpers(std::string s)
 {
        WriteOpers("%s",s.c_str());
@@ -475,7 +503,11 @@ void Server::Log(int level, std::string s)
 
 void Server::AddCommand(command_t *f)
 {
-       ServerInstance->Parser->CreateCommand(f);
+       if (!ServerInstance->Parser->CreateCommand(f))
+       {
+               ModuleException err("Command "+std::string(f->command)+" already exists.");
+               throw (err);
+       }
 }
 
 void Server::SendMode(char **parameters, int pcnt, userrec *user)
@@ -619,24 +651,28 @@ bool Server::AddExtendedMode(char modechar, int type, bool requires_oper, int pa
        {
                if (type == MT_SERVER)
                {
-                       log(DEBUG,"*** API ERROR *** Modes of type MT_SERVER are reserved for future expansion");
+                       ModuleException e("Modes of type MT_SERVER are reserved for future expansion");
+                       throw(e);
                        return false;
                }
                if (((params_when_on>0) || (params_when_off>0)) && (type == MT_CLIENT))
                {
-                       log(DEBUG,"*** API ERROR *** Parameters on MT_CLIENT modes are not supported");
+                       ModuleException e("Parameters on MT_CLIENT modes are not supported");
+                       throw(e);
                        return false;
                }
                if ((params_when_on>1) || (params_when_off>1))
                {
-                       log(DEBUG,"*** API ERROR *** More than one parameter for an MT_CHANNEL mode is not yet supported");
+                       ModuleException e("More than one parameter for an MT_CHANNEL mode is not yet supported");
+                       throw(e);
                        return false;
                }
                return DoAddExtendedMode(modechar,type,requires_oper,params_when_on,params_when_off);
        }
        else
        {
-               log(DEBUG,"*** API ERROR *** Muppet modechar detected.");
+               ModuleException e("Muppet modechar detected.");
+               throw(e);
        }
        return false;
 }