Ideas for online multiplayer

One of the things I eventually want to add to the game is online multiplayer. Since this isn’t an officially-planned or set-in-stone feature (multiplayer is expensive) I figured I’d just jot them down here and see how many of you guys are interested…and what ya’s think.

A note on the in-game Internet

You need to know how Socially Distant’s Internet works. There’s an article on the wiki that explains the Internet system in full detail, but essentially:

  • In single-player, there’s a City.
  • Cities have Internet Service Providers.
  • Homes and businesses connect to Internet Service Providers, through their LANs.
  • A LAN can have many Devices on it (computers, phones, etc.)

Devices connect to LANs, LANs connect to ISPs, and ISPs connect to each other forming the Internet.

Client/Server vs. P2P

Socially Distant doesn’t work as a P2P game, it must be client-server. You need to be able to hack into the computers of players who are offline, and that’s fundamentally incompatible with a P2P architecture. But there’s a reason P2P exists and that is it’s cheap. Players can act as hosts.

Client/Server works a lot better for Socially Distant because the server acts as the host and manages the game’s state. The server can be completely authoritative and manage the state of all players even when they’re offline. But that also means there must be a server to act as the authoritative host, which means it’ll likely be hosted by me and I’ll be the one paying for it. Just like this forum.

Servers also have resource limits. Only so many players can connect before network throughput, CPU and RAM are exhausted on the host. And only so many users can store save data before the server’s disks are too full.

The solution to this that many games use is to have a fleet of servers. As resource usage goes up, you can add more servers to the fleet and the game just keeps going. But that costs even more money over time. Who pays for it?

Well… generally you’re either a large studio that can afford it, or you’re okay with things like subscription services, microtransactions, pay-to-win mechanics and ads. I’m neither. So client/server isn’t feasible for this game. Not unless you want to fork over millions to my Patreon as a collective community. I’d appreciate that if it happened, but I don’t expect it to and I’m not going to budget around that. That’s just irresponsible.

But there’s another possibility… The community can maintain the fleet.

Federated Multiplayer: Treat Gameservers as In-Game ISPs

The beauty of how Socially Distant works is…the in-game networking simulation can be adapted into an actual networking system. Remember the hierarchical structure from earlier, how devices connect to LANs that connect to ISPs that connect to each other. Let’s take advantage of that.

Let’s treat each real-life player as a LAN. We do that so that we can have a mechanic where the player can grow their own network with new devices they’ve purchased in-game. To get internet access, the player picks an ISP to connect to.

Anyone in the community can be an ISP. As long as there’s at least one. Players can connect to it and interact with anyone on that same ISP and there’s our multiplayer. Right?

No. That’s a Minecraft server. Let’s take it further.

Let’s let these servers connect to each other. In-game network traffic can now route through multiple game servers and you can hack someone on ISP 1 while you’re connected to ISP 2. The game servers can also share state with each other over that some connection, such as which players are online.

The real power comes from gameservers agreeing to connect to multiple other gameservers. This adds fault tolerance. If we have three ISPs connected to each other in a triangle, one ISP can lose real-life connection to one other ISP and…that sucks. But traffic can still route through the third ISP to get between the two disconnected ones. If one ISP goes fully offline and there’s no route to it, welllll that stinks. But only players connected to that ISP lose access to the entire network, they’ll appear offline to you.

We can also provide a protocol whereby each ISP in the network can agree where to connect players to if it goes offline, but I’m not sure how that would work. It may be better to let the player manually decide that.

But there are issues with this.

At least that’s what I hear you say.

1. Save data

Where is it stored? If you trust ISP A with your save data and they go offline forever, do you lose that progress?

Not exactly. We can store your data locally and let you be authoritative of it. But anything critical, such as in-game bank balance, would be relayed to other gameservers on the network. As long as we collectively agree to create one large network instead of many small ones, this data should be well-replicated and safe as long as at least one gameserver has a copy of it.

Only the player’s current ISP is authoritative over the data and can mutate it. Contents of the player’s home directory, for example, would be stored on the client.

2. Authentication

How do we know a player is who they say they are? How do we prevent cheating? Well…this is a Steam game. Let me introduce you to the concept of VAC and the Steamworks API. Let the server software handle that.

Any client-side save data would be cryptographically blessed in some way that allows the client to read and write to it iwhen not connected to a game server, but:

  1. You must be able to connect to Steam before even accessing multiplayer
  2. You can’t access things like in-game currency, websites hosted by other players, or anything else that would be stored on the gameserver if you’re offline.
  3. We would need all gameservers (not just ones on the network you previously connected to) to be able to bless local save data, so that a network can go down without players losing their progress.

Would this be possible? Who knows. We may just need to live with certain limitations.

Ideally most of the anti-cheat stuff would be dealt with by Steam.

This might not actually work.

I want you guys to keep that in mind. We need to discuss this as a community with the expectation that multiplayer may never actually exist in the game. It’s a nice-to-have and something I want to pursue though, so this is my idea for how it’d be built.