Friday Facts #118 - Improving productivity

Posted by kovarex on 2015-12-25

Hello and Merry Christmas,
there are no holidays that stop us from informing you about the progress of Factorio development, so enjoy :)

Steam release date

We have been pushing the Steam release forward for a pretty long time, but we finally have a definitive release date of Factorio on Steam. The date is 25. February, exactly 2 months from now. We planned it to be in January, but we have found out, that we have to provide the Factorio package one month before the release to steam for inspection, and we need some extra time to solve all the little problems in 0.12 release. We also need to prepare the campaign and finish the trailers, so it is all done right.

Internal gui improvements

There are lot of places in Factorio where we need things to align perfectly by stretching some ui element. It was usually annoying and hard thing to do, as we solved that by custom size calculations which didn't even work always perfectly as in this example:

Here, the way we want it to behave is to just say to the gui to stretch the progress bar to be exactly as long to make the window match. This functionality was now implemented and used on many places. It is another small step to make the gui cleaner and easier to write, this is how it looks in 0.13, it matches exactly:

Train stop shows relevant info

So simple thing to do and it took us so long to do it. When you open the train station in 0.13, it shows you the list of all trains having the station in their schedule. It also shows part of the schedule and lets you open any of the trains remotely:

Latency state improvements

If you didn't know, Factorio uses certain pack of tricks that we call the latency hiding to make it feel more responsive in the multiplayer game. We explained the basics in Friday facts 83. As the power switch is going to be added into 0.13, we expect more manual wire manipulation to be done by the players, so we decided to include more of it in the latency hiding.
Here is an example of what you can see in a multiplayer game, when you connect wires to a switch:

But in reality, the game state can still look like this:

The wires are still not connected as long as the action is not applied, which may be delayed up to 2 seconds (extreme case, but possible, it depends on the latency settings). So the game remembers that you are planning to build two wires, and adds the wire connections to internal list of entities to be connected. This list is then used when rendering the game to trick you into the thinking, that the wires were connected instantly. The similar trick is done when disconnecting wires, the game has a list of entities to be disconnected and avoids drawing wires between points specified in this list. Things might get little bit complicated, when you are disconnecting wires that are only planned to be connected between entities that are only planned to be built, but all of these cases are now working properly in 0.13, and I can confirm, that it feels more comfortable working with wires in multiplayer now. The downside of this kind of work is, that when done perfectly people even don't notice it is there:)

Compilation time battle and Fastbuild - Technical

I complained about compilation times in one of the recent Friday facts, so I had to spend some time improving these to not leave it be empty complains.
Factorio has currently more than 1000 cpp files, and the compiler has to process all the header dependencies (including the big precompiled header) in every cpp file, so it is doing a lot of duplicate work. To overcome this, I made a 100 cpp files that only included Factorio cpp files, 10 in each (this is called unity/blob build). I almost halved the compilation time this way, which is already a great productivity boost.
Later, I have watched the youtube video explaining how are huge AAA games made in C++ without having huge compilation times. This finally convincmed me, that using fastbuild is a good idea. After 3 days of fiddling (and some kind help from Franta, the creator of fastbuild), I created working version of the fastbuild make file that can compile Factorio and all the needed libraries. This improved the compilation time by 15% itself. But mainly, we can configure it to use caching, and distributed builds, which might improve the build times even more. Fast build also have a way to generate visual studio project files. We can now remove these from the repository completely, and just generate them automatically whenever needed. This solves our never ending problems of merge conflicts in Visual studio files as well as missing cpp files in there when it was added by linux/mac programmer. Once we integrate it in our process fully, we will be able to spend more time by programming Factorio and less by "Compilation fix" commits and waiting for it to compile.

As always, let us know what you think on our forums.