*/
ModeType m_type;
- /** Number of items with this mode set on them
- */
- unsigned int count;
-
/** The prefix char needed on channel to use this mode,
* only checked for channel modes
*/
* value for this mode prefix.
*/
inline char GetPrefix() const { return prefix; }
- /** Get number of items with this mode set on them
- */
- virtual unsigned int GetCount();
- /** Adjust usage count returned by GetCount
- */
- virtual void ChangeCount(int modifier);
/**
* Get the 'value' of this modes prefix.
* determines which to display when there are multiple.
{
public:
ModeUserInvisible();
- unsigned int GetCount();
};
public:
ModeUserOperator();
ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding);
- unsigned int GetCount();
};
{
public:
ModeUserWallops();
- unsigned int GetCount();
};
*/
std::string cachedip;
- /** When we erase the user (in the destructor),
- * we call this method to subtract one from all
- * mode characters this user is making use of.
- */
- void DecrementModes();
public:
/** Hostname of connection.
ModeHandler::ModeHandler(Module* Creator, const std::string& Name, char modeletter, ParamSpec Params, ModeType type)
: ServiceProvider(Creator, Name, type == MODETYPE_CHANNEL ? SERVICE_CMODE : SERVICE_UMODE), m_paramtype(TR_TEXT),
parameters_taken(Params), mode(modeletter), prefix(0), oper(false),
- list(false), m_type(type), count(0), levelrequired(HALFOP_VALUE)
+ list(false), m_type(type), levelrequired(HALFOP_VALUE)
{
}
return 0;
}
-unsigned int ModeHandler::GetCount()
-{
- return 0;
-}
-
-void ModeHandler::ChangeCount(int modifier)
-{
- count += modifier;
- ServerInstance->Logs->Log("MODE", DEBUG,"Change count for mode %c is now %d", mode, count);
-}
-
int ModeHandler::GetNumParams(bool adding)
{
switch (parameters_taken)
if (ma != MODEACTION_ALLOW)
return ma;
- // TODO this count may not be reliable
- mh->ChangeCount(adding ? 1 : -1);
-
for (ModeWatchIter watchers = modewatchers[handler_id].begin(); watchers != modewatchers[handler_id].end(); watchers++)
(*watchers)->AfterMode(user, targetuser, chan, parameter, adding, type);
ModeUserInvisible::ModeUserInvisible() : SimpleUserModeHandler(NULL, "invisible", 'i')
{
}
-
-unsigned int ModeUserInvisible::GetCount()
-{
- return count;
-}
return MODEACTION_ALLOW;
}
-
-unsigned int ModeUserOperator::GetCount()
-{
- return count;
-}
ModeUserWallops::ModeUserWallops() : SimpleUserModeHandler(NULL, "wallops", 'w')
{
}
-
-unsigned int ModeUserWallops::GetCount()
-{
- return count;
-}
else
mh->OnModeChange(_new, _new, NULL, empty, true);
_new->SetMode(*v, true);
- mh->ChangeCount(1);
}
else
{
/* return how many users have a given mode e.g. 'a' */
int UserManager::ModeCount(const char mode)
{
- ModeHandler* mh = ServerInstance->Modes->FindMode(mode, MODETYPE_USER);
-
- if (mh)
- return mh->GetCount();
- else
- return 0;
+ 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;
}
return data;
}
-void User::DecrementModes()
-{
- ServerInstance->Logs->Log("USERS", DEBUG, "DecrementModes()");
- for (unsigned char n = 'A'; n <= 'z'; n++)
- {
- if (modes[n-65])
- {
- ServerInstance->Logs->Log("USERS", DEBUG,"DecrementModes() found mode %c", n);
- ModeHandler* mh = ServerInstance->Modes->FindMode(n, MODETYPE_USER);
- if (mh)
- {
- ServerInstance->Logs->Log("USERS", DEBUG,"Found handler %c and call ChangeCount", n);
- mh->ChangeCount(-1);
- }
- }
- }
-}
-
User::User(const std::string &uid, const std::string& sid, int type)
: uuid(uid), server(sid), usertype(type)
{
PurgeEmptyChannels();
this->InvalidateCache();
- this->DecrementModes();
if (client_sa.sa.sa_family != AF_UNSPEC)
ServerInstance->Users->RemoveCloneCounts(this);