Sending GameState from MMOG Servers to Clients
Hi, I was thinking about how game state is sent to clients in todays MMOGs. If anyone could shed some light on this issue it would be greatly appreciated. I was thinking about this mainly because my research involves implementing something that I would like to call a MMOG server :) , however right now I´m still architecting how things are gonna work. In my mind, in the server, each client would have a buffer were it would be placed his game state. Then, when the time comes to update the state of the client, the whole buffer would be sent. This buffer would be sent in an unreliable way using UDP. My idea was using frequent state regeneration, something like, sending 2 times or more per second those buffers, so that even though some messages would be lost, eventually the client would receive the game state properly. The problem with this is that not all data can be sent in that way in an efficient manner. Chat messages for instance. I could place somewhere in the buffer the chat message, but I would send that message constantly util is not meant to appear? That would be wastefull and some chat messages could not be received at all. So for the data that needs reliability and ordering I plan on using TCP. That way I even have the advantage of knowing when a connection is lost. All the clients this way would be using TCP and UDP. And also using 2 buffers, one for UPD and the other for TCP. But one thing I would also like to know is what type of data is sent in those game state updates. As of now, I plan on placing player positions and destinations and item positions in the UDP buffer. And chat messages in the TCP buffers. What else is normally sent? How is combat and trade messages are sent? If you can be very detailed in the answers giving bits and bytes I would really appreciate. Thanks! Lucas
hi,
what exactly do you consider a game state? IMO, i dont really see a need to send any constant updates. in my game, (an MMO style game), i do not send any messages at a constant rate.
now the questions you are asking have answers to them that could fill up a few papers, but i will try my best to describe this to you.
first, you will want to do as much visability filtering as possible. visability filtering means sending messages to as few people as possible while still maintaining an accurate simulation. here is how i handle it
- group players by map
- make a function that grabs all players on a map
- make a function that grabs all players who are within certain distance of another player
then, i only send updates as they happen. in general, all messages are at most sent to everyone on the same map (except for a few messages like global speach broadcast). when i client first enters the game, i send him a message saying "there are X number of people on the map you are logging into. here is their position, name, and if they are moving here is their velocity and destination, and by the way the time is T". the client gets this message and then creates all these clients on his local simulation. if a player was moving, he then uses the timestamp to place that player in the correct position. now you may not have to do this : my game is very action based so sync must be as correct as possible,but as i understand it most MMORPGs do not keep in perfect sync simply because its not needed and no one would ever notice.
now, not only do i tell the player who just logged in about the players on his map, but then i also send a message to all players on the map, saying "a player just joined the game, and he started on your map. this is his name and position". when a client gets this message, he created that client on his simulation.
ok, so now we have all clients knowing about each other, their names, where they are, etc. now we just have to keep the simulation updated and in sync. now your going to have to think about how you want to handle movement.. there are many ways to handle movement. is the game 2d or 3d? do you want to use the mouse to move, or keyboard? the former will most likely be easier and cheaper to implement, but unfortunately is not as user friendly.
either way, now that the clients know about each other, we have to keep them updated and in sync. my game is 2D overhead style ala FF3, and i use the mouse for movement. when a player clicks to move, he walks in a strait line to where he clicked. so when a player clicks, (roughly it is like this) he sends to the server "i want to move, i clicked here". the server gets this and starts the movement on his simulation, and then relays it to all players on his map. now they are all in sync with movement.
other things work similarly, but different things might have different visability filtering. for example, when a player fires his gun, the message is only sent to players within certain distance of that player, and the message is something like "i fired a gun at x,y". the server bounces this back to other clients and they keep this up with his simulation.
anywaym, im kind of in a rush right now, however if you have more questions i will help you out, just ask. hopefully this will give you some ideas.
what exactly do you consider a game state? IMO, i dont really see a need to send any constant updates. in my game, (an MMO style game), i do not send any messages at a constant rate.
now the questions you are asking have answers to them that could fill up a few papers, but i will try my best to describe this to you.
first, you will want to do as much visability filtering as possible. visability filtering means sending messages to as few people as possible while still maintaining an accurate simulation. here is how i handle it
- group players by map
- make a function that grabs all players on a map
- make a function that grabs all players who are within certain distance of another player
then, i only send updates as they happen. in general, all messages are at most sent to everyone on the same map (except for a few messages like global speach broadcast). when i client first enters the game, i send him a message saying "there are X number of people on the map you are logging into. here is their position, name, and if they are moving here is their velocity and destination, and by the way the time is T". the client gets this message and then creates all these clients on his local simulation. if a player was moving, he then uses the timestamp to place that player in the correct position. now you may not have to do this : my game is very action based so sync must be as correct as possible,but as i understand it most MMORPGs do not keep in perfect sync simply because its not needed and no one would ever notice.
now, not only do i tell the player who just logged in about the players on his map, but then i also send a message to all players on the map, saying "a player just joined the game, and he started on your map. this is his name and position". when a client gets this message, he created that client on his simulation.
ok, so now we have all clients knowing about each other, their names, where they are, etc. now we just have to keep the simulation updated and in sync. now your going to have to think about how you want to handle movement.. there are many ways to handle movement. is the game 2d or 3d? do you want to use the mouse to move, or keyboard? the former will most likely be easier and cheaper to implement, but unfortunately is not as user friendly.
either way, now that the clients know about each other, we have to keep them updated and in sync. my game is 2D overhead style ala FF3, and i use the mouse for movement. when a player clicks to move, he walks in a strait line to where he clicked. so when a player clicks, (roughly it is like this) he sends to the server "i want to move, i clicked here". the server gets this and starts the movement on his simulation, and then relays it to all players on his map. now they are all in sync with movement.
other things work similarly, but different things might have different visability filtering. for example, when a player fires his gun, the message is only sent to players within certain distance of that player, and the message is something like "i fired a gun at x,y". the server bounces this back to other clients and they keep this up with his simulation.
anywaym, im kind of in a rush right now, however if you have more questions i will help you out, just ask. hopefully this will give you some ideas.
FTA, my 2D futuristic action MMORPG
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement