views:

109

answers:

1

Hi, 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.

+3  A: 

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
Jack
great, that's the approach I want to implement, but there is a big delay between the user input and the movement, at least with TCP. And it's unsafe to use UDP for something like this, isn't it?
alcuadrado
UDP is not unsafe, it's just unrealiable.. it depends what kind of information you want to transmit. For example if you are transmitting the map state from server to clients 10 times per second just sending them with UDP is fine. Some of them maybe will be lost during travel but it won't affect real gameplay.. TCP is used for everything, so it should work quite fast if protocol is compressed (adaptive huffman?) and ping is acceptable..
Jack
Typically, for 'normal operation', your client will assume that the command will go through, and update the UI accordingly. Then if the server sends back a "you sent some invalid commands, this is what the map looks", the UI will compensate (usually in some jerky unappealing way, but yeah)
Tanzelax
The way Ultima Online did :D
Jack
@Jack: The ping is the problem, the protocol is very lightweight. That's why I wonder whether if I can use UDP or not.@Tanzelax: That's pretty unusable :s
alcuadrado