summaryrefslogtreecommitdiff
path: root/src/net/ea
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-04-19 09:01:46 -0600
committerJared Adams <jaxad0127@gmail.com>2009-04-19 09:01:46 -0600
commit822690170b501397b86626e13b5a542712a1719d (patch)
tree327bd24839195d677beca694b9a8fca7b18245ca /src/net/ea
parent124865b5d67c8c7b199046d19380e1e154ee99e4 (diff)
downloadmana-822690170b501397b86626e13b5a542712a1719d.tar.gz
mana-822690170b501397b86626e13b5a542712a1719d.tar.bz2
mana-822690170b501397b86626e13b5a542712a1719d.tar.xz
mana-822690170b501397b86626e13b5a542712a1719d.zip
Flesh out eAtehan party handling
Diffstat (limited to 'src/net/ea')
-rw-r--r--src/net/ea/gui/partytab.cpp100
-rw-r--r--src/net/ea/partyhandler.cpp117
-rw-r--r--src/net/ea/partyhandler.h15
-rw-r--r--src/net/ea/protocol.h7
4 files changed, 217 insertions, 22 deletions
diff --git a/src/net/ea/gui/partytab.cpp b/src/net/ea/gui/partytab.cpp
index b37105e9..0ba5c7f6 100644
--- a/src/net/ea/gui/partytab.cpp
+++ b/src/net/ea/gui/partytab.cpp
@@ -21,6 +21,8 @@
#include "partytab.h"
+#include "commandhandler.h"
+
#include "net/net.h"
#include "net/partyhandler.h"
@@ -53,6 +55,9 @@ void PartyTab::showHelp()
chatLog(_("/new > Alias of create"));
chatLog(_("/invite > Invite a player to your party"));
chatLog(_("/leave > Leave the party you are in"));
+ chatLog(_("/kick > Kick some one from the party you are in"));
+ chatLog(_("/item > Show/change party item sharing options"));
+ chatLog(_("/exp > Show/change party experience sharing options"));
}
bool PartyTab::handleCommand(const std::string &type, const std::string &args)
@@ -65,8 +70,6 @@ bool PartyTab::handleCommand(const std::string &type, const std::string &args)
chatLog(_("Command: /create <party-name>"));
chatLog(_("These commands create a new party called <party-name>."));
}
- //else if (msg == "settings")
- //else if (msg == "info")
else if (args == "invite")
{
chatLog(_("Command: /invite <nick>"));
@@ -79,6 +82,26 @@ bool PartyTab::handleCommand(const std::string &type, const std::string &args)
chatLog(_("Command: /leave"));
chatLog(_("This command causes the player to leave the party."));
}
+ else if (args == "item")
+ {
+ chatLog(_("Command: /item <policy>"));
+ chatLog(_("This command changes the party's item sharing policy."));
+ chatLog(_("<policy> can be one of \"1\", \"yes\", \"true\" to "
+ "enable item sharing, or \"0\", \"no\", \"false\" to "
+ "disable item sharing."));
+ chatLog(_("Command: /item"));
+ chatLog(_("This command displays the party's current item sharing policy."));
+ }
+ else if (args == "exp")
+ {
+ chatLog(_("Command: /exp <policy>"));
+ chatLog(_("This command changes the party's experience sharing policy."));
+ chatLog(_("<policy> can be one of \"1\", \"yes\", \"true\" to "
+ "enable experience sharing, or \"0\", \"no\", \"false\" to "
+ "disable experience sharing."));
+ chatLog(_("Command: /exp"));
+ chatLog(_("This command displays the party's current experience sharing policy."));
+ }
else
return false;
}
@@ -97,14 +120,73 @@ bool PartyTab::handleCommand(const std::string &type, const std::string &args)
{
Net::getPartyHandler()->leave();
}
- else if (type == "settings")
+ else if (type == "kick")
+ {
+ Net::getPartyHandler()->kick(args);
+ }
+ else if (type == "item")
{
- chatLog(_("The settings command is not yet implemented!"));
- /*
- MessageOut outMsg(CMSG_PARTY_SETTINGS);
- outMsg.writeInt16(0); // Experience
- outMsg.writeInt16(0); // Item
- */
+ if (args.empty())
+ {
+ switch (Net::getPartyHandler()->getShareItems())
+ {
+ case PARTY_SHARE:
+ chatLog(_("Item sharing enabled."), BY_SERVER);
+ return true;
+ case PARTY_SHARE_NO:
+ chatLog(_("Item sharing disabled."), BY_SERVER);
+ return true;
+ case PARTY_SHARE_NOT_POSSIBLE:
+ chatLog(_("Item sharing not possible."), BY_SERVER);
+ return true;
+ }
+ }
+
+ char opt = CommandHandler::parseBoolean(args);
+
+ switch (opt)
+ {
+ case 1:
+ Net::getPartyHandler()->setShareItems(PARTY_SHARE);
+ break;
+ case 0:
+ Net::getPartyHandler()->setShareItems(PARTY_SHARE_NO);
+ break;
+ case -1:
+ chatLog(strprintf(BOOLEAN_OPTIONS, "item"));
+ }
+ }
+ else if (type == "exp")
+ {
+ if (args.empty())
+ {
+ switch (Net::getPartyHandler()->getShareExperience())
+ {
+ case PARTY_SHARE:
+ chatLog(_("Experience sharing enabled."), BY_SERVER);
+ return true;
+ case PARTY_SHARE_NO:
+ chatLog(_("Experience sharing disabled."), BY_SERVER);
+ return true;
+ case PARTY_SHARE_NOT_POSSIBLE:
+ chatLog(_("Experience sharing not possible."), BY_SERVER);
+ return true;
+ }
+ }
+
+ char opt = CommandHandler::parseBoolean(args);
+
+ switch (opt)
+ {
+ case 1:
+ Net::getPartyHandler()->setShareExperience(PARTY_SHARE);
+ break;
+ case 0:
+ Net::getPartyHandler()->setShareExperience(PARTY_SHARE_NO);
+ break;
+ case -1:
+ chatLog(strprintf(BOOLEAN_OPTIONS, "exp"));
+ }
}
else
return false;
diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp
index 625f233a..8001488a 100644
--- a/src/net/ea/partyhandler.cpp
+++ b/src/net/ea/partyhandler.cpp
@@ -23,6 +23,7 @@
#include "beingmanager.h"
#include "localplayer.h"
+#include "log.h"
#include "gui/chat.h"
#include "gui/partywindow.h"
@@ -82,6 +83,8 @@ void PartyHandler::handleMessage(MessageIn &msg)
break;
case SMSG_PARTY_INFO:
{
+ partyWindow->clear();
+
int length = msg.readInt16();
std::string party = msg.readString(24);
int count = (length - 28) / 46;
@@ -96,6 +99,8 @@ void PartyHandler::handleMessage(MessageIn &msg)
partyWindow->updateMember(id, nick, leader, online);
}
+
+ partyWindow->setVisible(true);
}
break;
case SMSG_PARTY_INVITE_RESPONSE:
@@ -147,9 +152,58 @@ void PartyHandler::handleMessage(MessageIn &msg)
break;
}
case SMSG_PARTY_SETTINGS:
- // I don't see this in eAthena's source
- printf("Party settings!\n");
- break;
+ {
+ // These seem to indicate the sharing mode for exp and items
+ short exp = msg.readInt16();
+ short item = msg.readInt16();
+
+ switch (exp) {
+ case PARTY_SHARE:
+ if (mShareExp == PARTY_SHARE)
+ break;
+ mShareExp = PARTY_SHARE;
+ partyTab->chatLog(_("Experience sharing enabled."), BY_SERVER);
+ break;
+ case PARTY_SHARE_NO:
+ if (mShareExp == PARTY_SHARE_NO)
+ break;
+ mShareExp =PARTY_SHARE_NO;
+ partyTab->chatLog(_("Experience sharing disabled."), BY_SERVER);
+ break;
+ case PARTY_SHARE_NOT_POSSIBLE:
+ if (mShareExp == PARTY_SHARE_NOT_POSSIBLE)
+ break;
+ mShareExp = PARTY_SHARE_NOT_POSSIBLE;
+ partyTab->chatLog(_("Experience sharing not possible."), BY_SERVER);
+ break;
+ default:
+ logger->log("Unknown party exp option: %d\n", exp);
+ }
+
+ switch (item) {
+ case PARTY_SHARE:
+ if (mShareItems == PARTY_SHARE)
+ break;
+ mShareItems = PARTY_SHARE;
+ partyTab->chatLog(_("Item sharing enabled."), BY_SERVER);
+ break;
+ case PARTY_SHARE_NO:
+ if (mShareItems == PARTY_SHARE_NO)
+ break;
+ mShareItems =PARTY_SHARE_NO;
+ partyTab->chatLog(_("Item sharing disabled."), BY_SERVER);
+ break;
+ case PARTY_SHARE_NOT_POSSIBLE:
+ if (mShareItems == PARTY_SHARE_NOT_POSSIBLE)
+ break;
+ mShareItems = PARTY_SHARE_NOT_POSSIBLE;
+ partyTab->chatLog(_("Item sharing not possible."), BY_SERVER);
+ break;
+ default:
+ logger->log("Unknown party item option: %d\n", exp);
+ }
+ break;
+ }
case SMSG_PARTY_MOVE:
{
msg.readInt32(); // id
@@ -167,7 +221,15 @@ void PartyHandler::handleMessage(MessageIn &msg)
int id = msg.readInt32();
std::string nick = msg.readString(24);
msg.readInt8(); // fail
- partyTab->chatLog(strprintf(_("%s has left your party."),
+ if (id == player_node->getId())
+ {
+ player_node->setInParty(false);
+ partyWindow->clear();
+ partyWindow->setVisible(false);
+ partyTab->chatLog(_("You have left the party."), BY_SERVER);
+ }
+ else
+ partyTab->chatLog(strprintf(_("%s has left your party."),
nick.c_str()), BY_SERVER);
partyWindow->removeMember(id);
break;
@@ -219,6 +281,7 @@ void PartyHandler::create(const std::string &name)
void PartyHandler::join(int partyId)
{
+ // TODO?
}
void PartyHandler::invite(Player *player)
@@ -229,7 +292,7 @@ void PartyHandler::invite(Player *player)
void PartyHandler::invite(const std::string &name)
{
- // TODO
+ // TODO?
}
void PartyHandler::inviteResponse(const std::string &inviter, bool accept)
@@ -243,13 +306,28 @@ void PartyHandler::inviteResponse(const std::string &inviter, bool accept)
void PartyHandler::leave()
{
MessageOut outMsg(CMSG_PARTY_LEAVE);
- partyTab->chatLog(_("Left party."), BY_SERVER);
- player_node->setInParty(false);
}
-void PartyHandler::kick(int playerId)
+void PartyHandler::kick(Player *player)
{
- // TODO
+ MessageOut outMsg(CMSG_PARTY_KICK);
+ outMsg.writeInt32(player->getId());
+ outMsg.writeString("", 24); //Unused
+}
+
+void PartyHandler::kick(const std::string &name)
+{
+ int id = partyWindow->findMember(name);
+ if (id == -1)
+ {
+ partyTab->chatLog(strprintf(_("%s is not in your party!"), name.c_str()),
+ BY_SERVER);
+ return;
+ }
+
+ MessageOut outMsg(CMSG_PARTY_KICK);
+ outMsg.writeInt32(id);
+ outMsg.writeString(name, 24); //Unused
}
void PartyHandler::chat(const std::string &text)
@@ -262,6 +340,27 @@ void PartyHandler::chat(const std::string &text)
void PartyHandler::requestPartyMembers()
{
// Our eAthena doesn't have this message
+ // Not needed anyways
+}
+
+void PartyHandler::setShareExperience(PartyShare share)
+{
+ if (share == PARTY_SHARE_NOT_POSSIBLE)
+ return;
+
+ MessageOut outMsg(CMSG_PARTY_SETTINGS);
+ outMsg.writeInt16(share);
+ outMsg.writeInt16(mShareItems);
+}
+
+void PartyHandler::setShareItems(PartyShare share)
+{
+ if (share == PARTY_SHARE_NOT_POSSIBLE)
+ return;
+
+ MessageOut outMsg(CMSG_PARTY_SETTINGS);
+ outMsg.writeInt16(mShareExp);
+ outMsg.writeInt16(share);
}
} // namespace EAthena
diff --git a/src/net/ea/partyhandler.h b/src/net/ea/partyhandler.h
index aaebe353..a9fe843b 100644
--- a/src/net/ea/partyhandler.h
+++ b/src/net/ea/partyhandler.h
@@ -49,11 +49,24 @@ class PartyHandler : public MessageHandler, public Net::PartyHandler
void leave();
- void kick(int playerId);
+ void kick(Player *player);
+
+ void kick(const std::string &name);
void chat(const std::string &text);
void requestPartyMembers();
+
+ PartyShare getShareExperience() { return mShareExp; }
+
+ void setShareExperience(PartyShare share);
+
+ PartyShare getShareItems() { return mShareItems; }
+
+ void setShareItems(PartyShare share);
+
+ private:
+ PartyShare mShareExp, mShareItems;
};
} // namespace EAthena
diff --git a/src/net/ea/protocol.h b/src/net/ea/protocol.h
index d34a635f..c96b1734 100644
--- a/src/net/ea/protocol.h
+++ b/src/net/ea/protocol.h
@@ -119,7 +119,7 @@ static const int STORAGE_OFFSET = 1;
#define SMSG_PARTY_INFO 0x00fb
#define SMSG_PARTY_INVITE_RESPONSE 0x00fd
#define SMSG_PARTY_INVITED 0x00fe
-#define SMSG_PARTY_SETTINGS 0x0102
+#define SMSG_PARTY_SETTINGS 0x0101
#define SMSG_PARTY_MOVE 0x0104
#define SMSG_PARTY_LEAVE 0x0105
#define SMSG_PARTY_UPDATE_HP 0x0106
@@ -192,8 +192,9 @@ static const int STORAGE_OFFSET = 1;
#define CMSG_PARTY_CREATE 0x00f9
#define CMSG_PARTY_INVITE 0x00fc
#define CMSG_PARTY_INVITED 0x00ff
-#define CMSG_PARTY_LEAVE 0x0100 /** Undocumented */
-#define CMSG_PARTY_SETTINGS 0x0101
+#define CMSG_PARTY_LEAVE 0x0100
+#define CMSG_PARTY_SETTINGS 0x0102
+#define CMSG_PARTY_KICK 0x0103
#define CMSG_PARTY_MESSAGE 0x0108
#define CMSG_MOVE_TO_STORAGE 0x00f3 /** Move item to storage */