Friday Facts #51 - First MP Game

Posted by Tomas on 2014-09-12

Hello Factoriators,

greeting from rainy Prague. Bad weather makes perfect environment for making good development progress and that is imho exactly we did this week. Just before we start I have to share this picture I came across when checking out Factorio subreddit. I find it super funny. The Factorio subreddit has an active community and it is becoming a good alternative to the forums.

10 >= 10

The 0.10.10 was released today. It is yet another attempt at a stable 0.10.x release so we can finally close down this chapter and completely move on to the work in the master branch. The 0.10.x is historically first release where number of bugfix releases will be higher than the release number. Let's hope this will not become a rule:)

Multiplayer Progress

This week has seen some good progress in our master branch. Cube has been busy with optimizing the effective throughput we can get when sharing the maps over the network. The change that should bring the biggest effect is switching from polling the incoming socket once a tick (every 1/60th of a second) to running a separate thread that will block on the incoming socket. The advantage here is that when the map provider receives a request for a certain block from the map it will respond immediately and not wait till the next tick (as it is now).

Another bigger task we have done is something called the desync recovery. The thing is that the determinism desyncs will be quite frequent in the beginning. It would be rather annoying for the players if their game would just stop/crash now and then complaining about determinism problems. Here comes in the desync recovery mechanism. If the desync is detected (based on regular CRC checking) then the player(s) who is desynced will automatically reconnect to the game. This effectively means that the game pauses, desynced player's Factorio redownloads the map from the others and then all players can continue playing as if nothing happened. As a bonus there is a desync report generated (containing log file, reference and desynced save and replay file) that should help us in figuring out what the problem was.

First Multiplayer Game

Our efforts have culminated yesterday when me and Kovarex had a regular half an hour LAN game. Until now it was all about tests and 20 seconds lasting mini attempts. This was actually the very first real game we tried.

So we made a constrained map without enemies and basically played through the initial phase of the game all the way to automating the research for red and green science packs. It was a great fun. Building the factory in two people, dividing tasks, shouting at each other over the room (we will definitely need some in game marking/planning tool), getting each other in the way. It is really amazing to see couple of month's efforts work out like this.

There were still some quirks with setting up the connection between different systems (here OSX and Win), but these will be solved soon. Also we had quite a few determinism desyncs (probably related to inventory manipulations). But because of the desync recovery feature mentioned above these were a mere small annoyance for the gameplay experience. The end of the game came when Cube tried to connect as well and Factorio crashed deep in Windows socket code:)

Tank and the Masks

The model for the new tank is finished. Now we need to actually integrate it functionally in the game. Recently the graphics department has had an upper hand - there are already a few assets finished that need some programming efforts to appear in the game. This is quite a new situation for us:) The reason for this is basically a lot of programming time we have allocated to the multiplayer and bugfixing.

The new tank already contains masks for different player colors as you can see on the image below. Mask is a layer containing certain parts of the image in greyscale. This layer is then tinted by the engine and the effect is that entity can be cheaply displayed in different colors. With the multiplayer coming we will need to revisit a few existing entities to create masks for them, namely the car, turrets, walls. It might be surprising to see walls in the list, but the reason is that otherwise the player could mine the enemy walls (really fast) instead of destroying them.

Using masks is also interesting for the modders. Because they can create new types of the entity with very little effort. We have already made changes to the engine in master branch that pretty much any animation can integrate masks. The biggest gain we can picture now would be for expensive animations like biters (and other enemy units coming in the future).

Let us know what you think at our forums.