diff options
author | Jared Adams <jaxad0127@gmail.com> | 2010-02-24 06:50:35 -0700 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2010-02-24 07:55:20 -0700 |
commit | f6d50d0cbe12f8799e6fec844816defc8711df37 (patch) | |
tree | 344f28132bd3aa54ce058e92b4696d00f3a7bc0c /src/guild.cpp | |
parent | 3adb0710b9b0262b7d7a03aa687e78c232f04d06 (diff) | |
download | mana-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/guild.cpp')
-rw-r--r-- | src/guild.cpp | 60 |
1 files changed, 45 insertions, 15 deletions
diff --git a/src/guild.cpp b/src/guild.cpp index b4ecaa7e..30c004bc 100644 --- a/src/guild.cpp +++ b/src/guild.cpp @@ -24,22 +24,19 @@ #include "beingmanager.h" #include "player.h" -GuildMember::GuildMember(int guildId, int id, const std::string &name): - Avatar(name), mId(id) +GuildMember::GuildMember(Guild *guild, int id, const std::string &name): + Avatar(name), mId(id), mGuild(guild) { - mGuild = Guild::getGuild(guildId); } -GuildMember::GuildMember(int guildId, int id): - mId(id) +GuildMember::GuildMember(Guild *guild, int id): + mId(id), mGuild(guild) { - mGuild = Guild::getGuild(guildId); } -GuildMember::GuildMember(int guildId, const std::string &name): - Avatar(name), mId(0) +GuildMember::GuildMember(Guild *guild, const std::string &name): + Avatar(name), mId(0), mGuild(guild) { - mGuild = Guild::getGuild(guildId); } Guild::GuildMap Guild::guilds; @@ -51,16 +48,49 @@ Guild::Guild(short id): guilds[id] = this; } -void Guild::addMember(GuildMember *member) +GuildMember *Guild::addMember(int id, const std::string &name) { - if (member->mGuild > 0 && member->mGuild != this) - throw "Member in another guild!"; + GuildMember *m; + if ((m = getMember(id))) + { + return m; + } + + m = new GuildMember(this, id, name); + + mMembers.push_back(m); - if (!isMember(member)) + return m; +} + +GuildMember *Guild::addMember(int id) +{ + GuildMember *m; + if ((m = getMember(id))) { - mMembers.push_back(member); - member->mGuild = this; + return m; } + + m = new GuildMember(this, id); + + mMembers.push_back(m); + + return m; +} + +GuildMember *Guild::addMember(const std::string &name) +{ + GuildMember *m; + if ((m = getMember(name))) + { + return m; + } + + m = new GuildMember(this, name); + + mMembers.push_back(m); + + return m; } GuildMember *Guild::getMember(int id) |