Answer the question
In order to leave comments, you need to log in
How to organize the synchronization of the game world between the client and the server?
I decided to write a network game and came across an area little known to me - synchronization of the client with the server.
Important data:
Answer the question
In order to leave comments, you need to log in
Look at the question https://toster.ru/q/142555, it contains some points that will be useful to you. I'm including a few links to "read".
And the solution to your problem will very much depend on the number of players in one location. If there are few of them (say, less than a couple of dozen), then each such location is likely to be independent of the others, and the synchronization task will become much easier - fewer objects will require synchronization. And on one server several such locations will fit.
If there are many players (a hundred or more), then the architecture will become very complicated. So much so that it makes no sense to start studying on such a project. Read the question I posted above about this.
What technology is planned on the server and on the client? (programming language, platform)
A very broad topic. Books are written about it. Here are a couple of general tips
Why the hell sync them?
TCP for the quest accepted, gave the quest, and for the unit, the tryam ran here.
UDP if you want to do packet bombing.
Caching for "hot" things, database for "warm" and more or less static. You don't need to render the map on the server. Read about thick-thin client.
1. The client requests an update from the server only when it is active (not minimized, the modal window with settings is not open).
2. For authorization, the request to the server contains the session identifier created when entering the game.
3. The server returns information only about visible cells and the player himself. Do not trust user data - you should not send the current position of the player in the request, it must be stored in the database (this is also required to implement 1 point).
4. Calculate the movement of mobs only for those locations where the players are (or have been recently), generate maps only when the player moves to this location.
In general, try not to calculate extra data on the server, not to request data from the client when it is not necessary, and not to transfer data to the client in excess of what is needed.
Everything here is simple:
1. Polling for events from clients in a circle ("round robin")
2. Order: batch-> check-> set values on the stack (or discard)-> move to the next event (and so on until the delay limit will not be reached) -> sending the final result of the "world" to everyone who sent the event -> the next portion, etc.
Thus, the rule is achieved: "everyone knows about everyone synchronized and without delay, and they are also checked on the server."
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question