Social Integration
Always wanted to know more details about what kind of OpenTTD your friends are playing? You finally can!
In OpenTTD 14.0 we ship a plugin system which allows OpenTTD to integrate with systems like Steam, Discord, GOG Galaxy, etc. This didn’t came easy, and is the work of many years figuring out what the best approach would be. Let’s delve in!
Licensing
The first hurdle we had to take, is to figure out how to deal with licenses.
As you might know, OpenTTD is released under GPLv2. This is a good license for an Open Source game, as it ensures that everyone who makes a modification to the game, also have to release the source for that modification. And, if we would like so, we can integrate that change back into the vanilla game again, allowing everyone to enjoy that modification.
There is one downside of the GPLv2 license: it is not really compatible with many other licenses, as it is kinda strict in the implications. I am not going to delve too much into the details in this post, but just know once something is GPLv2, everything it touches has to be GPLv2 or compatible with it.
To integrate with social platforms like Steam, Discord, etc, you have to make use of an SDK they supply. And, as you might have guessed by now, they are not licensed under a so-called “free” license, which conflicts with our GPLv2 license.
Besides the legal part of the license, we also have the social part of “how people feel about it”, if we would integrate such non-free SDKs directly into the game. And this has always been a debate.
As it goes in the world of Open Source Software, people tend to have a very strong opinion about the “free” part of the license. And so integrating with something non-free is against the principles, and as such, by their argument, bad. We can’t simply dismiss such arguments because we want to integrate with social platforms. Which means we need to find a balance, so OpenTTD as game remains Open Source, free, and GPLv2 licensed, while still allowing us to integrate with social platforms.
The solution? Make it a choice.
Plugin system
To ensure the game itself remains licensed under GPLv2, we created a simple plugin system which allows us to extend the game with other binaries which might be licensed differently. We have been doing that for years and years now, via our BaNaNaS system. This delivers in-game content to the user, while the author of such content can license it how ever they like. The only “demand” we make, is that the author gives us the right to distribute their content, and that is is available free of charge.
In result, we see a wide variety of content on BaNaNaS, under all kinds of licenses. Some authors embrace the ideology of OpenTTD, and use open or free licenses. Others are more protective of their work, and do not allow anyone to make derivatives of their work. From our point of view, we don’t actually mind either way: as long as our players can download it for free and enjoy the content, we are more than happy.
The plugin system that is added to 14.0 is not much different from this. Although technically it is very different, more on that later, but from your point of view it is the same: download a plugin, put it in the right folder, and enjoy the added functionality.
Currently we release three plugins: Steam, Discord, and GOG Galaxy. The source of those plugins are released under MIT licenses; another Open Source license, with much less conditions compared to GPLv2.
Security is a thing
Content uploaded to BaNaNaS is executed in the game via sandboxes: nobody can read files on your computer, make network connections, or anything like that. They can only do things we allow them, which is a very restrictive set of things.
This is a lot harder for a plugin system that integrates with platforms like Steam, Discord, GOG Galaxy, etc. We can’t sandbox those really, as they have to be actual binaries that run on the player’s system.
As such, we have a dilemma: if we would allow a plugin system in the same way we allow BaNaNaS content, anyone could upload a plugin for anyone to download. And that plugin could, in theory, contain things that are harmful to the player. For example a bitcoin miner or something silly.
This meant we had to find a balance between allowing such plugins and not allowing anyone to just provide such plugins. What we came up with, is a system where a plugin can only be loaded into OpenTTD, if we, The OpenTTD Development Team, approved the plugin.
We find this less than ideal, as we like that for example BaNaNaS allows anyone to come up with ideas, try them out, see what people think, etc. But, we also have to keep the security of players in mind. And there is just too much potential for harm when we would open up the plugin system to anyone. As such, we were left with no other choice than to restrict who can make those plugins; or of course, not do it at all.
In result, every plugin is released and signed by OpenTTD, and before loaded into the game, it is validated the signature is correct. If you are a developer and want to design your own plugin, please come talk to us.
Capabilities
With the licensing and security finally addressed, and a solid idea how to build the plugin system, we could start working. But as you can imagine, it was a lot of work, with a lot of moving parts. Like … seriously, it took many hours figuring all this out, and getting it right.
An additional challenge was that we release for three OSes: Windows, Linux and MacOS. And they all deal with plugins like this in a different way. A lot of testing, failing, trying again went into getting this right.
Which also meant we had to make choices: get something to work now, and build on it later, or try to do everything at once, potentially never finishing it at all. We went for the first approach, but it also means the current capabilities of the plugin system are rather limited. So don’t think too much of it yet.
The main thing it currently does is announce you are playing the game, whether you are in the Main Menu or in-game, and what kind of map-size you are playing. Other things like being able to join each others games etc is all not implemented yet, but hopefully someone will pick that up for the next version. But, as always, no promises there.
How does it work?
When you first start OpenTTD 14, a new folder “social_integration” will be created in your OpenTTD documents folder. In here plugins can be installed, for example the Steam plugin. You have to extract its content in this “social_integration” folder, and start the game.
Under “Game Options” -> “Social”, you will now find whether the integration is running.
For Steam, we automatically add the Steam and Discord plugin. For people downloading the game manually, they have to download the plugins manually too. This is mentioned on the download page.
The future
With the biggest hurdles out of the way, the future is bright. We now finally have the ability to extend OpenTTD in a way that doesn’t violate our license or the essence of the license, while still integrating with non-free platforms. And that in a secure way.
This means that for next versions we can start looking into other parts of these platforms, like making use of their network capabilities (joining people’s games, but also maybe making use of Steam’s relay network), or possibly even achievements.
It will not happen overnight, and maybe not even in a few years. But instead of having to deal with all the above things, developers can now focus on that what is actually interesting: the plugins themselves. Of course this requires people working on this, so if you like a challenge and want to help out: feel free, go nuts!
More about OpenTTD 14
This post is part of the series of dev diaries about big new features coming in OpenTTD 14. Next week, we’ll …