Thursday, February 27, 2014

Little Game Programming Love (LGPL)

Hello Again,

First off, I was really reluctant while writing this, since I know lots of people take this kind of thing personally. I am an Open Source user, I have contributed to several Open Source projects and I preach open source to whoever I talk to. I also use Open Source operational systems.

Today I come to talk a little about something less technical than usual, but that some of you will certainly find relevant: the LGPL license.

A couple of days after I posted my bookmarks here on the blog, someone asked me if all those engines were free for commercial use; I promptly (and wrongly) replied Yes, without really checking it. In addition, yesterday, I saw someone in a forum saying that the LGPL license seemed to be an irrestrictive license. That is the general picture, LGPL is a confuse license, that seems free for commercial use without further considerations. A really fast google search revealed to me that lots of people use it without knowing what the restriction really is; while other people actually misexplain it on forums all over the web.

As I stated in the other post, there were some stuff there from before I even knew what GPL and LGPL meant. I just knew they were open source and that open source means free! Right? Well, yes... maybe a pinch too much. I decided to remove from my bookmarked engines the following entries: Indielib (LGPL), Mutiny (GPL)¹, Spherical (GPLv2), Fife (LGPL).

I won't go through GPL, since most know that it isn't usable for commercial projects. But how does a license like LGPL affect the developer and the end user?

Around the Internet, I have seen people describe this really differently. Some state that if you don't alter the libraries it won't matter (misleading enough?), while other misquote Ryan Gordon and say SDL2 changed to zlib because "people get nervous" about LGPL, but not due to the license itself. Doesn't seem like a good technical reason to me.

Clearly, none of them had even skimmed the LGPL license before answering.

¹ - It seems like Mutiny has been mistakenly licensed as GPL, while it was probably meant to use a license similar to Maratis-3D (engine is zlib while editor is GPL). I may put it back if that is the case, but will need verification. I sent the creator an e-mail, but am still waiting for the response.


What's LGPL?

The (GNU) Lesser General Public License is a free software license that allows commercial use. The main principle of this license is that it is free to use; and they make it clear in their terms. Still, it is really restrictive and confusing.

But what does free to use mean? Basically, it means that any developer is allowed to use it on their projects. In addition, it also means that the user is given the rights to freely debug, modify and relink your program, given that he does it inside the scope of the library.

This, initially, doesn't seem like that much of a problem. Of course, it raises a red flag on static linking, since it would legally allow anyone to reverse-engineer your software. Still, dynamic linkage seems to solve these problems. And it does, to an extent.


LGPL isn't always bad


When you see a software that uses code from the Qt Project (LGPL), it is usually a simple GUI application, that no one would really care about hacking or cracking. But why the jets does the Qt Project offer a paid commercial license then, if there's a free one? It all comes down to the needs of the software.

You have to study your case and evaluate whether or not your project has some specific needs or limitations.
  • Is your game a hobbyist project ¹?
  • Is it exclusively single player ¹? if not,
    • Does the multiplayer portion rely on a secure server (not hosted by the player) ¹? if not,
    • Would a cheating player ruin the other players' experience ²?
  • Is it free to play ¹? if not,
    • Would you try and take down crack distributions for your game ²?
  • Does your game's distribution mechanisms prevent you from honoring the "free to use" rights ²? (iOS?)
The entries marked with ¹ are indicatives that your project wouldn't suffer from the usage of LGPL licensed code. So, if this is your case, just go ahead and happily use your LGPL licensed code, just like you were using zlib/x11 licensed code.

Still, if you answered yes to one or more questions marked as ², you'd need to rethink your LGPL dependencies.


I'm on the dark side, what now?


The problems that come with the usage of LGPL licensed code all come from the fact that the user can modify the library our game is using. As the used library is certainly available, it is trivial to add custom code to it; and that's exactly what LGPL swears to guarantee, that the user is free to use it as they wish.

But games are special cases and have special needs. General software wouldn't really suffer from LGPL licensed libraries, but some games do. If your game has multiplayer (specially competitive multiplayer) you would want to be able to ban cheaters. The same goes for controlling crack distributions, in the reachable spectrum.

Multiplayer

If your game has problems with altering its multiplayer behavior, giving the user legal rights to modify the library (and, consequently, your game) isn't the best idea. Despite of what your TOS stated, you wouldn't be able to ban a player that is hacking your game by adding some custom code to the library, even if that code isn't related to the library's functionality at all.

This brings us to the possible solutions to this problem:
  • Use a secure server where the LGPL dependent client is merely an interface for the game, and altering it wouldn't break anything.
Even if you do this, it would still be legal to distribute modified clients with integrated bots and other features. If the modified part doesn't touch your own files, but only modifies the LGPL dlls and possibly adds some extra files, there's nothing you can do.
  • Separate the server from the LGPL.
Separate the game server application from the LGPL dependent client. It is a possible solution, but usually one that most would avoid, since it makes it necessary for the player to run the server, wait for its initialization and then join its localhost. I lost account of how many people I've seen complaining about how Starbound's server works.

Cracking


If your game isn't free to play, you'd probably want to take down possible cracks popping here and there around the web. This means that you would need to get in touch with the download websites (such as mediafire or mega) and ask for the files to be removed.

The problem is that you can only ask this if you own the rights; if a crack is actually done inside SDL1.2's dll, for example, you do not own these rights. In other words, it makes the distribution of cracked files perfectly legal. Of course, the distribution being legal doesn't mean your software can be used without a valid license, so it would still be illegal to use if the user doesn't own a license to your game.

Possible solutions:
  • Make your game server dependent even in single player.
And that's the reason I haven't played Diablo 3 yet.
  • DRM.

My personal stance on piracy is quite liberal. I don't monitor it by any means, and ignore it completely. That is not the best solution, it is just the easiest and more convenient. Of course, the fact that I would not try to stop it doesn't mean I would like this distribution to be legal. If someone wants to do this, they are doing something illegal and they should know that. Knowing it is legal on the other hand makes it worse.


Game Engines, Libaries and LGPL


Being unable to use LGPL for some projects limited the usability of several engines and libraries. Some have changed their licenses, like cocos2d and SDL. Others like Qt created paid commercial licenses, to break free from LGPL developer restrictions (or user freedoms, if you prefer). There are also some LGPL licensed libraries that include exceptions for static linking under iOS, as it would be an illegal use and distribution case otherwise. Not even the FSF votes for LGPL.

But in the end, you could use LGPL and ignore the license. Don't distribute the necessary attachments and license files, nor even acknowledge the use. But, in this case, there's not much to discuss. You could use whatever you want, however you want, if you don't care about their licenses. I just hope it is a personal hobbyist project!

For the open source library/engine creators, I always preach zlib, x11 and BSD 2-clause licenses. These are the ones I use in my projects, and also the ones I use to select technologies. I usually ignore LGPL licensed technologies.


Over and Out.