summaryrefslogtreecommitdiff
path: root/src/guild.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/guild.cpp')
-rw-r--r--src/guild.cpp42
1 files changed, 28 insertions, 14 deletions
diff --git a/src/guild.cpp b/src/guild.cpp
index 37cf6ef8..b8b277e5 100644
--- a/src/guild.cpp
+++ b/src/guild.cpp
@@ -22,19 +22,19 @@
#include "guild.h"
GuildMember::GuildMember(int guildId, int id, const std::string &name):
- mName(name), mId(id), mOnline(false)
+ Avatar(name), mId(id)
{
mGuild = Guild::getGuild(guildId);
}
GuildMember::GuildMember(int guildId, int id):
- mId(id), mOnline(false)
+ mId(id)
{
mGuild = Guild::getGuild(guildId);
}
GuildMember::GuildMember(int guildId, const std::string &name):
- mName(name), mId(0), mOnline(false)
+ Avatar(name), mId(0)
{
mGuild = Guild::getGuild(guildId);
}
@@ -80,7 +80,7 @@ GuildMember *Guild::getMember(std::string name)
itr_end = mMembers.end();
while (itr != itr_end)
{
- if ((*itr)->mName == name)
+ if((*itr)->getName() == name)
{
return (*itr);
}
@@ -96,7 +96,8 @@ void Guild::removeMember(GuildMember *member)
itr_end = mMembers.end();
while (itr != itr_end)
{
- if ((*itr)->mId == member->mId && (*itr)->mName == member->mName)
+ if((*itr)->mId == member->mId &&
+ (*itr)->getName() == member->getName())
{
mMembers.erase(itr);
}
@@ -122,7 +123,7 @@ void Guild::removeMember(const std::string &name)
itr_end = mMembers.end();
while (itr != itr_end)
{
- if ((*itr)->mName == name)
+ if((*itr)->getName() == name)
{
mMembers.erase(itr);
}
@@ -130,13 +131,9 @@ void Guild::removeMember(const std::string &name)
}
}
-std::string Guild::getElementAt(int index)
+Avatar *Guild::getAvatarAt(int index)
{
- GuildMember *m = mMembers[index];
- if (m->mOnline)
- return "* " + m->mName;
- else
- return m->mName;
+ return mMembers[index];
}
void Guild::setRights(short rights)
@@ -155,8 +152,11 @@ bool Guild::isMember(GuildMember *member) const
itr_end = mMembers.end();
while (itr != itr_end)
{
- if ((*itr)->mId == member->mId && (*itr)->mName == member->mName)
+ if ((*itr)->mId == member->mId &&
+ (*itr)->getName() == member->getName())
+ {
return true;
+ }
++itr;
}
@@ -183,14 +183,28 @@ bool Guild::isMember(const std::string &name) const
itr_end = mMembers.end();
while (itr != itr_end)
{
- if ((*itr)->mName == name)
+ if ((*itr)->getName() == name)
+ {
return true;
+ }
++itr;
}
return false;
}
+void Guild::getNames(std::vector<std::string> &names) const
+{
+ names.clear();
+ MemberList::const_iterator it = mMembers.begin(),
+ it_end = mMembers.end();
+ while (it != it_end)
+ {
+ names.push_back((*it)->getName());
+ ++it;
+ }
+}
+
Guild *Guild::getGuild(int id)
{
GuildMap::iterator it = guilds.find(id);