Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix loading of old resizable equipment #6182

Merged
merged 1 commit into from
Nov 9, 2024

Conversation

pavelbraginskiy
Copy link
Collaborator

Fixes #6179.

Fixes old mtf/blk files with cargo, liquid storage, communications equipment, ladders, mission equipment, or other resizable gear.

New unit files store resizable gear in a format like Cargo:SIZE:5.

Old unit files store them in a format like Cargo (5 tons), and this was never addressed when the switch to the new format was made.

This reintroduces support for unit files made in this older style, which includes most of the unit files presently in MM's data.

Copy link

codecov bot commented Nov 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 29.17%. Comparing base (a7bb1b4) to head (5c0fb11).
Report is 18 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #6182   +/-   ##
=========================================
  Coverage     29.17%   29.17%           
- Complexity    13971    13975    +4     
=========================================
  Files          2628     2628           
  Lines        266564   266560    -4     
  Branches      47575    47574    -1     
=========================================
+ Hits          77771    77781   +10     
+ Misses       184910   184895   -15     
- Partials       3883     3884    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@Scoppio Scoppio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

short and sweet, would be interesting to refactor some of those operations (at a later date) to be in another component, since there is so much repetition.

@pavelbraginskiy
Copy link
Collaborator Author

You could probably just generate and parse blk files as XML if you took the time to rewrite all the code

@Scoppio
Copy link
Collaborator

Scoppio commented Nov 6, 2024

You could probably just generate and parse blk files as XML if you took the time to rewrite all the code

that is true, will put a pin on that, I'd prefer to make other things work first before moving to this kind of modernization. however we do have the benefit of being able to work however we want with the parse (which is super simple and easy to use) and not be liable to many security risks that there are with using XML parsers due to how powerful they are.

@rjhancock
Copy link
Collaborator

You could probably just generate and parse blk files as XML if you took the time to rewrite all the code

That would require loading and re-saving EVERY BLK file and still supporting the old format. BLK is NOT XML despite what it looks like.

Copy link
Member

@SJuliez SJuliez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's good, but as @Scoppio said this wants to be a static parseVariableSize() method in BLKFile

@pavelbraginskiy
Copy link
Collaborator Author

The check for :SIZE: has to happen where it happens for the rest of the parsing code to work, and I didn't want to do a heuristic-based regex match against every single equipment line before being able to make the check for etype.isVariableSize(), so I think this is the best it gets without doing a major refactor.

This I'm comfortable shipping in 0.50.1, a more involved rewrite of the BLK code I would want to have more testing on.

@HammerGS HammerGS added the Bug label Nov 9, 2024
@HammerGS HammerGS merged commit f9b96ad into MegaMek:master Nov 9, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cargo and Liquid storage fails to load correctly
5 participants