summaryrefslogtreecommitdiff
path: root/src/net/beinghandler.cpp
diff options
context:
space:
mode:
authorGuillaume Melquiond <guillaume.melquiond@gmail.com>2006-09-02 13:03:20 +0000
committerGuillaume Melquiond <guillaume.melquiond@gmail.com>2006-09-02 13:03:20 +0000
commit3bce14c324e1d7bbd058e18072acc7bd953d6475 (patch)
treee51a4c8fd00bd0be1c63faae4984aaf72a72a6bc /src/net/beinghandler.cpp
parent2b322bf18d80acb464a9dc1820e581e7204cca1e (diff)
downloadMana-3bce14c324e1d7bbd058e18072acc7bd953d6475.tar.gz
Mana-3bce14c324e1d7bbd058e18072acc7bd953d6475.tar.bz2
Mana-3bce14c324e1d7bbd058e18072acc7bd953d6475.tar.xz
Mana-3bce14c324e1d7bbd058e18072acc7bd953d6475.zip
Removed pixel-based synchronisation. Added variable length move messages.
Diffstat (limited to 'src/net/beinghandler.cpp')
-rw-r--r--src/net/beinghandler.cpp30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/net/beinghandler.cpp b/src/net/beinghandler.cpp
index 8ccd3dd6..eb5ccb57 100644
--- a/src/net/beinghandler.cpp
+++ b/src/net/beinghandler.cpp
@@ -442,13 +442,33 @@ void BeingHandler::handleBeingLeaveMessage(MessageIn &msg)
void BeingHandler::handleBeingsMoveMessage(MessageIn &msg)
{
- for (int nb = (msg.getLength() - 2) / (2 + 4 * 2); nb > 0; --nb)
+ while (msg.getUnreadLength())
{
Uint16 id = msg.readShort();
+ Uint8 flags = msg.readByte();
Being *being = beingManager->findBeing(id);
- if (!being) continue;
- int sx = msg.readShort(), sy = msg.readShort(),
- dx = msg.readShort(), dy = msg.readShort();
+ int sx = 0, sy = 0, dx = 0, dy = 0;
+ if (flags & MOVING_POSITION)
+ {
+ Uint16 sx2, sy2;
+ msg.readCoordinates(sx2, sy2);
+ sx = sx2 * 32 + 16;
+ sy = sy2 * 32 + 16;
+ }
+ if (flags & MOVING_DESTINATION)
+ {
+ dx = msg.readShort();
+ dy = msg.readShort();
+ if (!(flags & MOVING_POSITION))
+ {
+ sx = dx;
+ sy = dy;
+ }
+ }
+ if (!being || !(flags & (MOVING_POSITION | MOVING_DESTINATION)))
+ {
+ continue;
+ }
bool update = being != player_node; // the local player already knows where he wants to go
if (abs(being->mX - sx) + abs(being->mY - sy) > 4 * 32)
{
@@ -457,7 +477,7 @@ void BeingHandler::handleBeingsMoveMessage(MessageIn &msg)
being->mY = sy;
update = true;
}
- if (update)
+ if (update && (flags & MOVING_DESTINATION))
{
being->setDestination(dx, dy);
}