Train Simulator 2021 Guide

[How to] Stop the game crashing when 'Updating scenario database' / 'Saving scenario database' for Train Simulator

[How to] Stop the game crashing when ‘Updating scenario database’ / ‘Saving scenario database’

Overview

A guide on how to find and remove corrupted scenarios / routes. This is important because any scenarios or routes past the point of corruption will not show up in-game, even if you have them installed.

Intro

There’s been an issue with the scenario database for years now and as dtg don’t seem to have any intention of fixing it, I decided to put this guide together to help those facing it.

If you’ve got a lot of corrupted files, this can be a really major issue and I’m surprised dtg haven’t made fixing this a priority as it’s pretty difficult and time consuming to solve.

Even though the game will still start and can still be played if you encounter this issue, you’ll have many missing scenarios and routes, because the database could only be compiled to a certain point.

The cause of this issue isn’t totally reproducible, but it seems the more workshop items you subscribe to in a short period of time, the more likely some are to become corrupt. To avoid it happening in the future, subscribe to one workshop item at a time, that way, you know the scenario / route that’s causing you problems straight away if your game crashes.

I’d recommend unsubscribing from all workshop scenarios before continuing, as if you don’t, steam will automatically reacquire them. If steam does reacquire them, they may be corrupt or they may not be, it seems to be completely random.

Program

I’ve made a program that will diagnose and solve your database issues for you.

Warning: While I’ve tested it thoroughly over the last few days, it may cause issues for some people as I can only test it in so many situations. While it’s extremely unlikely there’ll be any big problems, make sure you backup your ‘Content/routes/’ folder just in-case.

Source code[github.com]

Download[github.com]

Steps the program takes to try and fix your database:

  • Finds and moves all workshop scenarios to the backup folder if found.
  • Checks for scenario editor corruption and moves the files to the backup folder if found.
  • Checks if the steps above fixed the issue, if they didn’t: has a redundancy that moves route folders out of the routes folder 1 / 5 at a time, loading up the game in between, until coming across the faulty route, then goes through each scenario in that route until it finds the corrupt one. This step is really finicky, sometimes it works and sometimes it doesn’t, the steps above should always work though.
  • If there’s still problems after the step above, it will go through all logmate files that have been created and find all the errors, outputting them to Railworks/Error-(time).txt

The folder the program backs up your content to is C:/Users/YourUser/TSFixCorruptedScenarioDatabase/

I’d recommend using the program as I haven’t found a reliable way to check if a scenario is a workshop scenario by yourself. (The way the program does it is by scraping all steam workshop train sim content then comparing scenario names in the xml files to the scraped ones, this would be really tedious to do yourself, especially with a lot of scenarios.)

If you really don’t want to use the program, follow the guide below.

1. The easy way

This method is the easiest, but by doing this, you’ll need to re-download train sim entirely, including all of your purchased dlcs; you’ll also have to re-install any third party dlcs and unsubscribe from all of your workshop items. While this seems always work, I’d recommend the other methods, especially if you have a lot of dlc, as they’ll probably end up being less time-consuming.

  • Unsubscribe from all train sim workshop content.
  • Uninstall train sim.
  • Install train sim and any dlcs / third-party dlcs.
  • Only subscribe to one workshop item at a time from now on, as the more you subscribe to at once, the greater chance there is of the content becoming corrupted.
  • If you do run into this issue again and have only been downloading one workshop item at a time, you can search for ‘ScenarioProperties.xml’ as described in the next part, order by ‘Date modified’, then right click ‘Open file location’ and delete the folder.

2. File size / scenario editor corruption

To check if this is the problem in your case, go to your Railworks/Content folder and search for ‘ScenarioProperties.xml’, hold control and zoom in with the scroll wheel twice until you see something like this:


If you don’t have the ‘Size’ header, right click on the header and tick the ‘Size’ box.

Order the files by Size and if any are over 500kb or so, they’re more than likely corrupt. I have tons of scenarios and the largest non-corrupt one in my case is 300kb.

Make sure you let windows finish searching completely before continuing, it will take a while if you have a lot of scenarios.

To remove the corrupted scenarios, right click on the ScenarioProperties.xml files that are corrupted and ‘Open file location’.

Delete the scenario folders that the files are inside.

3. LuaCreator

Download LuaCreator[www.hollandhiking.nl].

When you start it up, you’ll see something like this:

The only things you need to input are the ‘TrainSimulator directory’ and the ‘LuaCreator directory’.

The train simulator directory being your Railworks folder and the LuaCreator directory being the place you installed the program to.

Once you’ve done you should get a screen like this:

Under ‘Tools’, click Routes/Scenarios and you’ll see something like this:

Find and delete invalid routes

Scroll to the bottom on the ‘Routes’ side and if any have a Red mark next to them, it means they’re corrupted. Click on any that are corrupted and press ‘Delete route’.

Find and delete invalid scenarios

Click on each route you have and scroll to the bottom of the scenarios section. Click and ‘Delete Scenario’ on any which have a name that includes ‘InvalidProperties’ with a Red mark next to them.

Example of a corrupted scenario:

4. Resetting your cache (Always do this after removing routes/scenarios)

After doing the steps above, you need to clear your scenario database cache.

To do this, go to Railworks/Content and delete the following files:

  • RVDBCache.bin
  • RVDBCache.bin.MD5
  • SDBCache.bin
  • SDBCache.bin.MD5

Make sure LuaCreator is closed and start up Train Sim and after a long wait for ‘Updating scenario database’, your game should start up with no issues.

If the game still crashes it means the game ran into another corrupted scenario/route. You have to keep repeating step 3 and deleting the files above until the game starts up correctly. Make sure you restart LuaCreator after each game crash so it can reload your routes / scenarios and make sure LuaCreator is closed when you’re starting up the game.

It may take many tries, especially if you’ve subscribed to a lot of workshop items at once, as that seems to be the main way corruption like this happens.

A good thing to keep track of during all of this is the size of the SDBCache.bin file when train sim crashes. This is good because you know if you’re making progress. For example, if I remove some corrupted scenarios when my SDBCache.bin is 9446kb, then I delete the cache and start the game again, SDBCache.bin may now be a higher file size (eg 10000kb) when it crashed. This means the game managed to compile more of the scenarios and it means you’re making progress.

If you can’t find anymore corrupted scenarios or routes, go to step 4.

5. If all else fails

If you’ve tried all of the steps above and the game is still crashing, you’ll need to use LogMate to try and diagnose the problem yourself.

To run train sim with LogMate, add the following to your launch options (Library -> Right click train sim -> Properties -> Set launch options): -LogMate -SetLogFilters=all

Make sure to reset your cache as shown in step 4 before continuing.

Start the game and don’t do anything with the LogMate window, just let it run in the background.

Once the game crashes, find the latest log file in your Railworks directory. Note: Don’t use the ‘Open’ button on LogMate as that doesn’t seem to open the correct log file most of the time.

First, press Control + F and search for ‘error’.

Those error messages will give you a clue to the route/scenario that’s causing you problems. An example in my case being:

(The error shown above isn’t actually a problem, as the game and mountain pass route both run fine, it’s just an example of what an error looks like)

If there are no errors, scroll to the bottom of the log file and see the last actions that the game made, these could give you a clue to the scenarios causing the issue.

If you can’t figure out how to fix the errors, leave a comment and I’ll give some pointers and add those to the guide.

If you still have issues after fixing the errors:

  • Restart your game a couple of times and go through the steps again.
  • LuaCreator doesn’t seem to always pickup the corrupt properties files, so you may also want to try restarting it a couple of times to make sure you’ve removed them all.
  • Restart your computer.

Conclusion

This seems to be a really common issue for people and it’s a shame that dtg don’t seem to have any intention of fixing it (there are posts regarding this going back 3+ years).

Thanks for reading and I hope this guide helped 🙂

SteamSolo.com