Client/Server with scripting design question

Started by
4 comments, last by wodinoneeye 13 years, 3 months ago
Hi all,

I have successfully implemented a simple client server model within my game, which also makes heavy use of Lua scripting. However, I've run into an issue I would appreciate some advice on.

There are a number of cases where the server has an algorithm, which is represented by a Lua function loaded from script, but individual clients can have different values for the parameters that drive it, resulting in different algorithm outputs. What I am stuck with is how to make sure that the algorithm is run with the correct parameters for each client. The only solution I can think of is for the server to request copies of the parameters from each client and store them ready for use, but this seems very inelegent, and I was wondering if there was a solution I am overlooking.

Any advice would be extremely helpful.

Thanks,

Phil
Advertisement
What are these functions doing?

You want to make sure your server has the final say in what happens. You might want to have the server send the outputs of the function to the clients. The clients should be pretty dumb, only sending user input to the server and rendering the outputs from the server.
In the example I was considering they are deciding the way elements of the game are positioned on the screen. Although the server has ownership of the overall algorithm that is used, clients have some configurability with some of the paramaters that the algorithm uses.
Quote:
In the example I was considering they are deciding the way elements of the game are positioned on the screen.


Are these UI widgets? The server shouldn't care where the UI elements are placed. This should be up to the client. The client should receive information about a widget from the server (ex. health, ammo, etc.) and the client should be free to display that information any way it chooses.
No, not UI widgets - I have good clean seperation for these. The things I am talking about are actual 'actors' within the game world. The game is card based, and certain aspects of their placement are sometimes user configurable. What I would like to be able to do is have the overall algorithm that decides the placement of the cards on the server, but for there to be parameters within it which individual clients can have set differently (typically within certain bounds). Different clients can set these seperately for the same actors, which could and probably would lead to the position of some actors varying from client to client.

The server should be the central place that integrates all the parameters from all the clients and arbitrates the results of all interactions.
So all the client variables related to those interactions need to be sent to the server including if they get changed by the user or by a 'smart' client.
Then the server calculates the results for that cycle of interactions and sends them to all the clients (or at least what each client is supposed to see).

Otherwise you have the clients running their own calculations as you admit with possibly the wrong variable for other clients and even if you did have the client send all these to the other clients there are timing differences and replicated data transmissions involved .

Trying to distribute the simulation so that each client calculates in parallel leads to discepencies and possible different viewed results on each client.
--------------------------------------------[size="1"]Ratings are Opinion, not Fact

This topic is closed to new replies.

Advertisement