Skip to main content
2 of 2
Fixed formatting. Reordered and retitled for clarity.
Anko
  • 13.5k
  • 10
  • 56
  • 82

How do I create a multiplayer server also suitable for local single-player?

I've created a voxel game in C++, OpenGL and SFML, and I want to make it multiplayer.

I'd like to make it similar to Minecraft's client-server model: The single-player is just a client to the hidden server underneath; but can be configured to connect to multiplayer as well so that the single player and multiplayer code are one and the same.

Spitball-ideas:

  • Use a separate thread for the server logic and then share the data between a synchronized point in the code for the client.
  • Just send packets to local host from the server thread and collect them from the client thread.

How should I do this?

John
  • 45
  • 8