summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2010-02-08 14:40:04 -0700
committerJared Adams <jaxad0127@gmail.com>2010-02-08 14:43:51 -0700
commit8a31e96d8534d402db9cd48183c0b15732f7d95e (patch)
tree885d83febf301c1289c3bf7f83bf9dca89e0347c /src/net
parentbc5c031e43eff506c925682349dd2a52b89d6565 (diff)
downloadmana-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')
-rw-r--r--src/net/ea/beinghandler.cpp10
-rw-r--r--src/net/ea/generalhandler.cpp12
-rw-r--r--src/net/ea/partyhandler.cpp104
-rw-r--r--src/net/ea/partyhandler.h2
-rw-r--r--src/net/manaserv/chathandler.cpp1
-rw-r--r--src/net/manaserv/generalhandler.cpp4
-rw-r--r--src/net/manaserv/guildhandler.cpp26
-rw-r--r--src/net/manaserv/partyhandler.cpp30
-rw-r--r--src/net/manaserv/partyhandler.h4
9 files changed, 107 insertions, 86 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
diff --git a/src/net/manaserv/chathandler.cpp b/src/net/manaserv/chathandler.cpp
index 08863eca..e849b51a 100644
--- a/src/net/manaserv/chathandler.cpp
+++ b/src/net/manaserv/chathandler.cpp
@@ -29,7 +29,6 @@
#include "main.h"
#include "gui/chat.h"
-#include "gui/guildwindow.h"
#include "gui/widgets/channeltab.h"
diff --git a/src/net/manaserv/generalhandler.cpp b/src/net/manaserv/generalhandler.cpp
index de066aca..aa3b06f5 100644
--- a/src/net/manaserv/generalhandler.cpp
+++ b/src/net/manaserv/generalhandler.cpp
@@ -26,7 +26,6 @@
#include "gui/changeemaildialog.h"
#include "gui/charselectdialog.h"
#include "gui/inventorywindow.h"
-#include "gui/partywindow.h"
#include "gui/register.h"
#include "gui/skilldialog.h"
#include "gui/specialswindow.h"
@@ -159,8 +158,7 @@ void GeneralHandler::flushNetwork()
void GeneralHandler::guiWindowsLoaded()
{
inventoryWindow->setSplitAllowed(true);
- partyWindow->clearPartyName();
- skillDialog->loadSkills("mana-skills.xml");
+ skillDialog->loadSkills("tmw-skills.xml");
specialsWindow->loadSpecials("specials.xml");
player_node->setExpNeeded(100);
diff --git a/src/net/manaserv/guildhandler.cpp b/src/net/manaserv/guildhandler.cpp
index 44220e9a..fc0e7e25 100644
--- a/src/net/manaserv/guildhandler.cpp
+++ b/src/net/manaserv/guildhandler.cpp
@@ -21,17 +21,18 @@
#include "net/manaserv/guildhandler.h"
-#include "gui/widgets/channeltab.h"
-#include "gui/chat.h"
-#include "gui/guildwindow.h"
-
#include "guild.h"
#include "log.h"
#include "localplayer.h"
#include "channel.h"
#include "channelmanager.h"
+#include "gui/widgets/channeltab.h"
+#include "gui/chat.h"
+#include "gui/socialwindow.h"
+
#include "net/messagein.h"
+#include "net/net.h"
#include "net/manaserv/connection.h"
#include "net/manaserv/messagein.h"
@@ -135,8 +136,6 @@ void GuildHandler::handleMessage(Net::MessageIn &msg)
guild->addMember(member);
}
}
-
- guildWindow->updateTab();
}
} break;
@@ -183,9 +182,6 @@ void GuildHandler::handleMessage(Net::MessageIn &msg)
logger->log("Invalid guild event");
}
}
- guildWindow->updateTab();
-
-
} break;
case CPMSG_GUILD_INVITED:
@@ -196,7 +192,7 @@ void GuildHandler::handleMessage(Net::MessageIn &msg)
int guildId = msg.readInt16();
// Open a dialog asking if the player accepts joining the guild.
- guildWindow->openAcceptDialog(inviterName, guildName, guildId);
+ socialWindow->showGuildInvite(guildName, guildId, inviterName);
} break;
case CPMSG_GUILD_PROMOTE_MEMBER_RESPONSE:
@@ -236,7 +232,6 @@ void GuildHandler::handleMessage(Net::MessageIn &msg)
{
Channel *channel = channelManager->findByName(guild->getName());
channelManager->removeChannel(channel);
- guildWindow->removeTab(guildId);
player_node->removeGuild(guildId);
}
}
@@ -252,11 +247,12 @@ void GuildHandler::joinedGuild(Net::MessageIn &msg)
short channelId = msg.readInt16();
std::string announcement = msg.readString();
- // Add guild to player and create new guild tab
- Guild *guild = player_node->addGuild(guildId, permissions);
+ // Add guild to player
+ Guild *guild = Guild::getGuild(guildId);
guild->setName(guildName);
- guildWindow->newGuildTab(guildName);
- guildWindow->requestMemberList(guildId);
+ guild->setRights(permissions);
+ player_node->addGuild(guild);
+ Net::getGuildHandler()->memberList(guildId);
// Automatically create the guild channel
// COMMENT: Should this go here??
diff --git a/src/net/manaserv/partyhandler.cpp b/src/net/manaserv/partyhandler.cpp
index cec33fc4..da97374b 100644
--- a/src/net/manaserv/partyhandler.cpp
+++ b/src/net/manaserv/partyhandler.cpp
@@ -21,13 +21,13 @@
#include "net/manaserv/partyhandler.h"
-#include "gui/partywindow.h"
-
-#include "gui/widgets/chattab.h"
-
#include "log.h"
#include "localplayer.h"
+#include "gui/socialwindow.h"
+
+#include "gui/widgets/chattab.h"
+
#include "net/manaserv/connection.h"
#include "net/manaserv/messagein.h"
#include "net/manaserv/messageout.h"
@@ -38,13 +38,16 @@
#include <iostream>
+#define PARTY_ID 1
+
extern Net::PartyHandler *partyHandler;
namespace ManaServ {
extern Connection *chatServerConnection;
-PartyHandler::PartyHandler()
+PartyHandler::PartyHandler():
+ mParty(Party::getParty(PARTY_ID))
{
static const Uint16 _messages[] = {
CPMSG_PARTY_INVITE_RESPONSE,
@@ -74,15 +77,14 @@ void PartyHandler::handleMessage(Net::MessageIn &msg)
case CPMSG_PARTY_INVITED:
{
- std::string inviter = msg.readString();
- partyWindow->showPartyInvite(inviter);
+ socialWindow->showPartyInvite(msg.readString());
} break;
case CPMSG_PARTY_ACCEPT_INVITE_RESPONSE:
{
if (msg.readInt8() == ERRMSG_OK)
{
- player_node->setInParty(true);
+ //
localChatTab->chatLog(_("Joined party."));
}
}
@@ -91,7 +93,8 @@ void PartyHandler::handleMessage(Net::MessageIn &msg)
{
if (msg.readInt8() == ERRMSG_OK)
{
- player_node->setInParty(false);
+ mParty->clearMembers();
+ player_node->setParty(NULL);
}
} break;
@@ -103,15 +106,16 @@ void PartyHandler::handleMessage(Net::MessageIn &msg)
localChatTab->chatLog(strprintf(_("%s joined the party."),
name.c_str()));
- if (!player_node->isInParty())
- player_node->setInParty(true);
+ if (id == player_node->getId())
+ player_node->setParty(mParty);
- partyWindow->updateMember(id, name);
+ PartyMember *member = new PartyMember(PARTY_ID, id, name);
+ mParty->addMember(member);
} break;
case CPMSG_PARTY_MEMBER_LEFT:
{
- partyWindow->removeMember(msg.readString());
+ mParty->removeMember(msg.readString());
} break;
case CPMSG_PARTY_REJECTED:
diff --git a/src/net/manaserv/partyhandler.h b/src/net/manaserv/partyhandler.h
index 5ab03785..f97d9fb9 100644
--- a/src/net/manaserv/partyhandler.h
+++ b/src/net/manaserv/partyhandler.h
@@ -26,6 +26,8 @@
#include "net/manaserv/messagehandler.h"
+#include "party.h"
+
#include <string>
namespace ManaServ {
@@ -64,6 +66,8 @@ public:
PartyShare getShareItems() { return PARTY_SHARE_NO; }
void setShareItems(PartyShare share) {}
+private:
+ Party *mParty;
};
} // namespace ManaServ