summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am18
-rw-r--r--src/commandhandler.cpp4
-rw-r--r--src/game.cpp17
-rw-r--r--src/gui/partywindow.cpp27
-rw-r--r--src/gui/partywindow.h3
-rw-r--r--src/localplayer.cpp14
-rw-r--r--src/localplayer.h8
-rw-r--r--src/net/ea/gui/partytab.cpp4
-rw-r--r--src/net/ea/gui/partytab.h2
-rw-r--r--src/net/ea/party.cpp61
-rw-r--r--src/net/ea/party.h48
-rw-r--r--src/net/ea/partyhandler.cpp31
-rw-r--r--src/net/ea/partyhandler.h9
-rw-r--r--src/net/ea/protocol.h2
-rw-r--r--src/player.cpp4
-rw-r--r--src/player.h5
16 files changed, 127 insertions, 130 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index ae9fa827..81e40d06 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -32,7 +32,7 @@ tmw_SOURCES = gui/widgets/avatar.cpp \
gui/button.cpp \
gui/button.h \
gui/buy.cpp \
- gui/buy.h \
+ gui/buy.h \
gui/char_select.cpp \
gui/char_select.h \
gui/chat.cpp \
@@ -102,6 +102,8 @@ tmw_SOURCES = gui/widgets/avatar.cpp \
gui/ok_dialog.h \
gui/palette.cpp \
gui/palette.h \
+ gui/partywindow.cpp \
+ gui/partywindow.h \
gui/passwordfield.cpp \
gui/passwordfield.h \
gui/playerbox.cpp \
@@ -355,8 +357,6 @@ tmw_SOURCES += \
gui/magic.h \
gui/npcpostdialog.cpp \
gui/npcpostdialog.h \
- gui/partywindow.cpp \
- gui/partywindow.h \
gui/quitdialog.cpp \
gui/quitdialog.h \
gui/serverdialog.cpp \
@@ -429,8 +429,8 @@ endif
if SERVER_EATHENA
tmw_CXXFLAGS += -DEATHENA_SUPPORT
tmw_SOURCES += \
- gui/buysell.cpp \
- gui/buysell.h \
+ gui/buysell.cpp \
+ gui/buysell.h \
gui/char_server.cpp \
gui/char_server.h \
gui/skill.cpp \
@@ -439,6 +439,8 @@ tmw_SOURCES += \
gui/status.h \
gui/storagewindow.cpp \
gui/storagewindow.h \
+ net/ea/gui/partytab.cpp \
+ net/ea/gui/partytab.h \
net/ea/beinghandler.cpp \
net/ea/beinghandler.h \
net/ea/buysellhandler.cpp \
@@ -461,8 +463,8 @@ tmw_SOURCES += \
net/ea/network.h \
net/ea/npchandler.cpp \
net/ea/npchandler.h \
- net/ea/party.cpp \
- net/ea/party.h \
+ net/ea/party.cpp \
+ net/ea/party.h \
net/ea/partyhandler.cpp \
net/ea/partyhandler.h \
net/ea/playerhandler.cpp \
@@ -472,7 +474,7 @@ tmw_SOURCES += \
net/ea/skillhandler.cpp \
net/ea/skillhandler.h \
net/ea/tradehandler.cpp \
- net/ea/tradehandler.h
+ net/ea/tradehandler.h
endif
# set the include path found by configure
diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp
index 5431cf88..19791aa8 100644
--- a/src/commandhandler.cpp
+++ b/src/commandhandler.cpp
@@ -252,7 +252,7 @@ void CommandHandler::handleHelp(const std::string &args)
#else
else if (args.substr(0, 5) == "party")
{
- playerParty->help(args);
+ eAthena::Party::help(args);
#endif
}
else if (args == "present")
@@ -526,7 +526,7 @@ void CommandHandler::handleParty(const std::string &args)
}
}
else
- playerParty->respond(command, rest);
+ eAthena::Party::respond(command, rest);
#endif
}
diff --git a/src/game.cpp b/src/game.cpp
index 2dc62b05..20bf1af1 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -74,12 +74,12 @@
#include "gui/status.h"
#include "gui/trade.h"
#include "gui/viewport.h"
+#include "gui/partywindow.h"
#ifdef TMWSERV_SUPPORT
#include "gui/buddywindow.h"
#include "gui/guildwindow.h"
#include "gui/magic.h"
#include "gui/npcpostdialog.h"
-#include "gui/partywindow.h"
#include "gui/quitdialog.h"
#else
#include "gui/storagewindow.h"
@@ -107,7 +107,6 @@
#include "net/ea/inventoryhandler.h"
#include "net/ea/itemhandler.h"
#include "net/ea/npchandler.h"
-#include "net/ea/party.h"
#include "net/ea/playerhandler.h"
#include "net/ea/tradehandler.h"
#include "net/ea/protocol.h"
@@ -155,12 +154,12 @@ NpcListDialog *npcListDialog;
NpcTextDialog *npcTextDialog;
NpcStringDialog *npcStringDialog;
SkillDialog *skillDialog;
+PartyWindow *partyWindow;
#ifdef TMWSERV_SUPPORT
BuddyWindow *buddyWindow;
GuildWindow *guildWindow;
MagicDialog *magicDialog;
NpcPostDialog *npcPostDialog;
-PartyWindow *partyWindow;
#else
StorageWindow *storageWindow;
#endif
@@ -180,9 +179,6 @@ Particle *particleEngine = NULL;
EffectManager *effectManager = NULL;
ChatTab *localChatTab = NULL;
-#ifdef EATHENA_SUPPORT
-Party *playerParty = NULL;
-#endif
const int MAX_TIME = 10000;
@@ -248,13 +244,13 @@ static void createGuiWindows()
npcIntegerDialog = new NpcIntegerDialog;
npcListDialog = new NpcListDialog;
npcStringDialog = new NpcStringDialog;
+ partyWindow = new PartyWindow;
#ifdef TMWSERV_SUPPORT
npcPostDialog = new NpcPostDialog;
magicDialog = new MagicDialog;
equipmentWindow = new EquipmentWindow(player_node->mEquipment.get());
buddyWindow = new BuddyWindow;
guildWindow = new GuildWindow;
- partyWindow = new PartyWindow;
#else
buySellDialog = new BuySellDialog;
equipmentWindow = new EquipmentWindow;
@@ -333,12 +329,12 @@ static void destroyGuiWindows()
delete npcListDialog;
delete npcTextDialog;
delete npcStringDialog;
+ delete partyWindow;
#ifdef TMWSERV_SUPPORT
delete npcPostDialog;
delete magicDialog;
delete buddyWindow;
delete guildWindow;
- delete partyWindow;
#endif
delete skillDialog;
delete minimap;
@@ -401,9 +397,6 @@ Game::Game(Network *network):
// Initialize beings
beingManager->setPlayer(player_node);
-#ifdef EATHENA_SUPPORT
- playerParty = new Party;
-#endif
Joystick::init();
// TODO: The user should be able to choose which one to use
@@ -459,8 +452,6 @@ Game::~Game()
{
#ifdef TMWSERV_SUPPORT
Net::clearHandlers();
-#else
- delete playerParty;
#endif
destroyGuiWindows();
diff --git a/src/gui/partywindow.cpp b/src/gui/partywindow.cpp
index 1f87b26f..f5cebdfd 100644
--- a/src/gui/partywindow.cpp
+++ b/src/gui/partywindow.cpp
@@ -24,9 +24,14 @@
#include "gui/widgets/avatar.h"
#include "gui/widgets/chattab.h"
+#ifdef TMWSERV_SUPPORT
#include "net/tmwserv/chatserver/party.h"
+#else
+#include "net/ea/party.h"
+#endif
#include "utils/gettext.h"
+#include "utils/strprintf.h"
PartyWindow::PartyWindow() : Window(_("Party"))
{
@@ -107,7 +112,8 @@ void PartyWindow::removePartyMember(const std::string &memberName)
}
}
-void PartyWindow::showPartyInvite(const std::string &inviter)
+void PartyWindow::showPartyInvite(const std::string &inviter,
+ const std::string &partyName)
{
// check there isnt already an invite showing
if (mPartyInviter != "")
@@ -117,8 +123,15 @@ void PartyWindow::showPartyInvite(const std::string &inviter)
return;
}
+ std::string msg;
// log invite
- std::string msg = inviter + " has invited you to join their party";
+ if (partyName.empty())
+ msg = strprintf("%s has invited you to join their party",
+ inviter.c_str());
+ else
+ msg = strprintf("%s has invited you to join the %s party",
+ inviter.c_str(), partyName.c_str());
+
localChatTab->chatLog(msg, BY_SERVER);
// show invite
@@ -136,11 +149,21 @@ void PartyWindow::action(const gcn::ActionEvent &event)
if (eventId == "yes")
{
localChatTab->chatLog("Accepted invite from " + mPartyInviter);
+#ifdef TMWSERV_SUPPORT
Net::ChatServer::Party::acceptInvite(mPartyInviter);
+#else
+ eAthena::Party::respondToInvite(true);
+#endif
mPartyInviter = "";
}
else if (eventId == "no")
{
+ localChatTab->chatLog("Rejected invite from " + mPartyInviter);
+#ifdef TMWSERV_SUPPORT
+ // TODO
+#else
+ eAthena::Party::respondToInvite(false);
+#endif
mPartyInviter = "";
}
}
diff --git a/src/gui/partywindow.h b/src/gui/partywindow.h
index b587cc42..64cfb582 100644
--- a/src/gui/partywindow.h
+++ b/src/gui/partywindow.h
@@ -77,7 +77,8 @@ class PartyWindow : public Window, gcn::ActionListener
/**
* Show party invite
*/
- void showPartyInvite(const std::string &inviter);
+ void showPartyInvite(const std::string &inviter,
+ const std::string &partyName = "");
/**
* Handle events
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 553e473b..eb54b4b1 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -363,11 +363,6 @@ void LocalPlayer::inviteToGuild(Being *being)
}
}
-void LocalPlayer::inviteToParty(const std::string &name)
-{
- Net::ChatServer::Party::invitePlayer(name);
-}
-
void LocalPlayer::clearInventory()
{
mEquipment->clear();
@@ -381,6 +376,15 @@ void LocalPlayer::setInvItem(int index, int id, int amount)
#endif
+void LocalPlayer::inviteToParty(const std::string &name)
+{
+#ifdef TMWSERV_SUPPORT
+ Net::ChatServer::Party::invitePlayer(name);
+#else
+
+#endif
+}
+
void LocalPlayer::moveInvItem(Item *item, int newIndex)
{
// special case, the old and new cannot copy over each other.
diff --git a/src/localplayer.h b/src/localplayer.h
index 7e48530e..4fd68d8f 100644
--- a/src/localplayer.h
+++ b/src/localplayer.h
@@ -183,15 +183,15 @@ class LocalPlayer : public Player
*/
void inviteToGuild(Being *being);
+ void clearInventory();
+ void setInvItem(int index, int id, int amount);
+#endif
+
/**
* Invite a player to join their party
*/
void inviteToParty(const std::string &name);
- void clearInventory();
- void setInvItem(int index, int id, int amount);
-#endif
-
/**
* Move the Inventory item from the old slot to the new slot.
*/
diff --git a/src/net/ea/gui/partytab.cpp b/src/net/ea/gui/partytab.cpp
index a55d2492..4e486bf0 100644
--- a/src/net/ea/gui/partytab.cpp
+++ b/src/net/ea/gui/partytab.cpp
@@ -44,10 +44,10 @@ PartyTab::~PartyTab()
{
}
-void PartyTab::handleInput(std::string &msg) {
+void PartyTab::handleInput(const std::string &msg) {
// TODO
}
-void PartyTab::handleCommand(std::string &msg) {
+void PartyTab::handleCommand(std::string msg) {
// TODO
}
diff --git a/src/net/ea/gui/partytab.h b/src/net/ea/gui/partytab.h
index b2aaca68..fce4b515 100644
--- a/src/net/ea/gui/partytab.h
+++ b/src/net/ea/gui/partytab.h
@@ -46,4 +46,6 @@ class PartyTab : public ChatTab
void handleCommand(std::string msg);
};
+extern PartyTab *partyTab;
+
#endif // CHANNELTAB_H
diff --git a/src/net/ea/party.cpp b/src/net/ea/party.cpp
index 2295cb81..0fbba2f1 100644
--- a/src/net/ea/party.cpp
+++ b/src/net/ea/party.cpp
@@ -26,19 +26,16 @@
#include "gui/widgets/chattab.h"
#include "gui/chat.h"
#include "gui/confirm_dialog.h"
+#include "gui/partywindow.h"
#include "net/messageout.h"
#include "net/ea/protocol.h"
+#include "net/ea/gui/partytab.h"
#include "utils/gettext.h"
#include "utils/strprintf.h"
-Party::Party() :
- mInviteListener(&mInParty)
-{
-}
-
-void Party::respond(const std::string &command, const std::string &args)
+void eAthena::Party::respond(const std::string &command, const std::string &args)
{
if (command == "new" || command == "create")
{
@@ -52,7 +49,7 @@ void Party::respond(const std::string &command, const std::string &args)
}
if (command == "settings")
{
- localChatTab->chatLog(_("Not yet implemented!"), BY_SERVER);
+ partyTab->chatLog(_("Not yet implemented!"), BY_SERVER);
return;
/*
MessageOut outMsg(CMSG_PARTY_SETTINGS);
@@ -60,10 +57,10 @@ void Party::respond(const std::string &command, const std::string &args)
outMsg.writeInt16(0); // Item
*/
}
- localChatTab->chatLog(_("Party command not known."), BY_SERVER);
+ partyTab->chatLog(_("Party command not known."), BY_SERVER);
}
-void Party::create(const std::string &party)
+void eAthena::Party::create(const std::string &party)
{
if (party.empty())
{
@@ -72,22 +69,21 @@ void Party::create(const std::string &party)
}
MessageOut outMsg(CMSG_PARTY_CREATE);
outMsg.writeString(party.substr(0, 23), 24);
- mCreating = true;
}
-void Party::leave(const std::string &args)
+void eAthena::Party::leave(const std::string &args)
{
MessageOut outMsg(CMSG_PARTY_LEAVE);
localChatTab->chatLog(_("Left party."), BY_SERVER);
- mInParty = false;
+ player_node->setInParty(false);
}
-void Party::createResponse(bool ok)
+void eAthena::Party::createResponse(bool ok)
{
if (ok)
{
localChatTab->chatLog(_("Party successfully created."), BY_SERVER);
- mInParty = true;
+ player_node->setInParty(true);
}
else
{
@@ -95,58 +91,41 @@ void Party::createResponse(bool ok)
}
}
-void Party::inviteResponse(const std::string &nick, int status)
+void eAthena::Party::inviteResponse(const std::string &nick, int status)
{
switch (status)
{
case 0:
- localChatTab->chatLog(strprintf(_("%s is already a member of a party."),
+ partyTab->chatLog(strprintf(_("%s is already a member of a party."),
nick.c_str()), BY_SERVER);
break;
case 1:
- localChatTab->chatLog(strprintf(_("%s refused your invitation."),
+ partyTab->chatLog(strprintf(_("%s refused your invitation."),
nick.c_str()), BY_SERVER);
break;
case 2:
- localChatTab->chatLog(strprintf(_("%s is now a member of your party."),
+ partyTab->chatLog(strprintf(_("%s is now a member of your party."),
nick.c_str()), BY_SERVER);
break;
}
}
-void Party::invitedAsk(const std::string &nick, int gender,
- const std::string &partyName)
-{
- mPartyName = partyName; /* Quick and nasty - needs redoing */
- if (nick.empty())
- {
- localChatTab->chatLog(_("You can\'t have a blank party name!"), BY_SERVER);
- return;
- }
- mCreating = false;
- ConfirmDialog *dlg = new ConfirmDialog(_("Invite to party"),
- strprintf(_("%s invites you to join"
- " the %s party, do you accept?"),
- nick.c_str(), partyName.c_str()));
- dlg->addActionListener(&mInviteListener);
-}
-
-void Party::InviteListener::action(const gcn::ActionEvent &event)
+void eAthena::Party::respondToInvite(bool accept)
{
MessageOut outMsg(CMSG_PARTY_INVITED);
outMsg.writeInt32(player_node->getId());
- bool accept = event.getId() == "yes";
outMsg.writeInt32(accept ? 1 : 0);
- *mInParty = *mInParty || accept;
+ player_node->setInParty(player_node->getInParty() || accept);
}
-void Party::leftResponse(const std::string &nick)
+void eAthena::Party::leftResponse(const std::string &nick)
{
localChatTab->chatLog(strprintf(_("%s has left your party."), nick.c_str()),
BY_SERVER);
+ partyWindow->removePartyMember(nick);
}
-void Party::receiveChat(Being *being, const std::string &msg)
+void eAthena::Party::receiveChat(Being *being, const std::string &msg)
{
if (!being)
{
@@ -162,7 +141,7 @@ void Party::receiveChat(Being *being, const std::string &msg)
localChatTab->chatLog(being->getName() + " : " + msg, BY_PARTY);
}
-void Party::help(const std::string &args)
+void eAthena::Party::help(const std::string &args)
{
// Strip "party " from the front
std::string msg = args.substr(6, args.length());
diff --git a/src/net/ea/party.h b/src/net/ea/party.h
index 25af80b3..6907de47 100644
--- a/src/net/ea/party.h
+++ b/src/net/ea/party.h
@@ -22,18 +22,14 @@
#ifndef PARTY_H
#define PARTY_H
-#include <string>
-
-#include <guichan/actionlistener.hpp>
+#include "being.h"
-class PartyHandler;
-class Being;
-class ChatWindow;
+#include <string>
-class Party
+namespace eAthena
{
- public:
- Party();
+ namespace Party
+ {
void respond(const std::string &command, const std::string &args);
void create(const std::string &party);
@@ -43,32 +39,20 @@ class Party
void inviteResponse(const std::string &nick, int status);
void invitedAsk(const std::string &nick, int gender,
const std::string &partyName);
+
+ /**
+ * Send invite response to the server
+ */
+ void respondToInvite(bool accept);
+
+ /**
+ * The player has left your party
+ */
void leftResponse(const std::string &nick);
void receiveChat(Being *being, const std::string &msg);
void help(const std::string &args);
-
- private:
- std::string mPartyName;
- bool mInParty;
- bool mCreating; /**< Used to give an appropriate response to
- failure */
- PartyHandler *handler;
-
- class InviteListener : public gcn::ActionListener
- {
- public:
- InviteListener(bool *inParty) :
- mInParty(inParty)
- {}
- void action(const gcn::ActionEvent &event);
-
- private:
- bool *mInParty;
- };
- InviteListener mInviteListener;
-};
-
-extern Party *playerParty;
+ }
+}
#endif
diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp
index d903976e..7ecf0863 100644
--- a/src/net/ea/partyhandler.cpp
+++ b/src/net/ea/partyhandler.cpp
@@ -21,21 +21,29 @@
#include "net/ea/partyhandler.h"
+#include "net/ea/gui/partytab.h"
+
#include "net/ea/protocol.h"
#include "net/messagein.h"
#include "gui/chat.h"
+#include "gui/partywindow.h"
#include "beingmanager.h"
#include "party.h"
-PartyHandler::PartyHandler(Party *party) : mParty(party)
+PartyTab *partyTab;
+
+static void newPartyTab() { partyTab = new PartyTab(); }
+static void deletePartyTab() { delete partyTab ; }
+
+PartyHandler::PartyHandler()
{
static const Uint16 _messages[] = {
SMSG_PARTY_CREATE,
SMSG_PARTY_INFO,
- SMSG_PARTY_INVITE,
+ SMSG_PARTY_INVITE_RESPONSE,
SMSG_PARTY_INVITED,
SMSG_PARTY_SETTINGS,
SMSG_PARTY_MEMBER_INFO,
@@ -46,6 +54,13 @@ PartyHandler::PartyHandler(Party *party) : mParty(party)
0
};
handledMessages = _messages;
+
+ newPartyTab();
+}
+
+PartyHandler::~PartyHandler()
+{
+ deletePartyTab();
}
void PartyHandler::handleMessage(MessageIn &msg)
@@ -53,15 +68,15 @@ void PartyHandler::handleMessage(MessageIn &msg)
switch (msg.getId())
{
case SMSG_PARTY_CREATE:
- mParty->createResponse(msg.readInt8());
+ eAthena::Party::createResponse(msg.readInt8());
break;
case SMSG_PARTY_INFO:
break;
- case SMSG_PARTY_INVITE:
+ case SMSG_PARTY_INVITE_RESPONSE:
{
std::string nick = msg.readString(24);
int status = msg.readInt8();
- mParty->inviteResponse(nick, status);
+ eAthena::Party::inviteResponse(nick, status);
break;
}
case SMSG_PARTY_INVITED:
@@ -85,7 +100,7 @@ void PartyHandler::handleMessage(MessageIn &msg)
gender = being->getGender();
partyName = msg.readString(24);
}
- mParty->invitedAsk(nick, gender, partyName);
+ partyWindow->showPartyInvite(nick, partyName);
break;
}
case SMSG_PARTY_SETTINGS:
@@ -97,7 +112,7 @@ void PartyHandler::handleMessage(MessageIn &msg)
/*int id = */msg.readInt32();
std::string nick = msg.readString(24);
/*int fail = */msg.readInt8();
- mParty->leftResponse(nick);
+ eAthena::Party::leftResponse(nick);
break;
}
case SMSG_PARTY_UPDATE_HP:
@@ -114,7 +129,7 @@ void PartyHandler::handleMessage(MessageIn &msg)
int id = msg.readInt32();
Being *being = beingManager->findBeing(id);
std::string chatMsg = msg.readString(msgLength);
- mParty->receiveChat(being, chatMsg);
+ eAthena::Party::receiveChat(being, chatMsg);
}
break;
}
diff --git a/src/net/ea/partyhandler.h b/src/net/ea/partyhandler.h
index 851c4ae3..c6ee261b 100644
--- a/src/net/ea/partyhandler.h
+++ b/src/net/ea/partyhandler.h
@@ -24,17 +24,14 @@
#include "net/messagehandler.h"
-class Party;
-
class PartyHandler : public MessageHandler
{
public:
- PartyHandler(Party *party);
+ PartyHandler();
- void handleMessage(MessageIn &msg);
+ ~PartyHandler();
- private:
- Party *mParty;
+ void handleMessage(MessageIn &msg);
};
#endif // NET_EA_PARTYHANDLER_H
diff --git a/src/net/ea/protocol.h b/src/net/ea/protocol.h
index a70e47b4..ff13cce9 100644
--- a/src/net/ea/protocol.h
+++ b/src/net/ea/protocol.h
@@ -101,7 +101,7 @@ static const int STORAGE_OFFSET = 1;
#define SMSG_PARTY_CREATE 0x00fa
#define SMSG_PARTY_INFO 0x00fb
-#define SMSG_PARTY_INVITE 0x00fd
+#define SMSG_PARTY_INVITE_RESPONSE 0x00fd
#define SMSG_PARTY_INVITED 0x00fe
#define SMSG_PARTY_SETTINGS 0x0102
#define SMSG_PARTY_MEMBER_INFO 0x0104
diff --git a/src/player.cpp b/src/player.cpp
index a75d4e35..839959b0 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -283,9 +283,9 @@ short Player::getNumberOfGuilds()
return mGuilds.size();
}
+#endif
+
void Player::setInParty(bool value)
{
mInParty = value;
}
-
-#endif
diff --git a/src/player.h b/src/player.h
index 1904c6d9..d1155f4b 100644
--- a/src/player.h
+++ b/src/player.h
@@ -107,6 +107,8 @@ class Player : public Being
*/
short getNumberOfGuilds();
+#endif
+
/**
* Set the player in party
*/
@@ -116,7 +118,6 @@ class Player : public Being
* Returns whether player is in the party
*/
bool getInParty() const { return mInParty; }
-#endif
/**
* Gets the way the character is blocked by other objects.
@@ -140,10 +141,8 @@ class Player : public Being
FlashText *mName;
-#ifdef TMWSERV_SUPPORT
private:
bool mInParty;
-#endif
};
#endif