diff options
author | Roderic Morris <roderic@ccs.neu.edu> | 2008-06-03 16:29:11 +0000 |
---|---|---|
committer | Roderic Morris <roderic@ccs.neu.edu> | 2008-06-03 16:29:11 +0000 |
commit | 0fdbf1d62c1add8800ffc7171a1911e1e243ac2a (patch) | |
tree | c22e6d658d908d3050cfe3dd5970f356e28aa465 /src/channel.cpp | |
parent | d4e8401e55c7bc3f5c8545b66167e8c3bf3cd380 (diff) | |
download | mana-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.cpp | 38 |
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); } |