Serverside calculation of different levels

Posted By: Vorick

Serverside calculation of different levels - 03/03/09 20:39

Hi there,

I'm currently stuck with kind of a difficult question. Let's say I have two players connected to a dedicated server. Both are in the same level, so I just load the level on the server and perform all calculations there. As far as I understand it, it kinda works like this:

P1 sends movement request to server.
Server checks validity of movement and sends back new position to P1 and P2.
Position of P1 is updated on both clients.

I know, that's only the basics, but you get the idea. As of this point I'm not running intro troubles, because I can perform all my nifty movement, collision detection and stuff, because my server has the level loaded.

What if P1 is inside the level "New York" and P2 is inside the level "Boston". I can't load both levels serverwise to perform every calculation that has to happen. When my server is running the "Boston"-level how can I calculate e.g. falling damage for P1 in "New York" when he's jumping from a bridge, without the level geometry on the server-side?

Any hints are appreciated.
Posted By: giorgi3

Re: Serverside calculation of different levels - 03/04/09 01:03

I believe a server process can only handle one level at a time. However the network engine allows the concept of zones. So New York would be one zone and Boston would be the other. The way it works is each zone is handled by a different server process. The zones can run on different computers, and you can pass a player between the zones as needed.
Posted By: Dark_samurai

Re: Serverside calculation of different levels - 03/04/09 06:39

I agree. You will have to use zones. But zones are only supported by gamestudio professional.
But you can also use zones with ANet (a plugin created by me) and your Commercial edition.

Just look into my signatur. (A HowTo create Zones is not included yet but I'm already working on it).
Posted By: Vorick

Re: Serverside calculation of different levels - 03/04/09 07:58

Thanks for the replies.

I already looked into the anet-documentation but there was nothing to be found regarding zones, besides the fact, that it should be possible.
Posted By: Dark_samurai

Re: Serverside calculation of different levels - 03/04/09 08:45

It's only in the new manual I'm currently working on (it will be released an ~1 week) with several other new HowTos.

But it's realy simple:
-create a server for each zone (attetion: use different ports and you can only create one server per application, so use more windows if you want to use more servers)
-on server A you load New York and on server B you load Boston
-connect with a client to server A or B
-if you want to change the server: disconnect and connect again to the other server


Posted By: Vorick

Re: Serverside calculation of different levels - 03/04/09 10:20

Okay, so that's the way I had it theoretically figured out. I was just hesitant to think about 50 levels loaded in 50 server-applications at the same time on one single machine.

Also I might have to use a more hands-on approach apart from your entity-function-set. The thing is, that I don't want to terminate and reconnect each time a zone change occurs. Therefore I have to have a persistent connection throughout each session. Below you'll find my first concept of the server structure.



After authentication (grey arrow) the authserver appoints a session server (of which there could be many) considering the amount of players already on a session server. He then tells the session server to expect a new client and tells the client on which session server to connect (red arrows).

After the connection is established, the session server queries the database server for the last known position and other information (playerstats and such). Then it queries the level management server for the level which might end up in the player being placed in this level or forced to another one if the player is in an area that doesnt exist anymore.

To put things short: All actions are routed through the session server so I don't think entity updates from a level server can be easily handed forward directly to the client. From what I gather I have to do this manually. Reconnection according to this layout is out of the question, because I would have to re-authenticate every user on a zone switch and the connection to the chat server would be lost.

On a sidenote: From my experience your ANET-Lib is really good. I thought about doing one myself using RakNet, but why reinvent the wheel. I'm still in the process of evaluation, but if ANet fulfills all needs, you can expect a paypal payment soon. :-)
Posted By: Dark_samurai

Re: Serverside calculation of different levels - 03/08/09 11:01

As far as I understood you, you want to forward the player positions of all players from the level servers through the management server and the session server and to the client?

This would cause extremly high latency and traffic. Something you can't allow when you create a MMO game! You always have to connect the client directly with a level server (= a Zone). Zones are used to reduce the traffic because each zone has only e.g. 32 clients and these are updating their positions. Clients that are in ZoneB don't send their positions to clients in Zone A. => Instead of 100 clients in one big world, you use 32 Clients per Zone and 3 Zones. => traffic is 1/3 on the clients.


A good structure would be like that:

Code:

You login in the login server:

[your client]
    |
[Login Server] - [SQL Server]  <= Stores the Player accounts + last pos

Then the Login Server forwards the player to the correct zone by
telling the correct IP and Port of the Server.
The Client connects with the Zone server and disconnects with the Login Server.

[your client]
   +
[ZoneA]   [ZoneB]    [ZoneC] ...
   |         |         |
[clients] [clients] [clients]


[SQL Server] <= Stores items,... (every Zone Server can connect with this server)


This is a more simple and even more effective way of how you should do something like this.
Posted By: Vorick

Re: Serverside calculation of different levels - 03/08/09 22:05

I don't think that your layout would work, because you always have to run one process managing global events other than level-specific stuff.

But let me ask you the following: If one machine can be simultaneously be server/client, would it be possible to connect a client pc to a client/server-levelapplication which itself registers as a client on a third machine?

Code:
   P1             M2               M3

[Client] -->  [Server&]
              [Client ] -->  [AnotherServer]



Would this work?
Posted By: Dark_samurai

Re: Serverside calculation of different levels - 03/09/09 16:40

Quote:
I don't think that your layout would work, because you always have to run one process managing global events other than level-specific stuff.


If you do it simple you won't need a global managing server. And this "simple" version is even hard enough smile
If I were you, I would start with more simple things.

Quote:
Would this work?


No! A client can't be connected with two servers at the same time.


If you want to use a global managing server you could use ANet Professional and the UDP feature that allows you opening a udp socket beneath the "normal" client/server in the same application:

Code:

          M1 (management)
           [UDP Server]
     /           |          \
M2/ZoneA       M3/ZoneB   M4/ZoneC
[UDP client][UDP client][UDP client]   ... connected with the udp server
[server]      [server]    [server]     ...  manages the level, players,...
   |             |            |
[clients]    [clients]    [clients]

© 2024 lite-C Forums