summaryrefslogtreecommitdiff
path: root/src/guild.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/guild.cpp')
-rw-r--r--src/guild.cpp60
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)