*/
#include "inspircd.h"
-#include "configreader.h"
-#include "users.h"
-#include "channels.h"
-#include "modules.h"
#include "commands/cmd_whois.h"
#include "commands/cmd_stats.h"
#include "socket.h"
/* $ModDep: m_spanningtree/timesynctimer.h m_spanningtree/resolvers.h m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h */
+bool SpanningTreeUtilities::IsSID(const std::string &str)
+{
+ /* Returns true if the string given is exactly 3 characters long,
+ * starts with a digit, and has no '.' in the other 2
+ */
+ return ((str.length() == 3) && isdigit(str[0]) && (str[1] != '.' && str[2] != '.'));
+}
+
/** Yay for fast searches!
* This is hundreds of times faster than recursion
* or even scanning a linked list, especially when
*/
TreeServer* SpanningTreeUtilities::FindServer(const std::string &ServerName)
{
+ if (IsSID(ServerName))
+ return this->FindServerID(ServerName);
+
server_hash::iterator iter = serverlist.find(ServerName.c_str());
if (iter != serverlist.end())
{
{
Bindings.clear();
- std::string OurSID;
-
- OurSID += (char)((Instance->Config->sid / 100) + 48);
- OurSID += (char)((Instance->Config->sid / 10) % 10 + 48);
- OurSID += (char)(Instance->Config->sid % 10 + 48);
-
lines_to_apply = 0;
ServerInstance->Log(DEBUG, "SpanningTreeUtilities: SID: %s", OurSID.c_str());
- this->TreeRoot = new TreeServer(this, ServerInstance, ServerInstance->Config->ServerName, ServerInstance->Config->ServerDesc, OurSID);
+ this->TreeRoot = new TreeServer(this, ServerInstance, ServerInstance->Config->ServerName, ServerInstance->Config->ServerDesc, ServerInstance->Config->GetSID());
modulelist* ml = ServerInstance->FindInterface("InspSocketHook");