diff options
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/ea/playerhandler.cpp | 96 | ||||
-rw-r--r-- | src/net/ea/playerhandler.h | 27 | ||||
-rw-r--r-- | src/net/playerhandler.h | 9 |
3 files changed, 127 insertions, 5 deletions
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() {} |