From d0df36406220717545221b0ed94b9ab4ebb908b3 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 2 Apr 2011 03:02:59 +0300 Subject: Some fixes after automatic code checking. --- src/party.cpp | 71 ++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 25 deletions(-) (limited to 'src/party.cpp') diff --git a/src/party.cpp b/src/party.cpp index dbf29f3ab..2b491edb9 100644 --- a/src/party.cpp +++ b/src/party.cpp @@ -106,50 +106,71 @@ void Party::removeMember(PartyMember *member) if (!member) return; - MemberList::iterator itr = mMembers.begin(), - itr_end = mMembers.end(); - while (itr != itr_end) + bool deleted = true; + while (deleted) { - if ((*itr)->mId == member->mId && - (*itr)->getName() == member->getName()) + deleted = false; + MemberList::iterator itr = mMembers.begin(), + itr_end = mMembers.end(); + while (itr != itr_end) { - PartyMember *member = (*itr); - mMembers.erase(itr); - delete member; + if ((*itr)->mId == member->mId && + (*itr)->getName() == member->getName()) + { + PartyMember *member = (*itr); + mMembers.erase(itr); + delete member; + deleted = true; + break; + } + ++itr; } - ++itr; } } void Party::removeMember(int id) { - MemberList::iterator itr = mMembers.begin(), - itr_end = mMembers.end(); - while (itr != itr_end) + bool deleted = true; + while (deleted) { - if ((*itr)->mId == id) + deleted = false; + MemberList::iterator itr = mMembers.begin(), + itr_end = mMembers.end(); + while (itr != itr_end) { - PartyMember *member = (*itr); - mMembers.erase(itr); - delete member; + if ((*itr)->mId == id) + { + PartyMember *member = (*itr); + mMembers.erase(itr); + delete member; + deleted = true; + break; + } + ++itr; } - ++itr; } } void Party::removeMember(const std::string &name) { - MemberList::iterator itr = mMembers.begin(), - itr_end = mMembers.end(); - while (itr != itr_end) + bool deleted = true; + while (deleted) { - if ((*itr)->getName() == name) + deleted = false; + MemberList::iterator itr = mMembers.begin(), + itr_end = mMembers.end(); + while (itr != itr_end) { - PartyMember *member = (*itr); - mMembers.erase(itr); - delete member; + if ((*itr)->getName() == name) + { + PartyMember *member = (*itr); + mMembers.erase(itr); + delete member; + deleted = true; + break; + } + ++itr; } - ++itr; } } -- cgit v1.2.3-70-g09d2