diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/common/manaserv_protocol.h | 2 | ||||
-rw-r--r-- | src/game-server/state.cpp | 16 |
2 files changed, 14 insertions, 4 deletions
diff --git a/src/common/manaserv_protocol.h b/src/common/manaserv_protocol.h index 96a5be1e..78497eb4 100644 --- a/src/common/manaserv_protocol.h +++ b/src/common/manaserv_protocol.h @@ -118,7 +118,7 @@ enum { PGMSG_DIRECTION_CHANGE = 0x0272, // B Direction GPMSG_BEING_DIR_CHANGE = 0x0273, // W being id, B direction GPMSG_BEING_HEALTH_CHANGE = 0x0274, // W being id, W hp, W max hp - GPMSG_BEINGS_MOVE = 0x0280, // { W being id, B flags [, W*2 position, B speed] }* + GPMSG_BEINGS_MOVE = 0x0280, // { W being id, B flags [, [W*2 position,] W*2 destination, B speed] }* GPMSG_ITEMS = 0x0281, // { W item id, W*2 position }* PGMSG_ATTACK = 0x0290, // W being id GPMSG_BEING_ATTACK = 0x0291, // W being id, B direction, B attacktype diff --git a/src/game-server/state.cpp b/src/game-server/state.cpp index 5ad0c579..1c4b38cc 100644 --- a/src/game-server/state.cpp +++ b/src/game-server/state.cpp @@ -165,7 +165,7 @@ static void serializeLooks(Character *ch, MessageOut &msg, bool full) /** * Informs a player of what happened around the character. */ -static void informPlayer(MapComposite *map, Character *p) +static void informPlayer(MapComposite *map, Character *p, int worldTime) { MessageOut moveMsg(GPMSG_BEINGS_MOVE); MessageOut damageMsg(GPMSG_BEINGS_DAMAGE); @@ -311,7 +311,11 @@ static void informPlayer(MapComposite *map, Character *p) if (opos != oold) { - flags |= MOVING_POSITION; + // Add position check coords every 5 seconds. + if (worldTime % 50 == 0) + flags |= MOVING_POSITION; + + flags |= MOVING_DESTINATION; } // Send move messages. @@ -319,6 +323,12 @@ static void informPlayer(MapComposite *map, Character *p) moveMsg.writeInt8(flags); if (flags & MOVING_POSITION) { + moveMsg.writeInt16(oold.x); + moveMsg.writeInt16(oold.y); + } + + if (flags & MOVING_DESTINATION) + { moveMsg.writeInt16(opos.x); moveMsg.writeInt16(opos.y); // We multiply the sent speed (in tiles per second) by ten @@ -460,7 +470,7 @@ void GameState::update(int worldTime) for (CharacterIterator p(map->getWholeMapIterator()); p; ++p) { - informPlayer(map, *p); + informPlayer(map, *p, worldTime); /* sending the whole character is overhead for the database, it should be replaced by a syncbuffer. see: game-server/accountconnection: |