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

[BUG] Loading an LCP with a frame on a higher LL than all itens for the frame breaks licenses for all mechs #2536

Open
The5thsPledger opened this issue Oct 1, 2024 · 0 comments

Comments

@The5thsPledger
Copy link

Describe the bug
If you add an LCP adding a frame on higher License Level than the other itens (weapons, systems, mods) for this frame's license, the console throws the following error message:

ERROR: Cannot read properties of undefined (reading 'unshift')

To Reproduce
Steps to reproduce the behavior:

  1. Create an LCP with a new frame on LL2 (tested on HA, but should have the same behavior on any Manufacturer) and any item on LL1 for that frame (tested with system and with mod, both at the same time and individually)
  2. Manage Content --> Install Content --> Select your test .lcp file --> Install
  3. Console should pop-up the error message
  4. Close the Manage Content Packs modal
  5. Try opening any license (including core licenses). Same result on level up, tactical profile or compendium.

Expected behavior
Best behavior: All licenses load successfully.
Good behavior: All core licenses and licenses from other LCPs load successfully, with an error message only affecting the licenses from the .lcp

Screenshots
image
image

Desktop:

  • OS: Windows 11 Pro
    • Version 23H2 (OS Build 22631.4249)
  • Browser: Microsoft Edge
    • Version 129.0.2792.65 (Official build) (64-bit)

Additional context
LCPs with the frame on any LL with no itens loads correctly.
LCPs with the frame and at least one item on the same LL as the frame also load correctly.

Though the error message wasn't very helpful, looking at the src/classes/pilot/components/license/License.ts file through DevTools, at line 44 it defines the const max. If there is no item on the frame, it defaults max to frame.LicenseLevel, but if there is any item it defines max as the highest LL required to unlock the item (if multiple itens, the highest LL in the array).
Notably, it doesn't count the frame as an item, so if you have a system on LL1 and the frame on LL2 it will look through the array of itens (only 1 system) and get the highest LL to unlock it, in this case 1.

Later on, it defines Unlocks based on max.

And finally, at line 57 it tries to this.Unlocks[frame.LicenseLevel - 1].unshift(frame) and throws the error.

Workaround
Create a placeholder item on the same LL as the frame.
Haven't tested at a level above, but should work too.

Suggestions
To make this kind of LCP load, I'd suggest setting the max based on the higher of the 2 figures, between higher LL required for itens and LL for the frame, rather than only looking at the LL for the frame when there are no itens.

To make the rest of the licenses still load, even with a "bad" LCP, I haven't checked the code, but I'd guess the catch exception is stopping the return of the function, so maybe i different way of handling exceptions should fix that. Will try to look at it at a later date and edit the suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant