diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-03-10 20:17:29 +0200 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-03-11 00:48:34 +0200 |
commit | c030596364968f86f88546d3890e5b45929db47a (patch) | |
tree | 859f4e8bb525d8c2d5ec2569f1da498d8c14706f /src | |
parent | a1d38a0ab4095c192390dbf10bca949454fc4b59 (diff) | |
download | manaverse-c030596364968f86f88546d3890e5b45929db47a.tar.gz manaverse-c030596364968f86f88546d3890e5b45929db47a.tar.bz2 manaverse-c030596364968f86f88546d3890e5b45929db47a.tar.xz manaverse-c030596364968f86f88546d3890e5b45929db47a.zip |
Show message if some one join your party.
Diffstat (limited to 'src')
-rw-r--r-- | src/net/tmwa/partyhandler.cpp | 26 | ||||
-rw-r--r-- | src/party.cpp | 12 | ||||
-rw-r--r-- | src/party.h | 3 |
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); |