1. Trouble with the game?
    Try the troubleshooter!

    Dismiss Notice
  2. Issues with the game?
    Check the Known Issues list before reporting!

    Dismiss Notice
  3. Before reporting issues or bugs, please check the up-to-date Bug Reporting Thread for the current version.
    0.32 Bug Reporting thread
    Solutions and more information may already be available.

Powertrain device discovery bug

Discussion in 'Troubleshooting: Bugs, Questions and Support' started by Arcanox, Sep 30, 2018.

  1. Arcanox

    Arcanox
    Expand Collapse

    Joined:
    Aug 22, 2018
    Messages:
    290
    I discovered a bug in the powertrain initialization function that manifests itself when a vehicle containing custom powertrain devices is the first vehicle loaded. I found the bug when loading the "Hustle and Bustle" campaign, which loads up the citybus immediately. It was giving an error in the console about not being able to find the "automaticGearbox" powertrain device type, when the file was definitely present.

    I did some debugging and pinpointed the source of the bug to line 279 of powertrain.lua:

    Code:
    local files = tableMerge(globalFiles, vehicleFiles)
    Because it's doing a table merge, any files found in vehicleFiles will overwrite the first n files in globalFiles. My custom "ecvtGearbox", loaded from the citybus folder, was in index "1" of vehicleFiles, which then overwrote index "1" of globalFiles (automaticGearbox). The line should read:

    Code:
    local files = arrayConcat(globalFiles, vehicleFiles)
    Applying this fix to my local scripts fixed the bug for me.
     
    • Like Like x 4
    • Staff Pick Staff Pick x 1
  2. Nadeox1

    Nadeox1
    Expand Collapse
    Spinning Cube
    BeamNG Team

    Joined:
    Aug 5, 2012
    Messages:
    14,685
    Thanks for finding this, we will be checking that soon :)
     
  3. Diamondback

    Diamondback
    Expand Collapse
    Vehicle Systems Lead
    BeamNG Team

    Joined:
    Apr 8, 2014
    Messages:
    1,957
    Hey! :)

    That's a very nice find indeed. I'm impressed you didn't only notice and track down the bug (that's definitely hard enough without any insider knowledge and the lack of documentation), no you also found the correct fix for it! Very nice work!

    After checking the issue I came to the same conclusion as you did, the method used simply didn't do what I was expecting it to do.
    On my machine I had to use a total of three custom devices before it started replacing actually important ones for regular cars, so that's probably why this issue slipped back when the powertrain code was created.

    In any case, will be fixed for the next update, thanks again and keep digging in the game files. :)
     
    • Like Like x 1
  4. Arcanox

    Arcanox
    Expand Collapse

    Joined:
    Aug 22, 2018
    Messages:
    290
    Excellent, glad my code skills could be of help! I've been digging into the game files to learn more about the game engine for writing mods, and I have to say, the code is very well organized! Made it pretty straightforward to locate the problem once I dug deep enough ;)
     
    • Like Like x 3
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice