summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/guild.cpp30
-rw-r--r--src/guild.h11
-rw-r--r--src/party.cpp56
-rw-r--r--src/party.h18
4 files changed, 17 insertions, 98 deletions
diff --git a/src/guild.cpp b/src/guild.cpp
index d6ef80cf..029cde7f 100644
--- a/src/guild.cpp
+++ b/src/guild.cpp
@@ -29,11 +29,6 @@ GuildMember::GuildMember(Guild *guild, int id, const std::string &name):
{
}
-GuildMember::GuildMember(Guild *guild, int id):
- mId(id), mGuild(guild)
-{
-}
-
GuildMember::GuildMember(Guild *guild, const std::string &name):
Avatar(name), mId(0), mGuild(guild)
{
@@ -63,21 +58,6 @@ GuildMember *Guild::addMember(int id, const std::string &name)
return m;
}
-GuildMember *Guild::addMember(int id)
-{
- GuildMember *m;
- if ((m = getMember(id)))
- {
- return m;
- }
-
- m = new GuildMember(this, id);
-
- mMembers.push_back(m);
-
- return m;
-}
-
GuildMember *Guild::addMember(const std::string &name)
{
GuildMember *m;
@@ -93,9 +73,9 @@ GuildMember *Guild::addMember(const std::string &name)
return m;
}
-GuildMember *Guild::getMember(int id)
+GuildMember *Guild::getMember(int id) const
{
- MemberList::iterator itr = mMembers.begin(),
+ MemberList::const_iterator itr = mMembers.begin(),
itr_end = mMembers.end();
while (itr != itr_end)
{
@@ -107,13 +87,13 @@ GuildMember *Guild::getMember(int id)
return NULL;
}
-GuildMember *Guild::getMember(std::string name)
+GuildMember *Guild::getMember(const std::string &name) const
{
- MemberList::iterator itr = mMembers.begin(),
+ MemberList::const_iterator itr = mMembers.begin(),
itr_end = mMembers.end();
while (itr != itr_end)
{
- if((*itr)->getName() == name)
+ if ((*itr)->getName() == name)
{
return (*itr);
}
diff --git a/src/guild.h b/src/guild.h
index 9b0eff9c..0bee95e0 100644
--- a/src/guild.h
+++ b/src/guild.h
@@ -46,8 +46,6 @@ protected:
GuildMember(Guild *guild, int id, const std::string &name);
- GuildMember(Guild *guild, int id);
-
GuildMember(Guild *guild, const std::string &name);
int mId;
@@ -74,11 +72,6 @@ public:
/**
* Adds member to the list.
*/
- GuildMember *addMember(int id);
-
- /**
- * Adds member to the list.
- */
GuildMember *addMember(const std::string &name);
/**
@@ -86,14 +79,14 @@ public:
*
* @return the member with the given ID, or NULL if they don't exist.
*/
- GuildMember *getMember(int id);
+ GuildMember *getMember(int id) const;
/**
* Find a member by name.
*
* @return the member with the given name, or NULL if they don't exist.
*/
- GuildMember *getMember(std::string name);
+ GuildMember *getMember(const std::string &name) const;
/**
* Get the name of the guild.
diff --git a/src/party.cpp b/src/party.cpp
index 22740489..75283916 100644
--- a/src/party.cpp
+++ b/src/party.cpp
@@ -28,16 +28,6 @@ PartyMember::PartyMember(Party *party, int id, const std::string &name):
{
}
-PartyMember::PartyMember(Party *party, int id):
- mId(id), mParty(party), mLeader(false)
-{
-}
-
-PartyMember::PartyMember(Party *party, const std::string &name):
- Avatar(name), mParty(party), mLeader(false)
-{
-}
-
Party::PartyMap Party::parties;
Party::Party(short id):
@@ -67,43 +57,13 @@ PartyMember *Party::addMember(int id, const std::string &name)
return m;
}
-PartyMember *Party::addMember(int id)
-{
- PartyMember *m;
- if ((m = getMember(id)))
- {
- return m;
- }
-
- m = new PartyMember(this, id);
-
- mMembers.push_back(m);
-
- return m;
-}
-
-PartyMember *Party::addMember(const std::string &name)
+PartyMember *Party::getMember(int id) const
{
- PartyMember *m;
- if ((m = getMember(name)))
- {
- return m;
- }
-
- m = new PartyMember(this, name);
-
- mMembers.push_back(m);
-
- return m;
-}
-
-PartyMember *Party::getMember(int id)
-{
- MemberList::iterator itr = mMembers.begin(),
+ MemberList::const_iterator itr = mMembers.begin(),
itr_end = mMembers.end();
- while(itr != itr_end)
+ while (itr != itr_end)
{
- if((*itr)->mId == id)
+ if ((*itr)->mId == id)
{
return (*itr);
}
@@ -113,13 +73,13 @@ PartyMember *Party::getMember(int id)
return NULL;
}
-PartyMember *Party::getMember(std::string name)
+PartyMember *Party::getMember(const std::string &name) const
{
- MemberList::iterator itr = mMembers.begin(),
+ MemberList::const_iterator itr = mMembers.begin(),
itr_end = mMembers.end();
- while(itr != itr_end)
+ while (itr != itr_end)
{
- if((*itr)->getName() == name)
+ if ((*itr)->getName() == name)
{
return (*itr);
}
diff --git a/src/party.h b/src/party.h
index c9d26672..91ff69bb 100644
--- a/src/party.h
+++ b/src/party.h
@@ -51,10 +51,6 @@ protected:
PartyMember(Party *party, int id, const std::string &name);
- PartyMember(Party *party, int id);
-
- PartyMember(Party *party, const std::string &name);
-
int mId;
Party *mParty;
bool mLeader;
@@ -78,28 +74,18 @@ public:
PartyMember *addMember(int id, const std::string &name);
/**
- * Adds member to the list.
- */
- PartyMember *addMember(int id);
-
- /**
- * Adds member to the list.
- */
- PartyMember *addMember(const std::string &name);
-
- /**
* Find a member by ID.
*
* @return the member with the given ID, or NULL if they don't exist.
*/
- PartyMember *getMember(int id);
+ PartyMember *getMember(int id) const;
/**
* Find a member by name.
*
* @return the member with the given name, or NULL if they don't exist.
*/
- PartyMember *getMember(std::string name);
+ PartyMember *getMember(const std::string &name) const;
/**
* Get the name of the party.