summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-23 21:34:04 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-23 21:34:04 +0000
commitea3ba4bfd1b072b4f14fb588286eedd0ea8c1d22 (patch)
tree6f31e715d182c4045f61fd69658c5ca092ae264a
parent9f9e49509ea6d4c4ab0b70e15356d50e1376fdba (diff)
Multi-prefix FJOIN, and allowing module-defined prefixes across the network
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5002 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--include/channels.h2
-rw-r--r--include/mode.h2
-rw-r--r--src/channels.cpp20
-rw-r--r--src/mode.cpp14
-rw-r--r--src/modules/m_spanningtree.cpp60
5 files changed, 49 insertions, 49 deletions
diff --git a/include/channels.h b/include/channels.h
index 132e3ba04..35e192a4e 100644
--- a/include/channels.h
+++ b/include/channels.h
@@ -488,6 +488,8 @@ class chanrec : public Extensible
*/
const char* GetPrefixChar(userrec *user);
+ const char* GetAllPrefixChars(userrec* user);
+
/** Get the value of a users prefix on this channel.
* @param The user to look up
* @return The module or core-defined value of the users prefix.
diff --git a/include/mode.h b/include/mode.h
index 198ae0369..6c9cce160 100644
--- a/include/mode.h
+++ b/include/mode.h
@@ -426,6 +426,8 @@ class ModeParser : public classbase
*/
ModeHandler* FindMode(unsigned const char modeletter, ModeType mt);
+ ModeHandler* FindPrefix(unsigned const char pfxletter);
+
/**
* Returns a list of mode characters which are usermodes.
* This is used in the 004 numeric when users connect.
diff --git a/src/channels.cpp b/src/channels.cpp
index d417ab763..e7564c3ea 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -906,6 +906,26 @@ const char* chanrec::GetPrefixChar(userrec *user)
return px;
}
+const char* chanrec::GetAllPrefixChars(userrec* user)
+{
+ static char prefix[MAXBUF];
+ int ctr = 0;
+ *prefix = 0;
+
+ prefixlist::iterator n = prefixes.find(user);
+ if (n != prefixes.end())
+ {
+ for (std::vector<prefixtype>::iterator x = n->second.begin(); x != n->second.end(); x++)
+ {
+ prefix[ctr++] = x->first;
+ }
+ }
+
+ prefix[ctr] = 0;
+
+ return prefix;
+}
+
unsigned int chanrec::GetPrefixValue(userrec* user)
{
unsigned int mx = 0;
diff --git a/src/mode.cpp b/src/mode.cpp
index 3a0937d91..281fb6ac8 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -642,6 +642,20 @@ std::string ModeParser::ParaModeList()
return modestr;
}
+ModeHandler* ModeParser::FindPrefix(unsigned const char pfxletter)
+{
+ for (unsigned char mode = 'A'; mode <= 'z'; mode++)
+ {
+ unsigned char pos = (mode-65) | MASK_CHANNEL;
+
+ if ((modehandlers[pos]) && (modehandlers[pos]->GetPrefix() == pfxletter))
+ {
+ return modehandlers[pos];
+ }
+ }
+ return NULL;
+}
+
bool ModeParser::PrefixComparison(const prefixtype one, const prefixtype two)
{
return one.second > two.second;
diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp
index 4f3645026..1485c709a 100644
--- a/src/modules/m_spanningtree.cpp
+++ b/src/modules/m_spanningtree.cpp
@@ -1392,24 +1392,17 @@ class TreeSocket : public InspSocket
* (is this even possible?) */
if (usr && *usr)
{
- char permissions = *usr;
- switch (permissions)
+ char* permissions = usr;
+ while (*permissions != ',')
{
- case '@':
- usr++;
- mode_users[modectr++] = usr;
- strlcat(modestring,"o",MAXBUF);
- break;
- case '%':
- usr++;
- mode_users[modectr++] = usr;
- strlcat(modestring,"h",MAXBUF);
- break;
- case '+':
- usr++;
+ ModeHandler* mh = ServerInstance->Modes->FindPrefix(*permissions);
+ if (mh)
+ {
mode_users[modectr++] = usr;
- strlcat(modestring,"v",MAXBUF);
- break;
+ charlcat(modestring,mh->GetModeChar(),MAXBUF);
+ }
+ usr++;
+ permissions++;
}
who = this->Instance->FindNick(usr);
if (who)
@@ -1603,18 +1596,8 @@ class TreeSocket : public InspSocket
for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
{
- int x = c->GetStatusFlags(i->second);
- if ((x & UCMODE_HOP) && (x & UCMODE_OP))
- {
- specific_halfop.push_back(i->second);
- }
- if (((x & UCMODE_HOP) || (x & UCMODE_OP)) && (x & UCMODE_VOICE))
- {
- specific_voice.push_back(i->second);
- }
-
// The first parameter gets a : before it
- size_t ptrlen = snprintf(ptr, MAXBUF, " %s%s%s", !numusers ? ":" : "", c->GetPrefixChar(i->second), i->second->nick);
+ size_t ptrlen = snprintf(ptr, MAXBUF, " %s%s,%s", !numusers ? ":" : "", c->GetAllPrefixChars(i->second), i->second->nick);
curlen += ptrlen;
ptr += ptrlen;
@@ -1628,32 +1611,11 @@ class TreeSocket : public InspSocket
ptr = list + dlen;
ptrlen = 0;
numusers = 0;
- for (unsigned int y = 0; y < specific_voice.size(); y++)
- {
- modes.append("v");
- params.append(specific_voice[y]->nick).append(" ");
- }
- for (unsigned int y = 0; y < specific_halfop.size(); y++)
- {
- modes.append("h");
- params.append(specific_halfop[y]->nick).append(" ");
- }
}
}
+
if (numusers)
- {
this->WriteLine(list);
- for (unsigned int y = 0; y < specific_voice.size(); y++)
- {
- modes.append("v");
- params.append(specific_voice[y]->nick).append(" ");
- }
- for (unsigned int y = 0; y < specific_halfop.size(); y++)
- {
- modes.append("h");
- params.append(specific_halfop[y]->nick).append(" ");
- }
- }
for (BanList::iterator b = c->bans.begin(); b != c->bans.end(); b++)
{