Making a video-game has the following challenges on variable storage:
- send player states every 50-200ms, so store position/ rotation as efficiently as possible.
- store large blocks of data for each player regarding their cooldowns, abilities, and loadout
- all variables have to revolve around the connection id assigned when they connect to the server, not who they say they are
solutions considered so far:
- use an integer as a "player id" which looks up data on dozens of arrays. Inform client of this number regarding each player for them to use in the backend API. Drawback- ugly and unwieldy on the server side.
- map each "player id" to a class. Drawback- have to iterate just to get the positions / rotations every 50-200ms.
- make an array of structures again using the "player id" as the index. Drawback- same as above.
However, each of these solutions using the "player id" as an index doesn't work well when the concurrency is unstable- with players coming and going. There are three approaches (to the actual structure of the data sent):
- mirror the list/array on the clients, then notify the clients when there needs to be a change made (ex: player x left, all player's >x down iterate). This has a tenancy to break things between the lag.
- attach the player id to each positional update as opposed to inferring the clients can deduct it from the array index.
- send a static array with an unchanging number of slots, all unoccupied positions get sent anyway. There's supposed to be a crossover point where this is more efficient than including the ids if you're utilizing a certain amount of it.
What would be the best solution to this scenario?