summaryrefslogtreecommitdiff
path: root/src/party.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-09-18 17:49:18 +0300
committerAndrei Karas <akaras@inbox.ru>2011-09-18 17:49:18 +0300
commit70b520b1e876f9698bb95baa2d274ea289a0c6bd (patch)
tree152c7519b0d9b8fb424af2373ec48db823a85575 /src/party.cpp
parent62ec17f6e489ec50f17219444468aeb8969dc961 (diff)
parent3b999f51c740d0541c53d223518e5e4bb482d996 (diff)
downloadplus-stripped1.1.9.18.tar.gz
plus-stripped1.1.9.18.tar.bz2
plus-stripped1.1.9.18.tar.xz
plus-stripped1.1.9.18.zip
Merge branch 'master' into strippedstripped1.1.9.18
Conflicts: src/guichan/cliprectangle.cpp src/guichan/focushandler.cpp src/guichan/gui.cpp src/guichan/include/guichan/cliprectangle.hpp src/guichan/include/guichan/inputevent.hpp src/guichan/include/guichan/keyevent.hpp src/guichan/include/guichan/mouseevent.hpp src/guichan/include/guichan/widgets/button.hpp src/guichan/include/guichan/widgets/checkbox.hpp src/guichan/include/guichan/widgets/dropdown.hpp src/guichan/include/guichan/widgets/radiobutton.hpp src/guichan/include/guichan/widgets/slider.hpp src/guichan/include/guichan/widgets/tab.hpp src/guichan/include/guichan/widgets/tabbedarea.hpp src/guichan/include/guichan/widgets/textfield.hpp src/guichan/include/guichan/widgets/window.hpp src/guichan/inputevent.cpp src/guichan/keyevent.cpp src/guichan/mouseevent.cpp src/guichan/widget.cpp src/guichan/widgets/button.cpp src/guichan/widgets/checkbox.cpp src/guichan/widgets/dropdown.cpp src/guichan/widgets/radiobutton.cpp src/guichan/widgets/slider.cpp src/guichan/widgets/tab.cpp src/guichan/widgets/tabbedarea.cpp src/guichan/widgets/textfield.cpp src/guichan/widgets/window.cpp
Diffstat (limited to 'src/party.cpp')
-rw-r--r--src/party.cpp63
1 files changed, 38 insertions, 25 deletions
diff --git a/src/party.cpp b/src/party.cpp
index f3f787807..f561ca49f 100644
--- a/src/party.cpp
+++ b/src/party.cpp
@@ -25,6 +25,8 @@
#include "debug.h"
+#include "utils/stringutils.h"
+
class SortPartyFunctor
{
public:
@@ -37,7 +39,15 @@ class SortPartyFunctor
if (p2->getLeader())
return false;
- return p1->getName() < p2->getName();
+ if (p1->getName() != p2->getName())
+ {
+ std::string s1 = p1->getName();
+ std::string s2 = p2->getName();
+ toLower(s1);
+ toLower(s2);
+ return s1 < s2;
+ }
+ return false;
}
} partySorter;
@@ -94,7 +104,7 @@ PartyMember *Party::getMember(const std::string &name) const
itr_end = mMembers.end();
while (itr != itr_end)
{
- if ((*itr)->getName() == name)
+ if ((*itr) && (*itr)->getName() == name)
return (*itr);
++itr;
@@ -116,12 +126,12 @@ void Party::removeMember(PartyMember *member)
itr_end = mMembers.end();
while (itr != itr_end)
{
- if ((*itr)->mId == member->mId &&
+ if ((*itr) && (*itr)->mId == member->mId &&
(*itr)->getName() == member->getName())
{
- PartyMember *member = (*itr);
+ PartyMember *m = (*itr);
mMembers.erase(itr);
- delete member;
+ delete m;
deleted = true;
break;
}
@@ -140,7 +150,7 @@ void Party::removeMember(int id)
itr_end = mMembers.end();
while (itr != itr_end)
{
- if ((*itr)->mId == id)
+ if ((*itr) && (*itr)->mId == id)
{
PartyMember *member = (*itr);
mMembers.erase(itr);
@@ -163,7 +173,7 @@ void Party::removeMember(const std::string &name)
itr_end = mMembers.end();
while (itr != itr_end)
{
- if ((*itr)->getName() == name)
+ if ((*itr) && (*itr)->getName() == name)
{
PartyMember *member = (*itr);
mMembers.erase(itr);
@@ -181,8 +191,9 @@ void Party::removeFromMembers()
if (!actorSpriteManager)
return;
- MemberList::iterator itr = mMembers.begin(),
- itr_end = mMembers.end();
+ MemberList::const_iterator itr = mMembers.begin();
+ MemberList::const_iterator itr_end = mMembers.end();
+
while (itr != itr_end)
{
Being *b = actorSpriteManager->findBeing((*itr)->getID());
@@ -212,11 +223,11 @@ bool Party::isMember(PartyMember *member) const
if (member->mParty > 0 && member->mParty != this)
return false;
- MemberList::const_iterator itr = mMembers.begin(),
- itr_end = mMembers.end();
+ MemberList::const_iterator itr = mMembers.begin();
+ MemberList::const_iterator itr_end = mMembers.end();
while (itr != itr_end)
{
- if ((*itr)->mId == member->mId &&
+ if ((*itr) && (*itr)->mId == member->mId &&
(*itr)->getName() == member->getName())
{
return true;
@@ -229,11 +240,11 @@ bool Party::isMember(PartyMember *member) const
bool Party::isMember(int id) const
{
- MemberList::const_iterator itr = mMembers.begin(),
- itr_end = mMembers.end();
+ MemberList::const_iterator itr = mMembers.begin();
+ MemberList::const_iterator itr_end = mMembers.end();
while (itr != itr_end)
{
- if ((*itr)->mId == id)
+ if ((*itr) && (*itr)->mId == id)
return true;
++itr;
}
@@ -243,11 +254,11 @@ bool Party::isMember(int id) const
bool Party::isMember(const std::string &name) const
{
- MemberList::const_iterator itr = mMembers.begin(),
- itr_end = mMembers.end();
+ MemberList::const_iterator itr = mMembers.begin();
+ MemberList::const_iterator itr_end = mMembers.end();
while (itr != itr_end)
{
- if ((*itr)->getName() == name)
+ if ((*itr) && (*itr)->getName() == name)
return true;
++itr;
}
@@ -258,11 +269,12 @@ bool Party::isMember(const std::string &name) const
void Party::getNames(std::vector<std::string> &names) const
{
names.clear();
- MemberList::const_iterator it = mMembers.begin(),
- it_end = mMembers.end();
+ MemberList::const_iterator it = mMembers.begin();
+ MemberList::const_iterator it_end = mMembers.end();
while (it != it_end)
{
- names.push_back((*it)->getName());
+ if (*it)
+ names.push_back((*it)->getName());
++it;
}
}
@@ -270,18 +282,19 @@ void Party::getNames(std::vector<std::string> &names) const
void Party::getNamesSet(std::set<std::string> &names) const
{
names.clear();
- MemberList::const_iterator it = mMembers.begin(),
- it_end = mMembers.end();
+ MemberList::const_iterator it = mMembers.begin();
+ MemberList::const_iterator it_end = mMembers.end();
while (it != it_end)
{
- names.insert((*it)->getName());
+ if (*it)
+ names.insert((*it)->getName());
++it;
}
}
Party *Party::getParty(short id)
{
- PartyMap::iterator it = parties.find(id);
+ PartyMap::const_iterator it = parties.find(id);
if (it != parties.end())
return it->second;
Party *party = new Party(id);