summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-04-01 07:45:13 -0600
committerJared Adams <jaxad0127@gmail.com>2009-04-01 07:45:13 -0600
commit33048e36c1fdc642459b0101ad0ab9c63807a3e7 (patch)
treea3d311e0a820c901058f8dfe7b3eeaaf946e7618
parentea4cfda4712ac31326b64ddf9dff61e448aeed28 (diff)
downloadmana-client-33048e36c1fdc642459b0101ad0ab9c63807a3e7.tar.gz
mana-client-33048e36c1fdc642459b0101ad0ab9c63807a3e7.tar.bz2
mana-client-33048e36c1fdc642459b0101ad0ab9c63807a3e7.tar.xz
mana-client-33048e36c1fdc642459b0101ad0ab9c63807a3e7.zip
Build eAthena's PlayerHandler
-rw-r--r--src/gui/status.cpp39
-rw-r--r--src/localplayer.cpp66
-rw-r--r--src/localplayer.h1
-rw-r--r--src/net/ea/playerhandler.cpp96
-rw-r--r--src/net/ea/playerhandler.h27
-rw-r--r--src/net/playerhandler.h9
6 files changed, 162 insertions, 76 deletions
diff --git a/src/gui/status.cpp b/src/gui/status.cpp
index e6f57de5..92ae2916 100644
--- a/src/gui/status.cpp
+++ b/src/gui/status.cpp
@@ -19,20 +19,24 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "button.h"
-#include "label.h"
-#include "progressbar.h"
-#include "status.h"
-#include "windowcontainer.h"
+#include "gui/status.h"
-#include "widgets/layout.h"
+#include "localplayer.h"
+#include "units.h"
-#include "../localplayer.h"
-#include "../units.h"
+#include "gui/button.h"
+#include "gui/label.h"
+#include "gui/progressbar.h"
+#include "gui/windowcontainer.h"
-#include "../utils/gettext.h"
-#include "../utils/strprintf.h"
-#include "../utils/stringutils.h"
+#include "gui/widgets/layout.h"
+
+#include "net/net.h"
+#include "net/ea/playerhandler.h"
+
+#include "utils/gettext.h"
+#include "utils/strprintf.h"
+#include "utils/stringutils.h"
StatusWindow::StatusWindow(LocalPlayer *player):
Window(player->getName()),
@@ -261,20 +265,21 @@ void StatusWindow::draw(gcn::Graphics *g)
void StatusWindow::action(const gcn::ActionEvent &event)
{
// Stats Part
+ // Net::getPlayerHandler()->increaseStat(?);
if (event.getId().length() == 3)
{
if (event.getId() == "STR")
- player_node->raiseAttribute(LocalPlayer::STR);
+ playerHandler->increaseStat(LocalPlayer::STR);
if (event.getId() == "AGI")
- player_node->raiseAttribute(LocalPlayer::AGI);
+ playerHandler->increaseStat(LocalPlayer::AGI);
if (event.getId() == "VIT")
- player_node->raiseAttribute(LocalPlayer::VIT);
+ playerHandler->increaseStat(LocalPlayer::VIT);
if (event.getId() == "INT")
- player_node->raiseAttribute(LocalPlayer::INT);
+ playerHandler->increaseStat(LocalPlayer::INT);
if (event.getId() == "DEX")
- player_node->raiseAttribute(LocalPlayer::DEX);
+ playerHandler->increaseStat(LocalPlayer::DEX);
if (event.getId() == "LUK")
- player_node->raiseAttribute(LocalPlayer::LUK);
+ playerHandler->increaseStat(LocalPlayer::LUK);
}
}
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index eec04a5c..f4ba142c 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -54,6 +54,7 @@
#else
#include "net/messageout.h"
#include "net/ea/partyhandler.h"
+#include "net/ea/playerhandler.h"
#include "net/ea/protocol.h"
#include "net/ea/skillhandler.h"
#include "net/ea/tradehandler.h"
@@ -496,12 +497,12 @@ void LocalPlayer::pickUp(FloorItem *item)
if (dx * dx + dy * dy < 4)
{
+ // Net::getPlayerHandler()->pickUp(item);
#ifdef TMWSERV_SUPPORT
int id = item->getId();
Net::GameServer::Player::pickUp(id >> 16, id & 0xFFFF);
#else
- MessageOut outMsg(CMSG_ITEM_PICKUP);
- outMsg.writeInt32(item->getId());
+ playerHandler->pickUp(item);
#endif
mPickUpTarget = NULL;
}
@@ -694,15 +695,13 @@ void LocalPlayer::setDestination(Uint16 x, Uint16 y)
mDestX = x;
mDestY = y;
+ // Net::getPlayerHandler()->setDestination(x, y, mDirection);
#ifdef TMWSERV_SUPPORT
Net::GameServer::Player::walk(x, y);
//Debugging fire burst
effectManager->trigger(15,x,y);
#else
- char temp[4] = "";
- set_coordinates(temp, x, y, mDirection);
- MessageOut outMsg(0x0085);
- outMsg.writeString(temp, 3);
+ playerHandler->setDestination(x, y, mDirection);
#endif
}
@@ -742,39 +741,6 @@ void LocalPlayer::stopWalking(bool sendToServer)
#endif
#ifdef EATHENA_SUPPORT
-void LocalPlayer::raiseAttribute(Attribute attr)
-{
- MessageOut outMsg(CMSG_STAT_UPDATE_REQUEST);
-
- switch (attr)
- {
- case STR:
- outMsg.writeInt16(0x000d);
- break;
-
- case AGI:
- outMsg.writeInt16(0x000e);
- break;
-
- case VIT:
- outMsg.writeInt16(0x000f);
- break;
-
- case INT:
- outMsg.writeInt16(0x0010);
- break;
-
- case DEX:
- outMsg.writeInt16(0x0011);
- break;
-
- case LUK:
- outMsg.writeInt16(0x0012);
- break;
- }
- outMsg.writeInt8(1);
-}
-
void LocalPlayer::raiseSkill(Uint16 skillId)
{
if (mSkillPoint <= 0)
@@ -799,13 +765,13 @@ void LocalPlayer::toggleSit()
default: return;
}
+ // Net::getPlayerHandler()->changeAction(newAction);
+
#ifdef TMWSERV_SUPPORT
setAction(newAction);
Net::GameServer::Player::changeAction(newAction);
#else
- MessageOut outMsg(0x0089);
- outMsg.writeInt32(0);
- outMsg.writeInt8((newAction == SIT) ? 2 : 3);
+ playerHandler->changeAction(newAction);
#endif
}
@@ -815,10 +781,9 @@ void LocalPlayer::emote(Uint8 emotion)
return;
mLastAction = tick_time;
- // XXX Convert for new server
+ // Net::getPlayerHandler()->emote(emotion);
#ifdef EATHENA_SUPPORT
- MessageOut outMsg(0x00bf);
- outMsg.writeInt8(emotion);
+ playerHandler->emote(emotion);
#endif
}
@@ -962,9 +927,7 @@ void LocalPlayer::attack(Being *target, bool keep)
sound.playSfx("sfx/fist-swish.ogg");
}
- MessageOut outMsg(0x0089);
- outMsg.writeInt32(target->getId());
- outMsg.writeInt8(0);
+ playerHandler->attack(target);
if (!keep)
stopAttack();
@@ -985,11 +948,8 @@ void LocalPlayer::stopAttack()
void LocalPlayer::revive()
{
- // XXX Convert for new server
-#ifdef EATHENA_SUPPORT
- MessageOut outMsg(0x00b2);
- outMsg.writeInt8(0);
-#endif
+ // Net::getPlayerHandler()->respawn();
+ playerHandler->respawn();
}
#ifdef TMWSERV_SUPPORT
diff --git a/src/localplayer.h b/src/localplayer.h
index f6df18a6..a049f67f 100644
--- a/src/localplayer.h
+++ b/src/localplayer.h
@@ -335,7 +335,6 @@ class LocalPlayer : public Player
bool withinAttackRange(Being *target);
#ifdef EATHENA_SUPPORT
- void raiseAttribute(Attribute attr);
void raiseSkill(Uint16 skillId);
#else
diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp
index 534c1b7b..cb3ed089 100644
--- a/src/net/ea/playerhandler.cpp
+++ b/src/net/ea/playerhandler.cpp
@@ -148,6 +148,8 @@ static const char *randomDeathMessage()
return gettext(deadMsg[random]);
}
+PlayerHandler *playerHandler;
+
PlayerHandler::PlayerHandler()
{
static const Uint16 _messages[] = {
@@ -163,6 +165,7 @@ PlayerHandler::PlayerHandler()
0
};
handledMessages = _messages;
+ playerHandler = this;
}
void PlayerHandler::handleMessage(MessageIn &msg)
@@ -427,3 +430,96 @@ void PlayerHandler::handleMessage(MessageIn &msg)
break;
}
}
+
+void PlayerHandler::attack(Being *being)
+{
+ MessageOut outMsg(0x0089);
+ outMsg.writeInt32(being->getId());
+ outMsg.writeInt8(0);
+}
+
+void PlayerHandler::emote(int emoteId)
+{
+ MessageOut outMsg(0x00bf);
+ outMsg.writeInt8(emoteId);
+}
+
+void PlayerHandler::increaseStat(LocalPlayer::Attribute attr)
+{
+ MessageOut outMsg(CMSG_STAT_UPDATE_REQUEST);
+
+ switch (attr)
+ {
+ case LocalPlayer::STR:
+ outMsg.writeInt16(0x000d);
+ break;
+
+ case LocalPlayer::AGI:
+ outMsg.writeInt16(0x000e);
+ break;
+
+ case LocalPlayer::VIT:
+ outMsg.writeInt16(0x000f);
+ break;
+
+ case LocalPlayer::INT:
+ outMsg.writeInt16(0x0010);
+ break;
+
+ case LocalPlayer::DEX:
+ outMsg.writeInt16(0x0011);
+ break;
+
+ case LocalPlayer::LUK:
+ outMsg.writeInt16(0x0012);
+ break;
+ }
+ outMsg.writeInt8(1);
+}
+
+void PlayerHandler::decreaseStat(LocalPlayer::Attribute attr)
+{
+ // Supported by eA?
+}
+
+void PlayerHandler::pickUp(FloorItem *floorItem)
+{
+ MessageOut outMsg(CMSG_ITEM_PICKUP);
+ outMsg.writeInt32(floorItem->getId());
+}
+
+void PlayerHandler::setDirection(int direction)
+{
+ // TODO
+}
+
+void PlayerHandler::setDestination(int x, int y, int direction)
+{
+ char temp[4] = "";
+ set_coordinates(temp, x, y, direction);
+ MessageOut outMsg(0x0085);
+ outMsg.writeString(temp, 3);
+}
+
+void PlayerHandler::changeAction(Being::Action action)
+{
+ MessageOut outMsg(0x0089);
+ outMsg.writeInt32(0);
+ outMsg.writeInt8((action == Being::SIT) ? 2 : 3);
+}
+
+void PlayerHandler::respawn()
+{
+ MessageOut outMsg(0x00b2);
+ outMsg.writeInt8(0);
+}
+
+void PlayerHandler::ingorePlayer(const std::string &player, bool ignore)
+{
+ // TODO
+}
+
+void PlayerHandler::ingoreAll(bool ignore)
+{
+ // TODO
+}
diff --git a/src/net/ea/playerhandler.h b/src/net/ea/playerhandler.h
index 6b36d86f..f1d45a79 100644
--- a/src/net/ea/playerhandler.h
+++ b/src/net/ea/playerhandler.h
@@ -23,13 +23,38 @@
#define NET_EA_PLAYERHANDLER_H
#include "net/messagehandler.h"
+#include "net/net.h"
-class PlayerHandler : public MessageHandler
+class PlayerHandler : public MessageHandler, public Net::PlayerHandler
{
public:
PlayerHandler();
virtual void handleMessage(MessageIn &msg);
+
+ virtual void attack(Being *being);
+
+ virtual void emote(int emoteId);
+
+ virtual void increaseStat(LocalPlayer::Attribute attr);
+
+ virtual void decreaseStat(LocalPlayer::Attribute attr);
+
+ virtual void pickUp(FloorItem *floorItem);
+
+ virtual void setDirection(int direction);
+
+ virtual void setDestination(int x, int y, int direction = -1);
+
+ virtual void changeAction(Being::Action action);
+
+ virtual void respawn();
+
+ virtual void ingorePlayer(const std::string &player, bool ignore);
+
+ virtual void ingoreAll(bool ignore);
};
+extern PlayerHandler *playerHandler;
+
#endif // NET_EA_PLAYERHANDLER_H
diff --git a/src/net/playerhandler.h b/src/net/playerhandler.h
index 87b51e2f..b451331e 100644
--- a/src/net/playerhandler.h
+++ b/src/net/playerhandler.h
@@ -24,6 +24,7 @@
#include "being.h"
#include "floor_item.h"
+#include "localplayer.h"
#include <iosfwd>
@@ -35,17 +36,17 @@ class PlayerHandler
virtual void emote(int emoteId) {}
- virtual void increaseStat(int statId) {}
+ virtual void increaseStat(LocalPlayer::Attribute attr) {}
- virtual void decreaseStat(int statId) {}
+ virtual void decreaseStat(LocalPlayer::Attribute attr) {}
virtual void pickUp(FloorItem *floorItem) {}
virtual void setDirection(int direction) {}
- virtual void setDestination(int x, int y, int direction = -1);
+ virtual void setDestination(int x, int y, int direction = -1) {}
- virtual void sit() {}
+ virtual void changeAction(Being::Action action) {}
virtual void respawn() {}