This changes most remaining User::IsModeSet() calls to use ModeReferences for modes that were created by other modules or the core
*/
unsigned int LocalUserCount() const { return (this->local_count - this->UnregisteredUserCount()); }
- /** Number of users with a certain mode set on them
- */
- int ModeCount(const char mode);
-
/** Send a server notice to all local users
* @param text The text format string to send
* @param ... The format arguments
* @param m The user mode
* @param value On or off setting of the mode
*/
- void SetMode(unsigned char m, bool value);
void SetMode(ModeHandler* mh, bool value);
void SetMode(ModeHandler& mh, bool value) { SetMode(&mh, value); }
ChanModeReference limitmode(NULL, "limit");
ChanModeReference secretmode(NULL, "secret");
ChanModeReference privatemode(NULL, "private");
+ UserModeReference invisiblemode(NULL, "invisible");
}
Channel::Channel(const std::string &cname, time_t ts)
{
if (i->first->quitting)
continue;
- if ((!has_user) && (i->first->IsModeSet('i')))
+ if ((!has_user) && (i->first->IsModeSet(invisiblemode)))
{
/*
* user is +i, and source not on the channel, does not show
unsigned int max_global;
unsigned int invisible;
- LusersCounters()
+ LusersCounters(unsigned int inv)
: max_local(ServerInstance->Users->LocalUserCount())
, max_global(ServerInstance->Users->RegisteredUserCount())
- , invisible(ServerInstance->Users->ModeCount('i'))
+ , invisible(inv)
{
}
class ModuleLusers : public Module
{
+ UserModeReference invisiblemode;
LusersCounters counters;
CommandLusers cmd;
InvisibleWatcher mw;
+ unsigned int CountInvisible()
+ {
+ unsigned int c = 0;
+ for (user_hash::iterator i = ServerInstance->Users->clientlist->begin(); i != ServerInstance->Users->clientlist->end(); ++i)
+ {
+ User* u = i->second;
+ if (u->IsModeSet(invisiblemode))
+ c++;
+ }
+ return c;
+ }
+
public:
ModuleLusers()
- : cmd(this, counters), mw(this, counters.invisible)
+ : invisiblemode(this, "invisible")
+ , counters(CountInvisible())
+ , cmd(this, counters)
+ , mw(this, counters.invisible)
{
}
void OnPostConnect(User* user)
{
counters.UpdateMaxUsers();
- if (user->IsModeSet('i'))
+ if (user->IsModeSet(invisiblemode))
counters.invisible++;
}
void OnUserQuit(User* user, const std::string& message, const std::string& oper_message)
{
- if (user->IsModeSet('i'))
+ if (user->IsModeSet(invisiblemode))
counters.invisible--;
}
*/
class CommandWallops : public Command
{
+ UserModeReference wallopsmode;
+
public:
/** Constructor for wallops.
*/
- CommandWallops ( Module* parent) : Command(parent,"WALLOPS",1,1) { flags_needed = 'o'; syntax = "<any-text>"; }
+ CommandWallops(Module* parent)
+ : Command(parent, "WALLOPS", 1, 1)
+ , wallopsmode(parent, "wallops")
+ {
+ flags_needed = 'o';
+ syntax = "<any-text>";
+ }
+
/** Handle command.
* @param parameters The parameters to the comamnd
* @param pcnt The number of parameters passed to teh command
for (LocalUserList::const_iterator i = ServerInstance->Users->local_users.begin(); i != ServerInstance->Users->local_users.end(); i++)
{
User* t = *i;
- if (t->IsModeSet('w'))
+ if (t->IsModeSet(wallopsmode))
user->WriteTo(t,wallop);
}
bool opt_time;
ChanModeReference secretmode;
ChanModeReference privatemode;
+ UserModeReference invisiblemode;
Channel* get_first_visible_channel(User *u)
{
: Command(parent, "WHO", 1)
, secretmode(parent, "secret")
, privatemode(parent, "private")
+ , invisiblemode(parent, "invisible")
{
syntax = "<server>|<nickname>|<channel>|<realname>|<host>|0 [ohurmMiaplf]";
}
continue;
/* If we're not inside the channel, hide +i users */
- if (i->first->IsModeSet('i') && !inside && !user->HasPrivPermission("users/auspex"))
+ if (i->first->IsModeSet(invisiblemode) && !inside && !user->HasPrivPermission("users/auspex"))
continue;
}
{
if (!user->SharesChannelWith(oper))
{
- if (usingwildcards && (!oper->IsModeSet('i')) && (!user->HasPrivPermission("users/auspex")))
+ if (usingwildcards && (!oper->IsModeSet(invisiblemode)) && (!user->HasPrivPermission("users/auspex")))
continue;
}
{
if (!user->SharesChannelWith(i->second))
{
- if (usingwildcards && (i->second->IsModeSet('i')) && (!user->HasPrivPermission("users/auspex")))
+ if (usingwildcards && (i->second->IsModeSet(invisiblemode)) && (!user->HasPrivPermission("users/auspex")))
continue;
}
/* whether or not +B users are allowed to use fantasy commands */
bool AllowBots;
+ UserModeReference botmode;
void ReadAliases()
{
}
public:
+ ModuleAlias()
+ : botmode(this, "bot")
+ {
+ }
+
void init() CXX11_OVERRIDE
{
ReadAliases();
}
/* Stop here if the user is +B and allowbot is set to no. */
- if (!AllowBots && user->IsModeSet('B'))
+ if (!AllowBots && user->IsModeSet(botmode))
{
return;
}
{
OperPrefixMode opm;
HideOperWatcher hideoperwatcher;
+ UserModeReference hideopermode;
public:
ModuleOperPrefixMode()
: opm(this), hideoperwatcher(this)
+ , hideopermode(this, "hideoper")
{
}
ModResult OnUserPreJoin(LocalUser* user, Channel* chan, const std::string& cname, std::string& privs, const std::string& keygiven) CXX11_OVERRIDE
{
- if ((user->IsOper()) && (user->IsModeSet('H')))
+ if ((user->IsOper()) && (!user->IsModeSet(hideopermode)))
privs.push_back('y');
return MOD_RES_PASSTHRU;
}
{
std::vector<std::string> modechange;
modechange.push_back("");
- modechange.push_back(add ? "+y" : "-y");
+ modechange.push_back(add ? "+" : "-");
+ modechange[1].push_back(opm.GetModeChar());
modechange.push_back(user->nick);
for (UCListIter v = user->chans.begin(); v != user->chans.end(); v++)
{
void OnPostOper(User* user, const std::string& opername, const std::string& opertype) CXX11_OVERRIDE
{
- if (IS_LOCAL(user) && (!user->IsModeSet('H')))
+ if (IS_LOCAL(user) && (!user->IsModeSet(hideopermode)))
SetOperPrefix(user, true);
}
class ModuleRegOnlyCreate : public Module
{
+ UserModeReference regusermode;
+
public:
+ ModuleRegOnlyCreate()
+ : regusermode(this, "u_registered")
+ {
+ }
+
void init() CXX11_OVERRIDE
{
Implementation eventlist[] = { I_OnUserPreJoin };
if (user->IsOper())
return MOD_RES_PASSTHRU;
- if (user->IsModeSet('r'))
+ if (user->IsModeSet(regusermode))
return MOD_RES_PASSTHRU;
const AccountExtItem* ext = GetAccountExtItem();
}
}
-/* return how many users have a given mode e.g. 'a' */
-int UserManager::ModeCount(const char mode)
-{
- int c = 0;
- for(user_hash::iterator i = clientlist->begin(); i != clientlist->end(); ++i)
- {
- User* u = i->second;
- if (u->modes[mode-65])
- c++;
- }
- return c;
-}
-
void UserManager::GarbageCollect()
{
// Reset the already_sent IDs so we don't wrap it around and drop a message
return (modes[m-65]);
}
-void User::SetMode(unsigned char m, bool value)
-{
- if (!isalpha(m))
- return;
- modes[m-65] = value;
-}
-
const char* User::FormatModes(bool showparameters)
{
static std::string data;