alcuadrado
alcuadrado

Reputation: 8530

Tile-based MMORPG movements protocol

I'm working in a tile-based MMORPG and I have a problem.

Each user has a fixed position (one tile) all the time, so the rest of the users can see him there, and cannot move to that tile. So there is only one object or user in each tile.

If a user becomes invisible, the rest of the users can't see him, but they still unable to move to his tile.

My question is, should the client know the position of all users (even the invisible ones)? The problem with this approach is that some users managed to crack the client and see the invisible users.

One idea that I had is that the client shouldn't know about users' position, and before moving ask the server if the tile where hi wants to move into is available, but the problem is the delay we are having.

FYI, the client/server protocol is build with TCP/IP.

Upvotes: 4

Views: 1384

Answers (1)

Jack
Jack

Reputation: 133619

You should definitely follow the second approach to have a safe MMORPG.

Actually the logic should be completely separated between client and server. While the client should be just

  • a "visual thing" that is able to render the world
  • an input interface to let players execute actions

the server should take care of everything else..

So for example you should handle the movement in something like:

  • user tries to move the player in client
  • client sends a packet with the "move request" to the server
  • server checks if move it's legal and updates its internal map according to it
  • if move was legal just send all clients the updated state (with new position)
  • if move was illegal just warn the client that tried to do it

The more important thing about this approach is that: the client is not responsible of actually moving the player into the new position, it just receives a new map state.

Forget this:

  • client ask if a move is legal
  • if server says YES then client updates the position

Upvotes: 5

Related Questions