So basically I have a design for attempting to do multiplayer matchmaking.
Essentially what it is, is the ability for people to host their own games, without the need of:
- Dedicated hosting (the server)
- Port forwarding (TCP and UDP)
First off, do you think matchmaking is better or worse for people who wish to play your multiplayer game?
By that I mean, will it drive people away or closer to playing your game? Will your game be more popular if you offer
matchmaking or more popular if you allow people to host their own servers?
Anyways, my design for matchmaking is that everyone connects to one server of which I host (or have dedicated hosting somewhere else, none the less same thing).
When a player wishes to "host" a game, a message is sent to the server and the server will create an instance of a class known as "Match".
Match will hold all the information necessary for a game match,
- Instances of incoming players (player names, keypress/keyreleases, positions, score, etc.)
- Who the host is
- The scores of the players
- What's currently happening in the game
- Solid blocks
With that said, Match will be doing a lot of work.
For example, in this game, there are multiple rooms to the world.
Each room has its own list of solid blocks for the server to do collision checks.
The reason for this is, it needs the information about the map, because the client also has this information.
The clients are basically a dummy. The only thing they do is send keypress/keyreleases, and the server will update the position
of the players, and check collisions. The server then sends keypress/keyreleases back to everyone (including the player), as well as the new positions of the player, and the clients will update the position/move the player/stop moving the player accordingly.
This way, the clients have no way of modifying their position for their advantage.
Anyways, like I said the Match class does a lot of work. Because the server checks for collisions on its side as well, the server
- A list of all the rooms
- For each room, a list of solid blocks and their positions
With that said, there would be multiple Match instances. Depending on how popular the game is, there could be as few as 10 or even 30 to 40 Match instances.
That's 10-40 threads, or maybe 2 threads for each Match. One thread would be for game logic (updating player positions, collisions), and the other thread would be for networking logic (what to do for incoming messages).
All of that plus the main server thread that listens for incoming messages (TCP and UDP).
Is this efficient for a small server computer to do?
Or would it just be better to let players host their own servers?
What do you guys think? Am I overcomplicating it?