Download

Client-server implementation feedback

Hi all. I’ve been working on getting a previously-singleplayer prototype to work in a client-server model, and I’m looking for feedback on some of the implementation choices I’ve made - namely about avoiding conflicting set function results.

Here’s what I’ve done:

It’s a simultaneous-turn-based game, so players queue up actions during a round, and when the last turn is submitted, the game processes everything, the new round begins and everything happens again.

It’s moderately UI based, so there are a few cases of texts updating as soon as a player has submitted an action, e.g. notifying the player that they don’t have enough action points. Previously this was fine because each action was a function that the UI could wait for and get return values from, then display the text. When I had to change to replicated RPC events to get things working on the server, it became a little hard to get that info straight away. So because I was replicating every class and variable to the clients, I set it so that it runs the function locally which gives the return values, and also calls an event on the server that runs the same function to perform the authoritative change. Because theyre the same function and data, when the server replicates down changed variables theyre the same.

The next issue that I had to think about was that of conflicting sets. Player values (e.g. each player’s price theyre selling a good at) are stored in array, with indexes corresponding to the player number. Originally I thought that if one player had a significant delay and attempted a set with outdated information (because it has to replicate the entire array), it might overwrite another player setting their own value. Then I thought it through and realised that this would only ever be an issue locally, and even then only temporarily - the actual set is done on the server through a replicated event with inputs, and the server will always process all the events it gets, updating the arrays, so that even if a local copy is wrong the correct copy will be replicated down.

Can anyone think of any ways this might break in adverse network conditions?