Hey guys,
This is making my head explode so I hope you can help point me in the right direction. I've simplified the actual process here.
- There is a server and multiple clients
- The clients and the server have a 10 by 10 2D array of integers
- The client can choose any position on the grid and change it to any integer
- When the client changes an integer it changes locally instantly so there is no input lag
- The request is then sent to the server and only updates on the server it if that position hasn't been set by anyone else
- If it's updated, the change is sent to all the other clients and is updated on the clients
Now I'm sure this is a common problem but I can't wrap my head around it. What if two clients try to change an integer at roughly the same time, what is a safe way of doing this. If client 1 has already updated itself locally, but client 2 updates on the server before client 1's request makes it to the server, how do I undo what client 1 has done and update it to what client 2 did.
I hope this makes sense. I'm not really looking for specific answers. I'm more curious if this is a specific topic with a name I can research. Most networking stuff I've read is about movement interpolation, etc. Any direction is appreciated. Thank you.