Friday, June 1, 2012

Railworks blueprint replacer

Download the latest (jar) (current version: 1.35 2012.06.01)
Download the latest (exe) (same as the jar, so you still need java runtime, but the exe loader gives more memory for the program, and checks for java version, and works when the run paths in system aren't set, and nothing happens on double click on jar)
If you did everything as written here, and you don't get any error message, but the application still not works, try running it in admin mode, especially if you want to open files in program files, because windows have a "fantastic" access right management, so it may deny the file writing of this application there.

If you have a good idea for a new function to this program, feel free to write it in a comment below, or send me an e-mail with your ideas (found below on the end of this article).

If you like this program, and you want to thank it:
Updates:
January 15:

  • added a function to save and load the whole table with all cells (in case if you want to replace with same settings in different time, or just to save what you've modified to what)
  • added table control icon at the right top corner of table, to hide columns, pack table
  • some other cosmetic changes
January 16:
  • Added a version with fixed multithreading (multiple cpu core usage) 

January 18:
  • Fixed file choosing windows (now these store the last location) per session
  • Added config file making/loading, so you can set a default directory for the application, which will be saved to config.cfg next to the application, and will be re loaded at each restart

January 19:
  • Added "Assets" directory blueprint file tree view and file list caching
  • Added function to double click on blueprint files in tree view to set them as desired blueprint in selected table row(s) which got now green highlight.
January 28:
  • Some optimizations
  • Fixed file filter stacking bug at file choose
February 4:
  • Some optimizations, that causing 20x faster (really) replacing in big files (on smaller files fe. scenery you won't notice at much improvement, unless if you have SSD). Now serz-ing takes longer time than the replacing itself. (for example replacing all of the ~2500 signals and mileposts and speedsigns. on hagen-siegen before took ~2 min on my pc now it takes 10  sec.
  • Some bug fixes
February 7:
  • Replaced backup saving code with a newer implementation (older java file libraries have problems with windows file locking)
  • Added a tool to toggle, enable or disable shadow casting in light blueprints. Select a file or directory in assets file tree, then right click to open the popup menu. If a directory is selected, all light blueprints will be changed in directory, but not in it's subdirectories.
  • Youtube video about the new function
February 8:

  • Fixed serz problems on filepaths that contain whitespace characters
February 10:

  • Fixed misaligned blueprint data fill when columns were hidden
February 11:
  • Added automatic online checking for new version at startup
February 16:
  • Added track network offsetting (raise/lower tracks, by setting an offset), this setting can be found in "Tracks" menu. It will only work if there are tracks.bin/xml file opened, otherwise, it won't have effect.
  • Added object offsetting (raise/lower height per object types by setting an offset in table), these are found at heightoffset column in table.
  • For both, if you don't want to change something, just leave it on 0. You can use negative numbers too.
February 21:
  • Now height changing works on simple lofts, and road lofts too
February 22:

  • Bug fix at height changing, and some optimizations
March 20:

  • Added new feature: dav file decoding to wav. It does the same as Ben Laws's Dav Decoder, but here you can select and convert multiple files at once, and you can select directories too (where the program will search for dav files and decode them). You can find this new feature in Assets/Decode Dav files menu
May 1:
  • Added a version that uses exe wrapper, to pre set max memory usage, and checks for required java runtime version.
June 1:
  • Added new feature: zip to rwp. With this you can convert plain zip addon releases to rwp format. It works similarly like the dav decoding feature. You can select multiple files, or directories to convert. This feature can be found at Assets/Zip to RWP.

I've wrote a simple Java application to mass replace blueprint references in railworks data xml/bin files. I'm tested it on scenery tiles, and tracks.xml(tracks.bin) to replace signals, and tracks and track rules. But it will probably work on any railworks xml/bin files that have blueprint references. (it will work on those too that haven't got blueprint references, just won't list anything though)
For example i've replaced all kind of german signals on Hagen-Siegen route, to hungarian signals, in 5 minutes.
Short tutorial with new function
Light shadow cast switch tutorial
Another tutorial

You can raise/lower track network, or objectst too, and you can bulk switch on/off the shadow casting of lights in game.

And yes you can do some of this with RWTools(like you can with any text editors), but with those you can do a lot of mistakes. Search for blueprint copy paste the tags, missing character mistakes, etc, and you cant replace multiple different blueprint references at once.
The application is pretty simple, for those who know what is provider, product, and blueprintID, so basically what is blueprint in RW.
Usage:
  • File menu/Open files (you can select more but of course the processing will take longer time)
  • Select one or more blueprint types (trackbedrumble, trackrule, etc)
  • Click on Filter button to populate the table
  • Find what you want to replace, and fill(double click to edit the cells) the desired<something> cells with the desired new blueprint reference.  Or double click on blueprint file in the tree view.  If you don't want to change something, then leave it's "desired" cells blank, so the application won't touch them.
  • If you're done, then click on Replace items button, and the application will replace all of the blueprint references in the file(s) where you filled ALL the three cells (if desiredProvider/product/blueprintid is missing, it won't modify those references). The processing time will depend on how big is the xml you modify, how many things you want to replace, how many xml files do you modify. For example replacing around 30 different signal blueprint references and 2024 pcs of signal instances on Hagen siegen took about 30sec processing time.
  • If you have multicore cpu, the program can use any cores if there are enough xml files opened, as every xml processing runs in seperate thread. So if you have a quad core cpu, with one opened xml it will use one core, but if you opened at least 4 files, it will use 4 cores (i hope :D ).
  • Also you can sort the rows by columns, by clicking on column headers
The application makes backup(renamed with .bak extension) from original bin files. If it finds an existing backup file then it will create a new backup with an increasing number after the bak extension starting with 0, and the highest numbered will be the latest backup (fe bak, bak0, bak1, bak2...).
It may have bugs, if you find any feel free to comment it here.

Important: this program calls serz.exe to convert bin to xml and back, so you need to put a copy of serz.exe(it can be found in railworks directory) next to this program. Otherwise you can only open .xml files, but not .bin.
Another important thing: Always make sure that you've loaded the appropriate blueprint libraries in editor that you going to use for replace, or the replaced object won't appear, or won't work correctly.
If you load a lot of files (scenery of a big route), java can run out of memory (it uses max 330 mbytes max at 32bit, and 1 GB at 64bit). When this happens you will notice that the program don't responds for longer time, and the program window sometimes blinking. If this happen, try with fewer files per session. Or start this program from command line, or make a shortcut for it, with -Xmx parameter (case sensitive!) , something like this "java -Xmx3000m -jar replacer.jar" -Xmx3000m means java can use maximum 3000mbytes of memory.

For the application, you need a Java 7 runtime Download

And here is the application itself: Download rw replacer (if java is correctly installed, you can run replacer.jar like any other executable file. If you can't you can try to open a command line where the .jar is, and execute "java -jar replacer.jar" command.

Tips:
  • Tracks.bin in Networks directory of a route contains everything that is connected to track infrastructure (signals, tracks, track rules, track rumble sound, overhead wire blueprint references) other bins in there are self explanatory
  • Scenery directory have the scenery objects per tile
  • in scenario directories, by modifying scenario.bin you can replace rolling stocks too with this application.
  • write the replacing texts in the table carefully. Just a missed character, and railworks will fail to load that object.
  • you can search in table by pressing ctrl-f
  • if you experiencing freezes and after some time "Out of memory" (on console) error messages loading huge bin files like Northern Europe route's track.bin/ or a lots of bin files you need to set the memory that can be used by java higher(actually for northern europe 2000 mbytes are enough). This can be done by starting the program from command line (or make a batch file for it) with java -XmxNUMBER -jar replacer.jar NUMBER is the max size of memory that can be used by java. -Xmx3000m means 3000 megabytes (of course the limits of os, and java runtime are still in effect, so you can use settings over 2100 megabytes only if you have 64bit OS and you've installed 64bit java) Example batch for 3000 mbyte max memory usage (copy this next to replacer.jar, and run this bat file) or use the alternative exe launcher, see the link on the top.
If you have problems and you did everything as it written here, report it on kokszalami(at)t-online.hu email

You can freely distribute this program, so you're allowed to upload it on any free sites, but not on pay to download sites like uktrainsim. If you upload the program somewhere, please make a link to this article too, as source.

15 comments:

  1. I wanted to list tracks.bin from new Scottish ECML and it don't want to work. I've tried v1.2 and new 1.33. Other routes are listed fine.

    ReplyDelete
    Replies
    1. try to run it as written above: open a command line and try java -jar thepathtoreplacer.jar and see what's written there.

      Delete
    2. By the way, for me the file works. Check if you have write access to that folder, and make sure you have the serz.exe used by replacer, maybe you didn't do it at the last railworks update, and something changed.

      Delete
  2. Wanted to change back Albula v2.0 to a normal gauge track as it was in v1.0 but it doesn't seem to work. Changed track rules, changed junction geometry , everything in it's right place but in-game the track is not visible. Any ideas ?

    ReplyDelete
    Replies
    1. hi it's an obvious question but did you clicked on execute? :D is the newest serz.exe provided to the replacer?
      The track is not visible at all? This happens if you aren't loaded the blueprints of the new track in route editor (in blue box with checkboxes), or if you used wrong provider/addon/blueprint path.

      "changed junction geometry" what do you mean? You can't change only the junction geometry, only the full tracks.

      Delete
  3. Yes i did press execute. I believe it's the latest serz , since the game is up to date. The track is not visible , however i forgot about the checkbox (will return with an answer).
    About the junctions i meant the lever blueprint which is visible in blueprint filter. If it doesn't work it doesn't mean the replacer has a problem, might be just a railworks bug, because as i know so far railworks does not tolerate to well multiple track rules on same route.And also an important thing might be the fact that i tried this on the original route file not on a clone.
    And in the end , congrats on your M62 project. Me and my team are also working on a route (based in Romania) and proper rolling-stock. So far we have released the CFR class 43 (3400kw) electric locomotive and one passenger carriage. Add-ons are freeware and available on www.train-sim.ro. Cheers !

    ReplyDelete
  4. The Checkbox did the trick. Thanks!

    ReplyDelete
  5. serz.exe isnt detected in the same directory....plz help me...this is showed to me if i open the replacer....

    ReplyDelete
    Replies
    1. You need to copy a serz.exe (it's in TS2013/railwork directory) next to the replacer. As it is needed to decompress and recompress the bin files.

      Delete
  6. Hello! How do I remove Blueprint? I would like to remove some Blueprint, like overhead electrification, and gantries!

    ReplyDelete
    Replies
    1. Currently replacing to empty blueprint (ie removing) is not possible, maybe later

      Delete
  7. seems i have a problem with large track.bin files; Once editing all the things to change and click execute t says "working" once that disappears i check the file to see if things have changed, but it doesnt update the .bin/.xml files, any ideas?

    ReplyDelete
    Replies
    1. Which you tried? bin or xml? If not works try manually convert to xml, then load it to replacer, so the bin conversion problem can be ruled out.

      Delete
  8. Hi, i've tried tried both XML and BIN files, sometimes i can get it to work on western mainlines route. but can never get it to work on the north,south, west london and thameslink lines.

    ReplyDelete
  9. Hi. I'd like to try this tool.
    Would it be possible for it to be reuploaded as the version on Rail-Sim.de does not work because Java has been updated since.

    ReplyDelete