summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/net/tmwa/partyhandler.cpp26
-rw-r--r--src/party.cpp12
-rw-r--r--src/party.h3
3 files changed, 40 insertions, 1 deletions
diff --git a/src/net/tmwa/partyhandler.cpp b/src/net/tmwa/partyhandler.cpp
index 77fbde20e..bd9766c4b 100644
--- a/src/net/tmwa/partyhandler.cpp
+++ b/src/net/tmwa/partyhandler.cpp
@@ -87,11 +87,23 @@ void PartyHandler::handleMessage(Net::MessageIn &msg)
break;
case SMSG_PARTY_INFO:
{
+ bool oldParty = false;
+ std::set<std::string> names;
if (!taParty)
{
logger->log1("error: party empty in SMSG_PARTY_INFO");
taParty = Party::getParty(1);
}
+ if (taParty)
+ {
+ if (taParty->getNumberOfElements() > 1)
+ {
+ oldParty = true;
+
+ taParty->getNamesSet(names);
+ }
+ }
+
if (!player_node)
logger->log1("error: player_node==0 in SMSG_PARTY_INFO");
@@ -119,7 +131,19 @@ void PartyHandler::handleMessage(Net::MessageIn &msg)
if (taParty)
{
- PartyMember *member = taParty->addMember(id, nick);
+ PartyMember *member = 0;
+ if (oldParty)
+ {
+ //member = taParty->getMember(id);
+ if (partyTab && names.find(nick) == names.end())
+ {
+ partyTab->chatLog(strprintf(
+ _("%s has join your party."),
+ nick.c_str()), BY_SERVER);
+ }
+ }
+ member = taParty->addMember(id, nick);
+
if (member)
{
member->setLeader(leader);
diff --git a/src/party.cpp b/src/party.cpp
index 812c9ff07..dbf29f3ab 100644
--- a/src/party.cpp
+++ b/src/party.cpp
@@ -244,6 +244,18 @@ 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();
+ while (it != it_end)
+ {
+ names.insert((*it)->getName());
+ ++it;
+ }
+}
+
Party *Party::getParty(short id)
{
PartyMap::iterator it = parties.find(id);
diff --git a/src/party.h b/src/party.h
index 359f0a6b3..581410f7f 100644
--- a/src/party.h
+++ b/src/party.h
@@ -29,6 +29,7 @@
#include "utils/dtor.h"
#include <map>
+#include <set>
#include <string>
#include <vector>
@@ -144,6 +145,8 @@ public:
void getNames(std::vector<std::string> &names) const;
+ void getNamesSet(std::set<std::string> &names) const;
+
void sort();
static Party *getParty(short id);