8000 Fix: Fixed Processing of Profession Salaries in the Event New Profession Added Since Campaign Last Loaded by IllianiBird · Pull Request #7059 · MegaMek/mekhq · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix: Fixed Processing of Profession Salaries in the Event New Profession Added Since Campaign Last Loaded #7059

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

IllianiBird
Copy link
Collaborator

When we load a campaign we transcribe profession salaries to the campaign. If a new profession were added this could potentially fail. The end result would be the remaining professions would all receive default salaries.

This isn't a huge issue currently as, concerning the recent addition of professions, we want them to have default salaries anyway. However, this would become a problem if a new profession was added in the middle of the profession enum, rather than at the end.

This PR resolves the problem.

@IllianiBird IllianiBird self-assigned this May 20, 2025
@IllianiBird IllianiBird requested a review from a team as a code owner May 20, 2025 01:56
@IllianiBird IllianiBird added Bug Campaign Options Relates to, or includes, campaign option changes Severity: Medium Issues described as medium severity as per the new issue form labels May 20, 2025
Comment on lines 5931 to +5943
} else if (nodeName.equalsIgnoreCase("salaryTypeBase")) {
Money[] defaultSalaries = retVal.getRoleBaseSalaries();
Money[] newSalaries = Utilities.readMoneyArray(wn2);
Money[] defaultSalaries = campaignOptions.getRoleBaseSalaries();
Money[] newSalaries = Utilities.readMoneyArray(childNode);

Money[] mergedSalaries = new Money[PersonnelRole.values().length];
for (int i = 0; i < mergedSalaries.length; i++) {
mergedSalaries[i] = (newSalaries[i] != null) ? newSalaries[i] : defaultSalaries[i];
try {
mergedSalaries[i] = (newSalaries[i] != null) ? newSalaries[i] : defaultSalaries[i];
} catch (Exception e) {
// This will happen if we ever add a new profession, as it will exceed the entries in
// the child node
mergedSalaries[i] = defaultSalaries[i];
}
Copy link
Collaborator 8000 Author

Choose a reason for hiding this comment

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

While I was in this neck of the woods I took the opportunity to clean up xml parsing. This is the only section with actual functionality changes.

Copy link
codecov bot commented May 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 12.38%. Comparing base (3b8700c) to head (ca3a326).
Report is 1 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #7059      +/-   ##
============================================
- Coverage     12.38%   12.38%   -0.01%     
+ Complexity     7246     7244       -2     
============================================
  Files          1117     1117              
  Lines        144483   144478       -5     
  Branches      22276    22276              
============================================
- Hits          17898    17890       -8     
- Misses       124722   124725       +3     
  Partials       1863     1863              

☔ 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.

@HammerGS HammerGS requested a review from Copilot May 21, 2025 00:43
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.

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Campaign Options Relates to, or includes, campaign option changes Severity: Medium Issues described as medium severity as per the new issue form
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0