Sign in to follow this  

Big landscapes in online games

This topic is 3654 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I havn't done much server programming.... (like none at all <.<) but I think I know the general idea of how it works. What happens is, all the players' info is stored on the server, so every time the server sends info to the players, it determines who is on screen the same way an offline game would. But I haven't had the chance to work on a project like that yet.. :)

Share this post


Link to post
Share on other sites
I've had as much experience as SSJMetroid above but i can think of two possibilities you can have the server send all updates to every client in that area (size of the area should be coded into the application) or have the client request the information from the server once again it would only be interested in a certain sized area.

Share this post


Link to post
Share on other sites
That's the basic idea of it. It's a bit more complicated since you have to take into consideration things like network latency, so things don't just suddenly pop into view, but the basic idea of it is still the same as it is in a single player. Think of how you cull things against your view camera in a single player game...

Really the only difference relevant to this discussion is that you have to send the player information based on what you think will be the game state in the future rather than what you know is the game state right now. You send the user a combined set of all the things you think the player will be able to reasonably see if they pursue all reasonable paths from where they currently are that they can reach within the time it takes you to transmit the data to them. Thanks to lag, there really isn't anything you can do to assure a 100% accurate synchronization between client and server on a MMO's scale, but you can at least do a pretty good job of assuring that things don't just suddenly pop into existence as the player looks at them.

The idea is the same, the scale and the exact approach is different.

Share this post


Link to post
Share on other sites
In World of Warcraft every player has a "Magic Bubble" (other games probably handle it similarly).

- the server tracks every player's Magic Bubble

- the server only sends you data about other monsters and players inside your Magic Bubble

- Thus, to your client, nothing exists outside the Magic Bubble.

As for seamless world loading:

- the world is divided into grid sections

- your client only loads data (terrain info) for the grid you are in and those adjacent

- when you move, new grid data is loaded and old data is deleted

Share this post


Link to post
Share on other sites
All of you described it like it's the easiest problem. I can solve the problems with landscape, but what to do with other players? For example we have 10000 players in game, and when somebody goes towards me I "begin to see him"! It means that the server need to send me all information in command ADD(position, nick, clothes), but if this person moved in my area, I get the command MOVE(position)... Or if player goes too far, the server sends the command REMOVE(). How to determine all of this situations for 10000 players on every second of virtual-world's life?

Share this post


Link to post
Share on other sites
It actually is a very easy problem! 10,000 is not all that many. All you need to do is measure the distance between them, which is simple. You also only need to do it when someone moves. And, you can subdivide the world (eg. with a quadtree, or just into a grid) so that you can easily ignore large amounts of the 10,000 players.

When Player A starts to be seen by Player B, you just send a description of Player A down to Player B, so Player B knows how to render it, etc.

Share this post


Link to post
Share on other sites
So do you advise me to search in quadtree for about 20 neighbours on the every move? If I have 10000 users it means that every second there's 10-100 moves. And do I realy need to search even 100 times per second?
The second question - how to determine if the neighbour enters/leaves my area? Of course I can find my neighbours on every step, but I need to find them in form "User A appeared, user B disappeared, user C left here". Do I need to store all my neighbours?

Share this post


Link to post
Share on other sites
Probably the easiest way I could think to do this would be to divide the world into nodes. Each node would be as big as the view distance (that you want players to be able to see other players at). As players enter the world they are assigned to the nearest node, as they move the server checks to see if they've moved closer to another node.

When the server software sends the other player updates it can send them out by node. You also would have it send data on adjacent nodes as well so that the client will be prepared if the player is at the edge of a node. This way you might get a couple of extra players in your update (i.e. ones that are outside of your viewable area), but you'd be certain to get everything in your viewable area and would have a reduced amount of calculations to do.

Share this post


Link to post
Share on other sites
But what to do when the player starts to jump into other NODE? Because it's a long process - to inform somebody to remove me, somebody - to add me, and load new visible nodes for me... All this time all threads that work with the objects in those nodes must be stopped, and resumed when this long operation ends. If I will do this for 2 players per second all their neighbors will wait...

Share this post


Link to post
Share on other sites
The servers that run these things are pretty beefy. They can handle tracking 10,000 players, informing them, updating them, etc, without a problem. Remember that they don't need to spend any time doing things like rendering, they only need to keep pushing data to and from the network.

Share this post


Link to post
Share on other sites
But we have not a card game where handling 10000 players is easy for computers... And I have a server where only 366 MHz, 128 RAM (a part of server) - because it's cheaper. So in my game if there are 10000 players it means that every second there's about 50 jumps to other locations, 200 move commands... And if to add some logic (like weather, threads for restoring human life, bots etc.) it won't be so easy...

Share this post


Link to post
Share on other sites
Seriously, it's not that big a deal. Moving from one node to another is an instant operation on the server, and it just means that when you next do the distance checks during the updates, you'll be looping through a slightly different subset than before. The subset will still be small and you still only need to send updates to a small number of people. If you remember who you sent updates to last time, you can send a 'no longer visible' update to anybody on the previous list who's not on the current list. And that's it, really.

Of course, you started off asking how "online games" do it, and then went on to say that you only have a 366MHz system to do it with... well, you can't expect to easily emulate professional games when you have only 10% of the processor power available. But I still don't think it's as difficult as you believe.

Share this post


Link to post
Share on other sites
As superpig said, these places have some serious hardware, and growing games like World of Warcraft are constantly upgrading to keep pace with additional players. Each "server" is undoubtedly comprised of many, many machines acting as a server cluster.

I'm just taking a wild stab here, but I'm guessing managing internet bandwidth is a lot bigger of a problem than processing all of the different stuff in the game world.

Share this post


Link to post
Share on other sites
Yesterday I began to calculate... I draw the field of 16 locations (4x4). Imagine that in every location there are 30 players moving. If I use magic bubble technique, I need to recalculate my "visible" neighbours. So for all the game I need to do it 50 times per second. What to do every second? Need to find players in some area... For example we foud 30, compare with existing player's list (OLD VISIBLE PLAYERS, len = 30 too) means that we need to make 30x30 comparsions (I have to tell to every player what players appeared in his view). So 900 comparsions, 50 times per second. You laughed at my computer configuration, but I wanna know the optimal techniques... Because if to implement this way, I need about 4 powerful computers to handle area of 16 locations and 480 players.

Share this post


Link to post
Share on other sites
There are various data structures you can use to speed up the search (for example, Red-Black trees), but I think you're massively, massively overestimating how slow this is.

Try implementing it as a prototype - just a quick and dirty simulation of player updates. Make them move around randomly and see just how slow it is to update all the information.

Share this post


Link to post
Share on other sites
I tried to calculate my method (to see 9 locations and inform everybody in them). I cross every location in 2 minutes, so for 480 players it's about 5 times per second (inform 180 players - just to loop in 4 array). On every move I need to inform 9 locations or 270 people. It's all VS 50 times per seconds (900 comparsions or some binary tree) in magic bubble method.

Share this post


Link to post
Share on other sites
You don't update on every move. Internet latency is 250ms, add 10% buffer zone to the area of interest, factor in player's movement speed, and you'll end up with needing to recalculate every 1-15 seconds.

Real-time here doesn't mean milliseconds, and you'll need to compensate for latency anyway, probably providing state synchronization for several seconds in the past.

So updating AOI once every 10 seconds for a reasonable range is probably enough. Note that once you establish interest subscriptions, finding out when someone moves out of range is very cheap - just check for subscriptions to a given object.

By far the most costly process of this will likely be serialization - but since not everything changes on every step, or you send only delta states, you can cache plenty of state information, making sending new information to a plater a relatively cheap process.

Quote:
And I have a server where only 366 MHz, 128 RAM (a part of server)


With all due respect - MMOs do not run on pre-historic hardware.

If you're thinking about 10k users (WoW does 3-5k per server, distributed over several machines), you might need to invest into a bit stronger hardware.

The typical load per machine is usually in the hundreds range.

Share this post


Link to post
Share on other sites
What you will want to do to save bandwidth is to use some sort of server-side client manager that is like a scene manager on the client side.

AKA smap, speed tree, ect...

So what you will do is create a very big array for your world, and devide that world up into cells, so lets say you world is 100000m (meters) long by 100000m wide, and you want cells that are 20 meters big.

so you would go 100000/40 then you would get how many cells wide and long.

Then after that you would make an array that size, after that you would have the client send you an update packet on its position then you would take its position and then find the cell that he is contained in.

so it would be like this:

|o|o| | | | | |
---------------
|x|0| | | | | |
---------------
|0|0| | | | | |

Where "x" would equal your character, then you would get the cells around him that are marked with "o" and load everything in those cells, just make sure when you do it to make it as memory effective and cpu effective as possible, and watch for memory leaks, because you will be allocating and deleteing alot of memory.

BTW, thats just one method, there are many many many other methods.

Share this post


Link to post
Share on other sites

This topic is 3654 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this