2
\$\begingroup\$

Background information:

I am developing a game similar to other 4x games like Sots, MoO,...

I am storing all information about the game(like star/planet/ship/fleet positions, owners and a lot of other stuff) in a data structure in memory. I call this structure the datastore.

I have one client act as server.

All clients should have a copy of the datastore, because in case the server disconnects another client could overtake the server role.

On the end of every turn all changes the clients did should be stored in the server datastore.

If it is important I use C# and Unity Pro.

Question:

After all client changes are applied to the server should I just copy the complete datastore to each client or is the way to go to sync only the changes made?

I would appreciate to get answers that not only include personal opinion but more about drawbacks or advantages of the different approaches.

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

The way I see it there are effectively 2 ways to handle this.

  1. every "command" a user intends to issue is stacked up in a local list then sent to the "server" at the end of each turn who then forwards on the lists from other players to ensure the data is replicated to all players.

  2. Every time a player issues a command to be added to the list of things for this turn its immediately passed to the server then at the end of the turn a final "im done" is received from each player and the server triggers a new turn.

The sync would happen in the same way in both situations a list / list per player is built and at the end of each turn the list(s) are processed by all.

The 2nd approach seems to be a bit better in that at the end of the turn its all action and no waiting for network sync however lists are in a sort of "fluid state" until the end of the turn as a player may chose to undo a previous command I guess as it's technically not "official" until the turn ends.

That said its just a "undo" request each time that happens.

I'm sure there are many other ways to do this but this is essentially how I would go about it :)

By having every client periodically dump key information to disk you could then effectively reload the game if any 1 player had their copy of the data intact.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .