summaryrefslogtreecommitdiff
path: root/src/users.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-09 10:37:42 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-09 10:37:42 +0000
commit6d4128715da39b1e097642a64ee0bd40586d9a38 (patch)
tree72c1d36df7c59e4b39ca7210df85e18554a2d1ae /src/users.cpp
parent0f61489ddb2f54d62c6a59e169901e4a17098230 (diff)
Get rid of Server::GetUsers(chanrec) - a throwback to before chanrec could do this itself
Move: bool ChangeDisplayedHost(const char* host); bool ChangeName(const char* gecos); int CountChannels(); Into userrec git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4807 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/users.cpp')
-rw-r--r--src/users.cpp80
1 files changed, 61 insertions, 19 deletions
diff --git a/src/users.cpp b/src/users.cpp
index 929caf19c..bb3ef18e9 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -1578,23 +1578,65 @@ void userrec::WriteWallOps(const char* text, ...)
*/
bool userrec::SharesChannelWith(userrec *other)
{
- if ((!other) || (this->registered != REG_ALL) || (other->registered != REG_ALL))
- return false;
-
- /* Outer loop */
- for (std::vector<ucrec*>::const_iterator i = this->chans.begin(); i != this->chans.end(); i++)
- {
- /* Fetch the channel from the user */
- ucrec* user_channel = *i;
-
- if (user_channel->channel)
- {
- /* Eliminate the inner loop (which used to be ~equal in size to the outer loop)
- * by replacing it with a map::find which *should* be more efficient
- */
- if (user_channel->channel->HasUser(other))
- return true;
- }
- }
- return false;
+ if ((!other) || (this->registered != REG_ALL) || (other->registered != REG_ALL))
+ return false;
+
+ /* Outer loop */
+ for (std::vector<ucrec*>::const_iterator i = this->chans.begin(); i != this->chans.end(); i++)
+ {
+ /* Fetch the channel from the user */
+ ucrec* user_channel = *i;
+
+ if (user_channel->channel)
+ {
+ /* Eliminate the inner loop (which used to be ~equal in size to the outer loop)
+ * by replacing it with a map::find which *should* be more efficient
+ */
+ if (user_channel->channel->HasUser(other))
+ return true;
+ }
+ }
+ return false;
+}
+
+int userrec::CountChannels()
+{
+ int z = 0;
+ for (std::vector<ucrec*>::const_iterator i = this->chans.begin(); i != this->chans.end(); i++)
+ if ((*i)->channel)
+ z++;
+ return z;
+}
+
+bool userrec::ChangeName(const char* gecos)
+{
+ if (IS_LOCAL(this))
+ {
+ int MOD_RESULT = 0;
+ FOREACH_RESULT(I_OnChangeLocalUserGECOS,OnChangeLocalUserGECOS(this,gecos));
+ if (MOD_RESULT)
+ return false;
+ FOREACH_MOD(I_OnChangeName,OnChangeName(this,gecos));
+ }
+ strlcpy(this->fullname,gecos,MAXGECOS+1);
+ return true;
}
+
+bool userrec::ChangeDisplayedHost(const char* host)
+{
+ if (IS_LOCAL(this))
+ {
+ int MOD_RESULT = 0;
+ FOREACH_RESULT(I_OnChangeLocalUserHost,OnChangeLocalUserHost(this,host));
+ if (MOD_RESULT)
+ return false;
+ FOREACH_MOD(I_OnChangeHost,OnChangeHost(this,host));
+ }
+ strlcpy(this->dhost,host,63);
+
+ if (IS_LOCAL(this))
+ this->WriteServ("396 %s %s :is now your hidden host",this->nick,this->dhost);
+
+ return true;
+}
+