diff options
author | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-04-15 15:29:02 +0200 |
---|---|---|
committer | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-04-18 01:11:40 +0200 |
commit | 80e07598a896e73e08e2511f08602e2b6d2e4eb7 (patch) | |
tree | 6cb16a6104e7cda5eec6c40991e2464954ad4040 /src | |
parent | 9a0038a475707e9d190847f49c5e6c05ab916309 (diff) | |
download | manaserv-80e07598a896e73e08e2511f08602e2b6d2e4eb7.tar.gz manaserv-80e07598a896e73e08e2511f08602e2b6d2e4eb7.tar.bz2 manaserv-80e07598a896e73e08e2511f08602e2b6d2e4eb7.tar.xz manaserv-80e07598a896e73e08e2511f08602e2b6d2e4eb7.zip |
Made the server send the being position each 5 seconds.
This will permit the client the make position resyncs when necessary,
and make use of the MOVING_POSITION and DESTINATION where relevant.
Reviewed-by: Thorbjorn.
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: |