I'm currently trying to implement networking (thanks jimbo for mentioning lidgren
). I'm a hell of a lot confused with the whole process.
I understand the basic concepts, like sending delta positions from the client to the server, which distributes it to every other client.
In fact you wouldn't even want to send positions as these might be compromised, but i will not care about this for now.
I am trying to implement it into my engine and ran into multiple obstacles.
Quick rundown of how my engine is structured wrote:
Game class - most underlying object, initializes opengl, the window, manages timing and calling the respective methods in the scene
Scene class - only one Scene can be attached to the Game class at a time, it provides Load() Update() Render() and such
GameObject class - the Scene can hold an arbitrary amount of GameObjects. The GameObjects can have an arbitrary amount of GameObjects
1. If i have a dedicated host running, i generally don't want any rendering to happen. Finding all references to OpenGL, rendering or anything in that respect and adding
seems a bit unconventional to say the least. So what i think makes most sense in my case is creating a seperate Game class (GameServer) that only provides timing and Load() and Update() to the attached Scene, so the rendering doesn't happen. There's still calls to GL though when initializing VBO's in Load(), or changing uniforms in Update() for instance. This seems like a major set back to use this method in the current state.
2. If i have a listen server running, i simply have one player acting as a host, redirecting the position (etc) to other players. I don't see the downsides of this, except not having a dedicated server running instead of locally hosting.
3. Having a server that simply receives data, and redirects it, without simulation and processing. This probably is the least favorable to use. I would guess you will end up with out of sync gameplay pretty quick, depending on the packages being lost or discarded, difference in framerate and updates.
I will for now stick to 2. and will try to get basic server client communication going by the end of the week, walking, shooting, dying etc.
What is your take on this? How did you model your networking, or what am i possibly missing here?