How to make a game for P2P and Dedicated Networking

First a bit of background: I am currently in the process of developing my game from the ground up to be networked. However, when I initially launch the game, I would like to not have to pay for dedicated servers until I’m sure that I will make enough money from the game to support it. So when I first launch, I would like to launch with P2P networking, and later transition to dedicated servers. I have to date been building my game for the dedicated server model, but I would ideally like to be able to support both models, and possibly even have support for LAN games.

Today I tried running my game in a simple P2P model where Client A spawns the map in “listen” mode and Client B connects to Client A. Since I have mostly developed with the idea that there is a dedicated server, things naturally did not work out so well. I would have to adapt my code alot to take into account that the Authority could also possibly be a player in the game, as opposed to just being a moderator.

I woudl like to get some opinions on which model would work better for a game looking to support both P2P and Dedicated servers:

  • Option A: Build the game so that it takes into account all the possibilities for both modes. Pro is that all logic is contained in 1 process, Con is that it will create additional complexity each time a new feature is added which requires network replication.

  • Option B: When the game is started, the host would launch a dedicated server as a separate child process. Pro is that it’s literally identical code for P2P and Dedicated, Con is that the host will need to bear the additional processing cost of a separate process

I am curious what are some thoughts on these two options, and possibly other options that I may not be considering.

Thank you for your time.

Basically require players to run server executable and client executable. Then use their server to communicate to other clients and their own.

I too would like peer to peer it seems unreal removed it from Trello. For true P2P you can use current model but would need each player to run a client and server instance. Then brute force ip search for anyone with your game. I think you would need to create a virtual port on one of the common open ports to avoid legal issues. Which is something I’m working on now.

Sorry I never answered this. This is what I ended up doing. Separate process for client and server is best, and the additional cost is not much for the host if their machine is decent.