diff options
author | Philipp Sehmisch <tmw@crushnet.org> | 2007-03-02 23:29:28 +0000 |
---|---|---|
committer | Philipp Sehmisch <tmw@crushnet.org> | 2007-03-02 23:29:28 +0000 |
commit | 58771baadb7529b0b20ca85566ab2790ca5dcd90 (patch) | |
tree | 526b458712f46fc6b9cfdcffc98e0a625f656eb6 /src/net/beinghandler.cpp | |
parent | 3ce08687bb879054f5fa93f456677246cb51afdd (diff) | |
download | mana-client-58771baadb7529b0b20ca85566ab2790ca5dcd90.tar.gz mana-client-58771baadb7529b0b20ca85566ab2790ca5dcd90.tar.bz2 mana-client-58771baadb7529b0b20ca85566ab2790ca5dcd90.tar.xz mana-client-58771baadb7529b0b20ca85566ab2790ca5dcd90.zip |
Implemented communication of being action changes.
Diffstat (limited to 'src/net/beinghandler.cpp')
-rw-r--r-- | src/net/beinghandler.cpp | 72 |
1 files changed, 47 insertions, 25 deletions
diff --git a/src/net/beinghandler.cpp b/src/net/beinghandler.cpp index 08d47f01..32c78b39 100644 --- a/src/net/beinghandler.cpp +++ b/src/net/beinghandler.cpp @@ -58,6 +58,7 @@ BeingHandler::BeingHandler() GPMSG_BEING_LEAVE, GPMSG_BEINGS_MOVE, GPMSG_BEINGS_DAMAGE, + GPMSG_BEING_ACTION_CHANGE, 0 }; handledMessages = _messages; @@ -79,11 +80,9 @@ void BeingHandler::handleMessage(MessageIn &msg) case GPMSG_BEING_ENTER: handleBeingEnterMessage(msg); break; - case GPMSG_BEING_LEAVE: handleBeingLeaveMessage(msg); break; - case GPMSG_BEINGS_MOVE: handleBeingsMoveMessage(msg); break; @@ -93,6 +92,9 @@ void BeingHandler::handleMessage(MessageIn &msg) case GPMSG_BEINGS_DAMAGE: handleBeingsDamageMessage(msg); break; + case GPMSG_BEING_ACTION_CHANGE: + handleBeingActionChangeMessage(msg); + break; /* case SMSG_BEING_VISIBLE: @@ -406,33 +408,45 @@ BeingHandler::handleBeingEnterMessage(MessageIn &msg) { int type = msg.readByte(); // type int id = msg.readShort(); + Being::Action action = (Being::Action)msg.readByte(); + Uint16 px = msg.readShort(); + Uint16 py = msg.readShort(); - switch (type) { - case OBJECT_PLAYER: + switch (type) { - std::string name = msg.readString(); - Being *being; - if (player_node->getName() == name) + case OBJECT_PLAYER: { - being = player_node; - being->setId(id); - } - else + std::string name = msg.readString(); + Being *being; + if (player_node->getName() == name) + { + being = player_node; + being->setId(id); + } + else + { + being = beingManager->createBeing(id, 0); + being->setName(name); + } + being->setHairStyle(msg.readByte()); + being->setHairColor(msg.readByte()); + being->setSex(msg.readByte()); + being->mX = px; + being->mY = py; + being->setDestination(px, py); + being->setAction(action); + } break; + case OBJECT_MONSTER: { - being = beingManager->createBeing(id, 0); - being->setName(name); - } - being->setHairStyle(msg.readByte()); - being->setHairColor(msg.readByte()); - being->setSex(msg.readByte()); - } break; - case OBJECT_MONSTER: - { - int monsterId = msg.readShort(); - Being *being; - being = beingManager->createBeing(id, 1002 + monsterId); - being->setWalkSpeed(150); // TODO - } break; + int monsterId = msg.readShort(); + Being *being; + being = beingManager->createBeing(id, 1002 + monsterId); + being->setWalkSpeed(150); // TODO + being->mX = px; + being->mY = py; + being->setDestination(px, py); + being->setAction(action); + } break; } } @@ -515,3 +529,11 @@ void BeingHandler::handleBeingsDamageMessage(MessageIn &msg) } } } + +void BeingHandler::handleBeingActionChangeMessage(MessageIn &msg) +{ + Being* being = beingManager->findBeing(msg.readShort()); + if (!being) return; + + being->setAction((Being::Action)msg.readByte()); +} |