summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-02-28 15:23:03 +0300
committerAndrei Karas <akaras@inbox.ru>2013-02-28 15:23:03 +0300
commit5ae7168e1f30efa4fd61c155eaecd55ce83bea14 (patch)
tree617af9417f6b4175fdf4ba0691dd5c4ac28e427e
parent096de2a656c036a241dd5f10c2bf28ae4d4dbe5a (diff)
downloadmv-5ae7168e1f30efa4fd61c155eaecd55ce83bea14.tar.gz
mv-5ae7168e1f30efa4fd61c155eaecd55ce83bea14.tar.bz2
mv-5ae7168e1f30efa4fd61c155eaecd55ce83bea14.tar.xz
mv-5ae7168e1f30efa4fd61c155eaecd55ce83bea14.zip
improve guild related files.
-rw-r--r--src/guild.cpp11
-rw-r--r--src/guild.h2
-rw-r--r--src/guildmanager.cpp24
-rw-r--r--src/guildmanager.h18
4 files changed, 29 insertions, 26 deletions
diff --git a/src/guild.cpp b/src/guild.cpp
index c7ad34c30..09ff80cc7 100644
--- a/src/guild.cpp
+++ b/src/guild.cpp
@@ -235,9 +235,12 @@ void Guild::removeFromMembers()
const MemberList::const_iterator itr_end = mMembers.end();
while (itr != itr_end)
{
- Being *const b = actorSpriteManager->findBeing((*itr)->getID());
- if (b)
- b->removeGuild(getId());
+ if (*itr)
+ {
+ Being *const b = actorSpriteManager->findBeing((*itr)->getID());
+ if (b)
+ b->removeGuild(mId);
+ }
++itr;
}
}
@@ -319,7 +322,7 @@ void Guild::getNames(StringVect &names) const
}
}
-void Guild::addPos(const int id, std::string name)
+void Guild::addPos(const int id, const std::string &name)
{
mPositions[id] = name;
}
diff --git a/src/guild.h b/src/guild.h
index 9259ae470..c4bcb47be 100644
--- a/src/guild.h
+++ b/src/guild.h
@@ -170,7 +170,7 @@ public:
void getNames(StringVect &names) const;
- void addPos(const int id, std::string name);
+ void addPos(const int id, const std::string &name);
void sort();
diff --git a/src/guildmanager.cpp b/src/guildmanager.cpp
index 4359d2659..eb56c2fc0 100644
--- a/src/guildmanager.cpp
+++ b/src/guildmanager.cpp
@@ -108,12 +108,12 @@ void GuildManager::reload()
mTab = nullptr;
}
-void GuildManager::send(std::string msg) const
+void GuildManager::send(const std::string &msg)
{
Net::getChatHandler()->privateMessage("guild", msg);
}
-void GuildManager::chat(std::string msg)
+void GuildManager::chat(const std::string &msg)
{
if (!player_node || !mTab)
return;
@@ -238,7 +238,7 @@ Guild *GuildManager::createGuild() const
return guild;
}
-bool GuildManager::processGuildMessage(std::string msg)
+bool GuildManager::processGuildMessage(const std::string &msg)
{
const bool res = process(msg);
@@ -354,7 +354,7 @@ bool GuildManager::process(std::string msg)
// logger->log("OL");
mTempList.clear();
splitToStringVector(mTempList, msg, '#');
- if (msg.size() < 1 || msg[msg.size() - 1] != '#')
+ if (msg.empty() || msg[msg.size() - 1] != '#')
updateList();
mRequest = false;
mGotOnlineInfo = true;
@@ -364,7 +364,7 @@ bool GuildManager::process(std::string msg)
{
// logger->log("oL");
splitToStringVector(mTempList, msg, '#');
- if (msg.size() < 1 || msg[msg.size() - 1] != '#')
+ if (msg.empty() || msg[msg.size() - 1] != '#')
updateList();
mRequest = false;
mGotOnlineInfo = true;
@@ -431,7 +431,7 @@ bool GuildManager::process(std::string msg)
const size_t pos = msg.find(": ", 0);
if (pos != std::string::npos)
{
- std::string sender_name = ((pos == std::string::npos)
+ const std::string sender_name = ((pos == std::string::npos)
? "" : msg.substr(0, pos));
if (!guild->getMember(sender_name))
{
@@ -456,22 +456,22 @@ bool GuildManager::process(std::string msg)
return false;
}
-void GuildManager::kick(std::string msg) const
+void GuildManager::kick(const std::string &msg)
{
send("!remove " + msg);
}
-void GuildManager::invite(std::string msg) const
+void GuildManager::invite(const std::string &msg)
{
send("!invite " + msg);
}
-void GuildManager::leave() const
+void GuildManager::leave()
{
send("!leave");
}
-void GuildManager::notice(std::string msg) const
+void GuildManager::notice(const std::string &msg)
{
if (msg.empty())
send("!removemotd");
@@ -479,7 +479,7 @@ void GuildManager::notice(std::string msg) const
send("!setmotd " + msg);
}
-void GuildManager::clear() const
+void GuildManager::clear()
{
if (socialWindow)
{
@@ -489,7 +489,7 @@ void GuildManager::clear() const
}
}
-void GuildManager::inviteResponse(const bool response) const
+void GuildManager::inviteResponse(const bool response)
{
if (response)
send("yes");
diff --git a/src/guildmanager.h b/src/guildmanager.h
index e9b05526d..c01ee6078 100644
--- a/src/guildmanager.h
+++ b/src/guildmanager.h
@@ -41,11 +41,11 @@ class GuildManager final
static void init();
- void chat(std::string msg);
+ void chat(const std::string &msg);
- void send(std::string msg) const;
+ static void send(const std::string &msg);
- bool processGuildMessage(std::string msg);
+ bool processGuildMessage(const std::string &msg);
void getNames(StringVect &names) const;
@@ -56,23 +56,23 @@ class GuildManager final
static bool getEnableGuildBot() A_WARN_UNUSED
{ return mEnableGuildBot; }
- void kick(std::string msg) const;
+ static void kick(const std::string &msg);
- void invite(std::string msg) const;
+ static void invite(const std::string &msg);
- void leave() const;
+ static void leave();
- void notice(std::string msg) const;
+ static void notice(const std::string &msg);
void createTab(Guild *const guild);
Guild *createGuild() const A_WARN_UNUSED;
- void clear() const;
+ static void clear();
void reload();
- void inviteResponse(const bool response) const;
+ static void inviteResponse(const bool response);
bool afterRemove();