summaryrefslogtreecommitdiff
path: root/src/party.cpp
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2010-02-24 06:50:35 -0700
committerJared Adams <jaxad0127@gmail.com>2010-02-24 07:55:20 -0700
commitf6d50d0cbe12f8799e6fec844816defc8711df37 (patch)
tree344f28132bd3aa54ce058e92b4696d00f3a7bc0c /src/party.cpp
parent3adb0710b9b0262b7d7a03aa687e78c232f04d06 (diff)
downloadmana-f6d50d0cbe12f8799e6fec844816defc8711df37.tar.gz
mana-f6d50d0cbe12f8799e6fec844816defc8711df37.tar.bz2
mana-f6d50d0cbe12f8799e6fec844816defc8711df37.tar.xz
mana-f6d50d0cbe12f8799e6fec844816defc8711df37.zip
Add more to eAthena guild support
It's not complete yet, but it is closer. Also fix up handling of guild/party members. Reviewed-by: Chuck Miller
Diffstat (limited to 'src/party.cpp')
-rw-r--r--src/party.cpp71
1 files changed, 44 insertions, 27 deletions
diff --git a/src/party.cpp b/src/party.cpp
index a8e18b2d..3987f0fb 100644
--- a/src/party.cpp
+++ b/src/party.cpp
@@ -23,32 +23,19 @@
#include "beingmanager.h"
#include "player.h"
-PartyMember::PartyMember(int partyId, int id, const std::string &name):
- Avatar(name), mId(id), mLeader(false)
+PartyMember::PartyMember(Party *party, int id, const std::string &name):
+ Avatar(name), mId(id), mParty(party), mLeader(false)
{
- mParty = Party::getParty(partyId);
-
- if (beingManager)
- {
- Player *player = dynamic_cast<Player*>(beingManager->findBeing(id));
- if (player)
- {
- player->setParty(mParty);
- }
- }
}
-PartyMember::PartyMember(int PartyId, int id):
- mId(id), mLeader(false)
+PartyMember::PartyMember(Party *party, int id):
+ mId(id), mParty(party), mLeader(false)
{
- mParty = Party::getParty(PartyId);
+}
- if (beingManager)
- {
- Player *player = dynamic_cast<Player*>(beingManager->findBeing(id));
- if (player)
- player->setParty(mParty);
- }
+PartyMember::PartyMember(Party *party, const std::string &name):
+ Avatar(name), mParty(party), mLeader(false)
+{
}
Party::PartyMap Party::parties;
@@ -59,19 +46,49 @@ Party::Party(short id):
{
parties[id] = this;
}
+PartyMember *Party::addMember(int id, const std::string &name)
+{
+ PartyMember *m;
+ if ((m = getMember(id)))
+ {
+ return m;
+ }
+
+ m = new PartyMember(this, id, name);
-void Party::addMember(PartyMember *member)
+ mMembers.push_back(m);
+
+ return m;
+}
+
+PartyMember *Party::addMember(int id)
{
- if (member->mParty > 0 && member->mParty != this)
+ PartyMember *m;
+ if ((m = getMember(id)))
{
- throw "Member in another Party!";
+ return m;
}
- if (!isMember(member))
+ m = new PartyMember(this, id);
+
+ mMembers.push_back(m);
+
+ return m;
+}
+
+PartyMember *Party::addMember(const std::string &name)
+{
+ PartyMember *m;
+ if ((m = getMember(name)))
{
- mMembers.push_back(member);
- member->mParty = this;
+ return m;
}
+
+ m = new PartyMember(this, name);
+
+ mMembers.push_back(m);
+
+ return m;
}
PartyMember *Party::getMember(int id)