summaryrefslogtreecommitdiff
path: root/src/channel.cpp
diff options
context:
space:
mode:
authorRoderic Morris <roderic@ccs.neu.edu>2008-06-03 16:29:11 +0000
committerRoderic Morris <roderic@ccs.neu.edu>2008-06-03 16:29:11 +0000
commit0fdbf1d62c1add8800ffc7171a1911e1e243ac2a (patch)
treec22e6d658d908d3050cfe3dd5970f356e28aa465 /src/channel.cpp
parentd4e8401e55c7bc3f5c8545b66167e8c3bf3cd380 (diff)
downloadmana-0fdbf1d62c1add8800ffc7171a1911e1e243ac2a.tar.gz
mana-0fdbf1d62c1add8800ffc7171a1911e1e243ac2a.tar.bz2
mana-0fdbf1d62c1add8800ffc7171a1911e1e243ac2a.tar.xz
mana-0fdbf1d62c1add8800ffc7171a1911e1e243ac2a.zip
channel announcements and leave / enter messages, chat code refactoring
Diffstat (limited to 'src/channel.cpp')
-rw-r--r--src/channel.cpp38
1 files changed, 18 insertions, 20 deletions
diff --git a/src/channel.cpp b/src/channel.cpp
index 3204b3b2..2bebcf51 100644
--- a/src/channel.cpp
+++ b/src/channel.cpp
@@ -21,35 +21,33 @@
* $Id$
*/
+#include <algorithm>
#include "channel.h"
-Channel::Channel(short id) :
-mID(id)
+Channel::Channel(short id,
+ const std::string &name,
+ const std::string &announcement) :
+ mId(id),
+ mName(name),
+ mAnnouncement(announcement)
{
}
-std::string Channel::getName() const
+void Channel::addUser(const std::string &user)
{
- return mName;
+ // Check if the user already exists in the channel
+ ChannelUsers::const_iterator i = mUserList.begin(),
+ i_end = mUserList.end();
+ if (std::find(i, i_end, user) != i_end) return;
+ mUserList.push_back(user);
}
-void Channel::setName(const std::string &channelName)
+void Channel::removeUser(const std::string &user)
{
- mName = channelName;
-}
-
-int Channel::getUserListSize() const
-{
- return userList.size();
-}
-
-std::string Channel::getUser(unsigned int id) const
-{
- if(id <= userList.size())
- {
- return userList[id];
- }
- return "";
+ ChannelUsers::iterator i_end = mUserList.end(),
+ i = std::find(mUserList.begin(), i_end, user);
+ if (i == i_end) return;
+ mUserList.erase(i);
}