• 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
 
A lot of them have, internal QA tests are looking good on this front, make a report if you encounter any issues.
That sounds amazing. I had essentially given up on playing MP, since I'm on Linux and the people I play with are all on Windows. Last time I tried playing MP I spent 3 hours getting immediate OOS upon game start.
 
This Dev Diary is evidence of the #1 complaint about multiplayer - You are taking resources away from the SP game in order to have it. PLEASE make Multiplayer a SEPARATE GAME with a SEPARATE TEAM working on it. I don't care for it, don't want it taking resources from the SP game or affecting SP balance in any way, and don't want the money I spend on the SP game to go towards improving it in any way. Grand Strategy are single player games at their heart and all this MP focus is not good for them. Thanks!
 
This Dev Diary is evidence of the #1 complaint about multiplayer - You are taking resources away from the SP game in order to have it. PLEASE make Multiplayer a SEPARATE GAME with a SEPARATE TEAM working on it. I don't care for it, don't want it taking resources from the SP game or affecting SP balance in any way, and don't want the money I spend on the SP game to go towards improving it in any way. Grand Strategy are single player games at their heart and all this MP focus is not good for them. Thanks!
I have never played a single MP game in EU4 and still I have to disagree with you... What you are saying makes no sense at all.. Making two games which are essentially the same just means redundant work and less money (and thus less dev time) for either game...
 
The launch options won't do anything for crashes, only generate more data for desyncs.
So I should advise host to use the launch options and then send in that?
 
This is great news, continuous rehosts are a big issue in large multiplayer games and I know for a fact that too much waiting in the lobby can discourage new people from an otherwise great experience.

Will the game have to be paused while someone is downloading the game state? How does the joining player select his country?
 
This Dev Diary is evidence of the #1 complaint about multiplayer - You are taking resources away from the SP game in order to have it. PLEASE make Multiplayer a SEPARATE GAME with a SEPARATE TEAM working on it. I don't care for it, don't want it taking resources from the SP game or affecting SP balance in any way, and don't want the money I spend on the SP game to go towards improving it in any way. Grand Strategy are single player games at their heart and all this MP focus is not good for them. Thanks!
During this patch project I've been an extra resource assigned to the project to help out with MP, the rest of the team have spent most of their time on adding features and fixing bugs. So don't worry about the patch/expansion not being same quality as always.

What's probably even more important is that there was quite a lot of bugs in singleplayer which were found when testing and fixing MP that've gotten fixed during this patch which would probably not have been looked at otherwise, so development on the MP part also improves SP. As for the money aspect of all this, I think all the SP fixes alone are worth the extra money the project spent on having me during this time.
 
I have never played a single MP game in EU4 and still I have to disagree with you... What you are saying makes no sense at all.. Making two games which are essentially the same just means redundant work and less money (and thus less dev time) for either game...

Having two titles (EU5 and EU5: Online for example) allows them to balance the titles differently. It also allows them to determine how much of the money is being spent by people who want MP (and this money can be used primarily on MP stuff) and how much by the population at large (which could be spent on the core game/SP version) - creating an MP focused team also means more specialized work which should improve that experience for the players who enjoy that sort of thing.
 
During this patch project I've been an extra resource assigned to the project to help out with MP, the rest of the team have spent most of their time on adding features and fixing bugs. So don't worry about the patch/expansion not being same quality as always.

What's probably even more important is that there was quite a lot of bugs in singleplayer which were found when testing and fixing MP that've gotten fixed during this patch which would probably not have been looked at otherwise, so development on the MP part also improves SP. As for the money aspect of all this, I think all the SP fixes alone are worth the extra money the project spent on having me during this time.

Thanks so much for responding to my rant. :)

This is close to what I was going for, hadn't realized they weren't using standard resources. P-Dox is a wonderful company (however much I rib them here) but it has transparency issues - most of them for good reasons I'd imagine. I'm already thinking about EU5 to be honest - EU4 is too mature a product at this point to expect structural changes to the design philosophy and team-makeups.
 
Yeah Desync rehosting and better hotjoin is a welcome feature for EU4.

How much effort would it take to add that to CK2 as well? Purty please with cherry on top! :oops:

(By that... I would be willing to pay for a CK2 host DLC which allows the host to resync a desynced game without rehosting)
 
Have you addressed how slowly saves transfer when hosting or hotjoining? Even playing over LAN it seems to cap out at ~50kb/s for me. It often takes minutes to transfer a 2-6 mb save file.
 
Yeah Desync rehosting and better hotjoin is a welcome feature for EU4.

How much effort would it take to add that to CK2 as well? Purty please with cherry on top! :oops:

(By that... I would be willing to pay for a CK2 host DLC which allows the host to resync a desynced game without rehosting)
Oh my god, I can't even imagine how much work it would be for CK2, I hope If that ever happens that I won't be the one to do it :p

Have you addressed how slowly saves transfer when hosting or hotjoining? Even playing over LAN it seems to cap out at ~50kb/s for me. It often takes minutes to transfer a 2-6 mb save file.
We have unfortunately not looked into improving the transfer speeds but I have noticed it being super slow sometimes, never that slow though. If you manage to reproduce this with the new version I'd love if you sent me a PM so we can gather some data, maybe we can figure something out.