diff options
author | Jared Adams <jaxad0127@gmail.com> | 2010-02-08 14:40:04 -0700 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2010-02-08 14:43:51 -0700 |
commit | 8a31e96d8534d402db9cd48183c0b15732f7d95e (patch) | |
tree | 885d83febf301c1289c3bf7f83bf9dca89e0347c /src/net/ea | |
parent | bc5c031e43eff506c925682349dd2a52b89d6565 (diff) | |
download | mana-8a31e96d8534d402db9cd48183c0b15732f7d95e.tar.gz mana-8a31e96d8534d402db9cd48183c0b15732f7d95e.tar.bz2 mana-8a31e96d8534d402db9cd48183c0b15732f7d95e.tar.xz mana-8a31e96d8534d402db9cd48183c0b15732f7d95e.zip |
Merge PartyWindow and GuildWindow into SocialWindow
Diffstat (limited to 'src/net/ea')
-rw-r--r-- | src/net/ea/beinghandler.cpp | 10 | ||||
-rw-r--r-- | src/net/ea/generalhandler.cpp | 12 | ||||
-rw-r--r-- | src/net/ea/partyhandler.cpp | 104 | ||||
-rw-r--r-- | src/net/ea/partyhandler.h | 2 |
4 files changed, 74 insertions, 54 deletions
diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp index 93962613..86bfe929 100644 --- a/src/net/ea/beinghandler.cpp +++ b/src/net/ea/beinghandler.cpp @@ -28,10 +28,9 @@ #include "localplayer.h" #include "log.h" #include "npc.h" +#include "party.h" #include "playerrelations.h" -#include "gui/partywindow.h" - #include "net/ea/protocol.h" #include "resources/colordb.h" @@ -515,11 +514,10 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) player = dynamic_cast<Player*>(dstBeing); - { - PartyMember *member = partyWindow->findMember(id); - if (member && member->getAvatar()->getOnline()) + if (Party *party = player_node->getParty()){ + if (party->isMember(id)) { - player->setInParty(true); + player->setParty(party); } } diff --git a/src/net/ea/generalhandler.cpp b/src/net/ea/generalhandler.cpp index 24bc79bb..547b0609 100644 --- a/src/net/ea/generalhandler.cpp +++ b/src/net/ea/generalhandler.cpp @@ -29,6 +29,7 @@ #include "gui/inventorywindow.h" #include "gui/register.h" #include "gui/skilldialog.h" +#include "gui/socialwindow.h" #include "gui/statuswindow.h" #include "net/ea/adminhandler.h" @@ -67,6 +68,8 @@ namespace EAthena { ServerInfo charServer; ServerInfo mapServer; +extern Party *eaParty; + GeneralHandler::GeneralHandler(): mAdminHandler(new AdminHandler), mBeingHandler(new BeingHandler(config.getValue("EnableSync", 0) == 1)), @@ -202,7 +205,6 @@ void GeneralHandler::flushNetwork() void GeneralHandler::guiWindowsLoaded() { - partyTab = new PartyTab; inventoryWindow->setSplitAllowed(false); skillDialog->loadSkills("ea-skills.xml"); @@ -224,8 +226,12 @@ void GeneralHandler::guiWindowsLoaded() void GeneralHandler::guiWindowsUnloaded() { - delete partyTab; - partyTab = 0; + socialWindow->removeTab(eaParty); + if (partyTab) + { + delete partyTab; + partyTab = 0; + } } void GeneralHandler::clearHandlers() diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp index 55331640..6934dde0 100644 --- a/src/net/ea/partyhandler.cpp +++ b/src/net/ea/partyhandler.cpp @@ -25,8 +25,7 @@ #include "localplayer.h" #include "log.h" -#include "gui/chat.h" -#include "gui/partywindow.h" +#include "gui/socialwindow.h" #include "net/messagein.h" #include "net/messageout.h" @@ -38,11 +37,14 @@ #include "utils/gettext.h" #include "utils/stringutils.h" +#define PARTY_ID 1 + extern Net::PartyHandler *partyHandler; namespace EAthena { PartyTab *partyTab = 0; +Party *eaParty; PartyHandler::PartyHandler(): mShareExp(PARTY_SHARE_UNKNOWN), mShareItems(PARTY_SHARE_UNKNOWN) @@ -62,13 +64,16 @@ PartyHandler::PartyHandler(): }; handledMessages = _messages; partyHandler = this; - - //newPartyTab(); + eaParty = Party::getParty(1); } PartyHandler::~PartyHandler() { - //deletePartyTab(); + if (partyTab) + { + delete partyTab; + partyTab = 0; + } } void PartyHandler::handleMessage(Net::MessageIn &msg) @@ -77,24 +82,19 @@ void PartyHandler::handleMessage(Net::MessageIn &msg) { case SMSG_PARTY_CREATE: if (msg.readInt8()) - partyTab->chatLog(_("Could not create party."), BY_SERVER); + localChatTab->chatLog(_("Could not create party."), BY_SERVER); else { - partyTab->chatLog(_("Party successfully created."), BY_SERVER); - player_node->setInParty(true); - partyWindow->setVisible(true); + localChatTab->chatLog(_("Party successfully created."), + BY_SERVER); } break; case SMSG_PARTY_INFO: { - if (!partyWindow) - break; - - partyWindow->clearMembers(); + eaParty->clearMembers(); int length = msg.readInt16(); - std::string party = msg.readString(24); - partyWindow->setPartyName(party); + eaParty->setName(msg.readString(24)); int count = (length - 28) / 46; for (int i = 0; i < count; i++) @@ -105,7 +105,10 @@ void PartyHandler::handleMessage(Net::MessageIn &msg) bool leader = msg.readInt8() == 0; bool online = msg.readInt8() == 0; - partyWindow->updateMember(id, nick, leader, online); + PartyMember *member = new PartyMember(PARTY_ID, id, nick); + member->setLeader(leader); + member->setOnline(online); + eaParty->addMember(member); } } break; @@ -136,29 +139,30 @@ void PartyHandler::handleMessage(Net::MessageIn &msg) case SMSG_PARTY_INVITED: { int id = msg.readInt32(); - Being *being = beingManager->findBeing(id); - if (!being) - { - break; - } - std::string nick; - std::string partyName = ""; - if (being->getType() != Being::PLAYER) - { - nick = ""; - } - else + std::string partyName = msg.readString(24); + std::string nick = ""; + Being *being; + + if (!(being = beingManager->findBeing(id))) { - nick = being->getName(); - partyName = msg.readString(24); + if (being->getType() == Being::PLAYER) + { + nick = being->getName(); + } } - partyWindow->showPartyInvite(nick, partyName); + + socialWindow->showPartyInvite(partyName, nick); break; } case SMSG_PARTY_SETTINGS: { if (!partyTab) - break; + { + if (!chatWindow) + break; + + partyTab = new PartyTab(); + } // These seem to indicate the sharing mode for exp and items short exp = msg.readInt16(); @@ -199,7 +203,7 @@ void PartyHandler::handleMessage(Net::MessageIn &msg) case PARTY_SHARE_NO: if (mShareItems == PARTY_SHARE_NO) break; - mShareItems =PARTY_SHARE_NO; + mShareItems = PARTY_SHARE_NO; partyTab->chatLog(_("Item sharing disabled."), BY_SERVER); break; case PARTY_SHARE_NOT_POSSIBLE: @@ -232,16 +236,22 @@ void PartyHandler::handleMessage(Net::MessageIn &msg) msg.readInt8(); // fail if (id == player_node->getId()) { - partyWindow->clearMembers(); - partyWindow->clearPartyName(); - partyWindow->setVisible(false); - partyTab->chatLog(_("You have left the party."), BY_SERVER); + eaParty->clearMembers(); + player_node->setParty(NULL); + localChatTab->chatLog(_("You have left the party."), + BY_SERVER); + if (partyTab) + { + delete partyTab; + partyTab = 0; + } + socialWindow->removeTab(eaParty); } else { partyTab->chatLog(strprintf(_("%s has left your party."), nick.c_str()), BY_SERVER); - partyWindow->removeMember(id); + eaParty->removeMember(id); } break; } @@ -250,7 +260,12 @@ void PartyHandler::handleMessage(Net::MessageIn &msg) int id = msg.readInt32(); int hp = msg.readInt16(); int maxhp = msg.readInt16(); - partyWindow->updateMemberHP(id, hp, maxhp); + PartyMember *m = eaParty->getMember(id); + if (m) + { + m->setHp(hp); + m->setMaxHp(maxhp); + } } break; case SMSG_PARTY_UPDATE_COORDS: @@ -270,9 +285,9 @@ void PartyHandler::handleMessage(Net::MessageIn &msg) int id = msg.readInt32(); std::string chatMsg = msg.readString(msgLength); - PartyMember *member = partyWindow->findMember(id); + PartyMember *member = eaParty->getMember(id); if (member) - partyTab->chatLog(member->getAvatar()->getName(), chatMsg); + partyTab->chatLog(member->getName(), chatMsg); else partyTab->chatLog(strprintf(_("An unknown member tried to " "say: %s"), chatMsg.c_str()), BY_SERVER); @@ -309,7 +324,6 @@ void PartyHandler::inviteResponse(const std::string &inviter, bool accept) MessageOut outMsg(CMSG_PARTY_INVITED); outMsg.writeInt32(player_node->getId()); outMsg.writeInt32(accept ? 1 : 0); - player_node->setInParty(player_node->isInParty() || accept); } void PartyHandler::leave() @@ -326,8 +340,8 @@ void PartyHandler::kick(Player *player) void PartyHandler::kick(const std::string &name) { - int id = partyWindow->findMember(name); - if (id == -1) + PartyMember *m = eaParty->getMember(name); + if (!m) { partyTab->chatLog(strprintf(_("%s is not in your party!"), name.c_str()), BY_SERVER); @@ -335,7 +349,7 @@ void PartyHandler::kick(const std::string &name) } MessageOut outMsg(CMSG_PARTY_KICK); - outMsg.writeInt32(id); + outMsg.writeInt32(m->getID()); outMsg.writeString(name, 24); //Unused } diff --git a/src/net/ea/partyhandler.h b/src/net/ea/partyhandler.h index 188df2ac..e58cf0bf 100644 --- a/src/net/ea/partyhandler.h +++ b/src/net/ea/partyhandler.h @@ -27,6 +27,8 @@ #include "net/ea/messagehandler.h" +#include "party.h" + namespace EAthena { class PartyHandler : public MessageHandler, public Net::PartyHandler |