summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGuillaume Melquiond <guillaume.melquiond@gmail.com>2006-08-27 08:58:42 +0000
committerGuillaume Melquiond <guillaume.melquiond@gmail.com>2006-08-27 08:58:42 +0000
commit5980dba7ace73e6587b9966bc2076ad2b2eaa5f0 (patch)
tree10ccabf85e599f47e31849c6e7d5ca50015e441e /src
parent40339bebb026cd553aacbbff6f2fe1aa14816d5a (diff)
downloadMana-5980dba7ace73e6587b9966bc2076ad2b2eaa5f0.tar.gz
Mana-5980dba7ace73e6587b9966bc2076ad2b2eaa5f0.tar.bz2
Mana-5980dba7ace73e6587b9966bc2076ad2b2eaa5f0.tar.xz
Mana-5980dba7ace73e6587b9966bc2076ad2b2eaa5f0.zip
Send movements.
Diffstat (limited to 'src')
-rw-r--r--src/localplayer.cpp9
-rw-r--r--src/net/beinghandler.cpp15
-rw-r--r--src/net/protocol.h2
3 files changed, 18 insertions, 8 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index f157f04c..55f536db 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -32,6 +32,7 @@
#include "sound.h"
#include "net/messageout.h"
+#include "net/network.h"
#include "net/protocol.h"
LocalPlayer *player_node = NULL;
@@ -214,10 +215,10 @@ void LocalPlayer::walk(unsigned char dir)
void LocalPlayer::setDestination(Uint16 x, Uint16 y)
{
- char temp[3];
- MessageOut outMsg(0x0085);
- set_coordinates(temp, x, y, mDirection);
- outMsg.writeString(temp, 3);
+ MessageOut msg(PGMSG_WALK);
+ msg.writeShort(x * 32 + 16);
+ msg.writeShort(y * 32 + 16);
+ Network::send(Network::GAME, msg);
mPickUpTarget = NULL;
diff --git a/src/net/beinghandler.cpp b/src/net/beinghandler.cpp
index 93f5f1a8..4ff92b63 100644
--- a/src/net/beinghandler.cpp
+++ b/src/net/beinghandler.cpp
@@ -421,8 +421,17 @@ void BeingHandler::handleBeingsMoveMessage(MessageIn &msg)
if (!being) continue;
int sx = msg.readShort(), sy = msg.readShort(),
dx = msg.readShort(), dy = msg.readShort();
- being->mX = sx / 32;
- being->mY = sy / 32;
- being->setDestination(dx / 32, dy / 32);
+ bool update = being != player_node; // the local player already knows where he wants to go
+ if (abs(being->mX - sx / 32) + abs(being->mY - sy / 32) > 4)
+ {
+ // crude handling of synchronization messages
+ being->mX = sx / 32;
+ being->mY = sy / 32;
+ update = true;
+ }
+ if (update)
+ {
+ being->setDestination(dx / 32, dy / 32);
+ }
}
}
diff --git a/src/net/protocol.h b/src/net/protocol.h
index 92405c77..be6e27cb 100644
--- a/src/net/protocol.h
+++ b/src/net/protocol.h
@@ -155,7 +155,7 @@ enum {
GPMSG_BEING_ENTER = 0x0200, // B type, L being id
// player: S name, B hair style, B hair color, B gender
GPMSG_BEING_LEAVE = 0x0201, // B type, L being id
- PGMSG_WALK = 0x0260, // L*2 destination
+ PGMSG_WALK = 0x0260, // W*2 destination
GPMSG_BEINGS_MOVE = 0x0280, // { L being id, W*2 position, W*2 destination }*
PGMSG_SAY = 0x02A0, // S text
GPMSG_SAY = 0x02A1, // L being id, S text