diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-08-03 11:17:03 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-08-03 11:17:03 +0000 |
commit | c6934754b0cb10f6510f98fb3668a5effbbe97a5 (patch) | |
tree | 2e9fececaf5d8d08f7e390b7b9dbc873685272bd | |
parent | 7da8ae070688fe8921edcd615d22d6cdd602459f (diff) |
Dynamically generate 004 numeric from the modehandler list
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4665 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | include/mode.h | 6 | ||||
-rw-r--r-- | src/mode.cpp | 48 | ||||
-rw-r--r-- | src/users.cpp | 2 |
3 files changed, 55 insertions, 1 deletions
diff --git a/include/mode.h b/include/mode.h index 4ec7cef4c..6d31d580e 100644 --- a/include/mode.h +++ b/include/mode.h @@ -375,6 +375,12 @@ class ModeParser : public classbase * @returns a pointer to a ModeHandler class, or NULL of there isnt a handler for the given mode */ ModeHandler* FindMode(unsigned const char modeletter, ModeType mt); + + std::string UserModeList(); + + std::string ChannelModeList(); + + std::string ParaModeList(); }; /** diff --git a/src/mode.cpp b/src/mode.cpp index 6507c6d26..807675e02 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -574,6 +574,54 @@ ModeHandler* ModeParser::FindMode(unsigned const char modeletter, ModeType mt) return modehandlers[pos]; } +std::string ModeParser::UserModeList() +{ + char modestr[256]; + int pointer = 0; + + for (unsigned char mode = 'A'; mode <= 'z'; mode++) + { + unsigned char pos = (mode-65) | MASK_USER; + + if (modehandlers[pos]) + modestr[pointer++] = mode; + } + modestr[pointer++] = 0; + return modestr; +} + +std::string ModeParser::ChannelModeList() +{ + char modestr[256]; + int pointer = 0; + + for (unsigned char mode = 'A'; mode <= 'z'; mode++) + { + unsigned char pos = (mode-65) | MASK_CHANNEL; + + if (modehandlers[pos]) + modestr[pointer++] = mode; + } + modestr[pointer++] = 0; + return modestr; +} + +std::string ModeParser::ParaModeList() +{ + char modestr[256]; + int pointer = 0; + + for (unsigned char mode = 'A'; mode <= 'z'; mode++) + { + unsigned char pos = (mode-65) | MASK_CHANNEL; + + if ((modehandlers[pos]) && (modehandlers[pos]->GetNumParams(true))) + modestr[pointer++] = mode; + } + modestr[pointer++] = 0; + return modestr; +} + bool ModeParser::AddModeWatcher(ModeWatcher* mw) { unsigned char mask = 0; diff --git a/src/users.cpp b/src/users.cpp index fcdba65ca..ced542d3c 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -992,7 +992,7 @@ void FullConnectUser(userrec* user, CullList* Goners) WriteServ(user->fd,"001 %s :Welcome to the %s IRC Network %s!%s@%s",user->nick,Config->Network,user->nick,user->ident,user->host); WriteServ(user->fd,"002 %s :Your host is %s, running version %s",user->nick,Config->ServerName,VERSION); WriteServ(user->fd,"003 %s :This server was created %s %s",user->nick,__TIME__,__DATE__); - WriteServ(user->fd,"004 %s %s %s iowghrasxRVSCWBG lvhopsmntikrcaqbegIOLQRSKVHGCNT vhobeIaqglk",user->nick,Config->ServerName,VERSION); + WriteServ(user->fd,"004 %s %s %s %s %s %s",user->nick,Config->ServerName,VERSION,ServerInstance->ModeGrok->UserModeList().c_str(),ServerInstance->ModeGrok->ChannelModeList().c_str(),+ServerInstance->ModeGrok->ParaModeList().c_str()); // anfl @ #ratbox, efnet reminded me that according to the RFC this cant contain more than 13 tokens per line... // so i'd better split it :) |