WEKarnesky / solarisskunkwerks

4 stars 1 forks source link

.ssw Files Don't Load, Cryptic Error #10

Closed Moonsword22 closed 5 years ago

Moonsword22 commented 5 years ago

Describe the bug Attached files do not load, instead loading a dialog box with a cryptic, apparently meaningless error message such as "-13". The mass open/resave function exhibits the same behavior.

The files work with SSW version 0.6.83.1.

Sample files attached here: SSW_Experiemental_Load.zip

To Reproduce Steps to reproduce the behavior:

  1. Load one of the attached .ssw files

Expected behavior The 'Mech should be parsed and opened with all the equipment in good order.

Desktop (please complete the following information):

Moonsword22 commented 5 years ago

Just confirmed the files don't work with Experimental 70.1, either. Whatever's going on, it's not related to the security-focused changes to the XML parser.

WEKarnesky commented 5 years ago

I've tracked it down to an index out of bounds issue in private void LoadMechIntoSSW() in dlgOpen.java.

I don't have time to dig further at the moment, but should help track down later.

Algebro7 commented 5 years ago

This bug is caused by a bad CT point calculation in SSWLib/src/states/stChassisISESBP.java:

    public int GetCTPoints( int Tonnage ) {
        return IntPoints[GetIndex(Tonnage)][0];
    }

[...]

    private int GetIndex( int Tonnage ) {
        return (Tonnage - 100) / 5 - 1;
    }

GetIndex is going to return a negative number for most mechs, which will cause an exception when indexing into the IntPoints array. I've decompiled 0.6.83.1 and the calculations there are totally different, so it looks like we have outdated code for SSWLib. I'll push the fix for this particular issue and hope there aren't a lot more bugs due to an outdated source tree.

Algebro7 commented 5 years ago

@Moonsword22 can you test the latest commit to develop and reopen this ticket if you notice any other issues? I was able to load all the mechs in your sample after that patch.