summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--src/localplayer.cpp9
-rw-r--r--src/net/beinghandler.cpp15
-rw-r--r--src/net/protocol.h2
4 files changed, 24 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 6850a45e..662acc65 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-08-26 Guillaume Melquiond <guillaume.melquiond@gmail.com>
+
+ * src/localplayer.cpp, src/net/protocol.h: Send move message
+ whenever a destination is selected.
+ * src/beinghandler.cpp: Smoothed being trajectories.
+
2006-08-27 Bjørn Lindeijer <bjorn@lindeijer.nl>
* src/localplayer.cpp, src/gui/sell.cpp, src/gui/trade.cpp,
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