• We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.

EU4 - Development Diary - 31st of October 2017

Good morning all. We're back with another dev diary. As mentioned last week we have been working on something behind the scenes. In a nutshell, we have put a tonne of work into multiplayer, to tackle some long-standing thorns such as Hotjoin and Cross-platform issues. Many users have raised issue with these functions not working well, or indeed at all, and with good reason! Like last week, I'll hand the mic over to the man responsible for the bulk of this, @Alexivan

################

Hi. I’d like to start by saying that multiplayer support for our games is not an easy task, and sometimes we dev’s joke that it would be easier to simply cut that feature. But, seeing people having a great time playing together inspires us to continue supporting it. Not to mention that we love playing ourselves in our Dev Clash MP.

EU4 has a lot of complexity when it comes to multiplayer as it has the largest amount of configurations MP can be played on among our games, the factors being:

Platform
DLC configurations
Hotjoin
Start dates/save game
Custom nations
World randomization
Random new world

Our efforts so far have mostly concentrated on hosting a game with 1444 and continuing a save game. During the development of this update however we’ve put some more effort on making MP work across all the different configurations, in the priority order of the list. I’d like to share some wisdom about some of the issues we’ve encountered and methods we use.

When we started working on the MP for the upcoming 1.23 Persia update the goal was to get hotjoin working again. Hotjoin is basically copying over the current state of the game to the newly connected player which in theory is a pretty simple thing to do. There are two parts of the gamestate that need to be synchronized: all the data that is saved in the gamestate, and all the data that is not. We’ll call these categories persisted and cached.

Starting with the persisted data we noticed that saves were not being saved as they are read, meaning we modify the savegame while reading and writing it. While this works for the standard setup as everyone applies the same changes when they all load the game it causes hotjoin to desynchronize as only the hotjoiners are doing the changes.

We added a console command called check_save to help us find this issue, it’s a console command that saves the game, loads it up, and saves it again. This helped us find most of the issues with savegame inconsistency. Most of the issues here came from calling gameplay logic when reading the save, so reading a country government could for example apply some modifiers or reset some variables. Otherwise it was mostly variables not being written/read properly.

For the cached data we had to do a couple of things. First we added a recalculation step which happens when you load a savegame or a hotjoiner enters the game, this step recalculates all the cached data. A lot of the data in this step was derived from the persisted data, which worked fine. Some however was dependent on other cached data, causing things to be recalculated differently, we solved this by moving all cached values into a separate container so we could easily clear all cached data before calculating it, guaranteeing the same results.

Another issue with persisted data would be load order dependencies. There are two common issues here, the first one being that objects that were loaded sometimes put themselves in a list. This causes the list to be sorted by the order of objects being loaded, rather than whatever order they were in when saving the game. Once these lists were identified the easy fix was to simply sort the lists in a deterministic order. The second issue is that objects being read from the savegame are sometimes referencing other objects in the savegame, which haven’t been read yet. The thing we do here is save the object ID mentioned in the save and dereference in a step after the save has been loaded.

After check_save resulted in the savegames with no differences, we started running MP tests to find more issues. One thing that helps us a lot with this is the randomlog, which is a tool we use to help us track desynchronized computation sequences. The way it works is that we add lines in the code which prints to the randomlog, when a desync happens we can then compare the randomlog data of the host to that of the desynchronized client and see what the client did differently. This shows us what happened incorrectly, but usually isn’t enough to pinpoint why. If we can’t figure out what happened we add more entries in related code to try getting closer to the source issue. This can be a slow process where we sometimes have to add more logs lots of times to help us find the issue, especially if the desync doesn’t happen consistently due to multithreading or the desync being a rare case.

As QA time for finding desyncs is limited, testing was slow, and we still knew we had a lot of desyncs to find so we had to start automating tests. For this we updated the standalone server build and improved on the script we use to help us find desyncs faster, this also allowed us to run the automated tests over the weekends and nights and fix during the days, which greatly improved our efficiency, the script was also updated to restart when an issue has been found, generating a lot of different desyncs.

As we now could get multiple desyncs with logs and data we needed to improve our method for collecting desync data, so we copied over the OOS dumps system from stellaris. This system copies over data relevant to the desync into a unique folder inside Paradox Interactive/Europa Universalis IV/oos folder. The name of the folder is a unique hash describing the desync and can be used to match the desync between clients and host.

All in all, I’ve been working on all this for the last 7 months with a lot of help from the team, a lot of systems had to be fixed and specialized solutions had to be invented, it’s been quite a bigger task than I initially expected. I was hoping to get it to a perfect state for this release but it’s not quite there yet.

So if you get desyncs I recommend letting us know, try giving us as much information as you could and more specifically how the game was set up, the OOS dump, and any savegame you might have loaded. If you manage to get desynced consistently I recommend starting the game with the “-randomlog” and “-hardoos” launch options on the host to generate better data for the OOS dumps. But otherwise it might be better to keep it turned off as it uses memory and slows down the game. I’m going to look into if we could potentially use something like the crash dump uploader to make it easier for you guys to send this data to us.

tl;dr: A lot of work on multiplayer has been done, and it will continue. Cross Platform, Cross DLC, and Hotjoin should now be working. Reporting your desyncs might get them fixed faster. If you guys have any questions or suggestions I’d be glad to discuss in this thread.

##################

Thanks Alexivan. Next week we'll have another mixed bag of Cradle of Civilization goodies. With the release only a couple of weeks away, we need to round off on all the new things coming in 1.23 and Cradle.

Although, this dev diary doesn't have any images in it...hrmm, let's change that.

eu4_mill_360.gif
 
Have you replaced the option for +1 combat terrain bonus for having a merchant in a trade node you control? In the latest video I see a siege bonus instead.

All announced features are subject to balance testing, meaning some modifiers, costs etc can be different in the final product compared to what are said in the dev diaries. The combat bonus was one such case, where we decided to change it to a siege bonus (siege ability and bonus v fort)
 
Nice looking, is it something that is going in game at some point?

Image can be still or moving.
Technically no, a moving picture is nothing but a bunch of pictures changing faster than your eye can see (Ok it's a bit more complicated these days because storing a bunch of images all containing to a large degree the same info is a waste of space)
 
And what bout dedicated server? It's a very interesting feature that might potentially solve some performance issues: for example a player launches a server and then joins a game with his client. This might help to redistribute the workload on 2 separate processes.

Another suggestion is to create a dedicated hosted cloud service: this should minimize the some individual host issues like blocked ports, possible routing troubles or performance hiccups and make it possible to choose server's location region.
 
With this big update, is also finally the cross-language OOS fixed? For a some time now there was a mod which fixed it, but it was said it will get implemented into the basegame.
Most of the people in our Mutliplayer Round play in German, but some would like to play in English.
 
Well, um, this isn't quite what I excepted given the apparent secrecy around it. Still, an improvement is an improvement.
 
So the out of sync issues between persons playing on Windows and Linux are finally fixed?
A lot of them have, internal QA tests are looking good on this front, make a report if you encounter any issues.

Will still advise my MP group of posting reports on crashes... But how important was the host launch options for that?
The launch options won't do anything for crashes, only generate more data for desyncs.

How about you keep hotjoin working from now on? It's a very weird policy to not have a marketed feature working for multiple versions of the game. Last week we had 40 minutes of rehosts in a 4 hour game.
I'm sorry to hear that, hate when that happens myself, with all the work done it's now a lot easier for the EU4 team fix future desyncs.

And what bout dedicated server? It's a very interesting feature that might potentially solve some performance issues: for example a player launches a server and then joins a game with his client. This might help to redistribute the workload on 2 separate processes.

Another suggestion is to create a dedicated hosted cloud service: this should minimize the some individual host issues like blocked ports, possible routing troubles or performance hiccups and make it possible to choose server's location region.
We have one which we use internally, and a future goal is to release that as well. Once the dedicated server is ready online server hosting could actually be a possibility, definitely an interesting idea there.
 
With this big update, is also finally the cross-language OOS fixed? For a some time now there was a mod which fixed it, but it was said it will get implemented into the basegame.
Most of the people in our Mutliplayer Round play in German, but some would like to play in English.
Cross language has gotten some work, but It wasn't a big priority for this version so there's probably some more fixes to be done there. Posting bug reports will help us find them, playing with the launch options enabled really helps for this category of desyncs.
 
@Alexivan Thank you! Resolving MP stability issues has #1 priority not only for me, but for thousands others EU4 MP-addicts that choose to spend their evenings' time plotting, scheming and conquering instead of burning their lives in LoL, DotA or WoW :rolleyes:
 
All announced features are subject to balance testing, meaning some modifiers, costs etc can be different in the final product compared to what are said in the dev diaries. The combat bonus was one such case, where we decided to change it to a siege bonus (siege ability and bonus v fort)
I really like this change, it's a strong policy but not overwhelmingly strong.

Personally I think increasing Maximise Profit from 5% to 10% would be a good small change as well because all the other policies seem significantly stronger. 10% trade power would I think make players think harder about which policy to activate.
 
Do this changes to multiplayer also fix the trade bonuses sometimes disappearing on loading a game in SP? Sounds to me like this would also be an issue with sync in MP games?
I don't think so, sorry. This is probably caused by recomputing cached data after having loaded a save, data which decides if you have the bonuses or not.

What about the MP cross-language issues? Having different languages was causing so many headaches a few versions back with my friends.
Cross language has gotten some work, but It wasn't a big priority for this version so there's probably some more fixes to be done there. Posting bug reports will help us find them, playing with the launch options enabled really helps for this category of desyncs.
 
All announced features are subject to balance testing, meaning some modifiers, costs etc can be different in the final product compared to what are said in the dev diaries. The combat bonus was one such case, where we decided to change it to a siege bonus (siege ability and bonus v fort)

Thanks! :)