diff options
-rw-r--r-- | include/users.h | 29 | ||||
-rw-r--r-- | src/channels.cpp | 8 | ||||
-rw-r--r-- | src/cmd_invite.cpp | 2 | ||||
-rw-r--r-- | src/users.cpp | 42 |
4 files changed, 18 insertions, 63 deletions
diff --git a/include/users.h b/include/users.h index 429606344..ccfc3447a 100644 --- a/include/users.h +++ b/include/users.h @@ -57,14 +57,6 @@ enum RegistrationState { REG_ALL = 7 /* REG_NICKUSER plus next bit along */ }; -/** Holds a channel name to which a user has been invited. - */ -class Invited : public classbase -{ - public: - irc::string channel; -}; - class InspIRCd; /** Derived from Resolver, and performs user forward/reverse lookups. @@ -136,9 +128,7 @@ class ConnectClass : public classbase /** Holds a complete list of all channels to which a user has been invited and has not yet joined. */ -typedef std::vector<Invited> InvitedList; - - +typedef std::vector<irc::string> InvitedList; /** Holds a complete list of all allow and deny tags from the configuration file (connection classes) */ @@ -423,19 +413,19 @@ class userrec : public connection * @param channel A channel name to look up * @return True if the user is invited to the given channel */ - virtual bool IsInvited(irc::string &channel); + virtual bool IsInvited(const irc::string &channel); /** Adds a channel to a users invite list (invites them to a channel) * @param channel A channel name to add */ - virtual void InviteTo(irc::string &channel); + virtual void InviteTo(const irc::string &channel); /** Removes a channel from a users invite list. * This member function is called on successfully joining an invite only channel * to which the user has previously been invited, to clear the invitation. * @param channel The channel to remove the invite to */ - virtual void RemoveInvite(irc::string &channel); + virtual void RemoveInvite(const irc::string &channel); /** Returns true or false for if a user can execute a privilaged oper command. * This is done by looking up their oper type from userrec::oper, then referencing @@ -730,17 +720,6 @@ class userrec : public connection */ bool ChangeName(const char* gecos); - /** Return the total number of channels this user is on. - * @return The number of channels the user is on - */ - int CountChannels(); - - /** Modify the number of channels this user is on (used by CountChannels). - * Pass a positive number to increment the counter, or a negative number - * to decrement it. - */ - void ModChannelCount(int n); - /** Send a notice to all local users from this user * @param text The text format string to send * @param ... Format arguments diff --git a/src/channels.cpp b/src/channels.cpp index 8a857f4af..b6912e245 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -28,7 +28,6 @@ chanrec::chanrec(InspIRCd* Instance) : ServerInstance(Instance) { *name = *topic = *setby = *key = 0; created = topicset = limit = 0; - internal_userlist.clear(); memset(&modes,0,64); age = ServerInstance->Time(true); } @@ -274,11 +273,10 @@ chanrec* chanrec::JoinUser(InspIRCd* Instance, userrec *user, const char* cn, bo if (Ptr->modes[CM_INVITEONLY]) { MOD_RESULT = 0; - irc::string xname(Ptr->name); FOREACH_RESULT_I(Instance,I_OnCheckInvite,OnCheckInvite(user, Ptr)); if (!MOD_RESULT) { - if (user->IsInvited(xname)) + if (user->IsInvited(Ptr->name)) { /* user was invited to channel */ /* there may be an optional channel NOTICE here */ @@ -289,7 +287,7 @@ chanrec* chanrec::JoinUser(InspIRCd* Instance, userrec *user, const char* cn, bo return NULL; } } - user->RemoveInvite(xname); + user->RemoveInvite(Ptr->name); } if (Ptr->limit) { @@ -367,7 +365,6 @@ chanrec* chanrec::ForceChan(InspIRCd* Instance, chanrec* Ptr, userrec* user, con dummyuser->SetFd(FD_MAGIC_NUMBER); Ptr->AddUser(user); - user->ModChannelCount(1); /* Just in case they have no permissions */ user->chans[Ptr] = 0; @@ -467,7 +464,6 @@ long chanrec::PartUser(userrec *user, const char* reason) FOREACH_MOD(I_OnUserPart,OnUserPart(user, this, reason ? reason : "")); this->WriteChannel(user, "PART %s%s%s", this->name, reason ? " :" : "", reason ? reason : ""); user->chans.erase(i); - user->ModChannelCount(-1); this->RemoveAllPrefixes(user); } diff --git a/src/cmd_invite.cpp b/src/cmd_invite.cpp index 2458134f3..34ca04791 100644 --- a/src/cmd_invite.cpp +++ b/src/cmd_invite.cpp @@ -90,7 +90,7 @@ CmdResult cmd_invite::Handle (const char** parameters, int pcnt, userrec *user) InvitedList* il = user->GetInviteList(); for (InvitedList::iterator i = il->begin(); i != il->end(); i++) { - user->WriteServ("346 %s :%s",user->nick,i->channel.c_str()); + user->WriteServ("346 %s :%s",user->nick,i->c_str()); } user->WriteServ("347 %s :End of INVITE list",user->nick); } diff --git a/src/users.cpp b/src/users.cpp index 4408c1938..d67f96e4f 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -439,13 +439,11 @@ char* userrec::GetFullRealHost() return fresult; } -bool userrec::IsInvited(irc::string &channel) +bool userrec::IsInvited(const irc::string &channel) { for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++) { - irc::string compare = i->channel; - - if (compare == channel) + if (channel == *i) { return true; } @@ -458,30 +456,22 @@ InvitedList* userrec::GetInviteList() return &invites; } -void userrec::InviteTo(irc::string &channel) +void userrec::InviteTo(const irc::string &channel) { - Invited i; - i.channel = channel; - invites.push_back(i); + invites.push_back(channel); } -void userrec::RemoveInvite(irc::string &channel) +void userrec::RemoveInvite(const irc::string &channel) { ServerInstance->Log(DEBUG,"Removing invites"); - - if (invites.size()) + for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++) { - for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++) + if (channel == *i) { - irc::string compare = i->channel; - - if (compare == channel) - { - invites.erase(i); - return; - } - } - } + invites.erase(i); + return; + } + } } bool userrec::HasPermission(const std::string &command) @@ -1762,16 +1752,6 @@ bool userrec::SharesChannelWith(userrec *other) return false; } -int userrec::CountChannels() -{ - return ChannelCount; -} - -void userrec::ModChannelCount(int n) -{ - ChannelCount += n; -} - bool userrec::ChangeName(const char* gecos) { if (!strcmp(gecos, this->fullname)) |