8000 Fix: #7025 Fixed Mass Repair Dialog Throwing Exception When Run From Warehouse by IllianiBird · Pull Request #7027 · MegaMek/mekhq · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix: #7025 Fixed Mass Repair Dialog Throwing Exception When Run From Warehouse #7027

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

Merged
merged 4 commits into from
May 16, 2025

Conversation

IllianiBird
Copy link
Collaborator

Fix #7025

We were running into comparison errors when comparing techs because we were using mixed comparison methods. Comparing both by experience level, and then if experience levels were equal by XP OR skill level (if Elite). Then finally available time.

This creates several issues:

  • This assumes that a character with greater XP is more skilled than a character with less. However this fails to account for characters with dual professions.
  • We were not checking whether a character was Elite, but if they had level 4 in the appropriate skill. However level 4 in a skill does not necessarily mean a character is Elite (depending on campaign options).
  • The 'Elite' comparison also doesn't account for anything that might be influencing that skill (modifying the skill level, such as SPAs).
  • Finally the Elite comparison also doesn't consider how to handle a character that has higher than level 4 in the skill (at that point it reverts back to XP, rendering this special handler somewhat redundant).

To mitigate this issue I've changed up the comparison. We now only compare final skill levels followed by available minutes in the event that final skill levels are equal. I also added in better null handling, in the event we feed a null skill into the comparison (this can happen if the unit attached to the part doesn't have a tech skill).

The way the final skill level comparison works it is compares total skill level (factoring in all modifiers). This means that if we're comparing two techs we're sorting based on who has the highest skill. Not who has the highest experience level (green, regular, etc). This better handles irregular experience levels. Such as if the player modified their campaign options so that MekTechs hit Elite at a different time to AeroTeks, for example.

Suspected Cause

That MRMS is randomly breaking like this is concerning, but I suspect it's likely due to MRMS finally getting some attention after years of neglect. This is being compounded by two factors: with the mass adoption of ATOW skills level 4 is no longer 'Elite', it's 'Veteran'; there are now significantly more skill modifiers than when MRMS was developed.

Tests

  • Tested the warehouse repair multiple times
  • Tested unit repair multiple times

@IllianiBird IllianiBird self-assigned this May 16, 2025
@IllianiBird IllianiBird requested a review from a team as a code owner May 16, 2025 17:59
@IllianiBird IllianiBird added Bug Mass Repair/Mass Salvage Any issue around MSRS Severity: Critical Issues described as critical as per the new issue form labels May 16, 2025
< 8000 a class="d-inline-block" href="/apps/codecov">@codecov Codecov
Copy link
codecov bot commented May 16, 2025

Codecov Report

Attention: Patch coverage is 0% with 10 lines in your changes missing coverage. Please review.

Project coverage is 12.04%. Comparing base (13a135e) to head (0b7d0cd).
Report is 9 commits behind head on master.

Files with missing lines Patch % Lines
MekHQ/src/mekhq/service/mrms/MRMSService.java 0.00% 10 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #7027      +/-   ##
============================================
- Coverage     12.04%   12.04%   -0.01%     
+ Complexity     6891     6887       -4     
============================================
  Files          1102     1102              
  Lines        142196   142205       +9     
  Branches      21984    21985       +1     
============================================
- Hits          17131    17122       -9     
- Misses       123230   123250      +20     
+ Partials       1835     1833       -2     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator
@Sleet01 Sleet01 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator
< 8000 img src="https://avatars.githubusercontent.com/u/189469115?s=48&v=4" alt="@psikomonkie" size="24" height="24" width="24" data-view-component="true" class="avatar circle d-inline-block d-md-none mr-2" /> psikomonkie left a comment

Choose a reason for hiding this comment

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

Nice! Further reinforcing that we need more unit tests, as the tech sorting is not something currently covered by MRMSServiceTest.

I wonder if you could get the error triggering with new unit tests, and then verify your change fixed it....

Anyway, one comment, not something that needs fixed.

}
// Nulls at the end
if (skill1 == null && skill2 == null) {
return 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

If the skill is null for both should we try to compare their minutes remaining before saying they're equal?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure

@HammerGS HammerGS requested a review from Copilot May 16, 2025 18:26
Copy link
Contributor
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request addresses issue #7025 by refining the tech comparison logic in the mass repair dialog to resolve exceptions caused by mixed comparison methods. Key changes include improved null handling for skills, removal of outdated XP and elite checks in favor of comparing total final skill levels, and a fallback to minutes left when skills are tied.

Comments suppressed due to low confidence (1)

MekHQ/src/mekhq/service/mrms/MRMSService.java:1230

  • [nitpick] The comment still refers to XP-based sorting, but the comparator now uses total final skill levels. Update the comment to accurately reflect that techs are being compared based on their final skill levels.
Sort the valid techs by applicable skill. Let's start with the least experienced and work our way up until we find someone who can perform the work. If we have two techs with the same XP, put the one with the more time ahead.

@HammerGS HammerGS merged commit 2aa3a7b into MegaMek:master May 16, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Mass Repair/Mass Salvage Any issue around MSRS Severity: Critical Issues described as critical as per the new issue form
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Issue] Mass Repair Warehouse Functionality Partially Functional (Nightly 1860)
4 participants
0